1 // Copyright (C) 2007-2011 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;
65 class vtkLabeledDataMapper;
66 class vtkSelectVisiblePoints;
69 class vtkImplicitBoolean;
72 class VTKViewer_CellCenters;
74 class SMESH_DeviceActor;
75 class SMESH_ScalarBarActor;
77 #ifndef DISABLE_PLOT2DVIEWER
78 class SPlot2d_Histogram;
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, int delta );
108 virtual void GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta);
110 virtual void SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
111 virtual void GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
113 virtual void SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
114 virtual void GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
117 virtual void SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
118 virtual void GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
120 virtual void Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
121 virtual void Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
123 virtual void SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
124 virtual void GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
126 virtual void SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
127 virtual void GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
129 virtual vtkFloatingPointType GetLineWidth();
130 virtual void SetLineWidth(vtkFloatingPointType theVal);
132 virtual void Set0DSize(vtkFloatingPointType size);
133 virtual vtkFloatingPointType Get0DSize();
135 virtual int GetNodeObjId(int theVtkID);
136 virtual vtkFloatingPointType* GetNodeCoord(int theObjID);
138 virtual int GetElemObjId(int theVtkID);
139 virtual vtkCell* GetElemCell(int theObjID);
141 virtual int GetObjDimension( const int theObjId );
143 virtual void SetVisibility(int theMode);
144 void SetVisibility(int theMode, bool theIsUpdateRepersentation);
146 virtual void SetRepresentation(int theMode);
148 virtual unsigned int GetEntityMode() const { return myEntityMode;}
149 virtual void SetEntityMode(unsigned int theMode);
151 virtual void SetPointRepresentation(bool theIsPointsVisible);
152 virtual bool GetPointRepresentation();
154 virtual vtkFloatingPointType* GetBounds();
155 virtual void SetTransform(VTKViewer_Transform* theTransform);
157 virtual vtkUnstructuredGrid* GetUnstructuredGrid();
158 virtual vtkDataSet* GetInput();
159 virtual vtkMapper* GetMapper();
161 virtual vtkFloatingPointType GetShrinkFactor();
162 virtual void SetShrinkFactor(vtkFloatingPointType theValue);
164 virtual bool IsShrunkable() { return myIsShrinkable;}
165 virtual bool IsShrunk() { return myIsShrunk;}
166 virtual void SetShrink();
167 virtual void UnShrink();
169 virtual void SetPointsLabeled(bool theIsPointsLabeled);
170 virtual bool GetPointsLabeled(){ return myIsPointsLabeled;}
172 virtual void SetCellsLabeled(bool theIsCellsLabeled);
173 virtual bool GetCellsLabeled(){ return myIsCellsLabeled;}
175 virtual void SetFacesOriented(bool theIsFacesOriented);
176 virtual bool GetFacesOriented();
178 virtual void SetFacesOrientationColor(vtkFloatingPointType theColor[3]);
179 virtual void GetFacesOrientationColor(vtkFloatingPointType theColor[3]);
181 virtual void SetFacesOrientationScale(vtkFloatingPointType theScale);
182 virtual vtkFloatingPointType GetFacesOrientationScale();
184 virtual void SetFacesOrientation3DVectors(bool theState);
185 virtual bool GetFacesOrientation3DVectors();
187 virtual void SetControlMode(eControl theMode);
188 virtual eControl GetControlMode(){ return myControlMode;}
189 virtual SMESH::Controls::FunctorPtr GetFunctor() { return myFunctor; }
191 virtual SMESH_ScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
193 virtual void RemoveAllClippingPlanes();
194 virtual vtkIdType GetNumberOfClippingPlanes();
195 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
196 virtual vtkIdType AddClippingPlane(vtkPlane* thePlane);
198 virtual TVisualObjPtr GetObject() { return myVisualObj;}
200 virtual void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
201 virtual long GetControlsPrecision() const { return myControlsPrecision; }
203 virtual void UpdateScalarBar();
204 virtual void UpdateDistribution();
206 #ifndef DISABLE_PLOT2DVIEWER
207 virtual SPlot2d_Histogram* GetPlot2Histogram() { return my2dHistogram; }
208 virtual SPlot2d_Histogram* UpdatePlot2Histogram();
212 virtual void SetQuadratic2DRepresentation(EQuadratic2DRepresentation);
213 virtual EQuadratic2DRepresentation GetQuadratic2DRepresentation();
215 virtual void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
216 virtual void SetMarkerTexture( int, VTK::MarkerTexture );
219 void SetControlMode(eControl theMode, bool theCheckEntityMode);
220 void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
221 bool IsImplicitFunctionUsed() const;
223 TVisualObjPtr myVisualObj;
224 vtkTimeStamp* myTimeStamp;
226 SMESH_ScalarBarActor* myScalarBarActor;
227 vtkLookupTable* myLookupTable;
229 vtkProperty* mySurfaceProp;
230 vtkProperty* myBackSurfaceProp;
231 vtkProperty* myEdgeProp;
232 vtkProperty* myNodeProp;
234 SMESH_DeviceActor* myBaseActor;
235 SMESH_DeviceActor* myNodeActor;
236 SMESH_DeviceActor* myPickableActor;
238 vtkProperty* myHighlightProp;
239 vtkProperty* myOutLineProp;
240 vtkProperty* myPreselectProp;
242 SMESH_DeviceActor* myHighlitableActor;
244 eControl myControlMode;
245 SMESH::Controls::FunctorPtr myFunctor;
246 vtkProperty* my2DExtProp;
247 SMESH_DeviceActor* my2DActor;
248 SMESH_DeviceActor* my2DExtActor;
249 SMESH_DeviceActor* my3DActor;
250 SMESH_DeviceActor* my3DExtActor;
251 SMESH_DeviceActor* myControlActor;
253 vtkProperty* myNodeExtProp;
254 SMESH_DeviceActor* myNodeExtActor;
256 vtkProperty* my1DProp;
257 SMESH_DeviceActor* my1DActor;
258 vtkProperty* my1DExtProp;
259 SMESH_DeviceActor* my1DExtActor;
261 vtkProperty* my0DProp;
262 SMESH_DeviceActor* my0DActor;
263 vtkProperty* my0DExtProp;
264 SMESH_DeviceActor* my0DExtActor;
266 unsigned int myEntityMode;
267 unsigned int myEntityState;
268 bool myIsPointsVisible;
273 bool myIsPointsLabeled;
274 vtkUnstructuredGrid* myPointsNumDataSet;
275 vtkActor2D *myPointLabels;
276 vtkMaskPoints* myPtsMaskPoints;
277 vtkLabeledDataMapper* myPtsLabeledDataMapper;
278 vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
280 bool myIsCellsLabeled;
281 vtkUnstructuredGrid* myCellsNumDataSet;
282 vtkActor2D *myCellsLabels;
283 vtkMaskPoints* myClsMaskPoints;
284 VTKViewer_CellCenters* myCellCenters;
285 vtkLabeledDataMapper* myClsLabeledDataMapper;
286 vtkSelectVisiblePoints* myClsSelectVisiblePoints;
288 vtkImplicitBoolean* myImplicitBoolean;
289 typedef TVTKSmartPtr<vtkPlane> TPlanePtr;
290 typedef std::vector<TPlanePtr> TCippingPlaneCont;
291 TCippingPlaneCont myCippingPlaneCont;
292 long myControlsPrecision;
294 #ifndef DISABLE_PLOT2DVIEWER
295 SPlot2d_Histogram* my2dHistogram;
298 bool myIsFacesOriented;
300 int myDeltaBrightness;
302 VTK::MarkerTexture myMarkerTexture;
307 bool Init(TVisualObjPtr theVisualObj,
308 const char* theEntry,
312 void SetIsShrunkable(bool theShrunkable);
313 void UpdateHighlight();
317 // hide the two parameter Render() method from the user and the compiler.
318 virtual void Render(vtkRenderer *, vtkMapper *) {};
319 virtual void ShallowCopy(vtkProp *prop);
320 virtual void SetMapper(vtkMapper *);
321 static SMESH_ActorDef* New();
324 SMESH_ActorDef(const SMESH_ActorDef&);
325 void operator=(const SMESH_ActorDef&);
329 #endif //SMESH_ACTORDEF_H