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 VTKVIEVER_ACTOR_H
29 #define VTKVIEVER_ACTOR_H
31 #include "VTKViewer.h"
36 #include <vtkLODActor.h>
45 class vtkPassThroughFilter;
47 class VTKViewer_Transform;
48 class VTKViewer_GeometryFilter;
49 class VTKViewer_TransformFilter;
51 extern int VTKViewer_POINT_SIZE;
52 extern int VTKViewer_LINE_WIDTH;
55 #pragma warning ( disable:4251 )
58 /*! \class vtkLODActor
59 * \brief For more information see <a href="http://www.vtk.org/">VTK documentation</a>
61 class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor
64 static VTKViewer_Actor* New();
66 vtkTypeMacro(VTKViewer_Actor,vtkLODActor);
68 //----------------------------------------------------------------------------
74 //! Name the #VTKViewer_Actor
77 setName(const char* theName);
79 //----------------------------------------------------------------------------
83 SetOpacity(vtkFloatingPointType theOpacity);
85 //! Get current opacity
93 SetColor(vtkFloatingPointType r,
94 vtkFloatingPointType g,
95 vtkFloatingPointType b);
100 GetColor(vtkFloatingPointType& r,
101 vtkFloatingPointType& g,
102 vtkFloatingPointType& b);
107 SetColor(const vtkFloatingPointType theRGB[3]);
109 //----------------------------------------------------------------------------
110 // For selection mapping purpose
111 //! Maps VTK index of a node to corresponding object index
114 GetNodeObjId(int theVtkID);
116 //! Get coordinates of a node for given object index
118 vtkFloatingPointType*
119 GetNodeCoord(int theObjID);
121 //! Maps VTK index of a cell to corresponding object index
124 GetElemObjId(int theVtkID);
126 //! Get corresponding #vtkCell for given object index
129 GetElemCell(int theObjID);
131 //----------------------------------------------------------------------------
132 //! Get dimension of corresponding mesh element
135 GetObjDimension( const int theObjId );
137 //! To insert some additional filters and then sets the given #vtkMapper
140 SetMapper(vtkMapper* theMapper);
142 //! Allows to get initial #vtkDataSet
147 //! Apply view transformation
150 SetTransform(VTKViewer_Transform* theTransform);
152 //! To calculatate last modified time
157 //----------------------------------------------------------------------------
158 //! Set representation (VTK_SURFACE, VTK_POINTS, VTK_WIREFRAME and so on)
161 SetRepresentation(int theMode);
163 //! Get current representation mode
168 //! Get current display mode (obsolete)
173 //! Set display mode (obsolete)
176 setDisplayMode(int theMode);
178 //----------------------------------------------------------------------------
179 //! Set infinive flag
181 Infinitive means actor without size (point for example),
182 which is not taken into account in calculation of boundaries of the scene
185 SetInfinitive(bool theIsInfinite);
187 //! Get infinive flag
192 //! To calcualte current bounding box
194 vtkFloatingPointType*
197 //! To calcualte current bounding box
199 GetBounds(vtkFloatingPointType bounds[6]);
201 //----------------------------------------------------------------------------
212 SetSize( const vtkFloatingPointType );
216 SetCamera( vtkCamera* );
218 //----------------------------------------------------------------------------
219 //! Set ResolveCoincidentTopology flag
221 SetResolveCoincidentTopology(bool theIsResolve);
223 //! Set ResolveCoincidentTopology parameters
225 SetPolygonOffsetParameters(vtkFloatingPointType factor,
226 vtkFloatingPointType units);
228 //! Get current ResolveCoincidentTopology parameters
230 GetPolygonOffsetParameters(vtkFloatingPointType& factor,
231 vtkFloatingPointType& units);
235 Render(vtkRenderer *, vtkMapper *);
237 //----------------------------------------------------------------------------
238 //! Get current shrink factor
243 //! Is the actor is shrunkable
248 //! Is the actor is shrunk
253 //! Insert shrink filter into pipeline
258 //! Remove shrink filter from pipeline
263 //----------------------------------------------------------------------------
264 //! To publish the actor an all its internal devices
267 AddToRender(vtkRenderer* theRendere);
269 //! To remove the actor an all its internal devices
272 RemoveFromRender(vtkRenderer* theRendere);
274 //! Used to obtain all dependent actors
277 GetChildActors(vtkActorCollection*);
279 //----------------------------------------------------------------------------
280 //! Ask, if the descendant of the VTKViewer_Actor will implement its own highlight or not
285 //! Ask, if the VTKViewer_Actor is already highlighted
290 //! Set preselection mode
293 SetPreSelected(bool thePreselect = false);
295 //----------------------------------------------------------------------------
296 //! Just to update visibility of the highlight devices
299 highlight(bool theHighlight);
302 SetPreviewProperty(vtkProperty* theProperty);
305 //----------------------------------------------------------------------------
306 bool myIsResolveCoincidentTopology;
307 vtkFloatingPointType myPolygonOffsetFactor;
308 vtkFloatingPointType myPolygonOffsetUnits;
312 vtkFloatingPointType myOpacity;
317 VTKViewer_GeometryFilter *myGeomFilter;
318 VTKViewer_TransformFilter *myTransformFilter;
319 std::vector<vtkPassThroughFilter*> myPassFilter;
321 int myRepresentation;
322 vtkProperty *myProperty;
325 InitPipeLine(vtkMapper* theMapper);
331 vtkProperty *PreviewProperty;
332 bool myIsPreselected;
333 bool myIsHighlighted;
337 #pragma warning ( default:4251 )
340 #endif // VTKVIEVER_ACTOR_H