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 
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 
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
#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
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
The basic entity type.
Definition: entity.h:90
const std::string & GetId() const
Returns the id of this entity.
Definition: entity.h:157
virtual void Reset()
Restores the initial state of the floor.
CColor GetColorAtPoint(Real f_x, Real f_y)
Returns the color at the given point.
Definition: floor_entity.h:99
CFloorEntity()
Class constructor.
virtual void Init(TConfigurationNode &t_tree)
Initializes the entity from an XML tree.
virtual std::string GetTypeDescription() const
Saves the current floor color to the given file.
Definition: floor_entity.h:143
virtual ~CFloorEntity()
Class destructor.
bool HasChanged() const
Returns true if the floor color has changed.
Definition: floor_entity.h:113
void ClearChanged()
Marks the floor color as not changed.
Definition: floor_entity.h:129
void SetChanged()
Marks the floor color as changed.
Definition: floor_entity.h:121
virtual CColor GetColorAtPoint(Real f_x, Real f_y)=0
The basic color type.
Definition: color.h:25