Version: 8.3.0
SMESH_ActorDef.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // SMESH OBJECT : interactive object for SMESH visualization
24 // File : SMESH_ActorDef.h
25 // Author : Nicolas REJNERI
26 // Module : SMESH
27 //
28 #ifndef SMESH_ACTORDEF_H
29 #define SMESH_ACTORDEF_H
30 
31 #include "SMESH_Actor.h"
32 #include "SMESH_Object.h"
33 
34 #include <vtkSmartPointer.h>
35 
36 template <class T>
37 class TVTKSmartPtr: public vtkSmartPointer<T>
38 {
39 public:
41  TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer<T>(r) {
42  if(r && theIsOwner)
43  r->Delete();
44  }
45  TVTKSmartPtr& operator()(T* r, bool theIsOwner = false){
47  if(r && theIsOwner)
48  r->Delete();
49  return *this;
50  }
52  T* Get() const { return this->GetPointer();}
53 };
54 
55 
56 class vtkProperty;
57 class vtkShrinkFilter;
58 class vtkPolyDataMapper;
60 class vtkMergeFilter;
61 class vtkPolyData;
62 class vtkMapper;
63 class vtkActor2D;
64 class vtkLookupTable;
65 class vtkPlane;
66 class vtkImplicitBoolean;
67 class vtkTimeStamp;
68 class vtkPlaneCollection;
69 
70 class SMESH_DeviceActor;
74 
75 #ifndef DISABLE_PLOT2DVIEWER
76 class SPlot2d_Histogram;
77 #endif
78 
79 
81 {
82  friend class SMESH_VisualObj;
83  friend class SMESH_Actor;
84 
85  public:
87 
88  virtual void Delete();
89 
90  virtual void ReleaseGraphicsResources(vtkWindow *renWin);
91  virtual int RenderOpaqueGeometry(vtkViewport *viewport);
92  virtual int RenderTranslucentGeometry(vtkViewport *viewport);
93  virtual void Render(vtkRenderer *ren);
94 
95  virtual void AddToRender(vtkRenderer* theRenderer);
96  virtual void RemoveFromRender(vtkRenderer* theRenderer);
97 
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);
102 
103  virtual bool IsInfinitive();
104 
105  virtual void SetOpacity(double theValue);
106  virtual double GetOpacity();
107 
108  virtual void SetSufaceColor(double r,double g,double b, int delta );
109  virtual void GetSufaceColor(double& r,double& g,double& b, int& delta);
110 
111  virtual void SetVolumeColor(double r,double g,double b, int delta );
112  virtual void GetVolumeColor(double& r,double& g,double& b, int& delta);
113 
114  virtual void SetEdgeColor(double r,double g,double b);
115  virtual void GetEdgeColor(double& r,double& g,double& b);
116 
117  virtual void SetOutlineColor(double r,double g,double b);
118  virtual void GetOutlineColor(double& r,double& g,double& b);
119 
120 
121  virtual void SetNodeColor(double r,double g,double b);
122  virtual void GetNodeColor(double& r,double& g,double& b);
123 
124  virtual void Set0DColor(double r,double g,double b);
125  virtual void Get0DColor(double& r,double& g,double& b);
126 
127  virtual void SetBallColor(double r,double g,double b);
128  virtual void GetBallColor(double& r,double& g,double& b);
129 
130  virtual void SetHighlightColor(double r,double g,double b);
131  virtual void GetHighlightColor(double& r,double& g,double& b);
132 
133  virtual void SetPreHighlightColor(double r,double g,double b);
134  virtual void GetPreHighlightColor(double& r,double& g,double& b);
135 
136  virtual double GetLineWidth();
137  virtual void SetLineWidth(double theVal);
138 
139  virtual double GetOutlineWidth();
140  virtual void SetOutlineWidth(double theVal);
141 
142  virtual void Set0DSize(double size);
143  virtual double Get0DSize();
144 
145  virtual void SetBallSize(double size);
146  virtual double GetBallSize();
147 
148  virtual void SetBallScale(double size);
149  virtual double GetBallScale();
150 
151  virtual int GetNodeObjId(int theVtkID);
152  virtual double* GetNodeCoord(int theObjID);
153 
154  virtual int GetElemObjId(int theVtkID);
155  virtual vtkCell* GetElemCell(int theObjID);
156 
157  virtual int GetObjDimension( const int theObjId );
158 
159  virtual void SetVisibility(int theMode);
160  void SetVisibility(int theMode, bool theIsUpdateRepersentation);
161 
162  virtual void SetRepresentation(int theMode);
163 
164  virtual unsigned int GetEntityMode() const { return myEntityMode;}
165  virtual void SetEntityMode(unsigned int theMode);
166 
167  virtual void SetPointRepresentation(bool theIsPointsVisible);
168  virtual bool GetPointRepresentation();
169 
170  virtual double* GetBounds();
171  virtual void SetTransform(VTKViewer_Transform* theTransform);
172 
174  virtual vtkDataSet* GetInput();
175  virtual vtkMapper* GetMapper();
176 
177  virtual double GetShrinkFactor();
178  virtual void SetShrinkFactor(double theValue);
179 
180  virtual bool IsShrunkable() { return myIsShrinkable;}
181  virtual bool IsShrunk() { return myIsShrunk;}
182  virtual void SetShrink();
183  virtual void UnShrink();
184 
185  virtual void SetPointsLabeled(bool theIsPointsLabeled);
186  virtual bool GetPointsLabeled();
187 
188  virtual void SetPointsFontProperties( SMESH::LabelFont family, int size,
189  bool bold, bool italic, bool shadow,
190  double r, double g, double b );
191  virtual void SetCellsFontProperties( SMESH::LabelFont family, int size,
192  bool bold, bool italic, bool shadow,
193  double r, double g, double b );
194 
195  virtual void SetCellsLabeled(bool theIsCellsLabeled);
196  virtual bool GetCellsLabeled();
197 
198  virtual void SetFacesOriented(bool theIsFacesOriented);
199  virtual bool GetFacesOriented();
200 
201  virtual void SetFacesOrientationColor(double r,double g,double b);
202  virtual void GetFacesOrientationColor(double& r,double& g,double& b);
203 
204  virtual void SetFacesOrientationScale(double theScale);
205  virtual double GetFacesOrientationScale();
206 
207  virtual void SetFacesOrientation3DVectors(bool theState);
208  virtual bool GetFacesOrientation3DVectors();
209 
210  virtual void SetControlMode(eControl theMode);
211  virtual int GetNumberControlEntities();
214 
216 
217  virtual void RemoveAllClippingPlanes();
218  virtual vtkIdType GetNumberOfClippingPlanes();
219  virtual vtkPlane* GetClippingPlane(vtkIdType theID);
220  virtual vtkIdType AddClippingPlane(vtkPlane* thePlane);
221  virtual void AddOpenGLClippingPlane(vtkPlane* thePlane);
222  virtual void SetOpenGLClippingPlane();
223 
224  virtual TVisualObjPtr GetObject() { return myVisualObj;}
225 
226  virtual void SetControlsPrecision( const long p ) { myControlsPrecision = p; }
227  virtual long GetControlsPrecision() const { return myControlsPrecision; }
228 
229  virtual void UpdateScalarBar();
230  virtual void UpdateDistribution();
231 
232 #ifndef DISABLE_PLOT2DVIEWER
233  virtual SPlot2d_Histogram* GetPlot2Histogram() { return my2dHistogram; }
234  virtual SPlot2d_Histogram* UpdatePlot2Histogram();
235 #endif
236 
237 
240 
241  virtual void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
242  virtual void SetMarkerTexture( int, VTK::MarkerTexture );
243 
244  protected:
245  void SetControlMode(eControl theMode, bool theCheckEntityMode);
246  void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
247  bool IsImplicitFunctionUsed() const;
248 
250  vtkTimeStamp* myTimeStamp;
251 
253  vtkLookupTable* myLookupTable;
254 
255  vtkProperty* mySurfaceProp;
256  vtkProperty* myBackSurfaceProp;
257  vtkProperty* myNormalVProp;
258  vtkProperty* myReversedVProp;
259  vtkProperty* myEdgeProp;
260  vtkProperty* myNodeProp;
261 
265 
266  vtkProperty* myHighlightProp;
267  vtkProperty* myOutLineProp;
268  vtkProperty* myPreselectProp;
269 
271 
274  vtkProperty* my2DExtProp;
275  vtkProperty* my3DExtProp;
281 
282  vtkProperty* myNodeExtProp;
284 
285  vtkProperty* my1DProp;
287  vtkProperty* my1DExtProp;
289 
290  vtkProperty* my0DProp;
292  vtkProperty* myBallProp;
294  vtkProperty* my0DExtProp;
296 
297  unsigned int myEntityMode;
298  unsigned int myEntityModeCache;
302 
305 
306  vtkImplicitBoolean* myImplicitBoolean;
307  vtkPlaneCollection* myPlaneCollection;
309  typedef std::vector<TPlanePtr> TCippingPlaneCont;
312 
313 #ifndef DISABLE_PLOT2DVIEWER
314  SPlot2d_Histogram* my2dHistogram;
315 #endif
316 
318 
321 
322  VTK::MarkerTexture myMarkerTexture;
323 
324  SMESH_ActorDef();
325  ~SMESH_ActorDef();
326 
327  bool Init(TVisualObjPtr theVisualObj,
328  const char* theEntry,
329  const char* theName,
330  int theIsClear);
331 
332  void SetIsShrunkable(bool theShrunkable);
333  void UpdateHighlight();
334  void Update();
335 
336  private:
337  // hide the two parameter Render() method from the user and the compiler.
338  virtual void Render(vtkRenderer *, vtkMapper *) {};
339  virtual void ShallowCopy(vtkProp *prop);
340  virtual void SetMapper(vtkMapper *);
341  static SMESH_ActorDef* New();
342 
343  // Not implemented.
345  void operator=(const SMESH_ActorDef&);
346 };
347 
348 
349 #endif //SMESH_ACTORDEF_H