Salome HOME
Update comments
[modules/gui.git] / src / VTKViewer / VTKViewer_Actor.h
1 #ifndef VTKVIEVER_ACTOR_H
2 #define VTKVIEVER_ACTOR_H
3
4 #include "VTKViewer.h"
5
6 #include <vtkLODActor.h>
7 #include <vtkProperty.h>
8 #include <vtkShrinkFilter.h>
9 #include <vtkDataSetMapper.h>
10 #include <vtkUnstructuredGrid.h>
11
12 #include <vector>
13
14 class vtkCell;
15 class vtkDataSet;
16 class vtkPolyData;
17
18 class VTKViewer_Transform;
19 class VTKViewer_GeometryFilter;
20 class VTKViewer_TransformFilter;
21 class VTKViewer_PassThroughFilter;
22
23 #define VTKViewer_POINT_SIZE 3
24 /*! \class vtkLODActor
25  * \brief For more information see <a href="http://www.vtk.org/">VTK documentation</a>
26  */
27 class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor
28 {
29 public:
30   /*!Create new instance of actor.*/
31   static VTKViewer_Actor* New();
32
33   vtkTypeMacro( VTKViewer_Actor, vtkLODActor );
34
35   /*!Get name of the actor*/
36   virtual const char* getName() { return myName.c_str(); }
37   /*!Set name of the actor*/
38   virtual void setName(const char* theName){ myName = theName;}
39
40   //! To generate highlight automaticaly
41   virtual bool hasHighlight() { return false; }
42   //! Sets highlight.
43   virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; }
44   //! Check highlight.
45   virtual bool isHighlighted() { return myIsHighlighted; }
46   
47   virtual void SetOpacity(float theOpacity);
48   virtual float GetOpacity();
49
50   virtual void SetColor(float r,float g,float b);
51   virtual void GetColor(float& r,float& g,float& b);
52   void SetColor(const float theRGB[3]){ SetColor(theRGB[0],theRGB[1],theRGB[2]); }
53
54   vtkSetObjectMacro(PreviewProperty,vtkProperty);
55
56   virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
57
58   //! Used to obtain all dependent actors
59   virtual void GetChildActors(vtkActorCollection*) {};
60   
61   virtual void AddToRender(vtkRenderer* theRenderer); 
62   virtual void RemoveFromRender(vtkRenderer* theRenderer);
63
64
65   /** @name For selection mapping purpose */
66   //@{
67   virtual int GetNodeObjId(int theVtkID) { return theVtkID;}
68   virtual float* GetNodeCoord(int theObjID);
69
70   virtual int GetElemObjId(int theVtkID) { return theVtkID;}
71   virtual vtkCell* GetElemCell(int theObjID);
72   //@}
73
74   virtual int GetObjDimension( const int theObjId );
75
76   virtual void SetMapper(vtkMapper* theMapper); 
77   virtual vtkDataSet* GetInput(); 
78
79   virtual void SetTransform(VTKViewer_Transform* theTransform); 
80   virtual unsigned long int GetMTime();
81
82   virtual void SetRepresentation(int theMode);
83   virtual int GetRepresentation();
84
85   virtual int getDisplayMode();
86   virtual void setDisplayMode(int theMode);
87
88   /*! Infinitive means actor without size (point for example), \n
89    * which is not taken into account in calculation of boundaries of the scene
90    */
91   void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; }
92   virtual bool IsInfinitive();
93     
94   void SetResolveCoincidentTopology(bool theIsResolve);
95   void SetPolygonOffsetParameters(float factor, float units);
96   void GetPolygonOffsetParameters(float& factor, float& units);
97
98   virtual void Render(vtkRenderer *, vtkMapper *);
99
100 protected:
101   /*!resolve coincedent topology flag*/
102   bool myIsResolveCoincidentTopology;
103   /*!polygon offset factor*/
104   float myPolygonOffsetFactor;
105   /*!polygon offset units*/
106   float myPolygonOffsetUnits;
107
108   /*!Actor name.*/
109   std::string myName;
110
111   /*!preview property*/
112   vtkProperty *PreviewProperty;
113   /*!preselected flag*/
114   bool myIsPreselected;
115
116   /*!opacity*/
117   float myOpacity;
118   /*!highlighted flag*/
119   bool myIsHighlighted;
120   /*!display mode*/
121   int myDisplayMode;
122   /*!infinite flag*/
123   bool myIsInfinite;
124
125   /*!store mapping flag*/
126   bool myStoreMapping;
127   /*!geometry filter*/
128   VTKViewer_GeometryFilter *myGeomFilter;
129   /*!transform filter*/
130   VTKViewer_TransformFilter *myTransformFilter;
131   /*!vector of passive filters(siz filters used)*/
132   std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
133
134   /*!presentation mode*/
135   int myRepresentation;
136   /*!property*/
137   vtkProperty *myProperty;
138
139   //! Main method, which calculate output.
140   void InitPipeLine(vtkMapper* theMapper); 
141
142   VTKViewer_Actor();
143   ~VTKViewer_Actor();
144 };
145
146 #endif