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;
66 class vtkImplicitBoolean;
69 class SMESH_DeviceActor;
70 class SMESH_NodeLabelActor;
71 class SMESH_CellLabelActor;
72 class SMESH_ScalarBarActor;
74 #ifndef DISABLE_PLOT2DVIEWER
75 class SPlot2d_Histogram;
79 class SMESH_ActorDef : public SMESH_Actor
81 friend class SMESH_VisualObj;
82 friend class SMESH_Actor;
85 vtkTypeMacro(SMESH_ActorDef,SMESH_Actor);
87 virtual void ReleaseGraphicsResources(vtkWindow *renWin);
88 virtual int RenderOpaqueGeometry(vtkViewport *viewport);
89 virtual int RenderTranslucentGeometry(vtkViewport *viewport);
90 virtual void Render(vtkRenderer *ren);
92 virtual void AddToRender(vtkRenderer* theRenderer);
93 virtual void RemoveFromRender(vtkRenderer* theRenderer);
95 virtual bool hasHighlight() { return true; }
96 virtual void highlight(bool theHighlight);
97 virtual void SetPreSelected(bool thePreselect = false);
99 virtual bool IsInfinitive();
101 virtual void SetOpacity(vtkFloatingPointType theValue);
102 virtual vtkFloatingPointType GetOpacity();
104 virtual void SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta );
105 virtual void GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta);
107 virtual void SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
108 virtual void GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
110 virtual void SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
111 virtual void GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
114 virtual void SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
115 virtual void GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
117 virtual void Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
118 virtual void Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
120 virtual void SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
121 virtual void GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
123 virtual void SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
124 virtual void GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
126 virtual vtkFloatingPointType GetLineWidth();
127 virtual void SetLineWidth(vtkFloatingPointType theVal);
129 virtual void Set0DSize(vtkFloatingPointType size);
130 virtual vtkFloatingPointType Get0DSize();
132 virtual int GetNodeObjId(int theVtkID);
133 virtual vtkFloatingPointType* GetNodeCoord(int theObjID);
135 virtual int GetElemObjId(int theVtkID);
136 virtual vtkCell* GetElemCell(int theObjID);
138 virtual int GetObjDimension( const int theObjId );
140 virtual void SetVisibility(int theMode);
141 void SetVisibility(int theMode, bool theIsUpdateRepersentation);
143 virtual void SetRepresentation(int theMode);
145 virtual unsigned int GetEntityMode() const { return myEntityMode;}
146 virtual void SetEntityMode(unsigned int theMode);
148 virtual void SetPointRepresentation(bool theIsPointsVisible);
149 virtual bool GetPointRepresentation();
151 virtual vtkFloatingPointType* GetBounds();
152 virtual void SetTransform(VTKViewer_Transform* theTransform);
154 virtual vtkUnstructuredGrid* GetUnstructuredGrid();
155 virtual vtkDataSet* GetInput();
156 virtual vtkMapper* GetMapper();
158 virtual vtkFloatingPointType GetShrinkFactor();
159 virtual void SetShrinkFactor(vtkFloatingPointType theValue);
161 virtual bool IsShrunkable() { return myIsShrinkable;}
162 virtual bool IsShrunk() { return myIsShrunk;}
163 virtual void SetShrink();
164 virtual void UnShrink();
166 virtual void SetPointsLabeled(bool theIsPointsLabeled);
167 virtual bool GetPointsLabeled();
169 virtual void SetCellsLabeled(bool theIsCellsLabeled);
170 virtual bool GetCellsLabeled();
172 virtual void SetFacesOriented(bool theIsFacesOriented);
173 virtual bool GetFacesOriented();
175 virtual void SetFacesOrientationColor(vtkFloatingPointType theColor[3]);
176 virtual void GetFacesOrientationColor(vtkFloatingPointType theColor[3]);
178 virtual void SetFacesOrientationScale(vtkFloatingPointType theScale);
179 virtual vtkFloatingPointType GetFacesOrientationScale();
181 virtual void SetFacesOrientation3DVectors(bool theState);
182 virtual bool GetFacesOrientation3DVectors();
184 virtual void SetControlMode(eControl theMode);
185 virtual eControl GetControlMode(){ return myControlMode;}
186 virtual SMESH::Controls::FunctorPtr GetFunctor() { return myFunctor; }
188 virtual SMESH_ScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
190 virtual void RemoveAllClippingPlanes();
191 virtual vtkIdType GetNumberOfClippingPlanes();
192 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
193 virtual vtkIdType AddClippingPlane(vtkPlane* thePlane);
195 virtual TVisualObjPtr GetObject() { return myVisualObj;}
197 virtual void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
198 virtual long GetControlsPrecision() const { return myControlsPrecision; }
200 virtual void UpdateScalarBar();
201 virtual void UpdateDistribution();
203 #ifndef DISABLE_PLOT2DVIEWER
204 virtual SPlot2d_Histogram* GetPlot2Histogram() { return my2dHistogram; }
205 virtual SPlot2d_Histogram* UpdatePlot2Histogram();
209 virtual void SetQuadratic2DRepresentation(EQuadratic2DRepresentation);
210 virtual EQuadratic2DRepresentation GetQuadratic2DRepresentation();
212 virtual void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
213 virtual void SetMarkerTexture( int, VTK::MarkerTexture );
216 void SetControlMode(eControl theMode, bool theCheckEntityMode);
217 void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
218 bool IsImplicitFunctionUsed() const;
220 TVisualObjPtr myVisualObj;
221 vtkTimeStamp* myTimeStamp;
223 SMESH_ScalarBarActor* myScalarBarActor;
224 vtkLookupTable* myLookupTable;
226 vtkProperty* mySurfaceProp;
227 vtkProperty* myBackSurfaceProp;
228 vtkProperty* myEdgeProp;
229 vtkProperty* myNodeProp;
231 SMESH_DeviceActor* myBaseActor;
232 SMESH_NodeLabelActor* myNodeActor;
233 SMESH_DeviceActor* myPickableActor;
235 vtkProperty* myHighlightProp;
236 vtkProperty* myOutLineProp;
237 vtkProperty* myPreselectProp;
239 SMESH_DeviceActor* myHighlitableActor;
241 eControl myControlMode;
242 SMESH::Controls::FunctorPtr myFunctor;
243 vtkProperty* my2DExtProp;
244 SMESH_CellLabelActor* my2DActor;
245 SMESH_DeviceActor* my2DExtActor;
246 SMESH_CellLabelActor* my3DActor;
247 SMESH_DeviceActor* my3DExtActor;
248 SMESH_DeviceActor* myControlActor;
250 vtkProperty* myNodeExtProp;
251 SMESH_DeviceActor* myNodeExtActor;
253 vtkProperty* my1DProp;
254 SMESH_CellLabelActor* my1DActor;
255 vtkProperty* my1DExtProp;
256 SMESH_DeviceActor* my1DExtActor;
258 vtkProperty* my0DProp;
259 SMESH_CellLabelActor* my0DActor;
260 vtkProperty* my0DExtProp;
261 SMESH_DeviceActor* my0DExtActor;
263 unsigned int myEntityMode;
264 unsigned int myEntityState;
265 unsigned int myEntityModeCache;
266 bool myIsEntityModeCache;
267 bool myIsPointsVisible;
272 vtkImplicitBoolean* myImplicitBoolean;
273 typedef TVTKSmartPtr<vtkPlane> TPlanePtr;
274 typedef std::vector<TPlanePtr> TCippingPlaneCont;
275 TCippingPlaneCont myCippingPlaneCont;
276 long myControlsPrecision;
278 #ifndef DISABLE_PLOT2DVIEWER
279 SPlot2d_Histogram* my2dHistogram;
282 bool myIsFacesOriented;
284 int myDeltaBrightness;
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