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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // A abstract class to define common parameters of detectors placed over lanes
15 /****************************************************************************/
16 #ifndef GNEDetector_h
17 #define GNEDetector_h
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 
24 #include "GNEAdditional.h"
25 
26 // ===========================================================================
27 // class definitions
28 // ===========================================================================
33 class GNEDetector : public GNEAdditional {
34 
35 public:
50  GNEDetector(const std::string& id, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag, double pos, SUMOTime freq, const std::string& filename,
51  const std::string& vehicleTypes, const std::string& name, bool friendlyPos, bool blockMovement, const std::vector<GNELane*>& parentLanes);
52 
66  GNEDetector(GNEAdditional* additionalParent, GNEViewNet* viewNet, GUIGlObjectType type, SumoXMLTag tag, double pos, SUMOTime freq, const std::string& filename,
67  const std::string& name, bool friendlyPos, bool blockMovement, const std::vector<GNELane*>& parentLanes);
68 
70  ~GNEDetector();
71 
75  virtual bool isAdditionalValid() const = 0;
76 
78  virtual std::string getAdditionalProblem() const = 0;
79 
81  virtual void fixAdditionalProblem() = 0;
83 
85  GNELane* getLane() const;
86 
88  double getPositionOverLane() const;
89 
91  double getGeometryPositionOverLane() const;
92 
95 
98  virtual void moveGeometry(const Position& offset) = 0;
99 
103  virtual void commitGeometryMoving(GNEUndoList* undoList) = 0;
104 
106  virtual void updateGeometry() = 0;
107 
109  Position getPositionInView() const;
110 
113 
115  void splitEdgeGeometry(const double splitPosition, const GNENetElement* originalElement, const GNENetElement* 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  double getAttributeDouble(SumoXMLAttr key) const;
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::string myVehicleTypes;
184 
187 
188 private:
190  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
191 
193  const Position& getPosition() const = delete;
194 
196  void setPosition(const Position& pos) = delete;
197 };
198 
199 #endif
200 
201 /****************************************************************************/
GNEAdditional
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
GNEAdditional.h
GNEDetector::commitGeometryMoving
virtual void commitGeometryMoving(GNEUndoList *undoList)=0
commit geometry changes in the attributes of an element after use of moveGeometry(....
GNEDetector::setAttribute
virtual void setAttribute(SumoXMLAttr key, const std::string &value)=0
set attribute after validation
GNEDetector::~GNEDetector
~GNEDetector()
Destructor.
Definition: GNEDetector.cpp:56
GNEDetector::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEDetector.cpp:72
GNEDetector::getPositionOverLane
double getPositionOverLane() const
get position over lane
Definition: GNEDetector.cpp:60
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
GNEDetector::isAdditionalValid
virtual bool isAdditionalValid() const =0
check if current additional is valid to be writed into XML (by default true, can be reimplemented in ...
GNEDetector::moveGeometry
virtual void moveGeometry(const Position &offset)=0
change the position of the element geometry without saving in undoList
GNEViewNet
Definition: GNEViewNet.h:42
GNEDetector::myPositionOverLane
double myPositionOverLane
position of detector over Lane
Definition: GNEDetector.h:174
GNEDetector::fixAdditionalProblem
virtual void fixAdditionalProblem()=0
fix additional problem (must be reimplemented in all detector children)
GNEDetector::myFriendlyPosition
bool myFriendlyPosition
Flag for friendly position.
Definition: GNEDetector.h:186
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:41
GNEDetector::splitEdgeGeometry
void splitEdgeGeometry(const double splitPosition, const GNENetElement *originalElement, const GNENetElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNEDetector.cpp:88
GNEDetector::getPosition
const Position & getPosition() const =delete
Invalidate return position of additional.
GNEDetector::getGeometryPositionOverLane
double getGeometryPositionOverLane() const
get position over lane that is applicable to the shape
Definition: GNEDetector.cpp:110
GUIGlObjectType
GUIGlObjectType
Definition: GUIGlObjectTypes.h:39
GNEDetector::updateGeometry
virtual void updateGeometry()=0
update pre-computed geometry information
GNEDetector::getParentName
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEDetector.cpp:128
GNEDetector::myVehicleTypes
std::string myVehicleTypes
attribute vehicle types
Definition: GNEDetector.h:183
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GNEDetector::getLane
GNELane * getLane() const
get lane
Definition: GNEDetector.cpp:66
GNEDetector
Definition: GNEDetector.h:33
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GNEDetector::isValid
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
GNENetElement
Definition: GNENetElement.h:43
GNEDetector::setAttribute
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes
GNEDetector::getAttribute
virtual std::string getAttribute(SumoXMLAttr key) const =0
GNEDetector::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEDetector.cpp:140
GNEDetector::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEDetector.cpp:78
GNEDetector::setPosition
void setPosition(const Position &pos)=delete
Invalidate set new position in the view.
GNEDetector::getAttributeDouble
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNEDetector.cpp:122
GNEDetector::myFilename
std::string myFilename
The path to the output file.
Definition: GNEDetector.h:180
GNEDetector::myFreq
SUMOTime myFreq
The aggregation period the values the detector collects shall be summed up.
Definition: GNEDetector.h:177
GNEDetector::drawGL
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
GNEDetector::GNEDetector
GNEDetector(const std::string &id, GNEViewNet *viewNet, GUIGlObjectType type, SumoXMLTag tag, double pos, SUMOTime 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:33
GNEUndoList
Definition: GNEUndoList.h:48
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GNEDetector::isAttributeEnabled
virtual bool isAttributeEnabled(SumoXMLAttr key) const =0
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
GNEDetector::getAdditionalProblem
virtual std::string getAdditionalProblem() const =0
return a string with the current additional problem (must be reimplemented in all detector children)
GNELane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
GNEDetector::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEDetector.cpp:134