1 // Copyright (C) 2007-2012 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
23 // SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
24 // File : SALOME_Actor.h
25 // Author : Nicolas REJNERI
27 #ifndef SALOME_ACTOR_H
28 #define SALOME_ACTOR_H
30 #include "SVTK_SelectionEvent.h"
31 #include "SVTK_Selector.h"
34 class Handle(SALOME_InteractiveObject);
36 // undefining min and max because CASCADE's defines them and
37 // it clashes with std::min(), std::max()
41 #include <VTKViewer_Actor.h>
42 #include <VTKViewer_MarkerDef.h>
44 #include <vtkSmartPointer.h>
46 class vtkAbstractPicker;
49 class vtkOutlineSource;
50 class vtkInteractorStyle;
51 class vtkRenderWindowInteractor;
53 class VTKViewer_FramedTextActor;
56 class SVTK_RectPicker;
57 class SVTK_InteractorStyle;
59 SVTK_EXPORT extern int SALOME_POINT_SIZE;
60 SVTK_EXPORT extern int SALOME_LINE_WIDTH;
63 #pragma warning ( disable:4251 )
66 //! The class is a basic one for all SALOME VTK presentation.
68 It provide highlight and prehighlight capabilites,
69 common way to publish and remove VTK presentation,
70 mapping of VTK and object IDs and so on.
72 class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
75 static SALOME_Actor* New();
77 vtkTypeMacro(SALOME_Actor,VTKViewer_Actor);
79 //----------------------------------------------------------------------------
80 //! To check, if the #SALOME_Actor has a reference to #SALOME_InteractiveObject
85 //! Get correspoinding reference to #SALOME_InteractiveObject
87 const Handle(SALOME_InteractiveObject)&
90 //! Set reference to #SALOME_InteractiveObject
93 setIO(const Handle(SALOME_InteractiveObject)& theIO);
95 //! Name the #SALOME_Actor
98 setName(const char* theName);
100 //----------------------------------------------------------------------------
101 //! Apply view transformation
104 SetTransform(VTKViewer_Transform* theTransform);
106 //! Apply additional position
109 SetPosition(vtkFloatingPointType _arg1,
110 vtkFloatingPointType _arg2,
111 vtkFloatingPointType _arg3);
113 //! Apply additional position
116 SetPosition(vtkFloatingPointType _arg[3]);
118 //----------------------------------------------------------------------------
119 //! Visibility management
122 SetVisibility( int );
124 //! Gets know whether the actor should be displayed or not
129 //----------------------------------------------------------------------------
130 //! To publish the actor an all its internal devices
133 AddToRender(vtkRenderer* theRendere);
135 //! To remove the actor an all its internal devices
138 RemoveFromRender(vtkRenderer* theRendere);
140 //! Get reference on renderer where it is published
144 //----------------------------------------------------------------------------
145 //! To set interactor in order to use #vtkInteractorObserver devices
148 SetInteractor(vtkRenderWindowInteractor* theInteractor);
150 //! Put a request to redraw the view
155 //----------------------------------------------------------------------------
156 //! Set selector in order to the actor at any time can restore current selection
159 SetSelector(SVTK_Selector* theSelector);
161 //! Just to update visibility of the highlight devices
164 highlight(bool theHighlight);
166 //! To map current selection to VTK representation
169 Highlight(bool theHighlight);
171 //----------------------------------------------------------------------------
172 //! To process prehighlight (called from #SVTK_InteractorStyle)
175 PreHighlight(vtkInteractorStyle* theInteractorStyle,
176 SVTK_SelectionEvent* theSelectionEvent,
177 bool theIsHighlight);
179 //! To process highlight (called from #SVTK_InteractorStyle)
182 Highlight(vtkInteractorStyle* theInteractorStyle,
183 SVTK_SelectionEvent* theSelectionEvent,
184 bool theIsHighlight);
186 //----------------------------------------------------------------------------
187 //! To get flag of displaying of name actor
190 IsDisplayNameActor() const;
192 //! To set flag of displaying of name actor
195 SetIsDisplayNameActor(bool theIsDisplayNameActor);
197 //! To set text of name actor
200 SetNameActorText(const char* theText);
202 //! To set offset of name actor
205 SetNameActorOffset(int theOffset[2]);
207 //! To get size of name actor
210 GetNameActorSize(vtkRenderer* theRenderer, int theSize[2]) const;
212 //! To update visibility of name actors
217 //----------------------------------------------------------------------------
218 //! Set standard point marker
221 SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
223 //! Set custom point marker
226 SetMarkerTexture( int, VTK::MarkerTexture );
228 //! Get type of the point marker
233 //! Get scale of the point marker
238 //! Get texture identifier of the point marker
243 //----------------------------------------------------------------------------
244 //! To set up a picker for nodal selection (initialized by #SVTK_Renderer::AddActor)
246 SetPointPicker(vtkPointPicker* thePointPicker);
248 //! To set up a picker for cell selection (initialized by #SVTK_Renderer::AddActor)
250 SetCellPicker(vtkCellPicker* theCellPicker);
252 //! To set up a picker for point rectangle selection (initialized by #SVTK_Renderer::AddActor)
254 SetPointRectPicker(SVTK_RectPicker* theRectPicker);
256 //! To set up a picker for cell rectangle selection (initialized by #SVTK_Renderer::AddActor)
258 SetCellRectPicker(SVTK_RectPicker* theRectPicker);
260 //----------------------------------------------------------------------------
261 //! To set up a prehighlight property (initialized by #SVTK_Renderer::AddActor)
263 SetPreHighlightProperty(vtkProperty* theProperty);
265 //! To set up a highlight property (initialized by #SVTK_Renderer::AddActor)
267 SetHighlightProperty(vtkProperty* theProperty);
270 //----------------------------------------------------------------------------
271 vtkRenderWindowInteractor* myInteractor;
272 vtkRenderer* myRenderer;
274 Handle(SALOME_InteractiveObject) myIO;
280 Selection_Mode mySelectionMode;
281 vtkSmartPointer<SVTK_Selector> mySelector;
283 //----------------------------------------------------------------------------
284 // Highlight/ Prehighlight devices
285 vtkSmartPointer<vtkPointPicker> myPointPicker;
286 vtkSmartPointer<vtkCellPicker> myCellPicker;
288 vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
289 vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
291 vtkSmartPointer<SVTK_Actor> myPreHighlightActor;
292 vtkSmartPointer<SVTK_Actor> myHighlightActor;
294 vtkSmartPointer<VTKViewer_Actor> myOutlineActor;
295 vtkSmartPointer<vtkOutlineSource> myOutline;
297 bool myIsDisplayNameActor;
298 vtkSmartPointer<VTKViewer_FramedTextActor> myNameActor;
303 class SVTK_EXPORT TPickLimiter
305 vtkAbstractPicker* myPicker;
307 TPickLimiter(vtkAbstractPicker*, SALOME_Actor*);
313 #pragma warning ( default:4251 )
316 #endif // SALOME_ACTOR_H