1 // SMESH OBJECT : interactive object for SMESH visualization
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESH_ActorDef.h
25 // Author : Nicolas REJNERI
29 #ifndef SMESH_ACTORDEF_H
30 #define SMESH_ACTORDEF_H
32 #include "SMESH_Actor.h"
33 #include "SMESH_Object.h"
35 #include <vtkSmartPointer.h>
38 class TVTKSmartPtr: public vtkSmartPointer<T>
42 TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer<T>(r) {
46 TVTKSmartPtr& operator()(T* r, bool theIsOwner = false){
47 vtkSmartPointer<T>::operator=(r);
52 TVTKSmartPtr& operator=(T* r){ vtkSmartPointer<T>::operator=(r); return *this;}
53 T* Get() const { return this->GetPointer();}
58 class vtkShrinkFilter;
59 class vtkPolyDataMapper;
60 class vtkUnstructuredGrid;
68 class vtkLabeledDataMapper;
69 class vtkSelectVisiblePoints;
71 class vtkScalarBarActor;
75 class vtkImplicitBoolean;
79 class SMESH_DeviceActor;
82 class SMESH_ActorDef : public SMESH_Actor{
83 friend class SMESH_VisualObj;
84 friend class SMESH_Actor;
87 vtkTypeMacro(SMESH_ActorDef,SMESH_Actor);
89 virtual void ReleaseGraphicsResources(vtkWindow *renWin);
90 virtual int RenderOpaqueGeometry(vtkViewport *viewport);
91 virtual int RenderTranslucentGeometry(vtkViewport *viewport);
92 virtual void Render(vtkRenderer *ren);
94 virtual void AddToRender(vtkRenderer* theRenderer);
95 virtual void RemoveFromRender(vtkRenderer* theRenderer);
97 virtual bool hasHighlight() { return true; }
98 virtual void highlight(bool theHighlight);
99 virtual void SetPreSelected(bool thePreselect = false);
101 virtual bool IsInfinitive();
103 virtual void SetOpacity(float theValue);
104 virtual float GetOpacity();
106 virtual void SetSufaceColor(float r,float g,float b);
107 virtual void GetSufaceColor(float& r,float& g,float& b);
109 virtual void SetBackSufaceColor(float r,float g,float b);
110 virtual void GetBackSufaceColor(float& r,float& g,float& b);
112 virtual void SetEdgeColor(float r,float g,float b);
113 virtual void GetEdgeColor(float& r,float& g,float& b);
115 virtual void SetNodeColor(float r,float g,float b);
116 virtual void GetNodeColor(float& r,float& g,float& b);
118 virtual void SetHighlightColor(float r,float g,float b);
119 virtual void GetHighlightColor(float& r,float& g,float& b);
121 virtual void SetPreHighlightColor(float r,float g,float b);
122 virtual void GetPreHighlightColor(float& r,float& g,float& b);
124 virtual float GetLineWidth();
125 virtual void SetLineWidth(float theVal);
127 virtual void SetNodeSize(float size) ;
128 virtual float GetNodeSize() ;
130 virtual int GetNodeObjId(int theVtkID);
131 virtual float* GetNodeCoord(int theObjID);
133 virtual int GetElemObjId(int theVtkID);
134 virtual vtkCell* GetElemCell(int theObjID);
136 virtual int GetObjDimension( const int theObjId );
138 virtual void SetVisibility(int theMode);
139 void SetVisibility(int theMode, bool theIsUpdateRepersentation);
141 virtual void SetRepresentation(int theMode);
143 virtual unsigned int GetEntityMode() const { return myEntityMode;}
144 virtual void SetEntityMode(unsigned int theMode);
146 virtual void SetPointRepresentation(bool theIsPointsVisible);
147 virtual bool GetPointRepresentation();
149 virtual float* GetBounds();
150 virtual void SetTransform(VTKViewer_Transform* theTransform);
152 virtual vtkUnstructuredGrid* GetUnstructuredGrid();
153 virtual vtkDataSet* GetInput();
154 virtual vtkMapper* GetMapper();
156 virtual float GetShrinkFactor();
157 virtual void SetShrinkFactor(float theValue);
159 virtual bool IsShrunkable() { return myIsShrinkable;}
160 virtual bool IsShrunk() { return myIsShrunk;}
161 virtual void SetShrink();
162 virtual void UnShrink();
164 virtual void SetPointsLabeled(bool theIsPointsLabeled);
165 virtual bool GetPointsLabeled(){ return myIsPointsLabeled;}
167 virtual void SetCellsLabeled(bool theIsCellsLabeled);
168 virtual bool GetCellsLabeled(){ return myIsCellsLabeled;}
170 virtual void SetControlMode(eControl theMode);
171 virtual eControl GetControlMode(){ return myControlMode;}
173 virtual vtkScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
175 virtual void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane);
176 virtual void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane);
178 virtual void RemoveAllClippingPlanes();
179 virtual vtkIdType GetNumberOfClippingPlanes();
180 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
181 virtual vtkIdType AddClippingPlane(vtkPlane* thePlane);
183 virtual TVisualObjPtr GetObject() { return myVisualObj;}
185 virtual void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
186 virtual long GetControlsPrecision() const { return myControlsPrecision; }
189 void SetControlMode(eControl theMode, bool theCheckEntityMode);
190 void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
191 bool IsImplicitFunctionUsed() const;
193 TVisualObjPtr myVisualObj;
194 vtkTimeStamp* myTimeStamp;
196 vtkScalarBarActor* myScalarBarActor;
197 vtkLookupTable* myLookupTable;
199 vtkProperty* mySurfaceProp;
200 vtkProperty* myBackSurfaceProp;
201 vtkProperty* myEdgeProp;
202 vtkProperty* myNodeProp;
204 SMESH_DeviceActor* myBaseActor;
205 SMESH_DeviceActor* myNodeActor;
206 SMESH_DeviceActor* myPickableActor;
208 vtkProperty* myHighlightProp;
209 vtkProperty* myPreselectProp;
210 SMESH_DeviceActor* myHighlitableActor;
212 eControl myControlMode;
213 SMESH_DeviceActor* my2DActor;
214 SMESH_DeviceActor* my3DActor;
215 SMESH_DeviceActor* myControlActor;
217 vtkProperty* my1DProp;
218 SMESH_DeviceActor* my1DActor;
219 vtkProperty* my1DExtProp;
220 SMESH_DeviceActor* my1DExtActor;
222 unsigned int myEntityMode;
223 unsigned int myEntityState;
224 bool myIsPointsVisible;
229 bool myIsPointsLabeled;
230 vtkUnstructuredGrid* myPointsNumDataSet;
231 vtkActor2D *myPointLabels;
232 vtkMaskPoints* myPtsMaskPoints;
233 vtkLabeledDataMapper* myPtsLabeledDataMapper;
234 vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
236 bool myIsCellsLabeled;
237 vtkUnstructuredGrid* myCellsNumDataSet;
238 vtkActor2D *myCellsLabels;
239 vtkMaskPoints* myClsMaskPoints;
240 vtkCellCenters* myCellCenters;
241 vtkLabeledDataMapper* myClsLabeledDataMapper;
242 vtkSelectVisiblePoints* myClsSelectVisiblePoints;
244 vtkImplicitBoolean* myImplicitBoolean;
245 typedef TVTKSmartPtr<vtkPlane> TPlanePtr;
246 typedef std::vector<TPlanePtr> TCippingPlaneCont;
247 TCippingPlaneCont myCippingPlaneCont;
248 long myControlsPrecision;
253 bool Init(TVisualObjPtr theVisualObj,
254 const char* theEntry,
258 void SetIsShrunkable(bool theShrunkable);
259 void UpdateHighlight();
263 // hide the two parameter Render() method from the user and the compiler.
264 virtual void Render(vtkRenderer *, vtkMapper *) {};
265 virtual void ShallowCopy(vtkProp *prop);
266 virtual void SetMapper(vtkMapper *);
267 static SMESH_ActorDef* New();
270 SMESH_ActorDef(const SMESH_ActorDef&);
271 void operator=(const SMESH_ActorDef&);
275 #endif //SMESH_ACTORDEF_H