VTK  9.4.20241229
QVTKRenderWindowAdapter.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
3#ifndef QVTKRenderWindowAdapter_h
4#define QVTKRenderWindowAdapter_h
5
25#include "vtkGUISupportQtModule.h" // For export macro
26#include <QObject>
27
28#include <QCursor> // for ivar
29#include <QScopedPointer> // for ivar
30
31class QOpenGLContext;
32class QSurfaceFormat;
33class QWidget;
34class QWindow;
35
36VTK_ABI_NAMESPACE_BEGIN
38class vtkObject;
39
40class VTKGUISUPPORTQT_EXPORT QVTKRenderWindowAdapter : public QObject
41{
42 Q_OBJECT;
43 using Superclass = QObject;
44
45public:
47
55 QOpenGLContext* cntxt, vtkGenericOpenGLRenderWindow* window, QWindow* parent);
57 QOpenGLContext* cntxt, vtkGenericOpenGLRenderWindow* window, QWidget* parent);
59
61
84 static QSurfaceFormat defaultFormat(bool stereo_capable = false);
85
91 void paint();
92
104 void resize(int width, int height);
105
107
111 bool blit(
112 unsigned int targetId, int targetAttachement, const QRect& targetRect, bool left = true);
113 bool blitLeftEye(unsigned int targetId, int targetAttachement, const QRect& targetRect)
114 {
115 return this->blit(targetId, targetAttachement, targetRect, true);
116 }
117 bool blitRightEye(unsigned int targetId, int targetAttachement, const QRect& targetRect)
118 {
119 return this->blit(targetId, targetAttachement, targetRect, false);
120 }
122
127 bool handleEvent(QEvent* evt);
128
130
133 void setDefaultCursor(const QCursor& cursor) { this->DefaultCursor = cursor; }
134 const QCursor& defaultCursor() const { return this->DefaultCursor; }
136
138
148 void setEnableHiDPI(bool value);
150
152
156 void setUnscaledDPI(int value);
158
160
166
167private Q_SLOTS:
168 void contextAboutToBeDestroyed();
169
170private: // NOLINT(readability-redundant-access-specifiers)
172 QOpenGLContext* cntxt, vtkGenericOpenGLRenderWindow* window, QObject* widgetOrWindow);
173 Q_DISABLE_COPY(QVTKRenderWindowAdapter);
174
175 class QVTKInternals;
176 QScopedPointer<QVTKInternals> Internals;
177
178 QCursor DefaultCursor;
179};
180
181VTK_ABI_NAMESPACE_END
182#endif
Helper to manage Qt context and other OpenGL components.
static QSurfaceFormat defaultFormat(bool stereo_capable=false)
Returns a QSurfaceFormat suitable for surfaces that intend to be used for VTK rendering.
bool blitLeftEye(unsigned int targetId, int targetAttachement, const QRect &targetRect)
Convenience methods to blit the results rendered in the internal FBO to a target.
~QVTKRenderWindowAdapter() override
QVTKRenderWindowAdapter(QOpenGLContext *cntxt, vtkGenericOpenGLRenderWindow *window, QWidget *parent)
Constructor that makes vtkGenericOpenGLRenderWindow ready for subsequent render requests i....
const QCursor & defaultCursor() const
Get/set the default cursor.
void setUnscaledDPI(int value)
Set the unscaled DPI to use when scaling DPI.
void setCustomDevicePixelRatio(double dpr)
Get/Set the custom device pixel ratio to use.
void resize(int width, int height)
Call this method to resize the render window.
bool blit(unsigned int targetId, int targetAttachement, const QRect &targetRect, bool left=true)
Convenience methods to blit the results rendered in the internal FBO to a target.
bool handleEvent(QEvent *evt)
Process the event and return true if the event have been processed successfully.
bool blitRightEye(unsigned int targetId, int targetAttachement, const QRect &targetRect)
Convenience methods to blit the results rendered in the internal FBO to a target.
void paint()
Call this method in paintGL to request a render.
QVTKRenderWindowAdapter(QOpenGLContext *cntxt, vtkGenericOpenGLRenderWindow *window, QWindow *parent)
Constructor that makes vtkGenericOpenGLRenderWindow ready for subsequent render requests i....
void setEnableHiDPI(bool value)
Enable/disable DPI scaling.
void setDefaultCursor(const QCursor &cursor)
Get/set the default cursor.
platform independent render window
abstract base class for most VTK objects
Definition vtkObject.h:162