1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
23 // SALOME VTKViewer : build VTK viewer into Salome desktop
27 #ifndef SVTK_Renderer_h
28 #define SVTK_Renderer_h
31 #include "VTKViewer.h"
33 #include <vtkObject.h>
34 #include <vtkSmartPointer.h>
37 class vtkCallbackCommand;
38 class vtkRenderWindowInteractor;
45 class SVTK_RectPicker;
47 class VTKViewer_Trihedron;
48 class VTKViewer_Transform;
49 class SVTK_CubeAxesActor2D;
50 class VTKViewer_Actor;
54 #pragma warning ( disable:4251 )
59 The class is a container for #vtkRenderer instance.
60 Main goal of the class is to apply common behaviour to all #SALOME_Actor, like
61 selection and preselection colors.
62 Also, the class is responsible for management of internal actors like trihedron an so on.
64 class SVTK_EXPORT SVTK_Renderer : public vtkObject
67 vtkTypeMacro(SVTK_Renderer,vtkObject);
68 static SVTK_Renderer* New();
70 //----------------------------------------------------------------------------
75 //! Initialize the class
78 Initialize(vtkRenderWindowInteractor* theInteractor,
79 SVTK_Selector* theSelector);
81 //----------------------------------------------------------------------------
82 //! Publishes pointed actor into the renderer
85 AddActor(VTKViewer_Actor* theActor, bool theIsAdjustActors = true);
87 //! Removes pointed actor from the renderer
90 RemoveActor(VTKViewer_Actor* theActor, bool theIsAdjustActors = true);
92 //! Get special container that keeps scaling of the scene
96 //! Allows to apply a scale on the whole scene
99 SetScale( double theScale[3] );
101 //! Allows to get a scale that is applied on the whole scene
103 GetScale( double theScale[3] );
105 //----------------------------------------------------------------------------
106 //! Applies color and size (PointSize and LineWidth) of primitives in selection mode
108 SetSelectionProp(const double& theRed = 1,
109 const double& theGreen = 1,
110 const double& theBlue = 0,
111 const int& theWidth = 5);
113 //! Applies color and size (PointSize and LineWidth) of primitives in preselection mode
115 SetPreselectionProp(const double& theRed = 0,
116 const double& theGreen = 1,
117 const double& theBlue = 1,
118 const int& theWidth = 5);
120 //! Setup requested tolerance for the picking
122 SetSelectionTolerance(const double& theTolNodes = 0.025,
123 const double& theTolCell = 0.001,
124 const double& theTolObjects = 0.025);
126 //----------------------------------------------------------------------------
127 //! Adjust all intenal actors (trihedron and graduated rules) to the scene
131 //! Set size of the trihedron in percents from bounding box of the scene
133 SetTrihedronSize(double theSize, const bool theRelative = true);
135 //! Get size of the trihedron in percents from bounding box of the scene
137 GetTrihedronSize() const;
139 //! Shows if the size of the trihedron is relative
141 IsTrihedronRelative() const;
143 //----------------------------------------------------------------------------
144 //! Get trihedron control
148 //! Is trihedron displayed
150 IsTrihedronDisplayed();
152 //! Toggle trihedron visibility
156 //! Adjust size of the trihedron to the bounding box of the scene
160 //----------------------------------------------------------------------------
161 //! Get graduated rules control
162 SVTK_CubeAxesActor2D*
165 //! Is graduated rules displayed
167 IsCubeAxesDisplayed();
169 //! Toggle graduated rules visibility
173 //! Adjust size of the graduated rules to the bounding box of the scene
177 //----------------------------------------------------------------------------
178 //! Fit all presentation in the scene into the window
181 //! Set camera into predefined state
184 //! Reset camera clipping range to adjust the range to the bounding box of the scene
185 void OnResetClippingRange();
187 //! To reset direction of the camera to front view
190 //! To reset direction of the camera to back view
193 //! To reset direction of the camera to top view
196 //! To reset direction of the camera to bottom view
199 //! To reset direction of the camera to right view
202 //! To reset direction of the camera to left view
205 //! To rotate view 90 degrees clockwise
206 void onClockWiseView();
208 //! To rotate view 90 degrees counterclockwise
209 void onAntiClockWiseView();
219 //----------------------------------------------------------------------------
220 // Priority at which events are processed
223 // Used to process events
224 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
227 // Main process event method
228 static void ProcessEvents(vtkObject* object,
233 vtkSmartPointer<vtkRenderer> myDevice;
234 vtkRenderWindowInteractor* myInteractor;
235 vtkSmartPointer<SVTK_Selector> mySelector;
237 //----------------------------------------------------------------------------
238 vtkSmartPointer<VTKViewer_Transform> myTransform;
240 //----------------------------------------------------------------------------
241 // Highlight/ Prehighlight devices
242 vtkSmartPointer<vtkPointPicker> myPointPicker;
243 vtkSmartPointer<vtkCellPicker> myCellPicker;
245 vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
246 vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
248 vtkSmartPointer<vtkProperty> myPreHighlightProperty;
249 vtkSmartPointer<vtkProperty> myHighlightProperty;
251 //----------------------------------------------------------------------------
252 vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
253 vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;
254 double myTrihedronSize;
255 bool myIsTrihedronRelative;
260 #pragma warning ( default:4251 )