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

« back to all changes in this revision

Viewing changes to src/cadxcore/main/gui/history/ipanelhistorial.h

  • 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: ipanelhistorial.h 3521 2011-03-16 14:54:22Z carlos $
 
4
 *  Ginkgo CADx Project
 
5
 *
 
6
 *  Copyright 2008-10 MetaEmotion S.L. All rights reserved.
 
7
 *  http://ginkgo-cadx.com
 
8
 *
 
9
 *  This file is licensed under LGPL v3 license.
 
10
 *  See License.txt for details
 
11
 *
 
12
 *
 
13
 */
 
14
#pragma once
 
15
#include <vector>
 
16
#include <list>
 
17
#include <map>
 
18
 
 
19
#include <api/ievento.h>
 
20
#include <yasper/yasper.h>
 
21
#include <api/imodelointegracion.h>
 
22
#include <api/icontroladorhistorial.h>
 
23
 
 
24
#define ginkgoEVT_Core_HistorialSeleccionar         100
 
25
#define ginkgoEVT_Core_HistorialLayout              101
 
26
#define ginkgoEVT_Core_HistorialAbribleEliminado    102
 
27
#define ginkgoEVT_Core_HistorialRecargarHistorial   103
 
28
#define ginkgoEVT_Core_AddModeloHistorial           104
 
29
#define ginkgoEVT_Core_LimpiarHistorial             105
 
30
#define ginkgoEVT_Core_SetFocus                     106
 
31
 
 
32
 
 
33
class wxWindow;
 
