Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/smesh.git] / src / OBJECT / SMESH_Actor.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_Actor.h
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //  $Header$
28
29 #ifndef SMESH_ACTOR_H
30 #define SMESH_ACTOR_H
31
32 #include "SALOME_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 vtkLabeledDataMapper;
46 class vtkSelectVisiblePoints;
47
48 class vtkScalarBarActor;
49 class vtkLookupTable;
50
51 class SMESH_DeviceActor;
52 class SALOME_ExtractUnstructuredGrid;
53
54
55 class SMESH_Actor : public SALOME_Actor{
56   friend class SMESH_VisualObj;
57
58  public:
59   vtkTypeMacro(SMESH_Actor,SALOME_Actor);
60   static SMESH_Actor* New(TVisualObjPtr theVisualObj, 
61                           SMESH::FilterManager_ptr theFilterMgr,
62                           const char* theEntry, 
63                           const char* theName,
64                           int theIsClear);
65   
66   virtual void ReleaseGraphicsResources(vtkWindow *renWin);
67   virtual int RenderOpaqueGeometry(vtkViewport *viewport);
68   virtual int RenderTranslucentGeometry(vtkViewport *viewport);
69   virtual void Render(vtkRenderer *ren);
70
71   virtual void AddToRender(vtkRenderer* theRenderer); 
72   virtual void RemoveFromRender(vtkRenderer* theRenderer);
73
74   virtual bool hasHighlight() { return true; }  
75   virtual void highlight(Standard_Boolean highlight);  
76   virtual void SetPreSelected(Standard_Boolean presel = Standard_False);
77
78   virtual bool IsInfinitive();  
79
80   virtual void SetOpacity(float theValue);
81   virtual float GetOpacity();
82
83   void SetSufaceColor(float r,float g,float b);
84   void GetSufaceColor(float& r,float& g,float& b);
85
86   void SetBackSufaceColor(float r,float g,float b);
87   void GetBackSufaceColor(float& r,float& g,float& b);
88
89   void SetEdgeColor(float r,float g,float b);
90   void GetEdgeColor(float& r,float& g,float& b);
91
92   void SetNodeColor(float r,float g,float b);
93   void GetNodeColor(float& r,float& g,float& b);
94
95   void SetHighlightColor(float r,float g,float b);
96   void GetHighlightColor(float& r,float& g,float& b);
97
98   void SetPreHighlightColor(float r,float g,float b);
99   void GetPreHighlightColor(float& r,float& g,float& b);
100  
101   float GetLineWidth();
102   void SetLineWidth(float theVal);
103
104   void SetNodeSize(float size) ;
105   float GetNodeSize() ;
106
107   virtual int GetObjId(int theVtkID);
108   virtual TVectorId GetVtkId(int theObjID);
109
110   virtual int GetNodeObjId(int theVtkID);
111   virtual TVectorId GetNodeVtkId(int theObjID);
112
113   virtual int GetElemObjId(int theVtkID);
114   virtual TVectorId GetElemVtkId(int theObjID);
115
116   virtual int GetObjDimension( const int theObjId );
117
118   virtual void SetVisibility(int theMode);
119
120   enum EReperesent { ePoint, eEdge, eSurface};
121   virtual void SetRepresentation(int theMode);
122   void SetPointRepresentation(int theIsPointsVisible);
123   bool GetPointRepresentation(){ return myIsPointsVisible;}
124
125   virtual vtkPolyData* GetPolyDataInput(); 
126   virtual void SetTransform(SALOME_Transform* theTransform); 
127
128   vtkUnstructuredGrid* GetUnstructuredGrid();
129   virtual vtkMapper* GetMapper();
130
131   float GetShrinkFactor();
132   void  SetShrinkFactor(float value );
133
134   bool IsShrunkable() { return myIsShrinkable;}
135   bool IsShrunk() { return myIsShrunk;}
136   void SetShrink(); 
137   void UnShrink(); 
138
139   void SetPointsLabeled(bool theIsPointsLabeled);
140   bool GetPointsLabeled(){ return myIsPointsLabeled;}
141
142   void SetCellsLabeled(bool theIsCellsLabeled);
143   bool GetCellsLabeled(){ return myIsCellsLabeled;}
144
145   enum eControl{eNone, eLengthEdges, eFreeBorders, eMultiConnection, 
146                 eArea, eTaper, eAspectRatio, eMinimumAngle, eWarping, eSkew};
147   void SetControlMode(eControl theMode);
148   eControl GetControlMode(){ return myColorMode;}
149
150   enum e1DControl{e1DNone, e1DColored, e1DHighlited};
151   e1DControl Get1DControlMode(){ return my1DColorMode;}
152
153   vtkScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
154
155   TVisualObjPtr GetObject() { return myVisualObj;}
156
157  protected:
158   TVisualObjPtr myVisualObj;
159
160   SMESH::FilterManager_var myFilterMgr;
161   vtkScalarBarActor* myScalarBarActor;
162   vtkLookupTable* myLookupTable;
163
164   vtkProperty* mySurfaceProp;
165   vtkProperty* myBackSurfaceProp;
166   vtkProperty* myEdgeProp;
167   vtkProperty* myNodeProp;
168
169   SMESH_DeviceActor* myBaseActor;
170   SMESH_DeviceActor* myNodeActor;
171   SMESH_DeviceActor* myPickableActor;
172
173   vtkProperty* myHighlightProp;
174   vtkProperty* myPreselectProp;
175   SMESH_DeviceActor* myHighlitableActor;
176
177   eControl myColorMode;
178   SMESH_DeviceActor* my2DActor;
179   SMESH_DeviceActor* my3DActor;
180   SMESH_DeviceActor* myControlActor;
181
182   e1DControl my1DColorMode;
183   vtkProperty* my1DProp;
184   SMESH_DeviceActor* my1DActor;
185   vtkProperty* my1DExtProp;
186   SMESH_DeviceActor* my1DExtActor;
187
188   bool myIsPointsVisible;
189
190   bool myIsShrinkable;
191   bool myIsShrunk;
192   
193   bool myIsPointsLabeled;
194   vtkUnstructuredGrid* myPointsNumDataSet;
195   vtkActor2D *myPointLabels;
196   vtkMaskPoints* myPtsMaskPoints;
197   vtkLabeledDataMapper* myPtsLabeledDataMapper;
198   vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
199
200   bool myIsCellsLabeled;
201   vtkUnstructuredGrid* myCellsNumDataSet;
202   vtkActor2D *myCellsLabels;
203   vtkMaskPoints* myClsMaskPoints;
204   vtkCellCenters* myCellCenters;
205   vtkLabeledDataMapper* myClsLabeledDataMapper;
206   vtkSelectVisiblePoints* myClsSelectVisiblePoints;
207
208   SMESH_Actor();
209   ~SMESH_Actor();
210
211   void Init(TVisualObjPtr theVisualObj, 
212             SMESH::FilterManager_ptr theFilterMgr,
213             const char* theEntry, 
214             const char* theName,
215             int theIsClear);
216
217   void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid);
218   void SetIsShrunkable(bool theShrunkable);
219   void UpdateHighlight();
220
221  private:
222   // hide the two parameter Render() method from the user and the compiler.
223   virtual void Render(vtkRenderer *, vtkMapper *) {};
224   virtual void ShallowCopy(vtkProp *prop);
225   virtual void SetMapper(vtkMapper *);
226   static SMESH_Actor* New();
227
228   // Not implemented.
229   SMESH_Actor(const SMESH_Actor&);  
230   void operator=(const SMESH_Actor&);
231 };
232
233
234 #endif //SMESH_ACTOR_H