wheeledexperimenthelper.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 WHEELEDEXPERIMENTHELPER_H
24 #define WHEELEDEXPERIMENTHELPER_H
25 
26 #include "experimentsconfig.h"
27 #include "parametersettable.h"
28 #include "resourcesuser.h"
29 #include "world.h"
30 #include "wvector.h"
31 #include "phyobject.h"
32 #include "phybox.h"
33 #include "phycylinder.h"
34 #include <QVector>
35 
36 namespace farsa {
37 
38 class Arena;
39 
48 class FARSA_EXPERIMENTS_API PhyObject2DWrapper
49 {
50 public:
54  enum Type {
55  Plane = 0,
56  Wall,
57  Box,
58  RectangularTargetArea,
59  Cylinder,
60  SmallCylinder,
61  BigCylinder,
62  CircularTargetArea,
63  NumberOfDifferentTypes
64  };
65 
66 public:
74  virtual PhyObject* phyObject() = 0;
75 
81  virtual const PhyObject* phyObject() const = 0;
82 
89  virtual Type type() const = 0;
90 
97  virtual void setStatic(bool s);
98 
104  bool getStatic() const;
105 
112  void setPosition(wVector pos);
113 
121  virtual void setPosition(real x, real y) = 0;
122 
128  wVector position() const;
129 
151  virtual void computeLinearViewFieldOccupiedRange(const wMatrix& mtr, double& minAngle, double& maxAngle, double& distance) const = 0;
152 
158  void setTexture(QString textureName);
159 
165  QString texture() const;
166 
172  void setColor(QColor color);
173 
179  QColor color() const;
180 
188  void setUseColorTextureOfOwner(bool b);
189 
197  bool useColorTextureOfOwner() const;
198 
199 protected:
204 
208  virtual ~PhyObject2DWrapper();
209 
210 private:
217 
223  PhyObject2DWrapper& operator=(const PhyObject2DWrapper&);
224 
229  friend class Arena;
230 };
231 
235 class FARSA_EXPERIMENTS_API Box2DWrapper : public PhyObject2DWrapper
236 {
237 public:
245  virtual PhyBox* phyObject();
246 
252  virtual const PhyBox* phyObject() const;
253 
259  virtual Type type() const;
260 
267  virtual void setStatic(bool s);
268 
276  virtual void setPosition(real x, real y);
277 
302  virtual void computeLinearViewFieldOccupiedRange(const wMatrix& cameraMtr, double& minAngle, double& maxAngle, double& distance) const;
303 
312  const wVector& vertex(int i) const
313  {
314  return m_vertexes[i];
315  }
316 
324  const wVector& centerOnPlane() const
325  {
326  return m_centerOnPlane;
327  }
328 
329 protected:
339  Box2DWrapper(PhyBox* box, Type type);
340 
344  ~Box2DWrapper();
345 
346 private:
350  PhyBox* const m_box;
351 
358  QVector<wVector> m_vertexes;
359 
365  wVector m_centerOnPlane;
366 
374  const Type m_type;
375 
380  friend class Arena;
381 };
382 
386 class FARSA_EXPERIMENTS_API Cylinder2DWrapper : public PhyObject2DWrapper
387 {
388 public:
396  virtual PhyCylinder* phyObject();
397 
403  virtual const PhyCylinder* phyObject() const;
404 
412  virtual void setStatic(bool s);
413 
419  virtual Type type() const;
420 
427  virtual void setPosition(real x, real y);
428 
453  virtual void computeLinearViewFieldOccupiedRange(const wMatrix& cameraMtr, double& minAngle, double& maxAngle, double& distance) const;
454 
455 protected:
465  Cylinder2DWrapper(PhyCylinder* cylinder, Type type);
466 
471 
472 private:
476  PhyCylinder* const m_cylinder;
477 
485  const Type m_type;
486 
491  friend class Arena;
492 };
493 
494 } // end namespace farsa
495 
496 #endif