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

« back to all changes in this revision

Viewing changes to src/cadxcore/main/gui/history/panelhistorial2.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: panelhistorial2.cpp 3710 2011-04-15 10:29:01Z tovar $
 
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 <api/globals.h>
 
16
#include <wx/wx.h>
 
17
#include <wx/menu.h>
 
18
#include <wx/file.h>
 
19
#include <wx/filename.h>
 
20
#include <wx/dir.h>
 
21
#include <wx/textfile.h>
 
22
#include <wx/imaglist.h>
 
23
#include <wx/menu.h>
 
24
#include <wx/config.h>
 
25
#include <wx/busyinfo.h>
 
26
#include <wx/bmpcbox.h>
 
27
#include <wx/ginkgostyle/ginkgostyle.h>
 
28
 
 
29
#include "panelhistorial2.h"
 
30
#include "panelserie.h"
 
31
#include "panelpaciente.h"
 
32
#include "panelestudio.h"
 
33
#include "dialogoconfirmacioneliminar.h"
 
34
#include <main/gui/import/wxwizardimportacionginkgo.h>
 
35
#include <main/gui/adquisition/dialogoadquisicion.h>
 
36
#include <main/gui/open/abrir.h>
 
37
 
 
38
#include <api/idicommanager.h>
 
39
#include <eventos/eventosginkgo.h>
 
40
 
 
41
#include <main/entorno.h>
 
42
#include <main/gui/mainwindow/ventanaprincipal.h>
 
43
#include <main/controllers/controladorextensiones.h>
 
44
#include <main/controllers/controladorpermisos.h>
 
45
#include <main/controllers/controladorhistorial.h>
 
46
#include <commands/comandoincluirhistorial.h>
 
47
#include <api/icontroladorcomandos.h>
 
48
#include <api/internacionalizacion.h>
 
49
#include <api/icontextoestudio.h>
 
50
#include <resources/ginkgoresourcemanager.h>
 
51
 
 
52
#include <sstream>
 
53
 
 
54
#include <api/imodelodicom.h>
 
55
 
 
56
 
 
57
#define ID_MENUS 1401
 
58
#define ID_EJECUTAR 1
 
59
#define ID_TITULO 0
 
60
 
 
61
 
 
62
namespace GNC {
 
63
        namespace GUI {
 
64
 
 
65
                class TimerRecargarHistorial:public wxTimer
 
66
                {
 
67
                public:
 
68
                        TimerRecargarHistorial(PanelHistorial2* pHistorial){
 
69
                                m_pHistorial = pHistorial;
 
70
                        }
 
71
 
 
72
                        ~TimerRecargarHistorial()
 
73
                        {
 
74
                                m_pHistorial=NULL;
 
75
                        }
 
76
 
 
77
                        virtual void Notify()
 
78
                        {
 
79
                                m_pHistorial->RecargarBusqueda();
 
80
                        }
 
81
 
 
82
                        PanelHistorial2* m_pHistorial;
 
83
                };
 
84
 
 
85
                class wxDataPaciente: public wxClientData {
 
86
                public:
 
87
                        wxDataPaciente(const GNC::GCS::ControladorHistorial::ModeloPaciente& modeloPaciente):wxClientData()
 
88
                        {
 
89
                                m_modeloPaciente = modeloPaciente;
 
90
                        }
 
91
                        ~wxDataPaciente() {
 
92
                        }
 
93
                        GNC::GCS::ControladorHistorial::ModeloPaciente m_modeloPaciente;
 
94
                };
 
95
 
 
96
 
 
97
                PanelHistorial2::PanelHistorial2(wxWindow* parent) : PanelHistorial2Base(parent),
 
98
                        INodoHistorial(NULL,"")
 
99
                {
 
100
                        m_pTimerRecargar = new TimerRecargarHistorial(this);
 
101
                        m_pacienteActual = _Std("All");
 
102
                        m_modalidadActual = _Std("All");
 
103
                        m_fromActual = wxDateTime::Now();
 
104
                        m_toActual = wxInvalidDateTime;
 
105
                        //titulo
 
106
                        m_pHistoryTitle->GetButtonBar()->AddTool(ID_EJECUTAR,_("Hide"),GinkgoResourcesManager::PanelHistorial::GetIcoPlegar(),_("Hide"), wxITEM_NORMAL);
 
107
                        m_pHistoryTitle->GetButtonBar()->Connect(ID_EJECUTAR,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( PanelHistorial2::OnPlegarClick),NULL,this);
 
108
                        m_pHistoryTitle->Realize();
 
109
 
 
110
                        //titulo filtros
 
111
                        m_pFiltersTitle->GetButtonBar()->AddTool(ID_EJECUTAR,_("Hide"),GinkgoResourcesManager::PanelHistorial::GetIcoPlegar(),_("Hide"), wxITEM_NORMAL);
 
112
                        m_pFiltersTitle->GetButtonBar()->Connect(ID_EJECUTAR,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( PanelHistorial2::OnPlegarFilters),NULL,this);
 
113
                        m_pFiltersTitle->Realize();
 
114
 
 
115
                        {
 
116
                                m_pComboBoxPaciente->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( PanelHistorial2::OnComboBox ), NULL, this );
 
117
                        }
 
118
 
 
119
                        m_pComboDate->Select(0);
 
120
 
 
121
                        //se conecta el evento Ginkgo
 
122
                        GNC::Entorno::Instance()->GetControladorEventos()->Registrar(this, GNC::GCS::Eventos::EventoModificacionFichero());
 
123
                        GNC::Entorno::Instance()->GetControladorEventos()->Registrar(this, GNC::GCS::Eventos::EventoAddFicheroHistorial());
 
124
                        GNC::Entorno::Instance()->GetControladorEventos()->Registrar(this, GNC::GUI::Eventos::EventoSeleccionarHistorial());
 
125
                        GNC::Entorno::Instance()->GetControladorEventos()->Registrar(this, GNC::GUI::Eventos::EventoLayoutHistorial());
 
126
                        GNC::Entorno::Instance()->GetControladorEventos()->Registrar(this, GNC::GUI::Eventos::EventoAbribleEliminado());
 
127
                        GNC::Entorno::Instance()->GetControladorEventos()->Registrar(this, GNC::GUI::Eventos::EventoRecargarHistorial());
 
128
                        GNC::Entorno::Instance()->GetControladorEventos()->Registrar(this, GNC::GUI::Eventos::EventoAddModeloHistorial());
 
129
                        GNC::Entorno::Instance()->GetControladorEventos()->Registrar(this, GNC::GCS::Eventos::EventoColorPaciente());
 
130
                        GNC::Entorno::Instance()->GetControladorEventos()->Registrar(this, GNC::GUI::Eventos::EventoLimpiarHistorial());
 
131
                        GNC::Entorno::Instance()->GetControladorEventos()->Registrar(this, GNC::GCS::Eventos::EvtHandleDicom());                        
 
132
                        GNC::Entorno::Instance()->GetControladorEventos()->Registrar(this, GNC::GCS::Eventos::EventView());
 
133
                        GNC::Entorno::Instance()->GetControladorEventos()->Registrar(this, GNC::GCS::Eventos::EventDeleteFileHistory());
 
134
 
 
135
                        m_pSeleccionado = NULL;
 
136
 
 
137
                        SetSize(230, -1);
 
138
                        SetMinSize(wxSize(230, -1));
 
139
                        SetMaxSize(wxSize(230, -1));
 
140
                        Layout();
 
141
                }
 
142
 
 
143
                PanelHistorial2::~PanelHistorial2() {
 
144
                        //stores filter state
 
145
                        {
 
146
                                wxConfigBase * config = wxConfigBase::Get();
 
147
                                config->SetPath(wxT("/GinkgoCore/History"));
 
148
                                config->Write(wxT("PatientComboValue"),m_pComboBoxPaciente->GetValue());
 
149
                                config->Write(wxT("ModalityValue"),m_pComboModalidad->GetValue());
 
150
                                config->Write(wxT("DateChoice") , m_pComboDate->GetSelection());
 
151
                                if (m_fromActual.IsValid()) {
 
152
                                        config->Write(wxT("DateFrom"), m_fromActual.Format(wxT("%Y/%m/%d")));
 
153
                                } else {
 
154
                                        config->DeleteEntry(wxT("DateFrom"));
 
155
                                }
 
156
                                if (m_toActual.IsValid()) {
 
157
                                        config->Write(wxT("DateTo"), m_toActual.Format(wxT("%Y/%m/%d")));
 
158
                                } else {
 
159
                                        config->DeleteEntry(wxT("DateTo"));
 
160
                                }
 
161
                        }
 
162
 
 
163
                        //si es preciso limpiar historial...
 
164
                        GNC::GCS::Permisos::EstadoPermiso estado = GNC::GCS::ControladorPermisos::Instance()->Get("core.history", "anonymous");
 
165
                        if (estado) {
 
166
                                GNC::GCS::ControladorHistorial::Instance()->VaciarHistorial(true);
 
167
                        }
 
168
                        delete m_pTimerRecargar;
 
169
 
 
170
                        this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PanelHistorial2::OnSize ) );
 
171
                        this->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( PanelHistorial2::OnMenuMouse ), NULL, this );
 
172
                }
 
173
 
 
174
                void PanelHistorial2::RecargarCombos(bool comprobarPurga)
 
