]> SALOME platform Git repositories - modules/smesh.git/blob - src/OBJECT/SMESH_ActorDef.h
Salome HOME
Bug PAL7334 DEVELOPMENT : Control Improvement
[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   enum e1DControl{e1DNone, e1DColored, e1DHighlited};
152   e1DControl Get1DControlMode(){ return my1DColorMode;}
153
154   virtual vtkScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
155
156   virtual void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane);
157   virtual void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane);
158
159   virtual vtkImplicitBoolean* GetPlaneContainer(); 
160
161   virtual TVisualObjPtr GetObject() { return myVisualObj;}
162
163   virtual void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
164   virtual long GetControlsPrecision() const { return myControlsPrecision; }
165
166  protected:
167   TVisualObjPtr myVisualObj;
168   vtkTimeStamp* myTimeStamp;
169
170   vtkScalarBarActor* myScalarBarActor;
171   vtkLookupTable* myLookupTable;
172
173   vtkProperty* mySurfaceProp;
174   vtkProperty* myBackSurfaceProp;
175   vtkProperty* myEdgeProp;
176   vtkProperty* myNodeProp;
177
178   SMESH_DeviceActor* myBaseActor;
179   SMESH_DeviceActor* myNodeActor;
180   SMESH_DeviceActor* myPickableActor;
181
182   vtkProperty* myHighlightProp;
183   vtkProperty* myPreselectProp;
184   SMESH_DeviceActor* myHighlitableActor;
185   SMESH_DeviceActor* myNodeHighlitableActor;
186
187   eControl myControlMode;
188   SMESH_DeviceActor* my2DActor;
189   SMESH_DeviceActor* my3DActor;
190   SMESH_DeviceActor* myControlActor;
191
192   e1DControl my1DColorMode;
193   vtkProperty* my1DProp;
194   SMESH_DeviceActor* my1DActor;
195   vtkProperty* my1DExtProp;
196   SMESH_DeviceActor* my1DExtActor;
197
198   unsigned int myEntityMode;
199   bool myIsPointsVisible;
200
201   bool myIsShrinkable;
202   bool myIsShrunk;
203   
204   bool myIsPointsLabeled;
205   vtkUnstructuredGrid* myPointsNumDataSet;
206   vtkActor2D *myPointLabels;
207   vtkMaskPoints* myPtsMaskPoints;
208   vtkLabeledDataMapper* myPtsLabeledDataMapper;
209   vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
210
211   bool myIsCellsLabeled;
212   vtkUnstructuredGrid* myCellsNumDataSet;
213   vtkActor2D *myCellsLabels;
214   vtkMaskPoints* myClsMaskPoints;
215   vtkCellCenters* myCellCenters;
216   vtkLabeledDataMapper* myClsLabeledDataMapper;
217   vtkSelectVisiblePoints* myClsSelectVisiblePoints;
218
219   vtkImplicitBoolean* myImplicitBoolean;
220
221   long myControlsPrecision;
222
223   SMESH_ActorDef();
224   ~SMESH_ActorDef();
225
226   bool Init(TVisualObjPtr theVisualObj, 
227             const char* theEntry, 
228             const char* theName,
229             int theIsClear);
230
231   void SetIsShrunkable(bool theShrunkable);
232   void UpdateHighlight();
233   void Update();
234
235  private:
236   // hide the two parameter Render() method from the user and the compiler.
237   virtual void Render(vtkRenderer *, vtkMapper *) {};
238   virtual void ShallowCopy(vtkProp *prop);
239   virtual void SetMapper(vtkMapper *);
240   static SMESH_ActorDef* New();
241
242   // Not implemented.
243   SMESH_ActorDef(const SMESH_ActorDef&);  
244   void operator=(const SMESH_ActorDef&);
245 };
246
247
248 #endif //SMESH_ACTORDEF_H