Salome HOME
Implementation of the "0022102: EDF 1496 SMESH : Displaying of discrete elements...
[modules/smesh.git] / src / OBJECT / SMESH_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 //  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 double* 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(double r,double g,double b);
83   virtual void GetFacesOrientationColor(double& r,double& g,double& b);
84
85   virtual void SetFacesOrientationScale(double theScale);
86   virtual double 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(double theMaxAngle);
97   virtual double GetQuadraticArcAngle();
98   
99   void UpdateFaceOrientation();
100
101   double GetShrinkFactor();
102   void  SetShrinkFactor(double 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 SetBallEnabled( bool );
148   void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
149   void SetMarkerTexture( int, VTK::MarkerTexture );
150   VTK::MarkerType GetMarkerType();
151   VTK::MarkerScale GetMarkerScale();
152   int GetMarkerTexture();
153
154  protected:
155   void Init(TVisualObjPtr theVisualObj, vtkImplicitBoolean* theImplicitBoolean);
156   void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid);
157
158   VTKViewer_PolyDataMapper *myMapper;
159   TVisualObjPtr myVisualObj;
160
161   vtkProperty *myProperty;
162   EReperesent myRepresentation;
163
164   SMESH_ExtractGeometry* myExtractGeometry;
165   bool myIsImplicitFunctionUsed;
166
167   vtkMergeFilter* myMergeFilter;
168   VTKViewer_ExtractUnstructuredGrid* myExtractUnstructuredGrid;
169
170   bool myIsFacesOriented;
171   SMESH_FaceOrientationFilter* myFaceOrientationFilter;
172   vtkPolyDataMapper* myFaceOrientationDataMapper;
173   vtkActor* myFaceOrientation;
174
175   bool myStoreClippingMapping;
176   VTKViewer_GeometryFilter *myGeomFilter;
177   VTKViewer_TransformFilter *myTransformFilter;
178   std::vector<vtkPassThroughFilter*> myPassFilter;
179
180   vtkShrinkFilter* myShrinkFilter;
181   bool myIsShrinkable;
182   bool myIsShrunk;
183   
184   bool myIsHighlited;
185
186   double myPolygonOffsetFactor;
187   double myPolygonOffsetUnits;
188
189   void
190   SetPolygonOffsetParameters(double factor, 
191                              double units);
192
193   void
194   GetPolygonOffsetParameters(double& factor, 
195                              double& units)
196   {
197     factor = myPolygonOffsetFactor;
198     units = myPolygonOffsetUnits;
199   }
200
201   SMESH_DeviceActor();
202   ~SMESH_DeviceActor();
203   SMESH_DeviceActor(const SMESH_DeviceActor&);
204   void operator=(const SMESH_DeviceActor&);
205
206 };
207
208
209 #endif //SMESH_DEVICE_ACTOR_H