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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
29 #ifndef SVTK_Renderer_h
30 #define SVTK_Renderer_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 //! The class is a container for #vtkRenderer instance.
57 Main goal of the class is to apply common behaviour to all #SALOME_Actor, like
58 selection and preselection colors.
59 Also, the class is responsible for management of internal actors like trihedron an so on.
61 //============================================================================
62 class SVTK_EXPORT SVTK_Renderer : public vtkObject
65 vtkTypeMacro(SVTK_Renderer,vtkObject);
66 static SVTK_Renderer* New();
68 //----------------------------------------------------------------------------
73 //! Initialize the class
76 Initialize(vtkRenderWindowInteractor* theInteractor,
77 SVTK_Selector* theSelector);
79 //----------------------------------------------------------------------------
80 //! This method publishes pointed actor into the renderer
83 AddActor(VTKViewer_Actor* theActor);
85 //! This method removes pointed actor from the renderer
88 RemoveActor(VTKViewer_Actor* theActor);
90 //! Get special container that keeps scaling of the scene
94 //! This method allow to apply a scale on the whole scene
97 SetScale( double theScale[3] );
99 //! This method allow to get a scale that is applied on the whole scene
101 GetScale( double theScale[3] );
103 //----------------------------------------------------------------------------
104 //! Applies color and size (PointSize and LineWidth) of primitives in selection mode
106 SetSelectionProp(const double& theRed = 1,
107 const double& theGreen = 1,
108 const double& theBlue = 0,
109 const int& theWidth = 5);
111 //! Applies color and size (PointSize and LineWidth) of primitives in preselection mode
113 SetPreselectionProp(const double& theRed = 0,
114 const double& theGreen = 1,
115 const double& theBlue = 1,
116 const int& theWidth = 5);
118 //! Setup requested tollerance for the picking
120 SetSelectionTolerance(const double& theTolNodes = 0.025,
121 const double& theTolCell = 0.001);
123 //----------------------------------------------------------------------------
124 //! Adjust all intenal actors (trihedron and graduated rules) to the scene
128 //! Set size of the trihedron in percents from bounding box of the scene
130 SetTrihedronSize(int theSize, const bool theRelative = true);
132 //! Get size of the trihedron in percents from bounding box of the scene
134 GetTrihedronSize() const;
136 //! Shows if the size of the trihedron is relative
138 IsTrihedronRelative() const;
140 //----------------------------------------------------------------------------
141 //! Get trihedron control
145 //! Is trihedron displayed
147 IsTrihedronDisplayed();
149 //! Toggle trihedron visibility
153 //! Adjust size of the trihedron to the bounding box of the scene
157 //----------------------------------------------------------------------------
158 //! Get graduated rules control
159 SVTK_CubeAxesActor2D*
162 //! Is graduated rules displayed
164 IsCubeAxesDisplayed();
166 //! Toggle graduated rules visibility
170 //! Adjust size of the graduated rules to the bounding box of the scene
174 //----------------------------------------------------------------------------
175 //! Fit all presentation in the scene into the window
178 //! Set camera into predefined state
181 //! Reset camera clipping range to adjust the range to the bounding box of the scene
182 void OnResetClippingRange();
184 //! To reset direction of the camera to front view
187 //! To reset direction of the camera to back view
190 //! To reset direction of the camera to top view
193 //! To reset direction of the camera to bottom view
196 //! To reset direction of the camera to right view
199 //! To reset direction of the camera to left view
210 //----------------------------------------------------------------------------
211 // Priority at which events are processed
214 // Used to process events
215 vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
218 // Main process event method
219 static void ProcessEvents(vtkObject* object,
224 vtkSmartPointer<vtkRenderer> myDevice;
225 vtkRenderWindowInteractor* myInteractor;
226 vtkSmartPointer<SVTK_Selector> mySelector;
228 //----------------------------------------------------------------------------
229 vtkSmartPointer<VTKViewer_Transform> myTransform;
231 //----------------------------------------------------------------------------
232 // Highlight/ Prehighlight devices
233 vtkSmartPointer<vtkPointPicker> myPointPicker;
234 vtkSmartPointer<vtkCellPicker> myCellPicker;
236 vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
237 vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
239 vtkSmartPointer<vtkProperty> myPreHighlightProperty;
240 vtkSmartPointer<vtkProperty> myHighlightProperty;
242 //----------------------------------------------------------------------------
243 vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
244 vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;
246 bool myIsTrihedronRelative;