1 // Copyright (C) 2007-2008 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
22 // SALOME VTKViewer : build VTK viewer into Salome desktop
28 #ifndef SVTK_Renderer_h
29 #define SVTK_Renderer_h
32 #include "VTKViewer.h"
34 #include <vtkObject.h>
35 #include <vtkSmartPointer.h>
38 class vtkCallbackCommand;
39 class vtkRenderWindowInteractor;
46 class SVTK_RectPicker;
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);
88 //! Removes pointed actor from the renderer
91 RemoveActor(VTKViewer_Actor* theActor);
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(vtkFloatingPointType 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 //! Adjust size of the trihedron to the bounding box of the scene
161 //----------------------------------------------------------------------------
162 //! Get graduated rules control
163 SVTK_CubeAxesActor2D*
166 //! Is graduated rules displayed
168 IsCubeAxesDisplayed();
170 //! Toggle graduated rules visibility
174 //! Adjust size of the graduated rules to the bounding box of the scene
178 //----------------------------------------------------------------------------
179 //! Fit all presentation in the scene into the window
182 //! Set camera into predefined state
185 //! Reset camera clipping range to adjust the range to the bounding box of the scene
186 void OnResetClippingRange();
188 //! To reset direction of the camera to front view
191 //! To reset direction of the camera to back view
194 //! To reset direction of the camera to top view
197 //! To reset direction of the camera to bottom view
200 //! To reset direction of the camera to right view
203 //! To reset direction of the camera to left view
214 //----------------------------------------------------------------------------
215 // Priority at which events are processed
216 vtkFloatingPointType myPriority;
218 // Used to process events
219 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
222 // Main process event method
223 static void ProcessEvents(vtkObject* object,
228 vtkSmartPointer<vtkRenderer> myDevice;
229 vtkRenderWindowInteractor* myInteractor;
230 vtkSmartPointer<SVTK_Selector> mySelector;
232 //----------------------------------------------------------------------------
233 vtkSmartPointer<VTKViewer_Transform> myTransform;
235 //----------------------------------------------------------------------------
236 // Highlight/ Prehighlight devices
237 vtkSmartPointer<vtkPointPicker> myPointPicker;
238 vtkSmartPointer<vtkCellPicker> myCellPicker;
240 vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
241 vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
243 vtkSmartPointer<vtkProperty> myPreHighlightProperty;
244 vtkSmartPointer<vtkProperty> myHighlightProperty;
246 //----------------------------------------------------------------------------
247 vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
248 vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;
249 vtkFloatingPointType myTrihedronSize;
250 bool myIsTrihedronRelative;
251 vtkFloatingPointType myBndBox[6];
255 #pragma warning ( default:4251 )