VTK  9.4.20250310
QVTKOpenGLNativeWidget.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
91#ifndef QVTKOpenGLNativeWidget_h
92#define QVTKOpenGLNativeWidget_h
93
94#include <QOpenGLWidget>
95#include <QScopedPointer> // for QScopedPointer.
96
97#include "QVTKInteractor.h" // needed for QVTKInteractor
98#include "vtkGUISupportQtModule.h" // for export macro
99#include "vtkNew.h" // needed for vtkNew
100#include "vtkSmartPointer.h" // needed for vtkSmartPointer
101
102VTK_ABI_NAMESPACE_BEGIN
103class QVTKInteractor;
107
108class VTKGUISUPPORTQT_EXPORT QVTKOpenGLNativeWidget : public QOpenGLWidget
109{
110 Q_OBJECT
111 typedef QOpenGLWidget Superclass;
112
113public:
114 QVTKOpenGLNativeWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
115 QVTKOpenGLNativeWidget(vtkGenericOpenGLRenderWindow* window, QWidget* parent = nullptr,
116 Qt::WindowFlags f = Qt::WindowFlags());
118
120
129
134
139
143 static QSurfaceFormat defaultFormat(bool stereo_capable = false);
144
146
152 bool enableTouchEventProcesing() const { return this->EnableTouchEventProcessing; }
154
156
162 void setEnableHiDPI(bool enable);
163 bool enableHiDPI() const { return this->EnableHiDPI; }
165
167
171 void setUnscaledDPI(int);
172 int unscaledDPI() const { return this->UnscaledDPI; }
174
176
189 void setCustomDevicePixelRatio(double cdpr);
190 double customDevicePixelRatio() const { return this->CustomDevicePixelRatio; }
193
195
198 void setDefaultCursor(const QCursor& cursor);
199 const QCursor& defaultCursor() const { return this->DefaultCursor; }
201
203
207 void setCursorCustom(const QCursor& cursor) { this->setCursor(cursor); }
208 QCursor cursorCustom() const { return this->cursor(); }
210
211protected Q_SLOTS:
217 virtual void cleanupContext();
218
220
221protected: // NOLINT(readability-redundant-access-specifiers)
222 bool event(QEvent* evt) override;
223 void initializeGL() override;
224 void paintGL() override;
225
227 QScopedPointer<QVTKRenderWindowAdapter> RenderWindowAdapter;
228
229private:
230 Q_DISABLE_COPY(QVTKOpenGLNativeWidget);
231
232 bool EnableTouchEventProcessing = true;
233 bool EnableHiDPI;
234 int UnscaledDPI;
235 double CustomDevicePixelRatio;
236 QCursor DefaultCursor;
237};
238
239VTK_ABI_NAMESPACE_END
240#endif
an interactor for QVTKOpenGLNativeWidget (and QVTKWiget).
QOpenGLWidget subclass to house a vtkGenericOpenGLRenderWindow in a Qt application.
bool enableHiDPI() const
Enable or disable support for HiDPI displays.
virtual void cleanupContext()
Called as a response to QOpenGLContext::aboutToBeDestroyed.
int unscaledDPI() const
Set/Get unscaled DPI value.
void setCustomDevicePixelRatio(double cdpr)
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
bool event(QEvent *evt) override
~QVTKOpenGLNativeWidget() override
void initializeGL() override
void setEnableHiDPI(bool enable)
Enable or disable support for HiDPI displays.
const QCursor & defaultCursor() const
Set/get the default cursor to use for this widget.
QCursor cursorCustom() const
Convenience method by symmetry with QVTKOpenGLStereoWidget.
QVTKInteractor * interactor() const
Get the QVTKInteractor that was either created by default or set by the user.
QScopedPointer< QVTKRenderWindowAdapter > RenderWindowAdapter
vtkSmartPointer< vtkGenericOpenGLRenderWindow > RenderWindow
void setRenderWindow(vtkGenericOpenGLRenderWindow *win)
Set a render window to use.
double effectiveDevicePixelRatio() const
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
vtkRenderWindow * renderWindow() const
Returns the render window that is being shown in this widget.
void setUnscaledDPI(int)
Set/Get unscaled DPI value.
void setCursorCustom(const QCursor &cursor)
Convenience method by symmetry with QVTKOpenGLStereoWidget.
QVTKOpenGLNativeWidget(vtkGenericOpenGLRenderWindow *window, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
bool enableTouchEventProcesing() const
Enable or disable support for touch event processing.
void setDefaultCursor(const QCursor &cursor)
Set/get the default cursor to use for this widget.
static QSurfaceFormat defaultFormat(bool stereo_capable=false)
Returns a QSurfaceFormat suitable for surfaces that intend to be used for VTK rendering.
double customDevicePixelRatio() const
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
void paintGL() override
void setEnableTouchEventProcessing(bool enable)
Enable or disable support for touch event processing.
QVTKOpenGLNativeWidget(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
void setRenderWindow(vtkRenderWindow *win)
Set a render window to use.
Helper to manage Qt context and other OpenGL components.
platform independent render window
create a window for renderers to draw into
Hold a reference to a vtkObjectBase instance.