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

The Wall class represents a physical object that is immovable during simulation. More...

#include <wall.h>

Inheritance diagram for Wall:
Inheritance graph

Public Member Functions

 Wall (b2World *world, QList< QList< QPointF > > hulls, QPointF position=QPointF(0, 0), float angle=0)
 Constructor creating a Wall object based on a number of parameters. More...
 
 ~Wall ()
 
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 wall 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 ComputeBoundingRect ()
 

Private Attributes

b2Body * _body
 
QRectF _boundingRect
 

Friends

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

Detailed Description

The Wall class represents a physical object that is immovable during simulation.

The Wall class represents a physical object that is immovable during simulation. It is perfect for creating an obstacle that cannot be moved.

The immovable wall object in simulation:

wall.png

Constructor & Destructor Documentation

Wall::Wall ( b2World *  world,
QList< QList< QPointF > >  hulls,
QPointF  position = QPointF(0,0),
float  angle = 0 
)
explicit

Constructor creating a Wall object based on a number of parameters.

Parameters
worldWorld for the pushable object to be created in.
hullsList of hulls forming the shape of the object. Each hull forms a separate collision mesh, allowing simulation of a concave hull through making them a series of convex hulls.
Note
Vertices must be in counterclockwise order, and must form a convex hull.
Parameters
positionStarting position of the pushable object.
angleStarting angle of the pushable object.

Creates a physical model of the wall object with Box2D and sets up the drawing of the object.

References _body, ComputeBoundingRect(), DEGTORAD, and QPointFTob2Vec2().

Here is the call graph for this function:

Wall::~Wall ( )

Member Function Documentation

b2Body* Wall::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 Wall::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 Wall::ComputeBoundingRect ( )
private

References _body, and _boundingRect.

Referenced by Wall().

Here is the caller graph for this function:

QGraphicsItem* Wall::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 Wall::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget 
)

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

References _body, and genericPaint().

Here is the call graph for this function:

Friends And Related Function Documentation

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

chirpFactory follows the PhysicalObject FactoryFunction, creating the Wall 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 Wall object.

Member Data Documentation

b2Body* Wall::_body
private

Referenced by body(), ComputeBoundingRect(), paint(), and Wall().

QRectF Wall::_boundingRect
private

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