ChirpSim
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
arena.h
Go to the documentation of this file.
1 #ifndef ARENA_H
2 #define ARENA_H
3 
4 #include <QString>
5 #include <QJsonObject>
6 #include <QGraphicsItem>
7 #include <Box2D/Box2D.h>
8 
9 #include "world.h"
10 #include "physicalobject.h"
11 
12 class Arena;
13 
20 PhysicalObject *arenaFactory(World *world, const QJsonObject &obj);
21 
28 class Arena : public PhysicalObject, public QGraphicsItem
29 {
30 public:
40  explicit Arena(b2World *world, QPointF position = QPointF(0,0), float halfWidth = 200, float halfHeight = 200);
41  ~Arena();
42 
47  QRectF boundingRect() const;
48 
52  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
53 
58  b2Body *body() const { return _body; }
59 
64  QGraphicsItem *item() const { return const_cast<Arena*>(this); }
65 
66 signals:
67 
68 public slots:
69 
70 private:
71  void CreatePhysicalBody(QPointF position, float width, float height, b2World *world);
72 
73 private:
74  friend PhysicalObject *arenaFactory(World *world, const QJsonObject &obj);
75  QRectF _boundingRect;
76 
77  b2Body* _body;
78 
79  static const QString Name;
80 };
81 
82 #endif // ARENA_H