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