Salome HOME
95949133be2793a0bfeeb780f06ed60c6bc13135
[modules/gui.git] / src / SVTK / SVTK_DeviceActor.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SVTK OBJECT : interactive object for SVTK visualization
23 //  File   : SVTK_DeviceActor.h
24 //  Author : 
25 //  Module : 
26 //  $Header$
27 //
28 #ifndef SVTK_DEVICE_ACTOR_H
29 #define SVTK_DEVICE_ACTOR_H
30
31 #include "SVTK.h"
32 #include "VTKViewer.h"
33
34 #include <vector>
35
36 #include <vtkLODActor.h>
37 #include <vtkProperty.h>
38
39 class VTKViewer_Transform;
40 class VTKViewer_TransformFilter;
41 class VTKViewer_GeometryFilter;
42
43 class vtkCell;
44 class vtkDataSet;
45 class vtkShrinkFilter;
46 class vtkFeatureEdges;
47 class vtkDataSetMapper;
48 class vtkPassThroughFilter;
49
50 namespace SVTK
51 {
52   namespace Representation
53   {
54     typedef int Type;
55     const Type Points = VTK_POINTS;
56     const Type Wireframe = VTK_WIREFRAME;
57     const Type Surface = VTK_SURFACE;
58     const Type Insideframe = Surface + 1;
59   }
60 }
61
62 #ifdef WIN32
63 #pragma warning ( disable:4251 )
64 #endif
65
66 class SVTK_EXPORT SVTK_DeviceActor: public vtkLODActor
67 {
68  public:
69   vtkTypeMacro(SVTK_DeviceActor,vtkLODActor);
70
71   static
72   SVTK_DeviceActor* 
73   New();
74
75   //! Apply a view transformation
76   virtual
77   void
78   SetTransform(VTKViewer_Transform* theTransform); 
79
80   //! To insert some additional filters and then sets the given #vtkMapper
81   virtual
82   void
83   SetMapper(vtkMapper* theMapper); 
84
85   //! Allows to get initial #vtkDataSet
86   virtual
87   vtkDataSet* 
88   GetInput(); 
89
90   //! Allows to set initial #vtkDataSet
91   virtual
92   void
93   SetInput(vtkDataSet* theDataSet); 
94
95   /** @name For selection mapping purpose */
96   //@{
97   virtual
98   int
99   GetNodeObjId(int theVtkID);
100
101   virtual
102   vtkFloatingPointType* 
103   GetNodeCoord(int theObjID);
104
105   virtual
106   int
107   GetElemObjId(int theVtkID);
108
109   virtual
110   vtkCell* 
111   GetElemCell(int theObjID);
112
113   //! To provide VTK to Object and backward mapping
114   virtual 
115   void
116   SetStoreMapping(bool theStoreMapping);
117   //@}
118
119   virtual 
120   unsigned long int 
121   GetMTime();
122
123   /** @name For shrink mamnagement purpose */
124   //@{
125   vtkFloatingPointType
126   GetShrinkFactor();
127
128   virtual 
129   void  
130   SetShrinkFactor(vtkFloatingPointType value);
131
132   virtual
133   void
134   SetShrinkable(bool theIsShrinkable);
135
136   bool
137   IsShrunkable();
138
139   bool
140   IsShrunk();
141
142   virtual
143   void
144   SetShrink(); 
145
146   virtual
147   void
148   UnShrink(); 
149   //@}
150
151   /** @name For feature edges management purpose */
152   //@{
153   virtual
154   bool
155   IsFeatureEdgesAllowed();
156
157   virtual
158   void
159   SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed);
160
161   virtual
162   bool
163   IsFeatureEdgesEnabled();
164
165   virtual
166   void
167   SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled);
168
169   virtual
170   vtkFloatingPointType
171   GetFeatureEdgesAngle();
172
173   virtual
174   void
175   SetFeatureEdgesAngle(vtkFloatingPointType theAngle); 
176
177   virtual
178   void
179   GetFeatureEdgesFlags(bool& theIsFeatureEdges,
180                        bool& theIsBoundaryEdges,
181                        bool& theIsManifoldEdges,
182                        bool& theIsNonManifoldEdges);
183   virtual
184   void
185   SetFeatureEdgesFlags(bool theIsFeatureEdges,
186                        bool theIsBoundaryEdges,
187                        bool theIsManifoldEdges,
188                        bool theIsNonManifoldEdges);
189
190   virtual
191   bool
192   GetFeatureEdgesColoring();
193
194   virtual
195   void
196   SetFeatureEdgesColoring(bool theIsColoring);
197   //@}
198
199   /** @name For representation mamnagement purpose */
200   virtual
201   void 
202   SetRepresentation(SVTK::Representation::Type theMode);
203
204   SVTK::Representation::Type 
205   GetRepresentation();
206
207   virtual
208   vtkFloatingPointType
209   GetDefaultPointSize();
210
211   virtual
212   vtkFloatingPointType
213   GetDefaultLineWidth();
214
215   bool
216   IsShaded();
217
218   void
219   SetShaded(bool theShaded);
220   //@}
221
222   virtual
223   void
224   Render(vtkRenderer *, vtkMapper *);
225
226   vtkDataSetMapper* GetDataSetMapper();
227
228  protected:
229   SVTK::Representation::Type myRepresentation;
230   vtkProperty *myProperty;
231   bool myIsShaded;
232
233   //! To initialize internal pipeline
234   void
235   InitPipeLine(vtkMapper* theMapper); 
236
237   VTKViewer_GeometryFilter *myGeomFilter;
238   VTKViewer_TransformFilter *myTransformFilter;
239   std::vector<vtkPassThroughFilter*> myPassFilter;
240   vtkShrinkFilter* myShrinkFilter;
241   vtkFeatureEdges* myFeatureEdges;
242   vtkDataSetMapper* myMapper;
243
244   bool myIsShrinkable;
245   bool myIsShrunk;
246   
247   bool myIsFeatureEdgesAllowed;
248   bool myIsFeatureEdgesEnabled;
249
250   bool myIsResolveCoincidentTopology;
251   vtkFloatingPointType myPolygonOffsetFactor;
252   vtkFloatingPointType myPolygonOffsetUnits;
253
254   void SetPolygonOffsetParameters(vtkFloatingPointType factor, 
255                                   vtkFloatingPointType units);
256   void GetPolygonOffsetParameters(vtkFloatingPointType& factor, 
257                                   vtkFloatingPointType& units);
258
259   SVTK_DeviceActor();
260   ~SVTK_DeviceActor();
261
262  private:
263   SVTK_DeviceActor(const SVTK_DeviceActor&); // Not implemented
264   void operator=(const SVTK_DeviceActor&); // Not implemented
265
266 };
267
268 #ifdef WIN32
269 #pragma warning ( default:4251 )
270 #endif
271
272 #endif //SVTK_DEVICE_ACTOR_H