VTK  9.1.0
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
 
vtkRenderWindowrenderWindow () const
 Returns the render window that is being shown in this widget. More...
 
QVTKInteractorinteractor () 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...
 
QVTKOpenGLWindowembeddedOpenGLWindow () 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...
 
QVTKInteractorAdapterGetInteractorAdapter ()
 
void setQVTKCursor (const QCursor &cursor)
 
void setDefaultQVTKCursor (const QCursor &cursor)
 
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 SetRenderWindow (vtkGenericOpenGLRenderWindow *win)
 
void SetRenderWindow (vtkRenderWindow *win)
 
vtkRenderWindowGetRenderWindow ()
 These methods have be deprecated to fix naming style. More...
 
QVTKInteractorGetInteractor ()
 These methods have be deprecated to fix naming style. 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 66 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 85 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 89 of file QVTKOpenGLStereoWidget.h.

◆ renderWindow()

vtkRenderWindow * QVTKOpenGLStereoWidget::renderWindow ( ) const
inline

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

Definition at line 95 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 100 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 105 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 113 of file QVTKOpenGLStereoWidget.h.

◆ enableHiDPI()

bool QVTKOpenGLStereoWidget::enableHiDPI ( ) const
inline

Definition at line 114 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 121 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 122 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 139 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 143 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 144 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 154 of file QVTKOpenGLStereoWidget.h.

◆ defaultCursor()

const QCursor & QVTKOpenGLStereoWidget::defaultCursor ( ) const
inline

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

Definition at line 155 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 162 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 173 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 184 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 189 of file QVTKOpenGLStereoWidget.h.

◆ SetRenderWindow() [1/2]

void QVTKOpenGLStereoWidget::SetRenderWindow ( vtkGenericOpenGLRenderWindow win)
Deprecated:
in VTK 8.3

◆ SetRenderWindow() [2/2]

void QVTKOpenGLStereoWidget::SetRenderWindow ( vtkRenderWindow win)
Deprecated:
in VTK 8.3

◆ GetRenderWindow()

vtkRenderWindow * QVTKOpenGLStereoWidget::GetRenderWindow ( )

These methods have be deprecated to fix naming style.

Since QVTKOpenGLNativeWidget is QObject subclass, we follow Qt naming conventions rather than VTK's.

◆ GetInteractor()

QVTKInteractor * QVTKOpenGLStereoWidget::GetInteractor ( )

These methods have be deprecated to fix naming style.

Since QVTKOpenGLNativeWidget is QObject subclass, we follow Qt naming conventions rather than VTK's.

◆ GetInteractorAdapter()

QVTKInteractorAdapter * QVTKOpenGLStereoWidget::GetInteractorAdapter ( )
Deprecated:
in VTK 8.3 QVTKInteractorAdapter is an internal helper. Hence the API was removed.

◆ setQVTKCursor()

void QVTKOpenGLStereoWidget::setQVTKCursor ( const QCursor &  cursor)
Deprecated:
in VTK 8.3. Simply use QWidget::setCursor API to change cursor.

◆ setDefaultQVTKCursor()

void QVTKOpenGLStereoWidget::setDefaultQVTKCursor ( const QCursor &  cursor)
Deprecated:
in VTK 8.3. Use setDefaultCursor instead.

◆ 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: