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