]> SALOME platform Git repositories - modules/gui.git/blob - src/SVTK/SVTK_InteractorStyle.cxx
Salome HOME
963aa1894733d7fd039d7a8b89608e7d78c9fa16
[modules/gui.git] / src / SVTK / SVTK_InteractorStyle.cxx
1 //  SALOME VTKViewer : build VTK viewer into Salome desktop
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : 
25 //  Author : 
26 //  Module : SALOME
27 //  $Header$
28
29
30 #include "SVTK_InteractorStyle.h"
31
32 #include "VTKViewer_Utilities.h"
33 #include "SVTK_GenericRenderWindowInteractor.h"
34
35 #include "SVTK_Selection.h"
36 #include "SVTK_Event.h" 
37 #include "SVTK_Selector.h"
38 #include "SVTK_Functor.h"
39
40 #include "VTKViewer_Algorithm.h"
41 #include "SVTK_Functor.h"
42
43 #include "SALOME_Actor.h"
44
45 #include <vtkObjectFactory.h>
46 #include <vtkMath.h>
47 #include <vtkCommand.h>
48 #include <vtkCamera.h>
49 #include <vtkRenderer.h>
50 #include <vtkPicker.h>
51 #include <vtkRenderWindow.h>
52 #include <vtkRenderWindowInteractor.h>
53 #include <vtkCallbackCommand.h>
54 #include <vtkRendererCollection.h>
55
56 #include <qapplication.h>
57 #include <qpixmap.h>
58 //VRV: porting on Qt 3.0.5
59 #if QT_VERSION >= 0x030005
60 #include <qpainter.h>
61 #endif
62 //VRV: porting on Qt 3.0.5
63 #include <algorithm>
64
65 using namespace std;
66
67 namespace
68 {
69   inline 
70   void
71   GetEventPosition(vtkRenderWindowInteractor* theInteractor,
72                    int& theX, 
73                    int& theY)
74   {
75     theInteractor->GetEventPosition(theX,theY);
76     theY = theInteractor->GetSize()[1] - theY - 1;
77   }
78
79   //==================================================================
80   // function : GetFirstSALOMEActor
81   // purpose  :
82   //==================================================================
83   struct THaveIO
84   {
85     bool
86     operator()(SALOME_Actor* theActor)
87     {
88       return theActor->hasIO();
89     }
90   };
91
92   inline
93   SALOME_Actor* 
94   GetFirstSALOMEActor(vtkPicker *thePicker)
95   {
96     return VTK::Find<SALOME_Actor>(thePicker->GetActors(),THaveIO());
97   }
98 }
99
100
101 //----------------------------------------------------------------------------
102 vtkStandardNewMacro(SVTK_InteractorStyle);
103 //----------------------------------------------------------------------------
104 SVTK_InteractorStyle
105 ::SVTK_InteractorStyle():
106   mySelectionEvent(new SVTK_SelectionEvent()),
107   myPicker(vtkPicker::New()),
108   myLastHighlitedActor(NULL),
109   myLastPreHighlitedActor(NULL),
110   myControllerIncrement(SVTK_ControllerIncrement::New()),
111   myControllerOnKeyDown(SVTK_ControllerOnKeyDown::New())
112 {
113   myPicker->Delete();
114
115   this->MotionFactor = 10.0;
116   this->State = VTK_INTERACTOR_STYLE_CAMERA_NONE;
117   this->RadianToDegree = 180.0 / vtkMath::Pi();
118   this->ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
119
120   loadCursors();
121
122   // set custom event handling function (to handle 3d space mouse events)
123   EventCallbackCommand->SetCallback( SVTK_InteractorStyle::ProcessEvents );
124
125   // set default values of properties.  user may edit them in preferences.
126   mySMDecreaseSpeedBtn = 1;
127   mySMIncreaseSpeedBtn = 2;
128   mySMDominantCombinedSwitchBtn = 9;
129   //
130   myControllerIncrement->Delete();
131   myControllerOnKeyDown->Delete();
132 }
133
134 //----------------------------------------------------------------------------
135 SVTK_InteractorStyle
136 ::~SVTK_InteractorStyle() 
137 {
138 }
139
140 //----------------------------------------------------------------------------
141 QWidget*
142 SVTK_InteractorStyle
143 ::GetRenderWidget()
144 {
145   return myInteractor->GetRenderWidget();
146 }
147
148 SVTK_Selector*
149 SVTK_InteractorStyle
150 ::GetSelector() 
151 {
152   return myInteractor->GetSelector();
153 }
154
155 //----------------------------------------------------------------------------
156 SVTK_SelectionEvent*
157 SVTK_InteractorStyle
158 ::GetSelectionEvent()
159 {
160   mySelectionEvent->mySelectionMode = GetSelector()->SelectionMode();
161
162   mySelectionEvent->myIsCtrl = Interactor->GetControlKey();
163   mySelectionEvent->myIsShift = Interactor->GetShiftKey();
164
165   mySelectionEvent->myLastX = mySelectionEvent->myX;
166   mySelectionEvent->myLastY = mySelectionEvent->myY;
167
168   GetEventPosition( this->Interactor, mySelectionEvent->myX, mySelectionEvent->myY );
169
170   return mySelectionEvent.get();
171 }
172
173 //----------------------------------------------------------------------------
174 SVTK_SelectionEvent*
175 SVTK_InteractorStyle
176 ::GetSelectionEventFlipY()
177 {
178   mySelectionEvent->mySelectionMode = GetSelector()->SelectionMode();
179
180   mySelectionEvent->myIsCtrl = Interactor->GetControlKey();
181   mySelectionEvent->myIsShift = Interactor->GetShiftKey();
182
183   mySelectionEvent->myLastX = mySelectionEvent->myX;
184   mySelectionEvent->myLastY = mySelectionEvent->myY;
185
186   this->Interactor->GetEventPosition(mySelectionEvent->myX, mySelectionEvent->myY);
187
188   return mySelectionEvent.get();
189 }
190
191 //----------------------------------------------------------------------------
192 void
193 SVTK_InteractorStyle
194 ::RotateXY(int dx, int dy)
195 {
196   if(GetCurrentRenderer() == NULL)
197     return;
198   
199   int *size = GetCurrentRenderer()->GetRenderWindow()->GetSize();
200   double aDeltaElevation = -20.0 / size[1];
201   double aDeltaAzimuth = -20.0 / size[0];
202   
203   double rxf = double(dx) * aDeltaAzimuth * this->MotionFactor;
204   double ryf = double(dy) * aDeltaElevation * this->MotionFactor;
205   
206   vtkCamera *cam = GetCurrentRenderer()->GetActiveCamera();
207   cam->Azimuth(rxf);
208   cam->Elevation(ryf);
209   cam->OrthogonalizeViewUp();
210
211   GetCurrentRenderer()->ResetCameraClippingRange(); 
212
213   this->Render();
214 }
215
216 //----------------------------------------------------------------------------
217 void
218 SVTK_InteractorStyle
219 ::PanXY(int x, int y, int oldX, int oldY)
220 {
221   TranslateView(x, y, oldX, oldY);   
222   this->Render();
223 }
224
225
226 //----------------------------------------------------------------------------
227 void 
228 SVTK_InteractorStyle
229 ::DollyXY(int dx, int dy)
230 {
231   if (GetCurrentRenderer() == NULL) 
232     return;
233
234   double dxf = this->MotionFactor * (double)(dx) / (double)(GetCurrentRenderer()->GetCenter()[1]);
235   double dyf = this->MotionFactor * (double)(dy) / (double)(GetCurrentRenderer()->GetCenter()[1]);
236
237   double zoomFactor = pow((double)1.1, dxf + dyf);
238   
239   vtkCamera *aCam = GetCurrentRenderer()->GetActiveCamera();
240   if (aCam->GetParallelProjection())
241     aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor);
242   else{
243     aCam->Dolly(zoomFactor);
244     GetCurrentRenderer()->ResetCameraClippingRange(); 
245   }
246
247   this->Render();
248 }
249
250 //----------------------------------------------------------------------------
251 void 
252 SVTK_InteractorStyle
253 ::SpinXY(int x, int y, int oldX, int oldY)
254 {
255   vtkCamera *cam;
256
257   if (GetCurrentRenderer() == NULL)
258     return;
259
260   double newAngle = atan2((double)(y - GetCurrentRenderer()->GetCenter()[1]),
261                           (double)(x - GetCurrentRenderer()->GetCenter()[0]));
262   double oldAngle = atan2((double)(oldY -GetCurrentRenderer()->GetCenter()[1]),
263                           (double)(oldX - GetCurrentRenderer()->GetCenter()[0]));
264   
265   newAngle *= this->RadianToDegree;
266   oldAngle *= this->RadianToDegree;
267
268   cam = GetCurrentRenderer()->GetActiveCamera();
269   cam->Roll(newAngle - oldAngle);
270   cam->OrthogonalizeViewUp();
271       
272   this->Render();
273 }
274
275
276 //----------------------------------------------------------------------------
277 void
278 SVTK_InteractorStyle
279 ::OnConfigure() 
280 {
281   this->FindPokedRenderer(0,0);
282   this->GetCurrentRenderer()->InvokeEvent(vtkCommand::ConfigureEvent,NULL);
283 }
284
285
286 //----------------------------------------------------------------------------
287 void
288 SVTK_InteractorStyle
289 ::OnMouseMove() 
290 {
291   int x, y;
292   GetEventPosition( this->Interactor, x, y );
293   this->OnMouseMove( this->Interactor->GetControlKey(),
294                      this->Interactor->GetShiftKey(),
295                      x, y );
296 }
297
298
299 //----------------------------------------------------------------------------
300 void
301 SVTK_InteractorStyle
302 ::OnLeftButtonDown()
303 {
304   int x, y;
305   GetEventPosition( this->Interactor, x, y );
306   this->OnLeftButtonDown( this->Interactor->GetControlKey(),
307                           this->Interactor->GetShiftKey(),
308                           x, y );
309 }
310
311
312 //----------------------------------------------------------------------------
313 void
314 SVTK_InteractorStyle
315 ::OnLeftButtonUp()
316 {
317   int x, y;
318   GetEventPosition( this->Interactor, x, y );
319   this->OnLeftButtonUp( this->Interactor->GetControlKey(),
320                         this->Interactor->GetShiftKey(),
321                         x, y );
322 }
323
324
325 //----------------------------------------------------------------------------
326 void
327 SVTK_InteractorStyle
328 ::OnMiddleButtonDown() 
329 {
330   int x, y;
331   GetEventPosition( this->Interactor, x, y );
332   this->OnMiddleButtonDown( this->Interactor->GetControlKey(),
333                             this->Interactor->GetShiftKey(),
334                             x, y );
335 }
336
337
338 //----------------------------------------------------------------------------
339 void
340 SVTK_InteractorStyle
341 ::OnMiddleButtonUp()
342 {
343   int x, y;
344   GetEventPosition( this->Interactor, x, y );
345   this->OnMiddleButtonUp( this->Interactor->GetControlKey(),
346                           this->Interactor->GetShiftKey(),
347                           x, y );
348 }
349
350
351 //----------------------------------------------------------------------------
352 void
353 SVTK_InteractorStyle
354 ::OnRightButtonDown() 
355 {
356   int x, y;
357   GetEventPosition( this->Interactor, x, y );
358   this->OnRightButtonDown( this->Interactor->GetControlKey(),
359                            this->Interactor->GetShiftKey(),
360                            x, y );
361 }
362
363 //----------------------------------------------------------------------------
364 void
365 SVTK_InteractorStyle
366 ::OnRightButtonUp()
367 {
368   int x, y;
369   GetEventPosition( this->Interactor, x, y );
370   this->OnRightButtonUp( this->Interactor->GetControlKey(),
371                          this->Interactor->GetShiftKey(),
372                          x, y );
373 }
374
375
376 //----------------------------------------------------------------------------
377 void
378 SVTK_InteractorStyle
379 ::OnMouseMove(int vtkNotUsed(ctrl), 
380               int shift,
381               int x, int y) 
382 {
383   myShiftState = shift;
384   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
385     onOperation(QPoint(x, y));
386   else if (ForcedState == VTK_INTERACTOR_STYLE_CAMERA_NONE)
387     onCursorMove(QPoint(x, y));
388 }
389
390
391 //----------------------------------------------------------------------------
392 void
393 SVTK_InteractorStyle
394 ::OnLeftButtonDown(int ctrl, int shift, 
395                    int x, int y) 
396 {
397   this->FindPokedRenderer(x, y);
398   if(GetCurrentRenderer() == NULL)
399     return;
400
401   myShiftState = shift;
402   // finishing current viewer operation
403   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
404     onFinishOperation();
405     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
406   }
407   myOtherPoint = myPoint = QPoint(x, y);
408   if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
409     startOperation(ForcedState);
410   } else {
411     if (ctrl)
412       startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
413     else
414       startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
415   }
416   return;
417 }
418
419
420 //----------------------------------------------------------------------------
421 void
422 SVTK_InteractorStyle
423 ::OnLeftButtonUp(int vtkNotUsed(ctrl),
424                  int shift, 
425                  int vtkNotUsed(x),
426                  int vtkNotUsed(y))
427 {
428   myShiftState = shift;
429   // finishing current viewer operation
430   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
431     onFinishOperation();
432     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
433   }
434 }
435
436
437 //----------------------------------------------------------------------------
438 void
439 SVTK_InteractorStyle
440 ::OnMiddleButtonDown(int ctrl,
441                      int shift, 
442                      int x, int y) 
443 {
444   this->FindPokedRenderer(x, y);
445   if(GetCurrentRenderer() == NULL)
446     return;
447
448   myShiftState = shift;
449   // finishing current viewer operation
450   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
451     onFinishOperation();
452     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
453   }
454   myOtherPoint = myPoint = QPoint(x, y);
455   if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
456     startOperation(ForcedState);
457   }
458   else {
459     if (ctrl)
460       startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN);
461   }
462 }
463
464
465 //----------------------------------------------------------------------------
466 void
467 SVTK_InteractorStyle
468 ::OnMiddleButtonUp(int vtkNotUsed(ctrl),
469                    int shift, 
470                    int vtkNotUsed(x),
471                    int vtkNotUsed(y))
472 {
473   myShiftState = shift;
474   // finishing current viewer operation
475   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
476     onFinishOperation();
477     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
478   }
479 }
480
481
482 //----------------------------------------------------------------------------
483 void
484 SVTK_InteractorStyle
485 ::OnRightButtonDown(int ctrl,
486                     int shift, 
487                     int x, int y) 
488 {
489   this->FindPokedRenderer(x, y);
490   if(GetCurrentRenderer() == NULL)
491     return;
492
493   myShiftState = shift;
494   // finishing current viewer operation
495   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
496     onFinishOperation();
497     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
498   }
499   myOtherPoint = myPoint = QPoint(x, y);
500   if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
501     startOperation(ForcedState);
502   }
503   else {
504     if (ctrl)
505       startOperation(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);  
506   }
507 }
508
509 //----------------------------------------------------------------------------
510 void
511 SVTK_InteractorStyle
512 ::OnRightButtonUp(int vtkNotUsed(ctrl),
513                   int shift, 
514                   int vtkNotUsed(x),
515                   int vtkNotUsed(y))
516 {
517   myShiftState = shift;
518   // finishing current viewer operation
519   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
520     onFinishOperation();
521     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
522   }
523 }
524
525 //----------------------------------------------------------------------------
526 /* XPM */
527 const char* imageZoomCursor[] = { 
528 "32 32 3 1",
529 ". c None",
530 "a c #000000",
531 "# c #ffffff",
532 "................................",
533 "................................",
534 ".#######........................",
535 "..aaaaaaa.......................",
536 "................................",
537 ".............#####..............",
538 "...........##.aaaa##............",
539 "..........#.aa.....a#...........",
540 ".........#.a.........#..........",
541 ".........#a..........#a.........",
542 "........#.a...........#.........",
543 "........#a............#a........",
544 "........#a............#a........",
545 "........#a............#a........",
546 "........#a............#a........",
547 ".........#...........#.a........",
548 ".........#a..........#a.........",
549 ".........##.........#.a.........",
550 "........#####.....##.a..........",
551 ".......###aaa#####.aa...........",
552 "......###aa...aaaaa.......#.....",
553 ".....###aa................#a....",
554 "....###aa.................#a....",
555 "...###aa...............#######..",
556 "....#aa.................aa#aaaa.",
557 ".....a....................#a....",
558 "..........................#a....",
559 "...........................a....",
560 "................................",
561 "................................",
562 "................................",
563 "................................"};
564
565 const char* imageRotateCursor[] = { 
566 "32 32 3 1",
567 ". c None",
568 "a c #000000",
569 "# c #ffffff",
570 "................................",
571 "................................",
572 "................................",
573 "................................",
574 "........#.......................",
575 ".......#.a......................",
576 "......#######...................",
577 ".......#aaaaa#####..............",
578 "........#..##.a#aa##........##..",
579 ".........a#.aa..#..a#.....##.aa.",
580 ".........#.a.....#...#..##.aa...",
581 ".........#a.......#..###.aa.....",
582 "........#.a.......#a..#aa.......",
583 "........#a.........#..#a........",
584 "........#a.........#a.#a........",
585 "........#a.........#a.#a........",
586 "........#a.........#a.#a........",
587 ".........#.........#a#.a........",
588 "........##a........#a#a.........",
589 "......##.a#.......#.#.a.........",
590 "....##.aa..##.....##.a..........",
591 "..##.aa.....a#####.aa...........",
592 "...aa.........aaa#a.............",
593 "................#.a.............",
594 "...............#.a..............",
595 "..............#.a...............",
596 "...............a................",
597 "................................",
598 "................................",
599 "................................",
600 "................................",
601 "................................"};
602
603
604 //----------------------------------------------------------------------------
605 // loads cursors for viewer operations - zoom, pan, etc...
606 void
607 SVTK_InteractorStyle
608 ::loadCursors()
609 {
610   myDefCursor       = QCursor(Qt::ArrowCursor);
611   myHandCursor      = QCursor(Qt::PointingHandCursor);
612   myPanCursor       = QCursor(Qt::SizeAllCursor);
613   myZoomCursor      = QCursor(QPixmap(imageZoomCursor));
614   myRotateCursor    = QCursor(QPixmap(imageRotateCursor));
615   mySpinCursor      = QCursor(QPixmap(imageRotateCursor)); // temporarly !!!!!!
616   myGlobalPanCursor = QCursor(Qt::CrossCursor);
617   myCursorState     = false;
618 }
619
620
621 //----------------------------------------------------------------------------
622 // starts Zoom operation (e.g. through menu command)
623 void
624 SVTK_InteractorStyle
625 ::startZoom()
626 {
627   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
628   {
629     onFinishOperation();
630     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
631   }
632   setCursor(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
633   ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ZOOM;
634 }
635
636
637 //----------------------------------------------------------------------------
638 // starts Pan operation (e.g. through menu command)
639 void
640 SVTK_InteractorStyle
641 ::startPan()
642 {
643   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
644   {
645     onFinishOperation();
646     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
647   }
648   setCursor(VTK_INTERACTOR_STYLE_CAMERA_PAN);
649   ForcedState = VTK_INTERACTOR_STYLE_CAMERA_PAN;
650 }
651
652 //----------------------------------------------------------------------------
653 // starts Rotate operation (e.g. through menu command)
654 void 
655 SVTK_InteractorStyle
656 ::startRotate()
657 {
658   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
659   {
660     onFinishOperation();
661     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
662   }
663   setCursor(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
664   ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ROTATE;
665 }
666
667
668 //----------------------------------------------------------------------------
669 // starts Spin operation (e.g. through menu command)
670 void
671 SVTK_InteractorStyle
672 ::startSpin()
673 {
674   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
675   {
676     onFinishOperation();
677     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
678   }
679   setCursor(VTK_INTERACTOR_STYLE_CAMERA_SPIN);
680   ForcedState = VTK_INTERACTOR_STYLE_CAMERA_SPIN;
681 }
682
683
684
685 //----------------------------------------------------------------------------
686 // starts Fit Area operation (e.g. through menu command)
687 void
688 SVTK_InteractorStyle
689 ::startFitArea()
690 {
691   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
692   {
693     onFinishOperation();
694     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
695   }
696   setCursor(VTK_INTERACTOR_STYLE_CAMERA_FIT);
697   ForcedState = VTK_INTERACTOR_STYLE_CAMERA_FIT;
698 }
699
700
701 //----------------------------------------------------------------------------
702 // starts Global Panning operation (e.g. through menu command)
703 void
704 SVTK_InteractorStyle
705 ::startGlobalPan()
706 {
707   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
708   {
709     onFinishOperation();
710     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
711   }
712   setCursor(VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN);
713   ForcedState = VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN;
714
715   // store current zoom scale
716   myScale = GetCurrentRenderer()->GetActiveCamera()->GetParallelScale();
717
718   GetCurrentRenderer()->ResetCamera();
719
720   this->Render();
721 }
722
723
724 //----------------------------------------------------------------------------
725 // fits viewer contents to rect
726 void
727 SVTK_InteractorStyle
728 ::fitRect(const int left, 
729           const int top, 
730           const int right, 
731           const int bottom)
732 {
733   if (GetCurrentRenderer() == NULL) 
734     return;
735  
736   // move camera
737   int x = (left + right)/2;
738   int y = (top + bottom)/2;
739   int *aSize = GetCurrentRenderer()->GetRenderWindow()->GetSize();
740   int oldX = aSize[0]/2;
741   int oldY = aSize[1]/2;
742   TranslateView(oldX, oldY, x, y);
743
744   // zoom camera
745   double dxf = right == left ? 1.0 : (double)(aSize[0]) / (double)(abs(right - left));
746   double dyf = bottom == top ? 1.0 : (double)(aSize[1]) / (double)(abs(bottom - top));
747   double zoomFactor = (dxf + dyf)/2 ;
748
749   vtkCamera *aCam = GetCurrentRenderer()->GetActiveCamera();
750   if(aCam->GetParallelProjection())
751     aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor);
752   else{
753     aCam->Dolly(zoomFactor);
754     GetCurrentRenderer()->ResetCameraClippingRange();
755   }
756   
757   this->Render();
758 }
759
760
761 //----------------------------------------------------------------------------
762 // starts viewer operation (!internal usage!)
763 void
764 SVTK_InteractorStyle
765 ::startOperation(int operation)
766 {
767   switch(operation)
768   { 
769   case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
770   case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
771   case VTK_INTERACTOR_STYLE_CAMERA_PAN:
772   case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
773   case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
774   case VTK_INTERACTOR_STYLE_CAMERA_FIT:
775   case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
776     if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
777       startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
778     State = operation;
779     if (State != VTK_INTERACTOR_STYLE_CAMERA_SELECT)
780       setCursor(operation);
781     onStartOperation();
782     break;
783   case VTK_INTERACTOR_STYLE_CAMERA_NONE:
784   default:
785     setCursor(VTK_INTERACTOR_STYLE_CAMERA_NONE);
786     State = ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
787     break;
788   }
789 }
790
791
792 //----------------------------------------------------------------------------
793 // sets proper cursor for window when viewer operation is activated
794 void
795 SVTK_InteractorStyle
796 ::setCursor(const int operation)
797 {
798   if (!GetRenderWidget()) return;
799   switch (operation)
800   {
801     case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
802       GetRenderWidget()->setCursor(myZoomCursor); 
803       myCursorState = true;
804       break;
805     case VTK_INTERACTOR_STYLE_CAMERA_PAN:
806       GetRenderWidget()->setCursor(myPanCursor); 
807       myCursorState = true;
808       break;
809     case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
810       GetRenderWidget()->setCursor(myRotateCursor); 
811       myCursorState = true;
812       break;
813     case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
814       GetRenderWidget()->setCursor(mySpinCursor); 
815       myCursorState = true;
816       break;
817     case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
818       GetRenderWidget()->setCursor(myGlobalPanCursor); 
819       myCursorState = true;
820       break;
821     case VTK_INTERACTOR_STYLE_CAMERA_FIT:
822     case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
823       GetRenderWidget()->setCursor(myHandCursor); 
824       myCursorState = true;
825       break;
826     case VTK_INTERACTOR_STYLE_CAMERA_NONE:
827     default:
828       GetRenderWidget()->setCursor(myDefCursor); 
829       myCursorState = false;
830       break;
831   }
832 }
833
834
835 //----------------------------------------------------------------------------
836 // called when viewer operation started (!put necessary initialization here!)
837 void
838 SVTK_InteractorStyle
839 ::onStartOperation()
840 {
841   if (!GetRenderWidget()) return;
842   // VSV: LOD actor activisation
843   //  this->Interactor->GetRenderWindow()->SetDesiredUpdateRate(this->Interactor->GetDesiredUpdateRate());
844   switch (State) {
845     case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
846     case VTK_INTERACTOR_STYLE_CAMERA_FIT:
847     {
848       QPainter p(GetRenderWidget());
849       p.setPen(Qt::lightGray);
850       p.setRasterOp(Qt::XorROP);
851       p.drawRect(QRect(myPoint, myOtherPoint));
852       break;
853     }
854     case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
855     case VTK_INTERACTOR_STYLE_CAMERA_PAN:
856     case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
857     case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
858     case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
859       break;
860   }
861 }
862
863
864 //----------------------------------------------------------------------------
865 // called when viewer operation finished (!put necessary post-processing here!)
866 void
867 SVTK_InteractorStyle
868 ::onFinishOperation() 
869 {
870   if (!GetRenderWidget()) 
871     return;
872
873   // VSV: LOD actor activisation
874   //  rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate());
875
876   SVTK_SelectionEvent* aSelectionEvent = GetSelectionEventFlipY();
877
878   switch (State) {
879     case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
880     case VTK_INTERACTOR_STYLE_CAMERA_FIT:
881     {
882       QPainter aPainter(GetRenderWidget());
883       aPainter.setPen(Qt::lightGray);
884       aPainter.setRasterOp(Qt::XorROP);
885       QRect aRect(myPoint, myOtherPoint);
886       aPainter.drawRect(aRect);
887       aRect = aRect.normalize();
888
889       if (State == VTK_INTERACTOR_STYLE_CAMERA_FIT) {
890         // making fit rect opeation 
891         int w, h;
892         Interactor->GetSize(w, h);
893         int x1 = aRect.left(); 
894         int y1 = h - aRect.top() - 1;
895         int x2 = aRect.right(); 
896         int y2 = h - aRect.bottom() - 1;
897         fitRect(x1, y1, x2, y2);
898       }
899       else {
900         if (myPoint == myOtherPoint) {
901           // process point selection
902           this->FindPokedRenderer(aSelectionEvent->myX, aSelectionEvent->myY);
903           Interactor->StartPickCallback();
904
905           myPicker->Pick(aSelectionEvent->myX, 
906                          aSelectionEvent->myY, 
907                          0.0, 
908                          GetCurrentRenderer());
909           //
910           SALOME_Actor* anActor = GetFirstSALOMEActor(myPicker.GetPointer());
911           aSelectionEvent->myIsRectangle = false;
912           if(anActor){
913             anActor->Highlight( this, aSelectionEvent, true );
914           }else{
915             if(myLastHighlitedActor.GetPointer() && myLastHighlitedActor.GetPointer() != anActor)
916               myLastHighlitedActor->Highlight( this, aSelectionEvent, false );
917             if(!myShiftState)
918               GetSelector()->ClearIObjects();
919           }
920           myLastHighlitedActor = anActor;
921         } 
922         else {
923           //processing rectangle selection
924           Interactor->StartPickCallback();
925           GetSelector()->StartPickCallback();
926           aSelectionEvent->myIsRectangle = true;
927
928           if(!myShiftState)
929             GetSelector()->ClearIObjects();
930
931           vtkActorCollection* aListActors = GetCurrentRenderer()->GetActors();
932           aListActors->InitTraversal();
933           while(vtkActor* aActor = aListActors->GetNextActor()){
934             if(aActor->GetVisibility()){
935               if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)){
936                 if(aSActor->hasIO()){
937                   aSActor->Highlight( this, aSelectionEvent, true );
938                 }
939               }
940             }
941           }
942         }
943         Interactor->EndPickCallback();
944         GetSelector()->EndPickCallback();
945       } 
946     } 
947     break;
948   case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
949   case VTK_INTERACTOR_STYLE_CAMERA_PAN:
950   case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
951   case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
952     break;
953   case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN: 
954     {
955       int w, h, x, y;
956       Interactor->GetSize(w, h);
957       x = myPoint.x(); 
958       y = h - myPoint.y() - 1;
959       Place(x, y);
960     }
961     break;
962   }
963
964   this->Render();
965 }
966
967
968 // called during viewer operation when user moves mouse (!put necessary processing here!)
969 //----------------------------------------------------------------------------
970 void
971 SVTK_InteractorStyle
972 ::onOperation(QPoint mousePos) 
973 {
974   if (!GetRenderWidget()) 
975     return;
976
977   switch (State) {
978   case VTK_INTERACTOR_STYLE_CAMERA_PAN: 
979     {
980       this->PanXY(mousePos.x(), myPoint.y(), myPoint.x(), mousePos.y());
981       myPoint = mousePos;
982       break;
983     }
984   case VTK_INTERACTOR_STYLE_CAMERA_ZOOM: 
985     {    
986       this->DollyXY(mousePos.x() - myPoint.x(), mousePos.y() - myPoint.y());
987       myPoint = mousePos;
988       break;
989     }
990   case VTK_INTERACTOR_STYLE_CAMERA_ROTATE: 
991     {
992       this->RotateXY(mousePos.x() - myPoint.x(), myPoint.y() - mousePos.y());
993       myPoint = mousePos;
994       break;
995     }
996   case VTK_INTERACTOR_STYLE_CAMERA_SPIN: 
997     {
998       this->SpinXY(mousePos.x(), mousePos.y(), myPoint.x(), myPoint.y());
999       myPoint = mousePos;
1000       break;
1001     }
1002   case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN: 
1003     {    
1004       break;
1005     }
1006   case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
1007     {
1008       if (!myCursorState)
1009         setCursor(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
1010     }
1011   case VTK_INTERACTOR_STYLE_CAMERA_FIT:
1012     {
1013       QPainter p(GetRenderWidget());
1014       p.setPen(Qt::lightGray);
1015       p.setRasterOp(Qt::XorROP);
1016       p.drawRect(QRect(myPoint, myOtherPoint));
1017       myOtherPoint = mousePos;
1018       p.drawRect(QRect(myPoint, myOtherPoint));
1019       break;
1020     }
1021   }
1022 }
1023
1024 // called when user moves mouse inside viewer window and there is no active viewer operation 
1025 // (!put necessary processing here!)
1026 //----------------------------------------------------------------------------
1027 void
1028 SVTK_InteractorStyle
1029 ::onCursorMove(QPoint mousePos) 
1030 {
1031   // processing highlighting
1032   SVTK_SelectionEvent* aSelectionEvent = GetSelectionEventFlipY();
1033   this->FindPokedRenderer(aSelectionEvent->myX,aSelectionEvent->myY);
1034
1035   bool anIsChanged = false;
1036
1037   myPicker->Pick(aSelectionEvent->myX, 
1038                  aSelectionEvent->myY, 
1039                  0.0, 
1040                  GetCurrentRenderer());
1041   
1042   SALOME_Actor *anActor = GetFirstSALOMEActor(myPicker.GetPointer());
1043   if (anActor){
1044     anIsChanged |= anActor->PreHighlight( this, aSelectionEvent, true );
1045   }
1046
1047   if(myLastPreHighlitedActor.GetPointer() && myLastPreHighlitedActor.GetPointer() != anActor)
1048     anIsChanged |= myLastPreHighlitedActor->PreHighlight( this, aSelectionEvent, false );   
1049
1050   myLastPreHighlitedActor = anActor;
1051
1052   if(anIsChanged)
1053     this->Render();
1054 }
1055
1056 // called on finsh GlobalPan operation 
1057 //----------------------------------------------------------------------------
1058 void
1059 SVTK_InteractorStyle
1060 ::Place(const int theX, const int theY) 
1061 {
1062   if (GetCurrentRenderer() == NULL)
1063     return;
1064
1065   //translate view
1066   int *aSize = GetCurrentRenderer()->GetRenderWindow()->GetSize();
1067   int centerX = aSize[0]/2;
1068   int centerY = aSize[1]/2;
1069
1070   TranslateView(centerX, centerY, theX, theY);
1071
1072   // restore zoom scale
1073   vtkCamera *cam = GetCurrentRenderer()->GetActiveCamera();
1074   cam->SetParallelScale(myScale);
1075   GetCurrentRenderer()->ResetCameraClippingRange();
1076
1077   this->Render();
1078 }
1079
1080
1081
1082 // Translates view from Point to Point
1083 //----------------------------------------------------------------------------
1084 void
1085 SVTK_InteractorStyle
1086 ::TranslateView(int toX, int toY, int fromX, int fromY)
1087 {
1088   vtkCamera *cam = GetCurrentRenderer()->GetActiveCamera();
1089   double viewFocus[4], focalDepth, viewPoint[3];
1090   float newPickPoint[4], oldPickPoint[4], motionVector[3];
1091   cam->GetFocalPoint(viewFocus);
1092
1093   this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1],
1094                               viewFocus[2], viewFocus);
1095   focalDepth = viewFocus[2];
1096
1097   this->ComputeDisplayToWorld(double(toX), double(toY),
1098                               focalDepth, newPickPoint);
1099   this->ComputeDisplayToWorld(double(fromX),double(fromY),
1100                               focalDepth, oldPickPoint);
1101   
1102   // camera motion is reversed
1103   motionVector[0] = oldPickPoint[0] - newPickPoint[0];
1104   motionVector[1] = oldPickPoint[1] - newPickPoint[1];
1105   motionVector[2] = oldPickPoint[2] - newPickPoint[2];
1106   
1107   cam->GetFocalPoint(viewFocus);
1108   cam->GetPosition(viewPoint);
1109   cam->SetFocalPoint(motionVector[0] + viewFocus[0],
1110                      motionVector[1] + viewFocus[1],
1111                      motionVector[2] + viewFocus[2]);
1112   cam->SetPosition(motionVector[0] + viewPoint[0],
1113                    motionVector[1] + viewPoint[1],
1114                    motionVector[2] + viewPoint[2]);
1115 }
1116
1117 //----------------------------------------------------------------------------
1118 void
1119 SVTK_InteractorStyle
1120 ::IncrementalPan( const int incrX, const int incrY )
1121 {
1122   this->PanXY( incrX, incrY, 0, 0 );
1123 }
1124
1125 //----------------------------------------------------------------------------
1126 void
1127 SVTK_InteractorStyle
1128 ::IncrementalZoom( const int incr )
1129 {
1130   this->DollyXY( incr, incr );
1131 }
1132
1133 //----------------------------------------------------------------------------
1134 void
1135 SVTK_InteractorStyle
1136 ::IncrementalRotate( const int incrX, const int incrY )
1137 {
1138   this->RotateXY( incrX, -incrY );
1139 }
1140
1141 //----------------------------------------------------------------------------
1142 void
1143 SVTK_InteractorStyle
1144 ::SetInteractor( vtkRenderWindowInteractor* theInteractor )
1145 {
1146   // register EventCallbackCommand as observer of standard events (keypress, mousemove, etc)
1147   Superclass::SetInteractor( theInteractor );
1148  
1149   myInteractor = dynamic_cast<SVTK_GenericRenderWindowInteractor*>(theInteractor);
1150
1151   if(theInteractor) { 
1152     // register EventCallbackCommand as observer of custorm event (3d space mouse event)
1153     theInteractor->AddObserver( SVTK::SpaceMouseMoveEvent, EventCallbackCommand, Priority );
1154     theInteractor->AddObserver( SVTK::SpaceMouseButtonEvent, EventCallbackCommand, Priority );
1155     theInteractor->AddObserver( SVTK::PanLeftEvent, EventCallbackCommand, Priority );
1156     theInteractor->AddObserver( SVTK::PanRightEvent, EventCallbackCommand, Priority );
1157     theInteractor->AddObserver( SVTK::PanUpEvent, EventCallbackCommand, Priority );
1158     theInteractor->AddObserver( SVTK::PanDownEvent, EventCallbackCommand, Priority );
1159     theInteractor->AddObserver( SVTK::ZoomInEvent, EventCallbackCommand, Priority );
1160     theInteractor->AddObserver( SVTK::ZoomOutEvent, EventCallbackCommand, Priority );
1161     theInteractor->AddObserver( SVTK::RotateLeftEvent, EventCallbackCommand, Priority );
1162     theInteractor->AddObserver( SVTK::RotateRightEvent, EventCallbackCommand, Priority );
1163     theInteractor->AddObserver( SVTK::RotateUpEvent, EventCallbackCommand, Priority );
1164     theInteractor->AddObserver( SVTK::RotateDownEvent, EventCallbackCommand, Priority );
1165     theInteractor->AddObserver( SVTK::PlusSpeedIncrementEvent, EventCallbackCommand, Priority );
1166     theInteractor->AddObserver( SVTK::MinusSpeedIncrementEvent, EventCallbackCommand, Priority );
1167     theInteractor->AddObserver( SVTK::SetSpeedIncrementEvent, EventCallbackCommand, Priority );
1168
1169     theInteractor->AddObserver( SVTK::SetSMDecreaseSpeedEvent, EventCallbackCommand, Priority );
1170     theInteractor->AddObserver( SVTK::SetSMIncreaseSpeedEvent, EventCallbackCommand, Priority );
1171     theInteractor->AddObserver( SVTK::SetSMDominantCombinedSwitchEvent, EventCallbackCommand, Priority );
1172
1173     theInteractor->AddObserver( SVTK::StartZoom, EventCallbackCommand, Priority );
1174     theInteractor->AddObserver( SVTK::StartPan, EventCallbackCommand, Priority );
1175     theInteractor->AddObserver( SVTK::StartRotate, EventCallbackCommand, Priority );
1176     theInteractor->AddObserver( SVTK::StartGlobalPan, EventCallbackCommand, Priority );
1177     theInteractor->AddObserver( SVTK::StartFitArea, EventCallbackCommand, Priority );
1178   }
1179 }
1180
1181
1182 //----------------------------------------------------------------------------
1183 void
1184 SVTK_InteractorStyle
1185 ::OnTimer() 
1186 {
1187   //vtkInteractorStyle::OnTimer();
1188   this->Interactor->Render();
1189 }
1190
1191 //----------------------------------------------------------------------------
1192 void
1193 SVTK_InteractorStyle
1194 ::Render() 
1195 {
1196   this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
1197 }
1198
1199 //----------------------------------------------------------------------------
1200 void
1201 SVTK_InteractorStyle
1202 ::onSpaceMouseMove( double* data )
1203 {
1204   // general things, do SetCurrentRenderer() within FindPokedRenderer() 
1205   int x, y;
1206   GetEventPosition( this->Interactor, x, y ); // current mouse position (from last mouse move event or any other event)
1207   FindPokedRenderer( x, y ); // calls SetCurrentRenderer
1208   
1209   IncrementalZoom( (int)data[2] );        // 1. push toward / pull backward = zoom out / zoom in
1210   IncrementalPan(  (int)data[0],  (int)data[1] );// 2. pull up / push down = pan up / down, 3. move left / right = pan left / right
1211   IncrementalRotate( 0,  (int)data[4] );   // 4. twist the control = rotate around Y axis
1212   IncrementalRotate( (int)data[3], 0  );   // 5. tilt the control forward/backward = rotate around X axis (Z axis of local coordinate system of space mouse)
1213 }
1214
1215 //----------------------------------------------------------------------------
1216 void
1217 SVTK_InteractorStyle
1218 ::onSpaceMouseButton( int button )
1219 {
1220   if( mySMDecreaseSpeedBtn == button ) {   
1221     ControllerIncrement()->Decrease();
1222   }
1223   if( mySMIncreaseSpeedBtn == button ) {    
1224     ControllerIncrement()->Increase();
1225   }
1226   if( mySMDominantCombinedSwitchBtn == button )    
1227     DominantCombinedSwitch();
1228 }
1229
1230 //----------------------------------------------------------------------------
1231 void
1232 SVTK_InteractorStyle
1233 ::DominantCombinedSwitch()
1234 {
1235   printf( "\n--DominantCombinedSwitch() NOT IMPLEMENTED--\n" );
1236 }
1237
1238 //----------------------------------------------------------------------------
1239 void
1240 SVTK_InteractorStyle
1241 ::ProcessEvents( vtkObject* object,
1242                  unsigned long event,
1243                  void* clientData, 
1244                  void* callData )
1245 {
1246   if ( clientData ) {
1247     vtkObject* anObject = reinterpret_cast<vtkObject*>( clientData );
1248     SVTK_InteractorStyle* self = dynamic_cast<SVTK_InteractorStyle*>( anObject );
1249     int aSpeedIncrement=self->ControllerIncrement()->Current();
1250     if ( self ) {
1251       switch ( event ) {
1252       case SVTK::SpaceMouseMoveEvent : 
1253         self->onSpaceMouseMove( (double*)callData ); 
1254         return;
1255       case SVTK::SpaceMouseButtonEvent : 
1256         self->onSpaceMouseButton( *((int*)callData) ); 
1257         return;
1258       case SVTK::PanLeftEvent: 
1259         self->IncrementalPan(-aSpeedIncrement, 0);
1260         return;
1261       case SVTK::PanRightEvent:
1262         self->IncrementalPan(aSpeedIncrement, 0);
1263         return;
1264       case SVTK::PanUpEvent:
1265         self->IncrementalPan(0, aSpeedIncrement);
1266         return;
1267       case SVTK::PanDownEvent:
1268         self->IncrementalPan(0, -aSpeedIncrement);
1269         return;
1270       case SVTK::ZoomInEvent:
1271         self->IncrementalZoom(aSpeedIncrement);
1272         return;
1273       case SVTK::ZoomOutEvent:
1274         self->IncrementalZoom(-aSpeedIncrement);
1275         return;
1276       case SVTK::RotateLeftEvent: 
1277         self->IncrementalRotate(-aSpeedIncrement, 0);
1278         return;
1279       case SVTK::RotateRightEvent:
1280         self->IncrementalRotate(aSpeedIncrement, 0);
1281         return;
1282       case SVTK::RotateUpEvent:
1283         self->IncrementalRotate(0, -aSpeedIncrement);
1284         return;
1285       case SVTK::RotateDownEvent:
1286         self->IncrementalRotate(0, aSpeedIncrement);
1287         return;
1288       case SVTK::PlusSpeedIncrementEvent:
1289         self->ControllerIncrement()->Increase();
1290         return;
1291       case SVTK::MinusSpeedIncrementEvent:
1292         self->ControllerIncrement()->Decrease();
1293         return;
1294       case SVTK::SetSpeedIncrementEvent:
1295         self->ControllerIncrement()->SetStartValue(*((int*)callData));
1296         return;
1297
1298       case SVTK::SetSMDecreaseSpeedEvent:
1299         self->mySMDecreaseSpeedBtn = *((int*)callData);
1300         return;
1301       case SVTK::SetSMIncreaseSpeedEvent:
1302         self->mySMIncreaseSpeedBtn = *((int*)callData);
1303         return;
1304       case SVTK::SetSMDominantCombinedSwitchEvent:
1305         self->mySMDominantCombinedSwitchBtn = *((int*)callData);
1306         return;
1307
1308       case SVTK::StartZoom:
1309         self->startZoom();
1310         return;
1311       case SVTK::StartPan:
1312         self->startPan();
1313         return;
1314       case SVTK::StartRotate:
1315         self->startRotate();
1316         return;
1317       case SVTK::StartGlobalPan:
1318         self->startGlobalPan();
1319         return;
1320       case SVTK::StartFitArea:
1321         self->startFitArea();
1322         return;
1323       }
1324     }
1325   }
1326
1327   Superclass::ProcessEvents( object, event, clientData, callData );
1328 }
1329 //----------------------------------------------------------------------------
1330 void SVTK_InteractorStyle::OnChar()
1331 {
1332 }
1333 //----------------------------------------------------------------------------
1334 void SVTK_InteractorStyle::OnKeyDown()
1335 {
1336   bool bInvokeSuperclass=myControllerOnKeyDown->OnKeyDown(this);
1337   if (bInvokeSuperclass){
1338     Superclass::OnKeyDown();
1339   }
1340 }
1341 //----------------------------------------------------------------------------
1342 void SVTK_InteractorStyle::ActionPicking()
1343 {
1344   int x, y;
1345   Interactor->GetEventPosition( x, y ); 
1346   FindPokedRenderer( x, y ); 
1347   
1348   myOtherPoint = myPoint = QPoint(x, y);
1349   
1350   startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
1351   onFinishOperation();
1352   startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
1353 }
1354 //----------------------------------------------------------------------------
1355 void SVTK_InteractorStyle::SetControllerOnKeyDown(SVTK_ControllerOnKeyDown* theController)
1356 {
1357   myControllerOnKeyDown=theController;
1358 }
1359 //----------------------------------------------------------------------------
1360 SVTK_ControllerOnKeyDown* SVTK_InteractorStyle::ControllerOnKeyDown()
1361 {
1362   return myControllerOnKeyDown.GetPointer();
1363 }
1364 //----------------------------------------------------------------------------
1365 void SVTK_InteractorStyle::SetControllerIncrement(SVTK_ControllerIncrement* theController)
1366 {
1367   myControllerIncrement=theController;
1368 }
1369 //----------------------------------------------------------------------------
1370 SVTK_ControllerIncrement* SVTK_InteractorStyle::ControllerIncrement()
1371 {
1372   return myControllerIncrement.GetPointer();
1373 }
1374
1375 vtkStandardNewMacro(SVTK_ControllerIncrement);
1376 //----------------------------------------------------------------------------
1377 SVTK_ControllerIncrement::SVTK_ControllerIncrement()
1378 {
1379   myIncrement=10;
1380 }
1381 //----------------------------------------------------------------------------
1382 SVTK_ControllerIncrement::~SVTK_ControllerIncrement()
1383 {
1384 }
1385 //----------------------------------------------------------------------------
1386 void SVTK_ControllerIncrement::SetStartValue(const int theValue)
1387 {
1388   myIncrement=theValue;
1389 }
1390 //----------------------------------------------------------------------------
1391 int SVTK_ControllerIncrement::Current()const
1392 {
1393   return myIncrement;
1394 }
1395 //----------------------------------------------------------------------------
1396 int SVTK_ControllerIncrement::Increase()
1397 {
1398   ++myIncrement;
1399   return myIncrement;
1400 }
1401 //----------------------------------------------------------------------------
1402 int SVTK_ControllerIncrement::Decrease()
1403 {
1404   if (myIncrement>1){
1405     --myIncrement;
1406   }
1407   return myIncrement;
1408 }
1409
1410 vtkStandardNewMacro(SVTK_ControllerOnKeyDown);
1411 //----------------------------------------------------------------------------
1412 SVTK_ControllerOnKeyDown::SVTK_ControllerOnKeyDown()
1413 {
1414 }
1415 //----------------------------------------------------------------------------
1416 SVTK_ControllerOnKeyDown::~SVTK_ControllerOnKeyDown()
1417 {
1418 }
1419 //----------------------------------------------------------------------------
1420 bool SVTK_ControllerOnKeyDown::OnKeyDown(vtkInteractorStyle* theIS)
1421 {
1422   return true;
1423 }