1 // Copyright (C) 2007-2024 CEA, EDF, 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, or (at your option) any later version.
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;
68 class vtkPlaneCollection;
70 class SMESH_DeviceActor;
71 class SMESH_NodeLabelActor;
72 class SMESH_CellLabelActor;
73 class SMESH_ScalarBarActor;
75 #ifndef DISABLE_PLOT2DVIEWER
76 class SPlot2d_Histogram;
80 class SMESH_ActorDef : public SMESH_Actor
82 friend class SMESH_VisualObj;
83 friend class SMESH_Actor;
86 vtkTypeMacro(SMESH_ActorDef,SMESH_Actor)
88 virtual void Delete();
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 void EnableSelection( bool enable );
99 virtual bool hasHighlight() { return true; }
100 virtual void highlight(bool theHighlight);
101 virtual void SetPreSelected(bool thePreselect = false);
103 virtual bool IsInfinitive();
105 virtual void SetOpacity(double theValue);
106 virtual double GetOpacity();
108 virtual void SetSufaceColor(double r,double g,double b, int delta );
109 virtual void GetSufaceColor(double& r,double& g,double& b, int& delta);
111 virtual void SetVolumeColor(double r,double g,double b, int delta );
112 virtual void GetVolumeColor(double& r,double& g,double& b, int& delta);
114 virtual void SetEdgeColor(double r,double g,double b);
115 virtual void GetEdgeColor(double& r,double& g,double& b);
117 virtual void SetOutlineColor(double r,double g,double b);
118 virtual void GetOutlineColor(double& r,double& g,double& b);
121 virtual void SetNodeColor(double r,double g,double b);
122 virtual void GetNodeColor(double& r,double& g,double& b);
124 virtual void Set0DColor(double r,double g,double b);
125 virtual void Get0DColor(double& r,double& g,double& b);
127 virtual void SetBallColor(double r,double g,double b);
128 virtual void GetBallColor(double& r,double& g,double& b);
130 virtual void UpdateSelectionProps();
132 virtual double GetLineWidth();
133 virtual void SetLineWidth(double theVal);
135 virtual double GetOutlineWidth();
136 virtual void SetOutlineWidth(double theVal);
138 virtual void Set0DSize(double size);
139 virtual double Get0DSize();
141 virtual void SetBallSize(double size);
142 virtual double GetBallSize();
144 virtual void SetBallScale(double size);
145 virtual double GetBallScale();
147 virtual vtkIdType GetNodeObjId(vtkIdType theVtkID);
148 virtual double* GetNodeCoord(vtkIdType theObjID);
149 virtual vtkIdType GetNodeVtkId(vtkIdType theObjID);
151 virtual vtkIdType GetElemObjId(vtkIdType theVtkID);
152 virtual vtkCell* GetElemCell(vtkIdType theObjID);
154 virtual int GetObjDimension( const vtkIdType theObjId ) override;
156 virtual void SetVisibility(int theMode);
157 void SetVisibility(int theMode, bool theIsUpdateRepersentation);
159 virtual void SetRepresentation(int theMode);
161 virtual unsigned int GetEntityMode() const { return myEntityMode;}
162 virtual void SetEntityMode(unsigned int theMode);
164 virtual void SetPointRepresentation(bool theIsPointsVisible);
165 virtual bool GetPointRepresentation();
167 virtual double* GetBounds();
168 virtual void SetTransform(VTKViewer_Transform* theTransform);
170 virtual vtkUnstructuredGrid* GetUnstructuredGrid();
171 virtual vtkDataSet* GetInput();
172 virtual vtkMapper* GetMapper();
174 virtual double GetShrinkFactor();
175 virtual void SetShrinkFactor(double theValue);
177 virtual bool IsShrunkable() { return myIsShrinkable;}
178 virtual bool IsShrunk() { return myIsShrunk;}
179 virtual void SetShrink();
180 virtual void UnShrink();
182 virtual void SetPointsLabeled(bool theIsPointsLabeled);
183 virtual bool GetPointsLabeled();
185 virtual void SetPointsFontProperties( SMESH::LabelFont family, int size,
186 bool bold, bool italic, bool shadow,
187 double r, double g, double b );
188 virtual void SetCellsFontProperties( SMESH::LabelFont family, int size,
189 bool bold, bool italic, bool shadow,
190 double r, double g, double b );
192 virtual void SetCellsLabeled(bool theIsCellsLabeled);
193 virtual bool GetCellsLabeled();
195 virtual void SetFacesOriented(bool theIsFacesOriented);
196 virtual bool GetFacesOriented();
198 virtual void SetFacesOrientationColor(double r,double g,double b);
199 virtual void GetFacesOrientationColor(double& r,double& g,double& b);
201 virtual void SetFacesOrientationScale(double theScale);
202 virtual double GetFacesOrientationScale();
204 virtual void SetFacesOrientation3DVectors(bool theState);
205 virtual bool GetFacesOrientation3DVectors();
207 virtual void SetControlMode(eControl theMode);
208 virtual void SetControl(SMESH::Controls::FunctorPtr theFunctor);
209 virtual smIdType GetNumberControlEntities();
210 virtual eControl GetControlMode(){ return myControlMode;}
211 virtual SMESH::Controls::FunctorPtr GetFunctor() { return myFunctor; }
213 virtual SMESH_ScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;}
215 virtual void RemoveAllClippingPlanes();
216 virtual vtkIdType GetNumberOfClippingPlanes();
217 virtual vtkPlane* GetClippingPlane(vtkIdType theID);
218 virtual vtkIdType AddClippingPlane(vtkPlane* thePlane);
219 virtual void AddOpenGLClippingPlane(vtkPlane* thePlane);
220 virtual void SetOpenGLClippingPlane();
222 virtual TVisualObjPtr GetObject() { return myVisualObj;}
224 virtual void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
225 virtual long GetControlsPrecision() const { return myControlsPrecision; }
227 virtual void UpdateScalarBar();
228 virtual void UpdateDistribution();
229 virtual SMESH_DeviceActor* GetActorForThreshold();
230 virtual void ClipThreshold(bool isThresholdOn, double min = 0.0, double max = 0.0);
231 virtual bool IsClipThresholdOn() const { return myIsClipThresholdOn; }
232 virtual void SetWireframeOff(bool isWireframeOff);
233 virtual bool IsWireframeOff() const { return myIsWireframeOff; }
235 #ifndef DISABLE_PLOT2DVIEWER
236 virtual SPlot2d_Histogram* GetPlot2Histogram() { return my2dHistogram; }
237 virtual SPlot2d_Histogram* UpdatePlot2Histogram();
241 virtual void SetQuadratic2DRepresentation(EQuadratic2DRepresentation);
242 virtual EQuadratic2DRepresentation GetQuadratic2DRepresentation();
244 virtual void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
245 virtual void SetMarkerTexture( int, VTK::MarkerTexture );
247 virtual void UpdateFilter();
250 void SetControlMode(eControl theMode, bool theCheckEntityMode);
251 void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
252 bool IsImplicitFunctionUsed() const;
254 TVisualObjPtr myVisualObj;
255 vtkTimeStamp* myTimeStamp;
257 SMESH_ScalarBarActor* myScalarBarActor;
258 vtkLookupTable* myLookupTable;
260 vtkProperty* mySurfaceProp;
261 vtkProperty* myBackSurfaceProp;
262 vtkProperty* myNormalVProp;
263 vtkProperty* myReversedVProp;
264 vtkProperty* myEdgeProp;
265 vtkProperty* myNodeProp;
267 SMESH_DeviceActor* myBaseActor;
268 SMESH_NodeLabelActor* myNodeActor;
269 SMESH_DeviceActor* myPickableActor;
271 vtkProperty* myHighlightProp;
272 vtkProperty* myOutLineProp;
273 vtkProperty* myPreselectProp;
275 SMESH_DeviceActor* myHighlitableActor;
277 eControl myControlMode;
278 SMESH::Controls::FunctorPtr myFunctor;
279 vtkProperty* my2DExtProp;
280 vtkProperty* my3DExtProp;
281 SMESH_CellLabelActor* my2DActor;
282 SMESH_DeviceActor* my2DExtActor;
283 SMESH_CellLabelActor* my3DActor;
284 SMESH_DeviceActor* my3DExtActor;
285 SMESH_DeviceActor* myControlActor;
287 vtkProperty* myNodeExtProp;
288 SMESH_DeviceActor* myNodeExtActor;
290 vtkProperty* my1DProp;
291 SMESH_CellLabelActor* my1DActor;
292 vtkProperty* my1DExtProp;
293 SMESH_DeviceActor* my1DExtActor;
295 vtkProperty* my0DProp;
296 SMESH_CellLabelActor* my0DActor;
297 vtkProperty* myBallProp;
298 SMESH_CellLabelActor* myBallActor;
299 vtkProperty* my0DExtProp;
300 SMESH_DeviceActor* my0DExtActor;
302 unsigned int myEntityMode;
303 unsigned int myEntityModeCache;
304 unsigned int objectEntitiesCache;
305 int myRepresentationCache;
306 bool myIsEntityModeCache;
307 bool myIsPointsVisible;
308 bool myIsClipThresholdOn = false;
309 bool myIsWireframeOff = false;
314 vtkImplicitBoolean* myImplicitBoolean;
315 vtkPlaneCollection* myPlaneCollection;
316 typedef TVTKSmartPtr<vtkPlane> TPlanePtr;
317 typedef std::vector<TPlanePtr> TCippingPlaneCont;
318 TCippingPlaneCont myCippingPlaneCont;
319 long myControlsPrecision;
321 #ifndef DISABLE_PLOT2DVIEWER
322 SPlot2d_Histogram* my2dHistogram;
325 bool myIsFacesOriented;
327 int myDeltaBrightness;
328 int myDeltaVBrightness;
330 VTK::MarkerTexture myMarkerTexture;
335 bool Init(TVisualObjPtr theVisualObj,
336 const char* theEntry,
340 void SetIsShrunkable(bool theShrunkable);
341 void UpdateHighlight();
345 // hide the two parameter Render() method from the user and the compiler.
346 virtual void Render(vtkRenderer *, vtkMapper *) {};
347 virtual void ShallowCopy(vtkProp *prop);
348 virtual void SetMapper(vtkMapper *);
349 static SMESH_ActorDef* New();
352 SMESH_ActorDef(const SMESH_ActorDef&);
353 void operator=(const SMESH_ActorDef&);
357 #endif //SMESH_ACTORDEF_H