VTK  9.7.1
QVTKOpenGLWindow.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
37 #ifndef QVTKOpenGLWindow_h
38 #define QVTKOpenGLWindow_h
39 
40 #include <QOpenGLWindow>
41 #include <QScopedPointer> // for QScopedPointer.
42 
43 #include "QVTKInteractor.h" // needed for QVTKInteractor
44 #include "vtkGUISupportQtModule.h" // for export macro
45 #include "vtkNew.h" // needed for vtkNew
46 #include "vtkSmartPointer.h" // needed for vtkSmartPointer
47 
48 VTK_ABI_NAMESPACE_BEGIN
49 class QVTKInteractor;
53 
54 class VTKGUISUPPORTQT_EXPORT QVTKOpenGLWindow : public QOpenGLWindow
55 {
56  Q_OBJECT
57  typedef QOpenGLWindow Superclass;
58 
59 public:
61  QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
62  QVTKOpenGLWindow(QOpenGLContext* shareContext,
63  QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
65  QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
66  QVTKOpenGLWindow(vtkGenericOpenGLRenderWindow* renderWindow, QOpenGLContext* shareContext,
67  QOpenGLWindow::UpdateBehavior updateBehavior = NoPartialUpdate, QWindow* parent = nullptr);
68  ~QVTKOpenGLWindow() override;
69 
71 
77  void setRenderWindow(vtkGenericOpenGLRenderWindow* win);
78  void setRenderWindow(vtkRenderWindow* win);
80 
84  vtkRenderWindow* renderWindow() const;
85 
89  QVTKInteractor* interactor() const;
90 
94  static QSurfaceFormat defaultFormat(bool stereo_capable = false);
95 
97 
104  void setEnableTouchEventProcessing(bool enable);
105  bool enableTouchEventProcessing() const { return this->EnableTouchEventProcessing; }
107 
109 
115  void setEnableHiDPI(bool enable);
116  bool enableHiDPI() const { return this->EnableHiDPI; }
118 
120 
124  void setUnscaledDPI(int);
125  int unscaledDPI() const { return this->UnscaledDPI; }
127 
129 
142  void setCustomDevicePixelRatio(double cdpr);
143  double customDevicePixelRatio() const { return this->CustomDevicePixelRatio; }
144  double effectiveDevicePixelRatio() const;
146 
148 
151  void setDefaultCursor(const QCursor& cursor);
152  const QCursor& defaultCursor() const { return this->DefaultCursor; }
154 
155 Q_SIGNALS:
160  void windowEvent(QEvent* e);
161 
162 protected Q_SLOTS:
168  void cleanupContext();
169 
170  void updateSize();
171 
178 
179 protected: // NOLINT(readability-redundant-access-specifiers)
180  bool event(QEvent* evt) override;
181  void initializeGL() override;
182  void paintGL() override;
183  void resizeGL(int w, int h) override;
184 
186  QScopedPointer<QVTKRenderWindowAdapter> RenderWindowAdapter;
187 
188 private:
189  Q_DISABLE_COPY(QVTKOpenGLWindow);
190  bool EnableTouchEventProcessing = true;
191  bool EnableHiDPI;
192  int UnscaledDPI;
193  double CustomDevicePixelRatio;
194  QCursor DefaultCursor;
195 };
196 
197 VTK_ABI_NAMESPACE_END
198 #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.
bool enableTouchEventProcessing() const
Enable or disable support for touch event processing.
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.