Version: 9.15.0
SVTK_ViewWindow.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2025 CEA, EDF, 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 #include "SALOME_ListIO.hxx"
37 
38 #include <QImage>
39 #include <vtkSmartPointer.h>
40 
41 class SUIT_Desktop;
42 class SUIT_ResourceMgr;
43 
44 class VTKViewer_Actor;
46 
47 class SVTK_ViewModelBase;
48 class SVTK_Selector;
49 class SVTK_View;
50 
52 
53 class vtkRenderer;
54 class vtkRenderWindow;
56 class vtkInteractorStyle;
57 class vtkCallbackCommand;
58 
60 class SVTK_Renderer;
62 class SVTK_UpdateRateDlg;
63 class SVTK_CubeAxesDlg;
68 class SVTK_Recorder;
69 
70 namespace salomevtk
71 {
72  class vtkPVAxesWidget;
73 }
74 
75 class vtkObject;
76 class QtxAction;
77 
78 namespace SVTK
79 {
81  int convertAction( const int );
82 }
83 
86 {
87  Q_OBJECT
88 
89  public:
91  SVTK_ViewWindow(SUIT_Desktop* theDesktop);
92 
93  virtual ~SVTK_ViewWindow();
94 
95  virtual QImage dumpView();
96 
98  virtual void Initialize(SVTK_ViewModelBase* theModel);
99 
101  SVTK_View* getView();
102 
104  vtkRenderWindow* getRenderWindow();
105 
107  vtkRenderWindowInteractor* getInteractor() const;
108 
110  SVTK_RenderWindowInteractor* GetInteractor() const;
111 
113  vtkInteractorStyle* GetInteractorStyle() const;
114 
116  void PushInteractorStyle(vtkInteractorStyle* theStyle);
117 
119  void PopInteractorStyle();
120 
122  vtkRenderer* getRenderer() const;
123 
125  SVTK_Renderer* GetRenderer() const;
126 
128  SVTK_Selector* GetSelector() const;
129 
131  Selection_Mode SelectionMode() const;
132 
134  virtual void SetSelectionMode(Selection_Mode theMode);
135 
137  virtual void setBackgroundColor( const QColor& );
138 
140  QColor backgroundColor() const;
141 
143  virtual void setBackground( const Qtx::BackgroundData& );
144 
146  Qtx::BackgroundData background() const;
147 
149  bool isTrihedronDisplayed();
150 
152  bool isCubeAxesDisplayed();
153 
154  /* interactive object management */
156  virtual void highlight(const Handle(SALOME_InteractiveObject)& theIO,
157  bool theIsHighlight = true,
158  bool theIsUpdate = true);
159 
161  virtual void unHighlightAll();
162 
164  bool isInViewer(const Handle(SALOME_InteractiveObject)& theIObject);
165 
167  bool isVisible(const Handle(SALOME_InteractiveObject)& theIObject);
168 
170  //----------------------------------------------------------------------------
171  Handle(SALOME_InteractiveObject) FindIObject(const char* theEntry);
172 
173  /* display */
174  //----------------------------------------------------------------------------
176  virtual void Display(const Handle(SALOME_InteractiveObject)& theIObject,
177  bool theImmediatly = true);
178 
180  virtual void DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject);
181 
183  virtual void Erase(const Handle(SALOME_InteractiveObject)& theIObject,
184  bool theImmediatly = true);
185 
187  virtual void DisplayAll();
188 
190  virtual void EraseAll();
191 
193  virtual void Repaint(bool theUpdateTrihedron = true);
194 
195  //----------------------------------------------------------------------------
197  virtual void SetScale( double theScale[3] );
198 
200  virtual void GetScale( double theScale[3] );
201 
203  virtual void AddActor(VTKViewer_Actor* theActor,
204  bool theIsUpdate = false,
205  bool theIsAdjustActors = true);
206 
208  virtual void RemoveActor(VTKViewer_Actor* theActor,
209  bool theIsUpdate = false,
210  bool theIsAdjustActors = true);
211 
212  //----------------------------------------------------------------------------
214  virtual void AdjustTrihedrons(const bool theIsForced);
215 
217  VTKViewer_Trihedron* GetTrihedron();
218 
220  SVTK_CubeAxesActor2D* GetCubeAxes();
221 
223  double GetTrihedronSize() const;
224 
226  virtual void SetTrihedronSize( const double, const bool = true );
227 
229  virtual void SetIncrementalSpeed( const int, const int = 0 );
230 
232  virtual void SetProjectionMode( const int );
233 
235  virtual void SetStereoType( const int );
236 
238  virtual void SetAnaglyphFilter( const int );
239 
241  virtual void SetQuadBufferSupport( const bool );
242 
244  virtual void SetInteractionStyle( const int );
245 
247  virtual void SetZoomingStyle( const int );
248 
250  virtual void SetPreSelectionMode( Preselection_Mode );
251 
253  virtual void SetSelectionEnabled( bool );
254 
256  virtual void SetSpacemouseButtons( const int, const int, const int );
257 
259  virtual void SetSelectionProp(const double& theRed = 1,
260  const double& theGreen = 1,
261  const double& theBlue = 0,
262  const int& theWidth = 5);
263 
265  virtual void SetPreselectionProp(const double& theRed = 0,
266  const double& theGreen = 1,
267  const double& theBlue = 1,
268  const int& theWidth = 5);
269 
271  virtual void SetSelectionTolerance(const double& theTolNodes = 0.025,
272  const double& theTolCell = 0.001,
273  const double& theTolObjects = 0.025);
274 
276  bool IsStaticTrihedronVisible() const;
277 
279  virtual void SetStaticTrihedronVisible( const bool );
280 
282  virtual void setStaticTrihedronTextColor();
283 
285  virtual QString getVisualParameters();
286 
287  virtual void setVisualParameters( const QString& parameters );
288 
289  virtual bool eventFilter( QObject*, QEvent* );
290 
291  virtual void RefreshDumpImage();
292 
293  void emitTransformed();
294 
296  void InvokeEvent(unsigned long theEvent, void* theCallData);
297 
299 
300  signals:
301  void Show( QShowEvent * );
302  void Hide( QHideEvent * );
303 
304 public slots:
305  virtual void showEvent( QShowEvent * );
306  virtual void hideEvent( QHideEvent * );
307  virtual void onSelectionChanged();
308 
309  void onChangeRotationPoint(bool theIsActivate);
310 
311  void activateSetRotationGravity();
312  void activateSetRotationSelected(void* theData);
313  void activateStartPointSelection( Selection_Mode );
314 
315  void onUpdateRate(bool theIsActivate);
316  void onNonIsometric(bool theIsActivate);
317  void onGraduatedAxes(bool theIsActivate);
318 
319  void activateZoom();
320  void activateWindowFit();
321  void activateRotation();
322  void activatePanning();
323  void activateGlobalPanning();
324 
325  void onProjectionMode( QAction* theAction );
326  void onStereoMode( bool activate );
327  void onProjectionMode();
328 
329  void activateProjectionMode(int);
330 
331  void activateSetFocalPointGravity();
332  void activateSetFocalPointSelected();
333  void activateStartFocalPointSelection();
334  void activateInteractiveSelection();
335  void deactivateCurrectOperation();
336 
337  void onViewParameters(bool theIsActivate);
338 
339  void onSwitchInteractionStyle(bool theOn);
340  void onSwitchZoomingStyle(bool theOn);
341 
342  void onSwitchPreSelectionMode(int theMode);
343  void onEnableSelection(bool theOn);
344 
345  void onStartRecording();
346  void onPlayRecording();
347  void onPauseRecording();
348  void onStopRecording();
349 
350 signals:
355 
356 public slots:
358  virtual void onFrontView();
359 
361  virtual void onBackView();
362 
364  virtual void onTopView();
365 
367  virtual void onBottomView();
368 
370  virtual void onRightView();
371 
373  virtual void onLeftView();
374 
376  virtual void onClockWiseView();
377 
379  virtual void onAntiClockWiseView();
380 
382  virtual void onResetView();
383 
385  virtual void onFitAll();
386 
388  virtual void onFitSelection();
389 
391  virtual void onFitIObjects(const SALOME_ListIO&);
392 
394  virtual void onViewTrihedron(bool);
395 
397  virtual void onViewCubeAxes();
398 
400  virtual void onAdjustTrihedron();
401 
403  virtual void onAdjustCubeAxes();
404 
405  virtual void synchronize(SVTK_ViewWindow*);
406 
407 protected slots:
408  void synchronize( SUIT_ViewWindow* );
409  void onKeyPressed(QKeyEvent* event);
410  void onKeyReleased(QKeyEvent* event);
411  void onMousePressed(QMouseEvent* event);
412  void onMouseDoubleClicked(QMouseEvent* event);
413  void onMouseReleased(QMouseEvent* event);
414  void onMouseMoving(QMouseEvent* event);
415 
416 public:
417  enum ProjectionType { Parallel, Projection, Stereo };
418 
419  enum StereoType { CrystalEyes, RedBlue, Interlaced, Left, Right, Dresden, Anaglyph, Checkerboard, SplitViewPortHorizontal };
420 
421  enum AnaglyphFilter { RedCyan, YellowBlue, GreenMagenta };
422 
423 protected:
424 
425  virtual void resizeEvent( QResizeEvent* );
426 
427  virtual void Initialize(SVTK_View* theView,
428  SVTK_ViewModelBase* theModel);
429 
430  // Main process event method
431  static void ProcessEvents(vtkObject* object,
432  unsigned long event,
433  void* clientdata,
434  void* calldata);
435 
436  bool isOpenGlStereoSupport() const;
437 
438  void doSetVisualParameters( const QString&, bool = false );
439  void SetEventDispatcher(vtkObject* theDispatcher);
440 
441  QImage dumpViewContent();
442 
443  virtual QString filter() const;
444  virtual bool dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format );
445 
446  virtual bool action( const int );
447 
448  QtxAction* getAction( int ) const;
449  void createToolBar();
450  void createActions(SUIT_ResourceMgr* theResourceMgr);
451 
452  enum { DumpId, FitAllId, FitRectId, FitSelectionId, ZoomId, PanId, GlobalPanId,
454  FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId, ResetId,
455  ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate,
456  ParallelModeId, ProjectionModeId, StereoModeId, ViewParametersId, SynchronizeId, SwitchInteractionStyleId,
458  PreselectionId, StandardPreselectionId, DynamicPreselectionId, DisablePreselectionId,
460  StartRecordingId, PlayRecordingId, PauseRecordingId, StopRecordingId };
461 
464 
466  vtkSmartPointer<SVTK_InteractorStyle> myDefaultInteractorStyle;
467  vtkSmartPointer<SVTK_KeyFreeInteractorStyle> myKeyFreeInteractorStyle;
468 
469  QString myVisualParams; // used for delayed setting of view parameters
470 
471  vtkSmartPointer<vtkObject> myEventDispatcher;
472 
473  // Used to process events
474  vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
475 
481 
484 
490 
493 
496 
497 private:
498  QImage myDumpImage;
499 };
500 
501 #ifdef WIN32
502 #pragma warning( default:4251 )
503 #endif
504 
505 #endif
Handle(TDocStd_Application) CAF_Application
Get OCAF application.
Definition: CAF_Application.cxx:97
const QString const bool const double theScale
Definition: OCCViewer_ViewModel.cxx:975
Selection_Mode
Definition: SALOME_Selection.h:27
#define SVTK_EXPORT
Definition: SVTK.h:37
int Preselection_Mode
Preselection modes.
Definition: SVTK_Selection.h:45
For more information see QT documentation.
Definition: SUIT_Application.h:42
Generic action class.
Definition: QtxAction.h:39
Stores background data.
Definition: Qtx.h:178
Definition: SALOME_ListIO.hxx:29
Base class for Camera Properties.
Definition: SUIT_CameraProperties.h:29
Definition: SUIT_Desktop.h:47
Definition: SUIT_ResourceMgr.h:31
Definition: SUIT_ViewWindow.h:42
virtual bool action(const int)
Definition: SUIT_ViewWindow.cxx:225
bool dumpViewToFormat(const QString &fileName, const QString &format)
Definition: SUIT_ViewWindow.cxx:125
virtual void setVisualParameters(const QString &parameters)
Definition: SUIT_ViewWindow.cxx:259
virtual QString getVisualParameters()
Definition: SUIT_ViewWindow.cxx:250
virtual SUIT_CameraProperties cameraProperties()
Definition: SUIT_ViewWindow.cxx:358
virtual QImage dumpView()
Definition: SUIT_ViewWindow.cxx:92
virtual void synchronize(SUIT_ViewWindow *)
Definition: SUIT_ViewWindow.cxx:372
virtual QString filter() const
Definition: SUIT_ViewWindow.cxx:175
Definition: SVTK_CubeAxesActor2D.h:54
Definition: SVTK_CubeAxesDlg.h:62
Introduce SALOME way of user interaction.
Definition: SVTK_InteractorStyle.h:158
Introduce new style of interaction (keyboard free)
Definition: SVTK_KeyFreeInteractorStyle.h:33
Definition: SVTK_NonIsometricDlg.h:41
Definition: SVTK_Recorder.h:35
Extends QVTK_RenderWindowInteractor functionality.
Definition: SVTK_RenderWindowInteractor.h:141
Definition: SVTK_Renderer.h:66
Define an abstract interface for selection in SVTK package.
Definition: SVTK_Selector.h:58
Definition: SVTK_SetRotationPointDlg.h:56
Definition: SVTK_UpdateRateDlg.h:48
To define minimal interface for SVTK_ViewWindow initialization.
Definition: SVTK_ViewModelBase.h:34
Definition: SVTK_ViewParameterDlg.h:49
Define a container for SALOME VTK view window.
Definition: SVTK_ViewWindow.h:86
void actorAdded(VTKViewer_Actor *)
void Show(QShowEvent *)
SVTK_View * myView
Definition: SVTK_ViewWindow.h:462
SVTK_ViewModelBase * myModel
Definition: SVTK_ViewWindow.h:463
QtxAction * myPlayAction
Definition: SVTK_ViewWindow.h:487
vtkSmartPointer< SVTK_KeyFreeInteractorStyle > myKeyFreeInteractorStyle
Definition: SVTK_ViewWindow.h:467
salomevtk::vtkPVAxesWidget * myAxesWidget
Definition: SVTK_ViewWindow.h:494
SVTK_CubeAxesDlg * myCubeAxesDlg
Definition: SVTK_ViewWindow.h:478
int myRecordingToolBar
Definition: SVTK_ViewWindow.h:492
Qtx::BackgroundData myBackground
Definition: SVTK_ViewWindow.h:495
@ SwitchZoomingStyleId
Definition: SVTK_ViewWindow.h:457
@ DisablePreselectionId
Definition: SVTK_ViewWindow.h:458
@ ParallelModeId
Definition: SVTK_ViewWindow.h:456
@ EnableSelectionId
Definition: SVTK_ViewWindow.h:459
@ GraduatedAxes
Definition: SVTK_ViewWindow.h:455
@ PauseRecordingId
Definition: SVTK_ViewWindow.h:460
@ DumpId
Definition: SVTK_ViewWindow.h:452
@ AntiClockWiseId
Definition: SVTK_ViewWindow.h:454
@ ChangeRotationPointId
Definition: SVTK_ViewWindow.h:453
SVTK_RenderWindowInteractor * myInteractor
Definition: SVTK_ViewWindow.h:465
SVTK_ViewParameterDlg * myViewParameterDlg
Definition: SVTK_ViewWindow.h:480
QImage myDumpImage
Definition: SVTK_ViewWindow.h:498
QtxAction * myPauseAction
Definition: SVTK_ViewWindow.h:488
SVTK_NonIsometricDlg * myNonIsometricDlg
Definition: SVTK_ViewWindow.h:476
void Hide(QHideEvent *)
SVTK_SetRotationPointDlg * mySetRotationPointDlg
Definition: SVTK_ViewWindow.h:479
QtxAction * myStartAction
Definition: SVTK_ViewWindow.h:486
int myToolBar
Definition: SVTK_ViewWindow.h:491
QSize myPreRecordingMaxSize
Definition: SVTK_ViewWindow.h:483
void actorRemoved(VTKViewer_Actor *)
AnaglyphFilter
Definition: SVTK_ViewWindow.h:421
vtkSmartPointer< vtkCallbackCommand > myEventCallbackCommand
Definition: SVTK_ViewWindow.h:474
QSize myPreRecordingMinSize
Definition: SVTK_ViewWindow.h:482
Handle(SALOME_InteractiveObject) FindIObject(const char *theEntry)
Redirect the request to #SVTK_View::FindIObject (to support old code)
vtkSmartPointer< vtkObject > myEventDispatcher
Definition: SVTK_ViewWindow.h:471
SVTK_UpdateRateDlg * myUpdateRateDlg
Definition: SVTK_ViewWindow.h:477
SVTK_Recorder * myRecorder
Definition: SVTK_ViewWindow.h:485
QString myVisualParams
Definition: SVTK_ViewWindow.h:469
StereoType
Definition: SVTK_ViewWindow.h:419
@ Anaglyph
Definition: SVTK_ViewWindow.h:419
void transformed(SVTK_ViewWindow *)
void selectionChanged()
ProjectionType
Definition: SVTK_ViewWindow.h:417
@ Parallel
Definition: SVTK_ViewWindow.h:417
QtxAction * myStopAction
Definition: SVTK_ViewWindow.h:489
vtkSmartPointer< SVTK_InteractorStyle > myDefaultInteractorStyle
Definition: SVTK_ViewWindow.h:466
This class is introduced just for compatibility with old code.
Definition: SVTK_View.h:119
Definition: VTKViewer_Actor.h:79
Definition: VTKViewer_Trihedron.h:145
Definition: salomevtkPVAxesWidget.h:60
Definition: SALOME_Actor.cxx:148
int convertAction(const int accelAction)
Definition: SVTK_ViewWindow.cxx:121
Definition: salomevtkPVAxesActor.cxx:60