~ubuntu-branches/ubuntu/wily/ginkgocadx/wily-proposed

« back to all changes in this revision

Viewing changes to src/visualizator/visualizator/herramientas/reconstructiontool.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Tille
  • Date: 2011-05-02 08:09:26 UTC
  • Revision ID: james.westby@ubuntu.com-20110502080926-bql5wep49c7hg91t
Tags: upstream-2.4.1.1
Import upstream version 2.4.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 *  $Id: reconstructiontool.cpp 3558 2011-03-20 20:02:22Z carlos $
 
4
 *  Ginkgo CADx Project
 
5
 *
 
6
 *  Copyright 2008-10 MetaEmotion S.L. All rights reserved.
 
7
 *  http://ginkgo-cadx.com
 
8
 *
 
9
 *  This file is licensed under LGPL v3 license.
 
10
 *  See License.txt for details
 
11
 *
 
12
 *
 
13
 */
 
14
//#define _GINKGO_TRACE
 
15
#include <wx/menu.h>
 
16
 
 
17
#include <api/globals.h>
 
18
#include "reconstructiontool.h"
 
19
#include <eventos/eventosginkgo.h>
 
20
 
 
21
 
 
22
#ifdef __DEPRECATED
 
23
#undef __DEPRECATED
 
24
#endif
 
25
 
 
26
#include <vtkObject.h>
 
27
 
 
28
#include <vtkImageData.h>
 
29
#include <api/internacionalizacion.h>
 
30
#include <api/ientorno.h>
 
31
#include <api/icontroladorpermisos.h>
 
32
#include <vtkDataSetAttributes.h>
 
33
#include <vtkAlgorithm.h>
 
34
#include <vtkAlgorithmOutput.h>
 
35
#include <vtkExecutive.h>
 
36
#include <vtkInformation.h>
 
37
#include <vtkInformationVector.h>
 
38
#include <vtkginkgoimageviewer.h>
 
39
 
 
40
#define MENU_IDS_RECONSTRUCTION  4201
 
