1 // SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
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
24 // File : SALOME_Actor.h
25 // Author : Nicolas REJNERI
29 #ifndef SALOME_ACTOR_H
30 #define SALOME_ACTOR_H
32 #include "SVTK_SelectionEvent.h"
33 #include "SVTK_Selector.h"
36 #include "SALOME_InteractiveObject.hxx"
38 // undefining min and max because CASCADE's defines them and
39 // it clashes with std::min(), std::max()
43 #include "VTKViewer_Actor.h"
45 #include <vtkSmartPointer.h>
49 class vtkOutlineSource;
50 class vtkInteractorStyle;
51 class vtkRenderWindowInteractor;
54 class SVTK_RectPicker;
55 class SVTK_InteractorStyle;
57 extern int SALOME_POINT_SIZE;
58 extern int SALOME_LINE_WIDTH;
60 //! The class is a basic one for all SALOME VTK presentation.
62 It provide highlight and prehighlight capabilites,
63 common way to publish and remove VTK presentation,
64 mapping of VTK and object IDs and so on.
66 class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
69 static SALOME_Actor* New();
71 vtkTypeMacro(SALOME_Actor,VTKViewer_Actor);
73 //----------------------------------------------------------------------------
74 //! To check, if the #SALOME_Actor has a reference to #SALOME_InteractiveObject
79 //! Get correspoinding reference to #SALOME_InteractiveObject
81 const Handle(SALOME_InteractiveObject)&
84 //! Set reference to #SALOME_InteractiveObject
87 setIO(const Handle(SALOME_InteractiveObject)& theIO);
89 //! Name the #SALOME_Actor
92 setName(const char* theName);
94 //----------------------------------------------------------------------------
95 //! Apply view transformation
98 SetTransform(VTKViewer_Transform* theTransform);
100 //! Apply additional position
103 SetPosition(vtkFloatingPointType _arg1,
104 vtkFloatingPointType _arg2,
105 vtkFloatingPointType _arg3);
107 //! Apply additional position
110 SetPosition(vtkFloatingPointType _arg[3]);
112 //----------------------------------------------------------------------------
113 //! Visibility management
116 SetVisibility( int );
118 //----------------------------------------------------------------------------
119 //! To publish the actor an all its internal devices
122 AddToRender(vtkRenderer* theRendere);
124 //! To remove the actor an all its internal devices
127 RemoveFromRender(vtkRenderer* theRendere);
129 //! Get reference on renderer where it is published
133 //----------------------------------------------------------------------------
134 //! To set interactor in order to use #vtkInteractorObserver devices
137 SetInteractor(vtkRenderWindowInteractor* theInteractor);
139 //! Put a request to redraw the view
144 //----------------------------------------------------------------------------
145 //! Set selector in order to the actor at any time can restore current selection
148 SetSelector(SVTK_Selector* theSelector);
150 //! Just to update visibility of the highlight devices
153 highlight(bool theHighlight);
155 //! To map current selection to VTK representation
158 Highlight(bool theHighlight);
160 //----------------------------------------------------------------------------
161 //! To process prehighlight (called from #SVTK_InteractorStyle)
164 PreHighlight(vtkInteractorStyle* theInteractorStyle,
165 SVTK_SelectionEvent* theSelectionEvent,
166 bool theIsHighlight);
168 //! To process highlight (called from #SVTK_InteractorStyle)
171 Highlight(vtkInteractorStyle* theInteractorStyle,
172 SVTK_SelectionEvent* theSelectionEvent,
173 bool theIsHighlight);
175 //----------------------------------------------------------------------------
176 //! To set up a picker for nodal selection (initialized by #SVTK_Renderer::AddActor)
178 SetPointPicker(vtkPointPicker* thePointPicker);
180 //! To set up a picker for cell selection (initialized by #SVTK_Renderer::AddActor)
182 SetCellPicker(vtkCellPicker* theCellPicker);
184 //! To set up a picker for point rectangle selection (initialized by #SVTK_Renderer::AddActor)
186 SetPointRectPicker(SVTK_RectPicker* theRectPicker);
188 //! To set up a picker for cell rectangle selection (initialized by #SVTK_Renderer::AddActor)
190 SetCellRectPicker(SVTK_RectPicker* theRectPicker);
192 //----------------------------------------------------------------------------
193 //! To set up a prehighlight property (initialized by #SVTK_Renderer::AddActor)
195 SetPreHighlightProperty(vtkProperty* theProperty);
197 //! To set up a highlight property (initialized by #SVTK_Renderer::AddActor)
199 SetHighlightProperty(vtkProperty* theProperty);
202 //----------------------------------------------------------------------------
203 vtkRenderWindowInteractor* myInteractor;
204 vtkRenderer* myRenderer;
206 Handle(SALOME_InteractiveObject) myIO;
212 Selection_Mode mySelectionMode;
213 vtkSmartPointer<SVTK_Selector> mySelector;
215 //----------------------------------------------------------------------------
216 // Highlight/ Prehighlight devices
217 vtkSmartPointer<vtkPointPicker> myPointPicker;
218 vtkSmartPointer<vtkCellPicker> myCellPicker;
220 vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
221 vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
223 vtkSmartPointer<SVTK_Actor> myPreHighlightActor;
224 vtkSmartPointer<SVTK_Actor> myHighlightActor;
226 vtkSmartPointer<VTKViewer_Actor> myOutlineActor;
227 vtkSmartPointer<vtkOutlineSource> myOutline;
230 #endif // SALOME_ACTOR_H