175
                {
 
176
                        if (comprobarPurga) {
 
177
                                //si es preciso limpiar historial...
 
178
                                GNC::GCS::Permisos::EstadoPermiso estado = GNC::GCS::ControladorPermisos::Instance()->Get("core.history", "anonymous");
 
179
                                if (estado) {
 
180
                                        GNC::GCS::ControladorHistorial::Instance()->VaciarHistorial(true);
 
181
                                }
 
182
                        }
 
183
 
 
184
                        //combo box pacientes
 
185
                        GNC::GCS::ControladorHistorial::ListaModelosPaciente listaPacientes;
 
186
                        GNC::GCS::ControladorHistorial::Instance()->GetAllPatients(listaPacientes);
 
187
 
 
188
                        m_pComboBoxPaciente->Clear();
 
189
 
 
190
                        m_pComboBoxPaciente->AppendString(_("All"));
 
191
                        if (m_pacienteActual == _Std("All")) {
 
192
                                m_pComboBoxPaciente->Select(0);
 
193
                        }
 
194
                        m_pComboBoxPaciente->AppendString(wxT("-----------------------------"));
 
195
 
 
196
                        for (GNC::GCS::ControladorHistorial::ListaModelosPaciente::iterator it = listaPacientes.begin(); it != listaPacientes.end(); ++it) {
 
197
                                std::ostringstream ostr;
 
198
                                ostr << (*it).m_nombrePaciente << " (" << (*it).m_idPaciente << ")";
 
199
 
 
200
                                wxDataPaciente* pData = new wxDataPaciente((*it));
 
201
                                int indice = -1;
 
202
                                if ((*it).m_sexo == 'M'){
 
203
                                        indice = m_pComboBoxPaciente->Append(wxString::FromUTF8(ostr.str().c_str()), GinkgoResourcesManager::PanelHistorial::GetIcoHombre(), pData);
 
204
                                }else if((*it).m_sexo =='F'){
 
205
                                        indice = m_pComboBoxPaciente->Append(wxString::FromUTF8(ostr.str().c_str()), GinkgoResourcesManager::PanelHistorial::GetIcoMujer(), pData);
 
206
                                }else{
 
207
                                        indice = m_pComboBoxPaciente->Append(wxString::FromUTF8(ostr.str().c_str()), GinkgoResourcesManager::PanelHistorial::GetIcoOtro(), pData);
 
208
                                }
 
209
 
 
210
                                if ((*it).m_idPaciente == m_pacienteActual) {
 
211
                                        m_pComboBoxPaciente->Select(indice);
 
212
                                }
 
213
                        }
 
214
                        if (m_pComboBoxPaciente->GetSelection() <0) {
 
215
                                m_pComboBoxPaciente->Select(0);
 
216
                        }
 
217
 
 
218
                        //combo box modalidades
 
219
                        m_pComboModalidad->Clear();
 
220
                        m_pComboModalidad->AppendString(_("All"));
 
221
                        if (m_modalidadActual == _Std("All")) {
 
222
                                m_pComboModalidad->Select(0);
 
223
                        }
 
224
                        m_pComboModalidad->AppendString(wxT("-----------------------------"));
 
225
 
 
226
                        std::list<std::string> listaModalidades;
 
227
                        GNC::GCS::ControladorHistorial::Instance()->GetAllModalities(listaModalidades);
 
228
                        for (std::list<std::string>::iterator it = listaModalidades.begin(); it !=  listaModalidades.end(); ++it) {
 
229
                                int item = m_pComboModalidad->Append((wxString::FromUTF8((*it).c_str())));
 
230
                                if (m_modalidadActual == (*it)) {
 
231
                                        m_pComboModalidad->Select(item);
 
232
                                }
 
233
                        }
 
234
 
 
235
                        if (comprobarPurga) {
 
236
                                //load filter state
 
237
                                wxConfigBase * config = wxConfigBase::Get();
 
238
                                config->SetPath(wxT("/GinkgoCore/History"));
 
239
                                wxString tmp;
 
240
                                if ( config->Read(wxT("PatientComboValue"), &tmp, wxEmptyString) ) {
 
241
                                        int pos = m_pComboBoxPaciente->FindString(tmp);
 
242
                                        if (pos >= 0) {
 
243
                                                m_pComboBoxPaciente->Select(pos);
 
244
                                        }
 
245
                                }
 
246
                                if ( config->Read(wxT("ModalityValue"), &tmp) ) {
 
247
                                        int pos = m_pComboModalidad->FindString(tmp);
 
248
                                        if (pos >= 0) {
 
249
                                                m_pComboModalidad->Select(pos);
 
250
                                        }
 
251
                                }
 
252
                                int intTmp;
 
253
                                if (config->Read(wxT("DateChoice"), &intTmp)) {
 
254
                                        m_pComboDate->Select(intTmp);
 
255
                                }
 
256
                                if (m_pComboDate->GetValue() == _("Between:")) {
 
257
                                        if (config->Read(wxT("DateFrom"), &tmp)) {
 
258
                                                wxDateTime from;
 
259
                                                from.ParseFormat(tmp, wxT("%Y/%m/%d"),wxDateTime::Now());
 
260
                                                m_pDatePickerFrom->SetValue(from);
 
261
                                        }
 
262
                                        if (config->Read(wxT("DateTo"), &tmp)) {
 
263
                                                wxDateTime to;
 
264
                                                to.ParseFormat(tmp, wxT("%Y/%m/%d"),wxDateTime::Now());
 
265
                                                m_pDatePickerTo->SetValue(to);
 
266
                                        }
 
267
                                }
 
268
                        }
 
269
                }
 
270
 
 
271
                void PanelHistorial2::CargarSeries( const GNC::GCS::IControladorHistorial::ListaModelosSeries& modelos, GnkPtr<GIL::IModeloIntegracion> pModeloIntegracion)
 
272
                {
 
273
                        GNC::Entorno::Instance()->GetVentanaPrincipal()->SuperFreeze();
 
274
                        Freeze();
 
275
                        m_pPanelHistorial->Freeze();
 
276
                        std::string uidScroll = "";
 
277
                        {
 
278
                                m_pPanelNoCabeMas->Show(false);
 
279
 
 
280
                                bool refrescar = false;
 
281
                                for(GNC::GCS::ControladorHistorial::ListaModelosSeries::const_iterator it = modelos.begin(); it!= modelos.end(); it++) {
 
282
                                        GNC::GCS::ControladorHistorial::ModeloSerie modeloControlador = (*it);
 
283
 
 
284
                                        if(m_mapaUIDsAbribles.find(modeloControlador.m_uidSerie) != m_mapaUIDsAbribles.end()){
 
285
                                                uidScroll = modeloControlador.m_uidSerie;
 
286
                                        } else {
 
287
                                                if(modeloControlador.m_modalidad != "SR") {
 
288
                                                        //se rellena el modelo
 
289
                                                        PanelPaciente* pPaciente = GetPaciente(modeloControlador);
 
290
                                                        refrescar = true;
 
291
                                                        if (pPaciente != NULL) {
 
292
                                                                uidScroll = modeloControlador.m_uidSerie;
 
293
                                                                m_mapaUIDsAbribles[modeloControlador.m_uidSerie] = pPaciente;
 
294
                                                                pPaciente->AddModeloSerie(modeloControlador);
 
295
                                                                refrescar = true;
 
296
                                                        } else {
 
297
                                                                //no caben más pacientes...
 
298
                                                                m_pPanelNoCabeMas->Show(true);
 
299
                                                                m_pPanelHistorial->Layout();
 
300
                                                                refrescar = true;
 
301
                                                                break;
 
302
                                                        }
 
303
                                                }
 
304
                                        }
 
305
                                }
 
306
                                if (refrescar) {
 
307
                                        m_pResultTitle->SetTitle(_("Results") + wxString::Format(_(" (%d series)"), m_mapaUIDsAbribles.size()));
 
308
                                        GNC::GCS::ControladorEventos::Instance()->ProcesarEvento(new GNC::GUI::Eventos::EventoLayoutHistorial());
 
309
                                }
 
310
 
 
311
                                if(uidScroll != "") {
 
312
                                        PanelSerie* pPanel = m_mapaUIDsAbribles[uidScroll]->GetSeries(uidScroll, true);
 
313
                                        wxWindow* pWin = dynamic_cast<wxWindow*>(pPanel);
 
314
                                        if(pWin!=NULL) {
 
315
                                                int pixelsx,pixelsy;
 
316
                                                m_pPanelHistorial->GetScrollPixelsPerUnit(&pixelsx,&pixelsy);
 
317
                                                wxPoint punto(0,0);
 
318
                                                wxWindow* pParent = pWin;
 
319
                                                do {
 
320
                                                        punto.y += pParent->GetPosition().y;
 
321
                                                        pParent = pParent->GetParent();
 
322
                                                }while (pParent != this);
 
323
                                                int x,y;
 
324
                                                m_pPanelHistorial->CalcUnscrolledPosition(punto.x,punto.y,&x,&y);
 
325
                                                m_pPanelHistorial->Scroll(0,y/pixelsy);
 
326
                                        }else {
 
327
                                                m_pPanelHistorial->Scroll(0,0);
 
328
                                        }
 
329
                                } else {
 
330
                                        m_pPanelHistorial->Scroll(0,0);
 
331
                                }
 
332
                                GNC::Entorno::Instance()->GetVentanaPrincipal()->SuperThaw();
 
333
                                Thaw();
 
334
                                m_pPanelHistorial->Thaw();
 
335
                        }
 
336
                }
 
337
 
 
338
                void PanelHistorial2::CargarDCMs( const GNC::GCS::IControladorHistorial::ListaModelosDCM& modelos, GnkPtr<GIL::IModeloIntegracion> pModeloIntegracion, bool desplegarNodo)
 
