]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.h
*** empty log message ***
[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() throw (char*);
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 {
323 public:
324         vtkInteractorStyleBaseView();
325         ~vtkInteractorStyleBaseView();
326         static vtkInteractorStyleBaseView *New();
327         virtual void  OnChar();
328         virtual void  OnMouseMove();
329         virtual void  OnLeftButtonDown(); 
330         virtual void  OnLeftButtonUp();
331         virtual void  OnMiddleButtonDown(); 
332         virtual void  OnMiddleButtonUp();
333         virtual void  OnRightButtonDown();
334         virtual void  OnRightButtonUp();
335
336         virtual void  OnLeftDClick();
337         virtual void  OnRightDClick();
338         virtual void  OnMiddleDClick();
339         virtual void  OnMouseWheel();
340
341         virtual void  TransformCoordinate(double &X, double &Y, double &Z);
342                         void  AddInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas);
343                         void  RemoveInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas);
344                         void  InsertInteractorStyleMaracas(int pos, InteractorStyleMaracas* interactorStyleMaracas);
345                         void  CallLstInteractorStyleMaracas(int type);
346
347         wxVtk2DBaseView         *GetWxVtk2DBaseView();
348         wxVtk3DBaseView         *GetWxVtk3DBaseView();
349                         void            SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview);
350                         void            SetActiveAllInteractors(bool ok);
351
352                         void            SetRefresh_waiting();
353                         void            SetParent_refresh_waiting();
354
355                         bool            GetRefresh_waiting();
356                         bool            GetParent_refresh_waiting();
357
358
359                         void            EvaluateToRefresh();
360                         void            BlockRefresh();
361                         void            UnBlockRefresh();
362
363 protected:
364                 std::vector< InteractorStyleMaracas* >  _lstInteractorStyleMaracas;
365
366 private:
367         bool                            _blockRefresh;
368         bool                            _refresh_waiting;
369         bool                            _parent_refresh_waiting;
370         wxVtkBaseView           *_wxvtkbaseview;
371 };
372
373 //------------------------------------------------------------------
374 //------------------------------------------------------------------
375 //------------------------------------------------------------------
376
377 class creaMaracasVisu_EXPORT vtkInteractorStyleBaseView2D : public vtkInteractorStyleBaseView{
378 public:
379         vtkInteractorStyleBaseView2D();
380         ~vtkInteractorStyleBaseView2D();
381         static vtkInteractorStyleBaseView2D *New();
382         virtual void  OnMouseMove();
383         virtual void  OnLeftButtonDown(); 
384         virtual void  OnLeftButtonUp();
385         virtual void  OnMiddleButtonDown(); 
386         virtual void  OnMiddleButtonUp();
387         virtual void  OnRightButtonDown();
388         virtual void  OnRightButtonUp();
389
390
391 protected:
392
393 private:
394         manualInteractorWindowLevel             *_manualinteractorwindowlevel;
395         vtkInteractorScrollZ                    *_vtkInteractorScrollZ;
396
397 };
398
399 //------------------------------------------------------------------
400 //------------------------------------------------------------------
401 //------------------------------------------------------------------
402
403 class creaMaracasVisu_EXPORT vtkInteractorStyleBaseView3D : public vtkInteractorStyleBaseView {
404 public:
405         vtkInteractorStyleBaseView3D();
406         ~vtkInteractorStyleBaseView3D();
407         static vtkInteractorStyleBaseView3D *New();
408
409         virtual void  OnMouseMove () ;
410         virtual void  OnLeftButtonDown (); 
411         virtual void  OnLeftButtonUp () ;
412         virtual void  OnMiddleButtonDown (); 
413         virtual void  OnMiddleButtonUp () ;
414         virtual void  OnRightButtonDown () ;
415         virtual void  OnRightButtonUp () ;
416
417 private:
418
419 };
420
421 //------------------------------------------------------------------
422 //------------------------------------------------------------------
423 //------------------------------------------------------------------
424
425 class creaMaracasVisu_EXPORT wxVtk3DBaseView: public wxVtkBaseView{
426 public:
427         wxVtk3DBaseView( wxWindow *parent );
428         virtual ~wxVtk3DBaseView();
429         vtkCamera*                      GetCamera();
430         virtual vtkRenderer*            GetRenderer();
431         virtual vtkRenderWindow*        GetRenWin();
432         void                            Refresh();
433         void                            Configure();
434         virtual void            GetSpacing(double spc[3]);
435
436 private:
437         bool                            _configure;
438         vtkRenderer                     *_aRenderer;
439         vtkRenderWindow         *_renWin;
440         vtkCamera                       *_aCamera;
441 protected:
442 };
443
444
445
446 #endif // __WX_VTK__BASE__VIEW__H
447
448
449
450