Salome HOME
0020279: [CEA 334] control the "random" use when using mesh algorithms
[modules/smesh.git] / src / OBJECT / SMESH_DeviceActor.h
1 //  Copyright (C) 2007-2008  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 //  SMESH OBJECT : interactive object for SMESH visualization
23 //  File   : SMESH_DeviceActor.h
24 //  Author : Nicolas REJNERI
25 //  Module : SMESH
26 //  $Header$
27 //
28 #ifndef SMESH_DEVICE_ACTOR_H
29 #define SMESH_DEVICE_ACTOR_H
30
31 #include <VTKViewer_GeometryFilter.h>
32 #include "SMESH_Controls.hxx"
33 #include "SMESH_Object.h"
34
35 #include <vtkLODActor.h>
36 #include <vtkSmartPointer.h>
37
38 class vtkCell;
39 class vtkProperty;
40 class vtkMergeFilter;
41 class vtkShrinkFilter;
42 class vtkPolyDataMapper;
43 class vtkUnstructuredGrid;
44 class vtkScalarBarActor;
45 class vtkLookupTable;
46 class vtkImplicitBoolean;
47 class vtkPassThroughFilter;
48
49 class VTKViewer_Transform;
50 class VTKViewer_TransformFilter;
51 class VTKViewer_ExtractUnstructuredGrid;
52
53 class SMESH_ExtractGeometry;
54
55
56 class SMESHOBJECT_EXPORT SMESH_DeviceActor: public vtkLODActor{
57   friend class SMESH_ActorDef;
58
59  public:
60   vtkTypeMacro(SMESH_DeviceActor,vtkLODActor);
61   static SMESH_DeviceActor* New();
62
63   void SetStoreClippingMapping(bool theStoreMapping);
64   void SetStoreGemetryMapping(bool theStoreMapping);
65   void SetStoreIDMapping(bool theStoreMapping);
66
67   virtual int GetNodeObjId(int theVtkID);
68   virtual vtkFloatingPointType* GetNodeCoord(int theObjID);
69
70   virtual int GetElemObjId(int theVtkID);
71   virtual vtkCell* GetElemCell(int theObjID);
72
73   virtual void SetTransform(VTKViewer_Transform* theTransform); 
74   virtual unsigned long int GetMTime();
75
76   vtkFloatingPointType GetShrinkFactor();
77   void  SetShrinkFactor(vtkFloatingPointType value);
78
79   bool IsShrunkable() { return myIsShrinkable;}
80   bool IsShrunk() { return myIsShrunk;}
81   void SetShrink(); 
82   void UnShrink(); 
83
84   enum EReperesent { ePoint, eWireframe, eSurface, eInsideframe};
85   EReperesent GetRepresentation(){ return myRepresentation;}
86   void SetRepresentation(EReperesent theMode);
87
88   virtual void SetVisibility(int theMode);
89   virtual int GetVisibility();
90
91   VTKViewer_ExtractUnstructuredGrid* GetExtractUnstructuredGrid();
92   vtkUnstructuredGrid* GetUnstructuredGrid();
93
94   void SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
95                       vtkScalarBarActor* theScalarBarActor,
96                       vtkLookupTable* theLookupTable);
97   void SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
98                          vtkScalarBarActor* theScalarBarActor,
99                          vtkLookupTable* theLookupTable);
100   void SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor);
101
102   bool IsHighlited() { return myIsHighlited;}
103   void SetHighlited(bool theIsHighlited);
104
105   virtual void Render(vtkRenderer *, vtkMapper *);
106
107   void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
108   bool IsImplicitFunctionUsed() const{ return myIsImplicitFunctionUsed;}
109
110  protected:
111   void Init(TVisualObjPtr theVisualObj, vtkImplicitBoolean* theImplicitBoolean);
112   void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid);
113
114   vtkPolyDataMapper *myMapper;
115   TVisualObjPtr myVisualObj;
116
117   vtkProperty *myProperty;
118   EReperesent myRepresentation;
119
120   SMESH_ExtractGeometry* myExtractGeometry;
121   bool myIsImplicitFunctionUsed;
122
123   vtkMergeFilter* myMergeFilter;
124   VTKViewer_ExtractUnstructuredGrid* myExtractUnstructuredGrid;
125
126   bool myStoreClippingMapping;
127   VTKViewer_GeometryFilter *myGeomFilter;
128   VTKViewer_TransformFilter *myTransformFilter;
129   std::vector<vtkPassThroughFilter*> myPassFilter;
130
131   vtkShrinkFilter* myShrinkFilter;
132   bool myIsShrinkable;
133   bool myIsShrunk;
134   
135   bool myIsHighlited;
136
137   vtkFloatingPointType myPolygonOffsetFactor;
138   vtkFloatingPointType myPolygonOffsetUnits;
139
140   void
141   SetPolygonOffsetParameters(vtkFloatingPointType factor, 
142                              vtkFloatingPointType units);
143
144   void
145   GetPolygonOffsetParameters(vtkFloatingPointType& factor, 
146                              vtkFloatingPointType& units)
147   {
148     factor = myPolygonOffsetFactor;
149     units = myPolygonOffsetUnits;
150   }
151
152   SMESH_DeviceActor();
153   ~SMESH_DeviceActor();
154   SMESH_DeviceActor(const SMESH_DeviceActor&);
155   void operator=(const SMESH_DeviceActor&);
156
157 };
158
159
160 #endif //SMESH_DEVICE_ACTOR_H