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