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 VTKViewer_Actor;
44 class VTKViewer_Trihedron;
45 class VTKViewer_ViewFrame;
46 class VTKViewer_RenderWindowInteractor;
48 #define VTK_INTERACTOR_STYLE_CAMERA_NONE 0
49 #define VTK_INTERACTOR_STYLE_CAMERA_ROTATE 1
50 #define VTK_INTERACTOR_STYLE_CAMERA_PAN 2
51 #define VTK_INTERACTOR_STYLE_CAMERA_ZOOM 3
52 #define VTK_INTERACTOR_STYLE_CAMERA_SPIN 4
53 #define VTK_INTERACTOR_STYLE_CAMERA_FIT 5
54 #define VTK_INTERACTOR_STYLE_CAMERA_SELECT 6
55 #define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
57 class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyle
61 // This class must be supplied with a vtkRenderWindowInteractor wrapper or
62 // parent. This class should not normally be instantiated by application
64 static VTKViewer_InteractorStyleSALOME *New();
65 vtkTypeMacro(VTKViewer_InteractorStyleSALOME, vtkInteractorStyle);
67 virtual void SetInteractor(vtkRenderWindowInteractor *theInteractor);
68 void setViewFrame(VTKViewer_ViewFrame* theViewFrame);
69 void setGUIWindow(QWidget* theWindow);
71 void setTriedron(VTKViewer_Trihedron* theTrihedron);
72 void setPreselectionProp(const double& theRed = 0, const double& theGreen = 1,
73 const double& theBlue = 1, const int& theWidth = 5);
75 // Generic event bindings must be overridden in subclasses
76 void OnMouseMove (int ctrl, int shift, int x, int y);
77 void OnLeftButtonDown(int ctrl, int shift, int x, int y);
78 void OnLeftButtonUp (int ctrl, int shift, int x, int y);
79 void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
80 void OnMiddleButtonUp (int ctrl, int shift, int x, int y);
81 void OnRightButtonDown(int ctrl, int shift, int x, int y);
82 void OnRightButtonUp (int ctrl, int shift, int x, int y);
84 void OnSelectionModeChanged();
88 void SetFilter( const Handle(VTKViewer_Filter)& );
89 Handle(VTKViewer_Filter) GetFilter( const int );
90 bool IsFilterPresent( const int );
91 void RemoveFilter( const int );
92 bool IsValid( SALOME_Actor* theActor,
94 const bool theIsNode = false );
98 VTKViewer_InteractorStyleSALOME();
99 ~VTKViewer_InteractorStyleSALOME();
100 VTKViewer_InteractorStyleSALOME(const VTKViewer_InteractorStyleSALOME&) {};
101 void operator=(const VTKViewer_InteractorStyleSALOME&) {};
103 void RotateXY(int dx, int dy);
104 void PanXY(int x, int y, int oldX, int oldY);
105 void DollyXY(int dx, int dy);
106 void SpinXY(int dx, int dy, int oldX, int oldY);
107 void fitRect(const int left, const int top, const int right, const int bottom);
108 void Place(const int theX, const int theY);
109 void TranslateView(int toX, int toY, int fromX, int fromY);
110 bool IsInRect(vtkActor* theActor,
111 const int left, const int top,
112 const int right, const int bottom);
113 bool IsInRect(vtkCell* theCell,
114 const int left, const int top,
115 const int right, const int bottom);
116 bool IsInRect(float* thePoint,
117 const int left, const int top,
118 const int right, const int bottom);
122 float RadianToDegree; // constant: for conv from deg to rad
125 SALOME_Actor* myPreViewActor;
127 VTKViewer_Actor* myPreSelectionActor;
128 SALOME_Actor* mySelectedActor;
134 bool eventFilter(QObject* object, QEvent* event);
137 void startGlobalPan();
141 bool needsRedrawing();
145 void startOperation(int operation);
146 void onStartOperation();
147 void onFinishOperation();
148 void onOperation(QPoint mousePos);
149 void onCursorMove(QPoint mousePos);
150 void setCursor(const int operation);
156 QCursor myZoomCursor;
157 QCursor myRotateCursor;
158 QCursor mySpinCursor;
159 QCursor myHandCursor;
160 QCursor myGlobalPanCursor;
167 VTKViewer_RenderWindowInteractor* m_Interactor;
168 VTKViewer_ViewFrame* m_ViewFrame;
169 VTKViewer_Trihedron* m_Trihedron;
170 QWidget* myGUIWindow;
172 std::map<int, Handle(VTKViewer_Filter)> myFilters;
174 // members from old version
175 double DeltaElevation;