VTK  9.3.0
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
89 QOpenGLContext* context() const;
90
96 void paint();
97
109 void resize(int width, int height);
110
112
116 bool blit(
117 unsigned int targetId, int targetAttachement, const QRect& targetRect, bool left = true);
118 bool blitLeftEye(unsigned int targetId, int targetAttachement, const QRect& targetRect)
119 {
120 return this->blit(targetId, targetAttachement, targetRect, true);
121 }
122 bool blitRightEye(unsigned int targetId, int targetAttachement, const QRect& targetRect)
123 {
124 return this->blit(targetId, targetAttachement, targetRect, false);
125 }
127
132 bool handleEvent(QEvent* evt);
133
135
138 void setDefaultCursor(const QCursor& cursor) { this->DefaultCursor = cursor; }
139 const QCursor& defaultCursor() const { return this->DefaultCursor; }
141
143
153 void setEnableHiDPI(bool value);
155
157
161 void setUnscaledDPI(int value);
163
165
171
172private Q_SLOTS:
173 void contextAboutToBeDestroyed();
174
175private: // NOLINT(readability-redundant-access-specifiers)
177 QOpenGLContext* cntxt, vtkGenericOpenGLRenderWindow* window, QObject* widgetOrWindow);
178 Q_DISABLE_COPY(QVTKRenderWindowAdapter);
179
180 class QVTKInternals;
181 QScopedPointer<QVTKInternals> Internals;
182
183 QCursor DefaultCursor;
184};
185
186VTK_ABI_NAMESPACE_END
187#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.
QOpenGLContext * context() const
Get the context to use for rendering.
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:49