1 // Copyright (C) 2007-2024 CEA, EDF, 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"
32 #include "SALOME_ListIO.hxx"
34 #include <vtkObject.h>
35 #include <vtkSmartPointer.h>
38 class vtkCallbackCommand;
39 class vtkRenderWindowInteractor;
46 class SVTK_AreaPicker;
48 class VTKViewer_Trihedron;
49 class VTKViewer_Transform;
50 class SVTK_CubeAxesActor2D;
51 class VTKViewer_Actor;
55 #pragma warning ( disable:4251 )
60 The class is a container for #vtkRenderer instance.
61 Main goal of the class is to apply common behaviour to all #SALOME_Actor, like
62 selection and preselection colors.
63 Also, the class is responsible for management of internal actors like trihedron an so on.
65 class SVTK_EXPORT SVTK_Renderer : public vtkObject
68 vtkTypeMacro(SVTK_Renderer,vtkObject)
69 static SVTK_Renderer* New();
71 //----------------------------------------------------------------------------
76 //! Initialize the class
79 Initialize(vtkRenderWindowInteractor* theInteractor,
80 SVTK_Selector* theSelector);
82 //----------------------------------------------------------------------------
83 //! Publishes pointed actor into the renderer
86 AddActor(VTKViewer_Actor* theActor, bool theIsAdjustActors = true);
88 //! Removes pointed actor from the renderer
91 RemoveActor(VTKViewer_Actor* theActor, bool theIsAdjustActors = true);
93 //! Get special container that keeps scaling of the scene
97 //! Allows to apply a scale on the whole scene
100 SetScale( double theScale[3] );
102 //! Allows to get a scale that is applied on the whole scene
104 GetScale( double theScale[3] );
106 //----------------------------------------------------------------------------
107 //! Applies color and size (PointSize and LineWidth) of primitives in selection mode
109 SetSelectionProp(const double& theRed = 1,
110 const double& theGreen = 1,
111 const double& theBlue = 0,
112 const int& theWidth = 5);
114 //! Applies color and size (PointSize and LineWidth) of primitives in preselection mode
116 SetPreselectionProp(const double& theRed = 0,
117 const double& theGreen = 1,
118 const double& theBlue = 1,
119 const int& theWidth = 5);
121 //! Setup requested tolerance for the picking
123 SetSelectionTolerance(const double& theTolNodes = 0.025,
124 const double& theTolCell = 0.001,
125 const double& theTolObjects = 0.025);
127 //----------------------------------------------------------------------------
128 //! Adjust all intenal actors (trihedron and graduated rules) to the scene
132 //! Set size of the trihedron in percents from bounding box of the scene
134 SetTrihedronSize(double theSize, const bool theRelative = true);
136 //! Get size of the trihedron in percents from bounding box of the scene
138 GetTrihedronSize() const;
140 //! Shows if the size of the trihedron is relative
142 IsTrihedronRelative() const;
144 //----------------------------------------------------------------------------
145 //! Get trihedron control
149 //! Is trihedron displayed
151 IsTrihedronDisplayed();
153 //! Toggle trihedron visibility
157 //! Set Toggle trihedron visibility
160 SetTrihedronVisibility( const bool );
162 //! Adjust size of the trihedron to the bounding box of the scene
166 //----------------------------------------------------------------------------
167 //! Get graduated rules control
168 SVTK_CubeAxesActor2D*
171 //! Is graduated rules displayed
173 IsCubeAxesDisplayed();
175 //! Toggle graduated rules visibility
179 //! Adjust size of the graduated rules to the bounding box of the scene
183 //----------------------------------------------------------------------------
184 //! Fit all presentation in the scene into the window
187 //----------------------------------------------------------------------------
188 //! Fit all selected presentation in the scene
189 void onFitSelection();
191 //! Fit given presentations in the scene
192 void OnFitIObjects(const SALOME_ListIO& objects);
194 //! Set camera into predefined state
197 //! Reset camera clipping range to adjust the range to the bounding box of the scene
198 void OnResetClippingRange();
200 //! To reset direction of the camera to front view
203 //! To reset direction of the camera to back view
206 //! To reset direction of the camera to top view
209 //! To reset direction of the camera to bottom view
212 //! To reset direction of the camera to right view
215 //! To reset direction of the camera to left view
218 //! To rotate view 90 degrees clockwise
219 void onClockWiseView();
221 //! To rotate view 90 degrees counterclockwise
222 void onAntiClockWiseView();
232 //----------------------------------------------------------------------------
233 // Priority at which events are processed
236 // Used to process events
237 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
240 // Main process event method
241 static void ProcessEvents(vtkObject* object,
246 vtkSmartPointer<vtkRenderer> myDevice;
247 vtkRenderWindowInteractor* myInteractor;
248 vtkSmartPointer<SVTK_Selector> mySelector;
250 //----------------------------------------------------------------------------
251 vtkSmartPointer<VTKViewer_Transform> myTransform;
253 //----------------------------------------------------------------------------
254 // Highlight/ Prehighlight devices
255 vtkSmartPointer<vtkPointPicker> myPointPicker;
256 vtkSmartPointer<vtkCellPicker> myCellPicker;
258 vtkSmartPointer<SVTK_AreaPicker> myPointAreaPicker;
259 vtkSmartPointer<SVTK_AreaPicker> myCellAreaPicker;
261 vtkSmartPointer<vtkProperty> myPreHighlightProperty;
262 vtkSmartPointer<vtkProperty> myHighlightProperty;
264 //----------------------------------------------------------------------------
265 vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
266 vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;
267 double myTrihedronSize;
268 bool myIsTrihedronRelative;
273 #pragma warning ( default:4251 )