]> SALOME platform Git repositories - modules/kernel.git/blob - src/VTKViewer/VTKViewer_InteractorStyleSALOME.h
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 ControlLblSize(double aOldScale, double aNewScale);
103   void startZoom();
104   void startPan();
105   void startGlobalPan();
106   void startRotate();
107   void startFitArea();
108   void startSpin();
109   bool needsRedrawing();
110   QWidget* getGUIWindow() {return myGUIWindow;}
111   void setGUIWindow(QWidget* theWin) { myGUIWindow = theWin;}
112
113 protected:
114   void loadCursors();
115   void startOperation(int operation);
116   void onStartOperation();
117   void onFinishOperation();
118   void onOperation(QPoint mousePos);
119   void onCursorMove(QPoint mousePos);
120   void setCursor(const int operation);
121
122 protected:
123   QCursor      myDefCursor;
124   QCursor      myPanCursor;
125   QCursor      myZoomCursor;
126   QCursor      myRotateCursor;
127   QCursor      mySpinCursor;
128   QCursor      myHandCursor;
129   QCursor      myGlobalPanCursor;
130   QPoint       myPoint;
131   QPoint       myOtherPoint;
132   bool         myCursorState;
133   bool         myShiftState;
134   int ForcedState;
135   vtkActorCollection* m_Triedron;  
136
137   QWidget*     myGUIWindow;
138
139   //  members from old version
140   double DeltaElevation;
141   double DeltaAzimuth;
142   int LastPos[2];
143 };
144
145 #endif