339
                {
 
340
                        GNC::Entorno::Instance()->GetVentanaPrincipal()->SuperFreeze();
 
341
                        Freeze();
 
342
                        m_pPanelHistorial->Freeze();
 
343
                        std::string uidScroll = "";
 
344
                        {
 
345
                                m_pPanelNoCabeMas->Show(false);
 
346
 
 
347
                                bool refrescar = false;
 
348
                                //los ficheros que pertenecen a series que ya existen provocan el refresco
 
349
                                std::set<std::string> listaRefrescarSlices;
 
350
                                for(GNC::GCS::ControladorHistorial::ListaModelosDCM::const_iterator it = modelos.begin(); it!= modelos.end(); it++) {
 
351
                                        GNC::GCS::ControladorHistorial::ModeloDCM modeloDCM = (*it);
 
352
 
 
353
                                        if(m_mapaUIDsAbribles.find(modeloDCM.m_uidSerie) != m_mapaUIDsAbribles.end()){
 
354
                                                uidScroll = modeloDCM.m_uidSerie;
 
355
                                                listaRefrescarSlices.insert(modeloDCM.m_uidSerie);
 
356
                                        }
 
357
                                }
 
358
 
 
359
                                //ahora se meten las nuevas series
 
360
                                for(GNC::GCS::ControladorHistorial::ListaModelosDCM::const_iterator it = modelos.begin(); it!= modelos.end(); it++) {
 
361
                                        GNC::GCS::ControladorHistorial::ModeloDCM modeloDCM = (*it);
 
362
 
 
363
                                        if(m_mapaUIDsAbribles.find(modeloDCM.m_uidSerie) != m_mapaUIDsAbribles.end()){
 
364
                                                uidScroll = modeloDCM.m_uidSerie;
 
365
 
 
366
                                                PanelSerie* pPanel = m_mapaUIDsAbribles[modeloDCM.m_uidSerie]->GetSeries(modeloDCM.m_uidSerie);
 
367
                                                if (pPanel != NULL) {
 
368
                                                        pPanel->IncrementarNumeroSlices();
 
369
                                                }
 
370
                                        } else {
 
371
                                                if(modeloDCM.m_modalidad != "SR") {
 
372
                                                        GNC::GCS::ControladorHistorial::ModeloSerie modeloSerie(modeloDCM);
 
373
                                                        //se rellena el modelo
 
374
                                                        PanelPaciente* pPaciente = GetPaciente(modeloSerie, desplegarNodo);
 
375
                                                        if (pPaciente != NULL) {
 
376
                                                                m_mapaUIDsAbribles[modeloSerie.m_uidSerie] = pPaciente;
 
377
                                                                uidScroll = modeloDCM.m_uidSerie;
 
378
                                                                pPaciente->AddModeloSerie(modeloSerie);
 
379
                                                                refrescar = true;
 
380
                                                        } else {
 
381
                                                                //no caben más pacientes
 
382
                                                                m_pPanelNoCabeMas->Show(true);
 
383
                                                                m_pPanelHistorial->Layout();
 
384
                                                                refrescar = true;
 
385
                                                                break;
 
386
                                                        }
 
387
                                                }
 
388
                                        }
 
389
                                }
 
390
                                //por último se refresca el numero d slices de las series que exisitian
 
391
                                for (std::set<std::string>::iterator it = listaRefrescarSlices.begin(); it != listaRefrescarSlices.end(); ++it) {
 
392
                                        PanelSerie* pPanel = m_mapaUIDsAbribles[(*it)]->GetSeries((*it));
 
393
                                        if (pPanel != NULL) {
 
394
                                                pPanel->RefrescarNumeroSlices();
 
395
                                        }
 
396
                                }
 
397
 
 
398
 
 
399
                                if (refrescar) {
 
400
                                        m_pResultTitle->SetTitle(_("Results") + wxString::Format(_(" (%d series)"), m_mapaUIDsAbribles.size()));
 
401
                                        GNC::GCS::ControladorEventos::Instance()->ProcesarEvento(new GNC::GUI::Eventos::EventoLayoutHistorial());
 
402
                                }
 
403
 
 
404
                                if(uidScroll != "") {
 
405
                                        PanelSerie* pPanel = m_mapaUIDsAbribles[uidScroll]->GetSeries(uidScroll, true);
 
406
                                        wxWindow* pWin = dynamic_cast<wxWindow*>(pPanel);
 
407
                                        if(pWin!=NULL) {
 
408
                                                int pixelsx,pixelsy;
 
409
                                                m_pPanelHistorial->GetScrollPixelsPerUnit(&pixelsx,&pixelsy);
 
410
                                                wxPoint punto(0,0);
 
411
                                                wxWindow* pParent = pWin;
 
412
                                                do {
 
413
                                                        punto.y += pParent->GetPosition().y;
 
414
                                                        pParent = pParent->GetParent();
 
415
                                                }while (pParent != this);
 
416
                                                int x,y;
 
417
                                                m_pPanelHistorial->CalcUnscrolledPosition(punto.x,punto.y,&x,&y);
 
418
                                                m_pPanelHistorial->Scroll(0,y/pixelsy);
 
419
                                        }else {
 
420
                                                m_pPanelHistorial->Scroll(0,0);
 
421
                                        }
 
422
                                } else {
 
423
                                        m_pPanelHistorial->Scroll(0,0);
 
424
                                }
 
425
                        }
 
426
                        GNC::Entorno::Instance()->GetVentanaPrincipal()->SuperThaw();
 
427
                        Thaw();
 
428
                        m_pPanelHistorial->Thaw();
 
429
                }
 
430
 
 
431
                //cargo pasando el path si es directorio cargo uno a uno... eso creo q no es asi xo bueno...
 
432
        /*      void PanelHistorial2::CargarDICOM( const std::vector<std::string>& paths, bool abrirDespuesDeCargar,GnkPtr<GIL::IModeloIntegracion> pModeloIntegracion)
 
433
                {
 
434
                        //controlador historial....
 
435
                        GNC::GCS::ControladorHistorial::ListaModelosDCM listaModelos;
 
436
                        GNC::GCS::ControladorHistorial::ListaModelosDCM listaModelosSR;
 
437
                        GNC::GCS::ControladorHistorial::ListaPaths rutasAdd;
 
438
                        GNC::GCS::ControladorHistorial::ListaPaths rutasModificar;
 
439
                        for(std::vector<std::string>::const_iterator it = paths.begin(); it != paths.end(); ++it){
 
440
                                wxString wxPath = FROMPATH((*it));
 
441
                                if(wxFileExists(wxPath)){
 
442
                                        std::string pathRelativo = GNC::Entorno::Instance()->GetPathRelativoFichero((*it));
 
443
                                        if(!GNC::GCS::ControladorHistorial::Instance()->ExisteFichero(pathRelativo)) {
 
444
                                                rutasAdd.push_back((*it));
 
445
                                        } else {
 
446
                                                if(m_mapaPathsAbribles.find((*it)) != m_mapaPathsAbribles.end()){
 
447
                                                        GNC::GCS::ControladorHistorial::ModeloDCM modelo;
 
448
                                                        modelo.m_pathRelativo = pathRelativo;
 
449
                                                        listaModelos.push_back(modelo);
 
450
                                                } else {
 
451
                                                        //es un "SR" que posiblemente se ha modificado, lo refrescamos
 
452
                                                        rutasModificar.push_back((*it));
 
453
                                                }
 
454
                                        }
 
455
                                } else if(wxDirExists(wxPath)) {
 
456
                                        //se listan los dcms del directorio y se cargan
 
457
                                        wxDir dir;
 
458
                                        std::vector<std::string> dcmEnElDirectorio;
 
459
                                        if (dir.Open(wxPath)) {
 
460
                                                wxString dcmName;
 
461
                                                bool cont = dir.GetFirst(&dcmName,wxT("*.dcm"));
 
462
                                                while (cont) {
 
463
                                                        dcmName=dir.GetName()+ wxFileName::GetPathSeparator(wxPATH_NATIVE) +dcmName;
 
464
                                                        dcmEnElDirectorio.push_back(std::string(TOPATH(dcmName)));
 
465
                                                        cont = dir.GetNext(&dcmName);
 
466
                                                }
 
467
                                        }
 
468
                                        for(std::vector<std::string>::iterator it2=dcmEnElDirectorio.begin();it2!=dcmEnElDirectorio.end();++it2){
 
469
                                                std::string pathRelativo = GNC::Entorno::Instance()->GetPathRelativoFichero((*it2));
 
470
                                                if(!GNC::GCS::ControladorHistorial::Instance()->ExisteFichero(pathRelativo)) {
 
471
                                                        rutasAdd.push_back((*it2));
 
472
                                                } else {
 
473
                                                        if(m_mapaPathsAbribles.find((*it2)) != m_mapaPathsAbribles.end()){
 
474
                                                                GNC::GCS::ControladorHistorial::ModeloDCM modelo;
 
475
                                                                modelo.m_pathRelativo = pathRelativo;
 
476
                                                                listaModelos.push_back(modelo);
 
477
                                                        } else {
 
478
                                                                //es un "SR" que posiblemente se ha modificado, lo refrescamos
 
479
                                                                rutasModificar.push_back((*it2));
 
480
                                                        }
 
481
                                                }
 
482
                                        }
 
483
                                }
 
484
                        }
 
485
                        if(rutasAdd.size()>0 || rutasModificar.size() >0){
 
486
                                wxBusyInfo* info = new wxBusyInfo(_("Updating History..."),this);
 
487
                                GNC::Entorno::Instance()->YieldApp();
 
488
                                GNC::GCS::ControladorHistorial::ListaPaths fooLista;
 
489
                                if(GNC::GCS::ControladorHistorial::Instance()->AddFiles(rutasAdd, listaModelos, fooLista, true) && GNC::GCS::ControladorHistorial::Instance()->UpdateFiles(rutasModificar,listaModelosSR)){
 
490
                                        delete info;
 
491
                                        CargarDICOM(listaModelos,abrirDespuesDeCargar,pModeloIntegracion);
 
492
                                } else {
 
493
                                        delete info;
 
494
                                }
 
495
                        } else {
 
496
                                CargarDICOM(listaModelos, abrirDespuesDeCargar, pModeloIntegracion);
 
497
                        }
 
498
                }*/
 
499
 
 
500
 
 
501
                //ya esta cargado... me avisan
 
502
                void PanelHistorial2::DICOMActivado(GNC::GCS::IVista* pVista)
 
503
                {
 
504
                        for(std::list<std::string>::const_iterator it = pVista->GetEstudio()->ListaUIDsSerie.begin(); it != pVista->GetEstudio()->ListaUIDsSerie.end(); ++it){
 
505
                                TMapaAbribles::iterator it2 = m_mapaUIDsAbribles.find( (*it) );
 
506
                                if(it2 != m_mapaUIDsAbribles.end()){
 
507
                                        //ya esta metido
 
508
                                        PanelSerie* pPanel = (*it2).second->GetSeries((*it), true);
 
509
                                        if (pPanel != NULL) {
 
510
                                                pPanel->AddVista(pVista);
 
511
                                        }
 
512
                                }
 
513
                                else{
 
514
                                        std::cerr << _Std("error, have tried to select a file that is not added to history")<<std::endl;
 
515
                                }
 
516
                        }
 
517
                }
 
518
 
 
519
                //Se desactiva...
 
520
                void PanelHistorial2::DICOMDesactivado(GNC::GCS::IVista* pVista)
 
521
                {
 
522
                        for(std::list<std::string>::const_iterator it = pVista->GetEstudio()->ListaUIDsSerie.begin(); it != pVista->GetEstudio()->ListaUIDsSerie.end(); ++it){
 
523
                                TMapaAbribles::iterator it2 = m_mapaUIDsAbribles.find( (*it) );
 
524
                                if(it2 != m_mapaUIDsAbribles.end()){
 
525
                                        //ya esta metido
 
526
                                        //ya esta metido
 
527
                                        PanelSerie* pPanel = (*it2).second->GetSeries((*it), true);
 
528
                                        if (pPanel != NULL) {
 
529
                                                pPanel->RemoveVista(pVista);
 
530
                                        }
 
531
                                }
 
532
                                else{
 
533
                                        std::cerr << _Std("error, have tried to select a file that is not added to history")<<std::endl;
 
534
                                }
 
535
                        }
 
536
 
 
537
                        PurgarHistorial(true);
 
538
                        GNC::GCS::ControladorEventos::Instance()->ProcesarEvento(new GNC::GUI::Eventos::EventoLayoutHistorial());
 
539
                }
 