34
namespace GNC {
 
35
        namespace GUI {
 
36
                //nodo seleccionable
 
37
                class ISeleccionableHistorial {
 
38
                protected:
 
39
                        bool m_seleccionado;
 
40
                public:                 
 
41
                        ISeleccionableHistorial(){
 
42
                                m_seleccionado = false;
 
43
                        }
 
44
                        ~ISeleccionableHistorial(){
 
45
                        }
 
46
                        bool EstaSeleccionado()
 
47
                        {
 
48
                                return m_seleccionado;
 
49
                        }
 
50
                        virtual void Seleccionar(bool seleccionar, bool force=false) = 0;
 
51
                };
 
52
 
 
53
                //nodo abrible
 
54
                class IAbribleHistorial {
 
55
                protected:
 
56
                        bool m_abierto;
 
57
                public:                 
 
58
                        IAbribleHistorial(){
 
59
                                m_abierto = false;
 
60
                        }
 
61
                        ~IAbribleHistorial(){
 
62
                        }
 
63
                        bool EstaAbierto()
 
64
                        {
 
65
                                return m_abierto;
 
66
                        }
 
67
                        virtual void Abrir(bool forzarEstudio = false) = 0;
 
68
                        virtual void AddVista(GNC::GCS::IVista* pVista) = 0;
 
69
                        virtual void VistaModificada(GNC::GCS::IVista* pVista) = 0;
 
70
                        virtual void VistaGuardada(GNC::GCS::IVista* pVista) = 0;
 
71
                        virtual void RemoveVista(GNC::GCS::IVista* pVista) = 0;
 
72
                };
 
73
 
 
74
                class INodoHistorial {
 
75
                public:
 
76
                        typedef std::map<std::string,GNC::GUI::INodoHistorial*> TMapaHijos;
 
77
                        INodoHistorial(INodoHistorial* pPadre,const std::string& clave) 
 
78
                        {
 
79
                                m_pPadre = pPadre;
 
80
                                m_clave = clave;
 
81
                        }
 
82
                        ~INodoHistorial() 
 
83
                        {
 
84
                                m_pPadre = NULL;
 
85
                        }
 
86
                        INodoHistorial* GetParentNode()
 
87
                        {
 
88
                                return m_pPadre;
 
89
                        }
 
90
 
 
91
                        bool Eliminar(INodoHistorial* pHijo) 
 
92
                        {
 
93
                                TMapaHijos::iterator it = m_mapaHijos.find(pHijo->GetClave());
 
94
                                if(it != m_mapaHijos.end()){
 
95
                                        m_mapaHijos.erase(it);
 
96
                                        if(m_mapaHijos.size() == 0) {
 
97
                                                Eliminar();
 
98
                                                return false;
 
99
                                        }
 
100
                                } 
 
101
                                return true;
 
102
                        }
 
103
                        virtual void Detach(wxWindow* pHijo) = 0;
 
104
                        virtual void Eliminar() = 0;
 
105
                        const std::string& GetClave() 
 
106
                        {
 
107
                                return m_clave;
 
108
                        }
 
109
                        bool HayNodosAbiertos()
 
110
                        {
 
111
                                IAbribleHistorial* pAbrible = dynamic_cast<IAbribleHistorial*>(this);
 
112
                                if (pAbrible != NULL)
 
113
                                {
 
114
                                        if (pAbrible->EstaAbierto()) {
 
115
                                                return true;
 
116
                                        }
 
117
                                }
 
118
                                for(TMapaHijos::iterator it=m_mapaHijos.begin(); it!= m_mapaHijos.end(); it++) {
 
119
                                        pAbrible = dynamic_cast<IAbribleHistorial*>((*it).second);
 
120
                                        if (pAbrible != NULL)
 
121
                                        {
 
122
                                                if (pAbrible->EstaAbierto()) {
 
123
                                                        return true;
 
124
                                                }
 
125
                                        } else {
 
126
                                                if ((*it).second->HayNodosAbiertos()) {
 
127
                                                        return true;
 
128
                                                }
 
129
                                        }
 
130
                                }
 
131
                                return false;
 
132
                        }
 
133
 
 
134
                        void EliminarNodosNoAbiertos() {
 
135
                                //se hace esto para evitar borrar elementos de un mapa que estamos recorriendo
 
136
                                std::list<GNC::GUI::INodoHistorial*> listaHijos;
 
137
 
 
138
                                for(TMapaHijos::iterator it=m_mapaHijos.begin(); it!= m_mapaHijos.end(); it++) {
 
139
                                        listaHijos.push_back((*it).second);
 
140
                                }
 
141
 
 
142
                                for (std::list<GNC::GUI::INodoHistorial*>::iterator it = listaHijos.begin(); it != listaHijos.end(); ++it) {
 
143
                                        IAbribleHistorial* pAbrible = dynamic_cast<IAbribleHistorial*>((*it));
 
144
                                        if (pAbrible != NULL)
 
145
                                        {
 
146
                                                if (!pAbrible->EstaAbierto()) {
 
147
                                                        //se elimina
 
148
                                                        (*it)->Eliminar();
 
149
                                                }
 
150
                                        } else {
 
151
                                                (*it)->EliminarNodosNoAbiertos();
 
152
                                        }
 
153
                                }
 
154
                        }
 
155
                protected:
 
156
                        TMapaHijos m_mapaHijos;
 
157
                        INodoHistorial* m_pPadre;
 
158
                        std::string m_clave;
 
159
                };
 
160
 
 
161
                //eventos variados...
 
162
                //evento de seleccion
 
163
                namespace Eventos {
 
164
                        class EventoSeleccionarHistorial: public GNC::GCS::Eventos::IEvento
 
165
                        {
 
166
                        public:
 
167
                                EventoSeleccionarHistorial():GNC::GCS::Eventos::IEvento(ginkgoEVT_Core_HistorialSeleccionar)
 
168
                                {
 
169
                                        m_Nombre = "SeleccionarHistorial";
 
170
                                        m_pSeleccionable=NULL;
 
171
                                }
 
172
 
 
173
                                EventoSeleccionarHistorial(ISeleccionableHistorial* pSeleccionable ):GNC::GCS::Eventos::IEvento(ginkgoEVT_Core_HistorialSeleccionar)
 
174
                                {
 
175
                                        m_pSeleccionable = pSeleccionable;
 
176
                                }
 
177
 
 
178
                                ~EventoSeleccionarHistorial()
 
179
                                {
 
180
                                }
 
181
 
 
182
                                ISeleccionableHistorial* GetSeleccionable()
 
183
                                {
 
184
                                        return m_pSeleccionable;
 
185
                                }
 
186
 
 
187
                        protected:
 
188
                                ISeleccionableHistorial* m_pSeleccionable;
 
189
                        };
 
190
 
 
191
                        class EventoLayoutHistorial: public GNC::GCS::Eventos::IEvento
 
192
                        {
 
193
                        public:
 
194
 
 
195
                                EventoLayoutHistorial():GNC::GCS::Eventos::IEvento(ginkgoEVT_Core_HistorialLayout)
 
196
                                {
 
197
                                        m_Nombre = "LayoutHistorial";
 
198
                                }
 
199
 
 
200
                                ~EventoLayoutHistorial()
 
201
                                {
 
202
                                }
 
203
                        protected:
 
204
                        };
 
205
 
 
206
                        class EventoSetFocusHistorial: public GNC::GCS::Eventos::IEvento
 
207
                        {
 
208
                        public:
 
209
 
 
210
                                EventoSetFocusHistorial():GNC::GCS::Eventos::IEvento(ginkgoEVT_Core_SetFocus)
 
211
                                {
 
212
                                        m_Nombre = "SetFocusHistorial";
 
213
                                }
 
214
 
 
215
                                ~EventoSetFocusHistorial()
 
216
                                {
 
217
                                }
 
218
                        protected:
 
219
                        };
 
220
 
 
221
                        class EventoAbribleEliminado: public GNC::GCS::Eventos::IEvento
 
222
                        {
 
223
                                public:
 
224
                                EventoAbribleEliminado():GNC::GCS::Eventos::IEvento(ginkgoEVT_Core_HistorialAbribleEliminado)
 
225
                                {
 
226
                                        m_Nombre = "SeleccionarHistorial";
 
227
                                }
 
228
 
 
229
                                EventoAbribleEliminado( const std::list<std::string>& UIDS ):GNC::GCS::Eventos::IEvento(ginkgoEVT_Core_HistorialAbribleEliminado)
 
230
                                {
 
231
                                        m_UIDS = UIDS;
 
232
                                }
 
233
 
 
234
                                ~EventoAbribleEliminado()
 
235
                                {
 
236
                                }
 
237
 
 
238
                                const std::list<std::string>& GetUIDs() {
 
239
                                        return m_UIDS;
 
240
                                }
 
241
 
 
242
                        protected:
 
243
                                std::list<std::string> m_UIDS;
 
244
                        };
 
245
 
 
246
                class EventoRecargarHistorial: public GNC::GCS::Eventos::IEvento
 
247
                        {
 
248
                                public:
 
249
                                EventoRecargarHistorial():GNC::GCS::Eventos::IEvento(ginkgoEVT_Core_HistorialRecargarHistorial)
 
250
                                {
 
251
                                        m_Nombre = "EventoRecargarHistorial";
 
252
                                }
 
253
 
 
254
                                ~EventoRecargarHistorial()
 
255
                                {
 
256
                                }
 
257
 
 
258
 
 
259
                        protected:
 
260
                        };
 
261
 
 
262
                class EventoAddModeloHistorial: public GNC::GCS::Eventos::IEvento
 
263
                        {
 
264
                        public:
 
265
                                EventoAddModeloHistorial(GNC::GCS::IControladorHistorial::ListaModelosDCM* pListaModelos = NULL, bool abrirDespuesDeCargar = true, GnkPtr<GIL::IModeloIntegracion> pModeloIntegracion=NULL ):GNC::GCS::Eventos::IEvento(ginkgoEVT_Core_AddModeloHistorial)
 
266
                                {
 
267
                                        m_pListaModelos        = pListaModelos;
 
268
                                        m_abrirDespuesDeCargar = abrirDespuesDeCargar;
 
269
                                        m_pModeloIntegracion   = pModeloIntegracion;
 
270
                                        m_Nombre               = "AddModeloHistorial";
 
271
                                }
 
272
 
 
273
                                ~EventoAddModeloHistorial()
 
274
                                {
 
275
                                        m_pListaModelos = NULL;
 
276
                                }
 
277
 
 
278
                                GNC::GCS::IControladorHistorial::ListaModelosDCM* GetListaModelos()
 
279
                                {
 
280
                                        return m_pListaModelos;
 
281
                                }
 
282
 
 
283
                                bool GetAbrirDespuesDeCargar(){
 
284
                                        return m_abrirDespuesDeCargar;
 
285
                                }
 
286
 
 
287
                                virtual void pushInfo(std::ostream& out) const {
 
288
                                        out << "Rutas = [ ";
 
289
                                        out << " ]";
 
290
                                }
 
291
 
 
292
                                GnkPtr<GIL::IModeloIntegracion> GetModeloIntegracion() {
 
293
                                        return m_pModeloIntegracion;
 
294
                                }
 
295
 
 
296
                        protected:
 
297
                                bool                                              m_abrirDespuesDeCargar;
 
298
                                GNC::GCS::IControladorHistorial::ListaModelosDCM* m_pListaModelos;
 
299
                                GnkPtr<GIL::IModeloIntegracion>                   m_pModeloIntegracion;
 
300
                        };
 
301
 
 
302
                        class EventoLimpiarHistorial: public GNC::GCS::Eventos::IEvento
 
303
                        {
 
304
                        public:
 
305
 
 
306
                                EventoLimpiarHistorial():GNC::GCS::Eventos::IEvento(ginkgoEVT_Core_LimpiarHistorial)
 
307
                                {
 
308
                                        m_Nombre = "LimpiarHistorial";
 
309
                                }
 
310
 
 
311
                                ~EventoLimpiarHistorial()
 
312
                                {
 
313
                                }
 
314
                        protected:
 
315
                        };
 
316
                };//eventos             
 
317
 
 
318
                class IPanelHistorial {
 
319
                public:                 
 
320
                        IPanelHistorial() { }
 
321
 
 
322
                        ~IPanelHistorial() { }
 
323
                        
 
324
                //      virtual void CargarDICOM( const std::vector<std::string>& rutas, bool abrirDespuesDeCargar )=0;
 
325
 
 
326
                        virtual void DICOMActivado( GNC::GCS::IVista* pVista )=0;
 
327
 
 
328
                        virtual void DICOMDesactivado( GNC::GCS::IVista* pVista )=0;
 
329
                };
 
330
        };
 
331
};