1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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 VTKVIEVER_ACTOR_H
28 #define VTKVIEVER_ACTOR_H
30 #include "VTKViewer.h"
35 #include <vtkLODActor.h>
36 #include <vtkProperty.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;
56 namespace Representation
59 const Type Points = VTK_POINTS;
60 const Type Wireframe = VTK_WIREFRAME;
61 const Type Surface = VTK_SURFACE;
62 const Type Insideframe = Surface + 1;
63 const Type SurfaceWithEdges = Insideframe + 1;
68 #pragma warning ( disable:4251 )
71 /*! \class vtkLODActor
72 * \brief For more information see <a href="http://www.vtk.org/">VTK documentation</a>
74 class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor
77 static VTKViewer_Actor* New();
79 vtkTypeMacro(VTKViewer_Actor,vtkLODActor);
81 //----------------------------------------------------------------------------
87 //! Name the #VTKViewer_Actor
90 setName(const char* theName);
92 //----------------------------------------------------------------------------
96 SetOpacity(double theOpacity);
98 //! Get current opacity
110 //! Get current color
120 SetColor(const double theRGB[3]);
122 //! Change material
\r
125 SetMaterial(std::vector<vtkProperty*> theProps);
127 //! Get current front material
\r
130 GetFrontMaterial();
\r
132 //! Get current back material
\r
137 //----------------------------------------------------------------------------
138 // For selection mapping purpose
139 //! Maps VTK index of a node to corresponding object index
142 GetNodeObjId(int theVtkID);
144 //! Get coordinates of a node for given object index
147 GetNodeCoord(int theObjID);
149 //! Maps VTK index of a cell to corresponding object index
152 GetElemObjId(int theVtkID);
154 //! Get corresponding #vtkCell for given object index
157 GetElemCell(int theObjID);
159 //----------------------------------------------------------------------------
160 //! Get dimension of corresponding mesh element
163 GetObjDimension( const int theObjId );
165 //! To insert some additional filters and then sets the given #vtkMapper
168 SetMapper(vtkMapper* theMapper);
170 //! Allows to get initial #vtkDataSet
175 //! Apply view transformation
178 SetTransform(VTKViewer_Transform* theTransform);
180 //! To calculatate last modified time
185 //----------------------------------------------------------------------------
186 //! Set representation (VTK_SURFACE, VTK_POINTS, VTK_WIREFRAME and so on)
189 SetRepresentation(int theMode);
191 //! Get current representation mode
196 //! Get current display mode (obsolete)
201 //! Set display mode (obsolete)
204 setDisplayMode(int theMode);
206 //----------------------------------------------------------------------------
207 //! Set infinive flag
209 Infinitive means actor without size (point for example),
210 which is not taken into account in calculation of boundaries of the scene
213 SetInfinitive(bool theIsInfinite);
215 //! Get infinive flag
220 //! To calcualte current bounding box
225 //! To calcualte current bounding box
227 GetBounds(double bounds[6]);
229 //----------------------------------------------------------------------------
240 SetSize( const double );
244 SetCamera( vtkCamera* );
246 //----------------------------------------------------------------------------
247 //! Set ResolveCoincidentTopology flag
249 SetResolveCoincidentTopology(bool theIsResolve);
251 //! Set ResolveCoincidentTopology parameters
253 SetPolygonOffsetParameters(double factor,
256 //! Get current ResolveCoincidentTopology parameters
258 GetPolygonOffsetParameters(double& factor,
261 //! Get default ResolveCoincidentTopology parameters
264 GetDefaultPolygonOffsetParameters(double& factor,
269 Render(vtkRenderer *, vtkMapper *);
271 //----------------------------------------------------------------------------
272 //! Get current shrink factor
277 //! Is the actor is shrunkable
282 //! Is the actor is shrunk
287 //! Insert shrink filter into pipeline
292 //! Remove shrink filter from pipeline
297 //----------------------------------------------------------------------------
298 //! To publish the actor an all its internal devices
301 AddToRender(vtkRenderer* theRendere);
303 //! To remove the actor an all its internal devices
306 RemoveFromRender(vtkRenderer* theRendere);
308 //! Used to obtain all dependent actors
311 GetChildActors(vtkActorCollection*);
313 //----------------------------------------------------------------------------
314 //! Is notified on enabling/disabling selection
317 EnableSelection( bool enable ) {}
319 //! Ask, if the descendant of the VTKViewer_Actor will implement its own highlight or not
324 //! Ask, if the VTKViewer_Actor is already highlighted
329 //! Ask, if the VTKViewer_Actor is already preselected
334 //! Set preselection mode
337 SetPreSelected(bool thePreselect = false);
339 //----------------------------------------------------------------------------
340 //! Just to update visibility of the highlight devices
343 highlight(bool theHighlight);
346 SetPreviewProperty(vtkProperty* theProperty);
348 //----------------------------------------------------------------------------
349 //! Setting for displaying quadratic elements
350 virtual void SetQuadraticArcMode(bool theFlag);
351 virtual bool GetQuadraticArcMode() const;
353 virtual void SetQuadraticArcAngle(double theMaxAngle);
354 virtual double GetQuadraticArcAngle() const;
356 //----------------------------------------------------------------------------
357 //! Return pointer to the dataset, which used to calculation of the bounding box of the actor
358 virtual vtkDataSet* GetHighlightedDataSet();
361 //----------------------------------------------------------------------------
362 bool myIsResolveCoincidentTopology;
363 double myPolygonOffsetFactor;
364 double myPolygonOffsetUnits;
373 VTKViewer_GeometryFilter *myGeomFilter;
374 VTKViewer_TransformFilter *myTransformFilter;
375 std::vector<vtkPassThroughFilter*> myPassFilter;
377 int myRepresentation;
378 vtkProperty *myProperty;
381 InitPipeLine(vtkMapper* theMapper);
387 vtkProperty *PreviewProperty;
388 bool myIsPreselected;
389 bool myIsHighlighted;
393 #pragma warning ( default:4251 )
396 #endif // VTKVIEVER_ACTOR_H