ImFusion SDK 4.3
QtDisplayWindow Class Reference

#include <ImFusion/GUI/QtDisplayWindow.h>

Specialization of a QWindow that allows for rendering the contents of a Display directly into the window framebuffer. More...

+ Inheritance diagram for QtDisplayWindow:

Detailed Description

Specialization of a QWindow that allows for rendering the contents of a Display directly into the window framebuffer.

Using a QWindow as backend is the most flexible approach as it should support integration into either a QtWidgets-based application, into a QML-based application, or as a freestanding window. Other integrations such as the QtDisplayWidget may perform better depending on your use case.

Warning
Make sure you understand and follow the constraints/expected class invariants regarding the used OpenGL contexts by both the ImFusion SDK and by QOpenGLWidget described below.

QtDisplayWindow will always use main context of the ImFusion SDK for rendering. Due to limitations of the underlying QWindow this main context must be of type GlContextQt. Thus, you must use that during SDK initialization, for instance:

// Initialize the SDK with a GlContextQt as main context
GL::Context::CreateInfo glCreateInfo = ...;
Framework::InitConfig sdkInitConfig;
sdkInitConfig.glContext = std::make_unique<GlContextQt>(glCreateInfo);
Framekwork::init(std::move(sdkInitConfig));
T make_unique(T... args)
Record to configure the initialization of the ImFusion SDK.
Definition Framework.h:35
std::unique_ptr< GL::Context > glContext
Optional OpenGL context to use as main context for the framework.
Definition Framework.h:60
Definition Context.h:59

Furthermore, this class requires a two-step initialization process: you must call init() once the main context has been initialized. If you are embedding this class into a QtWidgets-based application using QWidget::createWindowContainer() you should do this before calling init() unless you use an old Qt version.

See also
QtDisplayWidget

Public Member Functions

 QtDisplayWindow (Display &display, QWindow *parent=nullptr)
 Create a new QtDisplayWindow showing the given display.
 
void init ()
 Initialize the underlying window/display surface with the format of the main OpenGL context.
 
void deinit ()
 Deinitialize the surface, which will effectively disable any rendering.
 
void render ()
 
bool event (QEvent *event) override
 
void resizeEvent (QResizeEvent *event) override
 
QPointF mapToGlobal (const QPointF &pos) const final override
 Implementations shall forward to Qt's mapToGlobal() function of the wrapper class.
 
- Public Member Functions inherited from QtDisplayWrapperBase
 QtDisplayWrapperBase (Display &display)
 Constructor will subscribe to the Display::signalUpdateRequested signal.
 
Displaydisplay ()
 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.
 
- Public Member Functions inherited from SignalReceiver
 SignalReceiver ()=default
 Default constructor.
 
 SignalReceiver (const SignalReceiver &other)
 Copy constructor, does not copy any existing signal connections from other.
 
SignalReceiveroperator= (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.
 

Protected Member Functions

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.
 
- Protected Member Functions inherited from QtDisplayWrapperBase
bool handleInputEvent (QEvent *event)
 
- Protected Member Functions inherited from SignalReceiver
void disconnectAll ()
 Disconnects all existing connections.
 

Additional Inherited Members

- Protected Attributes inherited from QtDisplayWrapperBase
Displaym_display
 

Constructor & Destructor Documentation

◆ QtDisplayWindow()

QtDisplayWindow ( Display & display,
QWindow * parent = nullptr )

Create a new QtDisplayWindow showing the given display.

Exceptions
std::runtime_errorif the GL::ContextManager::mainContext() is not a GlContextQt (see class description).

Member Function Documentation

◆ init()

void init ( )

Initialize the underlying window/display surface with the format of the main OpenGL context.

Note
If you are embedding QtDisplayWindow into a QtWidgets-based application we recommend:
  • With Qt versions newer or equal than 5.9 you must call this function after calling QWidget::createWindowContainer().
  • With Qt versions older than 5.9 you must call this function before calling QWidget::createWindowContainer().

◆ deinit()

void deinit ( )

Deinitialize the surface, which will effectively disable any rendering.

This function is called implicitly by the destructor.

◆ mapToGlobal()

QPointF mapToGlobal ( const QPointF & pos) const
finaloverridevirtual

Implementations shall forward to Qt's mapToGlobal() function of the wrapper class.

Implements QtDisplayWrapperBase.

◆ onDisplayUpdateRequested()

void onDisplayUpdateRequested ( )
finaloverrideprotectedvirtual

Implementations shall make Qt rerender the display.

Implements QtDisplayWrapperBase.

◆ getDevicePixelRatio()

double getDevicePixelRatio ( ) const
finaloverrideprotectedvirtual

Return the device pixel ratio of the screen the display is shown on.

Implements QtDisplayWrapperBase.

◆ getHeight()

int getHeight ( ) const
finaloverrideprotectedvirtual

Return the height of the display wrapper in pixels.

Implements QtDisplayWrapperBase.

◆ setCursor()

void setCursor ( const QCursor & cursor)
finaloverrideprotectedvirtual

Implementations shall forward to Qt's setCursor() function of the wrapper class.

Implements QtDisplayWrapperBase.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close