Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/kernel.git] / src / VTKViewer / VTKViewer_InteractorStyleSALOME.h
1 //  File      : VTKViewer_InteractorStyleSALOME.h
2 //  Created   : Wed Mar 20 11:36:07 2002
3 //  Author    : Christophe ATTANASIO
4 //  Project   : SALOME
5 //  Module    : VTKViewer
6 //  Copyright : Open CASCADE 2002
7 //  $Header$
8
9
10 #ifndef __VTKViewer_InteractorStyleSALOME_h
11 #define __VTKViewer_InteractorStyleSALOME_h
12
13 #include <vtkInteractorStyle.h>
14 #include <qobject.h>
15 #include <qcursor.h>
16 #include "SALOME_Actor.h"
17
18
19 #define VTK_INTERACTOR_STYLE_CAMERA_NONE    0
20 #define VTK_INTERACTOR_STYLE_CAMERA_ROTATE  1
21 #define VTK_INTERACTOR_STYLE_CAMERA_PAN     2
22 #define VTK_INTERACTOR_STYLE_CAMERA_ZOOM    3
23 #define VTK_INTERACTOR_STYLE_CAMERA_SPIN    4
24 #define VTK_INTERACTOR_STYLE_CAMERA_FIT        5
25 #define VTK_INTERACTOR_STYLE_CAMERA_SELECT     6
26 #define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
27
28 class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyle
29 {
30  public:
31   // Description:
32   // This class must be supplied with a vtkRenderWindowInteractor wrapper or
33   // parent. This class should not normally be instantiated by application
34   // programmers.
35   static VTKViewer_InteractorStyleSALOME *New();
36
37   void setTriedron( vtkActorCollection* triedron );
38
39   vtkTypeMacro(VTKViewer_InteractorStyleSALOME, vtkObject);
40   void PrintSelf(ostream& os, vtkIndent indent);
41
42   // Generic event bindings must be overridden in subclasses
43   void OnMouseMove  (int ctrl, int shift, int x, int y);
44   void OnLeftButtonDown(int ctrl, int shift, int x, int y);
45   void OnLeftButtonUp  (int ctrl, int shift, int x, int y);
46   void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
47   void OnMiddleButtonUp  (int ctrl, int shift, int x, int y);
48   void OnRightButtonDown(int ctrl, int shift, int x, int y);
49   void OnRightButtonUp  (int ctrl, int shift, int x, int y);
50
51  protected:
52   VTKViewer_InteractorStyleSALOME();
53   ~VTKViewer_InteractorStyleSALOME();
54   VTKViewer_InteractorStyleSALOME(const VTKViewer_InteractorStyleSALOME&) {};
55   void operator=(const VTKViewer_InteractorStyleSALOME&) {};
56
57   void RotateXY(int dx, int dy);
58   void PanXY(int x, int y, int oldX, int oldY);
59   void DollyXY(int dx, int dy);
60   void SpinXY(int dx, int dy, int oldX, int oldY);
61   void fitRect(const int left, const int top, const int right, const int bottom);
62   void Place(const int theX, const int theY);
63   void TranslateView(int toX, int toY, int fromX, int fromY);
64   bool IsInRect(vtkActor* theActor, 
65                 const int left, const int top, 
66                 const int right, const int bottom);
67   bool IsInRect(vtkCell* theCell, 
68                 const int left, const int top, 
69                 const int right, const int bottom);
70   bool IsInRect(float* thePoint, 
71                 const int left, const int top, 
72                 const int right, const int bottom);
73
74   int State;
75   float MotionFactor;
76   float RadianToDegree;                 // constant: for conv from deg to rad
77   double myScale;
78
79   SALOME_Actor* preview;
80
81 public:
82   bool eventFilter(QObject* object, QEvent* event);
83   void startZoom();
84   void startPan();
85   void startGlobalPan();
86   void startRotate();
87   void startFitArea();
88   void startSpin();
89   bool needsRedrawing();
90
91 protected:
92   void loadCursors();
93   void startOperation(int operation);
94   void onStartOperation();
95   void onFinishOperation();
96   void onOperation(QPoint mousePos);
97   void onCursorMove(QPoint mousePos);
98   void setCursor(const int operation);
99
100 protected:
101   QCursor      myDefCursor;
102   QCursor      myPanCursor;
103   QCursor      myZoomCursor;
104   QCursor      myRotateCursor;
105   QCursor      mySpinCursor;
106   QCursor      myHandCursor;
107   QCursor      myGlobalPanCursor;
108   QPoint       myPoint;
109   QPoint       myOtherPoint;
110   bool         myCursorState;
111   bool         myShiftState;
112   int ForcedState;
113   vtkActorCollection* m_Triedron;  
114 };
115
116 #endif