![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GUI/QtDisplayWidget.h>
Specialization of a QOpenGLWidget
that allows for rendering the contents of a Display into a QtWidget-based application.
More...
Specialization of a QOpenGLWidget
that allows for rendering the contents of a Display into a QtWidget-based application.
The underlying QOpenGLWidget
will always create its own OpenGL context and expect all rendering happen in there. This complicates integration to some extent because the ImFusion SDK also maintains its own context for the main thread in which it expects the main OpenGL objects to reside and the rendering to happen. Therefore, QtDisplayWidget provides two different RenderModes:
UseImFusionContext
(recommended as default): UseQOpenGLWidgetContext
: Either way, you must make sure that OpenGL context sharing is enabled between the ImFusion context and the Qt context(s). We recommend the following approach for this:
Once the context sharing is configured correctly, the creation of QtDisplayWidget is straight-forward:
Public Types | |
enum class | RenderMode { UseImFusionContext , UseQOpenGLWidgetContext } |
Enumeration to define in which OpenGL context to conduct the rendering of the display (see class docstring for details). More... | |
Public Member Functions | |
QtDisplayWidget (Display &display, QWidget *parent=nullptr, RenderMode renderContext=RenderMode::UseImFusionContext) | |
Create a new QtDisplayWidget showing the given display. | |
bool | event (QEvent *event) override |
bool | eventFilter (QObject *obj, QEvent *event) override |
QPointF | mapToGlobal (const QPointF &pos) const final override |
Implementations shall forward to Qt's mapToGlobal() function of the wrapper class. | |
![]() | |
QtDisplayWrapperBase (Display &display) | |
Constructor will subscribe to the Display::signalUpdateRequested signal. | |
Display & | display () |
Returns the Display shown by this widget. | |
QPointF | mapFromOpenGL (const vec2 &point) const |
Converts point from ImFusion::GUI's bottom-left-origin coordinates to Qt's top-left-origin coordinates. | |
vec2 | mapToOpenGL (const QPointF &point) const |
Converts point from Qt's top-left-origin coordinates to ImFusion::GUI's bottom-left-origin coordinates. | |
![]() | |
SignalReceiver ()=default | |
Default constructor. | |
SignalReceiver (const SignalReceiver &other) | |
Copy constructor, does not copy any existing signal connections from other. | |
SignalReceiver & | operator= (SignalReceiver rhs) |
Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs. | |
virtual | ~SignalReceiver () |
Virtual destructor disconnects from all connected signals. | |
Public Attributes | |
Signal | signalGLContextInitialized |
Signal emitted during initializeGL() to allow for the initialization of GL resources without subclassing. | |
Protected Member Functions | |
void | initializeGL () override |
void | resizeGL (int w, int h) override |
void | paintGL () override |
void | onDisplayUpdateRequested () final override |
Implementations shall make Qt rerender the display. | |
double | getDevicePixelRatio () const final override |
Return the device pixel ratio of the screen the display is shown on. | |
int | getHeight () const final override |
Return the height of the display wrapper in pixels. | |
void | setCursor (const QCursor &cursor) final override |
Implementations shall forward to Qt's setCursor() function of the wrapper class. | |
![]() | |
bool | handleInputEvent (QEvent *event) |
![]() | |
void | disconnectAll () |
Disconnects all existing connections. | |
Additional Inherited Members | |
![]() | |
Display * | m_display |
|
strong |
Enumeration to define in which OpenGL context to conduct the rendering of the display (see class docstring for details).
Enumerator | |
---|---|
UseImFusionContext | Perform rendering in the ImFusion main context. |
UseQOpenGLWidgetContext | Perform rendering in the context created by the underlying QOpenGLWidget. |
|
finaloverridevirtual |
Implementations shall forward to Qt's mapToGlobal() function of the wrapper class.
Implements QtDisplayWrapperBase.
|
finaloverrideprotectedvirtual |
Implementations shall make Qt rerender the display.
Implements QtDisplayWrapperBase.
|
finaloverrideprotectedvirtual |
Return the device pixel ratio of the screen the display is shown on.
Implements QtDisplayWrapperBase.
|
finaloverrideprotectedvirtual |
Return the height of the display wrapper in pixels.
Implements QtDisplayWrapperBase.
|
finaloverrideprotectedvirtual |
Implementations shall forward to Qt's setCursor() function of the wrapper class.
Implements QtDisplayWrapperBase.