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"
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
47 class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyle
51 // This class must be supplied with a vtkRenderWindowInteractor wrapper or
52 // parent. This class should not normally be instantiated by application
54 static VTKViewer_InteractorStyleSALOME *New();
56 void setTriedron( vtkActorCollection* triedron );
58 vtkTypeMacro(VTKViewer_InteractorStyleSALOME, vtkObject);
59 void PrintSelf(ostream& os, vtkIndent indent);
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);
71 VTKViewer_InteractorStyleSALOME();
72 ~VTKViewer_InteractorStyleSALOME();
73 VTKViewer_InteractorStyleSALOME(const VTKViewer_InteractorStyleSALOME&) {};
74 void operator=(const VTKViewer_InteractorStyleSALOME&) {};
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);
95 float RadianToDegree; // constant: for conv from deg to rad
98 SALOME_Actor* preview;
101 bool eventFilter(QObject* object, QEvent* event);
102 void ControlLblSize(double aOldScale, double aNewScale);
105 void startGlobalPan();
109 bool needsRedrawing();
110 QWidget* getGUIWindow() {return myGUIWindow;}
111 void setGUIWindow(QWidget* theWin) { myGUIWindow = theWin;}
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);
125 QCursor myZoomCursor;
126 QCursor myRotateCursor;
127 QCursor mySpinCursor;
128 QCursor myHandCursor;
129 QCursor myGlobalPanCursor;
135 vtkActorCollection* m_Triedron;
137 QWidget* myGUIWindow;
139 // members from old version
140 double DeltaElevation;