41
 
 
42
namespace GNKVisualizator {
 
43
 
 
44
        namespace GUI {
 
45
 
 
46
                class EventHandlerReconstructionTool: public wxEvtHandler {
 
47
                public:
 
48
                        EventHandlerReconstructionTool(wxWindow* pParent, GNKVisualizator::ReconstructionTool* pTool, int modeId):wxEvtHandler()
 
49
                        {
 
50
                                m_pParent = pParent;
 
51
                                m_pTool = pTool;
 
52
 
 
53
                                m_pParent->Connect(modeId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( EventHandlerReconstructionTool::OnReconstructionModeSelected) ,NULL, this);
 
54
                                m_pParent->Connect(modeId, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(EventHandlerReconstructionTool::OnUpdateMenuReconstructionUI),NULL,this);
 
55
                        }
 
56
                        ~EventHandlerReconstructionTool()
 
57
                        {
 
58
                                m_pParent->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( EventHandlerReconstructionTool::OnReconstructionModeSelected),NULL,this);
 
59
                                m_pParent = NULL;
 
60
                                m_pTool = NULL;
 
61
                        }
 
62
 
 
63
                        void OnReconstructionModeSelected( wxCommandEvent& event )
 
64
                        {
 
65
                                int modeId = event.GetId() - MENU_IDS_RECONSTRUCTION;
 
66
                                m_pTool->SelectReconstructionMode(modeId);
 
67
                                event.Skip(false);
 
68
                        }
 
69
 
 
70
                        void OnUpdateMenuReconstructionUI(wxUpdateUIEvent& event) {
 
71
                                event.Enable(m_pTool->SupportsReconstructionMode(event.GetId() - MENU_IDS_RECONSTRUCTION));
 
72
                        }
 
73
 
 
74
                        GNKVisualizator::ReconstructionTool* m_pTool;
 
75
                        wxWindow* m_pParent;
 
76
                };
 
77
 
 
78
                class MenuItemReconstruction : public wxMenuItem {
 
79
                public:
 
80
                        MenuItemReconstruction(wxWindow* pParent,int idMode, const wxString& text,  wxMenu* pMenuPadre, GNKVisualizator::ReconstructionTool* pTool, GNC::GCS::IControladorPermisos* pCP):wxMenuItem(pMenuPadre,idMode,text,text,wxITEM_NORMAL) {
 
81
                                pEventHandler = new EventHandlerReconstructionTool(pParent,pTool, idMode);
 
82
                        }
 
83
 
 
84
                        ~MenuItemReconstruction()
 
85
                        {
 
86
                                if(pEventHandler != NULL) {
 
87
                                        delete pEventHandler;
 
88
                                        pEventHandler = NULL;
 
89
                                }
 
90
                        }
 
91
 
 
92
                        EventHandlerReconstructionTool* pEventHandler;
 
93
                };
 
94
 
 
95
 
 
96
 
 
97
 
 
98
                /*
 
99
        class MenuRecontructionTool : public wxMenu {
 
100
 
 
101
                        public:
 
102
                                MenuRecontructionTool(wxWindow* pParent, GNKVisualizator::ReconstructionTool* pTool, GNC::GCS::IControladorPermisos* pCP) : wxMenu() {
 
103
                                m_pParent = pParent;
 
104
                                m_pTool = pTool;
 
105
 
 
106
                                wxMenuItem* mode;
 
107
                                int modeId = MENU_IDS_RECONSTRUCTION;
 
108
 
 
109
                                //bool enabled = m_pTool->Habilitada();
 
110
 
 
111
                                if (pCP != NULL && pCP->Get("atencionprimaria", "reconstruction")) {
 
112
 
 
113
                                        if ( pCP->Get("atencionprimaria.reconstruction","orthogonalmpr3d") ) {
 
114
                                                int modeId = MENU_IDS_RECONSTRUCTION + (int)GNKVisualizator::Reconstruction::RM_OrthogonalMPR;
 
115
                                                mode = new wxMenuItem( this, modeId, _("3D MPR"));
 
116
                                                m_pParent->Connect(modeId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MenuRecontructionTool::OnReconstructionModeSelected) ,NULL, this);
 
117
                                                m_pParent->Connect(modeId, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(MenuRecontructionTool::OnUpdateMenuReconstructionUI),NULL,this);
 
118
                                                Append(mode);
 
119
                                        }
 
120
 
 
121
                                        if ( pCP->Get("atencionprimaria.reconstruction","mip3d") ) {
 
122
                                                int modeId = MENU_IDS_RECONSTRUCTION + (int)GNKVisualizator::Reconstruction::RM_MIP3D;
 
123
                                                mode = new wxMenuItem( this, modeId, _("MIP 3D"));
 
124
                                                m_pParent->Connect(modeId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MenuRecontructionTool::OnReconstructionModeSelected) ,NULL, this);
 
125
                                                m_pParent->Connect(modeId, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(MenuRecontructionTool::OnUpdateMenuReconstructionUI),NULL,this);
 
126
                                                Append(mode);
 
127
                                        }
 
128
 
 
129
                                        if ( pCP->Get("atencionprimaria.reconstruction","volumerengering3d") ) {
 
130
                                                int modeId = MENU_IDS_RECONSTRUCTION + (int)GNKVisualizator::Reconstruction::RM_VolumeRendering;
 
131
                                                mode = new wxMenuItem( this, modeId, _("3D Volume Rendering"));
 
132
                                                m_pParent->Connect(modeId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MenuRecontructionTool::OnReconstructionModeSelected) ,NULL, this);
 
133
                                                m_pParent->Connect(modeId, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(MenuRecontructionTool::OnUpdateMenuReconstructionUI),NULL,this);
 
134
                                                Append(mode);
 
135
                                        }
 
136
 
 
137
                                        if ( pCP->Get("atencionprimaria.reconstruction","surfacerendering3d") ) {
 
138
                                                int modeId = MENU_IDS_RECONSTRUCTION + (int)GNKVisualizator::Reconstruction::RM_SurfaceRendering;
 
139
                                                mode = new wxMenuItem( this, modeId, _("3D Surface Rendering"));
 
140
                                                m_pParent->Connect(modeId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MenuRecontructionTool::OnReconstructionModeSelected) ,NULL, this);
 
141
                                                m_pParent->Connect(modeId, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(MenuRecontructionTool::OnUpdateMenuReconstructionUI),NULL,this);
 
142
                                                Append(mode);
 
143
                                        }
 
144
 
 
145
 
 
146
                                        if ( pCP->Get("atencionprimaria.reconstruction","endoscopy3d") ) {
 
147
                                                int modeId = MENU_IDS_RECONSTRUCTION + (int)GNKVisualizator::Reconstruction::RM_3D_Endoscopy;
 
148
                                                mode = new wxMenuItem( this, modeId, _("3D Endoscopy"));
 
149
                                                m_pParent->Connect(modeId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MenuRecontructionTool::OnReconstructionModeSelected) ,NULL, this);
 
150
                                                m_pParent->Connect(modeId, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(MenuRecontructionTool::OnUpdateMenuReconstructionUI),NULL,this);
 
151
                                                Append(mode);
 
152
                                        }
 
153
 
 
154
                                        m_pParent->Connect(pTool->ID, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(MenuRecontructionTool::OnUpdateMenuReconstructionUI),NULL,this);
 
155
                                }
 
156
                        }
 
157
 
 
158
                        ~MenuRecontructionTool() {
 
159
                                m_pParent->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MenuRecontructionTool::OnReconstructionModeSelected),NULL,this);
 
160
                                m_pParent = NULL;
 
161
                                m_pTool = NULL;
 
162
                        }
 
163
 
 
164
                        void OnReconstructionModeSelected( wxCommandEvent& event )
 
165
                        {
 
166
                                int modeId = event.GetId() - MENU_IDS_RECONSTRUCTION;
 
167
                                m_pTool->SelectReconstructionMode(modeId);
 
168
                                event.Skip(false);
 
169
                        }
 
170
 
 
171
                        void OnUpdateMenuReconstructionUI(wxUpdateUIEvent& event) {
 
172
                                event.Enable(m_pTool->SupportsReconstructionMode(event.GetId() - MENU_IDS_RECONSTRUCTION));
 
173
                        }
 
174
 
 
175
                        GNKVisualizator::ReconstructionTool* m_pTool;
 
176
                        wxWindow* m_pParent;
 
177
                };*/
 
178
        }
 
