Salome HOME
Update copyright notes (for 2010)
[modules/smesh.git] / src / OBJECT / SMESH_ActorDef.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_ActorDef.h
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //
28 #ifndef SMESH_ACTORDEF_H
29 #define SMESH_ACTORDEF_H
30
31 #include "SMESH_Actor.h"
32 #include "SMESH_Object.h"
33
34 #include <vtkSmartPointer.h>
35
36 template <class T>
37 class TVTKSmartPtr: public vtkSmartPointer<T>
38 {
39 public:
40   TVTKSmartPtr() {}
41   TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer<T>(r) { 
42     if(r && theIsOwner) 
43       r->Delete();
44   }
45   TVTKSmartPtr& operator()(T* r, bool theIsOwner = false){ 
46     vtkSmartPointer<T>::operator=(r); 
47     if(r && theIsOwner) 
48       r->Delete();
49     return *this;
50   }
51   TVTKSmartPtr& operator=(T* r){ vtkSmartPointer<T>::operator=(r); return *this;}
52   T* Get() const { return this->GetPointer();}
53 };
54
55
56 class vtkProperty;
57 class vtkShrinkFilter;
58 class vtkPolyDataMapper;
59 class vtkUnstructuredGrid;
60 class vtkMergeFilter;
61 class vtkPolyData;
62
63 class vtkMapper;
64 class vtkActor2D;
65 class vtkMaskPoints;
66 class vtkCellCenters;
67 class vtkLabeledDataMapper;
68 class vtkSelectVisiblePoints;
69
70 class vtkScalarBarActor;
71 class vtkLookupTable;
72
73 class vtkPlane;
74 class vtkImplicitBoolean;
75
76 class vtkTimeStamp;
77
78 class SMESH_DeviceActor;
79
80
81 class SMESH_ActorDef : public SMESH_Actor
82 {
83   friend class SMESH_VisualObj;
84   friend class SMESH_Actor;
85
86  public:
87   vtkTypeMacro(SMESH_ActorDef,SMESH_Actor);
88   
89   virtual void ReleaseGraphicsResources(vtkWindow *renWin);
90   virtual int RenderOpaqueGeometry(vtkViewport *viewport);
91   virtual int RenderTranslucentGeometry(vtkViewport *viewport);
92   virtual void Render(vtkRenderer *ren);
93
94   virtual void AddToRender(vtkRenderer* theRenderer); 
95   virtual void RemoveFromRender(vtkRenderer* theRenderer);
96
97   virtual bool hasHighlight() { return true; }  
98   virtual void highlight(bool theHighlight);  
99   virtual void SetPreSelected(bool thePreselect = false);
100
101   virtual bool IsInfinitive();  
102
103   virtual void SetOpacity(vtkFloatingPointType theValue);
104   virtual vtkFloatingPointType GetOpacity();
105
106   virtual void SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
107   virtual void GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
108
109   virtual void SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
110   virtual void GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
111
112   virtual void SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
113   virtual void GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
114
115   virtual void SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
116   virtual void GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
117
118   virtual void Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
119   virtual void Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
120
121   virtual void SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
122   virtual void GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
123
124   virtual void SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
125   virtual void GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
126  
127   virtual vtkFloatingPointType GetLineWidth();
128   virtual void SetLineWidth(vtkFloatingPointType theVal);
129
130   virtual void Set0DSize(vtkFloatingPointType size);
131   virtual vtkFloatingPointType Get0DSize();
132
133   virtual int GetNodeObjId(int theVtkID);
134   virtual vtkFloatingPointType* GetNodeCoord(int theObjID);
135
136   virtual int GetElemObjId(int theVtkID);
137   virtual vtkCell* GetElemCell(int theObjID);
138
139   virtual int GetObjDimension( const int theObjId );
140
141   virtual void SetVisibility(int theMode);
142   void SetVisibility(int theMode, bool theIsUpdateRepersentation);
143
144   virtual void SetRepresentation(int theMode);
145   
146   virtual unsigned int GetEntityMode() const { return myEntityMode;}
147   virtual void SetEntityMode(unsigned int theMode);
148
149   virtual void SetPointRepresentation(bool theIsPointsVisible);
150   virtual bool GetPointRepresentation();
151
152   virtual vtkFloatingPointType* GetBounds();
153   virtual void SetTransform(VTKViewer_Transform* theTransform); 
154
155   virtual vtkUnstructuredGrid* GetUnstructuredGrid();
156   virtual vtkDataSet* GetInput();
157   virtual vtkMapper* GetMapper();
158
159   virtual vtkFloatingPointType GetShrinkFactor();
160   virtual void SetShrinkFactor(vtkFloatingPointType theValue);
161
162   virtual bool IsShrunkable() { return myIsShrinkable;}
163   virtual bool IsShrunk() { return myIsShrunk;}
164   virtual void SetShrink(); 
165   virtual void UnShrink(); 
166
167   virtual void SetPointsLabeled(bool theIsPointsLabeled);
168   virtual bool GetPointsLabeled(){ return myIsPointsLabeled;}
169
170   virtual void SetCellsLabeled(bool theIsCellsLabeled);
171   virtual bool GetCellsLabeled(){ return myIsCellsLabeled;}
172
173   virtual void SetFacesOriented(bool theIsFacesOriented);
174   virtual bool GetFacesOriented();
175
176   virtual void SetFacesOrientationColor(vtkFloatingPointType theColor[3]);
177   virtual void GetFacesOrientationColor(vtkFloatingPointType theColor[3]);
178
179   virtual void SetFacesOrientationScale(vtkFloatingPointType theScale);
180   virtual vtkFloatingPointType GetFacesOrientationScale();
181
182   virtual void SetFacesOrientation3DVectors(bool theState);
183   virtual bool GetFacesOrientation3DVectors();
184
185   virtual void SetControlMode(eControl theMode);
186   virtual eControl GetControlMode(){ return myControlMode;}
187
188   virtual vtkScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
189
190   virtual void SetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType theDist, vtkPlane* thePlane);
191   virtual void GetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType& theDist, vtkPlane* thePlane);
192
193   virtual void RemoveAllClippingPlanes();
194   virtual vtkIdType GetNumberOfClippingPlanes();
195   virtual vtkPlane* GetClippingPlane(vtkIdType theID);
196   virtual vtkIdType AddClippingPlane(vtkPlane* thePlane); 
197
198   virtual TVisualObjPtr GetObject() { return myVisualObj;}
199
200   virtual void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
201   virtual long GetControlsPrecision() const { return myControlsPrecision; }
202
203   virtual void UpdateScalarBar();
204
205
206   virtual void SetQuadratic2DRepresentation(EQuadratic2DRepresentation);
207   virtual EQuadratic2DRepresentation GetQuadratic2DRepresentation();
208   
209   virtual void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
210   virtual void SetMarkerTexture( int, VTK::MarkerTexture );
211
212  protected:
213   void SetControlMode(eControl theMode, bool theCheckEntityMode);
214   void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
215   bool IsImplicitFunctionUsed() const;
216
217   TVisualObjPtr myVisualObj;
218   vtkTimeStamp* myTimeStamp;
219
220   vtkScalarBarActor* myScalarBarActor;
221   vtkLookupTable* myLookupTable;
222
223   vtkProperty* mySurfaceProp;
224   vtkProperty* myBackSurfaceProp;
225   vtkProperty* myEdgeProp;
226   vtkProperty* myNodeProp;
227
228   SMESH_DeviceActor* myBaseActor;
229   SMESH_DeviceActor* myNodeActor;
230   SMESH_DeviceActor* myPickableActor;
231
232   vtkProperty* myHighlightProp;
233   vtkProperty* myPreselectProp;
234   SMESH_DeviceActor* myHighlitableActor;
235
236   eControl myControlMode;
237   vtkProperty* my2DExtProp;
238   SMESH_DeviceActor* my2DActor;
239   SMESH_DeviceActor* my2DExtActor;
240   SMESH_DeviceActor* my3DActor;
241   SMESH_DeviceActor* myControlActor;
242
243   vtkProperty* myNodeExtProp;
244   SMESH_DeviceActor* myNodeExtActor;
245
246   vtkProperty* my1DProp;
247   SMESH_DeviceActor* my1DActor;
248   vtkProperty* my1DExtProp;
249   SMESH_DeviceActor* my1DExtActor;
250
251   vtkProperty* my0DProp;
252   SMESH_DeviceActor* my0DActor;
253   vtkProperty* my0DExtProp;
254   SMESH_DeviceActor* my0DExtActor;
255
256   unsigned int myEntityMode;
257   unsigned int myEntityState;
258   bool myIsPointsVisible;
259
260   bool myIsShrinkable;
261   bool myIsShrunk;
262   
263   bool myIsPointsLabeled;
264   vtkUnstructuredGrid* myPointsNumDataSet;
265   vtkActor2D *myPointLabels;
266   vtkMaskPoints* myPtsMaskPoints;
267   vtkLabeledDataMapper* myPtsLabeledDataMapper;
268   vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
269
270   bool myIsCellsLabeled;
271   vtkUnstructuredGrid* myCellsNumDataSet;
272   vtkActor2D *myCellsLabels;
273   vtkMaskPoints* myClsMaskPoints;
274   vtkCellCenters* myCellCenters;
275   vtkLabeledDataMapper* myClsLabeledDataMapper;
276   vtkSelectVisiblePoints* myClsSelectVisiblePoints;
277
278   vtkImplicitBoolean* myImplicitBoolean;
279   typedef TVTKSmartPtr<vtkPlane> TPlanePtr;
280   typedef std::vector<TPlanePtr> TCippingPlaneCont;
281   TCippingPlaneCont myCippingPlaneCont;
282   long myControlsPrecision;
283
284   bool myIsFacesOriented;
285
286   VTK::MarkerTexture myMarkerTexture;
287
288   SMESH_ActorDef();
289   ~SMESH_ActorDef();
290
291   bool Init(TVisualObjPtr theVisualObj, 
292             const char* theEntry, 
293             const char* theName,
294             int theIsClear);
295
296   void SetIsShrunkable(bool theShrunkable);
297   void UpdateHighlight();
298   void Update();
299
300  private:
301   // hide the two parameter Render() method from the user and the compiler.
302   virtual void Render(vtkRenderer *, vtkMapper *) {};
303   virtual void ShallowCopy(vtkProp *prop);
304   virtual void SetMapper(vtkMapper *);
305   static SMESH_ActorDef* New();
306
307   // Not implemented.
308   SMESH_ActorDef(const SMESH_ActorDef&);  
309   void operator=(const SMESH_ActorDef&);
310 };
311
312
313 #endif //SMESH_ACTORDEF_H