Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Slots | Private Attributes | List of all members
QVTKOpenGLWidget Class Reference

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

#include <QVTKOpenGLWidget.h>

Inheritance diagram for QVTKOpenGLWidget:
Inheritance graph
[legend]

Signals

void mouseEvent (QMouseEvent *event)
 
void resized ()
 
void widgetEvent (QEvent *e)
 

Public Member Functions

virtual bool enableHiDPI ()
 
virtual vtkRenderWindowInteractor * GetInteractor ()
 
virtual QVTKInteractorAdapter * GetInteractorAdapter ()
 
virtual vtkRenderWindow * GetRenderWindow ()
 
QImage grabFramebuffer ()
 
virtual bool isValid ()
 
 QVTKOpenGLWidget (QOpenGLContext *shareContext, QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags())
 
 QVTKOpenGLWidget (QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags())
 
 QVTKOpenGLWidget (vtkGenericOpenGLRenderWindow *w, QOpenGLContext *shareContext, QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags())
 
 QVTKOpenGLWidget (vtkGenericOpenGLRenderWindow *w, QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags())
 
virtual void setEnableHiDPI (bool enable)
 
void setFormat (const QSurfaceFormat &format)
 
void setQVTKCursor (const QCursor &cursor)
 
void SetRenderWindow (vtkGenericOpenGLRenderWindow *win)
 
void SetRenderWindow (vtkRenderWindow *win)
 
virtual bool testingEvent (QEvent *e)
 
 ~QVTKOpenGLWidget () override
 

Static Public Member Functions

static QSurfaceFormat defaultFormat ()
 

Protected Member Functions

virtual bool event (QEvent *e) Q_DECL_OVERRIDE
 
virtual void resizeEvent (QResizeEvent *event) Q_DECL_OVERRIDE
 

Protected Attributes

bool EnableHiDPI = true
 

Private Types

typedef QWidget Superclass
 

Private Slots

void windowEvent (QEvent *event)
 

Private Attributes

QVTKOpenGLWindow * qVTKOpenGLWindowInternal
 

Detailed Description

QWidget for displaying a vtkRenderWindow in a Qt Application.

QVTKOpenGLWidget is a QWidget wrapper around QVTKOpenGLWindow. It holds a pointer to an internal QVTKOpenGLWindow instance in order to display VTK data in a Qt OpenGL context.

It was designed to support quad buffer stereo rendering.

A typical usage for QVTKOpenGLWidget is as follows:

// This must be done before instantiating the app in order to setup the
// right context for our widget.
QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
QApplication app(argc, argv);
vtkNew<vtkGenericOpenGLRenderWindow> window;
QScopedPointer<QVTKOpenGLWidget> qvtkWidget(new QVTKOpenGLWidget(window));
// You can continue to use `window` as a regular vtkRenderWindow
// including adding renderers, actors etc.
// Show the widget and start the app.
qvtkWidget->show();
return app.exec();

External calls requesting the render window to render might not be safe. Please make sure that QVTKOpenGLWidget::isValid() returns true before making explicit call to vtkGenericOpenGLRenderWindow::Render(). An alternative is to call update() on the widget instance to trigger a render once the context gets validated;

QVTKOpenGLWidget is compatible with Qt version 5.6 and above, but it is mainly tested on Qt 5.9 and above.

Due to Qt limitations, QVTKOpenGLWidget 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 QVTKOpenGLWidget is used in a QScrollArea or in a QMDIArea, it will force it to be native and this is NOT supported.

See also
QVTKOpenGLWindow QVTKOpenGLNativeWidget

Definition at line 84 of file QVTKOpenGLWidget.h.

Member Typedef Documentation

◆ Superclass

typedef QWidget QVTKOpenGLWidget::Superclass
private

Definition at line 87 of file QVTKOpenGLWidget.h.

Constructor & Destructor Documentation

◆ QVTKOpenGLWidget() [1/4]

QVTKOpenGLWidget::QVTKOpenGLWidget ( QWidget *  parent = Q_NULLPTR,
Qt::WindowFlags  f = Qt::WindowFlags() 
)

◆ QVTKOpenGLWidget() [2/4]

QVTKOpenGLWidget::QVTKOpenGLWidget ( QOpenGLContext *  shareContext,
QWidget *  parent = Q_NULLPTR,
Qt::WindowFlags  f = Qt::WindowFlags() 
)

◆ QVTKOpenGLWidget() [3/4]

QVTKOpenGLWidget::QVTKOpenGLWidget ( vtkGenericOpenGLRenderWindow *  w,
QWidget *  parent = Q_NULLPTR,
Qt::WindowFlags  f = Qt::WindowFlags() 
)

◆ QVTKOpenGLWidget() [4/4]

