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

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

#include <QVTKOpenGLWindow.h>

Inherits QOpenGLWindow.

Public Slots

virtual void MakeCurrent ()
 slot to make this vtk render window current More...
 
virtual void IsCurrent (vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
 slot called when vtk wants to know if the context is current More...
 
virtual void Frame ()
 slot called when vtk wants to frame the window More...
 
virtual void Start ()
 slot called when vtk wants to start the render More...
 
virtual void End ()
 slot called when vtk wants to end the render More...
 
virtual void IsDirect (vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
 slot called when vtk wants to know if a window is direct More...
 
virtual void SupportsOpenGL (vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
 slot called when vtk wants to know if a window supports OpenGL More...
 
virtual void UpdateStereoType (vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
 slot called when the stereo type of the render window changed More...
 
virtual void ChangeCursor (vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
 
virtual void widgetEvent (QEvent *e)
 slot to process events coming from the widget containing this window More...
 
virtual bool isValid ()
 Returns true if the internal QOpenGLWindow's is valid, i.e. More...
 
virtual bool isCurrent ()
 Returns true if the internal OpenGL contect is the actual current OpenGL context, false otherwise. More...
 

Signals

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

Public Member Functions

 QVTKOpenGLWindow ()
 
 QVTKOpenGLWindow (vtkGenericOpenGLRenderWindow *w, QOpenGLContext *shareContext=QOpenGLContext::currentContext(), UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=Q_NULLPTR)
 
 QVTKOpenGLWindow (QOpenGLContext *shareContext, UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=Q_NULLPTR)
 
 ~QVTKOpenGLWindow ()
 
virtual void SetRenderWindow (vtkGenericOpenGLRenderWindow *)
 Set the VTK render window used for rendering. More...
 
virtual vtkGenericOpenGLRenderWindowGetRenderWindow ()
 Get the VTK render window used for rendering. More...
 
virtual QVTKInteractorAdapterGetInteractorAdapter ()
 Get the QEvent to VTK events translator. More...
 
virtual void setEnableHiDPI (bool enable)
 Enable or disable support for HiDPI displays. More...
 
bool ProcessEvent (QEvent *e)
 Process a QEvent and send it to the internal render window interactor returns whether the event was recognized and processed. More...
 

Static Public Member Functions

static void copyFromFormat (const QSurfaceFormat &format, vtkRenderWindow *win)
 Sets up vtkRenderWindow ivars using QSurfaceFormat. More...
 
static void copyToFormat (vtkRenderWindow *win, QSurfaceFormat &format)
 Using the vtkRenderWindow, setup QSurfaceFormat. More...
 
static QSurfaceFormat defaultFormat ()
 Returns a typical QSurfaceFormat suitable for most applications using QVTKOpenGLWidget. More...
 

Protected Member Functions

virtual void initializeGL ()
 Override event handler. More...
 
virtual void paintGL ()
 
virtual void moveEvent (QMoveEvent *event)
 
virtual bool event (QEvent *e)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void enterEvent (QEvent *)
 
virtual void leaveEvent (QEvent *)
 
virtual void wheelEvent (QWheelEvent *)
 

Detailed Description

display a vtkGenericOpenGLRenderWindow in a Qt QOpenGLWindow.

QVTKOpenGLWindow provides a way to display VTK data in a Qt OpenGL context.

QVTKOpenGLWindow extends QOpenGLWindow to make it work with a vtkGenericOpenGLRenderWindow. This is akin to QVTKOpenGLNativeWidget except the OpenGL context is created and managed by QOpenGLWindow (added in Qt 5.4).

While QVTKOpenGLWindow is intended to be a replacement for QVTKOpenGLNativeWidget, there are a few difference between both. Unlike QVTKOpenGLNativeWidget, QVTKOpenGLWindow can target multiple framebuffers and thus allows for stereo-capable applications. QVTKOpenGLWindow API was adapted from deprecated QVTKWidget2.

Since QVTKOpenGLWindow uses QOpenGLWindow to create the OpenGL context, it uses QSurfaceFormat (set using QOpenGLWidget::setFormat or QSurfaceFormat::setDefaultFormat)to create appropriate window and context.

Since QOpenGLWindow (superclass for QVTKOpenGLWindow) is not a subclass of QWidget, a typical usage for QVTKOpenGLWindow is as follows:

QPointer<QVTKOpenGLWindow> qWindow = new QVTKOpenGLWindow(window);
// You can continue to use `window` as a regular vtkRenderWindow
// including adding renderers, actors etc.
// Get QVTKOpenGLWindow `widget` instance as a QWidget instance and add it
// to the parent widget.
QWidget* container =
QWidget::createWindowContainer(qWindow, parent);
// Set flag to propagate Mouse events to the parent
container->setAttribute(Qt::WA_TransparentForMouseEvents);

QVTKOpenGLWidget provides a wrapper around QVTKOpenGLWindow to manipulate a QVTKOpenGLWindow object as a QWidget instance, it is recommended to use QVTKOpenGLWidget instead of using this class directly.

QVTKOpenGLWindow is targeted for Qt version 5.9 and above.

See also
QVTKOpenGLWidget QVTKOpenGLNativeWidget QVTKWidget2

Definition at line 78 of file QVTKOpenGLWindow.h.

Constructor & Destructor Documentation

QVTKOpenGLWindow::QVTKOpenGLWindow ( )
QVTKOpenGLWindow::QVTKOpenGLWindow ( vtkGenericOpenGLRenderWindow w,
QOpenGLContext *  shareContext = QOpenGLContext::currentContext(),
UpdateBehavior  updateBehavior = NoPartialUpdate,
QWindow *  parent = Q_NULLPTR 
)
QVTKOpenGLWindow::QVTKOpenGLWindow ( QOpenGLContext *  shareContext,
UpdateBehavior  updateBehavior = NoPartialUpdate,
QWindow *  parent = Q_NULLPTR 
)
QVTKOpenGLWindow::~QVTKOpenGLWindow ( )

Member Function Documentation

virtual void QVTKOpenGLWindow::SetRenderWindow ( vtkGenericOpenGLRenderWindow )
virtual

Set the VTK render window used for rendering.

virtual vtkGenericOpenGLRenderWindow* QVTKOpenGLWindow::GetRenderWindow ( )
virtual

Get the VTK render window used for rendering.

static void QVTKOpenGLWindow::copyFromFormat ( const QSurfaceFormat &  format,
vtkRenderWindow win 
)
static

Sets up vtkRenderWindow ivars using QSurfaceFormat.

static void QVTKOpenGLWindow::copyToFormat ( vtkRenderWindow win,
QSurfaceFormat &  format 
)
static

Using the vtkRenderWindow, setup QSurfaceFormat.

static QSurfaceFormat QVTKOpenGLWindow::defaultFormat ( )
static

Returns a typical QSurfaceFormat suitable for most applications using QVTKOpenGLWidget.

Note that this is not the QSurfaceFormat that gets used if none is specified. That is set using QSurfaceFormat::setDefaultFormat.

virtual QVTKInteractorAdapter* QVTKOpenGLWindow::GetInteractorAdapter ( )
virtual

Get the QEvent to VTK events translator.

virtual void QVTKOpenGLWindow::setEnableHiDPI ( bool  enable)
virtual

Enable or disable support for HiDPI displays.

bool QVTKOpenGLWindow::ProcessEvent ( QEvent *  e)

Process a QEvent and send it to the internal render window interactor returns whether the event was recognized and processed.

void QVTKOpenGLWindow::windowEvent ( QEvent *  e)
signal

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

virtual void QVTKOpenGLWindow::MakeCurrent ( )
virtualslot

slot to make this vtk render window current

virtual void QVTKOpenGLWindow::IsCurrent ( vtkObject caller,
unsigned long  vtk_event,
void *  client_data,
void *  call_data 
)
virtualslot

slot called when vtk wants to know if the context is current

virtual void QVTKOpenGLWindow::Frame ( )
virtualslot

slot called when vtk wants to frame the window

virtual void QVTKOpenGLWindow::Start ( )
virtualslot

slot called when vtk wants to start the render

virtual void QVTKOpenGLWindow::End ( )
inlinevirtualslot

slot called when vtk wants to end the render

Definition at line 171 of file QVTKOpenGLWindow.h.

virtual void QVTKOpenGLWindow::IsDirect ( vtkObject caller,
unsigned long  vtk_event,
void *  client_data,
void *  call_data 
)
virtualslot

slot called when vtk wants to know if a window is direct

virtual void QVTKOpenGLWindow::SupportsOpenGL ( vtkObject caller,
unsigned long  vtk_event,
void *  client_data,
void *  call_data 
)
virtualslot

slot called when vtk wants to know if a window supports OpenGL

virtual void QVTKOpenGLWindow::UpdateStereoType ( vtkObject caller,
unsigned long  vtk_event,
void *  client_data,
void *  call_data 
)
virtualslot

slot called when the stereo type of the render window changed

virtual void QVTKOpenGLWindow::ChangeCursor ( vtkObject caller,
unsigned long  vtk_event,
void *  client_data,
void *  call_data 
)
virtualslot
virtual void QVTKOpenGLWindow::widgetEvent ( QEvent *  e)
virtualslot

slot to process events coming from the widget containing this window

virtual bool QVTKOpenGLWindow::isValid ( )
virtualslot

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

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

virtual bool QVTKOpenGLWindow::isCurrent ( )
virtualslot

Returns true if the internal OpenGL contect is the actual current OpenGL context, false otherwise.

virtual void QVTKOpenGLWindow::initializeGL ( )
protectedvirtual

Override event handler.

virtual void QVTKOpenGLWindow::paintGL ( )
protectedvirtual
virtual void QVTKOpenGLWindow::moveEvent ( QMoveEvent *  event)
protectedvirtual
virtual bool QVTKOpenGLWindow::event ( QEvent *  e)
protectedvirtual
virtual void QVTKOpenGLWindow::mousePressEvent ( QMouseEvent *  event)
protectedvirtual
virtual void QVTKOpenGLWindow::mouseMoveEvent ( QMouseEvent *  event)
protectedvirtual
virtual void QVTKOpenGLWindow::mouseReleaseEvent ( QMouseEvent *  event)
protectedvirtual
virtual void QVTKOpenGLWindow::mouseDoubleClickEvent ( QMouseEvent *  event)
protectedvirtual
virtual void QVTKOpenGLWindow::keyPressEvent ( QKeyEvent *  event)
protectedvirtual
virtual void QVTKOpenGLWindow::keyReleaseEvent ( QKeyEvent *  event)
protectedvirtual
virtual void QVTKOpenGLWindow::enterEvent ( QEvent *  )
protectedvirtual
virtual void QVTKOpenGLWindow::leaveEvent ( QEvent *  )
protectedvirtual
virtual void QVTKOpenGLWindow::wheelEvent ( QWheelEvent *  )
protectedvirtual

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