Salome HOME
0019939: EDF 762 SMESH : Definition of groups from other existing groups.
[modules/smesh.git] / src / OBJECT / SMESH_DeviceActor.h
1 //  SMESH OBJECT : interactive object for SMESH visualization
2 //
3 //  Copyright (C) 2003  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 //
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 "SMESH_Controls.hxx"
34 #include "SMESH_Object.h"
35
36 #include <vtkLODActor.h>
37 #include <vtkSmartPointer.h>
38
39 class vtkCell;
40 class vtkProperty;
41 class vtkMergeFilter;
42 class vtkShrinkFilter;
43 class vtkPolyDataMapper;
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
54 class SMESH_ExtractGeometry;
55 class SMESH_FaceOrientationFilter;
56
57
58 class SMESHOBJECT_EXPORT SMESH_DeviceActor: public vtkLODActor{
59   friend class SMESH_ActorDef;
60
61  public:
62   vtkTypeMacro(SMESH_DeviceActor,vtkLODActor);
63   static SMESH_DeviceActor* New();
64
65   void SetStoreClippingMapping(bool theStoreMapping);
66   void SetStoreGemetryMapping(bool theStoreMapping);
67   void SetStoreIDMapping(bool theStoreMapping);
68
69   virtual int GetNodeObjId(int theVtkID);
70   virtual vtkFloatingPointType* GetNodeCoord(int theObjID);
71
72   virtual int GetElemObjId(int theVtkID);
73   virtual vtkCell* GetElemCell(int theObjID);
74
75   virtual void SetTransform(VTKViewer_Transform* theTransform); 
76   virtual unsigned long int GetMTime();
77
78   virtual void SetFacesOriented(bool theIsFacesOriented);
79   virtual bool GetFacesOriented() { return myIsFacesOriented; }
80
81   void UpdateFaceOrientation();
82
83   vtkFloatingPointType GetShrinkFactor();
84   void  SetShrinkFactor(vtkFloatingPointType value);
85
86   bool IsShrunkable() { return myIsShrinkable;}
87   bool IsShrunk() { return myIsShrunk;}
88   void SetShrink(); 
89   void UnShrink(); 
90
91   enum EReperesent { ePoint, eWireframe, eSurface, eInsideframe};
92   EReperesent GetRepresentation(){ return myRepresentation;}
93   void SetRepresentation(EReperesent theMode);
94
95   virtual void SetVisibility(int theMode);
96   virtual int GetVisibility();
97
98   virtual void AddToRender(vtkRenderer* theRenderer); 
99   virtual void RemoveFromRender(vtkRenderer* theRenderer);
100
101   VTKViewer_ExtractUnstructuredGrid* GetExtractUnstructuredGrid();
102   vtkUnstructuredGrid* GetUnstructuredGrid();
103
104   void SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
105                       vtkScalarBarActor* theScalarBarActor,
106                       vtkLookupTable* theLookupTable);
107   void SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
108                          vtkScalarBarActor* theScalarBarActor,
109                          vtkLookupTable* theLookupTable);
110   void SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor);
111
112   bool IsHighlited() { return myIsHighlited;}
113   void SetHighlited(bool theIsHighlited);
114
115   virtual void Render(vtkRenderer *, vtkMapper *);
116
117   void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
118   bool IsImplicitFunctionUsed() const{ return myIsImplicitFunctionUsed;}
119
120  protected:
121   void Init(TVisualObjPtr theVisualObj, vtkImplicitBoolean* theImplicitBoolean);
122   void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid);
123
124   vtkPolyDataMapper *myMapper;
125   TVisualObjPtr myVisualObj;
126
127   vtkProperty *myProperty;
128   EReperesent myRepresentation;
129
130   SMESH_ExtractGeometry* myExtractGeometry;
131   bool myIsImplicitFunctionUsed;
132
133   vtkMergeFilter* myMergeFilter;
134   VTKViewer_ExtractUnstructuredGrid* myExtractUnstructuredGrid;
135
136   bool myIsFacesOriented;
137   SMESH_FaceOrientationFilter* myFaceOrientationFilter;
138   vtkPolyDataMapper* myFaceOrientationDataMapper;
139   vtkActor* myFaceOrientation;
140
141   bool myStoreClippingMapping;
142   VTKViewer_GeometryFilter *myGeomFilter;
143   VTKViewer_TransformFilter *myTransformFilter;
144   std::vector<vtkPassThroughFilter*> myPassFilter;
145
146   vtkShrinkFilter* myShrinkFilter;
147   bool myIsShrinkable;
148   bool myIsShrunk;
149   
150   bool myIsHighlited;
151
152   vtkFloatingPointType myPolygonOffsetFactor;
153   vtkFloatingPointType myPolygonOffsetUnits;
154
155   void
156   SetPolygonOffsetParameters(vtkFloatingPointType factor, 
157                              vtkFloatingPointType units);
158
159   void
160   GetPolygonOffsetParameters(vtkFloatingPointType& factor, 
161                              vtkFloatingPointType& units)
162   {
163     factor = myPolygonOffsetFactor;
164     units = myPolygonOffsetUnits;
165   }
166
167   SMESH_DeviceActor();
168   ~SMESH_DeviceActor();
169   SMESH_DeviceActor(const SMESH_DeviceActor&);
170   void operator=(const SMESH_DeviceActor&);
171
172 };
173
174
175 #endif //SMESH_DEVICE_ACTOR_H