]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVTKRenderWindowInteractorEditContour.cxx
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVTKRenderWindowInteractorEditContour.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #include "wxVTKRenderWindowInteractorEditContour.h"
27
28 //---------------------------------------------------------------------------
29 vtkInteractorStyle3DMaracas::vtkInteractorStyle3DMaracas(){
30 }
31 //---------------------------------------------------------------------------
32 vtkInteractorStyle3DMaracas::~vtkInteractorStyle3DMaracas(){
33 }
34 //---------------------------------------------------------------------------
35 void  vtkInteractorStyle3DMaracas::OnRightButtonDown (){    
36 /*
37                 if (GetInteractor()->GetControlKey()==1 ){
38                         this->vtkInteractorStyleTrackballCamera::OnRightButtonDown();
39                 }
40 */
41   this->FindPokedRenderer(this->Interactor->GetEventPosition()[0], 
42                           this->Interactor->GetEventPosition()[1]);
43
44   if (this->CurrentRenderer == NULL)
45     {
46     return;
47     }
48
49   if (this->Interactor->GetControlKey()) {
50       this->StartDolly();
51   }
52
53 }
54 //---------------------------------------------------------------------------
55 void  vtkInteractorStyle3DMaracas::OnRightButtonUp () {
56 /*
57                 if (GetInteractor()->GetControlKey()==1 ){
58                         this->vtkInteractorStyleTrackballCamera::OnRightButtonUp();
59                 }
60 */
61
62                 
63   switch (this->State) 
64     {
65     case VTKIS_DOLLY:
66       this->EndDolly();
67       break;
68     }
69 }
70 //---------------------------------------------------------------------------
71 void  vtkInteractorStyle3DMaracas::OnMouseMove () {
72
73 //              this->vtkInteractorStyleTrackballCamera::OnMouseMove();
74
75   /* int x = */ this->Interactor->GetEventPosition()[0]; // JPRx (unused)
76   /* int y = */ this->Interactor->GetEventPosition()[1]; // JPRx (unused)
77
78
79   vtkRenderWindowInteractor *rwi = this->Interactor;
80
81   /* int lx = */  rwi->GetLastEventPosition()[0]; // JPRx (unused)
82   /* int ly = */  rwi->GetLastEventPosition()[1]; // JPRx (unused)
83   /* int dx = */  rwi->GetEventPosition()[0] ;    // JPRx (unused)
84   /* int dy = */  rwi->GetEventPosition()[1] ;    // JPRx (unused)
85
86
87   switch (this->State) 
88     {
89     case VTKIS_ROTATE:
90  //     this->FindPokedRenderer(x, y);
91       this->Rotate();
92  //     this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
93       break;
94
95     case VTKIS_PAN:
96  //     this->FindPokedRenderer(x, y);
97       this->Pan();
98  //     this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
99       break;
100
101     case VTKIS_DOLLY:
102  //     this->FindPokedRenderer(x, y);
103       this->Dolly();
104  //     this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
105       break;
106
107     case VTKIS_SPIN:
108  //     this->FindPokedRenderer(x, y);
109       this->Spin();
110  //     this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
111       break;
112     }
113
114
115
116 }
117 //---------------------------------------------------------------------------
118 void  vtkInteractorStyle3DMaracas::OnLeftButtonDown (){
119 /*
120                 if (GetInteractor()->GetControlKey()==1 ){
121                         this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
122                 } else {
123                         this->vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
124                 }
125 */
126
127
128   this->FindPokedRenderer(this->Interactor->GetEventPosition()[0], 
129                           this->Interactor->GetEventPosition()[1]);
130   if (this->CurrentRenderer == NULL)
131     {
132     return;
133     }
134
135   if (this->Interactor->GetControlKey()) {
136       this->StartPan();
137   } else {
138       this->StartRotate();
139   }
140
141  /* 
142   if (this->Interactor->GetShiftKey()) 
143     {
144     if (this->Interactor->GetControlKey()) 
145       {
146       this->StartDolly();
147       }
148     else 
149       {
150       this->StartPan();
151       }
152     } 
153   else 
154     {
155     if (this->Interactor->GetControlKey()) 
156       {
157       this->StartSpin();
158       }
159     else 
160       {
161       this->StartRotate();
162       }
163     }
164 */
165
166
167 }
168 //---------------------------------------------------------------------------
169 void  vtkInteractorStyle3DMaracas::OnLeftButtonUp () {
170 /*
171                 if (GetInteractor()->GetControlKey()==1 ){
172                         this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
173                 } else {
174                         this->vtkInteractorStyleTrackballCamera::OnLeftButtonUp();
175                 }
176 */
177   switch (this->State) 
178     {
179
180     case VTKIS_PAN:
181       this->EndPan();
182       break;
183
184     case VTKIS_ROTATE:
185       this->EndRotate();
186       break;
187     }
188 }
189 //---------------------------------------------------------------------------
190 void  vtkInteractorStyle3DMaracas::OnMiddleButtonDown () {
191 //              this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
192 }
193 //---------------------------------------------------------------------------
194 void  vtkInteractorStyle3DMaracas::OnMiddleButtonUp () {
195 //              this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
196 }
197
198
199 //---------------------------------------------------------------------------
200 //---------------------------------------------------------------------------
201 //---------------------------------------------------------------------------
202
203
204 //---------------------------------------------------------------------------
205 vtkInteractorStyle2DMaracas::vtkInteractorStyle2DMaracas(){
206         _obs=NULL;
207 }
208 //---------------------------------------------------------------------------
209 vtkInteractorStyle2DMaracas::~vtkInteractorStyle2DMaracas(){
210 }
211 //---------------------------------------------------------------------------
212 void  vtkInteractorStyle2DMaracas::OnRightButtonDown (){    
213         if (GetInteractor()->GetControlKey()==1 ){
214                 this->vtkInteractorStyleImage::OnRightButtonDown();
215         }
216 }
217 //---------------------------------------------------------------------------
218 void  vtkInteractorStyle2DMaracas::OnRightButtonUp () {
219         if (GetInteractor()->GetControlKey()==1 ){
220                 this->vtkInteractorStyleImage::OnRightButtonUp();
221         }
222 }
223 //---------------------------------------------------------------------------
224 void  vtkInteractorStyle2DMaracas::OnMouseMove () {
225         this->vtkInteractorStyleImage::OnMouseMove();
226 }
227 //---------------------------------------------------------------------------
228 void  vtkInteractorStyle2DMaracas::OnLeftButtonDown (){
229         if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){
230                 this->vtkInteractorStyleImage::OnMiddleButtonDown();
231         } else if ((GetInteractor()->GetControlKey()==0) && (GetInteractor()->GetShiftKey()==1) ){
232                 if (_obs){
233                         _obs->Execute( NULL , vtkCommand::LeftButtonPressEvent  , NULL ) ;
234                 }
235         } else {
236                 this->vtkInteractorStyleImage::OnLeftButtonDown();
237         }
238 }
239
240 //---------------------------------------------------------------------------
241 void  vtkInteractorStyle2DMaracas::OnLeftButtonUp () {
242         if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){
243                 this->vtkInteractorStyleImage::OnMiddleButtonUp();
244         } else if ((GetInteractor()->GetControlKey()==0) && (GetInteractor()->GetShiftKey()==1) ){
245                 if (_obs) {
246                         _obs->Execute( NULL , vtkCommand::LeftButtonReleaseEvent  , NULL );
247                 }
248         } else {
249                 this->vtkInteractorStyleImage::OnLeftButtonUp();
250         }
251 }
252 //---------------------------------------------------------------------------
253 void  vtkInteractorStyle2DMaracas::OnMiddleButtonDown () {
254 }
255 //---------------------------------------------------------------------------
256 void  vtkInteractorStyle2DMaracas::OnMiddleButtonUp () {
257 }
258
259 //---------------------------------------------------------------------------
260 void vtkInteractorStyle2DMaracas::SetObserver(vtkCommand* obs){
261         this->_obs=obs;
262 }
263
264 //---------------------------------------------------------------------------
265 //---------------------------------------------------------------------------
266 //---------------------------------------------------------------------------
267
268 wxVTKRenderWindowInteractorEditContour::wxVTKRenderWindowInteractorEditContour(wxWindow *parent,wxWindowID id)
269   :wxVTKRenderWindowInteractor(parent,id){
270         this->_state=0;
271 }
272 //---------------------------------------------------------------------------
273 wxVTKRenderWindowInteractorEditContour::~wxVTKRenderWindowInteractorEditContour(){
274 }
275 //---------------------------------------------------------------------------
276 void wxVTKRenderWindowInteractorEditContour::OnButtonDown(wxMouseEvent &event){
277         if (this->_state==1){
278           wxVTKRenderWindowInteractor::OnButtonDown(event);
279         }
280         if (this->_state==2){
281                 if(event.LeftDown()==true){
282                         SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
283                         _obs->Execute( NULL , wxEVT_LEFT_DOWN  , NULL ) ;
284                 }
285                 if(event.RightDown()==true){
286             wxVTKRenderWindowInteractor::OnButtonDown(event);
287                         SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
288                         _obs->Execute( NULL , wxEVT_RIGHT_DOWN  , NULL ) ;
289                 }
290         }
291 }
292 //---------------------------------------------------------------------------
293 void wxVTKRenderWindowInteractorEditContour::OnButtonUp(wxMouseEvent &event){
294         if (this->_state==1){
295           wxVTKRenderWindowInteractor::OnButtonUp(event);
296         }
297         if (this->_state==2){
298                 if(event.LeftUp()==true){
299                         SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
300                         _obs->Execute( NULL , wxEVT_LEFT_UP  , NULL ) ;
301                 }
302                 if(event.RightUp()==true){
303             wxVTKRenderWindowInteractor::OnButtonUp(event);
304                 }
305         }
306 }
307 //---------------------------------------------------------------------------
308 void wxVTKRenderWindowInteractorEditContour::OnButtonDouble(wxMouseEvent &event){
309         if (this->_state==1){
310 // EED 22 dec 2007 :  SIL que tengo que hacer aqui ..??  Esto creo que lo quito silvia y como se 
311 // remplaza
312 //        wxVTKRenderWindowInteractor::OnButtonDouble(event);
313         }
314         if (this->_state==2){
315                 if(event.LeftDClick()==true){
316                         SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
317                         _obs->Execute( NULL , wxEVT_LEFT_DCLICK  , NULL ) ;
318                 }
319         }
320 }
321 //---------------------------------------------------------------------------
322 void wxVTKRenderWindowInteractorEditContour::OnMotion(wxMouseEvent &event){
323         if (this->_state==1){
324                 wxVTKRenderWindowInteractor::OnMotion(event);
325         }
326         if (this->_state==2){
327                 wxVTKRenderWindowInteractor::OnMotion(event);
328                 if(event.Moving()==true){
329                         SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
330                         _obs->Execute( NULL , wxEVT_MOTION   , NULL ) ;
331                 }
332         }
333 }
334 //---------------------------------------------------------------------------
335 void wxVTKRenderWindowInteractorEditContour::OnKeyDown(wxKeyEvent &event){
336         wxVTKRenderWindowInteractor::OnKeyDown(event);
337         if (( event.GetKeyCode()==WXK_BACK ) || ( event.GetKeyCode()==WXK_DELETE) ){
338                 _obs->Execute( NULL , WXK_CLEAR   , NULL ) ;
339         }
340 }
341 //---------------------------------------------------------------------------
342 void wxVTKRenderWindowInteractorEditContour::SetState(int state){
343         this->_state=state;
344 }
345 //---------------------------------------------------------------------------
346 int      wxVTKRenderWindowInteractorEditContour::GetState(){
347         return this->_state;
348 }
349 //---------------------------------------------------------------------------
350 void wxVTKRenderWindowInteractorEditContour::SetObserver(vtkCommand* obs){
351         this->_obs=obs;
352 }
353