1 // Copyright (C) 2007-2012 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 Delete();
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, int delta );
107 virtual void GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta);
109 virtual void SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
110 virtual void GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
112 virtual void SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
113 virtual void GetOutlineColor(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 SetBallColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
123 virtual void GetBallColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
125 virtual void SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
126 virtual void GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
128 virtual void SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
129 virtual void GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
131 virtual vtkFloatingPointType GetLineWidth();
132 virtual void SetLineWidth(vtkFloatingPointType theVal);
134 virtual void Set0DSize(vtkFloatingPointType size);
135 virtual vtkFloatingPointType Get0DSize();
137 virtual void SetBallSize(vtkFloatingPointType size);
138 virtual vtkFloatingPointType GetBallSize();
140 virtual int GetNodeObjId(int theVtkID);
141 virtual vtkFloatingPointType* GetNodeCoord(int theObjID);
143 virtual int GetElemObjId(int theVtkID);
144 virtual vtkCell* GetElemCell(int theObjID);
146 virtual int GetObjDimension( const int theObjId );
148 virtual void SetVisibility(int theMode);
149 void SetVisibility(int theMode, bool theIsUpdateRepersentation);
151 virtual void SetRepresentation(int theMode);
153 virtual unsigned int GetEntityMode() const { return myEntityMode;}
154 virtual void SetEntityMode(unsigned int theMode);
156 virtual void SetPointRepresentation(bool theIsPointsVisible);
157 virtual bool GetPointRepresentation();
159 virtual vtkFloatingPointType* GetBounds();
160 virtual void SetTransform(VTKViewer_Transform* theTransform);
162 virtual vtkUnstructuredGrid* GetUnstructuredGrid();
163 virtual vtkDataSet* GetInput();
164 virtual vtkMapper* GetMapper();
166 virtual vtkFloatingPointType GetShrinkFactor();
167 virtual void SetShrinkFactor(vtkFloatingPointType theValue);
169 virtual bool IsShrunkable() { return myIsShrinkable;}
170 virtual bool IsShrunk() { return myIsShrunk;}
171 virtual void SetShrink();
172 virtual void UnShrink();
174 virtual void SetPointsLabeled(bool theIsPointsLabeled);
175 virtual bool GetPointsLabeled();
177 virtual void SetCellsLabeled(bool theIsCellsLabeled);
178 virtual bool GetCellsLabeled();
180 virtual void SetFacesOriented(bool theIsFacesOriented);
181 virtual bool GetFacesOriented();
183 virtual void SetFacesOrientationColor(vtkFloatingPointType theColor[3]);
184 virtual void GetFacesOrientationColor(vtkFloatingPointType theColor[3]);
186 virtual void SetFacesOrientationScale(vtkFloatingPointType theScale);
187 virtual vtkFloatingPointType GetFacesOrientationScale();
189 virtual void SetFacesOrientation3DVectors(bool theState);
190 virtual bool GetFacesOrientation3DVectors();
192 virtual void SetControlMode(eControl theMode);
193 virtual eControl GetControlMode(){ return myControlMode;}
194 virtual SMESH::Controls::FunctorPtr GetFunctor() { return myFunctor; }
196 virtual SMESH_ScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
198 virtual void RemoveAllClippingPlanes();
199 virtual vtkIdType GetNumberOfClippingPlanes();
200 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
201 virtual vtkIdType AddClippingPlane(vtkPlane* thePlane);
203 virtual TVisualObjPtr GetObject() { return myVisualObj;}
205 virtual void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
206 virtual long GetControlsPrecision() const { return myControlsPrecision; }
208 virtual void UpdateScalarBar();
209 virtual void UpdateDistribution();
211 #ifndef DISABLE_PLOT2DVIEWER
212 virtual SPlot2d_Histogram* GetPlot2Histogram() { return my2dHistogram; }
213 virtual SPlot2d_Histogram* UpdatePlot2Histogram();
217 virtual void SetQuadratic2DRepresentation(EQuadratic2DRepresentation);
218 virtual EQuadratic2DRepresentation GetQuadratic2DRepresentation();
220 virtual void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
221 virtual void SetMarkerTexture( int, VTK::MarkerTexture );
224 void SetControlMode(eControl theMode, bool theCheckEntityMode);
225 void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
226 bool IsImplicitFunctionUsed() const;
228 TVisualObjPtr myVisualObj;
229 vtkTimeStamp* myTimeStamp;
231 SMESH_ScalarBarActor* myScalarBarActor;
232 vtkLookupTable* myLookupTable;
234 vtkProperty* mySurfaceProp;
235 vtkProperty* myBackSurfaceProp;
236 vtkProperty* myEdgeProp;
237 vtkProperty* myNodeProp;
239 SMESH_DeviceActor* myBaseActor;
240 SMESH_NodeLabelActor* myNodeActor;
241 SMESH_DeviceActor* myPickableActor;
243 vtkProperty* myHighlightProp;
244 vtkProperty* myOutLineProp;
245 vtkProperty* myPreselectProp;
247 SMESH_DeviceActor* myHighlitableActor;
249 eControl myControlMode;
250 SMESH::Controls::FunctorPtr myFunctor;
251 vtkProperty* my2DExtProp;
252 SMESH_CellLabelActor* my2DActor;
253 SMESH_DeviceActor* my2DExtActor;
254 SMESH_CellLabelActor* my3DActor;
255 SMESH_DeviceActor* my3DExtActor;
256 SMESH_DeviceActor* myControlActor;
258 vtkProperty* myNodeExtProp;
259 SMESH_DeviceActor* myNodeExtActor;
261 vtkProperty* my1DProp;
262 SMESH_CellLabelActor* my1DActor;
263 vtkProperty* my1DExtProp;
264 SMESH_DeviceActor* my1DExtActor;
266 vtkProperty* my0DProp;
267 SMESH_CellLabelActor* my0DActor;
268 vtkProperty* myBallProp;
269 SMESH_CellLabelActor* myBallActor;
270 vtkProperty* my0DExtProp;
271 SMESH_DeviceActor* my0DExtActor;
273 unsigned int myEntityMode;
274 unsigned int myEntityState;
275 unsigned int myEntityModeCache;
276 bool myIsEntityModeCache;
277 bool myIsPointsVisible;
282 vtkImplicitBoolean* myImplicitBoolean;
283 typedef TVTKSmartPtr<vtkPlane> TPlanePtr;
284 typedef std::vector<TPlanePtr> TCippingPlaneCont;
285 TCippingPlaneCont myCippingPlaneCont;
286 long myControlsPrecision;
288 #ifndef DISABLE_PLOT2DVIEWER
289 SPlot2d_Histogram* my2dHistogram;
292 bool myIsFacesOriented;
294 int myDeltaBrightness;
296 VTK::MarkerTexture myMarkerTexture;
301 bool Init(TVisualObjPtr theVisualObj,
302 const char* theEntry,
306 void SetIsShrunkable(bool theShrunkable);
307 void UpdateHighlight();
311 // hide the two parameter Render() method from the user and the compiler.
312 virtual void Render(vtkRenderer *, vtkMapper *) {};
313 virtual void ShallowCopy(vtkProp *prop);
314 virtual void SetMapper(vtkMapper *);
315 static SMESH_ActorDef* New();
318 SMESH_ActorDef(const SMESH_ActorDef&);
319 void operator=(const SMESH_ActorDef&);
323 #endif //SMESH_ACTORDEF_H