1 // Copyright (C) 2007-2010 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
23 // SMESH OBJECT : interactive object for SMESH visualization
24 // File : SMESH_ActorDef.h
25 // 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;
66 class vtkLabeledDataMapper;
67 class vtkSelectVisiblePoints;
69 class vtkScalarBarActor;
73 class vtkImplicitBoolean;
77 class VTKViewer_CellCenters;
79 class SMESH_DeviceActor;
82 class SMESH_ActorDef : public SMESH_Actor
84 friend class SMESH_VisualObj;
85 friend class SMESH_Actor;
88 vtkTypeMacro(SMESH_ActorDef,SMESH_Actor);
90 virtual void ReleaseGraphicsResources(vtkWindow *renWin);
91 virtual int RenderOpaqueGeometry(vtkViewport *viewport);
92 virtual int RenderTranslucentGeometry(vtkViewport *viewport);
93 virtual void Render(vtkRenderer *ren);
95 virtual void AddToRender(vtkRenderer* theRenderer);
96 virtual void RemoveFromRender(vtkRenderer* theRenderer);
98 virtual bool hasHighlight() { return true; }
99 virtual void highlight(bool theHighlight);
100 virtual void SetPreSelected(bool thePreselect = false);
102 virtual bool IsInfinitive();
104 virtual void SetOpacity(vtkFloatingPointType theValue);
105 virtual vtkFloatingPointType GetOpacity();
107 virtual void SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
108 virtual void GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
110 virtual void SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
111 virtual void GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
113 virtual void SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
114 virtual void GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
116 virtual void SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
117 virtual void GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
119 virtual void Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
120 virtual void Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
122 virtual void SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
123 virtual void GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
125 virtual void SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
126 virtual void GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
128 virtual vtkFloatingPointType GetLineWidth();
129 virtual void SetLineWidth(vtkFloatingPointType theVal);
131 virtual void Set0DSize(vtkFloatingPointType size);
132 virtual vtkFloatingPointType Get0DSize();
134 virtual int GetNodeObjId(int theVtkID);
135 virtual vtkFloatingPointType* GetNodeCoord(int theObjID);
137 virtual int GetElemObjId(int theVtkID);
138 virtual vtkCell* GetElemCell(int theObjID);
140 virtual int GetObjDimension( const int theObjId );
142 virtual void SetVisibility(int theMode);
143 void SetVisibility(int theMode, bool theIsUpdateRepersentation);
145 virtual void SetRepresentation(int theMode);
147 virtual unsigned int GetEntityMode() const { return myEntityMode;}
148 virtual void SetEntityMode(unsigned int theMode);
150 virtual void SetPointRepresentation(bool theIsPointsVisible);
151 virtual bool GetPointRepresentation();
153 virtual vtkFloatingPointType* GetBounds();
154 virtual void SetTransform(VTKViewer_Transform* theTransform);
156 virtual vtkUnstructuredGrid* GetUnstructuredGrid();
157 virtual vtkDataSet* GetInput();
158 virtual vtkMapper* GetMapper();
160 virtual vtkFloatingPointType GetShrinkFactor();
161 virtual void SetShrinkFactor(vtkFloatingPointType theValue);
163 virtual bool IsShrunkable() { return myIsShrinkable;}
164 virtual bool IsShrunk() { return myIsShrunk;}
165 virtual void SetShrink();
166 virtual void UnShrink();
168 virtual void SetPointsLabeled(bool theIsPointsLabeled);
169 virtual bool GetPointsLabeled(){ return myIsPointsLabeled;}
171 virtual void SetCellsLabeled(bool theIsCellsLabeled);
172 virtual bool GetCellsLabeled(){ return myIsCellsLabeled;}
174 virtual void SetFacesOriented(bool theIsFacesOriented);
175 virtual bool GetFacesOriented();
177 virtual void SetFacesOrientationColor(vtkFloatingPointType theColor[3]);
178 virtual void GetFacesOrientationColor(vtkFloatingPointType theColor[3]);
180 virtual void SetFacesOrientationScale(vtkFloatingPointType theScale);
181 virtual vtkFloatingPointType GetFacesOrientationScale();
183 virtual void SetFacesOrientation3DVectors(bool theState);
184 virtual bool GetFacesOrientation3DVectors();
186 virtual void SetControlMode(eControl theMode);
187 virtual eControl GetControlMode(){ return myControlMode;}
188 virtual SMESH::Controls::FunctorPtr GetFunctor() { return myFunctor; }
190 virtual vtkScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
192 virtual void RemoveAllClippingPlanes();
193 virtual vtkIdType GetNumberOfClippingPlanes();
194 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
195 virtual vtkIdType AddClippingPlane(vtkPlane* thePlane);
197 virtual TVisualObjPtr GetObject() { return myVisualObj;}
199 virtual void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
200 virtual long GetControlsPrecision() const { return myControlsPrecision; }
202 virtual void UpdateScalarBar();
205 virtual void SetQuadratic2DRepresentation(EQuadratic2DRepresentation);
206 virtual EQuadratic2DRepresentation GetQuadratic2DRepresentation();
208 virtual void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
209 virtual void SetMarkerTexture( int, VTK::MarkerTexture );
212 void SetControlMode(eControl theMode, bool theCheckEntityMode);
213 void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
214 bool IsImplicitFunctionUsed() const;
216 TVisualObjPtr myVisualObj;
217 vtkTimeStamp* myTimeStamp;
219 vtkScalarBarActor* myScalarBarActor;
220 vtkLookupTable* myLookupTable;
222 vtkProperty* mySurfaceProp;
223 vtkProperty* myBackSurfaceProp;
224 vtkProperty* myEdgeProp;
225 vtkProperty* myNodeProp;
227 SMESH_DeviceActor* myBaseActor;
228 SMESH_DeviceActor* myNodeActor;
229 SMESH_DeviceActor* myPickableActor;
231 vtkProperty* myHighlightProp;
232 vtkProperty* myPreselectProp;
233 SMESH_DeviceActor* myHighlitableActor;
235 eControl myControlMode;
236 SMESH::Controls::FunctorPtr myFunctor;
237 vtkProperty* my2DExtProp;
238 SMESH_DeviceActor* my2DActor;
239 SMESH_DeviceActor* my2DExtActor;
240 SMESH_DeviceActor* my3DActor;
241 SMESH_DeviceActor* myControlActor;
243 vtkProperty* myNodeExtProp;
244 SMESH_DeviceActor* myNodeExtActor;
246 vtkProperty* my1DProp;
247 SMESH_DeviceActor* my1DActor;
248 vtkProperty* my1DExtProp;
249 SMESH_DeviceActor* my1DExtActor;
251 vtkProperty* my0DProp;
252 SMESH_DeviceActor* my0DActor;
253 vtkProperty* my0DExtProp;
254 SMESH_DeviceActor* my0DExtActor;
256 unsigned int myEntityMode;
257 unsigned int myEntityState;
258 bool myIsPointsVisible;
263 bool myIsPointsLabeled;
264 vtkUnstructuredGrid* myPointsNumDataSet;
265 vtkActor2D *myPointLabels;
266 vtkMaskPoints* myPtsMaskPoints;
267 vtkLabeledDataMapper* myPtsLabeledDataMapper;
268 vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
270 bool myIsCellsLabeled;
271 vtkUnstructuredGrid* myCellsNumDataSet;
272 vtkActor2D *myCellsLabels;
273 vtkMaskPoints* myClsMaskPoints;
274 VTKViewer_CellCenters* myCellCenters;
275 vtkLabeledDataMapper* myClsLabeledDataMapper;
276 vtkSelectVisiblePoints* myClsSelectVisiblePoints;
278 vtkImplicitBoolean* myImplicitBoolean;
279 typedef TVTKSmartPtr<vtkPlane> TPlanePtr;
280 typedef std::vector<TPlanePtr> TCippingPlaneCont;
281 TCippingPlaneCont myCippingPlaneCont;
282 long myControlsPrecision;
284 bool myIsFacesOriented;
286 VTK::MarkerTexture myMarkerTexture;
291 bool Init(TVisualObjPtr theVisualObj,
292 const char* theEntry,
296 void SetIsShrunkable(bool theShrunkable);
297 void UpdateHighlight();
301 // hide the two parameter Render() method from the user and the compiler.
302 virtual void Render(vtkRenderer *, vtkMapper *) {};
303 virtual void ShallowCopy(vtkProp *prop);
304 virtual void SetMapper(vtkMapper *);
305 static SMESH_ActorDef* New();
308 SMESH_ActorDef(const SMESH_ActorDef&);
309 void operator=(const SMESH_ActorDef&);
313 #endif //SMESH_ACTORDEF_H