|
VTK
9.7.20260825
|
#include <QVTKWebGPUWidget.h>
QWidget subclass to house a vtkWebGPURenderWindow in a Qt application.
QVTKWebGPUWidget extends QWidget to make it work with a vtkWebGPURenderWindow. It creates a WebGPU surface from the native Qt window handle and sets it on the render window using a custom surface descriptor.
A typical usage for QVTKWebGPUWidget is as follows:
Definition at line 43 of file QVTKWebGPUWidget.h.
Inherits QWidget.
Public Member Functions | |
| QVTKWebGPUWidget (QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags()) | |
| ~QVTKWebGPUWidget () override | |
| vtkWebGPURenderWindow * | 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. | |
| void | setEnableHiDPI (bool enable) |
| Enable or disable support for HiDPI displays. | |
| bool | enableHiDPI () const |
| Enable or disable support for HiDPI displays. | |
| void | setUnscaledDPI (int dpi) |
| Set/Get unscaled DPI value. | |
| 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 WebGPU) sizes. | |
| double | customDevicePixelRatio () const |
| Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or WebGPU) sizes. | |
| double | effectiveDevicePixelRatio () const |
| Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or WebGPU) sizes. | |
| void | setDefaultCursor (const QCursor &cursor) |
| Set/get the default cursor to use for this widget. | |
| const QCursor & | defaultCursor () const |
| Set/get the default cursor to use for this widget. | |
Protected Member Functions | |
| void | resizeEvent (QResizeEvent *event) override |
| void | paintEvent (QPaintEvent *event) override |
| bool | event (QEvent *evt) override |
| void | initializeWebGPU () |
| Initialize the WebGPU render window with the native window handle. | |
| void | createSurfaceDescriptor () |
| Create the WebGPU surface descriptor from the native window handle. | |
| void | updateSize () |
| Update the render window size based on the widget size. | |
Protected Attributes | |
| vtkSmartPointer< vtkWebGPURenderWindow > | RenderWindow |
| std::unique_ptr< QVTKInteractorAdapter > | InteractorAdapter |
| QVTKWebGPUWidget::QVTKWebGPUWidget | ( | QWidget * | parent = nullptr, |
| Qt::WindowFlags | f = Qt::WindowFlags() ) |
|
override |
| vtkWebGPURenderWindow * QVTKWebGPUWidget::renderWindow | ( | ) | const |
Returns the render window that is being shown in this widget.
| QVTKInteractor * QVTKWebGPUWidget::interactor | ( | ) | const |
Get the QVTKInteractor that was either created by default or set by the user.
| void QVTKWebGPUWidget::setEnableHiDPI | ( | bool | enable | ) |
Enable or disable support for HiDPI displays.
When enabled, this enabled DPI scaling i.e. vtkWindow::SetDPI will be called with a DPI value scaled by the device pixel ratio every time the widget is resized. The unscaled DPI value can be specified by using setUnscaledDPI.
|
inline |
Enable or disable support for HiDPI displays.
When enabled, this enabled DPI scaling i.e. vtkWindow::SetDPI will be called with a DPI value scaled by the device pixel ratio every time the widget is resized. The unscaled DPI value can be specified by using setUnscaledDPI.
Definition at line 70 of file QVTKWebGPUWidget.h.
| void QVTKWebGPUWidget::setUnscaledDPI | ( | int | dpi | ) |
Set/Get unscaled DPI value.
Defaults to 72, which is also the default value in vtkWindow.
|
inline |
Set/Get unscaled DPI value.
Defaults to 72, which is also the default value in vtkWindow.
Definition at line 79 of file QVTKWebGPUWidget.h.
| void QVTKWebGPUWidget::setCustomDevicePixelRatio | ( | double | cdpr | ) |
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or WebGPU) sizes.
Thus, when the QWidget is resized, it called vtkRenderWindow::SetSize on the internal vtkRenderWindow after multiplying the QWidget's size by this scale factor.
By default, this is set to 0. Which means that devicePixelRatio obtained from Qt will be used. Set this to a number greater than 0 to override this behaviour and use the custom scale factor instead.
effectiveDevicePixelRatio can be used to obtain the device-pixel-ratio that will be used given the value for customDevicePixelRatio.
|
inline |
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or WebGPU) sizes.
Thus, when the QWidget is resized, it called vtkRenderWindow::SetSize on the internal vtkRenderWindow after multiplying the QWidget's size by this scale factor.
By default, this is set to 0. Which means that devicePixelRatio obtained from Qt will be used. Set this to a number greater than 0 to override this behaviour and use the custom scale factor instead.
effectiveDevicePixelRatio can be used to obtain the device-pixel-ratio that will be used given the value for customDevicePixelRatio.
Definition at line 97 of file QVTKWebGPUWidget.h.
| double QVTKWebGPUWidget::effectiveDevicePixelRatio | ( | ) | const |
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or WebGPU) sizes.
Thus, when the QWidget is resized, it called vtkRenderWindow::SetSize on the internal vtkRenderWindow after multiplying the QWidget's size by this scale factor.
By default, this is set to 0. Which means that devicePixelRatio obtained from Qt will be used. Set this to a number greater than 0 to override this behaviour and use the custom scale factor instead.
effectiveDevicePixelRatio can be used to obtain the device-pixel-ratio that will be used given the value for customDevicePixelRatio.
| void QVTKWebGPUWidget::setDefaultCursor | ( | const QCursor & | cursor | ) |
Set/get the default cursor to use for this widget.
|
inline |
Set/get the default cursor to use for this widget.
Definition at line 106 of file QVTKWebGPUWidget.h.
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
protected |
Initialize the WebGPU render window with the native window handle.
|
protected |
Create the WebGPU surface descriptor from the native window handle.
|
protected |
Update the render window size based on the widget size.
|
protected |
Definition at line 129 of file QVTKWebGPUWidget.h.
|
protected |
Definition at line 130 of file QVTKWebGPUWidget.h.