1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
19 #ifndef VTKVIEVER_ACTOR_H
20 #define VTKVIEVER_ACTOR_H
22 #include "VTKViewer.h"
24 #include <vtkLODActor.h>
25 #include <vtkProperty.h>
26 #include <vtkShrinkFilter.h>
27 #include <vtkDataSetMapper.h>
28 #include <vtkUnstructuredGrid.h>
36 class VTKViewer_Transform;
37 class VTKViewer_GeometryFilter;
38 class VTKViewer_TransformFilter;
39 class VTKViewer_PassThroughFilter;
41 #define VTKViewer_POINT_SIZE 3
42 /*! \class vtkLODActor
43 * \brief For more information see <a href="http://www.vtk.org/">VTK documentation</a>
45 class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor
48 /*!Create new instance of actor.*/
49 static VTKViewer_Actor* New();
51 vtkTypeMacro( VTKViewer_Actor, vtkLODActor );
53 /*!Get name of the actor*/
54 virtual const char* getName() { return myName.c_str(); }
55 /*!Set name of the actor*/
56 virtual void setName(const char* theName){ myName = theName;}
58 //! To generate highlight automaticaly
59 virtual bool hasHighlight() { return false; }
61 virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; }
63 virtual bool isHighlighted() { return myIsHighlighted; }
65 virtual void SetOpacity(float theOpacity);
66 virtual float GetOpacity();
68 virtual void SetColor(float r,float g,float b);
69 virtual void GetColor(float& r,float& g,float& b);
70 void SetColor(const float theRGB[3]){ SetColor(theRGB[0],theRGB[1],theRGB[2]); }
72 vtkSetObjectMacro(PreviewProperty,vtkProperty);
74 virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
76 //! Used to obtain all dependent actors
77 virtual void GetChildActors(vtkActorCollection*) {};
79 virtual void AddToRender(vtkRenderer* theRenderer);
80 virtual void RemoveFromRender(vtkRenderer* theRenderer);
83 /** @name For selection mapping purpose */
85 virtual int GetNodeObjId(int theVtkID) { return theVtkID;}
86 virtual float* GetNodeCoord(int theObjID);
88 virtual int GetElemObjId(int theVtkID) { return theVtkID;}
89 virtual vtkCell* GetElemCell(int theObjID);
92 virtual int GetObjDimension( const int theObjId );
94 virtual void SetMapper(vtkMapper* theMapper);
95 virtual vtkDataSet* GetInput();
97 virtual void SetTransform(VTKViewer_Transform* theTransform);
98 virtual unsigned long int GetMTime();
100 virtual void SetRepresentation(int theMode);
101 virtual int GetRepresentation();
103 virtual int getDisplayMode();
104 virtual void setDisplayMode(int theMode);
106 /*! Infinitive means actor without size (point for example), \n
107 * which is not taken into account in calculation of boundaries of the scene
109 void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; }
110 virtual bool IsInfinitive();
112 void SetResolveCoincidentTopology(bool theIsResolve);
113 void SetPolygonOffsetParameters(float factor, float units);
114 void GetPolygonOffsetParameters(float& factor, float& units);
116 virtual void Render(vtkRenderer *, vtkMapper *);
119 /*!resolve coincedent topology flag*/
120 bool myIsResolveCoincidentTopology;
121 /*!polygon offset factor*/
122 float myPolygonOffsetFactor;
123 /*!polygon offset units*/
124 float myPolygonOffsetUnits;
129 /*!preview property*/
130 vtkProperty *PreviewProperty;
131 /*!preselected flag*/
132 bool myIsPreselected;
136 /*!highlighted flag*/
137 bool myIsHighlighted;
143 /*!store mapping flag*/
146 VTKViewer_GeometryFilter *myGeomFilter;
147 /*!transform filter*/
148 VTKViewer_TransformFilter *myTransformFilter;
149 /*!vector of passive filters(siz filters used)*/
150 std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
152 /*!presentation mode*/
153 int myRepresentation;
155 vtkProperty *myProperty;
157 //! Main method, which calculate output.
158 void InitPipeLine(vtkMapper* theMapper);