VTK  9.0.1
QVTKOpenGLWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: QVTKOpenGLWindow.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
49 #ifndef QVTKOpenGLWindow_h
50 #define QVTKOpenGLWindow_h
51 
52 #include <QOpenGLWindow>
53 #include <QScopedPointer> // for QScopedPointer.
54 
55 #include "QVTKInteractor.h" // needed for QVTKInteractor
56 #include "vtkGUISupportQtModule.h" // for export macro
57 #include "vtkNew.h" // needed for vtkNew
58 #include "vtkSmartPointer.h" // needed for vtkSmartPointer
59 
60 class QVTKInteractor;
64 
65 class VTKGUISUPPORTQT_EXPORT QVTKOpenGLWindow : public QOpenGLWindow
66 {
67  Q_OBJECT
68  typedef QOpenGLWindow Superclass;
69 
70 public:
72  QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
73  QVTKOpenGLWindow(QOpenGLContext* shareContext,
74  QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
76  QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
77  QVTKOpenGLWindow(vtkGenericOpenGLRenderWindow* renderWindow, QOpenGLContext* shareContext,
78  QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
79  ~QVTKOpenGLWindow() override;
80 
82 
88  void setRenderWindow(vtkGenericOpenGLRenderWindow* win);
89  void setRenderWindow(vtkRenderWindow* win);
91 
95  vtkRenderWindow* renderWindow() const;
96 
100  QVTKInteractor* interactor() const;
101 
105  static QSurfaceFormat defaultFormat(bool stereo_capable = false);
106 
108 
114  void setEnableHiDPI(bool enable);
115  bool enableHiDPI() const { return this->EnableHiDPI; }
117 
119 
123  void setUnscaledDPI(int);
124  int unscaledDPI() const { return this->UnscaledDPI; }
126 
128 
131  void setDefaultCursor(const QCursor& cursor);
132  const QCursor& defaultCursor() const { return this->DefaultCursor; }
134 
136 
139  VTK_LEGACY(void SetRenderWindow(vtkGenericOpenGLRenderWindow* win));
140  VTK_LEGACY(void SetRenderWindow(vtkRenderWindow* win));
142 
144 
149  VTK_LEGACY(vtkRenderWindow* GetRenderWindow());
150  VTK_LEGACY(QVTKInteractor* GetInteractor());
152 
157  VTK_LEGACY(QVTKInteractorAdapter* GetInteractorAdapter());
158 
163  VTK_LEGACY(void setQVTKCursor(const QCursor& cursor));
164 
168  VTK_LEGACY(void setDefaultQVTKCursor(const QCursor& cursor));
169 
170 signals:
175  void windowEvent(QEvent* e);
176 
177 protected slots:
183  void cleanupContext();
184 
185  void updateSize();
186 
193 
194 protected:
195  bool event(QEvent* evt) override;
196  void initializeGL() override;
197  void paintGL() override;
198  void resizeGL(int w, int h) override;
199 
200 protected:
202  QScopedPointer<QVTKRenderWindowAdapter> RenderWindowAdapter;
203 
204 private:
205  Q_DISABLE_COPY(QVTKOpenGLWindow);
206  bool EnableHiDPI;
207  int UnscaledDPI;
208  QCursor DefaultCursor;
209 };
210 
211 #endif
QVTKOpenGLWindow::RenderWindow
vtkSmartPointer< vtkGenericOpenGLRenderWindow > RenderWindow
Definition: QVTKOpenGLWindow.h:201
QVTKOpenGLWindow
display a vtkGenericOpenGLRenderWindow in a Qt QOpenGLWindow.
Definition: QVTKOpenGLWindow.h:65
QVTKOpenGLWindow::RenderWindowAdapter
QScopedPointer< QVTKRenderWindowAdapter > RenderWindowAdapter
Definition: QVTKOpenGLWindow.h:202
vtkGenericOpenGLRenderWindow
platform independent render window
Definition: vtkGenericOpenGLRenderWindow.h:42
vtkSmartPointer< vtkGenericOpenGLRenderWindow >
QVTKInteractorAdapter
Definition: QVTKInteractorAdapter.h:50
QVTKRenderWindowAdapter
Helper to manage Qt context and other OpenGL components.
Definition: QVTKRenderWindowAdapter.h:50
vtkSmartPointer.h
QVTKOpenGLWindow::unscaledDPI
int unscaledDPI() const
Definition: QVTKOpenGLWindow.h:124
vtkNew.h
QVTKOpenGLWindow::enableHiDPI
bool enableHiDPI() const
Definition: QVTKOpenGLWindow.h:115
QVTKInteractor.h
QVTKOpenGLWindow::defaultCursor
const QCursor & defaultCursor() const
Definition: QVTKOpenGLWindow.h:132
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:93
QVTKInteractor
an interactor for QVTKOpenGLNativeWidget (and QVTKWiget).
Definition: QVTKInteractor.h:58
QVTKOpenGLStereoWidget
QWidget for displaying a vtkRenderWindow in a Qt Application.
Definition: QVTKOpenGLStereoWidget.h:64
h