540
 
 
541
 
 
542
//region "Eventos"
 
543
 
 
544
                //interfaz modelo dicom
 
545
                PanelPaciente* PanelHistorial2::GetPaciente(const GNC::GCS::ControladorHistorial::ModeloSerie& modeloSerie, bool desplegarNodo)
 
546
                {
 
547
                        TMapaHijos::iterator it=m_mapaHijos.find(modeloSerie.m_idPaciente);
 
548
                        if(it!=m_mapaHijos.end()){
 
549
                                return (PanelPaciente*)(*it).second;
 
550
                        }else{
 
551
                                //si el virtual size pasa de 16 bits (32000 pasan cosas malas) hay que dejar un margen para desplegar
 
552
                                if (m_pPanelHistorial->GetVirtualSize().y < 30000) {
 
553
                                        if(m_pPanelMensajeVacio->IsShown()) {
 
554
                                                m_pPanelMensajeVacio->Hide();
 
555
                                        }
 
556
                                        if (desplegarNodo) {
 
557
                                                //si el virtual size pasa de 16 bits (32000 pasan cosas malas)
 
558
                                                desplegarNodo = m_pPanelHistorial->GetVirtualSize().y < 25000;
 
559
                                        }
 
560
                                        PanelPaciente* pPanelPaciente = new PanelPaciente(this,m_pPanelHistorial,modeloSerie, desplegarNodo);
 
561
                                        m_pPanelHistorial->GetSizer()->Add(pPanelPaciente,0,wxBOTTOM|wxEXPAND,0);
 
562
                                        m_pPanelHistorial->Layout();
 
563
                                        m_mapaHijos[modeloSerie.m_idPaciente]=pPanelPaciente;
 
564
                                        return pPanelPaciente;
 
565
                                } else {
 
566
                                        //implica que no caben todos...
 
567
                                        return NULL;
 
568
                                }
 
569
                        }
 
570
                }
 
571
 
 
572
                wxColour PanelHistorial2::GetColorPaciente(const std::string& idPaciente)
 
573
                {
 
574
                        TMapaHijos::iterator it=m_mapaHijos.find(idPaciente);
 
575
                        if(it!=m_mapaHijos.end()){
 
576
                                return ((PanelPaciente*)(*it).second)->GetBackgroundColour();
 
577
                        }
 
578
                        return wxColour(49,106,197);
 
579
                }
 
580
                //
 
581
 
 
582
                void PanelHistorial2::ForzarCargarTodos()
 
583
                {
 
584
                        m_pComboBoxPaciente->SetSelection(m_pComboBoxPaciente->FindString(_("All")) );
 
585
                        m_pacienteActual = _Std("All");
 
586
                        //se eliminan todos los estudios que no están abiertos
 
587
                        Freeze();
 
588
                        //se eliminan los nodos que ya no van a valer
 
589
                        PurgarHistorial(false);
 
590
 
 
591
                        //pillamos los estudios del paciente seleccionado
 
592
                        GNC::GCS::ControladorHistorial::ListaModelosSeries listaSeries;
 
593
                        GNC::GCS::ControladorHistorial::Instance()->GetAllModelosSerie(listaSeries);
 
594
                        CargarSeries(listaSeries, NULL);
 
595
                        GNC::GCS::ControladorEventos::Instance()->ProcesarEvento(new GNC::GUI::Eventos::EventoLayoutHistorial());
 
596
                        Thaw();
 
597
                }
 
598
 
 
599
                std::list<std::string> PanelHistorial2::GetOpenedSeriesUIDs()
 
600
                {
 
601
                        std::list<std::string> result;
 
602
                        for (TMapaAbribles::iterator it = m_mapaUIDsAbribles.begin(); it !=  m_mapaUIDsAbribles.end(); ++it)
 
603
                        {
 
604
                                GNC::GUI::PanelSerie* pPanel = (*it).second->GetSeries((*it).first);
 
605
                                if (pPanel != NULL && pPanel->EstaAbierto()) {
 
606
                                        result.push_back((*it).first);
 
607
                                }
 
608
                        }
 
609
                        return result;
 
610
                }
 
611
 
 
612
                std::list<std::string> PanelHistorial2::GetOpenedStudiesUIDs()
 
613
                {
 
614
                        std::set<std::string> studies;
 
615
                        for (TMapaAbribles::iterator it = m_mapaUIDsAbribles.begin(); it !=  m_mapaUIDsAbribles.end(); ++it)
 
616
                        {
 
617
                                GNC::GUI::PanelSerie* pPanel = (*it).second->GetSeries((*it).first);
 
618
                                if (pPanel != NULL && pPanel->EstaAbierto()) {
 
619
                                        studies.insert(pPanel->GetParentNode()->GetClave());
 
620
                                }
 
621
                        }
 
622
                        std::list<std::string> result;
 
623
                        for(std::set<std::string>::iterator it = studies.begin(); it != studies.end(); ++it)
 
624
                        {
 
625
                                result.push_back((*it));
 
626
                        }
 
627
                        return result;
 
628
                }
 
629
 
 
630
                GNC::GCS::IVista* PanelHistorial2::GetVistaFromSeriesUID(const std::string& uid)
 
631
                {
 
632
                        TMapaAbribles::iterator it = m_mapaUIDsAbribles.find(uid);
 
633
                        if (it != m_mapaUIDsAbribles.end()) {
 
634
                                GNC::GUI::PanelSerie* pPanel = (*it).second->GetSeries((*it).first);
 
635
                                if (pPanel != NULL && pPanel->EstaAbierto()) {
 
636
                                        return pPanel->m_pVistas.front();
 
637
                                }
 
638
                        }
 
639
                        return NULL;
 
640
                }
 
641
 
 
642
                GNC::GCS::IVista* PanelHistorial2::GetVistaFromStudyUID(const std::string& uid)
 
643
                {
 
644
                        for (TMapaAbribles::iterator it = m_mapaUIDsAbribles.begin(); it !=  m_mapaUIDsAbribles.end(); ++it)
 
645
                        {
 
646
                                GNC::GUI::PanelSerie* pPanel = (*it).second->GetSeries((*it).first);
 
647
                                if (pPanel != NULL && pPanel->EstaAbierto()) {
 
648
                                        if (pPanel->GetParentNode()->GetClave() == uid)
 
649
                                        {
 
650
                                                return pPanel->m_pVistas.front();
 
651
                                        }
 
652
                                }
 
653
                        }
 
654
                        
 
655
                        return NULL;
 
656
                }
 
657
 
 
658
                void PanelHistorial2::OnCheckFromClick(wxCommandEvent &)
 
659
                {
 
660
                        m_pTimerRecargar->Stop();
 
661
                        m_pTimerRecargar->Start(500,true);
 
662
                }
 
663
 
 
664
                void PanelHistorial2::OnCheckToClick(wxCommandEvent &)
 
665
                {
 
666
                        m_pTimerRecargar->Stop();
 
667
                        m_pTimerRecargar->Start(500,true);
 
668
                }
 
669
 
 
670
                void PanelHistorial2::OnPlegarFilters(wxCommandEvent&)
 
671
                {
 
672
                        GNC::Entorno::Instance()->GetVentanaPrincipal()->SuperFreeze();
 
673
                        m_pFiltersPanel->Show(!m_pFiltersPanel->IsShown());
 
674
                        if (m_pFiltersPanel->IsShown()) {
 
675
                                m_pFiltersTitle->GetButtonBar()->SetToolBitmap(ID_EJECUTAR, GinkgoResourcesManager::PanelHistorial::GetIcoPlegar());
 
676
                        } else {
 
677
                                m_pFiltersTitle->GetButtonBar()->SetToolBitmap(ID_EJECUTAR, GinkgoResourcesManager::PanelHistorial::GetIcoDesplegar());
 
678
                        }
 
679
                        Layout();
 
680
                        Refresh(true);
 
681
                        GNC::Entorno::Instance()->GetVentanaPrincipal()->SuperThaw();
 
682
                }
 
683
 
 
684
                void PanelHistorial2::OnPlegarClick(wxCommandEvent& )
 
685
                {
 
686
                        Plegar(true);
 
687
                }
 
688
 
 
689
                void PanelHistorial2::OnDesplegar(wxMouseEvent& )
 
690
                {
 
691
                        Plegar(false);
 
692
                }
 
693
 
 
694
                void PanelHistorial2::Plegar(bool plegar)
 
695
                {
 
696
                        GNC::Entorno::Instance()->GetVentanaPrincipal()->SuperFreeze();
 
697
                        if (!plegar) {
 
698
                                SetSize(230, -1);
 
699
                                SetMinSize(wxSize(230, -1));
 
700
                                SetMaxSize(wxSize(300, -1));
 
701
                        } else {
 
702
                                SetSize(20, -1);
 
703
                                SetMinSize(wxSize(26, -1));
 
704
                        }
 
705
                        GetParent()->Layout();
 
706
                        m_pPanelHistorial->Show(!plegar);
 
707
                        m_pFiltersPanel->Show(!plegar);
 
708
                        m_pFiltersTitle->Show(!plegar);
 
709
                        m_pResultTitle->Show(!plegar);
 
710
                        m_pHistoryTitle->Show(!plegar);
 
711
                        m_pPanelVertical->Show(plegar);
 
712
                        if (m_pFiltersPanel->IsShown()) {
 
713
                                m_pFiltersTitle->GetButtonBar()->SetToolBitmap(ID_EJECUTAR, GinkgoResourcesManager::PanelHistorial::GetIcoPlegar());
 
714
                        } else {
 
715
                                m_pFiltersTitle->GetButtonBar()->SetToolBitmap(ID_EJECUTAR, GinkgoResourcesManager::PanelHistorial::GetIcoDesplegar());
 
716
                        }
 
717
                        Layout();
 
718
                        GNC::Entorno::Instance()->GetVentanaPrincipal()->SuperThaw();
 
719
                }
 
720
 
 
721
                void PanelHistorial2::OnDateFromChanged( wxDateEvent&  )
 
722
                {
 
723
                        m_pComboDate->Select(m_pComboDate->FindString(_("Between:")));
 
724
                        m_pTimerRecargar->Stop();
 
725
                        m_pTimerRecargar->Start(500,true);
 
726
                }
 
727
 
 
728
                void PanelHistorial2::OnDateToChanged( wxDateEvent&  )
 
