1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH OBJECT : interactive object for SMESH visualization
23 // File : SMESH_ActorDef.h
24 // Author : Nicolas REJNERI
28 #ifndef SMESH_ACTORDEF_H
29 #define SMESH_ACTORDEF_H
31 #include "SMESH_Actor.h"
32 #include "SMESH_Object.h"
34 #include <vtkSmartPointer.h>
37 class TVTKSmartPtr: public vtkSmartPointer<T>
41 TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer<T>(r) {
45 TVTKSmartPtr& operator()(T* r, bool theIsOwner = false){
46 vtkSmartPointer<T>::operator=(r);
51 TVTKSmartPtr& operator=(T* r){ vtkSmartPointer<T>::operator=(r); return *this;}
52 T* Get() const { return this->GetPointer();}
57 class vtkShrinkFilter;
58 class vtkPolyDataMapper;
59 class vtkUnstructuredGrid;
67 class vtkLabeledDataMapper;
68 class vtkSelectVisiblePoints;
70 class vtkScalarBarActor;
74 class vtkImplicitBoolean;
78 class SMESH_DeviceActor;
81 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(vtkFloatingPointType theValue);
104 virtual vtkFloatingPointType GetOpacity();
106 virtual void SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
107 virtual void GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
109 virtual void SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
110 virtual void GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
112 virtual void SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
113 virtual void GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
115 virtual void SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
116 virtual void GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
118 virtual void SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
119 virtual void GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
121 virtual void SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
122 virtual void GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
124 virtual vtkFloatingPointType GetLineWidth();
125 virtual void SetLineWidth(vtkFloatingPointType theVal);
127 virtual void SetNodeSize(vtkFloatingPointType size) ;
128 virtual vtkFloatingPointType GetNodeSize() ;
130 virtual int GetNodeObjId(int theVtkID);
131 virtual vtkFloatingPointType* 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 vtkFloatingPointType* GetBounds();
150 virtual void SetTransform(VTKViewer_Transform* theTransform);
152 virtual vtkUnstructuredGrid* GetUnstructuredGrid();
153 virtual vtkDataSet* GetInput();
154 virtual vtkMapper* GetMapper();
156 virtual vtkFloatingPointType GetShrinkFactor();
157 virtual void SetShrinkFactor(vtkFloatingPointType 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 SetFacesOriented(bool theIsFacesOriented);
171 virtual bool GetFacesOriented();
173 virtual void SetControlMode(eControl theMode);
174 virtual eControl GetControlMode(){ return myControlMode;}
176 virtual vtkScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
178 virtual void SetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType theDist, vtkPlane* thePlane);
179 virtual void GetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType& theDist, vtkPlane* thePlane);
181 virtual void RemoveAllClippingPlanes();
182 virtual vtkIdType GetNumberOfClippingPlanes();
183 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
184 virtual vtkIdType AddClippingPlane(vtkPlane* thePlane);
186 virtual TVisualObjPtr GetObject() { return myVisualObj;}
188 virtual void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
189 virtual long GetControlsPrecision() const { return myControlsPrecision; }
191 virtual void UpdateScalarBar();
194 void SetControlMode(eControl theMode, bool theCheckEntityMode);
195 void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
196 bool IsImplicitFunctionUsed() const;
198 TVisualObjPtr myVisualObj;
199 vtkTimeStamp* myTimeStamp;
201 vtkScalarBarActor* myScalarBarActor;
202 vtkLookupTable* myLookupTable;
204 vtkProperty* mySurfaceProp;
205 vtkProperty* myBackSurfaceProp;
206 vtkProperty* myEdgeProp;
207 vtkProperty* myNodeProp;
209 SMESH_DeviceActor* myBaseActor;
210 SMESH_DeviceActor* myNodeActor;
211 SMESH_DeviceActor* myPickableActor;
213 vtkProperty* myHighlightProp;
214 vtkProperty* myPreselectProp;
215 SMESH_DeviceActor* myHighlitableActor;
217 eControl myControlMode;
218 vtkProperty* my2DExtProp;
219 SMESH_DeviceActor* my2DActor;
220 SMESH_DeviceActor* my2DExtActor;
221 SMESH_DeviceActor* my3DActor;
222 SMESH_DeviceActor* myControlActor;
224 vtkProperty* myNodeExtProp;
225 SMESH_DeviceActor* myNodeExtActor;
227 vtkProperty* my1DProp;
228 SMESH_DeviceActor* my1DActor;
229 vtkProperty* my1DExtProp;
230 SMESH_DeviceActor* my1DExtActor;
232 unsigned int myEntityMode;
233 unsigned int myEntityState;
234 bool myIsPointsVisible;
239 bool myIsPointsLabeled;
240 vtkUnstructuredGrid* myPointsNumDataSet;
241 vtkActor2D *myPointLabels;
242 vtkMaskPoints* myPtsMaskPoints;
243 vtkLabeledDataMapper* myPtsLabeledDataMapper;
244 vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
246 bool myIsCellsLabeled;
247 vtkUnstructuredGrid* myCellsNumDataSet;
248 vtkActor2D *myCellsLabels;
249 vtkMaskPoints* myClsMaskPoints;
250 vtkCellCenters* myCellCenters;
251 vtkLabeledDataMapper* myClsLabeledDataMapper;
252 vtkSelectVisiblePoints* myClsSelectVisiblePoints;
254 vtkImplicitBoolean* myImplicitBoolean;
255 typedef TVTKSmartPtr<vtkPlane> TPlanePtr;
256 typedef std::vector<TPlanePtr> TCippingPlaneCont;
257 TCippingPlaneCont myCippingPlaneCont;
258 long myControlsPrecision;
260 bool myIsFacesOriented;
265 bool Init(TVisualObjPtr theVisualObj,
266 const char* theEntry,
270 void SetIsShrunkable(bool theShrunkable);
271 void UpdateHighlight();
275 // hide the two parameter Render() method from the user and the compiler.
276 virtual void Render(vtkRenderer *, vtkMapper *) {};
277 virtual void ShallowCopy(vtkProp *prop);
278 virtual void SetMapper(vtkMapper *);
279 static SMESH_ActorDef* New();
282 SMESH_ActorDef(const SMESH_ActorDef&);
283 void operator=(const SMESH_ActorDef&);
287 #endif //SMESH_ACTORDEF_H