3
* $Id: gvistacompleja.cpp 3748 2011-04-20 10:38:38Z 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
15
#include "gvistacompleja.h"
16
#include "gvistasimple.h"
17
#include "imprimevistasimple.h"
18
#include "../vistas/vista2d.h"
19
#include "../../recursos/aprimresourcemanager.h"
21
#include <wx/msgdlg.h>
23
#include <wx/config.h>
25
#include "../eventos/visualizatorevents.h"
26
#include <api/icontroladorherramientas.h>
27
#include <api/icontroladorlog.h>
28
#include <api/icontroladorvistas.h>
29
#include <eventos/eventosginkgo.h>
30
#include <api/iwidgetsmanager.h>
31
#include "../estudios/visualizatorstudy.h"
37
#include <vtkVISUManagement/vtkLookupTableManager.h>
38
#include <vtk/widgets/widgetsactor.h>
39
#include <vtkCamera.h>
40
#include <vtkPointData.h>
41
#include <vtkImageBlend.h>
42
#include <vtkImageMathematics.h>
43
#include <api/westilo.h>
46
#include <export/iherramientapuntero.h>
47
#include <export/iherramientaregla.h>
48
#include <export/iherramientaangulo.h>
49
#include <export/iherramientanota.h>
50
#include <export/iherramientawindowlevel.h>
51
#include <export/iherramientalupa.h>
52
#include <export/iherramientamarcado.h>
53
#include <export/iherramientarejillametrica.h>
54
#include <export/iherramientaanotacionesesquina.h>
55
#include <api/imodelointegracion.h>
56
#include <api/icontroladormodulo.h>
57
#include <api/icontroladorpermisos.h>
58
#include <api/icontroladorcomandos.h>
59
#include <export/iherramientareset.h>
60
#include <export/iherramientalayoutventana.h>
61
#include "../exportacion/iherramientamapacolor.h"
62
#include "../exportacion/iherramientaoverlays.h"
63
#include "../exportacion/ireconstructiontool.h"
64
#include <export/iherramientadesencajar.h>
66
#include <commands/comandodestruirvista.h>
68
#include <cairo/cairo.h>
69
#include <widgets/openglhelper.h>
70
//#include <widgets/wprogreso.h>
71
#include <widgets/wanotacionesquina.h>
73
#include <hackimageactor.h>
74
#include <api/internacionalizacion.h>
76
#include "reconstruction/endoscopy.h"
77
#include "reconstruction/mpr3d.h"
78
#include "reconstruction/surface.h"
79
#include "reconstruction/volume.h"
81
#define ID_BOTON_PLAY_STOP 0
82
#define ID_BOTON_VER 1
83
#define ID_BOTON_LAYOUT 2
84
#define ID_BOTON_SINCRONIZAR 3
85
#define ID_BOTON_DESENCAJAR 4
87
#define ID_ROTATE_LEFT 4151
88
#define ID_ROTATE_RIGHT 4152
89
#define ID_FLIP_V 4153
90
#define ID_FLIP_H 4154
91
//esta clase sirve para las barras de herramientas de abajo
92
class BarraHerramientasBotones:public wxAuiToolBar{
94
BarraHerramientasBotones(wxWindow* pParent, const wxColor& color = wxColor(0x40, 0x40, 0x40)): wxAuiToolBar(pParent,wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE)
96
SetToolBitmapSize(wxSize(16,16));
97
AUI_NAMESPACE wxAuiDefaultToolBarArt* pToolArt= new AUI_NAMESPACE wxAuiDefaultToolBarArt();
98
#if defined(USE_PATCHED_LIBS) && !defined(__WXOSX__)
99
pToolArt->SetBaseColor(color);
101
SetArtProvider(pToolArt);
104
~BarraHerramientasBotones()
109
//esta clase sirve para no tener que definir identificadores en las opciones de periodo en el cine
110
class ItemFrameRate: protected wxEvtHandler, public wxMenuItem {
112
ItemFrameRate(wxMenu *parentMenu,const wxString& text,GVistaCompleja* pVista,int periodo):wxMenuItem(parentMenu,wxID_ANY,text,wxEmptyString,wxITEM_CHECK)
116
int id = wxMenuItem::GetId();
118
parentMenu->GetParent()->Connect(id,wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( ItemFrameRate::OnMenuClick),NULL,this);
120
parentMenu->Connect(id,wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( ItemFrameRate::OnMenuClick),NULL,this);
125
int id = wxMenuItem::GetId();
127
GetMenu()->GetParent()->Disconnect(id,wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( ItemFrameRate::OnMenuClick ),NULL,this);
129
GetMenu()->Disconnect(id,wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( ItemFrameRate::OnMenuClick ),NULL,this);
133
void OnMenuClick(wxCommandEvent &event) {
134
m_pVista->SetPeriodo(m_periodo);
139
GVistaCompleja* m_pVista;
143
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
144
class TimerPlay:public wxTimer
147
TimerPlay(GVistaCompleja *pVista){
153
virtual void Notify(){
157
GVistaCompleja *m_pVista;
160
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
163
GVistaCompleja::GVistaCompleja(GNKVisualizator::Vista2D* pIVista) : VistaComplejaBase(pIVista->GetVisualizatorStudy()->VentanaPadre ) {
165
IVista->GetVisualizatorStudy()->Ventana = this;
166
m_hasBeenRendered = false;
167
m_ReproducirBucle = false;
169
m_posicion = m_pSliderSlice->GetValue();
171
// Setup del manejador de widgets */
172
GNC::GCS::IContratoWidgets::m_pManager = IVista->GetEstudio()->Entorno->NewWidgetsManager(IVista);
173
GNC::GCS::IContratoWidgets::Setup(GNC::GCS::IContratoWidgets::m_pManager);
175
m_playTimer = new TimerPlay(this);
177
//se añaden los botones de ver/cine
178
m_pBarraIzquierda = new BarraHerramientasBotones(m_pPanelManipulacion);
179
m_pBarraIzquierda->AddTool(ID_BOTON_VER,_("Display Options"),APrimResourcesManager::Herramientas::GetIcoMenuImagen(),_("Display Options"));
180
m_pBarraIzquierda->Connect(ID_BOTON_VER,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( GVistaCompleja::OnMenuVerClick),NULL,this);
182
m_pBarraIzquierda->AddTool(ID_BOTON_LAYOUT,_("Layout Setup"),APrimResourcesManager::Herramientas::GetIcoLayout(),_("Layout Setup"));
183
m_pBarraIzquierda->Connect(ID_BOTON_LAYOUT,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( GVistaCompleja::OnMenuLayout),NULL,this);
185
GNC::GCS::IControladorHerramientas* cH = IVista->GetEstudio()->Entorno->GetControladorHerramientas();
187
GNC::GCS::IHerramientaDesencajar* hDesencajar = NULL;
188
hDesencajar = cH->ObtenerHerramientaConcreta<GNC::GCS::IHerramientaDesencajar>(GNC::GCS::IHerramientaDesencajar::ID);
189
if (hDesencajar != NULL) {
190
m_pBarraIzquierda->AddTool(ID_BOTON_DESENCAJAR,_("Disencage view"),hDesencajar->GetIcono(),_("Disencage view"));
191
m_pBarraIzquierda->Connect(ID_BOTON_DESENCAJAR,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( GVistaCompleja::OnDesencajar),NULL,this);
195
m_pBarraIzquierda->Realize();
196
m_pSizerIzquierda->Add(m_pBarraIzquierda,0, wxALIGN_CENTER_VERTICAL|wxEXPAND,0);
198
m_pBarraCine = new BarraHerramientasBotones(m_pPanelManipulacion);
199
m_pBarraCine->AddTool(ID_BOTON_PLAY_STOP,_("Play"),APrimResourcesManager::BarraCine::GetIcoPlay(),_("Play"));
200
m_pBarraCine->Connect(ID_BOTON_PLAY_STOP,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( GVistaCompleja::OnPlayStopClick),NULL,this);
201
m_pBarraCine->SetToolDropDown(ID_BOTON_PLAY_STOP, true);
202
m_pBarraCine->Connect(ID_BOTON_PLAY_STOP,wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, wxAuiToolBarEventHandler( GVistaCompleja::OnMenuCineClick),NULL,this);
204
m_pBarraCine->Realize();
205
m_pSizerIzquierda->Add(m_pBarraCine,0, wxALIGN_CENTER_VERTICAL|wxEXPAND,0);
207
//se añaden los de sincronizar/dessincronizar
208
m_pBarraDerecha = new BarraHerramientasBotones(m_pPanelManipulacion);
209
m_pBarraDerecha->AddTool(ID_BOTON_SINCRONIZAR,_("Synchronize/Des synchronize"),APrimResourcesManager::BarraSincronizar::GetIcoDessincronizar(),_("Synchronize/Des synchronize"),wxITEM_CHECK);
210
m_pBarraDerecha->Connect(ID_BOTON_SINCRONIZAR,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( GVistaCompleja::OnSincronizarClick),NULL,this);
211
m_pBarraDerecha->ToggleTool(ID_BOTON_SINCRONIZAR,false);
213
m_pBarraDerecha->Realize();
214
m_pSizerDerecho->Add(m_pBarraDerecha,0, wxALIGN_CENTER_VERTICAL|wxEXPAND,0);
219
//Connect(wxEVT_CHILD_FOCUS, wxChildFocusEventHandler(GVistaCompleja::OnFocus),NULL,this);
220
Connect(wxEVT_KEY_DOWN,wxKeyEventHandler(GVistaCompleja::OnKeyDown),NULL,this);
221
Connect(wxEVT_CHAR,wxKeyEventHandler(GVistaCompleja::OnKeyDown),NULL,this);
222
Connect(wxEVT_MOUSEWHEEL,wxMouseEventHandler(GVistaCompleja::OnMouseWheel),NULL,this);
224
GNC::GCS::Eventos::EventoModificacionImagen ev2(IVista);
225
GNC::GCS::Eventos::EventoModificacionWidget ev3(IVista);
226
GNC::GCS::Eventos::EventoRender ev4(IVista);
227
GNKVisualizator::Eventos::EventoMostrarOverlay evt5(IVista);
229
pIVista->GetEstudio()->Entorno->GetControladorEventos()->Registrar(this, ev2);
230
pIVista->GetEstudio()->Entorno->GetControladorEventos()->Registrar(this, ev3);
231
pIVista->GetEstudio()->Entorno->GetControladorEventos()->Registrar(this, ev4);
232
pIVista->GetEstudio()->Entorno->GetControladorEventos()->Registrar(this, evt5);
234
GNC::GCS::IContratoWidgets::m_pManager->CrearWidgetAnotador(this);
237
//FUNDAMENTAL PARA QUE FUNCIONE LA HERRAMIENTA DE MAPAS DE COLOR
238
IVista->VisualizatorStudy->Viewer = m_VistasSimples[0]->ViewImage2D;
240
//GNC::GCS::IContratoWidgets::m_pManager->InsertarWidget(new GNC::GCS::Widgets::WProgreso(m_VistasSimples.front()->ViewInteractor2D, GNC::GCS::IContratoWidgets::m_pManager, -1, "progreso", 666));
241
GNC::GCS::IContratoWidgets::m_pManager->EnableAnimation();
246
GVistaCompleja::~GVistaCompleja()
248
IVista->ComienzaDestruccion();
249
//FUNDAMENTAL PARA QUE los viewers se destruyan correctamente y sin leaks ya que Viewer es smart pointer
250
for(TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
251
(*it)->UnRefIVista();
254
IVista->VisualizatorStudy->Viewer = NULL;
256
if (IVista != NULL) {
257
IVista->VisualizatorStudy->Entorno->GetControladorComandos()->AbortarComandosDeOwner(IVista);
260
//Disconnect(wxEVT_CHILD_FOCUS, wxChildFocusEventHandler(GVistaCompleja::OnFocus),NULL,this);
261
this->Disconnect(wxEVT_KEY_DOWN,wxKeyEventHandler(GVistaCompleja::OnKeyDown),NULL,this);
262
this->Disconnect(wxEVT_MOUSEWHEEL,wxMouseEventHandler(GVistaCompleja::OnMouseWheel),NULL,this);
264
if(m_ListaSincronizacion.size() >0){
265
//si esta reproduciendose se para
271
if(m_playTimer!= NULL) {
276
GNC::GCS::IContratoWidgets::m_pManager->EliminarTodosLosWidgets(false);
278
m_VistasSimples.clear();
280
IVista->GetEstudio()->Entorno->FreeWidgetsManager(GNC::GCS::IContratoWidgets::m_pManager);
281
GNC::GCS::IContratoWidgets::m_pManager = NULL;
283
GNKVisualizator::IReconstructionTool* hReconstruction = IVista->VisualizatorStudy->Entorno->GetControladorHerramientas()->ObtenerHerramientaConcreta<GNKVisualizator::IReconstructionTool>(GNKVisualizator::IReconstructionTool::ID);
284
if (hReconstruction != NULL) {
285
((GNC::GCS::IContratable<GNKVisualizator::IReconstructionContract>*)hReconstruction)->DesSubscribirsLosDeLaVista(IVista);
288
IVista->Lock(GLOC());
292
void GVistaCompleja::AddVistaSimple()
294
GVistaSimple* pVistaSimple = new GVistaSimple(IVista,this);
295
m_VistasSimples.push_back(pVistaSimple);
296
m_pSizerSeries->Add(pVistaSimple,1,wxEXPAND);
299
GNC::GCS::IWidgetsRenderer* pR = pVistaSimple->ViewInteractor2D;
300
pR->SetManager(GNC::GCS::IContratoWidgets::m_pManager);
301
pR->SetIOverlay(pVistaSimple);
302
//GNC::GCS::IContratoWidgets::m_pManager->SetRendererActivo(pR);
303
std::ostringstream os;
304
os << "Renderer " << pVistaSimple << std::endl;
308
WidgetRepresentation* pWidgetsRepresentation = WidgetRepresentation::New();
309
pWidgetsRepresentation->SetRenderer(pVistaSimple->ViewInteractor2D->FindPokedRenderer(0,0));
310
pVistaSimple->ViewInteractor2D->FindPokedRenderer(0,0)->AddViewProp(pWidgetsRepresentation);
311
pR->SetRepresentation(pWidgetsRepresentation);
312
pWidgetsRepresentation->SetWidgetsManager(GNC::GCS::IContratoWidgets::m_pManager);
313
pWidgetsRepresentation->SetWidgetsRenderer(pR);
314
pWidgetsRepresentation->Delete();
316
pVistaSimple->ViewImage2D->SetWindowLevelFrom(m_VistasSimples[0]->ViewImage2D);
317
pVistaSimple->ViewImage2D->SetLookupTable(m_VistasSimples[0]->ViewImage2D->GetLookupTable(), m_VistasSimples[0]->ViewImage2D->GetIdLookupTable());
318
pVistaSimple->ViewImage2D->SetZoom(m_VistasSimples[0]->ViewImage2D->GetZoom());
319
pVistaSimple->ViewImage2D->CopyCameraStatus(m_VistasSimples[0]->ViewImage2D);
321
for (unsigned int i = 0; i < m_VistasSimples.size(); i++) {
322
GNC::GCS::IWidgetsRenderer* pR = m_VistasSimples[i]->ViewInteractor2D;
323
pR->SetVID(i, false);
324
std::ostringstream os;
325
os << "Renderer " << i << std::endl;
330
void GVistaCompleja::IniciarPipeline()
332
m_pPanelManipulacion->Enable(true);
334
m_pListaOverlays = IVista->VisualizatorStudy->GetOverlaysImagenActiva();
335
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(new GNKVisualizator::Eventos::EventoRefrescarListaOverlays(IVista,m_pListaOverlays));
337
//contratos que son 1:1 con gvistacompleja
338
GNKVisualizator::IContratoMapaColor::Setup(IVista->GetEstudio());
339
GNKVisualizator::IReconstructionContract::Setup(IVista->GetEstudio());
340
GNKVisualizator::IContratoOverlays::Setup(m_pListaOverlays,IVista->GetEstudio()->Entorno);
341
//esto es correcto porque en la creacion se mete siempre una vista simple
344
GNC::GCS::IContratoWindowLevel::Setup(*IVista->GetEstudio()->GetTagsImagenDeImagenActiva());
347
///////////recorrer las vistas simples y pasarles las imagenes
349
if(m_VistasSimples.size() > 0) {
350
for(TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
351
GVistaSimple* pvs = *it;
352
pvs->EstudioReferido->SetIndiceActivo(i);
353
pvs->SetOverlays(m_pListaOverlays, m_EstadoOverlays);
355
//despues se establece el WL
356
if (HasDefaultWindowLevel()) {
357
GNC::GCS::IContratoWindowLevel::WindowLevel wl = GetAndSetDefaultWindowLevel();
358
pvs->ViewImage2D->SetDefaultWindowLevel(wl.m_window, wl.m_level);
361
pvs->ViewImage2D->SetAutoDefaultWindowLevel();
365
GNC::GCS::IContratoWidgets::m_pManager->SetRendererActivo( (* (m_VistasSimples.begin()) )->ViewInteractor2D );
367
GNC::GCS::IContratoLayoutVentana::Setup(0, IVista->GetEstudio()->GetNumeroCortes() - 1);
369
ActualizarMaxMinSlider();
372
//contrato window level, hay que preguntarle al viewer de la primera vista porque el estudioatencionprimaria no tiene viewer
373
GNC::GCS::IControladorHerramientas* cH = IVista->GetEstudio()->Entorno->GetControladorHerramientas();
374
GNC::GCS::IHerramientaWindowLevel* hWindowLevel = NULL;
376
if(m_VistasSimples[0]->ViewImage2D->GetNumberOfComponents() == 1){
377
// Subscribimos la vista al contrato de hWindowLevel
378
hWindowLevel = cH->ObtenerHerramientaConcreta<GNC::GCS::IHerramientaWindowLevel>(GNC::GCS::IHerramientaWindowLevel::ID);
379
if (hWindowLevel != NULL) {
380
((GNC::GCS::IContratable<GNC::GCS::IContratoWidgets>*)hWindowLevel)->Subscribir(IVista, this);
381
((GNC::GCS::IContratable<GNC::GCS::IContratoWindowLevel>*)hWindowLevel)->Subscribir(IVista, this);
385
catch (GNC::GCS::ControladorHerramientasException& ex) {
386
std::cerr << "Error al obtener la herramienta puntero: No se pudo subscribir la herramienta: " << ex.getCause() << std::endl;
389
GNKVisualizator::IReconstructionTool* hReconstruction = cH->ObtenerHerramientaConcreta<GNKVisualizator::IReconstructionTool>(GNKVisualizator::IReconstructionTool::ID);
390
if (hReconstruction != NULL) {
391
((GNC::GCS::IContratable<GNKVisualizator::IReconstructionContract>*)hReconstruction)->Subscribir(IVista, this);
397
void GVistaCompleja::DetenerPipeline()
399
m_pManager->OcultarTodosLosWidgets(true, 666);
400
m_pManager->DisableAnimation();
401
m_pPanelManipulacion->Enable(true);
402
m_pManager->Render();
405
void GVistaCompleja::OnCargaFinalizada()
407
m_pManager->OcultarTodosLosWidgets(true, 666);
408
m_pManager->DisableAnimation();
409
m_pManager->Render();
413
void GVistaCompleja::OnPaint(wxPaintEvent& event)
415
//std::cout << "GVistaCompleja::OnPaint()" << std::endl;
416
VistaComplejaBase::OnPaint(event);
417
if(IVista->GetEstudio()->Entorno->GetControladorVistas()->GetVistaActiva() == IVista)
420
wxColour colorLineaSeleccion(219, 219, 0, 255);
421
dc.SetBrush(wxBrush(colorLineaSeleccion,wxTRANSPARENT));
422
dc.SetPen(wxPen(colorLineaSeleccion, 3, wxSOLID));
423
dc.DrawRectangle(wxRect(wxPoint(1, 1), wxPoint(dc.GetSize().x-1, dc.GetSize().y-1)));
425
//la comprobacion de la textura, se hace la primera vez que se pinta
426
if(!m_hasBeenRendered ) {
427
if(IVista->EstaCargada()) {
428
for(GVistaCompleja::TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
429
GVistaSimple* vs = *it;
431
vs->ViewInteractor2D->Render();
432
long idTextura = vs->ViewImage2D->GetImageTexture();
433
if (idTextura != 0) {
434
if ( !glIsTexture(idTextura) ) {
435
IVista->GetEstudio()->Entorno->GetControladorLog()->Log("GVistaCompleja: Textura no cargada en memoria de video",GNC::GCS::IControladorLog::ErrorLog);
436
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(new GNC::GCS::Eventos::EventoMensajes(NULL,_Std("Error: You have exhausted the system's video memory and has not been able to load the image. Close some studies to free memory."),GNC::GCS::Eventos::EventoMensajes::PopUpMessage,false));
437
GADAPI::ComandoDestruirVistaParams* pParams = new GADAPI::ComandoDestruirVistaParams(IVista);
438
IVista->GetEstudio()->Entorno->GetControladorComandos()->ProcessAsync(_Std("Destroy View"),new GADAPI::ComandoDestruirVista(pParams),NULL);
441
//se comprobara mas tarde porque la textura todavia no tiene id
444
}catch(const std::bad_alloc&)
446
IVista->GetEstudio()->Entorno->GetControladorLog()->Log("GVistaCompleja: bad_alloc, error al reservar memoria física",GNC::GCS::IControladorLog::ErrorLog);
447
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(new GNC::GCS::Eventos::EventoMensajes(NULL,_Std("Error: System out of memory. Close some studies to free memory."),GNC::GCS::Eventos::EventoMensajes::PopUpMessage,false));
448
GADAPI::ComandoDestruirVistaParams* pParams = new GADAPI::ComandoDestruirVistaParams(IVista);
449
IVista->GetEstudio()->Entorno->GetControladorComandos()->ProcessAsync(_Std("Destroy View"),new GADAPI::ComandoDestruirVista(pParams),NULL);
453
IVista->GetEstudio()->Entorno->GetControladorLog()->Log("GVistaCompleja: excepción general al comprobar errores de memoria",GNC::GCS::IControladorLog::ErrorLog);
454
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(new GNC::GCS::Eventos::EventoMensajes(NULL,_Std("Error: Internal error."),GNC::GCS::Eventos::EventoMensajes::PopUpMessage,false));
455
GADAPI::ComandoDestruirVistaParams* pParams = new GADAPI::ComandoDestruirVistaParams(IVista);
456
IVista->GetEstudio()->Entorno->GetControladorComandos()->ProcessAsync(_Std("Destroy View"),new GADAPI::ComandoDestruirVista(pParams),NULL);
459
m_hasBeenRendered = true;
464
void GVistaCompleja::OnMenuVerClick(wxCommandEvent& )
467
wxMenu* pMenuVer = new wxMenu();
468
GNC::GCS::IControladorHerramientas* cH = IVista->GetEstudio()->Entorno->GetControladorHerramientas();
470
//////HERRAMIENTA ANOTACIONES ESQUINA, UN MENU////
471
GNC::GCS::IHerramientaAnotacionesEsquina* hAnotacionesEsquina = NULL;
472
// Subscribimos la vista al contrato de Anotaciones ventana
473
// Subscribimos la vista al contrato de rejilla
474
hAnotacionesEsquina = cH->ObtenerHerramientaConcreta<GNC::GCS::IHerramientaAnotacionesEsquina>(GNC::GCS::IHerramientaAnotacionesEsquina::ID);
475
if (hAnotacionesEsquina != NULL) {
476
hAnotacionesEsquina->AppendInMenu(this,pMenuVer);
479
GNC::GCS::IHerramientaRejillaMetrica* hRejilla = NULL;
480
// Subscribimos la vista al contrato de rejilla
481
hRejilla = cH->ObtenerHerramientaConcreta<GNC::GCS::IHerramientaRejillaMetrica>(GNC::GCS::IHerramientaRejillaMetrica::ID);
482
if (hRejilla != NULL) {
483
hRejilla->AppendInMenu(this,pMenuVer);
486
pMenuVer->AppendSeparator();
488
/////MAPA DE COLOR/////
489
GNKVisualizator::IHerramientaMapaColor* hMapa = NULL;
490
// Subscribimos la vista al contrato de rejilla
491
hMapa = cH->ObtenerHerramientaConcreta<GNKVisualizator::IHerramientaMapaColor>(GNKVisualizator::IHerramientaMapaColor::ID);
493
hMapa->AppendInMenu(this,pMenuVer);
496
GNKVisualizator::IHerramientaOverlays* hOverlays = NULL;
497
// Subscribimos la vista al contrato de rejilla
498
hOverlays = cH->ObtenerHerramientaConcreta<GNKVisualizator::IHerramientaOverlays>(GNKVisualizator::IHerramientaOverlays::ID);
499
if (hOverlays != NULL) {
500
hOverlays->AppendInMenu(this,pMenuVer);
503
if (m_pEntorno->GetControladorPermisos()->Get("atencionprimaria", "reconstruction")) {
504
GNKVisualizator::IReconstructionTool* hReconstruction = NULL;
505
// Reconstruction Tool subscription
506
hReconstruction = cH->ObtenerHerramientaConcreta<GNKVisualizator::IReconstructionTool>(GNKVisualizator::IReconstructionTool::ID);
507
if (hReconstruction != NULL) {
508
pMenuVer->AppendSeparator();
509
hReconstruction->AppendInMenu(this, pMenuVer);
513
pMenuVer->AppendSeparator();
516
GNC::GCS::IHerramientaReset* hReset = NULL;
517
// Subscribimos la vista al contrato de reset
518
hReset = cH->ObtenerHerramientaConcreta<GNC::GCS::IHerramientaReset>(GNC::GCS::IHerramientaReset::ID);
519
if (hReset != NULL) {
520
hReset->AppendInMenu(this,pMenuVer);
523
//rotate left y right y flip
524
pMenuVer->AppendSeparator();
525
wxMenuItem* pRotateLeft = new wxMenuItem(pMenuVer, ID_ROTATE_LEFT, _("Rotate 90") + wxString::FromUTF8("º")+ _(" Counter-ClockWise"));
526
wxMenuItem* pRotateRight = new wxMenuItem(pMenuVer, ID_ROTATE_RIGHT, _("Rotate 90") + wxString::FromUTF8("º")+ _(" ClockWise"));
527
wxMenuItem* pFlipVertical = new wxMenuItem(pMenuVer, ID_FLIP_V, _("Flip Vertical"));
528
wxMenuItem* pFlipHorizontal = new wxMenuItem(pMenuVer, ID_FLIP_H, _("Flip Horizontal"));
531
pRotateLeft->SetBitmaps(APrimResourcesManager::Herramientas::GetIcoRotateLeft());
532
pRotateRight->SetBitmaps(APrimResourcesManager::Herramientas::GetIcoRotateRight());
533
pFlipVertical->SetBitmaps(APrimResourcesManager::Herramientas::GetIcoFlipVertical());
534
pFlipHorizontal->SetBitmaps(APrimResourcesManager::Herramientas::GetIcoFlipHorizontal());
536
pRotateLeft->SetBitmap(APrimResourcesManager::Herramientas::GetIcoRotateLeft());
537
pRotateRight->SetBitmap(APrimResourcesManager::Herramientas::GetIcoRotateRight());
538
pFlipVertical->SetBitmap(APrimResourcesManager::Herramientas::GetIcoFlipVertical());
539
pFlipHorizontal->SetBitmap(APrimResourcesManager::Herramientas::GetIcoFlipHorizontal());
541
pMenuVer->Append(pRotateLeft);
542
pMenuVer->Append(pRotateRight);
543
pMenuVer->AppendSeparator();
544
pMenuVer->Append(pFlipVertical);
545
pMenuVer->Append(pFlipHorizontal);
547
pMenuVer->Connect(ID_ROTATE_LEFT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GVistaCompleja::OnRotateLeft),NULL,this);
548
pMenuVer->Connect(ID_ROTATE_RIGHT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GVistaCompleja::OnRotateRight),NULL,this);
549
pMenuVer->Connect(ID_FLIP_V, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GVistaCompleja::OnFlipVertical),NULL,this);
550
pMenuVer->Connect(ID_FLIP_H, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GVistaCompleja::OnFlipHorizontal),NULL,this);
552
catch (GNC::GCS::ControladorHerramientasException& ex) {
553
std::cerr << "Error al obtener la herramienta puntero: No se pudo subscribir la herramienta: " << ex.getCause() << std::endl;
555
m_pBarraIzquierda->PopupMenu(pMenuVer);
560
void GVistaCompleja::OnMenuCineClick(wxAuiToolBarEvent& evt)
562
if (evt.IsDropDownClicked())
564
wxAuiToolBar* tb = static_cast<wxAuiToolBar*>(evt.GetEventObject());
565
tb->SetToolSticky(evt.GetId(), true);
570
wxMenu* pMenuFrameRate = new wxMenu();
571
menuVer.AppendSubMenu(pMenuFrameRate,_("Speed"));
572
//importante si se añade un titulo añadir un periodo!!
573
wxString titulos[8] = {wxT("20 fps"), wxT("8 fps"),wxT("4 fps"),wxT("2 fps"),wxT("1 fps"),wxT("0.5 fps"),wxT("0.2 fps"),wxT("0.1 fps")};
574
int periodos[8] = {50,125,250,500,1000,2000,5000,10000};
575
for(int i=0; i < 8; i++)
577
wxMenuItem* pItem = new ItemFrameRate(pMenuFrameRate,titulos[i],this,periodos[i]);
578
pMenuFrameRate->Append(pItem);
579
if(periodos[i] == m_PeriodoMs) {
584
wxMenuItem* pItem = new wxMenuItem(&menuVer,wxID_ANY,_("Loop"),_("Repeat on end"),wxITEM_CHECK);
586
pItem->SetBitmaps(APrimResourcesManager::BarraCine::GetIcoBucle(),APrimResourcesManager::BarraCine::GetIcoNoBucle());
588
//pItem->SetBitmap(APrimResourcesManager::BarraCine::GetIcoBucle());
590
//este apend suelta por consola: 'InsertMenuItem()' failed with error 0x00000057, es un buf arreglado pero no afecta negativamente,
591
// es xq solo tiene un bitmap mas info:
592
//http://trac.wxwidgets.org/ticket/9878
593
menuVer.Append(pItem);
595
menuVer.Check(pItem->GetId(),m_ReproducirBucle);
596
menuVer.Connect(pItem->GetId(),wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GVistaCompleja::OnBucleClick ),NULL,this);
598
if(!m_playTimer->IsRunning()){
599
pItem = new wxMenuItem(&menuVer,wxID_ANY,_("Play"),_("Start playback"));
601
pItem->SetBitmaps(APrimResourcesManager::BarraCine::GetIcoPlay());
603
pItem->SetBitmap(APrimResourcesManager::BarraCine::GetIcoPlay());
605
menuVer.Append(pItem);
606
menuVer.Connect(pItem->GetId(),wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GVistaCompleja::OnPlayStopClick ),NULL,this);
608
pItem = new wxMenuItem(&menuVer,wxID_ANY,_("Stop"),_("End playback"));
610
pItem->SetBitmaps(APrimResourcesManager::BarraCine::GetIcoPause());
612
pItem->SetBitmap(APrimResourcesManager::BarraCine::GetIcoPause());
614
menuVer.Append(pItem);
615
menuVer.Connect(pItem->GetId(),wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GVistaCompleja::OnPlayStopClick ),NULL,this);
618
wxRect rect = tb->GetToolRect(evt.GetId());
619
wxPoint pt = tb->ClientToScreen(rect.GetBottomLeft());
620
pt = ScreenToClient(pt);
623
PopupMenu(&menuVer, pt);
625
// make sure the button is "un-stuck"
626
tb->SetToolSticky(evt.GetId(), false);
630
void GVistaCompleja::OnMenuLayout(wxCommandEvent &event)
633
GNC::GCS::IControladorHerramientas* cH = IVista->GetEstudio()->Entorno->GetControladorHerramientas();
635
//////HERRAMIENTA layout ventana////
636
GNC::GCS::IHerramientaLayoutVentana* hLayout = NULL;
637
hLayout = cH->ObtenerHerramientaConcreta<GNC::GCS::IHerramientaLayoutVentana>(GNC::GCS::IHerramientaLayoutVentana::ID);
638
if (hLayout != NULL) {
639
wxMenu* pMenuLayout = hLayout->GetMenu(this);
640
m_pBarraIzquierda->PopupMenu(pMenuLayout);
644
catch (GNC::GCS::ControladorHerramientasException& ex) {
645
std::cerr << "Error al obtener la herramienta puntero: No se pudo subscribir la herramienta: " << ex.getCause() << std::endl;
649
void GVistaCompleja::OnDesencajar(wxCommandEvent &event)
652
GNC::GCS::IControladorHerramientas* cH = IVista->GetEstudio()->Entorno->GetControladorHerramientas();
654
GNC::GCS::IHerramientaDesencajar* hDesencajar = NULL;
655
hDesencajar = cH->ObtenerHerramientaConcreta<GNC::GCS::IHerramientaDesencajar>(GNC::GCS::IHerramientaDesencajar::ID);
656
if (hDesencajar != NULL) {
657
if(hDesencajar->IsDesencajada()) {
658
m_pBarraIzquierda->SetToolShortHelp(ID_BOTON_DESENCAJAR,_("Disengage Vista"));
660
m_pBarraIzquierda->SetToolShortHelp(ID_BOTON_DESENCAJAR,_("Fit View"));
662
hDesencajar->Desencajar(IVista);
665
catch (GNC::GCS::ControladorHerramientasException& ex) {
666
std::cerr << "Error al obtener la herramienta puntero: No se pudo subscribir la herramienta: " << ex.getCause() << std::endl;
669
void GVistaCompleja::OnRotateLeft(wxCommandEvent &event)
671
for (TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
676
void GVistaCompleja::OnRotateRight(wxCommandEvent &event)
678
for (TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
683
void GVistaCompleja::OnFlipVertical(wxCommandEvent &event)
685
for (TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
690
void GVistaCompleja::OnFlipHorizontal(wxCommandEvent &event)
692
for (TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
697
void GVistaCompleja::ActualizarMaxMinSlider()
699
//depende de m_MinSlice y m_MaxSlice;
700
//tb depende del numero de vistasimples
701
int minSlider = m_MinSlice;
702
int maxSlider = ((m_MaxSlice - m_MinSlice) +1) - (m_pSizerSeries->GetRows() * m_pSizerSeries->GetCols());
703
if (minSlider < maxSlider) {
704
m_pSliderSlice->SetRange(minSlider, maxSlider);
705
m_pSliderSlice->Enable(true);
706
if( !m_pBarraCine->IsShown() ) {
707
m_pBarraCine->SetToolBitmap(ID_BOTON_PLAY_STOP, APrimResourcesManager::BarraCine::GetIcoPlay());
708
m_pBarraCine->SetToolShortHelp(ID_BOTON_PLAY_STOP, _("Play"));
709
m_pBarraCine->Enable(true);
710
m_pBarraCine->Show(true);
712
m_pSliderSlice->Show(true);
713
m_pBarraDerecha->Show(true);
714
m_pBarraDerecha->Refresh();
716
m_pSliderSlice->SetRange(0, 1);
717
if(m_ListaSincronizacion.size()>0)
721
if(m_playTimer->IsRunning()) {
724
m_pBarraCine->Hide();
725
m_pSliderSlice->Show(false);
726
m_pBarraDerecha->Show(false);
730
void GVistaCompleja::SetPeriodo(int milisegundos)
733
m_PeriodoMs = milisegundos;
734
if(m_playTimer->IsRunning()){
736
m_playTimer->Start(m_PeriodoMs);
741
void GVistaCompleja::OnFocus(wxChildFocusEvent &)
746
void GVistaCompleja::OnSize(wxSizeEvent &)
751
void GVistaCompleja::OnZSliderScroll (wxScrollEvent& event) {
752
int pos = event.GetPosition() - m_posicion;
755
GoToSlice(event.GetPosition(), false);
760
void GVistaCompleja::OnKeyDown( wxKeyEvent& event )
762
switch(event.GetKeyCode()){
775
GNC::GCS::ISolicitadorCambioHerramienta* solicitador = dynamic_cast<GNC::GCS::ISolicitadorCambioHerramienta*>(IVista->GetEstudio()->Entorno->GetControladorHerramientas());
776
if(solicitador!=NULL){
777
solicitador->SolicitarActivacion(IVista->GetEstudio()->Entorno->GetControladorHerramientas()->ObtenerHerramienta(GNC::GCS::IHerramientaPuntero::ID));
786
void GVistaCompleja::OnMouseWheel(wxMouseEvent& event)
788
if (event.ControlDown())
790
if (event.ShiftDown()) {
791
for (TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
792
if(event.GetWheelRotation() > 0)
794
(*it)->GoToTSlice(-1);
798
(*it)->GoToTSlice(1);
802
if(event.GetWheelRotation() > 0)
814
void GVistaCompleja::OnPlayStopClick(wxCommandEvent &){
815
if(!m_playTimer->IsRunning()) {
822
void GVistaCompleja::Play()
824
if(!m_ReproducirBucle && m_pSliderSlice->GetValue() == m_pSliderSlice->GetMax()){
827
m_playTimer->Start(m_PeriodoMs);
828
m_pBarraCine->SetToolBitmap(ID_BOTON_PLAY_STOP, APrimResourcesManager::BarraCine::GetIcoStop());
829
m_pBarraCine->SetToolShortHelp(ID_BOTON_PLAY_STOP, _("Stop"));
830
m_pBarraCine->Refresh();
832
AtencionPrimaria::Eventos::EventoSincronizacion* evt = new AtencionPrimaria::Eventos::EventoSincronizacion(IVista,AtencionPrimaria::Eventos::EventoSincronizacion::Play);
833
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(evt);
836
void GVistaCompleja::Stop()
840
m_pBarraCine->SetToolBitmap(ID_BOTON_PLAY_STOP, APrimResourcesManager::BarraCine::GetIcoPlay());
841
m_pBarraCine->SetToolShortHelp(ID_BOTON_PLAY_STOP, _("Play"));
842
m_pBarraCine->Refresh();
844
AtencionPrimaria::Eventos::EventoSincronizacion* evt = new AtencionPrimaria::Eventos::EventoSincronizacion(IVista,AtencionPrimaria::Eventos::EventoSincronizacion::Stop);
845
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(evt);
848
void GVistaCompleja::OnBucleClick(wxCommandEvent &){
849
m_ReproducirBucle = !m_ReproducirBucle;
852
void GVistaCompleja::OnTimer()
854
if((m_pSliderSlice->GetValue() +1 ) >m_pSliderSlice->GetMax() && m_ReproducirBucle){
859
if(m_pSliderSlice->GetValue() == m_pSliderSlice->GetMax() && !m_ReproducirBucle){
866
vtkGinkgoImageViewer* GVistaCompleja::GetViewer()
869
vtkGinkgoImageViewer* viewer = m_VistasSimples[0]->ViewImage2D;
870
for (TListaGVistasSimples::iterator it = m_VistasSimples.begin(); viewer == NULL && it != m_VistasSimples.end(); it++)
872
if (m_pManager->GetRendererActivo() == (*it)->ViewInteractor2D)
874
viewer = (*it)->ViewImage2D;
881
//region "Realizacion de la interfaz IAnnotator"
882
std::string GVistaCompleja::GetTopLeftAnnotation(GNC::GCS::Contexto3D* c)
884
GNC::GCS::IWidgetsRenderer* r = ( c == NULL? NULL : c->GetRenderer());
886
return m_VistasSimples[0]->GetTopLeftAnnotation(c);
888
for (TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
889
if ( (*it)->ViewInteractor2D == r) {
890
return (*it)->GetTopLeftAnnotation(c);
897
std::string GVistaCompleja::GetTopRightAnnotation(GNC::GCS::Contexto3D* c)
899
GNC::GCS::IWidgetsRenderer* r = ( c == NULL? NULL : c->GetRenderer());
901
return m_VistasSimples[0]->GetTopRightAnnotation(c);
903
for (TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
904
if ( (*it)->ViewInteractor2D == r) {
905
return (*it)->GetTopRightAnnotation(c);
912
std::string GVistaCompleja::GetBottomLeftAnnotation(GNC::GCS::Contexto3D* c)
914
GNC::GCS::IWidgetsRenderer* r = ( c == NULL? NULL : c->GetRenderer());
916
return m_VistasSimples[0]->GetBottomLeftAnnotation(c);
918
for (TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
919
if ( (*it)->ViewInteractor2D == r) {
920
return (*it)->GetBottomLeftAnnotation(c);
927
std::string GVistaCompleja::GetBottomRightAnnotation(GNC::GCS::Contexto3D* c)
929
GNC::GCS::IWidgetsRenderer* r = ( c == NULL? NULL : c->GetRenderer());
931
return m_VistasSimples[0]->GetBottomRightAnnotation(c);
933
for (TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
934
if ( (*it)->ViewInteractor2D == r) {
935
return (*it)->GetBottomRightAnnotation(c);
942
std::string GVistaCompleja::GetAnotacionPosicion(GNC::GCS::Vector* pPosicion)
944
GNC::GCS::IWidgetsRenderer* r = GNC::GCS::IContratoWidgets::m_pManager->GetRendererActivo();
945
for (TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
946
if ( (*it)->ViewInteractor2D == r) {
947
return (*it)->GetAnotacionPosicion(pPosicion);
954
// Asigna los valores de los apuntadores a la la imagen y el slice actual
955
void GVistaCompleja::AsignarConexionesDeFiltrado(vtkImageData** pImagen, int* slice, vtkImageData** pChroma)
958
*pImagen = m_pImagenOriginal;
959
if(m_VistasSimples.size() > 0) {
960
*slice = m_VistasSimples[0]->ViewImage2D->GetZSlice();
965
void GVistaCompleja::ActualizarImagen()
967
//m_pImagenOriginal->Modified();
968
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(new GNC::GCS::Eventos::EventoModificacionImagen(IVista,GNC::GCS::Eventos::EventoModificacionImagen::ImagenModificada, -1));
971
//----------DIALOGO SINCRONIZACION...-------------
972
class DialogoSincronizacion: public DialogoSincronizacionBase {
974
typedef std::vector<GNKVisualizator::Vista2D*> TipoListaVistas;
975
DialogoSincronizacion(wxWindow* parent, TipoListaVistas listaVistas):DialogoSincronizacionBase(parent){
976
m_lista = listaVistas;
977
for(TipoListaVistas::iterator it = listaVistas.begin(); it!=listaVistas.end(); it++){
978
m_pCheckListVistas->AppendString(wxString::FromUTF8((*it)->GetTitulo().c_str()));
983
~DialogoSincronizacion(){
987
void OnAceptarClick(wxCommandEvent &event){
991
TipoListaVistas GetVistasSeleccionadas(){
992
TipoListaVistas resultado;
993
wxArrayInt selecciones;
994
for(unsigned int i=0; i<m_pCheckListVistas->GetCount();i++){
996
for(TipoListaVistas::iterator itVistas = m_lista.begin(); itVistas!= m_lista.end(); ++itVistas){
997
if(m_pCheckListVistas->IsChecked(i)){
998
resultado.push_back(m_lista[i]);
1007
TipoListaVistas m_lista;
1010
//---------- end DIALOGO SINCRONIZACION...-------------
1012
void GVistaCompleja::OnSincronizarClick(wxCommandEvent &event)
1014
bool enabled = m_pBarraDerecha->GetToolToggled(ID_BOTON_SINCRONIZAR);
1015
Sincronizar(enabled);
1018
void GVistaCompleja::Sincronizar(bool sincronizar)
1020
//si esta toogled...
1023
//si esta reproduciendose se para
1029
typedef GNC::GCS::IControladorVistas::TipoListaVistas TipoListaIVistas;
1031
TipoListaVista2D lista;
1033
TipoListaIVistas listaTmp = IVista->GetEstudio()->Entorno->GetControladorVistas()->GetVistas();
1035
//pillamos las vistas simples
1036
for(TipoListaIVistas::iterator it = listaTmp.begin(); it!= listaTmp.end(); it++){
1037
GNKVisualizator::Vista2D* v = dynamic_cast<GNKVisualizator::Vista2D*> ((*it));
1038
if(v!=NULL && v!=IVista && v->GVista->EsSincronizable()){
1044
DialogoSincronizacion* dialogoSincronizacion = new DialogoSincronizacion(this, lista);
1045
int answer = dialogoSincronizacion->ShowModal();
1046
if (answer == wxID_OK) {
1047
//se pillan las vistas seleccionadas
1048
lista = dialogoSincronizacion->GetVistasSeleccionadas();
1050
//nos metemos en la lista
1051
lista.push_back(IVista);
1052
//y ahora sincronizamos a tol mundo
1053
for(DialogoSincronizacion::TipoListaVistas::iterator it = lista.begin(); it!= lista.end(); it++){
1054
(*it)->GVista->Sincronizar(lista);
1056
m_pBarraDerecha->ToggleTool(ID_BOTON_SINCRONIZAR,true);
1057
m_pBarraDerecha->Refresh();
1059
m_pBarraDerecha->ToggleTool(ID_BOTON_SINCRONIZAR,false);
1060
m_pBarraDerecha->Refresh();
1066
void GVistaCompleja::Sincronizar(const TipoListaVista2D& lista)
1068
//si esta reproduciendose se para
1070
//se suscribe a los eventos de los brothers
1071
for(TipoListaVista2D::const_iterator it = lista.begin(); it!= lista.end(); it++){
1072
if((*it) != IVista){
1073
AtencionPrimaria::Eventos::EventoSincronizacion evento((*it));
1074
IVista->GetEstudio()->Entorno->GetControladorEventos()->Registrar(this,evento);
1075
m_ListaSincronizacion.push_back((*it));
1078
m_pBarraDerecha->ToggleTool(ID_BOTON_SINCRONIZAR,true);
1079
m_pBarraDerecha->Refresh();
1082
bool GVistaCompleja::EsSincronizable(){
1083
return (m_ListaSincronizacion.size() == 0) && m_pSliderSlice->IsShown();
1086
void GVistaCompleja::DesSincronizar(){
1087
for(TipoListaVista2D::iterator it = m_ListaSincronizacion.begin(); it!= m_ListaSincronizacion.end(); it++){
1088
AtencionPrimaria::Eventos::EventoSincronizacion eventoOtro((*it));
1089
IVista->GetEstudio()->Entorno->GetControladorEventos()->DesRegistrar(this,eventoOtro);
1091
m_ListaSincronizacion.clear();
1093
m_pBarraCine->Enable(true);
1094
m_pBarraCine->Refresh();
1097
AtencionPrimaria::Eventos::EventoSincronizacion* evento = new AtencionPrimaria::Eventos::EventoSincronizacion(IVista,AtencionPrimaria::Eventos::EventoSincronizacion::Dessincronizar);
1098
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(evento);
1100
m_pBarraDerecha->ToggleTool(ID_BOTON_SINCRONIZAR,false);
1101
m_pBarraDerecha->Refresh();
1104
void GVistaCompleja::GoToSlice(int pos, bool relativa, bool propagar, bool render){
1105
if (m_MaxSlice == m_MinSlice) {
1111
posicion = m_pSliderSlice->GetValue() + pos;
1116
posicion = std::max(m_pSliderSlice->GetMin(), std::min(m_pSliderSlice->GetMax(), posicion));
1118
//si la posicion + las que se muestran en el layout actual es mayor al número de slices de la serie, no se avanza
1120
if(posicion + ( (int) m_VistasSimples.size() ) > IVista->GetEstudio()->GetNumeroCortes()) {
1124
m_pSliderSlice->SetValue(posicion);
1125
m_posicion = posicion;
1127
//se reestablece el window/level antes del evento de modificación porque ese evento lo escucha la herramienta
1128
GNC::GCS::IContratoWindowLevel::Setup(*IVista->GetEstudio()->GetTagsImagenDeImagenActiva());
1130
//se le indica al manager el vid
1131
IVista->GetEstudio()->IndiceFicheroActivo = posicion;
1132
for(TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
1133
(*it)->GoToSlice(posicion,false,false);
1135
//despues se establece el WL
1136
if (HasCurrentWindowLevel()) {
1137
GNC::GCS::IContratoWindowLevel::WindowLevel wl = GetCurrentWindowLevel();
1138
(*it)->ViewImage2D->SetDefaultWindowLevel(wl.m_window, wl.m_level);
1139
} else if (HasDefaultWindowLevel()) {
1140
GNC::GCS::IContratoWindowLevel::WindowLevel wl = GetAndSetDefaultWindowLevel();
1141
(*it)->ViewImage2D->SetDefaultWindowLevel(wl.m_window, wl.m_level);
1143
(*it)->ViewImage2D->SetAutoDefaultWindowLevel();
1146
if(IVista->VisualizatorStudy->TieneOverlaysImagen(posicion)) {
1147
GNKVisualizator::TListaOverlays* pLista = IVista->VisualizatorStudy->GetOverlaysImagen(posicion);
1148
(*it)->SetOverlays(pLista,m_EstadoOverlays);
1150
(*it)->SetOverlays(NULL, m_EstadoOverlays);
1156
GNC::GCS::Eventos::EventoModificacionImagen* pEvt = new GNC::GCS::Eventos::EventoModificacionImagen(IVista,GNC::GCS::Eventos::EventoModificacionImagen::SliceCambiado, -1, render);
1157
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(pEvt);
1160
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(new AtencionPrimaria::Eventos::EventoSincronizacion(IVista, AtencionPrimaria::Eventos::EventoSincronizacion::Scroll,pos,relativa));
1164
void GVistaCompleja::PreProcesarEvento(GNC::GCS::Eventos::IEvento* evt, GNC::GCS::IControladorEventos::TipoListaPunterosEventos& lista)
1167
std::cerr << "Error: Evento nulo" << std::endl;
1170
switch (evt->GetCodigoEvento()) {
1171
case ginkgoEVT_GNKVisualizator_EventoSincronizacion:
1173
AtencionPrimaria::Eventos::EventoSincronizacion* pEvt = dynamic_cast<AtencionPrimaria::Eventos::EventoSincronizacion*>(evt);
1175
std::cerr << "Error al interpretar evento como evento de sincronización: Evento = " << evt << std::endl;
1178
if (pEvt->GetTipoEvento() != AtencionPrimaria::Eventos::EventoSincronizacion::Scroll) {
1181
int posicion = pEvt->GetPosicion();
1182
if(pEvt->EsRelativa()){
1183
posicion += m_pSliderSlice->GetValue();
1185
posicion = std::max(m_pSliderSlice->GetMin(), std::min(m_pSliderSlice->GetMax(), posicion));
1188
case ginkgoEVT_Core_ModificacionImagen:
1190
GNC::GCS::Eventos::EventoModificacionImagen* pEvt = dynamic_cast<GNC::GCS::Eventos::EventoModificacionImagen*>(evt);
1192
std::cerr << "Error al interpretar evento como evento de modificación de imagen: Evento = " << evt << std::endl;
1195
switch (pEvt->GetTipo()) {
1196
case GNC::GCS::Eventos::EventoModificacionImagen::ImagenRecalibrada:
1198
lista.push_back(new GNC::GCS::Eventos::EventoModificacionImagen(IVista,GNC::GCS::Eventos::EventoModificacionImagen::ImagenCargada, -1));
1199
lista.push_back(new GNC::GCS::Eventos::EventoModificacionFichero(IVista,GNC::GCS::Eventos::EventoModificacionFichero::FicheroModificado));
1205
if (pEvt->GetApilarRender()) {
1206
lista.push_back(new GNC::GCS::Eventos::EventoRender(IVista,pEvt->GetSliceAfectado()));
1210
case ginkgoEVT_Core_ModificacionWidget:
1212
GNC::GCS::Eventos::EventoModificacionWidget* pEvt = dynamic_cast<GNC::GCS::Eventos::EventoModificacionWidget*>(evt);
1214
std::cerr << "Error al interpretar evento como evento de modificación de widget: Evento = " << evt << std::endl;
1217
// TODO: Este flujo es muy mejorable
1218
lista.push_back(new GNC::GCS::Eventos::EventoModificacionFichero(IVista,GNC::GCS::Eventos::EventoModificacionFichero::FicheroModificado,IVista));
1221
case ginkgoEVT_GNKVisualizator_EventoMostrarOverlay:
1223
lista.push_back(new GNC::GCS::Eventos::EventoRender(IVista));
1231
void GVistaCompleja::ProcesarEvento(GNC::GCS::Eventos::IEvento *evt)
1233
switch (evt->GetCodigoEvento()) {
1234
case ginkgoEVT_GNKVisualizator_EventoSincronizacion:
1236
AtencionPrimaria::Eventos::EventoSincronizacion* pEvt = dynamic_cast<AtencionPrimaria::Eventos::EventoSincronizacion*>(evt);
1238
if(pEvt->GetTipoEvento() == AtencionPrimaria::Eventos::EventoSincronizacion::Scroll){
1239
GoToSlice(pEvt->GetPosicion(),pEvt->EsRelativa(),false);
1240
} else if (pEvt->GetTipoEvento() == AtencionPrimaria::Eventos::EventoSincronizacion::Play) {
1241
m_pBarraCine->Enable(false);
1242
m_pBarraCine->Refresh();
1243
} else if (pEvt->GetTipoEvento() == AtencionPrimaria::Eventos::EventoSincronizacion::Stop) {
1244
m_pBarraCine->Enable(true);
1245
m_pBarraCine->Refresh();
1246
} else if (pEvt->GetTipoEvento() == AtencionPrimaria::Eventos::EventoSincronizacion::Dessincronizar) {
1247
for(TipoListaVista2D::iterator it = m_ListaSincronizacion.begin(); it!= m_ListaSincronizacion.end(); it++){
1248
if((*it) == pEvt->GetVista()){
1249
IVista->GetEstudio()->Entorno->GetControladorEventos()->DesRegistrar(this,*pEvt);
1250
m_ListaSincronizacion.erase(it);
1251
if(m_ListaSincronizacion.size() == 0){
1252
m_pBarraDerecha->ToggleTool(ID_BOTON_SINCRONIZAR,false);
1253
m_pBarraDerecha->Refresh();
1263
case ginkgoEVT_Core_ModificacionImagen:
1265
GNC::GCS::Eventos::EventoModificacionImagen* pEvt = dynamic_cast<GNC::GCS::Eventos::EventoModificacionImagen*>(evt);
1267
std::cerr << "Error al interpretar evento como evento de modificación de imagen: Evento = " << evt << std::endl;
1270
switch (pEvt->GetTipo()) {
1271
case GNC::GCS::Eventos::EventoModificacionImagen::ImagenModificada:
1272
case GNC::GCS::Eventos::EventoModificacionImagen::ImagenCargada:
1273
case GNC::GCS::Eventos::EventoModificacionImagen::MapaModificado:
1274
case GNC::GCS::Eventos::EventoModificacionImagen::SliceCambiado:
1276
for(TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
1277
(*it)->ViewImage2D->Modified();
1279
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(new GNC::GCS::Eventos::EventoModificacionImagen(IVista,GNC::GCS::Eventos::EventoModificacionImagen::AnotacionesEstaticasModificadas));
1282
case GNC::GCS::Eventos::EventoModificacionImagen::ImagenRecalibrada:
1286
for(TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++, i++) {
1287
m_VistasSimples[i]->GetEstudio()->RecalibrarImagenActiva(pEvt->GetNewSpacing(), pEvt->GetNewOrigin());
1289
//esto es necesario para establecer bien las coordenadas cuando se cambia el origen
1290
(*it)->GoToSlice(m_posicion + i,false,false);
1292
(*it)->RefrescarOverlays(m_EstadoOverlays);
1294
//se vuelve hacer setup del contrato mapa de color
1295
// GNKVisualizator::IContratoMapaColor::Setup(m_pImagenOriginal);
1300
case GNC::GCS::Eventos::EventoModificacionImagen::VisualizacionImagenModificada:
1301
//para que pille bien el window/level
1302
for(TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
1303
if(pEvt->ResetWindowLevel()) {
1304
if (HasDefaultWindowLevel()) {
1305
GNC::GCS::IContratoWindowLevel::WindowLevel wl = GetAndSetDefaultWindowLevel();
1306
(*it)->ViewImage2D->SetDefaultWindowLevel(wl.m_window, wl.m_level);
1308
(*it)->ViewImage2D->SetAutoDefaultWindowLevel();
1310
(*it)->ViewImage2D->ResetToDefaultWindowLevel();
1312
(*it)->ViewImage2D->SetWindow(pEvt->GetWindow());
1313
(*it)->ViewImage2D->SetLevel(pEvt->GetLevel());
1314
//(*it)->ViewImage2D->UpdateImage();
1315
for(TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
1316
//(*it)->ViewInteractor2D->Refresh(false);
1317
//(*it)->ViewInteractor2D->Render();
1320
if(pEvt->ResetCurrentPoint())
1323
double* bounds = (*it)->ViewImage2D->GetInput()->GetBounds();
1324
const double* currentPoint = (*it)->ViewImage2D->GetCurrentPoint();
1327
(bounds[0]+bounds[1])/2.0,
1328
(bounds[2]+bounds[3])/2.0,
1332
(*it)->ViewImage2D->SetCurrentPoint(pos);
1335
if(pEvt->ResetZoom())
1337
(*it)->ViewImage2D->ResetZoom();
1339
//(*it)->ViewImage2D->Modified();
1341
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(new GNC::GCS::Eventos::EventoModificacionImagen(IVista,GNC::GCS::Eventos::EventoModificacionImagen::AnotacionesEstaticasModificadas));
1343
case GNC::GCS::Eventos::EventoModificacionImagen::ImagenDescargada:
1345
case GNC::GCS::Eventos::EventoModificacionImagen::AnotacionesEstaticasModificadas:
1352
case ginkgoEVT_Core_Render:
1354
for(TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
1355
(*it)->ViewInteractor2D->Refresh(false);
1359
case ginkgoEVT_Core_ModificacionFichero:
1361
GNC::GCS::Eventos::EventoModificacionFichero* pEvt = new GNC::GCS::Eventos::EventoModificacionFichero();
1362
pEvt->SetVista(IVista);
1363
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(pEvt);
1366
case ginkgoEVT_GNKVisualizator_EventoMostrarOverlay:
1368
for(TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
1369
(*it)->RefrescarOverlays(m_EstadoOverlays);
1370
(*it)->ViewImage2D->Modified();
1377
void GVistaCompleja::SetMapaColor(vtkLookupTable* pTabla, int idLookupTable)
1380
for(TListaGVistasSimples::iterator it = m_VistasSimples.begin(); it != m_VistasSimples.end(); it++) {
1381
(*it)->ViewImage2D->SetLookupTable(pTabla, idLookupTable);
1383
IVista->GetEstudio()->Entorno->GetControladorEventos()->ProcesarEvento(new GNC::GCS::Eventos::EventoRender(IVista));
1388
void GVistaCompleja::SetLayoutVentana(int filas, int columnas)
1390
if(filas <1 || columnas < 1)
1395
bool incrementado = false;
1397
const int maxSlices = m_MaxSlice - m_MinSlice +1;
1398
if(filas*columnas > maxSlices) {
1399
//layout invalido aunque podría ser valido...
1400
filas = (int)std::ceil((double)maxSlices/columnas);
1404
int filasActuales = m_pSizerSeries->GetRows();
1405
int columnasActuales = m_pSizerSeries->GetCols();
1406
int tamAnterior = m_VistasSimples.size();
1407
int nuevoTam = filas*columnas;
1409
m_pSizerSeries->SetCols(columnas);
1410
m_pSizerSeries->SetRows(filas);
1413
//FUNDAMENTAL PARA QUE los viewers se destruyan correctamente y sin leaks ya que Viewer es smart pointer
1414
IVista->VisualizatorStudy->Viewer = NULL;
1415
if(tamAnterior > nuevoTam) {
1417
for(int i = 0; i< tamAnterior-nuevoTam; i++) {
1418
TListaGVistasSimples::iterator pVista = m_VistasSimples.begin();
1419
m_pManager->LiberarRecursos((*pVista)->ViewInteractor2D);
1420
m_pSizerSeries->Detach((*pVista));
1421
(*pVista)->Destroy();
1423
m_VistasSimples.erase(pVista);
1428
for(unsigned int i = 0; i< (unsigned int) (nuevoTam - tamAnterior) && m_VistasSimples.size() < (unsigned int) maxSlices; i++) {
1429
incrementado = true;
1432
//por si la posicion actual es invalida
1435
//FUNDAMENTAL PARA QUE FUNCIONE LA HERRAMIENTA DE MAPAS DE COLOR
1436
IVista->VisualizatorStudy->Viewer = m_VistasSimples[0]->ViewImage2D;
1437
ActualizarMaxMinSlider();
1439
//nos quedamos en la posicion
1440
GoToSlice(m_posicion,false,false,false);
1442
if ( (filas > 1 || columnas > 1) && incrementado) { // condición para evitar doble render. Ya se comprueba por otro lado en la creación (con 1 vista).
1443
bool noerror = true;
1444
for(TListaGVistasSimples::iterator it = m_VistasSimples.begin(); noerror && it != m_VistasSimples.end(); it++) {
1445
GVistaSimple* vs = *it;
1446
vs->ViewInteractor2D->Render();
1447
long idTextura = vs->ViewImage2D->GetImageTexture();
1448
if (idTextura == 0 || !glIsTexture(idTextura)) {
1453
SetLayoutVentana(filasActuales, columnasActuales);
1454
wxMessageBox(_("It has exhausted the system's video memory and has not been able to assign the grid configuration. Close some studies to free memory."), _("Error configuring the grid"), wxOK, NULL);
1460
int GVistaCompleja::GetFilas()
1462
return m_pSizerSeries->GetRows();
1465
int GVistaCompleja::GetColumnas()
1467
return m_pSizerSeries->GetCols();
1470
vtkScalarsToColors* GVistaCompleja::GetLookupTable()
1472
if(m_VistasSimples.size()>0) {
1473
return m_VistasSimples[0]->ViewImage2D->GetLookupTable();
1479
void GVistaCompleja::GetImage(GNC::GCS::IContratoExportacionImages::ImageType::Pointer& img, int index, bool conWidgets, const GNC::GCS::Vector& size)
1481
if (!IVista->VisualizatorStudy->Viewer->IsInstalledAndInitialized())
1484
GNKVisualizator::ImprimeVistaSimple imprimeVistaSimple(GNC::GCS::IContratoWidgets::m_pManager, IVista->VisualizatorStudy, index);
1486
if(IVista->VisualizatorStudy->Viewer->GetNumberOfComponents() == 3) {
1487
imprimeVistaSimple.PrintImageRGB(img,conWidgets, size);
1489
vtkScalarsToColors* pTabla = GetLookupTable();
1490
if(pTabla != NULL) {
1491
imprimeVistaSimple.PrintImage(img, conWidgets, pTabla, size);
1496
void GVistaCompleja::SetReconstructionMode(GNKVisualizator::Reconstruction::ReconstructionMode mode)
1500
case GNKVisualizator::Reconstruction::RM_SurfaceRendering:
1502
typedef MedicalViewer::Reconstruction::GUI::wxSurfaceRendering TReconstructionWin;
1503
TReconstructionWin* win = new TReconstructionWin(this, GNKVisualizator::IReconstructionContract::Estudio);
1507
case GNKVisualizator::Reconstruction::RM_VolumeRendering:
1509
typedef MedicalViewer::Reconstruction::GUI::wxVolumeRendering TReconstructionWin;
1510
TReconstructionWin* win = new TReconstructionWin(this, GNKVisualizator::IReconstructionContract::Estudio, GetViewer()->GetWindow(), GetViewer()->GetLevel());
1514
case GNKVisualizator::Reconstruction::RM_OrthogonalMPR:
1515
case GNKVisualizator::Reconstruction::RM_MIP3D:
1516
case GNKVisualizator::Reconstruction::RM_3D_Endoscopy:
1517
case GNKVisualizator::Reconstruction::RM_MaxMode:
1518
wxMessageBox(_("Reconstruction mode not implemented:\n"), _("Error"), wxICON_ERROR);
1521
wxMessageBox(_("Reconstruction mode not supported:\n"), _("Error"), wxICON_ERROR);