Salome HOME
Merge from V6_5_BR 05/06/2012
[modules/smesh.git] / src / OBJECT / SMESH_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 //  SMESH OBJECT : interactive object for SMESH visualization
24 //  File   : SMESH_DeviceActor.h
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //  $Header$
28 //
29 #ifndef SMESH_DEVICE_ACTOR_H
30 #define SMESH_DEVICE_ACTOR_H
31
32 #include <VTKViewer_GeometryFilter.h>
33 #include <VTKViewer_MarkerDef.h>
34 #include "SMESH_Controls.hxx"
35 #include "SMESH_Object.h"
36
37 #include <vtkLODActor.h>
38 #include <vtkSmartPointer.h>
39
40 class vtkCell;
41 class vtkProperty;
42 class vtkMergeFilter;
43 class vtkShrinkFilter;
44 class vtkUnstructuredGrid;
45 class vtkLookupTable;
46 class vtkImplicitBoolean;
47 class vtkPassThroughFilter;
48
49 class VTKViewer_Transform;
50 class VTKViewer_TransformFilter;
51 class VTKViewer_ExtractUnstructuredGrid;
52 class VTKViewer_PolyDataMapper;
53
54 class SMESH_ExtractGeometry;
55 class SMESH_FaceOrientationFilter;
56 class SMESH_ScalarBarActor;
57
58
59 class SMESHOBJECT_EXPORT SMESH_DeviceActor: public vtkLODActor{
60   friend class SMESH_ActorDef;
61
62  public:
63   vtkTypeMacro(SMESH_DeviceActor,vtkLODActor);
64   static SMESH_DeviceActor* New();
65
66   void SetStoreClippingMapping(bool theStoreMapping);
67   void SetStoreGemetryMapping(bool theStoreMapping);
68   void SetStoreIDMapping(bool theStoreMapping);
69
70   virtual int GetNodeObjId(int theVtkID);
71   virtual vtkFloatingPointType* GetNodeCoord(int theObjID);
72
73   virtual int GetElemObjId(int theVtkID);
74   virtual vtkCell* GetElemCell(int theObjID);
75
76   virtual void SetTransform(VTKViewer_Transform* theTransform); 
77   virtual unsigned long int GetMTime();
78
79   virtual void SetFacesOriented(bool theIsFacesOriented);
80   virtual bool GetFacesOriented() { return myIsFacesOriented; }
81
82   virtual void SetFacesOrientationColor(vtkFloatingPointType theColor[3]);
83   virtual void GetFacesOrientationColor(vtkFloatingPointType theColor[3]);
84
85   virtual void SetFacesOrientationScale(vtkFloatingPointType theScale);
86   virtual vtkFloatingPointType GetFacesOrientationScale();
87
88   virtual void SetFacesOrientation3DVectors(bool theState);
89   virtual bool GetFacesOrientation3DVectors();
90
91   //----------------------------------------------------------------------------
92   //! Setting for displaying quadratic elements
93   virtual void SetQuadraticArcMode(bool theFlag);
94   virtual bool GetQuadraticArcMode();
95   
96   virtual void SetQuadraticArcAngle(vtkFloatingPointType theMaxAngle);
97   virtual vtkFloatingPointType GetQuadraticArcAngle();
98   
99   void UpdateFaceOrientation();
100
101   vtkFloatingPointType GetShrinkFactor();
102   void  SetShrinkFactor(vtkFloatingPointType value);
103
104   bool IsShrunkable() { return myIsShrinkable;}
105   bool IsShrunk() { return myIsShrunk;}
106   void SetShrink(); 
107   void UnShrink(); 
108
109   enum EReperesent { ePoint, eWireframe, eSurface, eInsideframe};
110   EReperesent GetRepresentation(){ return myRepresentation;}
111   void SetRepresentation(EReperesent theMode);
112
113   virtual void SetVisibility(int theMode);
114   virtual int GetVisibility();
115
116   virtual void AddToRender(vtkRenderer* theRenderer); 
117   virtual void RemoveFromRender(vtkRenderer* theRenderer);
118
119   VTKViewer_ExtractUnstructuredGrid* GetExtractUnstructuredGrid();
120   vtkUnstructuredGrid* GetUnstructuredGrid();
121
122   void SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
123                       SMESH_ScalarBarActor* theScalarBarActor,
124                       vtkLookupTable* theLookupTable);
125   void SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
126                          SMESH_ScalarBarActor* theScalarBarActor,
127                          vtkLookupTable* theLookupTable);
128   void SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor);
129
130   bool IsHighlited() { return myIsHighlited;}
131   void SetHighlited(bool theIsHighlited);
132
133   virtual
134   void
135   SetCoincident3DAllowed(bool theIsFeatureEdgesAllowed);
136
137   virtual
138   bool 
139   IsCoincident3DAllowed() const;
140
141   virtual void Render(vtkRenderer *, vtkMapper *);
142
143   void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
144   bool IsImplicitFunctionUsed() const{ return myIsImplicitFunctionUsed;}
145
146   void SetMarkerEnabled( bool );
147   void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
148   void SetMarkerTexture( int, VTK::MarkerTexture );
149   VTK::MarkerType GetMarkerType();
150   VTK::MarkerScale GetMarkerScale();
151   int GetMarkerTexture();
152
153  protected:
154   void Init(TVisualObjPtr theVisualObj, vtkImplicitBoolean* theImplicitBoolean);
155   void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid);
156
157   VTKViewer_PolyDataMapper *myMapper;
158   TVisualObjPtr myVisualObj;
159
160   vtkProperty *myProperty;
161   EReperesent myRepresentation;
162
163   SMESH_ExtractGeometry* myExtractGeometry;
164   bool myIsImplicitFunctionUsed;
165
166   vtkMergeFilter* myMergeFilter;
167   VTKViewer_ExtractUnstructuredGrid* myExtractUnstructuredGrid;
168
169   bool myIsFacesOriented;
170   SMESH_FaceOrientationFilter* myFaceOrientationFilter;
171   vtkPolyDataMapper* myFaceOrientationDataMapper;
172   vtkActor* myFaceOrientation;
173
174   bool myStoreClippingMapping;
175   VTKViewer_GeometryFilter *myGeomFilter;
176   VTKViewer_TransformFilter *myTransformFilter;
177   std::vector<vtkPassThroughFilter*> myPassFilter;
178
179   vtkShrinkFilter* myShrinkFilter;
180   bool myIsShrinkable;
181   bool myIsShrunk;
182   
183   bool myIsHighlited;
184
185   vtkFloatingPointType myPolygonOffsetFactor;
186   vtkFloatingPointType myPolygonOffsetUnits;
187
188   void
189   SetPolygonOffsetParameters(vtkFloatingPointType factor, 
190                              vtkFloatingPointType units);
191
192   void
193   GetPolygonOffsetParameters(vtkFloatingPointType& factor, 
194                              vtkFloatingPointType& units)
195   {
196     factor = myPolygonOffsetFactor;
197     units = myPolygonOffsetUnits;
198   }
199
200   SMESH_DeviceActor();
201   ~SMESH_DeviceActor();
202   SMESH_DeviceActor(const SMESH_DeviceActor&);
203   void operator=(const SMESH_DeviceActor&);
204
205 };
206
207
208 #endif //SMESH_DEVICE_ACTOR_H