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