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.org/sumo
3 // Copyright (C) 2001-2022 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:
48  GNEDetector(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, const double pos,
49  const SUMOTime period, const std::vector<GNELane*>& parentLanes, const std::string& filename,
50  const std::vector<std::string>& vehicleTypes, const std::string& name, const bool friendlyPos, const Parameterised::Map& parameters);
51 
65  GNEDetector(GNEAdditional* additionalParent, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, const double pos,
66  const SUMOTime period, const std::vector<GNELane*>& parentLanes, const std::string& filename, const std::string& name,
67  const bool friendlyPos, const Parameterised::Map& parameters);
68 
70  ~GNEDetector();
71 
76 
79 
82  virtual void writeAdditional(OutputDevice& device) const = 0;
83 
85  virtual bool isAdditionalValid() const = 0;
86 
88  virtual std::string getAdditionalProblem() const = 0;
89 
91  virtual void fixAdditionalProblem() = 0;
93 
95  GNELane* getLane() const;
96 
98  double getPositionOverLane() const;
99 
101  double getGeometryPositionOverLane() const;
102 
106  virtual void updateGeometry() = 0;
107 
109  Position getPositionInView() const;
110 
112  void updateCenteringBoundary(const bool updateGrid);
113 
115  void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
117 
120 
123  std::string getParentName() const;
124 
129  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
131 
134  /* @brief method for getting the Attribute of an XML key
135  * @param[in] key The attribute key
136  * @return string with the value associated to key
137  */
138  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
139 
140  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
141  * @param[in] key The attribute key
142  * @return double with the value associated to key
143  */
144  virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
145 
147  const Parameterised::Map& getACParametersMap() const;
148 
149  /* @brief method for setting the attribute and letting the object perform additional changes
150  * @param[in] key The attribute key
151  * @param[in] value The new value
152  * @param[in] undoList The undoList on which to register changes
153  */
154  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
155 
156  /* @brief method for checking if the key and their conrrespond attribute are valids
157  * @param[in] key The attribute key
158  * @param[in] value The value associated to key key
159  * @return true if the value is valid, false in other case
160  */
161  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
162 
164  std::string getPopUpID() const;
165 
167  std::string getHierarchyName() const;
169 
170 protected:
173 
176 
178  std::string myFilename;
179 
181  std::vector<std::string> myVehicleTypes;
182 
185 
187  void drawE1Shape(const GUIVisualizationSettings& s, const double exaggeration, const double scaledWidth,
188  const RGBColor& mainColor, const RGBColor& secondColor) const;
189 
191  void drawDetectorLogo(const GUIVisualizationSettings& s, const double exaggeration, const std::string& logo, const RGBColor& textColor) const;
192 
193 private:
195  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
196 
198  virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
199 
201  virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
202 
204  const Position& getPosition() const = delete;
205 
207  void setPosition(const Position& pos) = delete;
208 };
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:48
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:175
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
virtual void setMoveShape(const GNEMoveResult &moveResult)=0
set move shape
std::string myFilename
The path to the output file.
Definition: GNEDetector.h:178
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:172
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEDetector.cpp:95
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
~GNEDetector()
Destructor.
Definition: GNEDetector.cpp:62
double getPositionOverLane() const
get position over lane
Definition: GNEDetector.cpp:83
void drawE1Shape(const GUIVisualizationSettings &s, const double exaggeration, const double scaledWidth, const RGBColor &mainColor, const RGBColor &secondColor) const
draw E1 shape
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
Definition: GNEDetector.cpp:89
virtual void updateGeometry()=0
update pre-computed geometry information
virtual double getAttributeDouble(SumoXMLAttr key) const =0
void setPosition(const Position &pos)=delete
Invalidate set new position in the view.
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNEDetector.cpp:66
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
virtual void writeAdditional(OutputDevice &device) const =0
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:184
void drawDetectorLogo(const GUIVisualizationSettings &s, const double exaggeration, const std::string &logo, const RGBColor &textColor) const
draw detector Logo
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
virtual std::string getAttribute(SumoXMLAttr key) const =0
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::string &name, const bool friendlyPos, const Parameterised::Map &parameters)
Constructor.
Definition: GNEDetector.cpp:37
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
virtual bool isAdditionalValid() const =0
check if current additional is valid to be writed into XML (must be reimplemented in all detector chi...
std::vector< std::string > myVehicleTypes
attribute vehicle types
Definition: GNEDetector.h:181
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