arena.h
1 /********************************************************************************
2  * FARSA Experimentes Library *
3  * Copyright (C) 2007-2012 *
4  * Gianluca Massera <emmegian@yahoo.it> *
5  * Stefano Nolfi <stefano.nolfi@istc.cnr.it> *
6  * Tomassino Ferrauto <tomassino.ferrauto@istc.cnr.it> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
21  ********************************************************************************/
22 
23 #ifndef ARENA_H
24 #define ARENA_H
25 
26 #include "experimentsconfig.h"
27 #include "parametersettable.h"
28 #include "resourcesuser.h"
29 #include "world.h"
30 #include "wheeledexperimenthelper.h"
31 #include <QVector>
32 
33 namespace farsa {
34 
45 class FARSA_EXPERIMENTS_API Arena : public ParameterSettableInConstructor, public ConcurrentResourcesUser
46 {
47 public:
58  Arena(ConfigurationParameters& params, QString prefix);
59 
63  virtual ~Arena();
64 
75  virtual void save(ConfigurationParameters& params, QString prefix);
76 
89  static void describe(QString type);
90 
96  const QVector<PhyObject2DWrapper*>& getObjects() const
97  {
98  return m_objects2DList;
99  }
100 
106  real getZ() const
107  {
108  return m_z;
109  }
110 
116  real getWidth() const
117  {
118  return m_plane->phyObject()->sideX();
119  }
120 
126  real getHeight() const
127  {
128  return m_plane->phyObject()->sideY();
129  }
130 
139  void addRobots(QStringList robots);
140 
146  Box2DWrapper* getPlane();
147 
165  Box2DWrapper* createWall(QColor color, wVector start, wVector end, real thickness, real height = -1.0);
166 
177  Cylinder2DWrapper* createSmallCylinder(QColor color, real height = -1.0);
178 
189  Cylinder2DWrapper* createBigCylinder(QColor color, real height = -1.0);
190 
200  Cylinder2DWrapper* createCircularTargetArea(real radius, QColor color);
201 
212  Box2DWrapper* createRectangularTargetArea(real width, real depth, QColor color);
213 
214 private:
225  Cylinder2DWrapper* createCylinder(QColor color, real radius, real height, Cylinder2DWrapper::Type type);
226 
238  Box2DWrapper* createBox(QColor color, real width, real depth, real height, Box2DWrapper::Type type);
239 
247  virtual void resourceChanged(QString resourceName, ResourceChangeType changeType);
248 
252  const real m_z;
253 
257  Box2DWrapper* const m_plane;
258 
262  QVector<PhyObject2DWrapper*> m_objects2DList;
263 
267  World* m_world;
268 
277  static Box2DWrapper* createPlane(ConfigurationParameters& params, QString prefix, real z);
278 };
279 
280 } // end namespace farsa
281 
282 #endif