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;
56 #pragma warning ( disable:4251 )
61 The class is a container for #vtkRenderer instance.
62 Main goal of the class is to apply common behaviour to all #SALOME_Actor, like
63 selection and preselection colors.
64 Also, the class is responsible for management of internal actors like trihedron an so on.
66 class SVTK_EXPORT SVTK_Renderer : public vtkObject
69 vtkTypeMacro(SVTK_Renderer,vtkObject);
70 static SVTK_Renderer* New();
72 //----------------------------------------------------------------------------
77 //! Initialize the class
80 Initialize(vtkRenderWindowInteractor* theInteractor,
81 SVTK_Selector* theSelector);
83 //----------------------------------------------------------------------------
84 //! Publishes pointed actor into the renderer
87 AddActor(VTKViewer_Actor* theActor);
89 //! Removes pointed actor from the renderer
92 RemoveActor(VTKViewer_Actor* theActor);
94 //! Get special container that keeps scaling of the scene
98 //! Allows to apply a scale on the whole scene
101 SetScale( double theScale[3] );
103 //! Allows to get a scale that is applied on the whole scene
105 GetScale( double theScale[3] );
107 //----------------------------------------------------------------------------
108 //! Applies color and size (PointSize and LineWidth) of primitives in selection mode
110 SetSelectionProp(const double& theRed = 1,
111 const double& theGreen = 1,
112 const double& theBlue = 0,
113 const int& theWidth = 5);
115 //! Applies color and size (PointSize and LineWidth) of primitives in preselection mode
117 SetPreselectionProp(const double& theRed = 0,
118 const double& theGreen = 1,
119 const double& theBlue = 1,
120 const int& theWidth = 5);
122 //! Setup requested tolerance for the picking
124 SetSelectionTolerance(const double& theTolNodes = 0.025,
125 const double& theTolCell = 0.001,
126 const double& theTolObjects = 0.025);
128 //----------------------------------------------------------------------------
129 //! Adjust all intenal actors (trihedron and graduated rules) to the scene
133 //! Set size of the trihedron in percents from bounding box of the scene
135 SetTrihedronSize(vtkFloatingPointType theSize, const bool theRelative = true);
137 //! Get size of the trihedron in percents from bounding box of the scene
139 GetTrihedronSize() const;
141 //! Shows if the size of the trihedron is relative
143 IsTrihedronRelative() const;
145 //----------------------------------------------------------------------------
146 //! Get trihedron control
150 //! Is trihedron displayed
152 IsTrihedronDisplayed();
154 //! Toggle trihedron visibility
158 //! Adjust size of the trihedron to the bounding box of the scene
162 //----------------------------------------------------------------------------
163 //! Get graduated rules control
164 SVTK_CubeAxesActor2D*
167 //! Is graduated rules displayed
169 IsCubeAxesDisplayed();
171 //! Toggle graduated rules visibility
175 //! Adjust size of the graduated rules to the bounding box of the scene
179 //----------------------------------------------------------------------------
180 //! Fit all presentation in the scene into the window
183 //! Set camera into predefined state
186 //! Reset camera clipping range to adjust the range to the bounding box of the scene
187 void OnResetClippingRange();
189 //! To reset direction of the camera to front view
192 //! To reset direction of the camera to back view
195 //! To reset direction of the camera to top view
198 //! To reset direction of the camera to bottom view
201 //! To reset direction of the camera to right view
204 //! To reset direction of the camera to left view
215 //----------------------------------------------------------------------------
216 // Priority at which events are processed
217 vtkFloatingPointType myPriority;
219 // Used to process events
220 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
223 // Main process event method
224 static void ProcessEvents(vtkObject* object,
229 vtkSmartPointer<vtkRenderer> myDevice;
230 vtkRenderWindowInteractor* myInteractor;
231 vtkSmartPointer<SVTK_Selector> mySelector;
233 //----------------------------------------------------------------------------
234 vtkSmartPointer<VTKViewer_Transform> myTransform;
236 //----------------------------------------------------------------------------
237 // Highlight/ Prehighlight devices
238 vtkSmartPointer<vtkPointPicker> myPointPicker;
239 vtkSmartPointer<vtkCellPicker> myCellPicker;
241 vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
242 vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
244 vtkSmartPointer<vtkProperty> myPreHighlightProperty;
245 vtkSmartPointer<vtkProperty> myHighlightProperty;
247 //----------------------------------------------------------------------------
248 vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
249 vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;
250 vtkFloatingPointType myTrihedronSize;
251 bool myIsTrihedronRelative;
252 vtkFloatingPointType myBndBox[6];
256 #pragma warning ( default:4251 )