Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SVTK_Renderer.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 VTKViewer : build VTK viewer into Salome desktop
24 // File :
25 // Author :
26 
27 #ifndef SVTK_Renderer_h
28 #define SVTK_Renderer_h
29 
30 #include "SVTK.h"
31 #include "VTKViewer.h"
32 
33 #include <vtkObject.h>
34 #include <vtkSmartPointer.h>
35 
36 class vtkRenderer;
37 class vtkCallbackCommand;
39 
40 class vtkPicker;
41 class vtkPointPicker;
42 class vtkCellPicker;
43 class vtkProperty;
44 
45 class SVTK_AreaPicker;
46 
50 class VTKViewer_Actor;
51 class SVTK_Selector;
52 
53 #ifdef WIN32
54 #pragma warning ( disable:4251 )
55 #endif
56 
65 {
66  public:
67  vtkTypeMacro(SVTK_Renderer,vtkObject);
68  static SVTK_Renderer* New();
69 
70  //----------------------------------------------------------------------------
72  vtkRenderer*
73  GetDevice();
74 
76  virtual
77  void
78  Initialize(vtkRenderWindowInteractor* theInteractor,
79  SVTK_Selector* theSelector);
80 
81  //----------------------------------------------------------------------------
83  virtual
84  void
85  AddActor(VTKViewer_Actor* theActor, bool theIsAdjustActors = true);
86 
88  virtual
89  void
90  RemoveActor(VTKViewer_Actor* theActor, bool theIsAdjustActors = true);
91 
94  GetTransform();
95 
97  virtual
98  void
99  SetScale( double theScale[3] );
100 
102  void
103  GetScale( double theScale[3] );
104 
105  //----------------------------------------------------------------------------
107  void
108  SetSelectionProp(const double& theRed = 1,
109  const double& theGreen = 1,
110  const double& theBlue = 0,
111  const int& theWidth = 5);
112 
114  void
115  SetPreselectionProp(const double& theRed = 0,
116  const double& theGreen = 1,
117  const double& theBlue = 1,
118  const int& theWidth = 5);
119 
121  void
122  SetSelectionTolerance(const double& theTolNodes = 0.025,
123  const double& theTolCell = 0.001,
124  const double& theTolObjects = 0.025);
125 
126  //----------------------------------------------------------------------------
128  void
129  AdjustActors();
130 
132  void
133  SetTrihedronSize(double theSize, const bool theRelative = true);
134 
136  double
137  GetTrihedronSize() const;
138 
140  bool
141  IsTrihedronRelative() const;
142 
143  //----------------------------------------------------------------------------
146  GetTrihedron();
147 
149  bool
150  IsTrihedronDisplayed();
151 
153  void
154  OnViewTrihedron();
155 
157 
158  void
159  SetTrihedronVisibility( const bool );
160 
162  void
163  OnAdjustTrihedron();
164 
165  //----------------------------------------------------------------------------
168  GetCubeAxes();
169 
171  bool
172  IsCubeAxesDisplayed();
173 
175  void
176  OnViewCubeAxes();
177 
179  void
180  OnAdjustCubeAxes();
181 
182  //----------------------------------------------------------------------------
184  void OnFitAll();
185 
186  //----------------------------------------------------------------------------
188  void onFitSelection();
189 
191  void OnResetView();
192 
194  void OnResetClippingRange();
195 
197  void OnFrontView();
198 
200  void OnBackView();
201 
203  void OnTopView();
204 
206  void OnBottomView();
207 
209  void OnRightView();
210 
212  void OnLeftView();
213 
215  void onClockWiseView();
216 
218  void onAntiClockWiseView();
219 
220 protected:
221  SVTK_Renderer();
222  ~SVTK_Renderer();
223 
224  virtual
225  bool
226  OnAdjustActors();
227 
228  //----------------------------------------------------------------------------
229  // Priority at which events are processed
230  double myPriority;
231 
232  // Used to process events
233  vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
234 
235  // Description:
236  // Main process event method
237  static void ProcessEvents(vtkObject* object,
238  unsigned long event,
239  void* clientdata,
240  void* calldata);
241 
242  vtkSmartPointer<vtkRenderer> myDevice;
244  vtkSmartPointer<SVTK_Selector> mySelector;
245 
246  //----------------------------------------------------------------------------
247  vtkSmartPointer<VTKViewer_Transform> myTransform;
248 
249  //----------------------------------------------------------------------------
250  // Highlight/ Prehighlight devices
251  vtkSmartPointer<vtkPointPicker> myPointPicker;
252  vtkSmartPointer<vtkCellPicker> myCellPicker;
253 
254  vtkSmartPointer<SVTK_AreaPicker> myPointAreaPicker;
255  vtkSmartPointer<SVTK_AreaPicker> myCellAreaPicker;
256 
257  vtkSmartPointer<vtkProperty> myPreHighlightProperty;
258  vtkSmartPointer<vtkProperty> myHighlightProperty;
259 
260  //----------------------------------------------------------------------------
261  vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
262  vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;
265  double myBndBox[6];
266 };
267 
268 #ifdef WIN32
269 #pragma warning ( default:4251 )
270 #endif
271 
272 #endif