Space Comps
 All Classes Files Functions Variables
Public Slots | Signals | Public Member Functions | List of all members
CollisionDisplay2D Class Reference

The view containing 2D visualization. More...

#include <collisiondisplay2d.h>

Inheritance diagram for CollisionDisplay2D:
CollisionDisplay

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
 
QAlgorithmqalg
 
int numCollisions
 
int displayTimestep
 
MultiQueuepositionQueue
 
std::queue< int > collisionTimesteps
 

Detailed Description

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.

Constructor & Destructor Documentation

CollisionDisplay2D::CollisionDisplay2D ( QWidget *  parent = 0)
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.

Parameters
parentthe parent window if one exists.

Member Function Documentation

void CollisionDisplay2D::finished ( )
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.

Returns
Pointer to a QGraphicsScene scene.
QTimer * CollisionDisplay2D::getTimer ( )

Gets the timer declared in CollisionDisplay.

Returns
Pointer to a QTimer timer.
void CollisionDisplay2D::setQAlgorithm ( QAlgorithm qalgorithm)

Sets the algorithm declared in CollisionDisplay.

Parameters
Pointerto the QAlgorithm being used.
void CollisionDisplay2D::start ( )
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.

void CollisionDisplay2D::step ( )
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.


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