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