VTK  9.7.20260825
QVTKWebGPUWidget Class Reference

#include <QVTKWebGPUWidget.h>

Detailed Description

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:

QPointer<QVTKWebGPUWidget> widget = new QVTKWebGPUWidget(...);
// Get the render window and add renderers, actors, etc.
vtkWebGPURenderWindow* renWin = widget->renderWindow();
renWin->AddRenderer(renderer);
QVTKWebGPUWidget(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
Allocate and hold a VTK object.
Definition vtkNew.h:168
virtual void AddRenderer(vtkRenderer *)
Add a renderer to the list of renderers.
WebGPU rendering window.
See also
vtkWebGPURenderWindow

Definition at line 43 of file QVTKWebGPUWidget.h.

Inherits QWidget.

Collaboration diagram for QVTKWebGPUWidget:
[legend]

Public Member Functions

 QVTKWebGPUWidget (QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
 ~QVTKWebGPUWidget () override
vtkWebGPURenderWindowrenderWindow () const
 Returns the render window that is being shown in this widget.
QVTKInteractorinteractor () 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< vtkWebGPURenderWindowRenderWindow
std::unique_ptr< QVTKInteractorAdapterInteractorAdapter

Constructor & Destructor Documentation

◆ QVTKWebGPUWidget()

QVTKWebGPUWidget::QVTKWebGPUWidget ( QWidget * parent = nullptr,
Qt::WindowFlags f = Qt::WindowFlags() )

◆ ~QVTKWebGPUWidget()

QVTKWebGPUWidget::~QVTKWebGPUWidget ( )
override

Member Function Documentation

◆ renderWindow()

vtkWebGPURenderWindow * QVTKWebGPUWidget::renderWindow ( ) const

Returns the render window that is being shown in this widget.

◆ interactor()

QVTKInteractor * QVTKWebGPUWidget::interactor ( ) const

Get the QVTKInteractor that was either created by default or set by the user.

◆ setEnableHiDPI()

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.

◆ enableHiDPI()

bool QVTKWebGPUWidget::enableHiDPI ( ) const
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.

◆ setUnscaledDPI()

void QVTKWebGPUWidget::setUnscaledDPI ( int dpi)

Set/Get unscaled DPI value.

Defaults to 72, which is also the default value in vtkWindow.

◆ unscaledDPI()

int QVTKWebGPUWidget::unscaledDPI ( ) const
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.

◆ setCustomDevicePixelRatio()

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.

◆ customDevicePixelRatio()

double QVTKWebGPUWidget::customDevicePixelRatio ( ) const
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.

◆ effectiveDevicePixelRatio()

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.

◆ setDefaultCursor()

void QVTKWebGPUWidget::setDefaultCursor ( const QCursor & cursor)

Set/get the default cursor to use for this widget.

◆ defaultCursor()

const QCursor & QVTKWebGPUWidget::defaultCursor ( ) const
inline

Set/get the default cursor to use for this widget.

Definition at line 106 of file QVTKWebGPUWidget.h.

◆ resizeEvent()

void QVTKWebGPUWidget::resizeEvent ( QResizeEvent * event)
overrideprotected

◆ paintEvent()

void QVTKWebGPUWidget::paintEvent ( QPaintEvent * event)
overrideprotected

◆ event()

bool QVTKWebGPUWidget::event ( QEvent * evt)
overrideprotected

◆ initializeWebGPU()

void QVTKWebGPUWidget::initializeWebGPU ( )
protected

Initialize the WebGPU render window with the native window handle.

◆ createSurfaceDescriptor()

void QVTKWebGPUWidget::createSurfaceDescriptor ( )
protected

Create the WebGPU surface descriptor from the native window handle.

◆ updateSize()

void QVTKWebGPUWidget::updateSize ( )
protected

Update the render window size based on the widget size.

Member Data Documentation

◆ RenderWindow

vtkSmartPointer<vtkWebGPURenderWindow> QVTKWebGPUWidget::RenderWindow
protected

Definition at line 129 of file QVTKWebGPUWidget.h.

◆ InteractorAdapter

std::unique_ptr<QVTKInteractorAdapter> QVTKWebGPUWidget::InteractorAdapter
protected

Definition at line 130 of file QVTKWebGPUWidget.h.


The documentation for this class was generated from the following file: