VTK  9.3.0
QQuickVTKRenderWindow.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
104 #ifndef QQuickVTKRenderWindow_h
105 #define QQuickVTKRenderWindow_h
106 
107 // vtk includes
108 #include "vtkDeprecation.h"
109 #include "vtkSmartPointer.h" // For vtkSmartPointer
110 
111 // Qt includes
112 #include <QOpenGLFunctions> // For QOpenGLFunctions
113 #include <QPointer> // For QPointer
114 #include <QQuickItem>
115 
116 #include "vtkGUISupportQtQuickModule.h" // for export macro
117 
118 // Qt Forward declarations
119 class QEvent;
120 class QQuickWindow;
121 class QWheelEvent;
122 
123 VTK_ABI_NAMESPACE_BEGIN
124 
125 // VTK Forward declarations
128 class vtkImageData;
129 class vtkRenderWindow;
130 class vtkRenderer;
132 
134  "Use QQuickVTKItem instead") VTKGUISUPPORTQTQUICK_EXPORT QQuickVTKRenderWindow
135  : public QQuickItem
136  , protected QOpenGLFunctions
137 {
138  Q_OBJECT
139  typedef QQuickItem Superclass;
140 
141 public:
148  QQuickVTKRenderWindow(QQuickItem* parent = nullptr);
149 
154 
163  static void setupGraphicsBackend();
164 
166 
175  virtual void setRenderWindow(vtkRenderWindow* renWin);
179 
183  virtual void mapToViewport(const QRectF& rect, double viewport[4]);
184 
188  QPointer<QQuickVTKInteractorAdapter> interactorAdapter() const;
189 
191 
201 
207  virtual bool isInitialized() const;
208 
209 public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
218  virtual void sync();
219 
226  virtual void init();
227 
236  virtual void paint();
237 
242  virtual void cleanup();
243 
248  virtual void renderNow();
249 
257  virtual void render();
258 
259 protected Q_SLOTS:
260  virtual void handleWindowChanged(QQuickWindow* w);
261 
262 protected: // NOLINT(readability-redundant-access-specifiers)
263  QPointer<QQuickVTKInteractorAdapter> m_interactorAdapter;
265  bool m_initialized = false;
266 
267  // Screenshot stuff
268  bool m_screenshotScheduled = false;
271 
272  // Event handlers
273 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
274  void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) override;
275 #else
276  void geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) override;
277 #endif
278 
283 
284 private:
286  void operator=(const QQuickVTKRenderWindow) = delete;
287 };
288 
289 VTK_ABI_NAMESPACE_END
290 #endif // QQuickVTKRenderWindow_h
Intermediate class that handles relaying Qt events to VTK.
QQuickItem that manages a VTK rendering in the QML scenegraph.
Definition: QQuickVTKItem.h:27
QQuickItem subclass that manages the vtkRenderWindow and, in turn, the OpenGL context of the QML appl...
vtkNew< vtkWindowToImageFilter > m_screenshotFilter
~QQuickVTKRenderWindow() override
Destructor.
virtual vtkSmartPointer< vtkImageData > captureScreenshot(double *viewport)
Capture a screenshot of the window.
QPointer< QQuickVTKInteractorAdapter > interactorAdapter() const
Get access to the interactor adapter.
vtkSmartPointer< vtkGenericOpenGLRenderWindow > m_renderWindow
virtual void mapToViewport(const QRectF &rect, double viewport[4])
Map a Qt item rect to viewport coordinates.
virtual void setRenderWindow(vtkRenderWindow *renWin)
Set/Get the vtkRenderWindow for the view.
virtual vtkSmartPointer< vtkImageData > captureScreenshot()
Capture a screenshot of the window.
bool checkGraphicsBackend()
Check the scenegraph backend and graphics API being used.
virtual void render()
Schedule a scenegraph update.
virtual bool isInitialized() const
Get whether the render window is initialized Used internally to determine if the OpenGL context,...
QQuickVTKRenderWindow(QQuickItem *parent=nullptr)
Constructor Creates a QQuickVTKRenderWindow with:
virtual void handleWindowChanged(QQuickWindow *w)
vtkRenderWindow * renderWindow() const
Set/Get the vtkRenderWindow for the view.
virtual void sync()
This is the function called on the QtQuick render thread before the scenegraph state is synchronized.
virtual void cleanup()
This is the function called on the QtQuick render thread when the scenegraph is invalidated.
QPointer< QQuickVTKInteractorAdapter > m_interactorAdapter
virtual void init()
Initialize the VTK render window for OpenGL based on the context created by QtQuick.
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
static void setupGraphicsBackend()
Set up the graphics surface format and api.
virtual void setRenderWindow(vtkGenericOpenGLRenderWindow *renWin)
Set/Get the vtkRenderWindow for the view.
virtual void renderNow()
Convenience method that schedules a scenegraph update and waits for the update.
vtkNew< vtkRenderer > m_dummyRenderer
virtual void paint()
This is the function called on the QtQuick render thread right before the scenegraph is rendered.
platform independent render window
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
create a window for renderers to draw into
abstract specification for renderers
Definition: vtkRenderer.h:71
Use a vtkWindow as input to image pipeline.
#define VTK_DEPRECATED_IN_9_3_0(reason)