VTK
9.2.6
|
[QQuickItem] subclass to render a VTK scene in a QtQuick/QML application. More...
#include <QQuickVTKRenderItem.h>
Inherits QQuickItem, and QOpenGLFunctions.
Public Slots | |
virtual void | sync () |
This is the function called on the QtQuick render thread before the scenegraph state is synchronized. More... | |
virtual void | init () |
Initialize the graphics resources required for this render item. More... | |
virtual void | paint () |
This is the function called on the QtQuick render thread right before the scenegraph is rendered. More... | |
virtual void | cleanup () |
This is the function called on the QtQuick render thread when the scenegraph is invalidated. More... | |
Public Member Functions | |
QQuickVTKRenderItem (QQuickItem *parent=nullptr) | |
~QQuickVTKRenderItem ()=default | |
vtkRenderer * | renderer () const |
Get access to the renderer. More... | |
virtual vtkSmartPointer< vtkImageData > | captureScreenshot () |
Capture a screenshot of the view. More... | |
QQuickVTKRenderWindow * | renderWindow () const |
Set/Get the render window for the item. More... | |
virtual void | setRenderWindow (QQuickVTKRenderWindow *w) |
Set/Get the render window for the item. More... | |
virtual void | addWidget (QQuickVTKInteractiveWidget *w) |
Add/Remove widgets to/from the view. More... | |
virtual void | removeWidget (QQuickVTKInteractiveWidget *w) |
Add/Remove widgets to/from the view. More... | |
virtual QQuickVTKInteractiveWidget * | widgetByName (QString name) const |
Get/Remove widgets from the view by their object name. More... | |
virtual void | removeWidgetByName (QString name) |
Get/Remove widgets from the view by their object name. More... | |
Protected Slots | |
virtual void | handleWindowChanged (QQuickWindow *w) |
Protected Member Functions | |
virtual void | setViewport (const QRectF &rect) |
Set the viewport for this item. More... | |
void | geometryChange (const QRectF &newGeometry, const QRectF &oldGeometry) override |
bool | event (QEvent *ev) override |
Protected Attributes | |
QQuickVTKRenderWindow * | m_renderWindow = nullptr |
vtkNew< vtkRenderer > | m_renderer |
QVector< QQuickVTKInteractiveWidget * > | m_widgets |
Properties | |
QQuickVTKRenderWindow | renderWindow |
[QQuickItem] subclass to render a VTK scene in a QtQuick/QML application.
QQuickVTKRenderItem extends QQuickItem so that a VTK visualization pipeline can be rendererd within the rect of the item.
This item is exported to the QML layer via the QQmlVTKPlugin under the module VTK. It is registered as a type VTKRenderItem. The QQuickVTKRenderItem manages a vtkRenderer internally that is rendered as a viewport inside the render window provided by QQuickVTKRenderWindow.
Typical usage for QQuickVTKRenderItem in a Qml application is as follows:
The corresponding C++ code that sets up the VTK pipeline would look like the following:
QtQuick/QML scenegraph rendering is done via private API inside the QQuickWindow class. For details on QtQuick's render loop, see QtQuick Scenegraph Rendering. Qt automatically decides between a threaded and basic render loop for most applications. QQuickVTKRenderWindow and QQuickVTKRenderItem support both these variants of the QtQuick render loop.
When the scenegraph render loop is threaded, i.e. there is a dedicated rendering thread, vtk sticks to doing all rendering on this render thread. This means that all the vtk classes, pipelines etc. can be set up on the main thread but vtkRenderWindow::Render should only be invoked on the render thread. Care must be taken not to call Render on the main thread because the OpenGL context would not be valid on the main thread.
QQuickVTKRenderItem also supports interactive vtk widgets with QtQuick's threaded render loop via the QQuickVTKInteractiveWidget class.
Definition at line 150 of file QQuickVTKRenderItem.h.
QQuickVTKRenderItem::QQuickVTKRenderItem | ( | QQuickItem * | parent = nullptr | ) |
|
default |
QQuickVTKRenderWindow* QQuickVTKRenderItem::renderWindow | ( | ) | const |
Set/Get the render window for the item.
|
virtual |
Set/Get the render window for the item.
vtkRenderer* QQuickVTKRenderItem::renderer | ( | ) | const |
Get access to the renderer.
|
virtual |
Capture a screenshot of the view.
|
virtual |
Add/Remove widgets to/from the view.
|
virtual |
Add/Remove widgets to/from the view.
|
virtual |
Get/Remove widgets from the view by their object name.
|
virtual |
Get/Remove widgets from the view by their object name.
|
virtualslot |
This is the function called on the QtQuick render thread before the scenegraph state is synchronized.
This is where most of the pipeline updates, camera manipulations, etc. and other pre-render steps can be performed.
|
virtualslot |
Initialize the graphics resources required for this render item.
This method is called on the QtQuick render thread at the beforeRenderPassRecording stage of the scenegraph render loop.
|
virtualslot |
This is the function called on the QtQuick render thread right before the scenegraph is rendered.
This is the stage where all the vtk rendering is performed. Applications would rarely need to override this method.
|
virtualslot |
This is the function called on the QtQuick render thread when the scenegraph is invalidated.
This is where all graphics resources allocated by vtk are released.
|
protectedvirtualslot |
|
protectedvirtual |
Set the viewport for this item.
|
overrideprotected |
|
overrideprotected |
|
protected |
Definition at line 240 of file QQuickVTKRenderItem.h.
|
protected |
Definition at line 241 of file QQuickVTKRenderItem.h.
|
protected |
Definition at line 243 of file QQuickVTKRenderItem.h.
|
readwrite |
Definition at line 157 of file QQuickVTKRenderItem.h.