729
                {
 
730
                        m_pComboDate->Select(m_pComboDate->FindString(_("Between:")));
 
731
                        m_pTimerRecargar->Stop();
 
732
                        m_pTimerRecargar->Start(500,true);
 
733
                }
 
734
 
 
735
                void PanelHistorial2::OnComboBox( wxCommandEvent& )
 
736
                {
 
737
                        m_pTimerRecargar->Stop();
 
738
                        m_pTimerRecargar->Start(500,true);
 
739
                }
 
740
 
 
741
                void PanelHistorial2::RecargarBusqueda(bool force)
 
742
                {
 
743
                        bool cambio = false;
 
744
                        if (m_pComboBoxPaciente->GetSelection() >= 0) {
 
745
                                if (m_pComboBoxPaciente->GetSelection() > 1) {
 
746
                                        wxDataPaciente* pPaciente = (wxDataPaciente*)(m_pComboBoxPaciente->GetClientObject(m_pComboBoxPaciente->GetSelection()));
 
747
                                        std::string idPacienteSeleccionado = pPaciente->m_modeloPaciente.m_idPaciente;
 
748
                                        if (idPacienteSeleccionado != m_pacienteActual) {
 
749
                                                m_pacienteActual = idPacienteSeleccionado;
 
750
                                                cambio  = true;
 
751
                                        }
 
752
                                } else if (m_pComboBoxPaciente->GetSelection() == 0) {
 
753
                                        wxString stringSeleccionado = m_pComboBoxPaciente->GetString(m_pComboBoxPaciente->GetSelection());
 
754
                                        if (stringSeleccionado == _("All") && m_pacienteActual != _Std("All")) {
 
755
                                                m_pacienteActual = std::string(stringSeleccionado.ToUTF8());
 
756
                                                cambio = true;
 
757
                                        }
 
758
                                }
 
759
                        }
 
760
 
 
761
                        //distinto del separador
 
762
                        if (m_pComboModalidad->GetSelection() >= 0) {
 
763
                                if (m_pComboModalidad->GetSelection() != 1) {
 
764
                                        std::string modalidadSeleccionada (m_pComboModalidad->GetString(m_pComboModalidad->GetSelection()).ToUTF8());
 
765
                                        if (modalidadSeleccionada != m_modalidadActual) {
 
766
                                                m_modalidadActual = modalidadSeleccionada;
 
767
                                                cambio = true;
 
768
                                        }
 
769
                                }
 
770
                        }
 
771
                        /*if (!m_fromActual.IsValid() || m_fromActual != m_pDatePickerFrom->GetValue()) {
 
772
                                        m_fromActual = m_pDatePickerFrom->GetValue();
 
773
                                        cambio = true;
 
774
                                }
 
775
                                if (m_fromActual.IsValid()) {
 
776
                                        m_fromActual = wxInvalidDateTime;
 
777
                                        cambio = true;
 
778
                                }
 
779
 
 
780
                        */
 
781
 
 
782
                        wxDateTime newFechaDesde = wxInvalidDateTime, newFechaHasta = wxInvalidDateTime;
 
783
                        std::string timeFrom(""), timeTo("");
 
784
                        if (m_pComboDate->GetValue() == _("Between:")) {
 
785
                                newFechaDesde = m_pDatePickerFrom->GetValue();
 
786
                                newFechaHasta = m_pDatePickerTo->GetValue();
 
787
                        } else if (m_pComboDate->GetValue() == _("Today") || m_pComboDate->GetValue() == _("Today AM") || m_pComboDate->GetValue() == _("Today PM")) {
 
788
                                newFechaDesde = newFechaHasta = wxDateTime::Now();
 
789
                                if (m_pComboDate->GetValue() == _("Today AM")) {
 
790
                                        timeFrom = "00:00:00";
 
791
                                        timeTo = "11:59:59";
 
792
                                } else if (m_pComboDate->GetValue() == _("Today PM")) {
 
793
                                        timeFrom = "12:00:00";
 
794
                                        timeTo = "23:59:59";
 
795
                                }
 
796
                        } else if (m_pComboDate->GetValue() == _("Yesterday")) {
 
797
                                newFechaDesde = newFechaHasta = wxDateTime::Now().Add(wxDateSpan(0,0,0,-1));
 
798
                                m_pDatePickerTo->SetValue(wxDateTime::Now());
 
799
                        } else if (m_pComboDate->GetValue() == _("Last week")) {
 
800
                                newFechaDesde = wxDateTime::Now().Add(wxDateSpan(0,0,-1,0));
 
801
                                m_pDatePickerTo->SetValue(wxDateTime::Now());
 
802
                        } else if (m_pComboDate->GetValue() == _("Last month")) {
 
803
                                newFechaDesde = wxDateTime::Now().Add(wxDateSpan(0,-1,0,0));
 
804
                                m_pDatePickerTo->SetValue(wxDateTime::Now());
 
805
                        } else if (m_pComboDate->GetValue() == _("Last 3 months")) {
 
806
                                newFechaDesde = wxDateTime::Now().Add(wxDateSpan(0,-3,0,0));
 
807
                                m_pDatePickerTo->SetValue(wxDateTime::Now());
 
808
                        } //else any date (invalid datetimes)
 
809
 
 
810
                        if ((newFechaDesde.IsValid() && !m_fromActual.IsValid()) || (!newFechaDesde.IsValid() && m_fromActual.IsValid()) ||
 
811
                                (newFechaDesde.IsValid() && m_fromActual.IsValid() && newFechaDesde != m_fromActual))
 
812
                        {
 
813
                                cambio = true;
 
814
                                m_fromActual = newFechaDesde;
 
815
                        }
 
816
                        if ((newFechaHasta.IsValid() && !m_toActual.IsValid()) || (!newFechaHasta.IsValid() && m_toActual.IsValid()) ||
 
817
                                (newFechaHasta.IsValid() && m_toActual.IsValid() && newFechaHasta != m_toActual))
 
818
                        {
 
819
                                cambio = true;
 
820
                                m_toActual = newFechaHasta;
 
821
                        }
 
822
                        if (m_fromActual.IsValid()) {
 
823
                                m_pDatePickerFrom->SetValue(m_fromActual);
 
824
                        }
 
825
                        if (m_toActual.IsValid()) {
 
826
                                m_pDatePickerTo->SetValue(m_toActual);
 
827
                        }
 
828
 
 
829
                        if (cambio || force) {
 
830
                                //se eliminan todos los estudios que no están abiertos
 
831
                                Freeze();
 
832
                                //se eliminan los nodos que ya no van a valer
 
833
                                PurgarHistorial(false);
 
834
 
 
835
                                //pillamos los estudios del paciente seleccionado
 
836
                                GNC::GCS::ControladorHistorial::ListaModelosSeries listaSeries;
 
837
                                GNC::GCS::ControladorHistorial::Instance()->GetModelosSeriePacienteModalidad(m_pacienteActual, m_modalidadActual, m_fromActual, m_toActual, timeFrom, timeTo, listaSeries);
 
838
                                CargarSeries(listaSeries, NULL);
 
839
                                GNC::GCS::ControladorEventos::Instance()->ProcesarEvento(new GNC::GUI::Eventos::EventoLayoutHistorial());
 
840
                                m_pResultTitle->SetTitle(_("Results") + wxString::Format(_(" (%d series)"), m_mapaUIDsAbribles.size()));
 
841
                                Thaw();
 
842
                        }
 
843
                }
 
844
 
 
845
                void PanelHistorial2::PurgarHistorial(bool ignoreActual)
 
846
                {
 
847
                        Freeze();
 
848
 
 
849
                        if (ignoreActual) {
 
850
 
 
851
                                //#1 eliminamos los estudios de pacientes que sobran
 
852
                                {
 
853
                                        std::list<GNC::GUI::INodoHistorial*> listaEliminar;
 
854
                                        bool todosLosPacientes = m_pacienteActual == _Std("All");
 
855
                                        if (!todosLosPacientes) {
 
856
                                                for(TMapaHijos::iterator it=m_mapaHijos.begin(); it!= m_mapaHijos.end(); it++) {
 
857
                                                        if (ignoreActual) {
 
858
                                                                if (((PanelPaciente*)(*it).second)->GetIdPaciente() == m_pacienteActual )
 
859
                                                                        continue;
 
860
                                                        }
 
861
                                                        if ((*it).second->HayNodosAbiertos()) {
 
862
                                                                (*it).second->EliminarNodosNoAbiertos();
 
863
                                                        } else {
 
864
                                                                listaEliminar.push_back((*it).second);
 
865
                                                        }
 
866
                                                }
 
867
                                        }
 
868
                                        for (std::list<GNC::GUI::INodoHistorial*>::iterator it = listaEliminar.begin(); it != listaEliminar.end(); ++it) {
 
869
                                                (*it)->Eliminar();
 
870
                                        }
 
871
                                }
 
872
                                //#2 eliminamos las series que sobran por modalidad
 
873
                                {
 
874
                                        std::list<GNC::GUI::INodoHistorial*> listaEliminar;
 
875
                                        bool todosLasModalidades = m_modalidadActual == _Std("All");
 
876
                                        if (!todosLasModalidades) {
 
877
                                                for (TMapaAbribles::iterator it = m_mapaUIDsAbribles.begin(); it != m_mapaUIDsAbribles.end(); ++it) {
 
878
                                                        PanelSerie* pPanel = (*it).second->GetSeries((*it).first);
 
879
                                                        if (pPanel != NULL) {
 
880
                                                                if (!pPanel->EstaAbierto() && pPanel->GetModalidad() != m_modalidadActual) {
 
881
                                                                        listaEliminar.push_back( pPanel);
 
882
                                                                }
 
883
                                                        }
 
884
                                                }
 
885
                                        }
 
886
                                        for (std::list<GNC::GUI::INodoHistorial*>::iterator it = listaEliminar.begin(); it != listaEliminar.end(); ++it) {
 
887
                                                (*it)->Eliminar();
 
888
                                        }
 
889
                                }
 
890
                        } else {
 
891
                                std::list<GNC::GUI::INodoHistorial*> listaEliminar;
 
892
                                for(TMapaHijos::iterator it=m_mapaHijos.begin(); it!= m_mapaHijos.end(); it++) {
 
893
                                        if ((*it).second->HayNodosAbiertos()) {
 
894
                                                (*it).second->EliminarNodosNoAbiertos();
 
895
                                        } else {
 
896
                                                listaEliminar.push_back((*it).second);
 
897
                                        }
 
898
                                }
 
899
                                for (std::list<GNC::GUI::INodoHistorial*>::iterator it = listaEliminar.begin(); it != listaEliminar.end(); ++it) {
 
900
                                        (*it)->Eliminar();
 
901
                                }
 
902
                        }
 
903
 
 
904
                        m_pResultTitle->SetTitle(_("Results") + wxString::Format(_(" (%d series)"), m_mapaUIDsAbribles.size()));
 
905
 
 
906
                        Thaw();
 
907
                }
 
