Eclipse SUMO - Simulation of Urban MObility
GNEDetector.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // A abstract class to define common parameters of detectors placed over lanes
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 #include "GNEAdditional.h"
23 
24 // ===========================================================================
25 // class definitions
26 // ===========================================================================
31 class GNEDetector : public GNEAdditional, public Parameterised {
32 
33 public:
50  GNEDetector(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, const double pos,
51  const SUMOTime period, const std::vector<GNELane*>& parentLanes, const std::string& filename,
52  const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges, const std::string& detectPersons,
53  const std::string& name, const bool friendlyPos, const Parameterised::Map& parameters);
54 
68  GNEDetector(GNEAdditional* additionalParent, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, const double pos,
69  const SUMOTime period, const std::vector<GNELane*>& parentLanes, const std::string& filename, const std::string& name,
70  const bool friendlyPos, const Parameterised::Map& parameters);
71 
73  ~GNEDetector();
74 
79 
82 
86  virtual void writeAdditional(OutputDevice& device) const = 0;
87 
89  virtual bool isAdditionalValid() const = 0;
90 
92  virtual std::string getAdditionalProblem() const = 0;
93 
95  virtual void fixAdditionalProblem() = 0;
96 
98 
101 
103  bool checkDrawMoveContour() const;
104 
106 
108  GNELane* getLane() const;
109 
111  double getPositionOverLane() const;
112 
114  double getGeometryPositionOverLane() const;
115 
118 
120  virtual void updateGeometry() = 0;
121 
123  Position getPositionInView() const;
124 
126  void updateCenteringBoundary(const bool updateGrid);
127 
129  void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
130 
132 
135 
139  std::string getParentName() const;
140 
145  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
146 
148 
151 
152  /* @brief method for getting the Attribute of an XML key
153  * @param[in] key The attribute key
154  * @return string with the value associated to key
155  */
156  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
157 
158  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
159  * @param[in] key The attribute key
160  * @return double with the value associated to key
161  */
162  virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
163 
165  const Parameterised::Map& getACParametersMap() const;
166 
167  /* @brief method for setting the attribute and letting the object perform additional changes
168  * @param[in] key The attribute key
169  * @param[in] value The new value
170  * @param[in] undoList The undoList on which to register changes
171  */
172  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
173 
174  /* @brief method for checking if the key and their conrrespond attribute are valids
175  * @param[in] key The attribute key
176  * @param[in] value The value associated to key key
177  * @return true if the value is valid, false in other case
178  */
179  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
180 
182  std::string getPopUpID() const;
183 
185  std::string getHierarchyName() const;
186 
188 
189 protected:
191  double myPositionOverLane = 0;
192 
195 
197  std::string myFilename;
198 
200  std::vector<std::string> myVehicleTypes;
201 
203  std::vector<std::string> myNextEdges;
204 
206  std::string myDetectPersons;
207 
209  bool myFriendlyPosition = false;
210 
211  /* @brief method for getting the Attribute of an XML key
212  * @param[in] key The attribute key
213  * @return string with the value associated to key
214  */
215  std::string getDetectorAttribute(SumoXMLAttr key) const;
216 
217  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
218  * @param[in] key The attribute key
219  * @return double with the value associated to key
220  */
221  double getDetectorAttributeDouble(SumoXMLAttr key) const;
222 
223  /* @brief method for setting the attribute and letting the object perform additional changes
224  * @param[in] key The attribute key
225  * @param[in] value The new value
226  * @param[in] undoList The undoList on which to register changes
227  */
228  void setDetectorAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
229 
230  /* @brief method for checking if the key and their conrrespond attribute are valids
231  * @param[in] key The attribute key
232  * @param[in] value The value associated to key key
233  * @return true if the value is valid, false in other case
234  */
235  bool isDetectorValid(SumoXMLAttr key, const std::string& value);
236 
240  void writeDetectorValues(OutputDevice& device) const;
241 
243  void setDetectorAttribute(SumoXMLAttr key, const std::string& value);
244 
246  void drawE1Shape(const GUIVisualizationSettings::Detail d, const double exaggeration,
247  const RGBColor& mainColor, const RGBColor& secondColor) const;
248 
251  const double exaggeration, const std::string& logo, const RGBColor& textColor) const;
252 
255  const double exaggeration, const std::string& logo, const RGBColor& textColor) const;
256 
257 private:
259  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
260 
262  virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
263 
265  virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
266 
268  const Position& getPosition() const = delete;
269 
271  void setPosition(const Position& pos) = delete;
272 };
long long int SUMOTime
Definition: GUI.h:35
GUIGlObjectType
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:49
virtual std::string getAdditionalProblem() const =0
return a string with the current additional problem (must be reimplemented in all detector children)
virtual void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)=0
commit move shape
SUMOTime myPeriod
The aggregation period the values the detector collects shall be summed up.
Definition: GNEDetector.h:194
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
virtual void setMoveShape(const GNEMoveResult &moveResult)=0
set move shape
void drawE2DetectorLogo(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration, const std::string &logo, const RGBColor &textColor) const
draw E2 detector Logo
std::string myFilename
The path to the output file.
Definition: GNEDetector.h:197
virtual void fixAdditionalProblem()=0
fix additional problem (must be reimplemented in all detector children)
virtual void setAttribute(SumoXMLAttr key, const std::string &value)=0
set attribute after validation
double myPositionOverLane
position of detector over Lane
Definition: GNEDetector.h:191
Position getPositionInView() const
Returns position of additional in view.
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
GNEDetector(const std::string &id, GNENet *net, GUIGlObjectType type, SumoXMLTag tag, FXIcon *icon, const double pos, const SUMOTime period, const std::vector< GNELane * > &parentLanes, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::vector< std::string > &nextEdges, const std::string &detectPersons, const std::string &name, const bool friendlyPos, const Parameterised::Map &parameters)
Constructor.
Definition: GNEDetector.cpp:38
~GNEDetector()
Destructor.
Definition: GNEDetector.cpp:67
bool isDetectorValid(SumoXMLAttr key, const std::string &value)
double getPositionOverLane() const
get position over lane
Definition: GNEDetector.cpp:88
const Position & getPosition() const =delete
Invalidate return position of additional.
double getGeometryPositionOverLane() const
get position over lane that is applicable to the shape
GNELane * getLane() const
get lane
virtual void updateGeometry()=0
update pre-computed geometry information
virtual double getAttributeDouble(SumoXMLAttr key) const =0
void setDetectorAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void setPosition(const Position &pos)=delete
Invalidate set new position in the view.
std::vector< std::string > myNextEdges
next edges
Definition: GNEDetector.h:203
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNEDetector.cpp:71
void drawE1Shape(const GUIVisualizationSettings::Detail d, const double exaggeration, const RGBColor &mainColor, const RGBColor &secondColor) const
draw E1 shape
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their correspondent attribute are valids
const Parameterised::Map & getACParametersMap() const
get parameters map
double getDetectorAttributeDouble(SumoXMLAttr key) const
bool checkDrawMoveContour() const
check if draw move contour (red)
Definition: GNEDetector.cpp:94
virtual void writeAdditional(OutputDevice &device) const =0
write additional element into a xml file
void writeDetectorValues(OutputDevice &device) const
write additional element into a xml file
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
bool myFriendlyPosition
Flag for friendly position.
Definition: GNEDetector.h:209
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
virtual std::string getAttribute(SumoXMLAttr key) const =0
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
std::string getDetectorAttribute(SumoXMLAttr key) const
virtual bool isAdditionalValid() const =0
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
std::vector< std::string > myVehicleTypes
attribute vehicle types
Definition: GNEDetector.h:200
void drawE1DetectorLogo(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration, const std::string &logo, const RGBColor &textColor) const
draw E1 detector Logo
std::string myDetectPersons
detect persons
Definition: GNEDetector.h:206
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes
std::string getParentName() const
Returns the name of the parent object.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
Stores the information about how to visualize structures.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37