Manages the Qt3D window, scene setup, and the main simulation loop.
More...
#include <display.hpp>
|
| using | BodyInformations = std::tuple< QPointer< Qt3DCore::QEntity >, QPointer< Qt3DCore::QTransform >, QPointer< Qt3DCore::QEntity >, QPointer< Qt3DCore::QTransform >, QPointer< Qt3DCore::QEntity >, QPointer< Qt3DCore::QTransform > > |
| | A tuple to hold the Qt-specific components for a single rendered body. More...
|
| |
|
|
void | simulationFinished () |
| | Emitted when the simulation has run for n_iter iterations.
|
| |
|
| | Display (const Configuration::SimulationConfig &config) |
| | Initialise the 3D window and set up the scene. More...
|
| |
| | ~Display () override |
| | Destructor to ensure worker thread is cleaned up. More...
|
| |
| void | cleanup () |
| | Performs cleanup actions, such as printing profiling reports. More...
|
| |
| void | runSimulation () |
| | Starts the physics simulation by starting the worker thread. More...
|
| |
|
| void | updateFrame (const Model::Vector3dVec &positions, const Model::QuaterniondVec &quaternions, const Model::Vector3dVec &torques, const Model::Vector3dVec &alphas, std::size_t iteration) |
| | Slot to receive updated data from the physics worker and update the scene. More...
|
| |
|
| void | createSpheres (Rng::Pcg32 &gen) |
| | Create and set up the spherical bodies in the scene. More...
|
| |
| void | createScene (unsigned int seed) |
| | Set up the scene. More...
|
| |
| std::pair< Qt3DCore::QEntity *, Qt3DCore::QTransform * > | createArrowEntity (Qt3DCore::QEntity *parent, const QColor &colour, float radius, float length) |
| | Creates a 3D arrow entity for vector visualization. More...
|
| |
| void | updateVectorArrow (Qt3DCore::QTransform *arrowTransform, const Model::Vector3d &vector, double scaleFactor) const |
| | Updates the transform of an arrow entity to represent a 3D vector. More...
|
| |
Manages the Qt3D window, scene setup, and the main simulation loop.
This class orchestrates the 3D rendering and the physics worker thread.
Definition at line 52 of file display.hpp.
◆ BodyInformations
| using Window::Display::BodyInformations = std::tuple< QPointer<Qt3DCore::QEntity>, QPointer<Qt3DCore::QTransform>, QPointer<Qt3DCore::QEntity>, QPointer<Qt3DCore::QTransform>, QPointer<Qt3DCore::QEntity>, QPointer<Qt3DCore::QTransform> > |
A tuple to hold the Qt-specific components for a single rendered body.
Definition at line 60 of file display.hpp.
◆ Display()
| Window::Display::Display |
( |
const Configuration::SimulationConfig & |
config | ) |
|
|
inlineexplicit |
Initialise the 3D window and set up the scene.
- Parameters
-
| config | The simulation configuration object. |
Definition at line 69 of file display.hpp.
◆ ~Display()
| Window::Display::~Display |
( |
| ) |
|
|
override |
Destructor to ensure worker thread is cleaned up.
Definition at line 43 of file display.cpp.
◆ cleanup()
| void Window::Display::cleanup |
( |
| ) |
|
Performs cleanup actions, such as printing profiling reports.
Definition at line 185 of file display.cpp.
◆ createArrowEntity()
| std::pair< Qt3DCore::QEntity *, Qt3DCore::QTransform * > Window::Display::createArrowEntity |
( |
Qt3DCore::QEntity * |
parent, |
|
|
const QColor & |
colour, |
|
|
float |
radius, |
|
|
float |
length |
|
) |
| |
|
private |
Creates a 3D arrow entity for vector visualization.
- Parameters
-
| parent | The parent entity. |
| colour | The colour of the arrow. |
| radius | The radius of the arrow's shaft. |
| length | The initial length of the arrow. |
- Returns
- A tuple containing the arrow's root entity and its transform component.
Definition at line 60 of file display.cpp.
◆ createScene()
| void Window::Display::createScene |
( |
unsigned int |
seed | ) |
|
|
private |
Set up the scene.
- Parameters
-
| seed | The seed for the random number generator. |
Definition at line 162 of file display.cpp.
◆ createSpheres()
| void Window::Display::createSpheres |
( |
Rng::Pcg32 & |
gen | ) |
|
|
private |
Create and set up the spherical bodies in the scene.
- Parameters
-
| gen | A seeded random number generator for reproducible body colours. |
Definition at line 106 of file display.cpp.
◆ runSimulation()
| void Window::Display::runSimulation |
( |
| ) |
|
Starts the physics simulation by starting the worker thread.
Definition at line 172 of file display.cpp.
◆ updateFrame
| void Window::Display::updateFrame |
( |
const Model::Vector3dVec & |
positions, |
|
|
const Model::QuaterniondVec & |
quaternions, |
|
|
const Model::Vector3dVec & |
torques, |
|
|
const Model::Vector3dVec & |
alphas, |
|
|
std::size_t |
iteration |
|
) |
| |
|
privateslot |
Slot to receive updated data from the physics worker and update the scene.
Definition at line 298 of file display.cpp.
◆ updateVectorArrow()
| void Window::Display::updateVectorArrow |
( |
Qt3DCore::QTransform * |
arrowTransform, |
|
|
const Model::Vector3d & |
vector, |
|
|
double |
scaleFactor |
|
) |
| const |
|
private |
Updates the transform of an arrow entity to represent a 3D vector.
- Parameters
-
| arrowTransform | The transform component of the arrow to update. |
| vector | The 3D vector to visualise. |
| scaleFactor | A multiplier for the arrow's length. |
Definition at line 267 of file display.cpp.
◆ bodies_
List of spheres representing bodies. This list differs from the actual physical bodies in the simulation.
Definition at line 171 of file display.hpp.
◆ camController_
| QPointer<Qt3DExtras::QOrbitCameraController> Window::Display::camController_ |
|
private |
◆ cleanupCalled_
| bool Window::Display::cleanupCalled_ |
|
private |
Flag to track if cleanup has already been called. This prevents cleanup from being called multiple times.
Definition at line 188 of file display.hpp.
◆ iterationCount_
| std::size_t Window::Display::iterationCount_ |
|
private |
The current iteration count.
Definition at line 150 of file display.hpp.
◆ maxIterations_
| std::size_t Window::Display::maxIterations_ |
|
private |
Maximum number of iterations.
Definition at line 153 of file display.hpp.
◆ physicsThread_
| QThread* Window::Display::physicsThread_ |
|
private |
The thread where the physics worker runs. Created with 'this' as parent, so Qt manages its lifetime.
Definition at line 180 of file display.hpp.
◆ physicsWorker_
The worker object running the simulation. Uses QPointer for safety: it becomes nullptr if the object is destroyed.
Definition at line 176 of file display.hpp.
◆ rootEntity_
| std::unique_ptr<Qt3DCore::QEntity> Window::Display::rootEntity_ |
|
private |
The root entity for the 3D scene.
Definition at line 162 of file display.hpp.
◆ showAlphaArrow_
| bool Window::Display::showAlphaArrow_ |
|
private |
Flag to display angular acceleration vectors in the UI.
Definition at line 159 of file display.hpp.
◆ showTorqueArrow_
| bool Window::Display::showTorqueArrow_ |
|
private |
Flag to display torque vectors in the UI.
Definition at line 156 of file display.hpp.
◆ simulationTimer_
| QTimer* Window::Display::simulationTimer_ |
|
private |
Timer to drive the simulation loop. Reused timer that triggers physics steps automatically.
Definition at line 184 of file display.hpp.
The documentation for this class was generated from the following files: