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