]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.h
19f0210a8605dfb2e0c893c400ecc174c6f6986f
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVtkBaseView.h
1
2
3 #ifndef __WX_VTK__BASE__VIEW__H
4 #define __WX_VTK__BASE__VIEW__H
5
6
7
8 #include <vtkRenderer.h>
9 #include <vtkRenderWindow.h>
10 #include <vtkCamera.h>
11 #include <vtkTextActor.h>
12
13 //EEDxx include
14 #include <vtkProperty.h>
15 #include <vtkActor.h>
16
17
18 #include <vtkImageViewer2.h> 
19 #include <vtkInteractorStyleImage.h> 
20
21 #include "wxMPRBaseData.h"
22 #include "wxVTKRenderWindowInteractorEditContour.h"
23
24 #include <wx/wx.h>
25
26
27
28 #include <vector>
29 #include "marTypes.h"
30
31
32 //------------------------------------------------------------------
33 //------------------------------------------------------------------
34 //------------------------------------------------------------------
35
36
37 class  creaMaracasVisu_EXPORT vtkImageViewer2_XYZ{
38 public:
39         vtkImageViewer2_XYZ();
40         ~vtkImageViewer2_XYZ();
41
42         void                    SetExtentDimension(int x1,int x2, int y1,int y2, int z1,int z2);
43         void                    SetXSlice(int slice);
44         void                    SetYSlice(int slice);
45         void                    SetZSlice(int slice);
46         int                             GetXSlice();
47         int                             GetYSlice();
48         int                             GetZSlice();
49         vtkImageViewer2 *GetVtkImageViewer2();
50
51 private:
52         int     _x1,_x2,_y1,_y2,_z1,_z2;
53         vtkImageViewer2 *_vtkimageviewer2;
54 protected:      
55 };
56
57
58
59 //------------------------------------------------------------------
60 //------------------------------------------------------------------
61 //------------------------------------------------------------------
62
63 class wxVtkBaseView;
64
65 class creaMaracasVisu_EXPORT wxVTKRenderWindowInteractorPlus : public wxVTKRenderWindowInteractor
66 {
67 public:
68         wxVTKRenderWindowInteractorPlus(wxWindow *parent ,wxVtkBaseView *_wxvtkbaseview);
69         virtual ~wxVTKRenderWindowInteractorPlus();
70
71         wxVTKRenderWindowInteractorPlus();
72          void OnLeftDClick( wxMouseEvent& event );   
73          void OnRightDClick( wxMouseEvent& event );   
74          void OnMiddleDClick( wxMouseEvent& event );   
75          void OnMouseWheel( wxMouseEvent& event );
76
77
78  // VTK
79     static wxVTKRenderWindowInteractorPlus * New();
80
81 protected:
82 private:
83         wxVtkBaseView   *_wxvtkbaseview;
84   DECLARE_EVENT_TABLE( );
85
86
87 };
88
89 //------------------------------------------------------------------
90 //------------------------------------------------------------------
91 //------------------------------------------------------------------
92
93
94 class vtkInteractorStyleBaseView;
95
96
97 class creaMaracasVisu_EXPORT wxVtkBaseView{
98 public:
99         wxVtkBaseView( );
100         wxVtkBaseView( wxWindow *parent );
101         virtual ~wxVtkBaseView();
102         wxVTKRenderWindowInteractor             *GetWxVTKRenderWindowInteractor();
103         virtual void                                    Configure();
104         virtual void                                    Refresh();
105         virtual void                                    RefreshView();
106         virtual vtkRenderer*                    GetRenderer();
107         virtual vtkRenderWindow*                GetRenWin();
108         virtual void                                    TransfromeCoordScreenToWorld(double &X, double &Y, double &Z, int type=2);
109         void                                                    SetInteractorStyleBaseView( vtkInteractorStyleBaseView* interactorStyle);
110         vtkInteractorStyleBaseView*             GetInteractorStyleBaseView();
111         virtual void                                    GetSpacing(double spc[3]);
112
113 private:
114         wxWindow                                                *_parent;
115         wxVTKRenderWindowInteractor             *_iren;
116         vtkInteractorStyleBaseView              *_interactorStyle;
117 protected:
118
119 };
120
121
122
123 //------------------------------------------------------------------
124 //------------------------------------------------------------------
125 //------------------------------------------------------------------
126
127 class vtkInteractorStyleBaseView;
128 class manualInteractorWindowLevel;
129 class vtkInfoTextImage;
130 class vtkInfoTextImageInteractor;
131
132 //------------------------------------------------------------------
133
134
135 class creaMaracasVisu_EXPORT wxVtk2DBaseView: public wxVtkBaseView{
136 public:
137         wxVtk2DBaseView(wxWindow *parent);
138         virtual ~wxVtk2DBaseView();
139         virtual void                    Configure(bool okimage=true);
140         vtkImageViewer2_XYZ*    _imageViewer2XYZ;
141         vtkBaseData*                    GetVtkBaseData();
142         void                                    SetVtkBaseData(vtkBaseData *vtkbasedata);
143         virtual void                    Refresh();
144         virtual void                    ResetView();
145         virtual int                             GetActualSlice();
146         virtual void                    SetActualSlice(int slice);
147                         void                    SetInteractorStyleImage(vtkInteractorStyleBaseView *interactorstylebaseview);
148
149         virtual vtkRenderer*            GetRenderer();
150         virtual vtkRenderWindow*        GetRenWin();
151         virtual void                    TransformCoordinate_spacing_ViewToModel(double &X,double &Y, double &Z);
152         virtual void                    TransformCoordinate_spacing_ModelToView(double &X,double &Y, double &Z);
153         virtual void                    GetSpacing(double spc[3]);
154
155
156 private:
157         vtkBaseData                                                     *_vtkbasedata;
158
159         vtkInfoTextImage                                        *_vtkIinfoTextImage;
160         vtkInfoTextImageInteractor                      *_vtkIinfoTextImageInteractor;
161
162 protected:
163
164 };
165
166
167
168
169 //------------------------------------------------------------------
170 //------------------------------------------------------------------
171 //------------------------------------------------------------------
172
173
174 //------------------------------------------------------------------
175
176 class creaMaracasVisu_EXPORT InteractorStyleMaracas 
177 {
178 public:
179         InteractorStyleMaracas();
180         virtual ~InteractorStyleMaracas();
181
182         virtual InteractorStyleMaracas * Clone();
183         void CopyAttributesTo( InteractorStyleMaracas *cloneObject );
184
185
186         virtual bool  OnChar();
187         virtual bool  OnMouseMove();
188         virtual bool  OnLeftButtonDown(); 
189         virtual bool  OnLeftButtonUp();
190         virtual bool  OnMiddleButtonDown(); 
191         virtual bool  OnMiddleButtonUp();
192         virtual bool  OnRightButtonDown();
193         virtual bool  OnRightButtonUp();
194
195         virtual bool  OnLeftDClick();
196         virtual bool  OnRightDClick();   
197         virtual bool  OnMiddleDClick();  
198         virtual bool  OnMouseWheel();    
199
200
201                         void  SetVtkInteractorStyleBaseView(vtkInteractorStyleBaseView* _vtkInteractorStyleBaseView);
202                         void  RemoveVtkInteractorStyleBaseView();
203         void SetActive(bool active);
204         bool GetActive();
205
206 protected:
207         vtkInteractorStyleBaseView* _vtkInteractorStyleBaseView;
208 private:
209         bool                                            _active;
210 };
211
212 //------------------------------------------------------------------
213 //------------------------------------------------------------------
214 //------------------------------------------------------------------
215
216
217
218 class creaMaracasVisu_EXPORT manualInteractorWindowLevel : public InteractorStyleMaracas {
219 public:
220         manualInteractorWindowLevel();
221         virtual ~manualInteractorWindowLevel();
222 protected:
223
224         bool    _stateWindowLevel;
225         int             _backPx;
226         int             _backPy;
227         int             _backWindow;
228         int             _backLevel;
229
230         virtual bool  OnMouseMove();
231         virtual bool  OnMiddleButtonDown(); 
232         virtual bool  OnMiddleButtonUp();
233 };
234
235
236 //------------------------------------------------------------------
237 //------------------------------------------------------------------
238 //------------------------------------------------------------------
239
240 class vtkInfoTextImage{
241 public:
242         vtkInfoTextImage();
243         ~vtkInfoTextImage();
244         void SetWxVtk2DBaseView(wxVtk2DBaseView *wxvtk2Dbaseview);
245         void SetMarImageData(marImageData *marimagedata);
246         void Configure();
247         void PutPixelIntensity(int x, int y, int z);
248         void PutPosition(int x, int y, int z);
249         void PutColorLevel();
250         void PutWindowLevel();
251
252
253 protected:
254 private:
255
256         marImageData    *_marimagedata;
257         wxVtk2DBaseView *_wxvtk2Dbaseview;
258         vtkTextActor    *_vtkText_WindowLevel;
259         vtkTextActor    *_vtkText_ColorLevel;
260         vtkTextActor    *_vtkText_position;
261         vtkTextActor    *_vtkText_pixelIntensity;
262
263         vtkTextActor    *Create_Text_Label(int px, int py);
264 };
265
266 //------------------------------------------------------------------
267 //------------------------------------------------------------------
268 //------------------------------------------------------------------
269
270 class vtkInfoTextImageInteractor : public InteractorStyleMaracas{
271 public:
272         vtkInfoTextImageInteractor();
273         virtual ~vtkInfoTextImageInteractor();
274         void SetModelVtkInfoTextImage(vtkInfoTextImage *vtkinfotextimage);
275         vtkInfoTextImage *GetVtkInfoTextImage();
276
277 protected:
278
279         virtual bool  OnMouseMove();
280
281 private:
282         vtkInfoTextImage        *_vtkinfotextimage; 
283 };
284
285 //------------------------------------------------------------------
286 //------------------------------------------------------------------
287 //------------------------------------------------------------------
288
289 class vtkInteractorScrollZ : public InteractorStyleMaracas {
290 public:
291         vtkInteractorScrollZ();
292         virtual ~vtkInteractorScrollZ();
293
294         virtual bool  OnMouseMove();
295         virtual bool  OnRightButtonDown();
296         virtual bool  OnRightButtonUp();
297
298
299
300 protected:
301                 bool                    _stateFordware;
302             int                         _fordwareX;
303         int                             _fordwareY;
304                 int                             _sliceZ;
305
306 private:
307
308 };
309
310
311
312
313
314
315 //------------------------------------------------------------------
316 //------------------------------------------------------------------
317 //------------------------------------------------------------------
318
319 class wxVtk3DBaseView;
320
321 class creaMaracasVisu_EXPORT vtkInteractorStyleBaseView : public vtkInteractorStyleImage{
322 public:
323         vtkInteractorStyleBaseView();
324         ~vtkInteractorStyleBaseView();
325         static vtkInteractorStyleBaseView *New();
326         virtual void  OnChar();
327         virtual void  OnMouseMove();
328         virtual void  OnLeftButtonDown(); 
329         virtual void  OnLeftButtonUp();
330         virtual void  OnMiddleButtonDown(); 
331         virtual void  OnMiddleButtonUp();
332         virtual void  OnRightButtonDown();
333         virtual void  OnRightButtonUp();
334
335         virtual void  OnLeftDClick();
336         virtual void  OnRightDClick();
337         virtual void  OnMiddleDClick();
338         virtual void  OnMouseWheel();
339
340         virtual void  TransformCoordinate(double &X, double &Y, double &Z);
341                         void  AddInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas);
342                         void  RemoveInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas);
343                         void  InsertInteractorStyleMaracas(int pos, InteractorStyleMaracas* interactorStyleMaracas);
344                         void  CallLstInteractorStyleMaracas(int type);
345
346         wxVtk2DBaseView         *GetWxVtk2DBaseView();
347         wxVtk3DBaseView         *GetWxVtk3DBaseView();
348                         void            SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview);
349                         void            SetActiveAllInteractors(bool ok);
350
351                         void            SetRefresh_waiting();
352                         void            SetParent_refresh_waiting();
353
354                         bool            GetRefresh_waiting();
355                         bool            GetParent_refresh_waiting();
356
357
358                         void            EvaluateToRefresh();
359                         void            BlockRefresh();
360                         void            UnBlockRefresh();
361
362 protected:
363                 std::vector< InteractorStyleMaracas* >  _lstInteractorStyleMaracas;
364
365 private:
366         bool                            _blockRefresh;
367         bool                            _refresh_waiting;
368         bool                            _parent_refresh_waiting;
369         wxVtkBaseView           *_wxvtkbaseview;
370 };
371
372 //------------------------------------------------------------------
373 //------------------------------------------------------------------
374 //------------------------------------------------------------------
375
376 class creaMaracasVisu_EXPORT vtkInteractorStyleBaseView2D : public vtkInteractorStyleBaseView{
377 public:
378         vtkInteractorStyleBaseView2D();
379         ~vtkInteractorStyleBaseView2D();
380         static vtkInteractorStyleBaseView2D *New();
381         virtual void  OnMouseMove();
382         virtual void  OnLeftButtonDown(); 
383         virtual void  OnLeftButtonUp();
384         virtual void  OnMiddleButtonDown(); 
385         virtual void  OnMiddleButtonUp();
386         virtual void  OnRightButtonDown();
387         virtual void  OnRightButtonUp();
388
389
390 protected:
391
392 private:
393         manualInteractorWindowLevel             *_manualinteractorwindowlevel;
394         vtkInteractorScrollZ                    *_vtkInteractorScrollZ;
395
396 };
397
398 //------------------------------------------------------------------
399 //------------------------------------------------------------------
400 //------------------------------------------------------------------
401
402 class creaMaracasVisu_EXPORT vtkInteractorStyleBaseView3D : public vtkInteractorStyleBaseView {
403 public:
404         vtkInteractorStyleBaseView3D();
405         ~vtkInteractorStyleBaseView3D();
406         static vtkInteractorStyleBaseView3D *New();
407
408         virtual void  OnMouseMove () ;
409         virtual void  OnLeftButtonDown (); 
410         virtual void  OnLeftButtonUp () ;
411         virtual void  OnMiddleButtonDown (); 
412         virtual void  OnMiddleButtonUp () ;
413         virtual void  OnRightButtonDown () ;
414         virtual void  OnRightButtonUp () ;
415
416 private:
417
418 };
419
420 //------------------------------------------------------------------
421 //------------------------------------------------------------------
422 //------------------------------------------------------------------
423
424 class creaMaracasVisu_EXPORT wxVtk3DBaseView: public wxVtkBaseView{
425 public:
426         wxVtk3DBaseView( wxWindow *parent );
427         virtual ~wxVtk3DBaseView();
428         vtkCamera*                      GetCamera();
429         virtual vtkRenderer*            GetRenderer();
430         virtual vtkRenderWindow*        GetRenWin();
431         void                            Refresh();
432         void                            Configure();
433         virtual void            GetSpacing(double spc[3]);
434
435 private:
436         bool                            _configure;
437         vtkRenderer                     *_aRenderer;
438         vtkRenderWindow         *_renWin;
439         vtkCamera                       *_aCamera;
440 protected:
441 };
442
443
444
445 #endif // __WX_VTK__BASE__VIEW__H
446
447
448
449