908
 
 
909
                void PanelHistorial2::OnSize(wxSizeEvent &event)
 
910
                {
 
911
                        m_pCabeceraVacio->SetLabel(_("\nThere aren't any stored study that matches with the search filter.\n"));
 
912
                        m_pCabeceraVacio->Wrap(event.GetSize().x-20);
 
913
 
 
914
                        m_pMensajeVacio->SetLabel(_("\nTo begin working must change filter criteria, acquire an existing study or Import DICOM images to DICOM format.\n"));
 
915
                        m_pMensajeVacio->Wrap(event.GetSize().x-20);
 
916
 
 
917
                        m_pCabeceraNoCabeMas->SetLabel(_("\nThere is no size in the medical history to show every patients\n"));
 
918
                        m_pCabeceraNoCabeMas->Wrap(event.GetSize().x-40);
 
919
 
 
920
                        m_pMensajeNoCabeMas->SetLabel(_("\nTry using filters or collapsing nodes and refresh search\n"));
 
921
                        m_pMensajeNoCabeMas->Wrap(event.GetSize().x-40);
 
922
 
 
923
                        m_pPanelHistorial->Layout();
 
924
                        Layout();
 
925
                        this->GetParent()->Layout();
 
926
                        event.Skip();
 
927
                }
 
928
 
 
929
                void PanelHistorial2::OnMenuMouse(wxMouseEvent &event)
 
930
                {
 
931
                        wxMenu menu(wxEmptyString);
 
932
                        wxMenuItem* pMenuEliminar = new wxMenuItem(&menu, 1, wxString( _("&Clear History") ), _("Delete"), wxITEM_NORMAL );
 
933
                        menu.Connect(1,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler( PanelHistorial2::OnLimpiarHistorial),NULL,this);
 
934
                        #ifdef __WXMSW__
 
935
                        pMenuEliminar->SetBitmaps(GinkgoResourcesManager::IconosMenus::GetIcoEliminar());
 
936
                        #else
 
937
                        pMenuEliminar->SetBitmap(GinkgoResourcesManager::IconosMenus::GetIcoEliminar());
 
938
                        #endif
 
939
                        menu.Append(pMenuEliminar);
 
940
                        if(m_mapaHijos.size() == 0) {
 
941
                                pMenuEliminar->Enable(false);
 
942
                        }
 
943
                        menu.AppendSeparator();
 
944
 
 
945
                        wxMenuItem* pMenuAdquirir = new wxMenuItem(&menu, 3, wxString( _("&DICOM &Acquisition") ), _("Acquiring a new DICOM study"), wxITEM_NORMAL );
 
946
                        menu.Connect(3,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler( PanelPaciente::OnAdquirir),NULL,this);
 
947
 
 
948
                        wxMenuItem* pMenuOpenFile = new wxMenuItem(&menu, 4, wxString( _("&Open File") ), _("Open a DICOM file"), wxITEM_NORMAL );
 
949
                        menu.Connect(4,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler( PanelPaciente::OnOpenFile),NULL,this);
 
950
 
 
951
                        wxMenuItem* pMenuOpenFolder = new wxMenuItem(&menu, 5, wxString( _("&Open Folder") ), _("Acquire from a local folder"), wxITEM_NORMAL );
 
952
                        menu.Connect(5,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler( PanelPaciente::OnOpenFolder),NULL,this);
 
953
 
 
954
                        wxMenuItem* pMenuImportar = new wxMenuItem( &menu, 6, wxString( _("&Import ...") ), _("Import images"), wxITEM_NORMAL );
 
955
                        menu.Connect(6,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler( PanelPaciente::OnImportar),NULL,this);
 
956
                        
 
957
                        wxMenuItem* pMenuSend = new wxMenuItem(&menu, 7, wxString( _("Send to PACS server") ), _("Send to PACS server"), wxITEM_NORMAL );
 
958
                        menu.Connect(7,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler( PanelPaciente::OnUploadPACS),NULL,this);
 
959
 
 
960
 
 
961
                        #ifdef __WXMSW__
 
962
                        pMenuAdquirir->SetBitmaps(GinkgoResourcesManager::IconosMenus::GetIcoAbrir());
 
963
                        pMenuImportar->SetBitmaps(GinkgoResourcesManager::IconosMenus::GetIcoImportar());
 
964
                        pMenuOpenFile->SetBitmaps(GinkgoResourcesManager::IconosMenus::GetIcoOpenFile());
 
965
                        pMenuOpenFolder->SetBitmaps(GinkgoResourcesManager::IconosMenus::GetIcoOpenDir());
 
966
                        pMenuSend->SetBitmaps(GinkgoResourcesManager::IconosMenus::GetIcoSendToPACS());
 
967
                        #else
 
968
                        pMenuAdquirir->SetBitmap(GinkgoResourcesManager::IconosMenus::GetIcoAbrir());
 
969
                        pMenuImportar->SetBitmap(GinkgoResourcesManager::IconosMenus::GetIcoImportar());
 
970
                        pMenuOpenFile->SetBitmap(GinkgoResourcesManager::IconosMenus::GetIcoOpenFile());
 
971
                        pMenuOpenFolder->SetBitmap(GinkgoResourcesManager::IconosMenus::GetIcoOpenDir());
 
972
                        pMenuSend->SetBitmap(GinkgoResourcesManager::IconosMenus::GetIcoSendToPACS());
 
973
                        #endif
 
974
 
 
975
                        menu.Append(pMenuOpenFile);
 
976
                        menu.Append(pMenuOpenFolder);
 
977
                        if(GNC::GCS::ControladorPermisos::Instance()->Get("core.adquisicion","pacs")) {
 
978
                                menu.AppendSeparator();
 
979
                                menu.Append( pMenuAdquirir );
 
980
                        } else {
 
981
                                delete pMenuAdquirir;
 
982
                        }
 
983
                        menu.AppendSeparator();
 
984
                        menu.Append(pMenuSend);
 
985
                        menu.AppendSeparator();
 
986
                        menu.Append(pMenuImportar);
 
987
                        PopupMenu(&menu);
 
988
                        event.Skip(false);
 
989
                }
 
990
 
 
991
                void PanelHistorial2::OnMouseWheel(wxMouseEvent &event)
 
992
                {
 
993
                        if(event.GetWheelRotation() > 0)
 
994
                        {
 
995
                                m_pPanelHistorial->ScrollLines(-1);
 
996
                        }
 
997
                        else if(event.GetWheelRotation() < 0)
 
998
                        {
 
999
                                m_pPanelHistorial->ScrollLines(1);
 
1000
                        }
 
1001
                }
 
1002
 
 
1003
                void PanelHistorial2::OnMedicalHistoryClick(wxMouseEvent &)
 
1004
                {
 
1005
                        m_pPanelHistorial->SetFocus();
 
1006
                }
 
1007
 
 
1008
                void PanelHistorial2::OnLimpiarHistorial(wxCommandEvent& event)
 
1009
                {
 
1010
                        LimpiarHistorial();
 
1011
                        event.Skip(false);
 
1012
                }
 
1013
 
 
1014
                void PanelHistorial2::LimpiarHistorial()
 
1015
                {
 
1016
                        for(TMapaHijos::iterator it=m_mapaHijos.begin(); it!= m_mapaHijos.end(); it++) {
 
1017
                                if ((*it).second->HayNodosAbiertos())
 
1018
                                {
 
1019
                                        wxMessageBox(_("Failed to empty the history, you have to close opened studies"), _("Info"),
 
1020
                                                wxOK | wxICON_WARNING);
 
1021
                                        return;
 
1022
                                }
 
1023
                        }
 
1024
 
 
1025
                        bool eliminar = false;
 
1026
 
 
1027
                        DialogoConfirmacionEliminar dlg(GNC::Entorno::Instance()->GetVentanaRaiz(), _("all files"));
 
1028
                        dlg.ShowModal();
 
1029
                        switch (dlg.GetResultado()) {
 
1030
                                case DialogoConfirmacionEliminar::TR_Eliminar :
 
1031
                                        eliminar = GNC::GCS::ControladorHistorial::Instance()->VaciarHistorial(true);
 
1032
                                        break;
 
1033
                                case DialogoConfirmacionEliminar::TR_Cancelar :
 
1034
                                        break;
 
1035
                        }
 
1036
                        if(eliminar) {
 
1037
                                Freeze();
 
1038
                                for(TMapaHijos::iterator it=m_mapaHijos.begin(); it!= m_mapaHijos.end(); it++) {
 
1039
                                        wxWindow* pWin = dynamic_cast<wxWindow*> ((*it).second);
 
1040
                                        if(pWin!= NULL) {
 
1041
                                                GetSizer()->Detach(pWin);
 
1042
                                                pWin->Destroy();
 
1043
                                        }
 
1044
                                }
 
1045
                                m_mapaHijos.clear();
 
1046
                                m_mapaUIDsAbribles.clear();
 
1047
                                if(!m_pPanelMensajeVacio->IsShown()) {
 
1048
                                        m_pPanelMensajeVacio->Show();
 
1049
                                }
 
1050
                                m_pResultTitle->SetTitle(_("Results") + wxString::Format(_(" (%d series)"), 0));
 
1051
                                RecargarCombos(false);
 
1052
                                GNC::GCS::ControladorEventos::Instance()->ProcesarEvento(new GNC::GUI::Eventos::EventoLayoutHistorial());
 
1053
                                Thaw();
 
1054
                        }
 
1055
                }
 
1056
 
 
1057
                void PanelHistorial2::OnImportar(wxCommandEvent& )
 
1058
                {
 
1059
                        try{
 
1060
                                GNC::GUI::wxWizardImportacionGinkgo ib(this,NULL);
 
1061
                                ib.ShowModal();
 
1062
                        }
 
1063
                        catch(GIL::DICOM::I2DException i){
 
1064
                        }
 
1065
                }
 
1066
 
 
1067
                void PanelHistorial2::OnAdquirir(wxCommandEvent& )
 
1068
                {
 
1069
                        GNC::GUI::DialogoAdquisicion::Instance()->Show();
 
1070
                }
 