QVTKOpenGLWidget::QVTKOpenGLWidget ( vtkGenericOpenGLRenderWindow *  w,
QOpenGLContext *  shareContext,
QWidget *  parent = Q_NULLPTR,
Qt::WindowFlags  f = Qt::WindowFlags() 
)

◆ ~QVTKOpenGLWidget()

QVTKOpenGLWidget::~QVTKOpenGLWidget ( )
override

Member Function Documentation

◆ defaultFormat()

static QSurfaceFormat QVTKOpenGLWidget::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.

◆ enableHiDPI()

virtual bool QVTKOpenGLWidget::enableHiDPI ( )
inlinevirtual

Definition at line 136 of file QVTKOpenGLWidget.h.

◆ event()

virtual bool QVTKOpenGLWidget::event ( QEvent *  e)
protectedvirtual

◆ GetInteractor()

virtual vtkRenderWindowInteractor* QVTKOpenGLWidget::GetInteractor ( )
virtual

Get the VTK render window interactor from the internal QVTKOpenGLWindow.

◆ GetInteractorAdapter()

virtual QVTKInteractorAdapter* QVTKOpenGLWidget::GetInteractorAdapter ( )
virtual

Get the QEvent to VTK events translator.

◆ GetRenderWindow()

virtual vtkRenderWindow* QVTKOpenGLWidget::GetRenderWindow ( )
virtual

Get the VTK render window from the internal QVTKOpenGLWindow.

◆ grabFramebuffer()

QImage QVTKOpenGLWidget::grabFramebuffer ( )

Expose internal QVTKOpenGLWindow::grabFramebuffer(). Renders and returns a 32-bit RGB image of the framebuffer.

◆ isValid()

virtual bool QVTKOpenGLWidget::isValid ( )
virtual

Returns true if the internal QOpenGLWindow's is valid, i.e. if OpenGL resources, like the context, have been successfully initialized.

◆ mouseEvent

void QVTKOpenGLWidget::mouseEvent ( QMouseEvent *  event)
signal

This signal will be emitted whenever a mouse event occurs within the QVTK window.

◆ resized

void QVTKOpenGLWidget::resized ( )
signal

This signal will be emitted whenever a resize event occurs within the QVTK window.

◆ resizeEvent()

virtual void QVTKOpenGLWidget::resizeEvent ( QResizeEvent *  event)
protectedvirtual

◆ setEnableHiDPI()

virtual void QVTKOpenGLWidget::setEnableHiDPI ( bool  enable)
virtual

Enable or disable support for HiDPI displays.

◆ setFormat()

void QVTKOpenGLWidget::setFormat ( const QSurfaceFormat &  format)

Set the QSurfaceFormat used to create the OpenGL context.

◆ setQVTKCursor()

void QVTKOpenGLWidget::setQVTKCursor ( const QCursor &  cursor)

Set the cursor on this widget.

◆ SetRenderWindow() [1/2]

void QVTKOpenGLWidget::SetRenderWindow ( vtkGenericOpenGLRenderWindow *  win)

Set the VTK render window for the internal QVTKOpenGLWindow.

◆ SetRenderWindow() [2/2]

void QVTKOpenGLWidget::SetRenderWindow ( vtkRenderWindow *  win)

◆ testingEvent()

virtual bool QVTKOpenGLWidget::testingEvent ( QEvent *  e)
virtual

Forward events to the internal QVTKOpenGLWindow when events are explicitly sent to the widget. This is required due to QTBUG-61836 that prevents the use of the flag Qt::TransparentForMouseInput. This flag indicates that the internal window let events pass through. When this misbehavior gets fixed, events will be forwarded to this widget's event() callback, that will then forward them back to the window.

◆ widgetEvent

void QVTKOpenGLWidget::widgetEvent ( QEvent *  e)
signal

Forward events to the internal QVTK window.

◆ windowEvent

void QVTKOpenGLWidget::windowEvent ( QEvent *  event)
privateslot

called as a response to QVTKOpenGLWindow::event to forward the signal.

Member Data Documentation

◆ EnableHiDPI

bool QVTKOpenGLWidget::EnableHiDPI = true
protected

Definition at line 191 of file QVTKOpenGLWidget.h.

◆ qVTKOpenGLWindowInternal

QVTKOpenGLWindow* QVTKOpenGLWidget::qVTKOpenGLWindowInternal
private

Definition at line 194 of file QVTKOpenGLWidget.h.


The documentation for this class was generated from the following file:
QVTKOpenGLWidget::defaultFormat
static QSurfaceFormat defaultFormat()
QVTKOpenGLWidget::QVTKOpenGLWidget
QVTKOpenGLWidget(QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags())
argc
int argc
Definition: tests_high_five_parallel.cpp:27
argv
char ** argv
Definition: tests_high_five_parallel.cpp:28


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:26