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