ChirpSim
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
World Class Reference

The World class represents the physical world being simulated. More...

#include <world.h>

Inheritance diagram for World:
Inheritance graph

Public Member Functions

 ~World ()
 
void addObject (PhysicalObject *object)
 Adds an object to the simulation. More...
 
void removeObject (PhysicalObject *object)
 Removes an object from the simulation. More...
 
void step (float dt)
 Steps the simulation once, then calls the step method of all the objects in the simulation. More...
 
void stepGraphics ()
 Called by SimulatorView to synchronize the graphical view (positions and rotations) with the physical simulation of each object. More...
 
b2World * world ()
 Getter for the Box2D world object. More...
 

Static Public Member Functions

static WorldfromJsonDocument (const QJsonDocument &doc)
 Named constructor creating a world with many PhysicalObject based on a JSON-document. More...
 
static Worldinstance ()
 Static getter method to get the singleton instance of the class. More...
 

Private Member Functions

 World ()
 

Private Attributes

b2World * _world
 
QList< PhysicalObject * > _physicalObjects
 

Static Private Attributes

static World_instance = NULL
 

Detailed Description

The World class represents the physical world being simulated.

It has methods for adding and removing objects from the simulation. The step function will call the step-method on all PhysicalObject stored in the simulation.

The world can be created from a JSON-file, which will delete the old world and create a new one based on the objects of the JSON-file.

Constructor & Destructor Documentation

World::~World ( )

References _instance, and _world.

World::World ( )
explicitprivate

References _world.

Referenced by fromJsonDocument(), and instance().

Here is the caller graph for this function:

Member Function Documentation

void World::addObject ( PhysicalObject object)

Adds an object to the simulation.

Parameters
objectPhysicalObject that will be added to the simulation.

References _physicalObjects, and PhysicalObject::item().

Referenced by fromJsonDocument().

Here is the call graph for this function:

Here is the caller graph for this function:

World * World::fromJsonDocument ( const QJsonDocument &  doc)
static

Named constructor creating a world with many PhysicalObject based on a JSON-document.

Parameters
docThe JSON-document containing the objects in the world.
Returns
The newly created world.

References _instance, addObject(), PhysicalObjectFactory::getFactory(), PhysicalObjectFactory::instance(), and World().

Referenced by MainWindow::on_actionLoad_World_triggered().

Here is the call graph for this function:

Here is the caller graph for this function:

World * World::instance ( )
static

Static getter method to get the singleton instance of the class.

Returns
Singleton instance of World.

References _instance, and World().

Referenced by SimulatorView::SimulatorView().

Here is the call graph for this function:

Here is the caller graph for this function:

void World::removeObject ( PhysicalObject object)

Removes an object from the simulation.

Parameters
objectPhysicalObject that will be removed from the simulation.

References _physicalObjects, _world, PhysicalObject::body(), and PhysicalObject::item().

Here is the call graph for this function:

void World::step ( float  dt)

Steps the simulation once, then calls the step method of all the objects in the simulation.

Parameters
dtTime in seconds since last step.

References _physicalObjects, and _world.

Referenced by SimulatorView::step().

Here is the caller graph for this function:

void World::stepGraphics ( )

Called by SimulatorView to synchronize the graphical view (positions and rotations) with the physical simulation of each object.

References _physicalObjects.

Referenced by SimulatorView::step().

Here is the caller graph for this function:

b2World * World::world ( )

Getter for the Box2D world object.

Returns
The Box2D world object holding all the simulation details.

References _world.

Referenced by arenaFactory(), chirpFactory(), pushableObjectFactory(), and wallFactory().

Here is the caller graph for this function:

Member Data Documentation

World * World::_instance = NULL
staticprivate

Referenced by fromJsonDocument(), instance(), and ~World().

QList<PhysicalObject*> World::_physicalObjects
private
b2World* World::_world
private

Referenced by removeObject(), step(), world(), World(), and ~World().


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