Salome HOME
f8a49bc36316937a3669c5542f9fa035ec54332b
[modules/gui.git] / src / SVTK / SVTK_DeviceActor.h
1 //  SVTK OBJECT : interactive object for SVTK visualization
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   : SVTK_DeviceActor.h
25 //  Author : 
26 //  Module : 
27 //  $Header$
28
29 #ifndef SVTK_DEVICE_ACTOR_H
30 #define SVTK_DEVICE_ACTOR_H
31
32 #include <vector>
33
34 #include <vtkLODActor.h>
35 #include <vtkProperty.h>
36
37 class VTKViewer_Transform;
38 class VTKViewer_TransformFilter;
39 class VTKViewer_PassThroughFilter;
40 class VTKViewer_GeometryFilter;
41
42 class vtkCell;
43 class vtkDataSet;
44 class vtkShrinkFilter;
45 class vtkDataSetMapper;
46
47 //----------------------------------------------------------------------------
48 namespace SVTK
49 {
50   namespace Representation
51   {
52     typedef int Type;
53     const Type Points = VTK_POINTS;
54     const Type Wireframe = VTK_WIREFRAME;
55     const Type Surface = VTK_SURFACE;
56     const Type Insideframe = Surface + 1;
57   }
58 }
59
60
61 //----------------------------------------------------------------------------
62 class SVTK_DeviceActor: public vtkLODActor
63 {
64  public:
65   vtkTypeMacro(SVTK_DeviceActor,vtkLODActor);
66
67   static
68   SVTK_DeviceActor* 
69   New();
70
71   //! Apply a view transformation
72   virtual
73   void
74   SetTransform(VTKViewer_Transform* theTransform); 
75
76   //! To insert some additional filters and then sets the given #vtkMapper
77   virtual
78   void
79   SetMapper(vtkMapper* theMapper); 
80
81   //! Allows to get initial #vtkDataSet
82   virtual
83   vtkDataSet* 
84   GetInput(); 
85
86   //! Allows to set initial #vtkDataSet
87   virtual
88   void
89   SetInput(vtkDataSet* theDataSet); 
90
91   /** @name For selection mapping purpose */
92   //@{
93   virtual
94   int
95   GetNodeObjId(int theVtkID);
96
97   virtual
98   float* 
99   GetNodeCoord(int theObjID);
100
101   virtual
102   int
103   GetElemObjId(int theVtkID);
104
105   virtual
106   vtkCell* 
107   GetElemCell(int theObjID);
108
109   //! To provide VTK to Object and backward mapping
110   virtual 
111   void
112   SetStoreMapping(bool theStoreMapping);
113   //@}
114
115   virtual 
116   unsigned long int 
117   GetMTime();
118
119   /** @name For shrink mamnagement purpose */
120   //@{
121   float
122   GetShrinkFactor();
123
124   virtual 
125   void  
126   SetShrinkFactor(float value);
127
128   virtual
129   void
130   SetShrinkable(bool theIsShrinkable);
131
132   bool
133   IsShrunkable();
134
135   bool
136   IsShrunk();
137
138   virtual
139   void
140   SetShrink(); 
141
142   virtual
143   void
144   UnShrink(); 
145   //@}
146
147   /** @name For representation mamnagement purpose */
148   virtual
149   void 
150   SetRepresentation(SVTK::Representation::Type theMode);
151
152   SVTK::Representation::Type 
153   GetRepresentation();
154
155   virtual
156   float
157   GetDefaultPointSize();
158
159   virtual
160   float
161   GetDefaultLineWidth();
162
163   bool
164   IsShaded();
165
166   void
167   SetShaded(bool theShaded);
168   //@}
169
170   virtual
171   void
172   Render(vtkRenderer *, vtkMapper *);
173
174  protected:
175   SVTK::Representation::Type myRepresentation;
176   vtkProperty *myProperty;
177   bool myIsShaded;
178
179   //! To initialize internal pipeline
180   void
181   InitPipeLine(vtkMapper* theMapper); 
182
183   VTKViewer_GeometryFilter *myGeomFilter;
184   VTKViewer_TransformFilter *myTransformFilter;
185   std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
186   vtkShrinkFilter* myShrinkFilter;
187   vtkDataSetMapper* myMapper;
188
189   bool myIsShrinkable;
190   bool myIsShrunk;
191   
192   bool myIsResolveCoincidentTopology;
193   float myPolygonOffsetFactor;
194   float myPolygonOffsetUnits;
195
196   void SetPolygonOffsetParameters(float factor, float units);
197   void GetPolygonOffsetParameters(float& factor, float& units);
198
199   SVTK_DeviceActor();
200   ~SVTK_DeviceActor();
201
202  private:
203   SVTK_DeviceActor(const SVTK_DeviceActor&); // Not implemented
204   void operator=(const SVTK_DeviceActor&); // Not implemented
205
206 };
207
208
209 #endif //SVTK_DEVICE_ACTOR_H