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