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