Salome HOME
PR: mergefrom_PAL_OCC_21Oct04
[modules/kernel.git] / src / OBJECT / SALOME_Actor.h
1 //  SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOME_Actor.h
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef SALOME_ACTOR_H
30 #define SALOME_ACTOR_H
31
32 #include <vector>
33
34 #include <vtkLODActor.h>
35 #include <vtkProperty.h>
36
37 class vtkCell;
38 class vtkDataSet;
39 class vtkPolyData;
40 class vtkCamera;
41
42 #include "SALOME_InteractiveObject.hxx"
43
44 class SALOME_Transform;
45 class SALOME_GeometryFilter;
46 class SALOME_TransformFilter;
47 class SALOME_PassThroughFilter;
48
49 extern int SALOME_POINT_SIZE;
50
51 class SALOME_Actor : public vtkLODActor{
52  public:
53   static SALOME_Actor* New();
54
55   vtkTypeMacro(SALOME_Actor,vtkLODActor);
56
57   virtual Standard_Boolean hasIO() { return !myIO.IsNull(); }
58   virtual const Handle(SALOME_InteractiveObject)& getIO() { return myIO; } 
59   virtual void setIO(const Handle(SALOME_InteractiveObject)& io) { myIO = io; }
60
61   virtual const char* getName() { return myName.c_str(); }
62   virtual void setName(const char* theName){
63     if(hasIO()) myIO->setName(theName);
64     myName = theName;
65   }
66
67   // To generate highlight automaticaly
68   virtual bool hasHighlight() { return false; } 
69   virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; }  
70   virtual bool isHighlighted() { return myIsHighlighted; }
71
72   virtual void SetOpacity(float theOpacity);
73   virtual float GetOpacity();
74
75   virtual void SetColor(float r,float g,float b);
76   virtual void GetColor(float& r,float& g,float& b);
77   void SetColor(const float theRGB[3]){ 
78     SetColor(theRGB[0],theRGB[1],theRGB[2]);
79   }
80
81   vtkSetObjectMacro(PreviewProperty,vtkProperty);
82
83   virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
84
85
86   // Used to obtain all dependent actors
87   virtual void GetChildActors(vtkActorCollection*) {};
88   
89   virtual void AddToRender(vtkRenderer* theRenderer); 
90   virtual void RemoveFromRender(vtkRenderer* theRenderer);
91
92
93   // For selection mapping purpose
94   virtual int GetNodeObjId(int theVtkID) { return theVtkID;}
95   virtual float* GetNodeCoord(int theObjID);
96
97   virtual int GetElemObjId(int theVtkID) { return theVtkID;}
98   virtual vtkCell* GetElemCell(int theObjID);
99
100   virtual int GetObjDimension( const int theObjId );
101
102   virtual void SetMapper(vtkMapper* theMapper); 
103   virtual vtkDataSet* GetInput(); 
104
105
106   virtual void SetTransform(SALOME_Transform* theTransform); 
107   virtual unsigned long int GetMTime();
108
109   virtual void SetRepresentation(int theMode);
110   virtual int GetRepresentation();
111
112   virtual int getDisplayMode();
113   virtual void setDisplayMode(int theMode);
114
115   // Infinitive means actor without size (point for example),
116   // which is not taken into account in calculation of boundaries of the scene
117   void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; }
118   virtual bool IsInfinitive();
119     
120   void SetResolveCoincidentTopology(bool theIsResolve);
121   void SetPolygonOffsetParameters(float factor, float units);
122   void GetPolygonOffsetParameters(float& factor, float& units);
123
124   virtual void Render(vtkRenderer *, vtkMapper *);
125
126   virtual float GetShrinkFactor() { return 1.0;}
127
128   virtual bool IsShrunkable() { return false;}
129   virtual bool IsShrunk() { return false;}
130
131   virtual void SetShrink() {} 
132   virtual void UnShrink() {}
133
134   virtual bool IsSetCamera() const { return false; }
135   virtual bool IsResizable() const { return false; }
136   virtual void SetSize( const float ) {}
137   virtual void SetCamera( vtkCamera* ) {}
138
139  protected:
140   bool myIsResolveCoincidentTopology;
141   float myPolygonOffsetFactor;
142   float myPolygonOffsetUnits;
143
144   Handle(SALOME_InteractiveObject) myIO;
145   std::string myName;
146
147   vtkProperty *PreviewProperty;
148   bool myIsPreselected;
149
150   float myOpacity;
151   bool myIsHighlighted;
152   int myDisplayMode;
153   bool myIsInfinite;
154
155   bool myStoreMapping;
156   SALOME_GeometryFilter *myGeomFilter;
157   SALOME_TransformFilter *myTransformFilter;
158   std::vector<SALOME_PassThroughFilter*> myPassFilter;
159
160   int myRepresentation;
161   vtkProperty *myProperty;
162
163   void InitPipeLine(vtkMapper* theMapper); 
164
165   SALOME_Actor();
166   ~SALOME_Actor();
167 };
168
169
170 #endif // SALOME_ACTOR_H
171