VTK  9.4.20250212
QQuickVTKItem.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright (c) John Stone
3// SPDX-License-Identifier: BSD-3-Clause
8#ifndef QQuickVTKItem_h
9#define QQuickVTKItem_h
10
11#include <QtQuick/QQuickItem>
12
13#include <QtCore/QScopedPointer>
14
15#include <functional>
16
17#include "vtkGUISupportQtQuickModule.h" // for export macro
18#include "vtkSmartPointer.h"
19
20VTK_ABI_NAMESPACE_BEGIN
21
22class vtkRenderWindow;
23class vtkObject;
24
25class QQuickVTKItemPrivate;
26class VTKGUISUPPORTQTQUICK_EXPORT QQuickVTKItem : public QQuickItem
27{
28 Q_OBJECT
29
30public:
31 explicit QQuickVTKItem(QQuickItem* parent = nullptr);
32 ~QQuickVTKItem() override;
33
35
43 static void setGraphicsApi();
44
46
73 {
74 Q_UNUSED(renderWindow)
75 return {};
76 }
78
80
96 virtual void destroyingVTK(vtkRenderWindow* renderWindow, vtkUserData userData)
97 {
98 Q_UNUSED(renderWindow);
99 Q_UNUSED(userData);
100 }
102
104
123 void dispatch_async(std::function<void(vtkRenderWindow* renderWindow, vtkUserData userData)> f);
125
136
137public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
139
163 Q_INVOKABLE void pinchHandlerRotate(const QPointF& position, double delta);
164 Q_INVOKABLE void pinchHandlerScale(const QPointF& position, double delta);
165 Q_INVOKABLE void pinchHandlerTranslate(const QPointF& position, const QVector2D& delta);
167
168protected:
169 bool event(QEvent*) override;
170
171 QSGNode* updatePaintNode(QSGNode*, UpdatePaintNodeData*) override;
172 bool isTextureProvider() const override;
173 QSGTextureProvider* textureProvider() const override;
174 void releaseResources() override;
175
176private Q_SLOTS:
177 void invalidateSceneGraph();
178
179private: // NOLINT(readability-redundant-access-specifiers)
180 Q_DISABLE_COPY(QQuickVTKItem)
181 Q_DECLARE_PRIVATE_D(_d_ptr, QQuickVTKItem)
182 QScopedPointer<QQuickVTKItemPrivate> _d_ptr;
183};
184
185VTK_ABI_NAMESPACE_END
186#endif // QQuickVTKItem_h
QQuickItem that manages a VTK rendering in the QML scenegraph.
QQuickVTKItem(QQuickItem *parent=nullptr)
Q_INVOKABLE void pinchHandlerTranslate(const QPointF &position, const QVector2D &delta)
Individual slots for the three pinch handler signals in QML namely, translationChanged,...
QSGTextureProvider * textureProvider() const override
bool isTextureProvider() const override
void scheduleRender()
Schedules an update on the vtkRenderWindow encapsulated in this item.
virtual vtkUserData initializeVTK(vtkRenderWindow *renderWindow)
This is where the VTK initialization should be done including creating a pipeline and attaching it to...
void releaseResources() override
Q_INVOKABLE void pinchHandlerScale(const QPointF &position, double delta)
Individual slots for the three pinch handler signals in QML namely, translationChanged,...
QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *) override
~QQuickVTKItem() override
void dispatch_async(std::function< void(vtkRenderWindow *renderWindow, vtkUserData userData)> f)
This is the function that enqueues an async command that will be executed just before VTK renders.
bool event(QEvent *) override
virtual void destroyingVTK(vtkRenderWindow *renderWindow, vtkUserData userData)
At any moment the QML SceneGraph can decide to delete the underlying QSGNode.
static void setGraphicsApi()
Set up the graphics surface format and api.
Q_INVOKABLE void pinchHandlerRotate(const QPointF &position, double delta)
Individual slots for the three pinch handler signals in QML namely, translationChanged,...
abstract base class for most VTK objects
Definition vtkObject.h:162
create a window for renderers to draw into
Hold a reference to a vtkObjectBase instance.