1071
 
 
1072
                void PanelHistorial2::Eliminar()
 
1073
                {
 
1074
                        if(!m_pPanelMensajeVacio->IsShown()) {
 
1075
                                m_pPanelMensajeVacio->Show();
 
1076
                                Layout();
 
1077
                        }
 
1078
                        m_mapaHijos.clear();
 
1079
                        m_mapaUIDsAbribles.clear();
 
1080
                }
 
1081
 
 
1082
                void PanelHistorial2::Detach(wxWindow* pHijo)
 
1083
                {
 
1084
                        m_pPanelHistorial->GetSizer()->Detach(pHijo);
 
1085
                        pHijo->Hide();
 
1086
                }
 
1087
 
 
1088
                void PanelHistorial2::PreProcesarEvento(GNC::GCS::Eventos::IEvento * evt, GNC::GCS::IControladorEventos::TipoListaPunterosEventos& lista)
 
1089
                {
 
1090
                        if (evt == NULL) {
 
1091
                                std::cerr << "Error: Evento nulo" << std::endl;
 
1092
                                return;
 
1093
                        }
 
1094
                        switch (evt->GetCodigoEvento()) {
 
1095
                                case ginkgoEVT_Core_HistorialSeleccionar:
 
1096
                                case ginkgoEVT_Core_HistorialLayout:
 
1097
                                        {
 
1098
                                                lista.push_back(new GNC::GUI::Eventos::EventoSetFocusHistorial());
 
1099
                                        }
 
1100
                                        break;
 
1101
                                default:
 
1102
                                        break;
 
1103
 
 
1104
                        }
 
1105
                }
 
1106
 
 
1107
                void PanelHistorial2::ProcesarEvento(GNC::GCS::Eventos::IEvento *evt)
 
