The view containing 2D visualization. More...
#include <collisiondisplay2d.h>
Public Slots | |
void | start () |
Starts the simulation. More... | |
void | stop () |
Stops the timer and reinitializes the QTimer timer, QGraphicsScene scene, QAlgorithm qalg, and int numCollisions. Emits the signal finished. | |
void | step () |
Performs one step of the display. More... | |
Public Slots inherited from CollisionDisplay | |
virtual void | start ()=0 |
Slot used to initialize the display. More... | |
virtual void | stop ()=0 |
Slot used to stop the display. More... | |
virtual void | step ()=0 |
Slot used to step the display. More... | |
Signals | |
void | finished () |
Signals that the display has finished. Usually because the user clicked "stop", for example. More... | |
Signals inherited from CollisionDisplay | |
virtual void | finished ()=0 |
Signals that the display is no longer running. More... | |
Public Member Functions | |
CollisionDisplay2D (QWidget *parent=0) | |
Constructs a CollisionDisplay2D. More... | |
QGraphicsScene * | getScene () |
Gets the scene that is declared in CollisionDisplay2D. More... | |
QTimer * | getTimer () |
Gets the timer declared in CollisionDisplay. More... | |
void | setQAlgorithm (QAlgorithm *qalgorithm) |
Sets the algorithm declared in CollisionDisplay. More... | |
Public Member Functions inherited from CollisionDisplay | |
CollisionDisplay () | |
Constructs a CollisionDisplay. More... | |
QTimer * | getTimer () |
Returns a pointer to the timer. More... | |
int | getNumCollisions () |
Returns the number of collisions seen so far. More... | |
void | setQAlgorithm (QAlgorithm *qalgorithm) |
Gives a pointer to the QAlgorithm to the display. More... | |
int | getDisplayTimestep () |
Returns the display timestep. More... | |
Additional Inherited Members | |
Protected Attributes inherited from CollisionDisplay | |
QTimer * | timer |
QAlgorithm * | qalg |
int | numCollisions |
int | displayTimestep |
MultiQueue * | positionQueue |
std::queue< int > | collisionTimesteps |
The view containing 2D visualization.
CollisionDisplay2D creates and displays a 2D visualization of a simulation. It keeps track of a QParticle2D for each particle in the environment and it updates their drawing on the scene at every timestep.
It inherits from QGraphicsView and CollisionDisplay.
|
explicit |
Constructs a CollisionDisplay2D.
Calls CollisionDisplay constructor and QGraphicsView constructor. Initializes the QGraphicsScene scene and sets its dimensions. Initializes the QTimer timer used to continually update the graphics.
parent | the parent window if one exists. |
|
signal |
Signals that the display has finished. Usually because the user clicked "stop", for example.
This signal allows CollisionSystem to start a new simulation or exit safely.
QGraphicsScene * CollisionDisplay2D::getScene | ( | ) |
Gets the scene that is declared in CollisionDisplay2D.
QTimer * CollisionDisplay2D::getTimer | ( | ) |
Gets the timer declared in CollisionDisplay.
void CollisionDisplay2D::setQAlgorithm | ( | QAlgorithm * | qalgorithm | ) |
Sets the algorithm declared in CollisionDisplay.
Pointer | to the QAlgorithm being used. |
|
slot |
Starts the simulation.
Several values are reinitialized to values they should be at the beginning of a simulation. A QParticle2D qp is created and mapped to every Particle p in the environment. Every qp is then added to the scene that will be displayed.
Finally, the timer is started.
|
slot |
Performs one step of the display.
Increments the display timestep and checks it against the TIMESTEP_LIMIT to see if the display should continue running. If so, attempts to update the position of each QParticle2D and mark them as colliding if they will collide within the specified window. Finally, updates the timer interval to allow the framerate to be changed in real time.