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