1108
                {
 
1109
                        switch(evt->GetCodigoEvento()) {
 
1110
                                case ginkgoEVT_Core_ModificacionFichero:
 
1111
                                        {
 
1112
                                                GNC::GCS::Eventos::EventoModificacionFichero* pEvt = dynamic_cast<GNC::GCS::Eventos::EventoModificacionFichero*>(evt);
 
1113
                                                if(pEvt != NULL && pEvt->GetVistaModificada()!=NULL){
 
1114
                                                        std::list<std::string> listaUIDsSerie = pEvt->GetContextoEstudio()->ListaUIDsSerie;
 
1115
                                                        for(std::list<std::string>::const_iterator it = listaUIDsSerie.begin(); it != listaUIDsSerie.end(); ++it){
 
1116
                                                                TMapaAbribles::iterator it2 = m_mapaUIDsAbribles.find( (*it) );
 
1117
                                                                if(it2 != m_mapaUIDsAbribles.end()){//si esta en el arbol
 
1118
                                                                        if(pEvt->GetTipoEvento() == GNC::GCS::Eventos::EventoModificacionFichero::FicheroModificado){
 
1119
                                                                                PanelSerie* pPanel = (*it2).second->GetSeries((*it), true);
 
1120
                                                                                if (pPanel != NULL) {
 
1121
                                                                                        pPanel->VistaModificada(pEvt->GetVistaModificada());
 
1122
                                                                                }
 
1123
                                                                        } else if(pEvt->GetTipoEvento() == GNC::GCS::Eventos::EventoModificacionFichero::FicheroGuardado){
 
1124
                                                                                PanelSerie* pPanel = (*it2).second->GetSeries((*it), true);
 
1125
                                                                                if (pPanel != NULL) {
 
1126
                                                                                        pPanel->VistaGuardada(pEvt->GetVistaModificada());
 
1127
                                                                                }
 
1128
                                                                        }
 
1129
                                                                }
 
1130
                                                        }
 
1131
 
 
1132
                                                        if(pEvt->GetTipoEvento() == GNC::GCS::Eventos::EventoModificacionFichero::FicheroGuardado){
 
1133
                                                                //se lanza el comando de incluir en el historial con los diagnosticos
 
1134
                                                                std::list<std::string> nuevasRutas;
 
1135
                                                                std::vector<std::string> listaPaths = pEvt->GetContextoEstudio()->GetRutasDiagnosticos();
 
1136
                                                                for (std::vector<std::string>::const_iterator it = listaPaths.begin(); it != listaPaths.end(); ++it) {
 
1137
                                                                        nuevasRutas.push_back((*it));
 
1138
                                                                }
 
1139
                                                                GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorialParams* pParams = new GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorialParams(nuevasRutas,false,true);
 
1140
                                                                pParams->m_informar = false;
 
1141
                                                                GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorial* pCmd = new GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorial(pParams);
 
1142
                                                                GNC::Entorno::Instance()->GetControladorComandos()->ProcessAsync(_Std("Storing in the history..."),pCmd, NULL);
 
1143
                                                        }
 
1144
                                                }
 
1145
                                        }
 
1146
                                        break;
 
1147
                                case  ginkgoEVT_Core_AddFicheroHistorial:
 
1148
                                        {
 
1149
                                                GNC::GCS::Eventos::EventoAddFicheroHistorial* pEvtMod = dynamic_cast<GNC::GCS::Eventos::EventoAddFicheroHistorial*>(evt);
 
1150
                                                if(pEvtMod != NULL){
 
1151
                                                        //se lanza el comando de incluir en el historial
 
1152
                                                        GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorialParams* pParams = new GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorialParams(pEvtMod->GetListaRutas(), false, true);
 
1153
                                                        pParams->m_informar = false;
 
1154
                                                        GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorial* pCmd = new GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorial(pParams);
 
1155
                                                        GNC::Entorno::Instance()->GetControladorComandos()->ProcessAsync(_Std("Storing in the history..."),pCmd, NULL);
 
1156
                                                }
 
1157
                                        }
 
1158
                                        break;
 
1159
                                case  ginkgoEVT_Core_HistorialSeleccionar:
 
1160
                                        {
 
1161
                                                GNC::GUI::Eventos::EventoSeleccionarHistorial* pEvtSelecc = dynamic_cast<GNC::GUI::Eventos::EventoSeleccionarHistorial*>(evt);
 
1162
                                                if(pEvtSelecc != NULL) {
 
1163
                                                        GNC::GUI::ISeleccionableHistorial* pSeleccionable = pEvtSelecc->GetSeleccionable();
 
1164
                                                        if(pSeleccionable != m_pSeleccionado){
 
1165
                                                                if(m_pSeleccionado!= NULL) {
 
1166
                                                                        m_pSeleccionado->Seleccionar(false);
 
1167
                                                                }
 
1168
                                                                if(pSeleccionable != NULL){
 
1169
                                                                        pSeleccionable->Seleccionar(true);
 
1170
                                                                }
 
1171
                                                                m_pSeleccionado = pSeleccionable;
 
1172
                                                        }
 
1173
                                                }
 
1174
                                        }
 
1175
                                        break;
 
1176
                                case ginkgoEVT_Core_SetFocus:
 
1177
                                        {
 
1178
                                            #if defined(_WIN32) || defined(__WXOSX__)
 
1179
                                                m_pPanelHistorial->SetFocus();
 
1180
                                                #endif
 
1181
                                        }
 
1182
                                        break;
 
1183
                                case ginkgoEVT_Core_HistorialLayout:
 
1184
                                        {
 
1185
                                                // SuperHack
 
1186
                                                GNC::Entorno::Instance()->GetVentanaPrincipal()->SuperFreeze();
 
1187
                                                Freeze();
 
1188
                                                m_pPanelHistorial->Freeze();
 
1189
                                                #if defined(_WIN32) || defined(__WXOSX__)
 
1190
                                                int yPos = m_pPanelHistorial->GetScrollPos(wxVERTICAL);
 
1191
                                                m_pPanelHistorial->SetScrollbars(20, 20, 20, 30, 0, yPos, false);
 
1192
                                                m_pPanelHistorial->AdjustScrollbars();
 
1193
                                                #endif
 
1194
 
 
1195
                                                m_pPanelHistorial->Layout();
 
1196
                                                Layout();
 
1197
                                                this->GetParent()->Layout();
 
1198
                                                #if defined(_WIN32) || defined(__WXOSX__)
 
1199
                                                m_pPanelHistorial->Scroll(0, yPos);
 
1200
                                                Refresh(true);
 
1201
                                                #endif
 
1202
                                                m_pPanelHistorial->Thaw();
 
1203
                                                Thaw();
 
1204
                                                GNC::Entorno::Instance()->GetVentanaPrincipal()->SuperThaw();
 
1205
                                        }
 
1206
                                        break;
 
1207
                                case ginkgoEVT_Core_HistorialAbribleEliminado:
 
1208
                                        {
 
1209
                                                Freeze();
 
1210
                                                GNC::GUI::Eventos::EventoAbribleEliminado* pEvtElim = dynamic_cast<GNC::GUI::Eventos::EventoAbribleEliminado*>(evt);
 
1211
                                                if(pEvtElim != NULL) {
 
1212
                                                        for(std::list<std::string>::const_iterator itUIDs = pEvtElim->GetUIDs().begin(); itUIDs!= pEvtElim->GetUIDs().end(); itUIDs++){
 
1213
                                                                TMapaAbribles::iterator it = m_mapaUIDsAbribles.find((*itUIDs));
 
1214
                                                                if(it!= m_mapaUIDsAbribles.end()) {
 
1215
                                                                        m_mapaUIDsAbribles.erase(it);
 
1216
                                                                }
 
1217
                                                        }
 
1218
                                                }
 
1219
                                                Thaw();
 
1220
                                        }
 
1221
                                        break;
 
1222
                                case ginkgoEVT_Core_HistorialRecargarHistorial:
 
1223
                                        {
 
1224
                                                Freeze();
 
1225
                                                GNC::GUI::Eventos::EventoRecargarHistorial* pEvtRecargar = dynamic_cast<GNC::GUI::Eventos::EventoRecargarHistorial*>(evt);
 
1226
                                                if(pEvtRecargar != NULL) {
 
1227
                                                        for(TMapaHijos::iterator it=m_mapaHijos.begin(); it!= m_mapaHijos.end(); it++) {
 
1228
                                                                wxWindow* pWin = dynamic_cast<wxWindow*> ((*it).second);
 
1229
                                                                if(pWin!= NULL) {
 
1230
                                                                        GetSizer()->Detach(pWin);
 
1231
                                                                        pWin->Destroy();
 
1232
                                                                }
 
1233
                                                        }
 
1234
                                                        m_mapaHijos.clear();
 
1235
                                                        m_mapaUIDsAbribles.clear();
 
1236
                                                        if(!m_pPanelMensajeVacio->IsShown()) {
 
1237
                                                                m_pPanelMensajeVacio->Show();
 
1238
                                                        }
 
1239
                                                        Layout();
 
1240
 
 
1241
                                                        //se vacia el historial
 
1242
                                                        GNC::GCS::ControladorHistorial::Instance()->RecargarHistorial();
 
1243
                                                        RecargarCombos(false);
 
1244
                                                        RecargarBusqueda(true);
 
1245
                                                }
 
1246
                                                Thaw();
 
1247
                                        }
 
1248
                                        break;
 
1249
                                case ginkgoEVT_Core_AddModeloHistorial:
 
1250
                                        {
 
1251
                                                //no freeze porque muestra diálogos
 
1252
                                                GNC::GUI::Eventos::EventoAddModeloHistorial* pEvtAdd = dynamic_cast<GNC::GUI::Eventos::EventoAddModeloHistorial*>(evt);
 
1253
                                                if(pEvtAdd != NULL) {
 
1254
 
 
1255
                                                        bool todos = m_pacienteActual == _Std("All");
 
1256
                                                        GNC::GCS::ControladorHistorial::ListaModelosDCM listaPacienteActual;
 
1257
                                                        for(GNC::GCS::ControladorHistorial::ListaModelosDCM::iterator it = pEvtAdd->GetListaModelos()->begin(); it!= pEvtAdd->GetListaModelos()->end(); it++) {
 
1258
                                                                if (todos || (*it).m_idPaciente == m_pacienteActual || pEvtAdd->GetAbrirDespuesDeCargar()) {
 
1259
                                                                        listaPacienteActual.push_back((*it));
 
1260
                                                                }
 
1261
                                                        }
 
1262
                                                        if (listaPacienteActual.size() > 0) {
 
1263
                                                                CargarDCMs( listaPacienteActual, pEvtAdd->GetModeloIntegracion(), true);
 
1264
                                                                if (pEvtAdd->GetAbrirDespuesDeCargar()) {
 
1265
                                                                        //se pilla la primear serie y se abre
 
1266
                                                                        const std::string& uidSerie =listaPacienteActual.front().m_uidSerie;
 
1267
                                                                        if ( m_mapaUIDsAbribles.find(uidSerie) != m_mapaUIDsAbribles.end() ){
 
1268
                                                                                PanelSerie* pPanel = m_mapaUIDsAbribles[uidSerie]->GetSeries(uidSerie, true);
 
1269
                                                                                if (pPanel != NULL) {
 
1270
                                                                                        pPanel->Abrir();
 
1271
                                                                                }
 
1272
                                                                        }
 
1273
                                                                }
 
1274
                                                        }
 
1275
                                                        RecargarCombos(false);
 
1276
                                                }
 
1277
 
 
1278
                                        }
 
1279
                                        break;
 
1280
                                case ginkgoEVT_Core_Estilo:
 
1281
                                        {
 
1282
                                                Freeze();
 
1283
                                                GNC::GCS::Eventos::EventoColorPaciente* pEvtColor = dynamic_cast<GNC::GCS::Eventos::EventoColorPaciente*>(evt);
 
1284
                                                if(pEvtColor != NULL) {
 
1285
                                                        wxColour colorPaciente = GetColorPaciente(pEvtColor->GetIdPaciente());
 
1286
                                                        GNC::GCS::Eventos::EventoColorPaciente::TColor color;
 
1287
                                                        color.r = colorPaciente.Red();
 
1288
                                                        color.g = colorPaciente.Green();
 
1289
                                                        color.b = colorPaciente.Blue();
 
1290
                                                        pEvtColor->SetColorPaciente(color);
 
1291
                                                }
 
1292
                                                Thaw();
 
1293
                                        }
 
1294
                                        break;
 
1295
                                case ginkgoEVT_Core_LimpiarHistorial:
 
1296
                                        {
 
1297
                                                //no freeze porque muestra diálogos
 
1298
                                                LimpiarHistorial();
 
1299
                                        }
 
1300
                                        break;
 
1301
                                case ginkgoEVT_Core_HandleDICOM :
 
1302
                                        {
 
1303
                                                GNC::GCS::Eventos::EvtHandleDicom* pEvt = dynamic_cast<GNC::GCS::Eventos::EvtHandleDicom*>(evt);
 
1304
                                                if (pEvt->GetAction() == GNC::GCS::Eventos::EvtHandleDicom::OpenSeries) {
 
1305
                                                        const GNC::GCS::Eventos::EvtHandleDicom::ListaUIDs& listaUIDs = pEvt->GetListaUIDs();
 
1306
                                                        GNC::GCS::Eventos::EvtHandleDicom::ListaUIDs listaUIDsNoHistorial;
 
1307
                                                        for (GNC::GCS::Eventos::EvtHandleDicom::ListaUIDs::const_iterator it = listaUIDs.begin(); it != listaUIDs.end(); ++it)
 
1308
                                                        {
 
1309
                                                                if (m_mapaUIDsAbribles.find((*it)) == m_mapaUIDsAbribles.end()) {
 
1310
                                                                        listaUIDsNoHistorial.push_back((*it));
 
1311
                                                                } else {
 
1312
                                                                        PanelSerie* pPanel = m_mapaUIDsAbribles[(*it)]->GetSeries((*it), true);
 
1313
                                                                        if (pPanel) {
 
1314
                                                                                pPanel->Abrir();
 
1315
                                                                        }
 
1316
                                                                }
 
1317
                                                        }
 
1318
                                                        //se añaden al historial
 
1319
                                                        GNC::GCS::IControladorHistorial::ListaModelosSeries listaModelosSerie;
 
1320
                                                        GNC::GCS::ControladorHistorial::Instance()->GetAllModelosSerieSeries(listaUIDsNoHistorial, listaModelosSerie);
 
1321
                                                        CargarSeries(listaModelosSerie, NULL);
 
1322
 
 
1323
                                                        for (GNC::GCS::IControladorHistorial::ListaModelosSeries::iterator it = listaModelosSerie.begin(); it != listaModelosSerie.end(); ++it) {
 
1324
                                                                //se pilla la serie y se abre
 
1325
                                                                const std::string& uidSerie =(*it).m_uidSerie;
 
1326
                                                                if ( m_mapaUIDsAbribles.find(uidSerie) != m_mapaUIDsAbribles.end() ){
 
1327
                                                                        PanelSerie* pPanel = m_mapaUIDsAbribles[uidSerie]->GetSeries(uidSerie, true);
 
1328
                                                                        if (pPanel != NULL) {
 
1329
                                                                                pPanel->Abrir();
 
1330
                                                                        }
 
1331
                                                                }
 
1332
                                                        }
 
1333
                                                } else {
 
1334
                                                        //delete
 
1335
                                                        const GNC::GCS::Eventos::EvtHandleDicom::ListaUIDs& listaUIDs = pEvt->GetListaUIDs();
 
1336
                                                        GNC::GCS::Eventos::EvtHandleDicom::ListaUIDs listaUIDsNoHistorial;
 
1337
                                                        for (GNC::GCS::Eventos::EvtHandleDicom::ListaUIDs::const_iterator it = listaUIDs.begin(); it != listaUIDs.end(); ++it)
 
1338
                                                        {
 
1339
                                                                if (m_mapaUIDsAbribles.find((*it)) == m_mapaUIDsAbribles.end()) {
 
1340
                                                                        listaUIDsNoHistorial.push_back((*it));
 
1341
                                                                } else {
 
1342
                                                                        PanelSerie* pPanel = m_mapaUIDsAbribles[(*it)]->GetSeries((*it), true);
 
1343
                                                                        if (pPanel) {
 
1344
                                                                                if (!pPanel->DoDelete(false)) {
 
1345
                                                                                        return;
 
1346
                                                                                }
 
1347
                                                                        }
 
1348
                                                                }
 
1349
                                                        }
 
1350
                                                        //
 
1351
                                                        GNC::GCS::ControladorHistorial::Instance()->DeleteSeriesList(listaUIDsNoHistorial, true);
 
1352
                                                        RecargarCombos(false);
 
1353
                                                        RecargarBusqueda();
 
1354
                                                }
 
1355
                                        }
 
1356
                                        break;
 
1357
                                case ginkgoEVT_Core_Views:
 
1358
                                        {
 
1359
                                                GNC::GCS::Eventos::EventView* pEvt = dynamic_cast<GNC::GCS::Eventos::EventView*>(evt);
 
1360
                                                if (pEvt != NULL)
 
1361
                                                {
 
1362
                                                        if (pEvt->GetType() == GNC::GCS::Eventos::EventView::Creation) {
 
1363
                                                                DICOMActivado(pEvt->GetView());
 
1364
                                                        } else {
 
1365
                                                                DICOMDesactivado(pEvt->GetView());
 
1366
                                                        }
 
1367
                                                }                                               
 
1368
                                        }
 
1369
                                        break;
 
1370
                                case ginkgoEVT_Core_DeleteFile:
 
1371
                                        {
 
1372
                                                GNC::GCS::Eventos::EventDeleteFileHistory* pEvt = dynamic_cast<GNC::GCS::Eventos::EventDeleteFileHistory*>(evt);
 
1373
                                                if (pEvt != NULL)
 
1374
                                                {
 
1375
                                                        //delete files from history
 
1376
                                                        if (GNC::GCS::ControladorHistorial::Instance()->DeleteFilesList(pEvt->GetPatientId(), pEvt->GetStudyId(), pEvt->GetSeriesId(), (GNC::GCS::IControladorHistorial::ListaStrings)pEvt->GetIdList()))
 
1377
                                                        {
 
1378
                                                                if (m_mapaUIDsAbribles.find(pEvt->GetSeriesId()) != m_mapaUIDsAbribles.end()) {
 
1379
                                                                        PanelSerie* pPanel = m_mapaUIDsAbribles[pEvt->GetSeriesId()]->GetSeries(pEvt->GetSeriesId(), true);
 
1380
                                                                        if (pPanel) {
 
1381
                                                                                if (pPanel->RefrescarNumeroSlices() == 0) {
 
1382
                                                                                        pPanel->DoDelete(false);
 
1383
                                                                                }
 
1384
                                                                        }
 
1385
                                                                }                                                               
 
1386
                                                        }
 
1387
                                                }
 
1388
                                        }
 
1389
                                        break;
 
1390
                        }
 
1391
                }
 
1392
//endregion
 
1393
 
 
1394
        };
 
1395
};