Salome HOME
557af907defb29fc82d84f803ff764e925da377b
[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
26  */
27 class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor
28 {
29 public:
30   static VTKViewer_Actor* New();
31
32   vtkTypeMacro( VTKViewer_Actor, vtkLODActor );
33
34   virtual const char* getName() { return myName.c_str(); }
35   virtual void setName(const char* theName){ myName = theName;}
36
37   //! To generate highlight automaticaly
38   virtual bool hasHighlight() { return false; }
39   //! Sets highlight.
40   virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; }
41   //! Check highlight.
42   virtual bool isHighlighted() { return myIsHighlighted; }
43   
44   virtual void SetOpacity(float theOpacity);
45   virtual float GetOpacity();
46
47   virtual void SetColor(float r,float g,float b);
48   virtual void GetColor(float& r,float& g,float& b);
49   void SetColor(const float theRGB[3]){ SetColor(theRGB[0],theRGB[1],theRGB[2]); }
50
51   vtkSetObjectMacro(PreviewProperty,vtkProperty);
52
53   virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
54
55   //! Used to obtain all dependent actors
56   virtual void GetChildActors(vtkActorCollection*) {};
57   
58   virtual void AddToRender(vtkRenderer* theRenderer); 
59   virtual void RemoveFromRender(vtkRenderer* theRenderer);
60
61
62   /*! For selection mapping purpose */
63   virtual int GetNodeObjId(int theVtkID) { return theVtkID;}
64   virtual float* GetNodeCoord(int theObjID);
65
66   virtual int GetElemObjId(int theVtkID) { return theVtkID;}
67   virtual vtkCell* GetElemCell(int theObjID);
68
69   virtual int GetObjDimension( const int theObjId );
70
71   virtual void SetMapper(vtkMapper* theMapper); 
72   virtual vtkDataSet* GetInput(); 
73
74
75   virtual void SetTransform(VTKViewer_Transform* theTransform); 
76   virtual unsigned long int GetMTime();
77
78   virtual void SetRepresentation(int theMode);
79   virtual int GetRepresentation();
80
81   virtual int getDisplayMode();
82   virtual void setDisplayMode(int theMode);
83
84   //! Infinitive means actor without size (point for example),
85   //! which is not taken into account in calculation of boundaries of the scene
86   void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; }
87   virtual bool IsInfinitive();
88     
89   void SetResolveCoincidentTopology(bool theIsResolve);
90   void SetPolygonOffsetParameters(float factor, float units);
91   void GetPolygonOffsetParameters(float& factor, float& units);
92
93   virtual void Render(vtkRenderer *, vtkMapper *);
94
95 protected:
96   bool myIsResolveCoincidentTopology;
97   float myPolygonOffsetFactor;
98   float myPolygonOffsetUnits;
99
100   std::string myName;
101
102   vtkProperty *PreviewProperty;
103   bool myIsPreselected;
104
105   float myOpacity;
106   bool myIsHighlighted;
107   int myDisplayMode;
108   bool myIsInfinite;
109
110   bool myStoreMapping;
111   VTKViewer_GeometryFilter *myGeomFilter;
112   VTKViewer_TransformFilter *myTransformFilter;
113   std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
114
115   int myRepresentation;
116   vtkProperty *myProperty;
117
118   //! Main method, which calculate output.
119   void InitPipeLine(vtkMapper* theMapper); 
120
121   VTKViewer_Actor();
122   ~VTKViewer_Actor();
123 };
124
125 #endif