VTK  9.4.20250214
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
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; }
146
148
151 void setDefaultCursor(const QCursor& cursor);
152 const QCursor& defaultCursor() const { return this->DefaultCursor; }
154
155Q_SIGNALS:
160 void windowEvent(QEvent* e);
161
162protected Q_SLOTS:
169
171
178
179protected: // 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
188private:
189 Q_DISABLE_COPY(QVTKOpenGLWindow);
190 bool EnableTouchEventProcessing = true;
191 bool EnableHiDPI;
192 int UnscaledDPI;
193 double CustomDevicePixelRatio;
194 QCursor DefaultCursor;
195};
196
197VTK_ABI_NAMESPACE_END
198#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.
bool enableTouchEventProcessing() const
Enable or disable support for touch event processing.
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 setEnableTouchEventProcessing(bool enable)
Enable or disable support for touch event processing.
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.