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 : SVTK_InteractorStyle.h
25 // Author : Christophe ATTANASIO
29 #ifndef __SVTK_InteractorStyle_h
30 #define __SVTK_InteractorStyle_h
34 #include <vtkInteractorStyle.h>
37 class vtkRenderWindowInteractor;
44 #include "VTKViewer_Filter.h"
46 class VTKViewer_Trihedron;
52 class SVTK_ViewWindow;
53 class SVTK_RenderWindowInteractor;
55 #define VTK_INTERACTOR_STYLE_CAMERA_NONE 0
56 #define VTK_INTERACTOR_STYLE_CAMERA_ROTATE 1
57 #define VTK_INTERACTOR_STYLE_CAMERA_PAN 2
58 #define VTK_INTERACTOR_STYLE_CAMERA_ZOOM 3
59 #define VTK_INTERACTOR_STYLE_CAMERA_SPIN 4
60 #define VTK_INTERACTOR_STYLE_CAMERA_FIT 5
61 #define VTK_INTERACTOR_STYLE_CAMERA_SELECT 6
62 #define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
64 class SVTK_EXPORT SVTK_InteractorStyle : public QObject,
65 public vtkInteractorStyle
71 // This class must be supplied with a vtkRenderWindowInteractor wrapper or
72 // parent. This class should not normally be instantiated by application
74 static SVTK_InteractorStyle *New();
75 vtkTypeMacro(SVTK_InteractorStyle, vtkInteractorStyle);
77 virtual void SetInteractor(vtkRenderWindowInteractor *theInteractor);
78 void setViewWindow(SVTK_ViewWindow* theViewWindow);
79 void setGUIWindow(QWidget* theWindow);
81 void setTriedron(VTKViewer_Trihedron* theTrihedron);
82 void setPreselectionProp(const double& theRed = 0,
83 const double& theGreen = 1,
84 const double& theBlue = 1,
85 const int& theWidth = 5);
87 // Generic event bindings must be overridden in subclasses
88 void OnMouseMove (int ctrl, int shift, int x, int y);
89 void OnLeftButtonDown(int ctrl, int shift, int x, int y);
90 void OnLeftButtonUp (int ctrl, int shift, int x, int y);
91 void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
92 void OnMiddleButtonUp (int ctrl, int shift, int x, int y);
93 void OnRightButtonDown(int ctrl, int shift, int x, int y);
94 void OnRightButtonUp (int ctrl, int shift, int x, int y);
96 void OnSelectionModeChanged();
100 void SetFilter( const Handle(VTKViewer_Filter)& );
101 Handle(VTKViewer_Filter) GetFilter( const int );
102 bool IsFilterPresent( const int );
103 void RemoveFilter( const int );
104 bool IsValid( SALOME_Actor* theActor,
106 const bool theIsNode = false );
108 void IncrementalPan ( const int incrX, const int incrY );
109 void IncrementalZoom ( const int incr );
110 void IncrementalRotate( const int incrX, const int incrY );
113 SVTK_InteractorStyle();
114 ~SVTK_InteractorStyle();
115 SVTK_InteractorStyle(const SVTK_InteractorStyle&) {};
116 void operator=(const SVTK_InteractorStyle&) {};
118 SVTK_Selector* GetSelector();
120 void RotateXY(int dx, int dy);
121 void PanXY(int x, int y, int oldX, int oldY);
122 void DollyXY(int dx, int dy);
123 void SpinXY(int dx, int dy, int oldX, int oldY);
124 void fitRect(const int left, const int top, const int right, const int bottom);
125 void Place(const int theX, const int theY);
126 void TranslateView(int toX, int toY, int fromX, int fromY);
127 bool IsInRect(vtkActor* theActor,
128 const int left, const int top,
129 const int right, const int bottom);
130 bool IsInRect(vtkCell* theCell,
131 const int left, const int top,
132 const int right, const int bottom);
133 bool IsInRect(float* thePoint,
134 const int left, const int top,
135 const int right, const int bottom);
139 float RadianToDegree; // constant: for conv from deg to rad
142 SALOME_Actor* myPreViewActor;
144 SVTK_Actor* myPreSelectionActor;
145 SALOME_Actor* mySelectedActor;
151 bool eventFilter(QObject* object, QEvent* event);
154 void startGlobalPan();
158 bool needsRedrawing();
162 void startOperation(int operation);
163 void onStartOperation();
164 void onFinishOperation();
165 void onOperation(QPoint mousePos);
166 void onCursorMove(QPoint mousePos);
167 void setCursor(const int operation);
172 QCursor myZoomCursor;
173 QCursor myRotateCursor;
174 QCursor mySpinCursor;
175 QCursor myHandCursor;
176 QCursor myGlobalPanCursor;
183 SVTK_RenderWindowInteractor* myInteractor;
184 SVTK_ViewWindow* myViewWindow;
185 VTKViewer_Trihedron* myTrihedron;
186 QWidget* myGUIWindow;
188 std::map<int, Handle(VTKViewer_Filter)> myFilters;
190 // members from old version
191 double DeltaElevation;