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.salome-platform.org/ or email : webmaster.salome@opencascade.com
29 #ifndef SVTK_Renderer_h
30 #define SVTK_Renderer_h
33 #include "VTKViewer.h"
35 #include <vtkObject.h>
36 #include <vtkSmartPointer.h>
39 class vtkCallbackCommand;
40 class vtkRenderWindowInteractor;
47 class SVTK_RectPicker;
49 class VTKViewer_Trihedron;
50 class VTKViewer_Transform;
51 class SVTK_CubeAxesActor2D;
52 class VTKViewer_Actor;
58 The class is a container for #vtkRenderer instance.
59 Main goal of the class is to apply common behaviour to all #SALOME_Actor, like
60 selection and preselection colors.
61 Also, the class is responsible for management of internal actors like trihedron an so on.
63 class SVTK_EXPORT SVTK_Renderer : public vtkObject
66 vtkTypeMacro(SVTK_Renderer,vtkObject);
67 static SVTK_Renderer* New();
69 //----------------------------------------------------------------------------
74 //! Initialize the class
77 Initialize(vtkRenderWindowInteractor* theInteractor,
78 SVTK_Selector* theSelector);
80 //----------------------------------------------------------------------------
81 //! Publishes pointed actor into the renderer
84 AddActor(VTKViewer_Actor* theActor);
86 //! Removes pointed actor from the renderer
89 RemoveActor(VTKViewer_Actor* theActor);
91 //! Get special container that keeps scaling of the scene
95 //! Allows to apply a scale on the whole scene
98 SetScale( double theScale[3] );
100 //! Allows to get a scale that is applied on the whole scene
102 GetScale( double theScale[3] );
104 //----------------------------------------------------------------------------
105 //! Applies color and size (PointSize and LineWidth) of primitives in selection mode
107 SetSelectionProp(const double& theRed = 1,
108 const double& theGreen = 1,
109 const double& theBlue = 0,
110 const int& theWidth = 5);
112 //! Applies color and size (PointSize and LineWidth) of primitives in preselection mode
114 SetPreselectionProp(const double& theRed = 0,
115 const double& theGreen = 1,
116 const double& theBlue = 1,
117 const int& theWidth = 5);
119 //! Setup requested tolerance for the picking
121 SetSelectionTolerance(const double& theTolNodes = 0.025,
122 const double& theTolCell = 0.001);
124 //----------------------------------------------------------------------------
125 //! Adjust all intenal actors (trihedron and graduated rules) to the scene
129 //! Set size of the trihedron in percents from bounding box of the scene
131 SetTrihedronSize(int theSize, const bool theRelative = true);
133 //! Get size of the trihedron in percents from bounding box of the scene
135 GetTrihedronSize() const;
137 //! Shows if the size of the trihedron is relative
139 IsTrihedronRelative() const;
141 //----------------------------------------------------------------------------
142 //! Get trihedron control
146 //! Is trihedron displayed
148 IsTrihedronDisplayed();
150 //! Toggle trihedron visibility
154 //! Adjust size of the trihedron to the bounding box of the scene
158 //----------------------------------------------------------------------------
159 //! Get graduated rules control
160 SVTK_CubeAxesActor2D*
163 //! Is graduated rules displayed
165 IsCubeAxesDisplayed();
167 //! Toggle graduated rules visibility
171 //! Adjust size of the graduated rules to the bounding box of the scene
175 //----------------------------------------------------------------------------
176 //! Fit all presentation in the scene into the window
179 //! Set camera into predefined state
182 //! Reset camera clipping range to adjust the range to the bounding box of the scene
183 void OnResetClippingRange();
185 //! To reset direction of the camera to front view
188 //! To reset direction of the camera to back view
191 //! To reset direction of the camera to top view
194 //! To reset direction of the camera to bottom view
197 //! To reset direction of the camera to right view
200 //! To reset direction of the camera to left view
211 //----------------------------------------------------------------------------
212 // Priority at which events are processed
213 vtkFloatingPointType myPriority;
215 // Used to process events
216 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
219 // Main process event method
220 static void ProcessEvents(vtkObject* object,
225 vtkSmartPointer<vtkRenderer> myDevice;
226 vtkRenderWindowInteractor* myInteractor;
227 vtkSmartPointer<SVTK_Selector> mySelector;
229 //----------------------------------------------------------------------------
230 vtkSmartPointer<VTKViewer_Transform> myTransform;
232 //----------------------------------------------------------------------------
233 // Highlight/ Prehighlight devices
234 vtkSmartPointer<vtkPointPicker> myPointPicker;
235 vtkSmartPointer<vtkCellPicker> myCellPicker;
237 vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
238 vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
240 vtkSmartPointer<vtkProperty> myPreHighlightProperty;
241 vtkSmartPointer<vtkProperty> myHighlightProperty;
243 //----------------------------------------------------------------------------
244 vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
245 vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;
247 bool myIsTrihedronRelative;
248 vtkFloatingPointType myBndBox[6];