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