Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-2025 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
23#include "GNEAdditional.h"
24
25// ===========================================================================
26// class definitions
27// ===========================================================================
28
29class GNEDetector : public GNEAdditional, public Parameterised {
30
31public:
36 GNEDetector(GNENet* net, SumoXMLTag tag);
37
54 GNEDetector(const std::string& id, GNENet* net, const std::string& filename, SumoXMLTag tag,
55 const double pos, const SUMOTime period, GNELane* lane, const std::string& outputFilename,
56 const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges,
57 const std::string& detectPersons, const std::string& name, const bool friendlyPos,
58 const Parameterised::Map& parameters);
59
76 GNEDetector(const std::string& id, GNENet* net, const std::string& filename, SumoXMLTag tag, const double pos,
77 const SUMOTime period, const std::vector<GNELane*>& lanes, const std::string& outputFilename,
78 const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges,
79 const std::string& detectPersons, const std::string& name, const bool friendlyPos,
80 const Parameterised::Map& parameters);
81
93 GNEDetector(GNEAdditional* additionalParent, SumoXMLTag tag, const double pos, const SUMOTime period, GNELane* lane,
94 const std::string& outputFilename, const std::string& name, const bool friendlyPos, const Parameterised::Map& parameters);
95
98
103
106
110 virtual void writeAdditional(OutputDevice& device) const = 0;
111
113 virtual bool isAdditionalValid() const = 0;
114
116 virtual std::string getAdditionalProblem() const = 0;
117
119 virtual void fixAdditionalProblem() = 0;
120
122
125
127 bool checkDrawMoveContour() const;
128
130
132 GNELane* getLane() const;
133
135 double getPositionOverLane() const;
136
138 double getGeometryPositionOverLane() const;
139
142
144 virtual void updateGeometry() = 0;
145
148
150 void updateCenteringBoundary(const bool updateGrid);
151
153 void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
154
156
159
163 std::string getParentName() const;
164
169 virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
170
172
175
176 /* @brief method for getting the Attribute of an XML key
177 * @param[in] key The attribute key
178 * @return string with the value associated to key
179 */
180 virtual std::string getAttribute(SumoXMLAttr key) const = 0;
181
182 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
183 * @param[in] key The attribute key
184 * @return double with the value associated to key
185 */
186 virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
187
190
191 /* @brief method for setting the attribute and letting the object perform additional changes
192 * @param[in] key The attribute key
193 * @param[in] value The new value
194 * @param[in] undoList The undoList on which to register changes
195 */
196 virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
197
198 /* @brief method for checking if the key and their conrrespond attribute are valids
199 * @param[in] key The attribute key
200 * @param[in] value The value associated to key key
201 * @return true if the value is valid, false in other case
202 */
203 virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
204
206 std::string getPopUpID() const;
207
209 std::string getHierarchyName() const;
210
212
213protected:
216
219
221 std::string myOutputFilename;
222
224 std::vector<std::string> myVehicleTypes;
225
227 std::vector<std::string> myNextEdges;
228
230 std::string myDetectPersons;
231
233 bool myFriendlyPosition = false;
234
235 /* @brief method for getting the Attribute of an XML key
236 * @param[in] key The attribute key
237 * @return string with the value associated to key
238 */
239 std::string getDetectorAttribute(SumoXMLAttr key) const;
240
241 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
242 * @param[in] key The attribute key
243 * @return double with the value associated to key
244 */
245 double getDetectorAttributeDouble(SumoXMLAttr key) const;
246
247 /* @brief method for setting the attribute and letting the object perform additional changes
248 * @param[in] key The attribute key
249 * @param[in] value The new value
250 * @param[in] undoList The undoList on which to register changes
251 */
252 void setDetectorAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
253
254 /* @brief method for checking if the key and their conrrespond attribute are valids
255 * @param[in] key The attribute key
256 * @param[in] value The value associated to key key
257 * @return true if the value is valid, false in other case
258 */
259 bool isDetectorValid(SumoXMLAttr key, const std::string& value);
260
264 void writeDetectorValues(OutputDevice& device) const;
265
267 void setDetectorAttribute(SumoXMLAttr key, const std::string& value);
268
270 void drawE1Shape(const GUIVisualizationSettings::Detail d, const double exaggeration,
271 const RGBColor& mainColor, const RGBColor& secondColor) const;
272
275 const double exaggeration, const std::string& logo, const RGBColor& textColor) const;
276
279 const double exaggeration, const std::string& logo, const RGBColor& textColor) const;
280
281private:
283 virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
284
286 virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
287
289 virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
290
292 const Position& getPosition() const = delete;
293
295 void setPosition(const Position& pos) = delete;
296};
long long int SUMOTime
Definition GUI.h:36
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
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.
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
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
Position getPositionInView() const
Returns position of additional in view.
std::string myOutputFilename
The path to the output file.
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
~GNEDetector()
Destructor.
bool isDetectorValid(SumoXMLAttr key, const std::string &value)
double getPositionOverLane() const
get position over lane
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
GNEMoveOperation * getMoveOperation()
get move operation
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)
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.
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
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
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes
const Position & getPosition() const =delete
Invalidate return position of additional.
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.
An upper class for objects with additional parameters.
std::map< std::string, std::string > Map
parameters map
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37