Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SVTK_ViewWindow.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 #ifndef SVTK_VIEWWINDOW_H
24 #define SVTK_VIEWWINDOW_H
25 
26 #ifdef WIN32
27 #pragma warning( disable:4251 )
28 #endif
29 
30 #include "SVTK.h"
31 #include "SVTK_Selection.h"
32 #include "Qtx.h"
33 #include "SUIT_ViewWindow.h"
34 
36 
37 #include <QImage>
38 #include <vtkSmartPointer.h>
39 
40 class SUIT_Desktop;
41 class SUIT_ResourceMgr;
42 
43 class VTKViewer_Actor;
45 
46 class SVTK_ViewModelBase;
47 class SVTK_Selector;
48 class SVTK_View;
49 
51 
52 class vtkRenderer;
53 class vtkRenderWindow;
55 class vtkInteractorStyle;
56 class vtkCallbackCommand;
57 
59 class SVTK_Renderer;
61 class SVTK_UpdateRateDlg;
62 class SVTK_CubeAxesDlg;
67 class SVTK_Recorder;
68 
69 namespace salomevtk
70 {
71  class vtkPVAxesWidget;
72 }
73 
74 class vtkObject;
75 class QtxAction;
76 
77 namespace SVTK
78 {
80  int convertAction( const int );
81 }
82 
85 {
86  Q_OBJECT;
87 
88  public:
90  SVTK_ViewWindow(SUIT_Desktop* theDesktop);
91 
92  virtual ~SVTK_ViewWindow();
93 
94  virtual QImage dumpView();
95 
97  virtual void Initialize(SVTK_ViewModelBase* theModel);
98 
100  SVTK_View* getView();
101 
103  vtkRenderWindow* getRenderWindow();
104 
106  vtkRenderWindowInteractor* getInteractor() const;
107 
109  SVTK_RenderWindowInteractor* GetInteractor() const;
110 
112  vtkInteractorStyle* GetInteractorStyle() const;
113 
115  void PushInteractorStyle(vtkInteractorStyle* theStyle);
116 
118  void PopInteractorStyle();
119 
121  vtkRenderer* getRenderer() const;
122 
124  SVTK_Renderer* GetRenderer() const;
125 
127  SVTK_Selector* GetSelector() const;
128 
130  Selection_Mode SelectionMode() const;
131 
133  virtual void SetSelectionMode(Selection_Mode theMode);
134 
136  virtual void setBackgroundColor( const QColor& );
137 
139  QColor backgroundColor() const;
140 
142  virtual void setBackground( const Qtx::BackgroundData& );
143 
145  Qtx::BackgroundData background() const;
146 
148  bool isTrihedronDisplayed();
149 
151  bool isCubeAxesDisplayed();
152 
153  /* interactive object management */
155  virtual void highlight(const Handle(SALOME_InteractiveObject)& theIO,
156  bool theIsHighlight = true,
157  bool theIsUpdate = true);
158 
160  virtual void unHighlightAll();
161 
163  bool isInViewer(const Handle(SALOME_InteractiveObject)& theIObject);
164 
166  bool isVisible(const Handle(SALOME_InteractiveObject)& theIObject);
167 
169  //----------------------------------------------------------------------------
170  Handle(SALOME_InteractiveObject) FindIObject(const char* theEntry);
171 
172  /* display */
173  //----------------------------------------------------------------------------
175  virtual void Display(const Handle(SALOME_InteractiveObject)& theIObject,
176  bool theImmediatly = true);
177 
179  virtual void DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject);
180 
182  virtual void Erase(const Handle(SALOME_InteractiveObject)& theIObject,
183  bool theImmediatly = true);
184 
186  virtual void DisplayAll();
187 
189  virtual void EraseAll();
190 
192  virtual void Repaint(bool theUpdateTrihedron = true);
193 
194  //----------------------------------------------------------------------------
196  virtual void SetScale( double theScale[3] );
197 
199  virtual void GetScale( double theScale[3] );
200 
202  virtual void AddActor(VTKViewer_Actor* theActor,
203  bool theIsUpdate = false,
204  bool theIsAdjustActors = true);
205 
207  virtual void RemoveActor(VTKViewer_Actor* theActor,
208  bool theIsUpdate = false,
209  bool theIsAdjustActors = true);
210 
211  //----------------------------------------------------------------------------
213  virtual void AdjustTrihedrons(const bool theIsForced);
214 
216  VTKViewer_Trihedron* GetTrihedron();
217 
219  SVTK_CubeAxesActor2D* GetCubeAxes();
220 
222  double GetTrihedronSize() const;
223 
225  virtual void SetTrihedronSize( const double, const bool = true );
226 
228  virtual void SetIncrementalSpeed( const int, const int = 0 );
229 
231  virtual void SetProjectionMode( const int );
232 
234  virtual void SetStereoType( const int );
235 
237  virtual void SetAnaglyphFilter( const int );
238 
240  virtual void SetQuadBufferSupport( const bool );
241 
243  virtual void SetInteractionStyle( const int );
244 
246  virtual void SetZoomingStyle( const int );
247 
249  virtual void SetPreSelectionMode( Preselection_Mode );
250 
252  virtual void SetSelectionEnabled( bool );
253 
255  virtual void SetSpacemouseButtons( const int, const int, const int );
256 
258  virtual void SetSelectionProp(const double& theRed = 1,
259  const double& theGreen = 1,
260  const double& theBlue = 0,
261  const int& theWidth = 5);
262 
264  virtual void SetPreselectionProp(const double& theRed = 0,
265  const double& theGreen = 1,
266  const double& theBlue = 1,
267  const int& theWidth = 5);
268 
270  virtual void SetSelectionTolerance(const double& theTolNodes = 0.025,
271  const double& theTolCell = 0.001,
272  const double& theTolObjects = 0.025);
273 
275  bool IsStaticTrihedronVisible() const;
276 
278  virtual void SetStaticTrihedronVisible( const bool );
279 
281  virtual QString getVisualParameters();
282 
283  virtual void setVisualParameters( const QString& parameters );
284 
285  virtual bool eventFilter( QObject*, QEvent* );
286 
287  virtual void RefreshDumpImage();
288 
289  void emitTransformed();
290 
292  void InvokeEvent(unsigned long theEvent, void* theCallData);
293 
295 
296  signals:
297  void Show( QShowEvent * );
298  void Hide( QHideEvent * );
299 
300 public slots:
301  virtual void showEvent( QShowEvent * );
302  virtual void hideEvent( QHideEvent * );
303  virtual void onSelectionChanged();
304 
305  void onChangeRotationPoint(bool theIsActivate);
306 
307  void activateSetRotationGravity();
308  void activateSetRotationSelected(void* theData);
309  void activateStartPointSelection( Selection_Mode );
310 
311  void onUpdateRate(bool theIsActivate);
312  void onNonIsometric(bool theIsActivate);
313  void onGraduatedAxes(bool theIsActivate);
314 
315  void activateZoom();
316  void activateWindowFit();
317  void activateRotation();
318  void activatePanning();
319  void activateGlobalPanning();
320 
321  void onProjectionMode( QAction* theAction );
322  void onStereoMode( bool activate );
323  void onProjectionMode();
324 
325  void activateProjectionMode(int);
326 
327  void activateSetFocalPointGravity();
328  void activateSetFocalPointSelected();
329  void activateStartFocalPointSelection();
330 
331  void onViewParameters(bool theIsActivate);
332 
333  void onSwitchInteractionStyle(bool theOn);
334  void onSwitchZoomingStyle(bool theOn);
335 
336  void onSwitchPreSelectionMode(int theMode);
337  void onEnableSelection(bool theOn);
338 
339  void onStartRecording();
340  void onPlayRecording();
341  void onPauseRecording();
342  void onStopRecording();
343 
344 signals:
345  void selectionChanged();
346  void actorAdded(VTKViewer_Actor*);
347  void actorRemoved(VTKViewer_Actor*);
348  void transformed(SVTK_ViewWindow*);
349 
350 public slots:
352  virtual void onFrontView();
353 
355  virtual void onBackView();
356 
358  virtual void onTopView();
359 
361  virtual void onBottomView();
362 
364  virtual void onRightView();
365 
367  virtual void onLeftView();
368 
370  virtual void onClockWiseView();
371 
373  virtual void onAntiClockWiseView();
374 
376  virtual void onResetView();
377 
379  virtual void onFitAll();
380 
382  virtual void onFitSelection();
383 
385  virtual void onViewTrihedron(bool);
386 
388  virtual void onViewCubeAxes();
389 
391  virtual void onAdjustTrihedron();
392 
394  virtual void onAdjustCubeAxes();
395 
396  virtual void synchronize(SVTK_ViewWindow*);
397 
398 protected slots:
399  void synchronize( SUIT_ViewWindow* );
400  void onKeyPressed(QKeyEvent* event);
401  void onKeyReleased(QKeyEvent* event);
402  void onMousePressed(QMouseEvent* event);
403  void onMouseDoubleClicked(QMouseEvent* event);
404  void onMouseReleased(QMouseEvent* event);
405  void onMouseMoving(QMouseEvent* event);
406 
407 public:
408  enum ProjectionType { Parallel, Projection, Stereo };
409 
410  enum StereoType { CrystalEyes, RedBlue, Interlaced, Left, Right, Dresden, Anaglyph, Checkerboard, SplitViewPortHorizontal };
411 
412  enum AnaglyphFilter { RedCyan, YellowBlue, GreenMagenta };
413 
414 protected:
415  virtual void Initialize(SVTK_View* theView,
416  SVTK_ViewModelBase* theModel);
417 
418  // Main process event method
419  static void ProcessEvents(vtkObject* object,
420  unsigned long event,
421  void* clientdata,
422  void* calldata);
423 
424  bool isOpenGlStereoSupport() const;
425 
426  void doSetVisualParameters( const QString&, bool = false );
427  void SetEventDispatcher(vtkObject* theDispatcher);
428 
429  QImage dumpViewContent();
430 
431  virtual QString filter() const;
432  virtual bool dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format );
433 
434  virtual bool action( const int );
435 
436  QtxAction* getAction( int ) const;
437  void createToolBar();
438  void createActions(SUIT_ResourceMgr* theResourceMgr);
439 
440  enum { DumpId, FitAllId, FitRectId, FitSelectionId, ZoomId, PanId, GlobalPanId,
441  ChangeRotationPointId, RotationId,
442  FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId, ResetId,
443  ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate,
444  ParallelModeId, ProjectionModeId, StereoModeId, ViewParametersId, SynchronizeId, SwitchInteractionStyleId,
446  PreselectionId, StandardPreselectionId, DynamicPreselectionId, DisablePreselectionId,
448  StartRecordingId, PlayRecordingId, PauseRecordingId, StopRecordingId };
449 
452 
454  vtkSmartPointer<SVTK_InteractorStyle> myDefaultInteractorStyle;
455  vtkSmartPointer<SVTK_KeyFreeInteractorStyle> myKeyFreeInteractorStyle;
456 
457  QString myVisualParams; // used for delayed setting of view parameters
458 
459  vtkSmartPointer<vtkObject> myEventDispatcher;
460 
461  // Used to process events
462  vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
463 
469 
472 
478 
481 
484 
485 private:
486  QImage myDumpImage;
487 };
488 
489 #ifdef WIN32
490 #pragma warning( default:4251 )
491 #endif
492 
493 #endif