pure-cpp 1.0.0
A C++ physics simulation benchmark comparing performance with Python implementations
Window::QmlBridge Class Reference

Bridge class to expose C++ functionality to QML. More...

#include <qml_bridge.hpp>

Inheritance diagram for Window::QmlBridge:
Inheritance graph
Collaboration diagram for Window::QmlBridge:
Collaboration graph

Public Slots

void showAbout ()
 Slot to display the "About" dialogue. More...
 
void showAboutQt ()
 Slot to display the "About Qt" dialogue. More...
 
void quit ()
 Slot to quit the application. More...
 

Signals

void displayContainerChanged ()
 Emitted when the display container is created.
 
void aboutTextChanged ()
 Emitted when the about text changes.
 
void simulationFinished ()
 Emitted when the simulation finishes.
 

Public Member Functions

 QmlBridge (const Configuration::SimulationConfig &config, QObject *parent=nullptr)
 Constructs the QML bridge. More...
 
 ~QmlBridge () override
 Destructor. More...
 
QWidget * displayContainer () const
 Gets the widget container for the 3D display. More...
 
QString aboutText () const
 Gets the "About" page text. More...
 
Q_INVOKABLE void startSimulation ()
 Starts the simulation after the window is shown. More...
 
Q_INVOKABLE void shutdownSimulation ()
 Stops the physics thread and prints profiling reports. More...
 
void releaseDisplayDeferred (QWidget *container_for_deferred_delete)
 Schedules deferred destruction of Display and its container. More...
 
void releaseDisplayStrict (QWidget *container)
 Synchronously destroys the display container and its window. More...
 

Properties

QWidget * displayContainer
 
QString aboutText
 

Private Member Functions

std::optional< QString > loadAboutText ()
 Loads the "About" page content from resources. More...
 

Private Attributes

QPointer< Displaydisplay_
 The 3D display view for the simulation. More...
 
QPointer< QWidget > container_
 The widget container for the 3D display. More...
 
QString aboutText_
 The cached about text. More...
 
bool uiReleased_ = false
 True after UI resources have been released. More...
 

Detailed Description

Bridge class to expose C++ functionality to QML.

This class acts as an interface between QML and the C++ backend, exposing the Display widget and application actions (About, Quit).

Definition at line 44 of file qml_bridge.hpp.

Constructor & Destructor Documentation

◆ QmlBridge()

Window::QmlBridge::QmlBridge ( const Configuration::SimulationConfig &  config,
QObject *  parent = nullptr 
)
explicit

Constructs the QML bridge.

Parameters
configThe simulation configuration object.
parentThe parent QObject.

Definition at line 33 of file qml_bridge.cpp.

Here is the call graph for this function:

◆ ~QmlBridge()

Window::QmlBridge::~QmlBridge ( )
override

Destructor.

Definition at line 67 of file qml_bridge.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ aboutText()

QString Window::QmlBridge::aboutText ( ) const

Gets the "About" page text.

Returns
The about text as a QString.

Definition at line 76 of file qml_bridge.cpp.

◆ displayContainer()

QWidget * Window::QmlBridge::displayContainer ( ) const

Gets the widget container for the 3D display.

Returns
A pointer to the widget container, or nullptr if not created.

Definition at line 74 of file qml_bridge.cpp.

◆ loadAboutText()

std::optional< QString > Window::QmlBridge::loadAboutText ( )
private

Loads the "About" page content from resources.

Returns
The content of the about page as a QString, or std::nullopt if loading fails.

Definition at line 139 of file qml_bridge.cpp.

Here is the caller graph for this function:

◆ quit

void Window::QmlBridge::quit ( )
slot

Slot to quit the application.

Definition at line 137 of file qml_bridge.cpp.

Here is the caller graph for this function:

◆ releaseDisplayDeferred()

void Window::QmlBridge::releaseDisplayDeferred ( QWidget *  container_for_deferred_delete)

Schedules deferred destruction of Display and its container.

Used in fast cleanup mode (benchmark-friendly, similar to async Python GC). Display is destroyed first; the container follows via a queued connection.

Definition at line 90 of file qml_bridge.cpp.

◆ releaseDisplayStrict()

void Window::QmlBridge::releaseDisplayStrict ( QWidget *  container)

Synchronously destroys the display container and its window.

Used in strict cleanup mode (Valgrind and conservative teardown).

Definition at line 116 of file qml_bridge.cpp.

Here is the caller graph for this function:

◆ showAbout

void Window::QmlBridge::showAbout ( )
slot

Slot to display the "About" dialogue.

Definition at line 129 of file qml_bridge.cpp.

Here is the caller graph for this function:

◆ showAboutQt

void Window::QmlBridge::showAboutQt ( )
slot

Slot to display the "About Qt" dialogue.

Definition at line 135 of file qml_bridge.cpp.

Here is the caller graph for this function:

◆ shutdownSimulation()

void Window::QmlBridge::shutdownSimulation ( )

Stops the physics thread and prints profiling reports.

UI teardown is handled separately by releaseDisplayDeferred() or releaseDisplayStrict(), depending on –cleanup-mode.

Definition at line 84 of file qml_bridge.cpp.

Here is the caller graph for this function:

◆ startSimulation()

void Window::QmlBridge::startSimulation ( )

Starts the simulation after the window is shown.

Definition at line 78 of file qml_bridge.cpp.

Member Data Documentation

◆ aboutText_

QString Window::QmlBridge::aboutText_
private

The cached about text.

Definition at line 152 of file qml_bridge.hpp.

◆ container_

QPointer<QWidget> Window::QmlBridge::container_
private

The widget container for the 3D display.

Definition at line 149 of file qml_bridge.hpp.

◆ display_

QPointer<Display> Window::QmlBridge::display_
private

The 3D display view for the simulation.

Definition at line 146 of file qml_bridge.hpp.

◆ uiReleased_

bool Window::QmlBridge::uiReleased_ = false
private

True after UI resources have been released.

Definition at line 155 of file qml_bridge.hpp.

Property Documentation

◆ aboutText

QString Window::QmlBridge::aboutText
read

Definition at line 1 of file qml_bridge.hpp.

◆ displayContainer

QWidget* Window::QmlBridge::displayContainer
read

Definition at line 1 of file qml_bridge.hpp.


The documentation for this class was generated from the following files: