VTK  9.3.0
QQuickVTKRenderItem.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
117 #ifndef QQuickVTKRenderItem_h
118 #define QQuickVTKRenderItem_h
119 
120 // Qt includes
121 #include <QOpenGLFunctions> // For QOpenGLFunctions
122 #include <QQuickItem>
123 
124 // vtk includes
125 #include "QQuickVTKRenderWindow.h" // For QQuickVTKRenderWindow
126 #include "vtkDeprecation.h"
127 #include "vtkNew.h" // For vtkNew
128 #include "vtkRenderer.h" // For vtkRenderer
129 
130 #include "vtkGUISupportQtQuickModule.h" // for export macro
131 
132 // Qt Forward declarations
133 class QHoverEvent;
134 class QKeyEvent;
135 class QMouseEvent;
136 
137 VTK_ABI_NAMESPACE_BEGIN
138 // VTK Forward declarations
140 class vtkImageData;
141 
143  "Use QQuickVTKItem instead") VTKGUISUPPORTQTQUICK_EXPORT QQuickVTKRenderItem
144  : public QQuickItem
145  , protected QOpenGLFunctions
146 {
147  Q_OBJECT
148  typedef QQuickItem Superclass;
149 
150  Q_PROPERTY(QQuickVTKRenderWindow* renderWindow READ renderWindow WRITE setRenderWindow)
151 
152 public:
153  QQuickVTKRenderItem(QQuickItem* parent = nullptr);
154  ~QQuickVTKRenderItem() override = default;
155 
157 
163 
168 
176 
178 
184 
186 
190  virtual void removeWidgetByName(QString name);
192 
193 public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
202  virtual void sync();
203 
210  virtual void init();
211 
220  virtual void paint();
221 
226  virtual void cleanup();
227 
228 protected Q_SLOTS:
229  virtual void handleWindowChanged(QQuickWindow* w);
230 
231 protected: // NOLINT(readability-redundant-access-specifiers)
232  // Helper members
233  QQuickVTKRenderWindow* m_renderWindow = nullptr;
235 
236  QVector<QQuickVTKInteractiveWidget*> m_widgets;
237 
241  virtual void setViewport(const QRectF& rect);
242 
243  // Event handlers
244 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
245  void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) override;
246 #else
247  void geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) override;
248 #endif
249  bool event(QEvent* ev) override;
250 
251 private:
252  QQuickVTKRenderItem(const QQuickVTKRenderItem&) = delete;
253  void operator=(const QQuickVTKRenderItem) = delete;
254 };
255 
256 VTK_ABI_NAMESPACE_END
257 #endif // QQuickVTKRenderItem_h
QObject that manages a VTK interactive widget to ensure that it behaves as per the QtQuick threaded r...
QQuickItem that manages a VTK rendering in the QML scenegraph.
Definition: QQuickVTKItem.h:27
QQuickItem subclass to render a VTK scene in a QtQuick/QML application.
QQuickVTKRenderWindow * renderWindow() const
Set/Get the render window for the item.
virtual void removeWidgetByName(QString name)
Get/Remove widgets from the view by their object name.
virtual void handleWindowChanged(QQuickWindow *w)
QQuickVTKRenderItem(QQuickItem *parent=nullptr)
virtual vtkSmartPointer< vtkImageData > captureScreenshot()
Capture a screenshot of the view.
virtual void init()
Initialize the graphics resources required for this render item.
virtual void sync()
This is the function called on the QtQuick render thread before the scenegraph state is synchronized.
virtual QQuickVTKInteractiveWidget * widgetByName(QString name) const
Get/Remove widgets from the view by their object name.
vtkNew< vtkRenderer > m_renderer
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
virtual void setRenderWindow(QQuickVTKRenderWindow *w)
Set/Get the render window for the item.
vtkRenderer * renderer() const
Get access to the renderer.
bool event(QEvent *ev) override
QVector< QQuickVTKInteractiveWidget * > m_widgets
virtual void setViewport(const QRectF &rect)
Set the viewport for this item.
virtual void removeWidget(QQuickVTKInteractiveWidget *w)
Add/Remove widgets to/from the view.
virtual void cleanup()
This is the function called on the QtQuick render thread when the scenegraph is invalidated.
~QQuickVTKRenderItem() override=default
virtual void addWidget(QQuickVTKInteractiveWidget *w)
Add/Remove widgets to/from the view.
virtual void paint()
This is the function called on the QtQuick render thread right before the scenegraph is rendered.
QQuickItem subclass that manages the vtkRenderWindow and, in turn, the OpenGL context of the QML appl...
topologically and geometrically regular array of data
Definition: vtkImageData.h:43
abstract specification for renderers
Definition: vtkRenderer.h:62
@ name
Definition: vtkX3D.h:219
#define VTK_DEPRECATED_IN_9_3_0(reason)