Salome HOME
Merge with OCC_development_01
[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 class vtkProperty;
36 class vtkShrinkFilter;
37 class vtkPolyDataMapper;
38 class vtkUnstructuredGrid;
39 class vtkMergeFilter;
40 class vtkPolyData;
41
42 class vtkMapper;
43 class vtkActor2D;
44 class vtkMaskPoints;
45 class vtkCellCenters;
46 class vtkLabeledDataMapper;
47 class vtkSelectVisiblePoints;
48
49 class vtkScalarBarActor;
50 class vtkLookupTable;
51
52 class vtkPlane;
53 class vtkImplicitBoolean;
54
55 class vtkTimeStamp;
56
57 class SMESH_DeviceActor;
58
59
60 class SMESH_ActorDef : public SMESH_Actor{
61   friend class SMESH_VisualObj;
62   friend class SMESH_Actor;
63
64  public:
65   vtkTypeMacro(SMESH_ActorDef,SMESH_Actor);
66   
67   virtual void ReleaseGraphicsResources(vtkWindow *renWin);
68   virtual int RenderOpaqueGeometry(vtkViewport *viewport);
69   virtual int RenderTranslucentGeometry(vtkViewport *viewport);
70   virtual void Render(vtkRenderer *ren);
71
72   virtual void AddToRender(vtkRenderer* theRenderer); 
73   virtual void RemoveFromRender(vtkRenderer* theRenderer);
74
75   virtual bool hasHighlight() { return true; }  
76   virtual void highlight(bool theHighlight);  
77   virtual void SetPreSelected(bool thePreselect = false);
78
79   virtual bool IsInfinitive();  
80
81   virtual void SetOpacity(float theValue);
82   virtual float GetOpacity();
83
84   virtual void SetSufaceColor(float r,float g,float b);
85   virtual void GetSufaceColor(float& r,float& g,float& b);
86
87   virtual void SetBackSufaceColor(float r,float g,float b);
88   virtual void GetBackSufaceColor(float& r,float& g,float& b);
89
90   virtual void SetEdgeColor(float r,float g,float b);
91   virtual void GetEdgeColor(float& r,float& g,float& b);
92
93   virtual void SetNodeColor(float r,float g,float b);
94   virtual void GetNodeColor(float& r,float& g,float& b);
95
96   virtual void SetHighlightColor(float r,float g,float b);
97   virtual void GetHighlightColor(float& r,float& g,float& b);
98
99   virtual void SetPreHighlightColor(float r,float g,float b);
100   virtual void GetPreHighlightColor(float& r,float& g,float& b);
101  
102   virtual float GetLineWidth();
103   virtual void SetLineWidth(float theVal);
104
105   virtual void SetNodeSize(float size) ;
106   virtual float GetNodeSize() ;
107
108   virtual int GetNodeObjId(int theVtkID);
109   virtual float* GetNodeCoord(int theObjID);
110
111   virtual int GetElemObjId(int theVtkID);
112   virtual vtkCell* GetElemCell(int theObjID);
113
114   virtual int GetObjDimension( const int theObjId );
115
116   virtual void SetVisibility(int theMode);
117   void SetVisibility(int theMode, bool theIsUpdateRepersentation);
118
119   virtual void SetRepresentation(int theMode);
120   
121   virtual unsigned int GetEntityMode() const { return myEntityMode;}
122   virtual void SetEntityMode(unsigned int theMode);
123
124   virtual void SetPointRepresentation(bool theIsPointsVisible);
125   virtual bool GetPointRepresentation();
126
127   virtual float* GetBounds();
128   virtual void SetTransform(SALOME_Transform* theTransform); 
129
130   virtual vtkUnstructuredGrid* GetUnstructuredGrid();
131   virtual vtkDataSet* GetInput();
132   virtual vtkMapper* GetMapper();
133
134   virtual float GetShrinkFactor();
135   virtual void SetShrinkFactor(float theValue);
136
137   virtual bool IsShrunkable() { return myIsShrinkable;}
138   virtual bool IsShrunk() { return myIsShrunk;}
139   virtual void SetShrink(); 
140   virtual void UnShrink(); 
141
142   virtual void SetPointsLabeled(bool theIsPointsLabeled);
143   virtual bool GetPointsLabeled(){ return myIsPointsLabeled;}
144
145   virtual void SetCellsLabeled(bool theIsCellsLabeled);
146   virtual bool GetCellsLabeled(){ return myIsCellsLabeled;}
147
148   virtual void SetControlMode(eControl theMode);
149   virtual eControl GetControlMode(){ return myControlMode;}
150
151   virtual vtkScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
152
153   virtual void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane);
154   virtual void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane);
155
156   virtual vtkImplicitBoolean* GetPlaneContainer(); 
157
158   virtual TVisualObjPtr GetObject() { return myVisualObj;}
159
160   virtual void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
161   virtual long GetControlsPrecision() const { return myControlsPrecision; }
162
163  protected:
164   TVisualObjPtr myVisualObj;
165   vtkTimeStamp* myTimeStamp;
166
167   vtkScalarBarActor* myScalarBarActor;
168   vtkLookupTable* myLookupTable;
169
170   vtkProperty* mySurfaceProp;
171   vtkProperty* myBackSurfaceProp;
172   vtkProperty* myEdgeProp;
173   vtkProperty* myNodeProp;
174
175   SMESH_DeviceActor* myBaseActor;
176   SMESH_DeviceActor* myNodeActor;
177   SMESH_DeviceActor* myPickableActor;
178
179   vtkProperty* myHighlightProp;
180   vtkProperty* myPreselectProp;
181   SMESH_DeviceActor* myHighlitableActor;
182   SMESH_DeviceActor* myNodeHighlitableActor;
183
184   eControl myControlMode;
185   SMESH_DeviceActor* my2DActor;
186   SMESH_DeviceActor* my3DActor;
187   SMESH_DeviceActor* myControlActor;
188
189   vtkProperty* my1DProp;
190   SMESH_DeviceActor* my1DActor;
191   vtkProperty* my1DExtProp;
192   SMESH_DeviceActor* my1DExtActor;
193
194   unsigned int myEntityMode;
195   bool myIsPointsVisible;
196
197   bool myIsShrinkable;
198   bool myIsShrunk;
199   
200   bool myIsPointsLabeled;
201   vtkUnstructuredGrid* myPointsNumDataSet;
202   vtkActor2D *myPointLabels;
203   vtkMaskPoints* myPtsMaskPoints;
204   vtkLabeledDataMapper* myPtsLabeledDataMapper;
205   vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
206
207   bool myIsCellsLabeled;
208   vtkUnstructuredGrid* myCellsNumDataSet;
209   vtkActor2D *myCellsLabels;
210   vtkMaskPoints* myClsMaskPoints;
211   vtkCellCenters* myCellCenters;
212   vtkLabeledDataMapper* myClsLabeledDataMapper;
213   vtkSelectVisiblePoints* myClsSelectVisiblePoints;
214
215   vtkImplicitBoolean* myImplicitBoolean;
216
217   long myControlsPrecision;
218
219   SMESH_ActorDef();
220   ~SMESH_ActorDef();
221
222   bool Init(TVisualObjPtr theVisualObj, 
223             const char* theEntry, 
224             const char* theName,
225             int theIsClear);
226
227   void SetIsShrunkable(bool theShrunkable);
228   void UpdateHighlight();
229   void Update();
230
231  private:
232   // hide the two parameter Render() method from the user and the compiler.
233   virtual void Render(vtkRenderer *, vtkMapper *) {};
234   virtual void ShallowCopy(vtkProp *prop);
235   virtual void SetMapper(vtkMapper *);
236   static SMESH_ActorDef* New();
237
238   // Not implemented.
239   SMESH_ActorDef(const SMESH_ActorDef&);  
240   void operator=(const SMESH_ActorDef&);
241 };
242
243
244 #endif //SMESH_ACTORDEF_H