VTK
9.1.0
|
Helper to manage Qt context and other OpenGL components. More...
#include <QVTKRenderWindowAdapter.h>
Inherits QObject.
Public Member Functions | |
~QVTKRenderWindowAdapter () override | |
QOpenGLContext * | context () const |
Get the context to use for rendering. More... | |
void | paint () |
Call this method in paintGL to request a render. More... | |
void | resize (int width, int height) |
Call this method to resize the render window. More... | |
bool | handleEvent (QEvent *evt) |
Process the event and return true if the event have been processed successfully. More... | |
QVTKRenderWindowAdapter (QOpenGLContext *cntxt, vtkGenericOpenGLRenderWindow *window, QWindow *parent) | |
Constructor that makes vtkGenericOpenGLRenderWindow ready for subsequent render requests i.e. More... | |
QVTKRenderWindowAdapter (QOpenGLContext *cntxt, vtkGenericOpenGLRenderWindow *window, QWidget *parent) | |
Constructor that makes vtkGenericOpenGLRenderWindow ready for subsequent render requests i.e. More... | |
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. More... | |
bool | blitLeftEye (unsigned int targetId, int targetAttachement, const QRect &targetRect) |
Convenience methods to blit the results rendered in the internal FBO to a target. More... | |
bool | blitRightEye (unsigned int targetId, int targetAttachement, const QRect &targetRect) |
Convenience methods to blit the results rendered in the internal FBO to a target. More... | |
void | setDefaultCursor (const QCursor &cursor) |
Get/set the default cursor. More... | |
const QCursor & | defaultCursor () const |
Get/set the default cursor. More... | |
void | setEnableHiDPI (bool value) |
Enable/disable DPI scaling. More... | |
void | setUnscaledDPI (int value) |
Set the unscaled DPI to use when scaling DPI. More... | |
void | setCustomDevicePixelRatio (double dpr) |
Get/Set the custom device pixel ratio to use. More... | |
Static Public Member Functions | |
static QSurfaceFormat | defaultFormat (bool stereo_capable=false) |
Returns a QSurfaceFormat suitable for surfaces that intend to be used for VTK rendering. More... | |
Helper to manage Qt context and other OpenGL components.
QVTKRenderWindowAdapter is an internal class that is used by QVTKOpenGLNativeWidget and QVTKOpenGLWindow to manage the rendering using vtkGenericOpenGLRenderWindow within a OpenGL context created via Qt.
QVTKRenderWindowAdapter is expected to be recreated anytime the context changes. In the constructor, QVTKRenderWindowAdapter will mark the vtkGenericOpenGLRenderWindow ready for rendering and call OpenGL context initialization API (vtkOpenGLRenderWindow::OpenGLInitContext).
By observing events on vtkGenericOpenGLRenderWindow, QVTKRenderWindowAdapter can then support rendering to an internally created FBO via VTK's rendering calls. Making sure that the rendering results are shown on the screen is handled by QVTKOpenGLWindow or QVTKOpenGLNativeWidget.
Definition at line 50 of file QVTKRenderWindowAdapter.h.
QVTKRenderWindowAdapter::QVTKRenderWindowAdapter | ( | QOpenGLContext * | cntxt, |
vtkGenericOpenGLRenderWindow * | window, | ||
QWindow * | parent | ||
) |
Constructor that makes vtkGenericOpenGLRenderWindow ready for subsequent render requests i.e.
calls vtkGenericOpenGLRenderWindow::SetReadyForRendering(true)
. This also calls vtkOpenGLRenderWindow::OpenGLInitContext
to ensure that the OpenGL context is ready for VTK rendering.
QVTKRenderWindowAdapter::QVTKRenderWindowAdapter | ( | QOpenGLContext * | cntxt, |
vtkGenericOpenGLRenderWindow * | window, | ||
QWidget * | parent | ||
) |
Constructor that makes vtkGenericOpenGLRenderWindow ready for subsequent render requests i.e.
calls vtkGenericOpenGLRenderWindow::SetReadyForRendering(true)
. This also calls vtkOpenGLRenderWindow::OpenGLInitContext
to ensure that the OpenGL context is ready for VTK rendering.
|
override |
|
static |
Returns a QSurfaceFormat suitable for surfaces that intend to be used for VTK rendering.
If your applications plans on using QVTKOpenGLNativeWidget
, then this format (or similar) must be set as the default format on QSurfaceFormat before any widgets are created.
Note this returns a QSurfaceFormat required to support the OpenGL rendering capabilities in a vtkRenderWindow. Whether those features, e.g. multi sampling, is actually used for rendering is determined by values specified on the vtkRenderWindow instance itself through appropriate API.
Passing stereo_capable=true
is same as calling QSurfaceFormat::setStereo(true)
. This is necessary if you want to use quad-buffer based stereo in your application.
Refer to Qt docs for QOpenGLWidget and QOpenGLWindow for appropriate locations in your application where to the format may be provided e.g. either on the instance of QOpenGLWindow or QOpenGLWidget subclasses or as default format for the application using QSurfaceFormat::setDefaultFormat()
.
QOpenGLContext * QVTKRenderWindowAdapter::context | ( | ) | const |
Get the context to use for rendering.
void QVTKRenderWindowAdapter::paint | ( | ) |
Call this method in paintGL
to request a render.
This may trigger a vtkRenderWindow::Render
if this class determines the buffers may be obsolete.
void QVTKRenderWindowAdapter::resize | ( | int | width, |
int | height | ||
) |
Call this method to resize the render window.
This simply calls vtkRenderWindow::SetSize
taking device pixel ratio into consideration. This doesn't cause a render or resize of the FBO. That happens on a subsequent render request.
Besides widget resize, this method should also be called in cases when the devicePixelRatio for the parent window (or widget) changes. This is necessary since the internal FBO's pixel size is computed by scaling the widget
and height
provided by the window's (or widget's) devicePixelRatio
.
bool QVTKRenderWindowAdapter::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.
|
inline |
Convenience methods to blit the results rendered in the internal FBO to a target.
Definition at line 128 of file QVTKRenderWindowAdapter.h.
|
inline |
Convenience methods to blit the results rendered in the internal FBO to a target.
Definition at line 132 of file QVTKRenderWindowAdapter.h.
bool QVTKRenderWindowAdapter::handleEvent | ( | QEvent * | evt | ) |
Process the event and return true if the event have been processed successfully.
|
inline |
Get/set the default cursor.
Definition at line 148 of file QVTKRenderWindowAdapter.h.
|
inline |
Get/set the default cursor.
Definition at line 149 of file QVTKRenderWindowAdapter.h.
void QVTKRenderWindowAdapter::setEnableHiDPI | ( | bool | value | ) |
Enable/disable DPI scaling.
When enabled call to resize
(which must happen any time the devicePixelRatio
, in addition to the size may change), will result in updating the DPI on the vtkGenericOpenGLRenderWindow as well. The DPI change only happens in resize
to enable applications to temporarily change DPI on the vtkGenericOpenGLRenderWindow and request an explicit render seamlessly. In such a case, it's the applications responsibility to restore DPI value or the changed value will linger until the next resize
happens.
void QVTKRenderWindowAdapter::setUnscaledDPI | ( | int | value | ) |
Set the unscaled DPI to use when scaling DPI.
It defaults to 72, which is same as the hard-coded default in vtkWindow
.
void QVTKRenderWindowAdapter::setCustomDevicePixelRatio | ( | double | dpr | ) |
Get/Set the custom device pixel ratio to use.
If 0 or negative, it is treated as unset and DPR from Qt will be used instead.