floor_entity.h
Go to the documentation of this file.
1 
7 #ifndef FLOOR_ENTITY_H
8 #define FLOOR_ENTITY_H
9 
10 namespace argos {
11  class CFloorEntity;
12 }
13 
14 #include <argos3/core/simulator/entity/entity.h>
15 #include <argos3/core/utility/math/vector2.h>
16 #include <argos3/core/utility/math/vector3.h>
17 #include <argos3/core/utility/datatypes/color.h>
18 
19 namespace argos {
20 
21  class CFloorEntity : public CEntity {
22 
23  public:
24 
26 
27  public:
28 
29  virtual ~CFloorColorSource() {}
30 
31  virtual void Reset() {}
32 
33  virtual CColor GetColorAtPoint(Real f_x,
34  Real f_y) = 0;
35 
36 #ifdef ARGOS_WITH_FREEIMAGE
37  virtual void SaveAsImage(const std::string& str_path) = 0;
38 #endif
39 
40  };
41 
42  public:
43 
44  ENABLE_VTABLE();
45 
46  enum EColorSource {
47  UNSET = 0,
50  };
51 
52  public:
53 
58  CFloorEntity();
59 
66 #ifdef ARGOS_WITH_FREEIMAGE
67  CFloorEntity(const std::string& str_id,
68  const std::string& str_file_name);
69 #endif
70 
75  CFloorEntity(const std::string& str_id,
76  UInt32 un_pixels_per_meter);
77 
81  virtual ~CFloorEntity();
82 
86  virtual void Init(TConfigurationNode& t_tree);
87 
91  virtual void Reset();
92 
100  Real f_y) {
101  ARGOS_ASSERT(m_pcColorSource != NULL,
102  "The floor entity \"" <<
103  GetId() <<
104  "\" has no associated color source.");
105  return m_pcColorSource->GetColorAtPoint(f_x, f_y);
106  }
107 
113  inline bool HasChanged() const {
114  return m_bHasChanged;
115  }
116 
121  inline void SetChanged() {
122  m_bHasChanged = true;
123  }
124 
129  inline void ClearChanged() {
130  m_bHasChanged = false;
131  }
132 
139 #ifdef ARGOS_WITH_FREEIMAGE
140  void SaveAsImage(const std::string& str_path);
141 #endif
142 
143  virtual std::string GetTypeDescription() const {
144  return "floor";
145  }
146 
147  private:
148 
152  EColorSource m_eColorSource;
153 
157  CFloorColorSource* m_pcColorSource;
158 
162  bool m_bHasChanged;
163  };
164 }
165 
166 #endif
virtual CColor GetColorAtPoint(Real f_x, Real f_y)=0
CColor GetColorAtPoint(Real f_x, Real f_y)
Returns the color at the given point.
Definition: floor_entity.h:99
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
The basic entity type.
Definition: entity.h:89
void SetChanged()
Marks the floor color as changed.
Definition: floor_entity.h:121
virtual void Reset()
Restores the initial state of the floor.
CFloorEntity()
Class constructor.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
#define ARGOS_ASSERT(condition, message)
When code is compiled in debug, this macro throws an ARGoS exception with the passed message if the s...
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
void ClearChanged()
Marks the floor color as not changed.
Definition: floor_entity.h:129
virtual void Init(TConfigurationNode &t_tree)
Initializes the entity from an XML tree.
bool HasChanged() const
Returns true if the floor color has changed.
Definition: floor_entity.h:113
virtual ~CFloorEntity()
Class destructor.
virtual std::string GetTypeDescription() const
Saves the current floor color to the given file.
Definition: floor_entity.h:143
The basic color type.
Definition: color.h:25
const std::string & GetId() const
Returns the id of this entity.
Definition: entity.h:157
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12