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-2020 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 "GNEAdditional.h"
22 
23 // ===========================================================================
24 // class definitions
25 // ===========================================================================
30 class GNEDetector : public GNEAdditional {
31 
32 public:
47  GNEDetector(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, double pos, const std::string& freq, const std::string& filename,
48  const std::string& vehicleTypes, const std::string& name, bool friendlyPos, bool blockMovement, const std::vector<GNELane*>& parentLanes);
49 
63  GNEDetector(GNEAdditional* additionalParent, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, double pos, const std::string& freq, const std::string& filename,
64  const std::string& name, bool friendlyPos, bool blockMovement, const std::vector<GNELane*>& parentLanes);
65 
67  ~GNEDetector();
68 
72  GNEMoveOperation* getMoveOperation(const double shapeOffset);
73 
77  virtual bool isAdditionalValid() const = 0;
78 
80  virtual std::string getAdditionalProblem() const = 0;
81 
83  virtual void fixAdditionalProblem() = 0;
85 
87  GNELane* getLane() const;
88 
90  double getPositionOverLane() const;
91 
93  double getGeometryPositionOverLane() const;
94 
98  virtual void updateGeometry() = 0;
99 
101  void updateCenteringBoundary(const bool updateGrid);
102 
104  void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
106 
109 
112  std::string getParentName() const;
113 
118  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
120 
123  /* @brief method for getting the Attribute of an XML key
124  * @param[in] key The attribute key
125  * @return string with the value associated to key
126  */
127  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
128 
129  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
130  * @param[in] key The attribute key
131  * @return double with the value associated to key
132  */
133  double getAttributeDouble(SumoXMLAttr key) const;
134 
135  /* @brief method for setting the attribute and letting the object perform additional changes
136  * @param[in] key The attribute key
137  * @param[in] value The new value
138  * @param[in] undoList The undoList on which to register changes
139  */
140  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
141 
142  /* @brief method for checking if the key and their conrrespond attribute are valids
143  * @param[in] key The attribute key
144  * @param[in] value The value asociated to key key
145  * @return true if the value is valid, false in other case
146  */
147  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
148 
149  /* @brief method for check if the value for certain attribute is set
150  * @param[in] key The attribute key
151  */
152  virtual bool isAttributeEnabled(SumoXMLAttr key) const = 0;
153 
155  std::string getPopUpID() const;
156 
158  std::string getHierarchyName() const;
160 
161 protected:
164 
166  std::string myFreq;
167 
169  std::string myFilename;
170 
172  std::string myVehicleTypes;
173 
176 
178  void drawE1Shape(const GUIVisualizationSettings& s, const double exaggeration, const double scaledWidth,
179  const RGBColor& mainColor, const RGBColor& secondColor) const;
180 
182  void drawDetectorLogo(const GUIVisualizationSettings& s, const double exaggeration, const std::string& logo, const RGBColor& textColor) const;
183 
184 private:
186  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
187 
189  void setMoveShape(const GNEMoveResult& moveResult);
190 
192  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
193 
195  const Position& getPosition() const = delete;
196 
198  void setPosition(const Position& pos) = delete;
199 };
GUIGlObjectType
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
GNEMoveOperation * getMoveOperation(const double shapeOffset)
get move operation for the given shapeOffset
Definition: GNEDetector.cpp:63
virtual std::string getAdditionalProblem() const =0
return a string with the current additional problem (must be reimplemented in all detector children)
virtual bool isAttributeEnabled(SumoXMLAttr key) const =0
GNEDetector(const std::string &id, GNENet *net, GUIGlObjectType type, SumoXMLTag tag, double pos, const std::string &freq, const std::string &filename, const std::string &vehicleTypes, const std::string &name, bool friendlyPos, bool blockMovement, const std::vector< GNELane * > &parentLanes)
Constructor.
Definition: GNEDetector.cpp:36
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
std::string myFilename
The path to the output file.
Definition: GNEDetector.h:169
virtual void fixAdditionalProblem()=0
fix additional problem (must be reimplemented in all detector children)
std::string myFreq
The aggregation period the values the detector collects shall be summed up.
Definition: GNEDetector.h:166
virtual void setAttribute(SumoXMLAttr key, const std::string &value)=0
set attribute after validation
double myPositionOverLane
position of detector over Lane
Definition: GNEDetector.h:163
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
double getAttributeDouble(SumoXMLAttr key) const
~GNEDetector()
Destructor.
Definition: GNEDetector.cpp:59
double getPositionOverLane() const
get position over lane
Definition: GNEDetector.cpp:76
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
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:82
virtual void updateGeometry()=0
update pre-computed geometry information
void setPosition(const Position &pos)=delete
Invalidate set new position in the view.
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
std::string myVehicleTypes
attribute vehicle types
Definition: GNEDetector.h:172
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNEDetector.cpp:98
bool myFriendlyPosition
Flag for friendly position.
Definition: GNEDetector.h:175
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)
Definition: GNEDetector.cpp:88
virtual std::string getAttribute(SumoXMLAttr key) const =0
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 (by default true, can be reimplemented in ...
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:45
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
Stores the information about how to visualize structures.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36