]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVTKRenderWindowInteractorEditContour.cxx
#3471 Doxygen OFF in CMake AND wx.h conflict
[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 <creaWx.h>
27 #include <wx/tooltip.h>
28 #include <wx/config.h>
29 #include <stdlib.h>
30 #include <iostream> // for std::cout
31
32 #include "wxVTKRenderWindowInteractorEditContour.h"
33
34 //---------------------------------------------------------------------------
35 vtkInteractorStyle3DMaracas::vtkInteractorStyle3DMaracas(){
36 }
37 //---------------------------------------------------------------------------
38 vtkInteractorStyle3DMaracas::~vtkInteractorStyle3DMaracas(){
39 }
40 //---------------------------------------------------------------------------
41 void  vtkInteractorStyle3DMaracas::OnRightButtonDown (){    
42 /*
43                 if (GetInteractor()->GetControlKey()==1 ){
44                         this->vtkInteractorStyleTrackballCamera::OnRightButtonDown();
45                 }
46 */
47   this->FindPokedRenderer(this->Interactor->GetEventPosition()[0], 
48                           this->Interactor->GetEventPosition()[1]);
49
50   if (this->CurrentRenderer == NULL)
51     {
52     return;
53     }
54
55   if (this->Interactor->GetControlKey()) {
56       this->StartDolly();
57   }
58
59 }
60 //---------------------------------------------------------------------------
61 void  vtkInteractorStyle3DMaracas::OnRightButtonUp () {
62 /*
63                 if (GetInteractor()->GetControlKey()==1 ){
64                         this->vtkInteractorStyleTrackballCamera::OnRightButtonUp();
65                 }
66 */
67
68                 
69   switch (this->State) 
70     {
71     case VTKIS_DOLLY:
72       this->EndDolly();
73       break;
74     }
75 }
76 //---------------------------------------------------------------------------
77 void  vtkInteractorStyle3DMaracas::OnMouseMove () {
78
79 //              this->vtkInteractorStyleTrackballCamera::OnMouseMove();
80
81   /* int x = */ this->Interactor->GetEventPosition()[0]; // JPRx (unused)
82   /* int y = */ this->Interactor->GetEventPosition()[1]; // JPRx (unused)
83
84
85   vtkRenderWindowInteractor *rwi = this->Interactor;
86
87   /* int lx = */  rwi->GetLastEventPosition()[0]; // JPRx (unused)
88   /* int ly = */  rwi->GetLastEventPosition()[1]; // JPRx (unused)
89   /* int dx = */  rwi->GetEventPosition()[0] ;    // JPRx (unused)
90   /* int dy = */  rwi->GetEventPosition()[1] ;    // JPRx (unused)
91
92
93   switch (this->State) 
94     {
95     case VTKIS_ROTATE:
96  //     this->FindPokedRenderer(x, y);
97       this->Rotate();
98  //     this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
99       break;
100
101     case VTKIS_PAN:
102  //     this->FindPokedRenderer(x, y);
103       this->Pan();
104  //     this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
105       break;
106
107     case VTKIS_DOLLY:
108  //     this->FindPokedRenderer(x, y);
109       this->Dolly();
110  //     this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
111       break;
112
113     case VTKIS_SPIN:
114  //     this->FindPokedRenderer(x, y);
115       this->Spin();
116  //     this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
117       break;
118     }
119
120
121
122 }
123 //---------------------------------------------------------------------------
124 void  vtkInteractorStyle3DMaracas::OnLeftButtonDown (){
125 /*
126                 if (GetInteractor()->GetControlKey()==1 ){
127                         this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
128                 } else {
129                         this->vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
130                 }
131 */
132
133
134   this->FindPokedRenderer(this->Interactor->GetEventPosition()[0], 
135                           this->Interactor->GetEventPosition()[1]);
136   if (this->CurrentRenderer == NULL)
137     {
138     return;
139     }
140
141   if (this->Interactor->GetControlKey()) {
142       this->StartPan();
143   } else {
144       this->StartRotate();
145   }
146
147  /* 
148   if (this->Interactor->GetShiftKey()) 
149     {
150     if (this->Interactor->GetControlKey()) 
151       {
152       this->StartDolly();
153       }
154     else 
155       {
156       this->StartPan();
157       }
158     } 
159   else 
160     {
161     if (this->Interactor->GetControlKey()) 
162       {
163       this->StartSpin();
164       }
165     else 
166       {
167       this->StartRotate();
168       }
169     }
170 */
171
172
173 }
174 //---------------------------------------------------------------------------
175 void  vtkInteractorStyle3DMaracas::OnLeftButtonUp () {
176 /*
177                 if (GetInteractor()->GetControlKey()==1 ){
178                         this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
179                 } else {
180                         this->vtkInteractorStyleTrackballCamera::OnLeftButtonUp();
181                 }
182 */
183   switch (this->State) 
184     {
185
186     case VTKIS_PAN:
187       this->EndPan();
188       break;
189
190     case VTKIS_ROTATE:
191       this->EndRotate();
192       break;
193     }
194 }
195 //---------------------------------------------------------------------------
196 void  vtkInteractorStyle3DMaracas::OnMiddleButtonDown () {
197 //              this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
198 }
199 //---------------------------------------------------------------------------
200 void  vtkInteractorStyle3DMaracas::OnMiddleButtonUp () {
201 //              this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
202 }
203
204
205 //---------------------------------------------------------------------------
206 //---------------------------------------------------------------------------
207 //---------------------------------------------------------------------------
208
209
210 //---------------------------------------------------------------------------
211 vtkInteractorStyle2DMaracas::vtkInteractorStyle2DMaracas(){
212         _obs=NULL;
213 }
214 //---------------------------------------------------------------------------
215 vtkInteractorStyle2DMaracas::~vtkInteractorStyle2DMaracas(){
216 }
217 //---------------------------------------------------------------------------
218 void  vtkInteractorStyle2DMaracas::OnRightButtonDown (){    
219         if (GetInteractor()->GetControlKey()==1 ){
220                 this->vtkInteractorStyleImage::OnRightButtonDown();
221         }
222 }
223 //---------------------------------------------------------------------------
224 void  vtkInteractorStyle2DMaracas::OnRightButtonUp () {
225         if (GetInteractor()->GetControlKey()==1 ){
226                 this->vtkInteractorStyleImage::OnRightButtonUp();
227         }
228 }
229 //---------------------------------------------------------------------------
230 void  vtkInteractorStyle2DMaracas::OnMouseMove () {
231         this->vtkInteractorStyleImage::OnMouseMove();
232 }
233 //---------------------------------------------------------------------------
234 void  vtkInteractorStyle2DMaracas::OnLeftButtonDown (){
235         if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){
236                 this->vtkInteractorStyleImage::OnMiddleButtonDown();
237         } else if ((GetInteractor()->GetControlKey()==0) && (GetInteractor()->GetShiftKey()==1) ){
238                 if (_obs){
239                         _obs->Execute( NULL , vtkCommand::LeftButtonPressEvent  , NULL ) ;
240                 }
241         } else {
242                 this->vtkInteractorStyleImage::OnLeftButtonDown();
243         }
244 }
245
246 //---------------------------------------------------------------------------
247 void  vtkInteractorStyle2DMaracas::OnLeftButtonUp () {
248         if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){
249                 this->vtkInteractorStyleImage::OnMiddleButtonUp();
250         } else if ((GetInteractor()->GetControlKey()==0) && (GetInteractor()->GetShiftKey()==1) ){
251                 if (_obs) {
252                         _obs->Execute( NULL , vtkCommand::LeftButtonReleaseEvent  , NULL );
253                 }
254         } else {
255                 this->vtkInteractorStyleImage::OnLeftButtonUp();
256         }
257 }
258 //---------------------------------------------------------------------------
259 void  vtkInteractorStyle2DMaracas::OnMiddleButtonDown () {
260 }
261 //---------------------------------------------------------------------------
262 void  vtkInteractorStyle2DMaracas::OnMiddleButtonUp () {
263 }
264
265 //---------------------------------------------------------------------------
266 void vtkInteractorStyle2DMaracas::SetObserver(vtkCommand* obs){
267         this->_obs=obs;
268 }
269
270 //---------------------------------------------------------------------------
271 //---------------------------------------------------------------------------
272 //---------------------------------------------------------------------------
273
274 wxVTKRenderWindowInteractorEditContour::wxVTKRenderWindowInteractorEditContour(wxWindow *parent,wxWindowID id)
275   :wxVTKRenderWindowInteractor(parent,id){
276         this->_state=0;
277 }
278 //---------------------------------------------------------------------------
279 wxVTKRenderWindowInteractorEditContour::~wxVTKRenderWindowInteractorEditContour(){
280 }
281 //---------------------------------------------------------------------------
282 void wxVTKRenderWindowInteractorEditContour::OnButtonDown(wxMouseEvent &event){
283         if (this->_state==1){
284           wxVTKRenderWindowInteractor::OnButtonDown(event);
285         }
286         if (this->_state==2){
287                 if(event.LeftDown()==true){
288                         SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
289                         _obs->Execute( NULL , wxEVT_LEFT_DOWN  , NULL ) ;
290                 }
291                 if(event.RightDown()==true){
292             wxVTKRenderWindowInteractor::OnButtonDown(event);
293                         SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
294                         _obs->Execute( NULL , wxEVT_RIGHT_DOWN  , NULL ) ;
295                 }
296         }
297 }
298 //---------------------------------------------------------------------------
299 void wxVTKRenderWindowInteractorEditContour::OnButtonUp(wxMouseEvent &event){
300         if (this->_state==1){
301           wxVTKRenderWindowInteractor::OnButtonUp(event);
302         }
303         if (this->_state==2){
304                 if(event.LeftUp()==true){
305                         SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
306                         _obs->Execute( NULL , wxEVT_LEFT_UP  , NULL ) ;
307                 }
308                 if(event.RightUp()==true){
309             wxVTKRenderWindowInteractor::OnButtonUp(event);
310                 }
311         }
312 }
313 //---------------------------------------------------------------------------
314 void wxVTKRenderWindowInteractorEditContour::OnButtonDouble(wxMouseEvent &event){
315         if (this->_state==1){
316 // EED 22 dec 2007 :  SIL que tengo que hacer aqui ..??  Esto creo que lo quito silvia y como se 
317 // remplaza
318 //        wxVTKRenderWindowInteractor::OnButtonDouble(event);
319         }
320         if (this->_state==2){
321                 if(event.LeftDClick()==true){
322                         SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
323                         _obs->Execute( NULL , wxEVT_LEFT_DCLICK  , NULL ) ;
324                 }
325         }
326 }
327 //---------------------------------------------------------------------------
328 void wxVTKRenderWindowInteractorEditContour::OnMotion(wxMouseEvent &event){
329         if (this->_state==1){
330                 wxVTKRenderWindowInteractor::OnMotion(event);
331         }
332         if (this->_state==2){
333                 wxVTKRenderWindowInteractor::OnMotion(event);
334                 if(event.Moving()==true){
335                         SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);
336                         _obs->Execute( NULL , wxEVT_MOTION   , NULL ) ;
337                 }
338         }
339 }
340 //---------------------------------------------------------------------------
341 void wxVTKRenderWindowInteractorEditContour::OnKeyDown(wxKeyEvent &event){
342         wxVTKRenderWindowInteractor::OnKeyDown(event);
343         if (( event.GetKeyCode()==WXK_BACK ) || ( event.GetKeyCode()==WXK_DELETE) ){
344                 _obs->Execute( NULL , WXK_CLEAR   , NULL ) ;
345         }
346 }
347 //---------------------------------------------------------------------------
348 void wxVTKRenderWindowInteractorEditContour::SetState(int state){
349         this->_state=state;
350 }
351 //---------------------------------------------------------------------------
352 int      wxVTKRenderWindowInteractorEditContour::GetState(){
353         return this->_state;
354 }
355 //---------------------------------------------------------------------------
356 void wxVTKRenderWindowInteractorEditContour::SetObserver(vtkCommand* obs){
357         this->_obs=obs;
358 }
359