VTK  9.2.6
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 
141  void setCustomDevicePixelRatio(double cdpr);
142  double customDevicePixelRatio() const { return this->CustomDevicePixelRatio; }
143  double effectiveDevicePixelRatio() const;
145 
147 
150  void setDefaultCursor(const QCursor& cursor);
151  const QCursor& defaultCursor() const { return this->DefaultCursor; }
153 
154 Q_SIGNALS:
159  void windowEvent(QEvent* e);
160 
161 protected Q_SLOTS:
167  void cleanupContext();
168 
169  void updateSize();
170 
177 
178 protected:
179  bool event(QEvent* evt) override;
180  void initializeGL() override;
181  void paintGL() override;
182  void resizeGL(int w, int h) override;
183 
184 protected:
186  QScopedPointer<QVTKRenderWindowAdapter> RenderWindowAdapter;
187 
188 private:
189  Q_DISABLE_COPY(QVTKOpenGLWindow);
190  bool EnableHiDPI;
191  int UnscaledDPI;
192  double CustomDevicePixelRatio;
193  QCursor DefaultCursor;
194 };
195 
196 #endif
an interactor for QVTKOpenGLNativeWidget (and QVTKWiget).
bool enableHiDPI() const
Enable or disable support for HiDPI displays.
const QCursor & defaultCursor() const
Set/get the default cursor to use for this widget.
platform independent render window
display a vtkGenericOpenGLRenderWindow in a Qt QOpenGLWindow.
QWidget for displaying a vtkRenderWindow in a Qt Application.
vtkSmartPointer< vtkGenericOpenGLRenderWindow > RenderWindow
create a window for renderers to draw into
QScopedPointer< QVTKRenderWindowAdapter > RenderWindowAdapter
double customDevicePixelRatio() const
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
Helper to manage Qt context and other OpenGL components.
int unscaledDPI() const
Set/Get unscaled DPI value.