VTK
9.1.0
|
QWidget for displaying a vtkRenderWindow in a Qt Application. More...
#include <QVTKOpenGLStereoWidget.h>
Inherits QWidget.
Public Member Functions | |
QVTKOpenGLStereoWidget (QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags()) | |
QVTKOpenGLStereoWidget (QOpenGLContext *shareContext, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags()) | |
QVTKOpenGLStereoWidget (vtkGenericOpenGLRenderWindow *w, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags()) | |
QVTKOpenGLStereoWidget (vtkGenericOpenGLRenderWindow *w, QOpenGLContext *shareContext, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags()) | |
~QVTKOpenGLStereoWidget () override | |
vtkRenderWindow * | renderWindow () const |
Returns the render window that is being shown in this widget. | |
QVTKInteractor * | interactor () const |
Get the QVTKInteractor that was either created by default or set by the user. | |
void | setEnableHiDPI (bool enable) |
Enable or disable support for HiDPI displays. | |
bool | enableHiDPI () const |
bool | isValid () |
Returns true if the internal QOpenGLWindow's is valid, i.e. | |
QImage | grabFramebuffer () |
Expose internal QVTKOpenGLWindow::grabFramebuffer(). | |
QVTKOpenGLWindow * | embeddedOpenGLWindow () const |
Returns the embedded QVTKOpenGLWindow. | |
void | setFormat (const QSurfaceFormat &fmt) |
Sets the requested surface format. | |
QSurfaceFormat | format () const |
Returns the context and surface format used by this widget and its toplevel window. | |
QVTKInteractorAdapter * | GetInteractorAdapter () |
void | setQVTKCursor (const QCursor &cursor) |
void | setDefaultQVTKCursor (const QCursor &cursor) |
void | setRenderWindow (vtkGenericOpenGLRenderWindow *win) |
Set a render window to use. | |
void | setRenderWindow (vtkRenderWindow *win) |
Set a render window to use. | |
void | setUnscaledDPI (int dpi) |
Set/Get unscaled DPI value. | |
int | unscaledDPI () const |
Set/Get unscaled DPI value. | |
void | setCustomDevicePixelRatio (double cdpr) |
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes. | |
double | customDevicePixelRatio () const |
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes. | |
double | effectiveDevicePixelRatio () const |
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes. | |
void | setDefaultCursor (const QCursor &cursor) |
Set/get the default cursor to use for this widget. | |
const QCursor & | defaultCursor () const |
Set/get the default cursor to use for this widget. | |
void | SetRenderWindow (vtkGenericOpenGLRenderWindow *win) |
void | SetRenderWindow (vtkRenderWindow *win) |
vtkRenderWindow * | GetRenderWindow () |
These methods have be deprecated to fix naming style. | |
QVTKInteractor * | GetInteractor () |
These methods have be deprecated to fix naming style. | |
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. | |
Protected Member Functions | |
void | resizeEvent (QResizeEvent *evt) override |
void | paintEvent (QPaintEvent *evt) override |
QWidget for displaying a vtkRenderWindow in a Qt Application.
QVTKOpenGLStereoWidget simplifies using a QVTKOpenGLWindow as a widget in Qt application so it can be embedded in a layout rather than being a top-level window. QVTKOpenGLWindow has all the limitations posed by Qt with QWidget::createWindowContainer
hence developers are advised to refer to Qt docs for more details.
In general QVTKOpenGLNativeWidget may be a better choice, however QVTKOpenGLWindow-based QVTKOpenGLStereoWidget may be better choice for applications requiring quad-buffer stereo.
Due to Qt limitations, QVTKOpenGLStereoWidget does not support being a native widget. But native widget are sometimes mandatory, for example within QScrollArea and QMDIArea, so the QVTKOpenGLNativeWidget should be used when in needs of VTK rendering in the context of Qt native widget.
If a QVTKOpenGLStereoWidget is used in a QScrollArea or in a QMDIArea, it will force it to be native and this is NOT supported.
Unlike QVTKOpenGLNativeWidget, QVTKOpenGLStereoWidget does not require that the default surface format for the application be changed. One can simply specify the needed QSurfaceFormat for the specific QVTKOpenGLStereoWidget instance by calling QVTKOpenGLStereoWidget::setFormat
before the widget is initialized.
Definition at line 66 of file QVTKOpenGLStereoWidget.h.
QVTKOpenGLStereoWidget::QVTKOpenGLStereoWidget | ( | QWidget * | parent = nullptr , |
Qt::WindowFlags | f = Qt::WindowFlags() |
||
) |
QVTKOpenGLStereoWidget::QVTKOpenGLStereoWidget | ( | QOpenGLContext * | shareContext, |
QWidget * | parent = nullptr , |
||
Qt::WindowFlags | f = Qt::WindowFlags() |
||
) |
QVTKOpenGLStereoWidget::QVTKOpenGLStereoWidget | ( | vtkGenericOpenGLRenderWindow * | w, |
QWidget * | parent = nullptr , |
||
Qt::WindowFlags | f = Qt::WindowFlags() |
||
) |
QVTKOpenGLStereoWidget::QVTKOpenGLStereoWidget | ( | vtkGenericOpenGLRenderWindow * | w, |
QOpenGLContext * | shareContext, | ||
QWidget * | parent = nullptr , |
||
Qt::WindowFlags | f = Qt::WindowFlags() |
||
) |
|
override |
|
inline |
Set a render window to use.
It a render window was already set, it will be finalized and all of its OpenGL resource released. If the win
is non-null and it has no interactor set, then a QVTKInteractor instance will be created as set on the render window as the interactor.
Definition at line 85 of file QVTKOpenGLStereoWidget.h.
|
inline |
Set a render window to use.
It a render window was already set, it will be finalized and all of its OpenGL resource released. If the win
is non-null and it has no interactor set, then a QVTKInteractor instance will be created as set on the render window as the interactor.
Definition at line 89 of file QVTKOpenGLStereoWidget.h.
|
inline |
Returns the render window that is being shown in this widget.
Definition at line 95 of file QVTKOpenGLStereoWidget.h.
|
inline |
Get the QVTKInteractor that was either created by default or set by the user.
Definition at line 100 of file QVTKOpenGLStereoWidget.h.
|
inlinestatic |
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()
.
Definition at line 105 of file QVTKOpenGLStereoWidget.h.
|
inline |
Enable or disable support for HiDPI displays.
When enabled, this enabled DPI scaling i.e. vtkWindow::SetDPI
will be called with a DPI value scaled by the device pixel ratio every time the widget is resized. The unscaled DPI value can be specified by using setUnscaledDPI
.
Definition at line 113 of file QVTKOpenGLStereoWidget.h.
|
inline |
Definition at line 114 of file QVTKOpenGLStereoWidget.h.
|
inline |
Set/Get unscaled DPI value.
Defaults to 72, which is also the default value in vtkWindow.
Definition at line 121 of file QVTKOpenGLStereoWidget.h.
|
inline |
Set/Get unscaled DPI value.
Defaults to 72, which is also the default value in vtkWindow.
Definition at line 122 of file QVTKOpenGLStereoWidget.h.
|
inline |
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
Thus, when the QWidget is resized, it called vtkRenderWindow::SetSize
on the internal vtkRenderWindow after multiplying the QWidget's size by this scale factor.
By default, this is set to 0. Which means that devicePixelRatio
obtained from Qt will be used. Set this to a number greater than 0 to override this behaviour and use the custom scale factor instead.
effectiveDevicePixelRatio
can be used to obtain the device-pixel-ratio that will be used given the value for customDevicePixelRatio.
Definition at line 139 of file QVTKOpenGLStereoWidget.h.
|
inline |
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
Thus, when the QWidget is resized, it called vtkRenderWindow::SetSize
on the internal vtkRenderWindow after multiplying the QWidget's size by this scale factor.
By default, this is set to 0. Which means that devicePixelRatio
obtained from Qt will be used. Set this to a number greater than 0 to override this behaviour and use the custom scale factor instead.
effectiveDevicePixelRatio
can be used to obtain the device-pixel-ratio that will be used given the value for customDevicePixelRatio.
Definition at line 143 of file QVTKOpenGLStereoWidget.h.
|
inline |
Set/Get a custom device pixel ratio to use to map Qt sizes to VTK (or OpenGL) sizes.
Thus, when the QWidget is resized, it called vtkRenderWindow::SetSize
on the internal vtkRenderWindow after multiplying the QWidget's size by this scale factor.
By default, this is set to 0. Which means that devicePixelRatio
obtained from Qt will be used. Set this to a number greater than 0 to override this behaviour and use the custom scale factor instead.
effectiveDevicePixelRatio
can be used to obtain the device-pixel-ratio that will be used given the value for customDevicePixelRatio.
Definition at line 144 of file QVTKOpenGLStereoWidget.h.
|
inline |
Set/get the default cursor to use for this widget.
Definition at line 154 of file QVTKOpenGLStereoWidget.h.
|
inline |
Set/get the default cursor to use for this widget.
Definition at line 155 of file QVTKOpenGLStereoWidget.h.
|
inline |
Returns true if the internal QOpenGLWindow's is valid, i.e.
if OpenGL resources, like the context, have been successfully initialized.
Definition at line 162 of file QVTKOpenGLStereoWidget.h.
QImage QVTKOpenGLStereoWidget::grabFramebuffer | ( | ) |
Expose internal QVTKOpenGLWindow::grabFramebuffer().
Renders and returns a 32-bit RGB image of the framebuffer.
|
inline |
Returns the embedded QVTKOpenGLWindow.
Definition at line 173 of file QVTKOpenGLStereoWidget.h.
|
inline |
Sets the requested surface format.
When the format is not explicitly set via this function, the format returned by QSurfaceFormat::defaultFormat() will be used. This means that when having multiple OpenGL widgets, individual calls to this function can be replaced by one single call to QSurfaceFormat::setDefaultFormat() before creating the first widget.
Definition at line 184 of file QVTKOpenGLStereoWidget.h.
|
inline |
Returns the context and surface format used by this widget and its toplevel window.
Definition at line 189 of file QVTKOpenGLStereoWidget.h.
void QVTKOpenGLStereoWidget::SetRenderWindow | ( | vtkGenericOpenGLRenderWindow * | win | ) |
void QVTKOpenGLStereoWidget::SetRenderWindow | ( | vtkRenderWindow * | win | ) |
vtkRenderWindow * QVTKOpenGLStereoWidget::GetRenderWindow | ( | ) |
These methods have be deprecated to fix naming style.
Since QVTKOpenGLNativeWidget is QObject subclass, we follow Qt naming conventions rather than VTK's.
QVTKInteractor * QVTKOpenGLStereoWidget::GetInteractor | ( | ) |
These methods have be deprecated to fix naming style.
Since QVTKOpenGLNativeWidget is QObject subclass, we follow Qt naming conventions rather than VTK's.
QVTKInteractorAdapter * QVTKOpenGLStereoWidget::GetInteractorAdapter | ( | ) |
void QVTKOpenGLStereoWidget::setQVTKCursor | ( | const QCursor & | cursor | ) |
QWidget::setCursor
API to change cursor. void QVTKOpenGLStereoWidget::setDefaultQVTKCursor | ( | const QCursor & | cursor | ) |
setDefaultCursor
instead.
|
overrideprotected |
|
overrideprotected |