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