1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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_AreaPicker;
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 //! Set Toggle trihedron visibility
159 SetTrihedronVisibility( const bool );
161 //! Adjust size of the trihedron to the bounding box of the scene
165 //----------------------------------------------------------------------------
166 //! Get graduated rules control
167 SVTK_CubeAxesActor2D*
170 //! Is graduated rules displayed
172 IsCubeAxesDisplayed();
174 //! Toggle graduated rules visibility
178 //! Adjust size of the graduated rules to the bounding box of the scene
182 //----------------------------------------------------------------------------
183 //! Fit all presentation in the scene into the window
186 //! Set camera into predefined state
189 //! Reset camera clipping range to adjust the range to the bounding box of the scene
190 void OnResetClippingRange();
192 //! To reset direction of the camera to front view
195 //! To reset direction of the camera to back view
198 //! To reset direction of the camera to top view
201 //! To reset direction of the camera to bottom view
204 //! To reset direction of the camera to right view
207 //! To reset direction of the camera to left view
210 //! To rotate view 90 degrees clockwise
211 void onClockWiseView();
213 //! To rotate view 90 degrees counterclockwise
214 void onAntiClockWiseView();
224 //----------------------------------------------------------------------------
225 // Priority at which events are processed
228 // Used to process events
229 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
232 // Main process event method
233 static void ProcessEvents(vtkObject* object,
238 vtkSmartPointer<vtkRenderer> myDevice;
239 vtkRenderWindowInteractor* myInteractor;
240 vtkSmartPointer<SVTK_Selector> mySelector;
242 //----------------------------------------------------------------------------
243 vtkSmartPointer<VTKViewer_Transform> myTransform;
245 //----------------------------------------------------------------------------
246 // Highlight/ Prehighlight devices
247 vtkSmartPointer<vtkPointPicker> myPointPicker;
248 vtkSmartPointer<vtkCellPicker> myCellPicker;
250 vtkSmartPointer<SVTK_AreaPicker> myPointAreaPicker;
251 vtkSmartPointer<SVTK_AreaPicker> myCellAreaPicker;
253 vtkSmartPointer<vtkProperty> myPreHighlightProperty;
254 vtkSmartPointer<vtkProperty> myHighlightProperty;
256 //----------------------------------------------------------------------------
257 vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
258 vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;
259 double myTrihedronSize;
260 bool myIsTrihedronRelative;
265 #pragma warning ( default:4251 )