179
}
 
180
 
 
181
//----------------------------------------------------------------------
 
182
 
 
183
GNKVisualizator::ReconstructionTool::ReconstructionTool(GNC::GCS::IControladorPermisos* pControladorPermisos)
 
184
{
 
185
        m_Descripcion = _Std("3D/4D Reconstruction");
 
186
        m_IsMenu = true;
 
187
        m_pControladorPermisos = pControladorPermisos;
 
188
}
 
189
 
 
190
GNKVisualizator::ReconstructionTool::~ReconstructionTool()
 
191
{
 
192
}
 
193
 
 
194
bool GNKVisualizator::ReconstructionTool::AppendInMenu(wxWindow* pParent, wxMenu* pMenuParent)
 
195
{
 
196
        if (m_pControladorPermisos->Get("atencionprimaria", "reconstruction")) {
 
197
/*              wxMenu* pMenu = new GNKVisualizator::GUI::MenuRecontructionTool(pParent,this, m_pControladorPermisos);
 
198
                pMenuParent->Append(ID,wxString::FromUTF8(m_Descripcion.c_str()),pMenu);*/
 
199
                GNKVisualizator::GUI::MenuItemReconstruction* mode;
 
200
                //int modeId = MENU_IDS_RECONSTRUCTION;
 
201
 
 
202
                if ( m_pControladorPermisos->Get("atencionprimaria.reconstruction","orthogonalmpr3d") ) {
 
203
                        int modeId = MENU_IDS_RECONSTRUCTION + (int)GNKVisualizator::Reconstruction::RM_OrthogonalMPR;
 
204
                        mode = new GNKVisualizator::GUI::MenuItemReconstruction(pParent, modeId, _("3D MPR"), pMenuParent,this, m_pControladorPermisos);
 
205
                        pMenuParent->Append(mode);
 
206
                }
 
207
 
 
208
                if ( m_pControladorPermisos->Get("atencionprimaria.reconstruction","mip3d") ) {
 
209
                        int modeId = MENU_IDS_RECONSTRUCTION + (int)GNKVisualizator::Reconstruction::RM_MIP3D;
 
210
                        mode = new GNKVisualizator::GUI::MenuItemReconstruction(pParent, modeId, _("MIP 3D"), pMenuParent,this, m_pControladorPermisos);
 
211
                        pMenuParent->Append(mode);
 
212
                }
 
213
 
 
214
                if ( m_pControladorPermisos->Get("atencionprimaria.reconstruction","volumerengering3d") ) {
 
215
                        int modeId = MENU_IDS_RECONSTRUCTION + (int)GNKVisualizator::Reconstruction::RM_VolumeRendering;
 
216
                        mode = new GNKVisualizator::GUI::MenuItemReconstruction(pParent, modeId, _("3D Volume Rendering"), pMenuParent,this, m_pControladorPermisos);
 
217
                        pMenuParent->Append(mode);
 
218
                }
 
219
 
 
220
                if ( m_pControladorPermisos->Get("atencionprimaria.reconstruction","surfacerendering3d") ) {
 
221
                        int modeId = MENU_IDS_RECONSTRUCTION + (int)GNKVisualizator::Reconstruction::RM_SurfaceRendering;
 
222
                        mode = new GNKVisualizator::GUI::MenuItemReconstruction(pParent, modeId, _("3D Surface Rendering"), pMenuParent,this, m_pControladorPermisos);
 
223
                        pMenuParent->Append(mode);
 
224
                }
 
225
 
 
226
 
 
227
                if ( m_pControladorPermisos->Get("atencionprimaria.reconstruction","endoscopy3d") ) {
 
228
                        int modeId = MENU_IDS_RECONSTRUCTION + (int)GNKVisualizator::Reconstruction::RM_3D_Endoscopy;
 
229
                        mode = new GNKVisualizator::GUI::MenuItemReconstruction(pParent, modeId, _("3D Endoscopy"), pMenuParent,this, m_pControladorPermisos);
 
230
                        pMenuParent->Append(mode);
 
231
                }
 
232
        }
 
233
        return true;
 
234
}
 
235
 
 
236
//region "Realizaci�n de la interfaz IHerramienta"
 
237
 
 
238
void GNKVisualizator::ReconstructionTool::CrearPaneles( wxPanel* /*panel*/ )
 
239
{
 
240
        m_pAbstractPanelHerramientaOpciones =  NULL;
 
241
}
 
242
 
 
243
bool GNKVisualizator::ReconstructionTool::SupportsReconstructionMode(int mode)
 
244
{
 
245
 
 
246
        if(Habilitada())
 
247
        {
 
248
                // TODO: More and better checks required (Ex: modality, etc...)
 
249
                bool supported = true;
 
250
                for (TReconstructionContratable::IteradorListaContratos it1 = TReconstructionContratable::m_pListaActiva->begin(); it1 != TReconstructionContratable::m_pListaActiva->end(); it1++) {
 
251
                        TReconstructionContract* pCR = (*it1);
 
252
                        if(pCR->Estudio->Viewer != NULL) {
 
253
 
 
254
                                int nc = pCR->Estudio->Viewer->GetNumberOfComponents();
 
255
 
 
256
                                supported = ( supported && (nc == 1) );
 
257
                        }
 
258
                        else {
 
259
                                supported = false;
 
260
                        }
 
261
                }
 
262
                return supported;
 
263
        } else {
 
264
                return false;
 
265
        }
 
266
}
 
267
 
 
268
void GNKVisualizator::ReconstructionTool::SelectReconstructionMode(int mode)
 
269
{
 
270
        if(Habilitada())
 
271
        {
 
272
                if(mode >= 0 && mode < (int)GNKVisualizator::Reconstruction::RM_MaxMode) {
 
273
                        for (TReconstructionContratable::IteradorListaContratos it1 = TReconstructionContratable::m_pListaActiva->begin(); it1 != TReconstructionContratable::m_pListaActiva->end(); it1++) {
 
274
                                TReconstructionContract* pCR = (*it1);
 
275
                                switch (mode) {
 
276
                                        case GNKVisualizator::Reconstruction::RM_OrthogonalMPR:
 
277
                                                pCR->SetReconstructionMode(GNKVisualizator::Reconstruction::RM_OrthogonalMPR);
 
278
                                                break;
 
279
                                        case GNKVisualizator::Reconstruction::RM_MIP3D:
 
280
                                                pCR->SetReconstructionMode(GNKVisualizator::Reconstruction::RM_MIP3D);
 
281
                                                break;
 
282
                                        case GNKVisualizator::Reconstruction::RM_VolumeRendering:
 
283
                                                pCR->SetReconstructionMode(GNKVisualizator::Reconstruction::RM_VolumeRendering);
 
284
                                                break;
 
285
                                        case GNKVisualizator::Reconstruction::RM_SurfaceRendering:
 
286
                                                pCR->SetReconstructionMode(GNKVisualizator::Reconstruction::RM_SurfaceRendering);
 
287
                                                break;
 
288
                                        case GNKVisualizator::Reconstruction::RM_3D_Endoscopy:
 
289
                                                pCR->SetReconstructionMode(GNKVisualizator::Reconstruction::RM_3D_Endoscopy);
 
290
                                                break;
 
291
                                }
 
292
                        }
 
293
                }
 
294
        }
 
295
}
 
296
 
 
297
void GNKVisualizator::ReconstructionTool::SolicitarActivacion()
 
298
{
 
299
}
 
300
 
 
301
void GNKVisualizator::ReconstructionTool::ConectarContratoFalso(bool ) {
 
302
        if (TReconstructionContratable::m_pListaActiva == NULL) {
 
303
                //std::cerr << "Error: Se trato de activar el modo deshabilitado de una vista sin haber asignado la vista activa. Error en la logica de activacion. Accion ignorada" << std::endl;
 
304
                return;
 
305
        }
 
306
 
 
307
}
 
308
 
 
309
void GNKVisualizator::ReconstructionTool::SetVistaActiva(GNC::GCS::IVista* pVista) {
 
310
        TReconstructionContratable::EstablecerVistaActiva(pVista);
 
311
}
 
312
 
 
313
// FIXME: Aviso!!!! para que funcione deben contratarse contratos pareados obligatorios y en el mismo orden
 
314
void GNKVisualizator::ReconstructionTool::ConectarContratos(bool )
 
315
{
 
316
        if (TReconstructionContratable::m_pListaActiva == NULL) {
 
317
                return;
 
318
        }
 
319
 
 
320
}
 
321
 
 
322
//endregion