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 {
32 
33 public:
48  GNEDetector(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, const double pos, const SUMOTime freq,
49  const std::vector<GNELane*>& parentLanes, const std::string& filename, const std::vector<std::string>& vehicleTypes,
50  const std::string& name, const bool friendlyPos, const std::map<std::string, std::string>& parameters);
51 
65  GNEDetector(GNEAdditional* additionalParent, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, const double pos, const SUMOTime freq,
66  const std::vector<GNELane*>& parentLanes, const std::string& filename, const std::string& name, const bool friendlyPos,
67  const std::map<std::string, std::string>& 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 
146  /* @brief method for setting the attribute and letting the object perform additional changes
147  * @param[in] key The attribute key
148  * @param[in] value The new value
149  * @param[in] undoList The undoList on which to register changes
150  */
151  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
152 
153  /* @brief method for checking if the key and their conrrespond attribute are valids
154  * @param[in] key The attribute key
155  * @param[in] value The value asociated to key key
156  * @return true if the value is valid, false in other case
157  */
158  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
159 
160  /* @brief method for check if the value for certain attribute is set
161  * @param[in] key The attribute key
162  */
163  virtual bool isAttributeEnabled(SumoXMLAttr key) const = 0;
164 
166  std::string getPopUpID() const;
167 
169  std::string getHierarchyName() const;
171 
172 protected:
175 
178 
180  std::string myFilename;
181 
183  std::vector<std::string> myVehicleTypes;
184 
187 
189  void drawE1Shape(const GUIVisualizationSettings& s, const double exaggeration, const double scaledWidth,
190  const RGBColor& mainColor, const RGBColor& secondColor) const;
191 
193  void drawDetectorLogo(const GUIVisualizationSettings& s, const double exaggeration, const std::string& logo, const RGBColor& textColor) const;
194 
195 private:
197  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
198 
200  virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
201 
203  virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
204 
207 
210 
212  const Position& getPosition() const = delete;
213 
215  void setPosition(const Position& pos) = delete;
216 };
GUIGlObjectType
long long int SUMOTime
Definition: SUMOTime.h:32
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:48
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
virtual void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)=0
commit move shape
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
virtual void setMoveShape(const GNEMoveResult &moveResult)=0
set move shape
GNEDetector(const std::string &id, GNENet *net, GUIGlObjectType type, SumoXMLTag tag, const double pos, const SUMOTime freq, const std::vector< GNELane * > &parentLanes, const std::string &filename, const std::vector< std::string > &vehicleTypes, const std::string &name, const bool friendlyPos, const std::map< std::string, std::string > &parameters)
Constructor.
Definition: GNEDetector.cpp:40
std::string myFilename
The path to the output file.
Definition: GNEDetector.h:180
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:174
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEDetector.cpp:94
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
~GNEDetector()
Destructor.
Definition: GNEDetector.cpp:63
SUMOTime myFreq
The aggregation period the values the detector collects shall be summed up.
Definition: GNEDetector.h:177
double getPositionOverLane() const
get position over lane
Definition: GNEDetector.cpp:82
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:88
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 * getMoveOperationE2MultiLane()
get moveOperation for E2 multi lane
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNEDetector.cpp:67
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
virtual void writeAdditional(OutputDevice &device) const =0
writte 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:186
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
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...
GNEMoveOperation * getMoveOperationE2SingleLane()
get moveOperation for E2 single lane
std::vector< std::string > myVehicleTypes
attribute vehicle types
Definition: GNEDetector.h:183
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
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37