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 VTKVIEVER_ACTOR_H
30 #define VTKVIEVER_ACTOR_H
32 #include "VTKViewer.h"
37 #include <vtkLODActor.h>
47 class VTKViewer_Transform;
48 class VTKViewer_GeometryFilter;
49 class VTKViewer_TransformFilter;
50 class VTKViewer_PassThroughFilter;
52 extern int VTKViewer_POINT_SIZE;
53 extern int VTKViewer_LINE_WIDTH;
55 /*! \class vtkLODActor
56 * \brief For more information see <a href="http://www.vtk.org/">VTK documentation</a>
58 class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor
61 static VTKViewer_Actor* New();
63 vtkTypeMacro(VTKViewer_Actor,vtkLODActor);
65 //----------------------------------------------------------------------------
71 //! Name the #VTKViewer_Actor
74 setName(const char* theName);
76 //----------------------------------------------------------------------------
80 SetOpacity(float theOpacity);
82 //! Get current opacity
90 SetColor(float r,float g,float b);
95 GetColor(float& r,float& g,float& b);
100 SetColor(const float theRGB[3]);
102 //----------------------------------------------------------------------------
103 // For selection mapping purpose
104 //! Maps VTK index of a node to corresponding object index
107 GetNodeObjId(int theVtkID);
109 //! Get coordinates of a node for given object index
112 GetNodeCoord(int theObjID);
114 //! Maps VTK index of a cell to corresponding object index
117 GetElemObjId(int theVtkID);
119 //! Get corresponding #vtkCell for given object index
122 GetElemCell(int theObjID);
124 //----------------------------------------------------------------------------
125 //! Get dimension of corresponding mesh element
128 GetObjDimension( const int theObjId );
130 //! To insert some additional filters and then sets the given #vtkMapper
133 SetMapper(vtkMapper* theMapper);
135 //! Allows to get initial #vtkDataSet
140 //! Apply view transformation
143 SetTransform(VTKViewer_Transform* theTransform);
145 //! To calculatate last modified time
150 //----------------------------------------------------------------------------
151 //! Set representation (VTK_SURFACE, VTK_POINTS, VTK_WIREFRAME and so on)
154 SetRepresentation(int theMode);
156 //! Get current representation mode
161 //! Get current display mode (obsolete)
166 //! Set display mode (obsolete)
169 setDisplayMode(int theMode);
171 //----------------------------------------------------------------------------
172 //! Set infinive flag
174 Infinitive means actor without size (point for example),
175 which is not taken into account in calculation of boundaries of the scene
178 SetInfinitive(bool theIsInfinite);
180 //! Get infinive flag
185 //! To calcualte current bounding box
190 //! To calcualte current bounding box
192 GetBounds(float bounds[6]);
194 //----------------------------------------------------------------------------
205 SetSize( const float );
209 SetCamera( vtkCamera* );
211 //----------------------------------------------------------------------------
212 //! Set ResolveCoincidentTopology flag
214 SetResolveCoincidentTopology(bool theIsResolve);
216 //! Set ResolveCoincidentTopology parameters
218 SetPolygonOffsetParameters(float factor, float units);
220 //! Get current ResolveCoincidentTopology parameters
222 GetPolygonOffsetParameters(float& factor, float& units);
226 Render(vtkRenderer *, vtkMapper *);
228 //----------------------------------------------------------------------------
229 //! Get current shrink factor
234 //! Is the actor is shrunkable
239 //! Is the actor is shrunk
244 //! Insert shrink filter into pipeline
249 //! Remove shrink filter from pipeline
254 //----------------------------------------------------------------------------
255 //! To publish the actor an all its internal devices
258 AddToRender(vtkRenderer* theRendere);
260 //! To remove the actor an all its internal devices
263 RemoveFromRender(vtkRenderer* theRendere);
265 //! Used to obtain all dependent actors
268 GetChildActors(vtkActorCollection*);
270 //----------------------------------------------------------------------------
271 //! Ask, if the descendant of the VTKViewer_Actor will implement its own highlight or not
276 //! Ask, if the VTKViewer_Actor is already highlighted
281 //! Set preselection mode
284 SetPreSelected(bool thePreselect = false);
286 //----------------------------------------------------------------------------
287 //! Just to update visibility of the highlight devices
290 highlight(bool theHighlight);
293 SetPreviewProperty(vtkProperty* theProperty);
296 //----------------------------------------------------------------------------
297 bool myIsResolveCoincidentTopology;
298 float myPolygonOffsetFactor;
299 float myPolygonOffsetUnits;
308 VTKViewer_GeometryFilter *myGeomFilter;
309 VTKViewer_TransformFilter *myTransformFilter;
310 std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
312 int myRepresentation;
313 vtkProperty *myProperty;
316 InitPipeLine(vtkMapper* theMapper);
322 vtkProperty *PreviewProperty;
323 bool myIsPreselected;
324 bool myIsHighlighted;
327 #endif // VTKVIEVER_ACTOR_H