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 OBJECT : implementation of interactive object visualization for OCC and VTK viewers
23 // File : SALOME_Actor.h
24 // Author : Nicolas REJNERI
28 #ifndef SALOME_ACTOR_H
29 #define SALOME_ACTOR_H
31 #include "SVTK_SelectionEvent.h"
32 #include "SVTK_Selector.h"
35 class Handle(SALOME_InteractiveObject);
37 // undefining min and max because CASCADE's defines them and
38 // it clashes with std::min(), std::max()
42 #include "VTKViewer_Actor.h"
44 #include <vtkSmartPointer.h>
48 class vtkOutlineSource;
49 class vtkInteractorStyle;
50 class vtkRenderWindowInteractor;
53 class SVTK_RectPicker;
54 class SVTK_InteractorStyle;
56 SVTK_EXPORT extern int SALOME_POINT_SIZE;
57 SVTK_EXPORT extern int SALOME_LINE_WIDTH;
60 #pragma warning ( disable:4251 )
63 //! The class is a basic one for all SALOME VTK presentation.
65 It provide highlight and prehighlight capabilites,
66 common way to publish and remove VTK presentation,
67 mapping of VTK and object IDs and so on.
69 class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
72 static SALOME_Actor* New();
74 vtkTypeMacro(SALOME_Actor,VTKViewer_Actor);
76 //----------------------------------------------------------------------------
77 //! To check, if the #SALOME_Actor has a reference to #SALOME_InteractiveObject
82 //! Get correspoinding reference to #SALOME_InteractiveObject
84 const Handle(SALOME_InteractiveObject)&
87 //! Set reference to #SALOME_InteractiveObject
90 setIO(const Handle(SALOME_InteractiveObject)& theIO);
92 //! Name the #SALOME_Actor
95 setName(const char* theName);
97 //----------------------------------------------------------------------------
98 //! Apply view transformation
101 SetTransform(VTKViewer_Transform* theTransform);
103 //! Apply additional position
106 SetPosition(vtkFloatingPointType _arg1,
107 vtkFloatingPointType _arg2,
108 vtkFloatingPointType _arg3);
110 //! Apply additional position
113 SetPosition(vtkFloatingPointType _arg[3]);
115 //----------------------------------------------------------------------------
116 //! Visibility management
119 SetVisibility( int );
121 //----------------------------------------------------------------------------
122 //! To publish the actor an all its internal devices
125 AddToRender(vtkRenderer* theRendere);
127 //! To remove the actor an all its internal devices
130 RemoveFromRender(vtkRenderer* theRendere);
132 //! Get reference on renderer where it is published
136 //----------------------------------------------------------------------------
137 //! To set interactor in order to use #vtkInteractorObserver devices
140 SetInteractor(vtkRenderWindowInteractor* theInteractor);
142 //! Put a request to redraw the view
147 //----------------------------------------------------------------------------
148 //! Set selector in order to the actor at any time can restore current selection
151 SetSelector(SVTK_Selector* theSelector);
153 //! Just to update visibility of the highlight devices
156 highlight(bool theHighlight);
158 //! To map current selection to VTK representation
161 Highlight(bool theHighlight);
163 //----------------------------------------------------------------------------
164 //! To process prehighlight (called from #SVTK_InteractorStyle)
167 PreHighlight(vtkInteractorStyle* theInteractorStyle,
168 SVTK_SelectionEvent* theSelectionEvent,
169 bool theIsHighlight);
171 //! To process highlight (called from #SVTK_InteractorStyle)
174 Highlight(vtkInteractorStyle* theInteractorStyle,
175 SVTK_SelectionEvent* theSelectionEvent,
176 bool theIsHighlight);
178 //----------------------------------------------------------------------------
179 //! To set up a picker for nodal selection (initialized by #SVTK_Renderer::AddActor)
181 SetPointPicker(vtkPointPicker* thePointPicker);
183 //! To set up a picker for cell selection (initialized by #SVTK_Renderer::AddActor)
185 SetCellPicker(vtkCellPicker* theCellPicker);
187 //! To set up a picker for point rectangle selection (initialized by #SVTK_Renderer::AddActor)
189 SetPointRectPicker(SVTK_RectPicker* theRectPicker);
191 //! To set up a picker for cell rectangle selection (initialized by #SVTK_Renderer::AddActor)
193 SetCellRectPicker(SVTK_RectPicker* theRectPicker);
195 //----------------------------------------------------------------------------
196 //! To set up a prehighlight property (initialized by #SVTK_Renderer::AddActor)
198 SetPreHighlightProperty(vtkProperty* theProperty);
200 //! To set up a highlight property (initialized by #SVTK_Renderer::AddActor)
202 SetHighlightProperty(vtkProperty* theProperty);
205 //----------------------------------------------------------------------------
206 vtkRenderWindowInteractor* myInteractor;
207 vtkRenderer* myRenderer;
209 Handle(SALOME_InteractiveObject) myIO;
215 Selection_Mode mySelectionMode;
216 vtkSmartPointer<SVTK_Selector> mySelector;
218 //----------------------------------------------------------------------------
219 // Highlight/ Prehighlight devices
220 vtkSmartPointer<vtkPointPicker> myPointPicker;
221 vtkSmartPointer<vtkCellPicker> myCellPicker;
223 vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
224 vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
226 vtkSmartPointer<SVTK_Actor> myPreHighlightActor;
227 vtkSmartPointer<SVTK_Actor> myHighlightActor;
229 vtkSmartPointer<VTKViewer_Actor> myOutlineActor;
230 vtkSmartPointer<vtkOutlineSource> myOutline;
234 #pragma warning ( default:4251 )
237 #endif // SALOME_ACTOR_H