Salome HOME
Merge from V5_1_4_BR 07/05/2010
[modules/smesh.git] / src / OBJECT / SMESH_DeviceActor.h
1 //  Copyright (C) 2007-2010  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 vtkScalarBarActor;
46 class vtkLookupTable;
47 class vtkImplicitBoolean;
48 class vtkPassThroughFilter;
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
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                       vtkScalarBarActor* theScalarBarActor,
124                       vtkLookupTable* theLookupTable);
125   void SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
126                          vtkScalarBarActor* 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 void Render(vtkRenderer *, vtkMapper *);
134
135   void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
136   bool IsImplicitFunctionUsed() const{ return myIsImplicitFunctionUsed;}
137
138   void SetMarkerEnabled( bool );
139   void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
140   void SetMarkerTexture( int, VTK::MarkerTexture );
141   VTK::MarkerType GetMarkerType();
142   VTK::MarkerScale GetMarkerScale();
143   int GetMarkerTexture();
144
145  protected:
146   void Init(TVisualObjPtr theVisualObj, vtkImplicitBoolean* theImplicitBoolean);
147   void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid);
148
149   VTKViewer_PolyDataMapper *myMapper;
150   TVisualObjPtr myVisualObj;
151
152   vtkProperty *myProperty;
153   EReperesent myRepresentation;
154
155   SMESH_ExtractGeometry* myExtractGeometry;
156   bool myIsImplicitFunctionUsed;
157
158   vtkMergeFilter* myMergeFilter;
159   VTKViewer_ExtractUnstructuredGrid* myExtractUnstructuredGrid;
160
161   bool myIsFacesOriented;
162   SMESH_FaceOrientationFilter* myFaceOrientationFilter;
163   vtkPolyDataMapper* myFaceOrientationDataMapper;
164   vtkActor* myFaceOrientation;
165
166   bool myStoreClippingMapping;
167   VTKViewer_GeometryFilter *myGeomFilter;
168   VTKViewer_TransformFilter *myTransformFilter;
169   std::vector<vtkPassThroughFilter*> myPassFilter;
170
171   vtkShrinkFilter* myShrinkFilter;
172   bool myIsShrinkable;
173   bool myIsShrunk;
174   
175   bool myIsHighlited;
176
177   vtkFloatingPointType myPolygonOffsetFactor;
178   vtkFloatingPointType myPolygonOffsetUnits;
179
180   void
181   SetPolygonOffsetParameters(vtkFloatingPointType factor, 
182                              vtkFloatingPointType units);
183
184   void
185   GetPolygonOffsetParameters(vtkFloatingPointType& factor, 
186                              vtkFloatingPointType& units)
187   {
188     factor = myPolygonOffsetFactor;
189     units = myPolygonOffsetUnits;
190   }
191
192   SMESH_DeviceActor();
193   ~SMESH_DeviceActor();
194   SMESH_DeviceActor(const SMESH_DeviceActor&);
195   void operator=(const SMESH_DeviceActor&);
196
197 };
198
199
200 #endif //SMESH_DEVICE_ACTOR_H