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(float _arg1, float _arg2, float _arg3);
105 //! Apply additional position
108 SetPosition(float _arg[3]);
110 //----------------------------------------------------------------------------
111 //! Visibility management
114 SetVisibility( int );
116 //----------------------------------------------------------------------------
117 //! To publish the actor an all its internal devices
120 AddToRender(vtkRenderer* theRendere);
122 //! To remove the actor an all its internal devices
125 RemoveFromRender(vtkRenderer* theRendere);
127 //! Get reference on renderer where it is published
131 //----------------------------------------------------------------------------
132 //! To set interactor in order to use #vtkInteractorObserver devices
135 SetInteractor(vtkRenderWindowInteractor* theInteractor);
137 //! Put a request to redraw the view
142 //----------------------------------------------------------------------------
143 //! Set selector in order to the actor at any time can restore current selection
146 SetSelector(SVTK_Selector* theSelector);
148 //! Just to update visibility of the highlight devices
151 highlight(bool theHighlight);
153 //! To map current selection to VTK representation
156 Highlight(bool theHighlight);
158 //----------------------------------------------------------------------------
159 //! To process prehighlight (called from #SVTK_InteractorStyle)
162 PreHighlight(vtkInteractorStyle* theInteractorStyle,
163 SVTK_SelectionEvent* theSelectionEvent,
164 bool theIsHighlight);
166 //! To process highlight (called from #SVTK_InteractorStyle)
169 Highlight(vtkInteractorStyle* theInteractorStyle,
170 SVTK_SelectionEvent* theSelectionEvent,
171 bool theIsHighlight);
173 //----------------------------------------------------------------------------
174 //! To set up a picker for nodal selection (initialized by #SVTK_Renderer::AddActor)
176 SetPointPicker(vtkPointPicker* thePointPicker);
178 //! To set up a picker for cell selection (initialized by #SVTK_Renderer::AddActor)
180 SetCellPicker(vtkCellPicker* theCellPicker);
182 //! To set up a picker for point rectangle selection (initialized by #SVTK_Renderer::AddActor)
184 SetPointRectPicker(SVTK_RectPicker* theRectPicker);
186 //! To set up a picker for cell rectangle selection (initialized by #SVTK_Renderer::AddActor)
188 SetCellRectPicker(SVTK_RectPicker* theRectPicker);
190 //----------------------------------------------------------------------------
191 //! To set up a prehighlight property (initialized by #SVTK_Renderer::AddActor)
193 SetPreHighlightProperty(vtkProperty* theProperty);
195 //! To set up a highlight property (initialized by #SVTK_Renderer::AddActor)
197 SetHighlightProperty(vtkProperty* theProperty);
200 //----------------------------------------------------------------------------
201 vtkRenderWindowInteractor* myInteractor;
202 vtkRenderer* myRenderer;
204 Handle(SALOME_InteractiveObject) myIO;
210 Selection_Mode mySelectionMode;
211 vtkSmartPointer<SVTK_Selector> mySelector;
213 //----------------------------------------------------------------------------
214 // Highlight/ Prehighlight devices
215 vtkSmartPointer<vtkPointPicker> myPointPicker;
216 vtkSmartPointer<vtkCellPicker> myCellPicker;
218 vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
219 vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
221 vtkSmartPointer<SVTK_Actor> myPreHighlightActor;
222 vtkSmartPointer<SVTK_Actor> myHighlightActor;
224 vtkSmartPointer<VTKViewer_Actor> myOutlineActor;
225 vtkSmartPointer<vtkOutlineSource> myOutline;
228 #endif // SALOME_ACTOR_H