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 class vtkRenderWindowInteractor;
40 #include "VTKViewer_Filter.h"
43 class SALOME_CubeAxesActor2D;
44 class VTKViewer_Actor;
45 class VTKViewer_Trihedron;
46 class VTKViewer_ViewFrame;
47 class VTKViewer_RenderWindowInteractor;
49 #define VTK_INTERACTOR_STYLE_CAMERA_NONE 0
50 #define VTK_INTERACTOR_STYLE_CAMERA_ROTATE 1
51 #define VTK_INTERACTOR_STYLE_CAMERA_PAN 2
52 #define VTK_INTERACTOR_STYLE_CAMERA_ZOOM 3
53 #define VTK_INTERACTOR_STYLE_CAMERA_SPIN 4
54 #define VTK_INTERACTOR_STYLE_CAMERA_FIT 5
55 #define VTK_INTERACTOR_STYLE_CAMERA_SELECT 6
56 #define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
58 class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyle
62 // This class must be supplied with a vtkRenderWindowInteractor wrapper or
63 // parent. This class should not normally be instantiated by application
65 static VTKViewer_InteractorStyleSALOME *New();
66 vtkTypeMacro(VTKViewer_InteractorStyleSALOME, vtkInteractorStyle);
68 virtual void SetInteractor(vtkRenderWindowInteractor *theInteractor);
69 void setViewFrame(VTKViewer_ViewFrame* theViewFrame);
70 void setGUIWindow(QWidget* theWindow);
72 void setTriedron(VTKViewer_Trihedron* theTrihedron);
73 void setCubeAxes(SALOME_CubeAxesActor2D* theCubeAxes);
75 void setPreselectionProp(const double& theRed = 0, const double& theGreen = 1,
76 const double& theBlue = 1, const int& theWidth = 5);
78 // Generic event bindings must be overridden in subclasses
79 void OnMouseMove (int ctrl, int shift, int x, int y);
80 void OnLeftButtonDown(int ctrl, int shift, int x, int y);
81 void OnLeftButtonUp (int ctrl, int shift, int x, int y);
82 void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
83 void OnMiddleButtonUp (int ctrl, int shift, int x, int y);
84 void OnRightButtonDown(int ctrl, int shift, int x, int y);
85 void OnRightButtonUp (int ctrl, int shift, int x, int y);
87 void OnSelectionModeChanged();
91 void SetFilter( const Handle(VTKViewer_Filter)& );
92 Handle(VTKViewer_Filter) GetFilter( const int );
93 bool IsFilterPresent( const int );
94 void RemoveFilter( const int );
95 bool IsValid( SALOME_Actor* theActor,
97 const bool theIsNode = false );
99 void IncrementalPan ( const int incrX, const int incrY );
100 void IncrementalZoom ( const int incr );
101 void IncrementalRotate( const int incrX, const int incrY );
104 VTKViewer_InteractorStyleSALOME();
105 ~VTKViewer_InteractorStyleSALOME();
106 VTKViewer_InteractorStyleSALOME(const VTKViewer_InteractorStyleSALOME&) {};
107 void operator=(const VTKViewer_InteractorStyleSALOME&) {};
109 void RotateXY(int dx, int dy);
110 void PanXY(int x, int y, int oldX, int oldY);
111 void DollyXY(int dx, int dy);
112 void SpinXY(int dx, int dy, int oldX, int oldY);
113 void fitRect(const int left, const int top, const int right, const int bottom);
114 void Place(const int theX, const int theY);
115 void TranslateView(int toX, int toY, int fromX, int fromY);
116 bool IsInRect(vtkActor* theActor,
117 const int left, const int top,
118 const int right, const int bottom);
119 bool IsInRect(vtkCell* theCell,
120 const int left, const int top,
121 const int right, const int bottom);
122 bool IsInRect(float* thePoint,
123 const int left, const int top,
124 const int right, const int bottom);
128 float RadianToDegree; // constant: for conv from deg to rad
131 SALOME_Actor* myPreViewActor;
133 VTKViewer_Actor* myPreSelectionActor;
134 SALOME_Actor* mySelectedActor;
140 bool eventFilter(QObject* object, QEvent* event);
143 void startGlobalPan();
147 bool needsRedrawing();
151 void startOperation(int operation);
152 void onStartOperation();
153 void onFinishOperation();
154 void onOperation(QPoint mousePos);
155 void onCursorMove(QPoint mousePos);
156 void setCursor(const int operation);
162 QCursor myZoomCursor;
163 QCursor myRotateCursor;
164 QCursor mySpinCursor;
165 QCursor myHandCursor;
166 QCursor myGlobalPanCursor;
173 VTKViewer_RenderWindowInteractor* m_Interactor;
174 VTKViewer_ViewFrame* m_ViewFrame;
175 VTKViewer_Trihedron* m_Trihedron;
176 SALOME_CubeAxesActor2D* m_CubeAxes;
177 QWidget* myGUIWindow;
179 std::map<int, Handle(VTKViewer_Filter)> myFilters;
181 // members from old version
182 double DeltaElevation;