Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VTKViewer_Actor.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 // SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
24 // File : SALOME_Actor.h
25 // Author : Nicolas REJNERI
26 
27 #ifndef VTKVIEVER_ACTOR_H
28 #define VTKVIEVER_ACTOR_H
29 
30 #include "VTKViewer.h"
31 
32 #include <string>
33 #include <vector>
34 
35 #include <vtkLODActor.h>
36 #include <vtkProperty.h>
37 
38 class vtkCell;
39 class vtkPointPicker;
40 class vtkCellPicker;
41 class vtkDataSet;
42 class vtkCamera;
43 class vtkProperty;
44 class vtkRenderer;
45 class vtkPassThroughFilter;
46 
50 
51 extern int VTKViewer_POINT_SIZE;
52 extern int VTKViewer_LINE_WIDTH;
53 
54 namespace VTKViewer
55 {
56  namespace Representation
57  {
58  typedef int Type;
59  const Type Points = VTK_POINTS;
60  const Type Wireframe = VTK_WIREFRAME;
61  const Type Surface = VTK_SURFACE;
62  const Type Insideframe = Surface + 1;
64  }
65 }
66 
67 #ifdef WIN32
68 #pragma warning ( disable:4251 )
69 #endif
70 
75 {
76  public:
77  static VTKViewer_Actor* New();
78 
79  vtkTypeMacro(VTKViewer_Actor,vtkLODActor);
80 
81  //----------------------------------------------------------------------------
83  virtual
84  const char*
85  getName();
86 
88  virtual
89  void
90  setName(const char* theName);
91 
92  //----------------------------------------------------------------------------
94  virtual
95  void
96  SetOpacity(double theOpacity);
97 
99  virtual
100  double
101  GetOpacity();
102 
104  virtual
105  void
106  SetColor(double r,
107  double g,
108  double b);
109 
111  virtual
112  void
113  GetColor(double& r,
114  double& g,
115  double& b);
116 
118  virtual
119  void
120  SetColor(const double theRGB[3]);
121 
123  virtual
124  void
125  SetMaterial(std::vector<vtkProperty*> theProps);
126 
128  virtual
129  vtkProperty*
130  GetFrontMaterial();
131 
133  virtual
134  vtkProperty*
135  GetBackMaterial();
136 
137  //----------------------------------------------------------------------------
138  // For selection mapping purpose
140  virtual
141  int
142  GetNodeObjId(int theVtkID);
143 
145  virtual
146  double*
147  GetNodeCoord(int theObjID);
148 
150  virtual
151  int
152  GetElemObjId(int theVtkID);
153 
155  virtual
156  vtkCell*
157  GetElemCell(int theObjID);
158 
159  //----------------------------------------------------------------------------
161  virtual
162  int
163  GetObjDimension( const int theObjId );
164 
166  virtual
167  void
168  SetMapper(vtkMapper* theMapper);
169 
171  virtual
172  vtkDataSet*
173  GetInput();
174 
176  virtual
177  void
178  SetTransform(VTKViewer_Transform* theTransform);
179 
181  virtual
183  GetMTime();
184 
185  //----------------------------------------------------------------------------
187  virtual
188  void
189  SetRepresentation(int theMode);
190 
192  virtual
193  int
194  GetRepresentation();
195 
197  virtual
198  int
199  getDisplayMode();
200 
202  virtual
203  void
204  setDisplayMode(int theMode);
205 
206  //----------------------------------------------------------------------------
208 
212  void
213  SetInfinitive(bool theIsInfinite);
214 
216  virtual
217  bool
218  IsInfinitive();
219 
221  virtual
222  double*
223  GetBounds();
224 
226  void
227  GetBounds(double bounds[6]);
228 
229  //----------------------------------------------------------------------------
230  virtual
231  bool
232  IsSetCamera() const;
233 
234  virtual
235  bool
236  IsResizable() const;
237 
238  virtual
239  void
240  SetSize( const double );
241 
242  virtual
243  void
244  SetCamera( vtkCamera* );
245 
246  //----------------------------------------------------------------------------
248  void
249  SetResolveCoincidentTopology(bool theIsResolve);
250 
252  void
253  SetPolygonOffsetParameters(double factor,
254  double units);
255 
257  void
258  GetPolygonOffsetParameters(double& factor,
259  double& units);
260 
261  virtual
262  void
263  Render(vtkRenderer *, vtkMapper *);
264 
265  //----------------------------------------------------------------------------
267  virtual
268  double
269  GetShrinkFactor();
270 
272  virtual
273  bool
274  IsShrunkable();
275 
277  virtual
278  bool
279  IsShrunk();
280 
282  virtual
283  void
284  SetShrink();
285 
287  virtual
288  void
289  UnShrink();
290 
291  //----------------------------------------------------------------------------
293  virtual
294  void
295  AddToRender(vtkRenderer* theRendere);
296 
298  virtual
299  void
300  RemoveFromRender(vtkRenderer* theRendere);
301 
303  virtual
304  void
305  GetChildActors(vtkActorCollection*);
306 
307  //----------------------------------------------------------------------------
309  virtual
310  void
311  EnableSelection( bool enable ) {}
312 
314  virtual
315  bool
316  hasHighlight();
317 
319  virtual
320  bool
321  isHighlighted();
322 
324  virtual
325  bool
326  isPreselected();
327 
329  virtual
330  void
331  SetPreSelected(bool thePreselect = false);
332 
333  //----------------------------------------------------------------------------
335  virtual
336  void
337  highlight(bool theHighlight);
338 
339  void
340  SetPreviewProperty(vtkProperty* theProperty);
341 
342  //----------------------------------------------------------------------------
344  virtual void SetQuadraticArcMode(bool theFlag);
345  virtual bool GetQuadraticArcMode() const;
346 
347  virtual void SetQuadraticArcAngle(double theMaxAngle);
348  virtual double GetQuadraticArcAngle() const;
349 
350  //----------------------------------------------------------------------------
352  virtual vtkDataSet* GetHighlightedDataSet();
353 
354  protected:
355  //----------------------------------------------------------------------------
359 
360  std::string myName;
361 
362  double myOpacity;
365 
369  std::vector<vtkPassThroughFilter*> myPassFilter;
370 
372  vtkProperty *myProperty;
373 
374  void
375  InitPipeLine(vtkMapper* theMapper);
376 
377  VTKViewer_Actor();
378  ~VTKViewer_Actor();
379 
380  protected:
381  vtkProperty *PreviewProperty;
384 };
385 
386 #ifdef WIN32
387 #pragma warning ( default:4251 )
388 #endif
389 
390 #endif // VTKVIEVER_ACTOR_H