VTK  9.1.0
Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Friends | List of all members
QVTKOpenGLWindow Class Reference

display a vtkGenericOpenGLRenderWindow in a Qt QOpenGLWindow. More...

#include <QVTKOpenGLWindow.h>

Inherits QOpenGLWindow.

Collaboration diagram for QVTKOpenGLWindow:
[legend]

Signals

void windowEvent (QEvent *e)
 Signal emitted when any event has been receive, with the corresponding event as argument. More...
 

Public Member Functions

 QVTKOpenGLWindow (QOpenGLWindow::UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
 
 QVTKOpenGLWindow (QOpenGLContext *shareContext, QOpenGLWindow::UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
 
 QVTKOpenGLWindow (vtkGenericOpenGLRenderWindow *renderWindow, QOpenGLWindow::UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
 
 QVTKOpenGLWindow (vtkGenericOpenGLRenderWindow *renderWindow, QOpenGLContext *shareContext, QOpenGLWindow::UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
 
 ~QVTKOpenGLWindow () 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...
 
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 setEnableHiDPI (bool enable)
 Enable or disable support for HiDPI displays. More...
 
bool enableHiDPI () const
 Enable or disable support for HiDPI displays. More...
 
void setUnscaledDPI (int)
 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 Slots

void cleanupContext ()
 Called as a response to QOpenGLContext::aboutToBeDestroyed. More...
 
void updateSize ()
 

Protected Member Functions

bool event (QEvent *evt) override
 
void initializeGL () override
 
void paintGL () override
 
void resizeGL (int w, int h) override
 

Protected Attributes

vtkSmartPointer< vtkGenericOpenGLRenderWindowRenderWindow
 
QScopedPointer< QVTKRenderWindowAdapterRenderWindowAdapter
 

Friends

class QVTKOpenGLStereoWidget
 QVTKOpenGLStereoWidget is given friendship so it can call cleanupContext in its destructor to ensure that OpenGL state is proporly cleaned up before the widget goes away. More...
 

Detailed Description

display a vtkGenericOpenGLRenderWindow in a Qt QOpenGLWindow.

QVTKOpenGLWindow is one of the mechanisms for displaying VTK rendering results in a Qt application. QVTKOpenGLWindow extends QOpenGLWindow to display the rendering results of a vtkGenericOpenGLRenderWindow.

Since QVTKOpenGLWindow is based on QOpenGLWindow it is intended for rendering in a top-level window. QVTKOpenGLWindow can be embedded in a another QWidget using QWidget::createWindowContainer or by using QVTKOpenGLStereoWidget instead. However, developers are encouraged to check Qt documentation for QWidget::createWindowContainer idiosyncrasies. Using QVTKOpenGLNativeWidget instead is generally a better choice for causes where you want to embed VTK rendering results in a QWidget. QVTKOpenGLWindow or QVTKOpenGLStereoWidget is still preferred for applications that want to support quad-buffer based stereo rendering.

To request a specific configuration for the context, use QWindow::setFormat() like for any other QWindow. This allows, among others, requesting a given OpenGL version and profile. Use QOpenGLWindow::defaultFormat() to obtain a QSurfaceFormat with appropriate OpenGL version configuration. To enable quad-buffer stereo, you'll need to call QSurfaceFormat::setStereo(true).

VTK Rendering features like multi-sampling, double buffering etc. are enabled/disabled by directly setting the corresponding attributes on vtkGenericOpenGLRenderWindow and not when specifying the OpenGL context format in setFormat. If not specified, then QSurfaceFormat::defaultFormat will be used.

Note
QVTKOpenGLWindow requires Qt version 5.9 and above.
See also
QVTKOpenGLStereoWidget QVTKOpenGLNativeWidget

Definition at line 66 of file QVTKOpenGLWindow.h.

Constructor & Destructor Documentation

◆ QVTKOpenGLWindow() [1/4]

QVTKOpenGLWindow::QVTKOpenGLWindow ( QOpenGLWindow::UpdateBehavior  updateBehavior = NoPartialUpdate,
QWindow *  parent = nullptr 
)

◆ QVTKOpenGLWindow() [2/4]

QVTKOpenGLWindow::QVTKOpenGLWindow ( QOpenGLContext *  shareContext,
QOpenGLWindow::UpdateBehavior  updateBehavior = NoPartialUpdate,
QWindow *  parent = nullptr 
)

◆ QVTKOpenGLWindow() [3/4]

QVTKOpenGLWindow::QVTKOpenGLWindow ( vtkGenericOpenGLRenderWindow renderWindow,
QOpenGLWindow::UpdateBehavior  updateBehavior = NoPartialUpdate,
QWindow *  parent = nullptr 
)

◆ QVTKOpenGLWindow() [4/4]

QVTKOpenGLWindow::QVTKOpenGLWindow ( vtkGenericOpenGLRenderWindow renderWindow,
QOpenGLContext *  shareContext,
QOpenGLWindow::UpdateBehavior  updateBehavior = NoPartialUpdate,
QWindow *  parent = nullptr 
)

◆ ~QVTKOpenGLWindow()

QVTKOpenGLWindow::~QVTKOpenGLWindow ( )
override

Member Function Documentation

◆ setRenderWindow() [1/2]

void QVTKOpenGLWindow::setRenderWindow ( vtkGenericOpenGLRenderWindow win)

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.

◆ setRenderWindow() [2/2]

void QVTKOpenGLWindow::setRenderWindow ( vtkRenderWindow win)

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.

◆ renderWindow()

vtkRenderWindow * QVTKOpenGLWindow::renderWindow ( ) const

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

◆ interactor()

QVTKInteractor * QVTKOpenGLWindow::interactor ( ) const

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

◆ defaultFormat()

static QSurfaceFormat QVTKOpenGLWindow::defaultFormat ( bool  stereo_capable = false)
static

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().

◆ setEnableHiDPI()

void QVTKOpenGLWindow::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 QVTKOpenGLWindow::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 116 of file QVTKOpenGLWindow.h.

◆ setUnscaledDPI()

void QVTKOpenGLWindow::setUnscaledDPI ( int  )

Set/Get unscaled DPI value.

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

◆ unscaledDPI()

int QVTKOpenGLWindow::unscaledDPI ( ) const
inline

Set/Get unscaled DPI value.

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

Definition at line 125 of file QVTKOpenGLWindow.h.

◆ setCustomDevicePixelRatio()

void QVTKOpenGLWindow::setCustomDevicePixelRatio ( double  cdpr)

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.

◆ customDevicePixelRatio()

double QVTKOpenGLWindow::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 QVTKOpenGLWindow.h.

◆ effectiveDevicePixelRatio()

double QVTKOpenGLWindow::effectiveDevicePixelRatio ( ) const

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.

◆ setDefaultCursor()

void QVTKOpenGLWindow::setDefaultCursor ( const QCursor &  cursor)

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

◆ defaultCursor()

const QCursor & QVTKOpenGLWindow::defaultCursor ( ) const
inline

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

Definition at line 152 of file QVTKOpenGLWindow.h.

◆ SetRenderWindow() [1/2]

void QVTKOpenGLWindow::SetRenderWindow ( vtkGenericOpenGLRenderWindow win)
Deprecated:
in VTK 9.0. Use setRenderWindow instead.

◆ SetRenderWindow() [2/2]

void QVTKOpenGLWindow::SetRenderWindow ( vtkRenderWindow win)
Deprecated:
in VTK 9.0. Use setRenderWindow instead.

◆ GetRenderWindow()

vtkRenderWindow * QVTKOpenGLWindow::GetRenderWindow ( )

These methods have be deprecated to fix naming style.

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

◆ GetInteractor()

QVTKInteractor * QVTKOpenGLWindow::GetInteractor ( )

These methods have be deprecated to fix naming style.

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

◆ GetInteractorAdapter()

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

◆ setQVTKCursor()

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

◆ setDefaultQVTKCursor()

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

◆ windowEvent

void QVTKOpenGLWindow::windowEvent ( QEvent *  e)
signal

Signal emitted when any event has been receive, with the corresponding event as argument.

◆ cleanupContext

void QVTKOpenGLWindow::cleanupContext ( )
protectedslot

Called as a response to QOpenGLContext::aboutToBeDestroyed.

This may be called anytime during the widget lifecycle. We need to release any OpenGL resources allocated in VTK work in this method.

◆ updateSize

void QVTKOpenGLWindow::updateSize ( )
protectedslot

◆ event()

bool QVTKOpenGLWindow::event ( QEvent *  evt)
overrideprotected

◆ initializeGL()

void QVTKOpenGLWindow::initializeGL ( )
overrideprotected

◆ paintGL()

void QVTKOpenGLWindow::paintGL ( )
overrideprotected

◆ resizeGL()

void QVTKOpenGLWindow::resizeGL ( int  w,
int  h 
)
overrideprotected

Friends And Related Function Documentation

◆ QVTKOpenGLStereoWidget

friend class QVTKOpenGLStereoWidget
friend

QVTKOpenGLStereoWidget is given friendship so it can call cleanupContext in its destructor to ensure that OpenGL state is proporly cleaned up before the widget goes away.

Definition at line 219 of file QVTKOpenGLWindow.h.

Member Data Documentation

◆ RenderWindow

vtkSmartPointer<vtkGenericOpenGLRenderWindow> QVTKOpenGLWindow::RenderWindow
protected

Definition at line 228 of file QVTKOpenGLWindow.h.

◆ RenderWindowAdapter

QScopedPointer<QVTKRenderWindowAdapter> QVTKOpenGLWindow::RenderWindowAdapter
protected

Definition at line 229 of file QVTKOpenGLWindow.h.


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