Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SALOME_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 SALOME_ACTOR_H
28 #define SALOME_ACTOR_H
29 
30 #include "SVTK_SelectionEvent.h"
31 #include "SVTK_Selector.h"
32 #include "SVTK.h"
33 
35 
36 // undefining min and max because CASCADE's defines them and
37 // it clashes with std::min(), std::max()
38 #undef min
39 #undef max
40 
41 #include <VTKViewer_Actor.h>
42 #include <VTKViewer_MarkerDef.h>
43 
44 #include <vtkSmartPointer.h>
45 
46 class vtkAbstractPicker;
47 class vtkPointPicker;
48 class vtkCellPicker;
49 class vtkOutlineSource;
50 class vtkInteractorStyle;
52 
54 
55 class SVTK_Actor;
56 class SVTK_AreaPicker;
58 
61 
62 #ifdef WIN32
63 #pragma warning ( disable:4251 )
64 #endif
65 
67 
73 {
74  public:
75  static SALOME_Actor* New();
76 
78 
79  //----------------------------------------------------------------------------
81  virtual
82  Standard_Boolean
83  hasIO();
84 
86  virtual
88  getIO();
89 
91  virtual
92  void
93  setIO(const Handle(SALOME_InteractiveObject)& theIO);
94 
96  virtual
97  void
98  setName(const char* theName);
99 
100  //----------------------------------------------------------------------------
102  virtual
103  void
104  SetTransform(VTKViewer_Transform* theTransform);
105 
107  virtual
108  void
109  SetPosition(double _arg1,
110  double _arg2,
111  double _arg3);
112 
114  virtual
115  void
116  SetPosition(double _arg[3]);
117 
118  //----------------------------------------------------------------------------
120  virtual
121  void
122  SetVisibility( int );
123 
125  virtual
126  bool
127  ShouldBeDisplayed();
128 
129  //----------------------------------------------------------------------------
131  virtual
132  void
133  AddToRender(vtkRenderer* theRendere);
134 
136  virtual
137  void
138  RemoveFromRender(vtkRenderer* theRendere);
139 
141  vtkRenderer*
142  GetRenderer();
143 
144  //----------------------------------------------------------------------------
146  virtual
147  void
148  SetInteractor(vtkRenderWindowInteractor* theInteractor);
149 
151  virtual
152  void
153  Update();
154 
155  //----------------------------------------------------------------------------
157  virtual
158  void
159  SetSelector(SVTK_Selector* theSelector);
160 
162  virtual
163  void
164  highlight(bool theHighlight);
165 
167  virtual
168  void
169  Highlight(bool theHighlight);
170 
171  //----------------------------------------------------------------------------
173  virtual
174  bool
175  PreHighlight(vtkInteractorStyle* theInteractorStyle,
176  SVTK_SelectionEvent* theSelectionEvent,
177  bool theIsHighlight);
178 
180  virtual
181  bool
182  Highlight(vtkInteractorStyle* theInteractorStyle,
183  SVTK_SelectionEvent* theSelectionEvent,
184  bool theIsHighlight);
185 
186  //----------------------------------------------------------------------------
188  virtual
189  bool
190  IsDisplayNameActor() const;
191 
193  virtual
194  void
195  SetIsDisplayNameActor(bool theIsDisplayNameActor);
196 
198  virtual
199  void
200  SetNameActorText(const char* theText);
201 
203  virtual
204  void
205  SetNameActorOffset(double theOffset[2]);
206 
208  virtual
209  void
210  GetNameActorSize(vtkRenderer* theRenderer, double theSize[2]) const;
211 
213  virtual
214  void
215  UpdateNameActors();
216 
217  //----------------------------------------------------------------------------
219  virtual
220  void
221  SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
222 
224  virtual
225  void
226  SetMarkerTexture( int, VTK::MarkerTexture );
227 
229  virtual
231  GetMarkerType();
232 
234  virtual
236  GetMarkerScale();
237 
239  virtual
240  int
241  GetMarkerTexture();
242 
243  //----------------------------------------------------------------------------
245  void
246  SetPointPicker(vtkPointPicker* thePointPicker);
247 
249  void
250  SetCellPicker(vtkCellPicker* theCellPicker);
251 
253  void
254  SetPointAreaPicker(SVTK_AreaPicker* theAreaPicker);
255 
257  void
258  SetCellAreaPicker(SVTK_AreaPicker* theAreaPicker);
259 
260  //----------------------------------------------------------------------------
262  double* GetGravityCenter( int );
263 
264  //----------------------------------------------------------------------------
266  void
267  SetPreHighlightProperty(vtkProperty* theProperty);
268 
270  void
271  SetHighlightProperty(vtkProperty* theProperty);
272 
273  protected:
274  //----------------------------------------------------------------------------
276  vtkRenderer* myRenderer;
277 
279 
280  SALOME_Actor();
281  ~SALOME_Actor();
282 
283  protected:
284  Selection_Mode mySelectionMode;
285  vtkSmartPointer<SVTK_Selector> mySelector;
286 
287  //----------------------------------------------------------------------------
288  // Highlight/ Prehighlight devices
289  vtkSmartPointer<vtkPointPicker> myPointPicker;
290  vtkSmartPointer<vtkCellPicker> myCellPicker;
291 
292  vtkSmartPointer<SVTK_AreaPicker> myPointAreaPicker;
293  vtkSmartPointer<SVTK_AreaPicker> myCellAreaPicker;
294 
295  vtkSmartPointer<SVTK_Actor> myPreHighlightActor;
296  vtkSmartPointer<SVTK_Actor> myHighlightActor;
297 
298  vtkSmartPointer<VTKViewer_Actor> myOutlineActor;
299  vtkSmartPointer<vtkOutlineSource> myOutline;
300 
301  bool myIsDisplayNameActor;
302  vtkSmartPointer<VTKViewer_FramedTextActor> myNameActor;
303 };
304 
305 namespace SVTK
306 {
308  {
309  vtkAbstractPicker* myPicker;
310  public:
311  TPickLimiter(vtkAbstractPicker*, SALOME_Actor*);
312  ~TPickLimiter();
313  };
314 }
315 
316 #ifdef WIN32
317 #pragma warning ( default:4251 )
318 #endif
319 
320 #endif // SALOME_ACTOR_H