VTK  9.7.20260825
QVTKWebGPUWidget.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
25
26#ifndef QVTKWebGPUWidget_h
27#define QVTKWebGPUWidget_h
28
29#include <QWidget>
30#include <memory> // for std::unique_ptr
31
32#include "QVTKInteractor.h" // needed for QVTKInteractor
33#include "vtkGUISupportQtWebGPUModule.h" // for export macro
34#include "vtkSmartPointer.h" // needed for vtkSmartPointer
35
36#include "vtk_wgpu.h" // for webgpu
37
38VTK_ABI_NAMESPACE_BEGIN
39class QVTKInteractor;
42
43class VTKGUISUPPORTQTWEBGPU_EXPORT QVTKWebGPUWidget : public QWidget
44{
45 Q_OBJECT
46 typedef QWidget Superclass;
47
48public:
49 QVTKWebGPUWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
51
56
61
63
69 void setEnableHiDPI(bool enable);
70 bool enableHiDPI() const { return this->EnableHiDPI; }
72
74
78 void setUnscaledDPI(int dpi);
79 int unscaledDPI() const { return this->UnscaledDPI; }
81
83
96 void setCustomDevicePixelRatio(double cdpr);
97 double customDevicePixelRatio() const { return this->CustomDevicePixelRatio; }
100
102
105 void setDefaultCursor(const QCursor& cursor);
106 const QCursor& defaultCursor() const { return this->DefaultCursor; }
108
109protected:
110 void resizeEvent(QResizeEvent* event) override;
111 void paintEvent(QPaintEvent* event) override;
112 bool event(QEvent* evt) override;
113
118
123
128
130 std::unique_ptr<QVTKInteractorAdapter> InteractorAdapter;
131
132private:
133 Q_DISABLE_COPY(QVTKWebGPUWidget);
134
135 bool Initialized = false;
136 bool InPaint = false;
137 bool EnableHiDPI = true;
138 int UnscaledDPI = 72;
139 double CustomDevicePixelRatio = 0.0;
140 QCursor DefaultCursor;
141
142 // Platform-specific surface descriptor
143 struct PlatformSurface;
144 std::unique_ptr<PlatformSurface> Platform;
145
146 wgpu::SurfaceDescriptor SurfaceDescriptor;
147};
148
149VTK_ABI_NAMESPACE_END
150#endif
an interactor for QVTKOpenGLNativeWidget (and QVTKWiget).
const QCursor & defaultCursor() const
Set/get the default cursor to use for this widget.
void paintEvent(QPaintEvent *event) override
void setEnableHiDPI(bool enable)
Enable or disable support for HiDPI displays.
std::unique_ptr< QVTKInteractorAdapter > InteractorAdapter
void resizeEvent(QResizeEvent *event) override
double effectiveDevicePixelRatio() const
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or WebGPU) sizes.
vtkSmartPointer< vtkWebGPURenderWindow > RenderWindow
void initializeWebGPU()
Initialize the WebGPU render window with the native window handle.
double customDevicePixelRatio() const
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or WebGPU) sizes.
vtkWebGPURenderWindow * renderWindow() const
Returns the render window that is being shown in this widget.
void setDefaultCursor(const QCursor &cursor)
Set/get the default cursor to use for this widget.
~QVTKWebGPUWidget() override
bool enableHiDPI() const
Enable or disable support for HiDPI displays.
void setCustomDevicePixelRatio(double cdpr)
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or WebGPU) sizes.
QVTKWebGPUWidget(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
void updateSize()
Update the render window size based on the widget size.
int unscaledDPI() const
Set/Get unscaled DPI value.
void createSurfaceDescriptor()
Create the WebGPU surface descriptor from the native window handle.
void setUnscaledDPI(int dpi)
Set/Get unscaled DPI value.
bool event(QEvent *evt) override
QVTKInteractor * interactor() const
Get the QVTKInteractor that was either created by default or set by the user.
Hold a reference to a vtkObjectBase instance.
WebGPU rendering window.