VTK: QVTKOpenGLStereoWidget Class Reference

| VTK 9.3.1

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QVTKOpenGLStereoWidget Class Reference

QWidget for displaying a vtkRenderWindow in a Qt Application. More...

`#include <QVTKOpenGLStereoWidget.h>`

Inherits QWidget.

## Public Member Functions
| QVTKOpenGLStereoWidget (QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
| QVTKOpenGLStereoWidget (QOpenGLContext *shareContext, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
| QVTKOpenGLStereoWidget (vtkGenericOpenGLRenderWindow *w, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
| QVTKOpenGLStereoWidget (vtkGenericOpenGLRenderWindow *w, QOpenGLContext *shareContext, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
| ~QVTKOpenGLStereoWidget () override
vtkRenderWindow * | renderWindow () const
| Returns the render window that is being shown in this widget. More...
QVTKInteractor * | interactor () const
| Get the QVTKInteractor that was either created by default or set by the user. More...
void | setEnableHiDPI (bool enable)
| Enable or disable support for HiDPI displays. More...
bool | enableHiDPI () const
bool | isValid ()
| Returns true if the internal QOpenGLWindow's is valid, i.e. More...
QImage | grabFramebuffer ()
| Expose internal QVTKOpenGLWindow::grabFramebuffer(). More...
QVTKOpenGLWindow * | embeddedOpenGLWindow () const
| Returns the embedded QVTKOpenGLWindow. More...
void | setFormat (const QSurfaceFormat &fmt)
| Sets the requested surface format. More...
QSurfaceFormat | format () const
| Returns the context and surface format used by this widget and its toplevel window. More...
void | setRenderWindow (vtkGenericOpenGLRenderWindow *win)
| Set a render window to use. More...
void | setRenderWindow (vtkRenderWindow *win)
| Set a render window to use. More...
void | setUnscaledDPI (int dpi)
| Set/Get unscaled DPI value. More...
int | unscaledDPI () const
| Set/Get unscaled DPI value. More...
void | setCustomDevicePixelRatio (double cdpr)
| Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes. More...
double | customDevicePixelRatio () const
| Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes. More...
double | effectiveDevicePixelRatio () const
| Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes. More...
void | setDefaultCursor (const QCursor &cursor)
| Set/get the default cursor to use for this widget. More...
const QCursor & | defaultCursor () const
| Set/get the default cursor to use for this widget. More...
void | setCursorCustom (const QCursor &cursor)
| Set/get the cursor to use for this widget. More...
QCursor | cursorCustom () const
| Set/get the cursor to use for this widget. More...

## Static Public Member Functions
static QSurfaceFormat | defaultFormat (bool stereo_capable=false)
| Returns a QSurfaceFormat suitable for surfaces that intend to be used for VTK rendering. More...

## Protected Member Functions
void | resizeEvent (QResizeEvent *evt) override
void | paintEvent (QPaintEvent *evt) override

## Detailed Description

QWidget for displaying a vtkRenderWindow in a Qt Application.

QVTKOpenGLStereoWidget simplifies using a QVTKOpenGLWindow as a widget in Qt application so it can be embedded in a layout rather than being a top-level window. QVTKOpenGLWindow has all the limitations posed by Qt with `QWidget::createWindowContainer` hence developers are advised to refer to Qt docs for more details.

In general QVTKOpenGLNativeWidget may be a better choice, however QVTKOpenGLWindow-based QVTKOpenGLStereoWidget may be better choice for applications requiring quad-buffer stereo.

Due to Qt limitations, QVTKOpenGLStereoWidget does not support being a native widget. But native widget are sometimes mandatory, for example within QScrollArea and QMDIArea, so the QVTKOpenGLNativeWidget should be used when in needs of VTK rendering in the context of Qt native widget.

If a QVTKOpenGLStereoWidget is used in a QScrollArea or in a QMDIArea, it will force it to be native and this is NOT supported.

Unlike QVTKOpenGLNativeWidget, QVTKOpenGLStereoWidget does not require that the default surface format for the application be changed. One can simply specify the needed QSurfaceFormat for the specific QVTKOpenGLStereoWidget instance by calling `QVTKOpenGLStereoWidget::setFormat` before the widget is initialized.

See also
  QVTKOpenGLWindow QVTKOpenGLNativeWidget QVTKRenderWidget

Definition at line 53 of file QVTKOpenGLStereoWidget.h.

## Constructor & Destructor Documentation

## ◆ QVTKOpenGLStereoWidget() [1/4]

QVTKOpenGLStereoWidget::QVTKOpenGLStereoWidget | ( | QWidget * | parent = `nullptr`,
|  | Qt::WindowFlags | f = `Qt::WindowFlags()`
| ) |  |

## ◆ QVTKOpenGLStereoWidget() [2/4]

QVTKOpenGLStereoWidget::QVTKOpenGLStereoWidget | ( | QOpenGLContext * | shareContext,
|  | QWidget * | parent = `nullptr`,
|  | Qt::WindowFlags | f = `Qt::WindowFlags()`
| ) |  |

## ◆ QVTKOpenGLStereoWidget() [3/4]

QVTKOpenGLStereoWidget::QVTKOpenGLStereoWidget | ( | vtkGenericOpenGLRenderWindow * | w,
|  | QWidget * | parent = `nullptr`,
|  | Qt::WindowFlags | f = `Qt::WindowFlags()`
| ) |  |

## ◆ QVTKOpenGLStereoWidget() [4/4]

QVTKOpenGLStereoWidget::QVTKOpenGLStereoWidget | ( | vtkGenericOpenGLRenderWindow * | w,
|  | QOpenGLContext * | shareContext,
|  | QWidget * | parent = `nullptr`,
|  | Qt::WindowFlags | f = `Qt::WindowFlags()`
| ) |  |

## ◆ ~QVTKOpenGLStereoWidget()

QVTKOpenGLStereoWidget::~QVTKOpenGLStereoWidget | ( |  | ) |
| override

## Member Function Documentation

## ◆ setRenderWindow() [1/2]

void QVTKOpenGLStereoWidget::setRenderWindow | ( | vtkGenericOpenGLRenderWindow * | win | ) |
| inline

Set a render window to use.

It a render window was already set, it will be finalized and all of its OpenGL resource released. If the `win` is non-null and it has no interactor set, then a QVTKInteractor instance will be created as set on the render window as the interactor.

Definition at line 72 of file QVTKOpenGLStereoWidget.h.

## ◆ setRenderWindow() [2/2]

void QVTKOpenGLStereoWidget::setRenderWindow | ( | vtkRenderWindow * | win | ) |
| inline

Set a render window to use.

It a render window was already set, it will be finalized and all of its OpenGL resource released. If the `win` is non-null and it has no interactor set, then a QVTKInteractor instance will be created as set on the render window as the interactor.

Definition at line 76 of file QVTKOpenGLStereoWidget.h.

## ◆ renderWindow()

vtkRenderWindow* QVTKOpenGLStereoWidget::renderWindow | ( |  | ) | const
| inline

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

Definition at line 82 of file QVTKOpenGLStereoWidget.h.

## ◆ interactor()

QVTKInteractor* QVTKOpenGLStereoWidget::interactor | ( |  | ) | const
| inline

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

Definition at line 87 of file QVTKOpenGLStereoWidget.h.

## ◆ defaultFormat()

static QSurfaceFormat QVTKOpenGLStereoWidget::defaultFormat | ( | bool | stereo_capable = `false` | ) |
| inlinestatic

Returns a QSurfaceFormat suitable for surfaces that intend to be used for VTK rendering.

If your applications plans on using `QVTKOpenGLNativeWidget`, then this format (or similar) must be set as the default format on QSurfaceFormat before any widgets are created.

Note this returns a QSurfaceFormat required to support the OpenGL rendering capabilities in a vtkRenderWindow. Whether those features, e.g. multi sampling, is actually used for rendering is determined by values specified on the vtkRenderWindow instance itself through appropriate API.

Passing `stereo_capable=true` is same as calling `QSurfaceFormat::setStereo(true)`. This is necessary if you want to use quad-buffer based stereo in your application.

Refer to Qt docs for QOpenGLWidget and QOpenGLWindow for appropriate locations in your application where to the format may be provided e.g. either on the instance of QOpenGLWindow or QOpenGLWidget subclasses or as default format for the application using `QSurfaceFormat::setDefaultFormat()`.

Definition at line 92 of file QVTKOpenGLStereoWidget.h.

## ◆ setEnableHiDPI()

void QVTKOpenGLStereoWidget::setEnableHiDPI | ( | bool | enable | ) |
| 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 100 of file QVTKOpenGLStereoWidget.h.

## ◆ enableHiDPI()

bool QVTKOpenGLStereoWidget::enableHiDPI | ( |  | ) | const
| inline

Definition at line 101 of file QVTKOpenGLStereoWidget.h.

## ◆ setUnscaledDPI()

void QVTKOpenGLStereoWidget::setUnscaledDPI | ( | int | dpi | ) |
| inline

Set/Get unscaled DPI value.

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

Definition at line 108 of file QVTKOpenGLStereoWidget.h.

## ◆ unscaledDPI()

int QVTKOpenGLStereoWidget::unscaledDPI | ( |  | ) | const
| inline

Set/Get unscaled DPI value.

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

Definition at line 109 of file QVTKOpenGLStereoWidget.h.

## ◆ setCustomDevicePixelRatio()

void QVTKOpenGLStereoWidget::setCustomDevicePixelRatio | ( | double | cdpr | ) |
| inline

Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) 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 126 of file QVTKOpenGLStereoWidget.h.

## ◆ customDevicePixelRatio()

double QVTKOpenGLStereoWidget::customDevicePixelRatio | ( |  | ) | const
| inline

Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) 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 130 of file QVTKOpenGLStereoWidget.h.

## ◆ effectiveDevicePixelRatio()

double QVTKOpenGLStereoWidget::effectiveDevicePixelRatio | ( |  | ) | const
| inline

Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) 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 131 of file QVTKOpenGLStereoWidget.h.

## ◆ setDefaultCursor()

void QVTKOpenGLStereoWidget::setDefaultCursor | ( | const QCursor & | cursor | ) |
| inline

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

Definition at line 141 of file QVTKOpenGLStereoWidget.h.

## ◆ defaultCursor()

const QCursor& QVTKOpenGLStereoWidget::defaultCursor | ( |  | ) | const
| inline

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

Definition at line 142 of file QVTKOpenGLStereoWidget.h.

## ◆ setCursorCustom()

void QVTKOpenGLStereoWidget::setCursorCustom | ( | const QCursor & | cursor | ) |
| inline

Set/get the cursor to use for this widget.

Internally calls QWindow::setCursor / QWindow::cursor on the embedded window.

Definition at line 150 of file QVTKOpenGLStereoWidget.h.

## ◆ cursorCustom()

QCursor QVTKOpenGLStereoWidget::cursorCustom | ( |  | ) | const
| inline

Set/get the cursor to use for this widget.

Internally calls QWindow::setCursor / QWindow::cursor on the embedded window.

Definition at line 151 of file QVTKOpenGLStereoWidget.h.

## ◆ isValid()

bool QVTKOpenGLStereoWidget::isValid | ( |  | ) |
| inline

Returns true if the internal QOpenGLWindow's is valid, i.e.

if OpenGL resources, like the context, have been successfully initialized.

Definition at line 158 of file QVTKOpenGLStereoWidget.h.

## ◆ grabFramebuffer()

QImage QVTKOpenGLStereoWidget::grabFramebuffer | ( |  | ) |

Expose internal QVTKOpenGLWindow::grabFramebuffer().

Renders and returns a 32-bit RGB image of the framebuffer.

## ◆ embeddedOpenGLWindow()

QVTKOpenGLWindow* QVTKOpenGLStereoWidget::embeddedOpenGLWindow | ( |  | ) | const
| inline

Returns the embedded QVTKOpenGLWindow.

Definition at line 169 of file QVTKOpenGLStereoWidget.h.

## ◆ setFormat()

void QVTKOpenGLStereoWidget::setFormat | ( | const QSurfaceFormat & | fmt | ) |
| inline

Sets the requested surface format.

When the format is not explicitly set via this function, the format returned by QSurfaceFormat::defaultFormat() will be used. This means that when having multiple OpenGL widgets, individual calls to this function can be replaced by one single call to QSurfaceFormat::setDefaultFormat() before creating the first widget.

Definition at line 180 of file QVTKOpenGLStereoWidget.h.

## ◆ format()

QSurfaceFormat QVTKOpenGLStereoWidget::format | ( |  | ) | const
| inline

Returns the context and surface format used by this widget and its toplevel window.

Definition at line 185 of file QVTKOpenGLStereoWidget.h.

## ◆ resizeEvent()

void QVTKOpenGLStereoWidget::resizeEvent | ( | QResizeEvent * | evt | ) |
| overrideprotected

## ◆ paintEvent()

void QVTKOpenGLStereoWidget::paintEvent | ( | QPaintEvent * | evt | ) |
| overrideprotected

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

- GUISupport/Qt/QVTKOpenGLStereoWidget.h