3
* $Id: reconstructiontool.cpp 3558 2011-03-20 20:02:22Z carlos $
6
* Copyright 2008-10 MetaEmotion S.L. All rights reserved.
7
* http://ginkgo-cadx.com
9
* This file is licensed under LGPL v3 license.
10
* See License.txt for details
14
//#define _GINKGO_TRACE
17
#include <api/globals.h>
18
#include "reconstructiontool.h"
19
#include <eventos/eventosginkgo.h>
26
#include <vtkObject.h>
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>
40
#define MENU_IDS_RECONSTRUCTION 4201
42
namespace GNKVisualizator {
46
class EventHandlerReconstructionTool: public wxEvtHandler {
48
EventHandlerReconstructionTool(wxWindow* pParent, GNKVisualizator::ReconstructionTool* pTool, int modeId):wxEvtHandler()
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);
56
~EventHandlerReconstructionTool()
58
m_pParent->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( EventHandlerReconstructionTool::OnReconstructionModeSelected),NULL,this);
63
void OnReconstructionModeSelected( wxCommandEvent& event )
65
int modeId = event.GetId() - MENU_IDS_RECONSTRUCTION;
66
m_pTool->SelectReconstructionMode(modeId);
70
void OnUpdateMenuReconstructionUI(wxUpdateUIEvent& event) {
71
event.Enable(m_pTool->SupportsReconstructionMode(event.GetId() - MENU_IDS_RECONSTRUCTION));
74
GNKVisualizator::ReconstructionTool* m_pTool;
78
class MenuItemReconstruction : public wxMenuItem {
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);
84
~MenuItemReconstruction()
86
if(pEventHandler != NULL) {
92
EventHandlerReconstructionTool* pEventHandler;
99
class MenuRecontructionTool : public wxMenu {
102
MenuRecontructionTool(wxWindow* pParent, GNKVisualizator::ReconstructionTool* pTool, GNC::GCS::IControladorPermisos* pCP) : wxMenu() {
107
int modeId = MENU_IDS_RECONSTRUCTION;
109
//bool enabled = m_pTool->Habilitada();
111
if (pCP != NULL && pCP->Get("atencionprimaria", "reconstruction")) {
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);
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);
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);
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);
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);
154
m_pParent->Connect(pTool->ID, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(MenuRecontructionTool::OnUpdateMenuReconstructionUI),NULL,this);
158
~MenuRecontructionTool() {
159
m_pParent->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MenuRecontructionTool::OnReconstructionModeSelected),NULL,this);
164
void OnReconstructionModeSelected( wxCommandEvent& event )
166
int modeId = event.GetId() - MENU_IDS_RECONSTRUCTION;
167
m_pTool->SelectReconstructionMode(modeId);
171
void OnUpdateMenuReconstructionUI(wxUpdateUIEvent& event) {
172
event.Enable(m_pTool->SupportsReconstructionMode(event.GetId() - MENU_IDS_RECONSTRUCTION));
175
GNKVisualizator::ReconstructionTool* m_pTool;
181
//----------------------------------------------------------------------
183
GNKVisualizator::ReconstructionTool::ReconstructionTool(GNC::GCS::IControladorPermisos* pControladorPermisos)
185
m_Descripcion = _Std("3D/4D Reconstruction");
187
m_pControladorPermisos = pControladorPermisos;
190
GNKVisualizator::ReconstructionTool::~ReconstructionTool()
194
bool GNKVisualizator::ReconstructionTool::AppendInMenu(wxWindow* pParent, wxMenu* pMenuParent)
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;
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);
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);
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);
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);
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);
236
//region "Realizaci�n de la interfaz IHerramienta"
238
void GNKVisualizator::ReconstructionTool::CrearPaneles( wxPanel* /*panel*/ )
240
m_pAbstractPanelHerramientaOpciones = NULL;
243
bool GNKVisualizator::ReconstructionTool::SupportsReconstructionMode(int mode)
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) {
254
int nc = pCR->Estudio->Viewer->GetNumberOfComponents();
256
supported = ( supported && (nc == 1) );
268
void GNKVisualizator::ReconstructionTool::SelectReconstructionMode(int mode)
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);
276
case GNKVisualizator::Reconstruction::RM_OrthogonalMPR:
277
pCR->SetReconstructionMode(GNKVisualizator::Reconstruction::RM_OrthogonalMPR);
279
case GNKVisualizator::Reconstruction::RM_MIP3D:
280
pCR->SetReconstructionMode(GNKVisualizator::Reconstruction::RM_MIP3D);
282
case GNKVisualizator::Reconstruction::RM_VolumeRendering:
283
pCR->SetReconstructionMode(GNKVisualizator::Reconstruction::RM_VolumeRendering);
285
case GNKVisualizator::Reconstruction::RM_SurfaceRendering:
286
pCR->SetReconstructionMode(GNKVisualizator::Reconstruction::RM_SurfaceRendering);
288
case GNKVisualizator::Reconstruction::RM_3D_Endoscopy:
289
pCR->SetReconstructionMode(GNKVisualizator::Reconstruction::RM_3D_Endoscopy);
297
void GNKVisualizator::ReconstructionTool::SolicitarActivacion()
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;
309
void GNKVisualizator::ReconstructionTool::SetVistaActiva(GNC::GCS::IVista* pVista) {
310
TReconstructionContratable::EstablecerVistaActiva(pVista);
313
// FIXME: Aviso!!!! para que funcione deben contratarse contratos pareados obligatorios y en el mismo orden
314
void GNKVisualizator::ReconstructionTool::ConectarContratos(bool )
316
if (TReconstructionContratable::m_pListaActiva == NULL) {