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

The Arena class creates four walls that are immovable at a specified distance from the center position. More...

#include <arena.h>

Inheritance diagram for Arena:
Inheritance graph

Public Member Functions

 Arena (b2World *world, QPointF position=QPointF(0, 0), float halfWidth=200, float halfHeight=200)
 Constructor creating an Arena object based on a number of parameters. More...
 
 ~Arena ()
 
QRectF boundingRect () const
 boundingRect returns the computed bounding rectangle used for drawing and redrawing the object. From the QGraphicsItem abstract base class. More...
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 paint Draws the walls for display. From the QGraphicsItem abstract base class. More...
 
b2Body * body () const
 Simple getter for _body field. From the PhysicalObject interface class. More...
 
QGraphicsItem * item () const
 Simple getter for returning QGraphicsItem connected to this object. From the PhysicalObject interface class. More...
 
- Public Member Functions inherited from PhysicalObject
 PhysicalObject ()
 
virtual ~PhysicalObject ()
 
virtual void step (float dt)
 Called by World on all PhysicalObjects in the simulation so they can implement any custom physics. More...
 
virtual void stepGraphics ()
 stepGraphics More...
 

Private Member Functions

void CreatePhysicalBody (QPointF position, float width, float height, b2World *world)
 

Private Attributes

QRectF _boundingRect
 
b2Body * _body
 

Static Private Attributes

static const QString Name = QString("Arena")
 

Friends

PhysicalObjectarenaFactory (World *world, const QJsonObject &obj)
 chirpFactory follows the PhysicalObject FactoryFunction, creating the Arena object from a QJsonObject. More...
 

Detailed Description

The Arena class creates four walls that are immovable at a specified distance from the center position.

The Arena class creates four walls that are immovable at a specified distance from the center position. It handles creation of all four walls in the Box2D world, along with drawing them in the simulator. It's a handy class for restricting movement in the world.

Constructor & Destructor Documentation

Arena::Arena ( b2World *  world,
QPointF  position = QPointF(0,0),
float  halfWidth = 200,
float  halfHeight = 200 
)
explicit

Constructor creating an Arena object based on a number of parameters.

Parameters
worldWorld for the arena to be created in.
positionCenter position of the arena.
halfWidthDistance from center position to both walls on the x-axis.
halfHeightDistance from the center position to both walls on the y-axis.

Creates a physical model of the arena with Box2D and sets up the drawing of the walls.

References CreatePhysicalBody().

Here is the call graph for this function:

Arena::~Arena ( )

Member Function Documentation

b2Body* Arena::body ( ) const
inlinevirtual

Simple getter for _body field. From the PhysicalObject interface class.

Returns
Physical representation of object used by b2World class.

Implements PhysicalObject.

References _body.

QRectF Arena::boundingRect ( ) const

boundingRect returns the computed bounding rectangle used for drawing and redrawing the object. From the QGraphicsItem abstract base class.

Returns
bounding rectangle.

References _boundingRect.

void Arena::CreatePhysicalBody ( QPointF  position,
float  width,
float  height,
b2World *  world 
)
private

References _body.

Referenced by Arena().

Here is the caller graph for this function:

QGraphicsItem* Arena::item ( ) const
inlinevirtual

Simple getter for returning QGraphicsItem connected to this object. From the PhysicalObject interface class.

Returns
this casted to a non-const pointer.

Implements PhysicalObject.

void Arena::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget 
)

paint Draws the walls for display. From the QGraphicsItem abstract base class.

References _body, _boundingRect, and genericPaint().

Here is the call graph for this function:

Friends And Related Function Documentation

PhysicalObject* arenaFactory ( World world,
const QJsonObject &  obj 
)
friend

chirpFactory follows the PhysicalObject FactoryFunction, creating the Arena object from a QJsonObject.

See Also
physicalobjectfactory.h
Parameters
worldWorld to put the physical object model in.
objJsonObject containing the parameters for the object.
Returns
A constructed Arena object.

Member Data Documentation

b2Body* Arena::_body
private

Referenced by body(), CreatePhysicalBody(), and paint().

QRectF Arena::_boundingRect
private

Referenced by boundingRect(), and paint().

const QString Arena::Name = QString("Arena")
staticprivate

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