VTK  9.3.20240424
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
48VTK_ABI_NAMESPACE_BEGIN
49class QVTKInteractor;
53
54class VTKGUISUPPORTQT_EXPORT QVTKOpenGLWindow : public QOpenGLWindow
55{
56 Q_OBJECT
57 typedef QOpenGLWindow Superclass;
58
59public:
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);
69
71
80
85
90
94 static QSurfaceFormat defaultFormat(bool stereo_capable = false);
95
97
103 void setEnableHiDPI(bool enable);
104 bool enableHiDPI() const { return this->EnableHiDPI; }
106
108
112 void setUnscaledDPI(int);
113 int unscaledDPI() const { return this->UnscaledDPI; }
115
117
130 void setCustomDevicePixelRatio(double cdpr);
131 double customDevicePixelRatio() const { return this->CustomDevicePixelRatio; }
134
136
139 void setDefaultCursor(const QCursor& cursor);
140 const QCursor& defaultCursor() const { return this->DefaultCursor; }
142
143Q_SIGNALS:
148 void windowEvent(QEvent* e);
149
150protected Q_SLOTS:
157
159
166
167protected: // NOLINT(readability-redundant-access-specifiers)
168 bool event(QEvent* evt) override;
169 void initializeGL() override;
170 void paintGL() override;
171 void resizeGL(int w, int h) override;
172
174 QScopedPointer<QVTKRenderWindowAdapter> RenderWindowAdapter;
175
176private:
177 Q_DISABLE_COPY(QVTKOpenGLWindow);
178 bool EnableHiDPI;
179 int UnscaledDPI;
180 double CustomDevicePixelRatio;
181 QCursor DefaultCursor;
182};
183
184VTK_ABI_NAMESPACE_END
185#endif
an interactor for QVTKOpenGLNativeWidget (and QVTKWiget).
QWidget for displaying a vtkRenderWindow in a Qt Application.
display a vtkGenericOpenGLRenderWindow in a Qt QOpenGLWindow.
void setRenderWindow(vtkGenericOpenGLRenderWindow *win)
Set a render window to use.
bool enableHiDPI() const
Enable or disable support for HiDPI displays.
void paintGL() override
const QCursor & defaultCursor() const
Set/get the default cursor to use for this widget.
QVTKOpenGLWindow(vtkGenericOpenGLRenderWindow *renderWindow, QOpenGLContext *shareContext, QOpenGLWindow::UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
~QVTKOpenGLWindow() override
QVTKOpenGLWindow(QOpenGLContext *shareContext, QOpenGLWindow::UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
double effectiveDevicePixelRatio() const
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
void setUnscaledDPI(int)
Set/Get unscaled DPI value.
vtkRenderWindow * renderWindow() const
Returns the render window that is being shown in this widget.
QVTKInteractor * interactor() const
Get the QVTKInteractor that was either created by default or set by the user.
QVTKOpenGLWindow(QOpenGLWindow::UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
QScopedPointer< QVTKRenderWindowAdapter > RenderWindowAdapter
void windowEvent(QEvent *e)
Signal emitted when any event has been receive, with the corresponding event as argument.
void setEnableHiDPI(bool enable)
Enable or disable support for HiDPI displays.
int unscaledDPI() const
Set/Get unscaled DPI value.
void cleanupContext()
Called as a response to QOpenGLContext::aboutToBeDestroyed.
void setDefaultCursor(const QCursor &cursor)
Set/get the default cursor to use for this widget.
vtkSmartPointer< vtkGenericOpenGLRenderWindow > RenderWindow
void initializeGL() override
void setCustomDevicePixelRatio(double cdpr)
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
void setRenderWindow(vtkRenderWindow *win)
Set a render window to use.
void resizeGL(int w, int h) override
static QSurfaceFormat defaultFormat(bool stereo_capable=false)
Returns a QSurfaceFormat suitable for surfaces that intend to be used for VTK rendering.
bool event(QEvent *evt) override
double customDevicePixelRatio() const
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
QVTKOpenGLWindow(vtkGenericOpenGLRenderWindow *renderWindow, QOpenGLWindow::UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
Helper to manage Qt context and other OpenGL components.
platform independent render window
create a window for renderers to draw into
Computes the portion of a dataset which is inside a selection.
Hold a reference to a vtkObjectBase instance.