1 // SALOME VTKViewer : build VTK viewer into Salome desktop
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VTKViewer_InteractorStyleSALOME.h
25 // Author : Christophe ATTANASIO
29 #ifndef __VTKViewer_InteractorStyleSALOME_h
30 #define __VTKViewer_InteractorStyleSALOME_h
32 #include <vtkInteractorStyle.h>
35 #include "SALOME_Actor.h"
37 class VTKViewer_Trihedron;
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
48 class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyle
52 // This class must be supplied with a vtkRenderWindowInteractor wrapper or
53 // parent. This class should not normally be instantiated by application
55 static VTKViewer_InteractorStyleSALOME *New();
57 void setTriedron(VTKViewer_Trihedron* theTrihedron);
59 vtkTypeMacro(VTKViewer_InteractorStyleSALOME, vtkObject);
60 void PrintSelf(ostream& os, vtkIndent indent);
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);
74 VTKViewer_InteractorStyleSALOME();
75 ~VTKViewer_InteractorStyleSALOME();
76 VTKViewer_InteractorStyleSALOME(const VTKViewer_InteractorStyleSALOME&) {};
77 void operator=(const VTKViewer_InteractorStyleSALOME&) {};
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);
98 float RadianToDegree; // constant: for conv from deg to rad
101 SALOME_Actor* preview;
104 bool eventFilter(QObject* object, QEvent* event);
105 void ControlLblSize(double aOldScale, double aNewScale);
108 void startGlobalPan();
112 bool needsRedrawing();
113 QWidget* getGUIWindow() {return myGUIWindow;}
114 void setGUIWindow(QWidget* theWin) { myGUIWindow = theWin;}
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);
128 QCursor myZoomCursor;
129 QCursor myRotateCursor;
130 QCursor mySpinCursor;
131 QCursor myHandCursor;
132 QCursor myGlobalPanCursor;
138 VTKViewer_Trihedron* m_Trihedron;
140 QWidget* myGUIWindow;
142 // members from old version
143 double DeltaElevation;