Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/additional/GNECalibrator.h
169684 views
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
/****************************************************************************/
14
/// @file GNECalibrator.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Nov 2015
17
///
18
// Calibrator over edge or lane
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include "GNEAdditional.h"
24
25
// ===========================================================================
26
// class declaration
27
// ===========================================================================
28
29
class GNERouteProbe;
30
class GNECalibratorFlow;
31
class GNERoute;
32
33
// ===========================================================================
34
// class definitions
35
// ===========================================================================
36
37
class GNECalibrator : public GNEAdditional, public Parameterised {
38
39
public:
40
/// @brief Default constructor
41
GNECalibrator(SumoXMLTag tag, GNENet* net);
42
43
/**@brief Constructor using edge
44
* @param[in] id The storage of gl-ids to get the one for this lane representation from
45
* @param[in] net pointer to GNENet of this additional element belongs
46
* @param[in] filename file in which this element is stored
47
* @param[in] edge Edge of this calibrator belongs
48
* @param[in] pos position of the calibrator on the edge (Currently not used)
49
* @param[in] frequency the aggregation interval in which to calibrate the flows
50
* @param[in] name Calibrator name
51
* @param[in] output The output file for writing calibrator information
52
* @param[in] jamThreshold A threshold value to detect and clear unexpected jamming
53
* @param[in] vTypes space separated list of vehicle type ids to consider
54
* @param[in] parameters generic parameters
55
*/
56
GNECalibrator(const std::string& id, GNENet* net, const std::string& filename, GNEEdge* edge, double pos, SUMOTime frequency, const std::string& name,
57
const std::string& output, const double jamThreshold, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters);
58
59
/**@brief Constructor using edge and routeProbe
60
* @param[in] id The storage of gl-ids to get the one for this lane representation from
61
* @param[in] net pointer to GNENet of this additional element belongs
62
* @param[in] filename file in which this element is stored
63
* @param[in] edge Edge of this calibrator belongs
64
* @param[in] pos position of the calibrator on the edge (Currently not used)
65
* @param[in] frequency the aggregation interval in which to calibrate the flows
66
* @param[in] name Calibrator name
67
* @param[in] output The output file for writing calibrator information
68
* @param[in] routeProbe route probe vinculated with this calibrator
69
* @param[in] jamThreshold A threshold value to detect and clear unexpected jamming
70
* @param[in] vTypes space separated list of vehicle type ids to consider
71
* @param[in] parameters generic parameters
72
*/
73
GNECalibrator(const std::string& id, GNENet* net, const std::string& filename, GNEEdge* edge, double pos, SUMOTime frequency, const std::string& name,
74
const std::string& output, GNEAdditional* routeProbe, const double jamThreshold, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters);
75
76
/**@brief Constructor using lane
77
* @param[in] id The storage of gl-ids to get the one for this lane representation from
78
* @param[in] net pointer to GNENet of this additional element belongs
79
* @param[in] filename file in which this element is stored
80
* @param[in] lane Lane of this calibrator belongs
81
* @param[in] pos position of the calibrator on the edge (Currently not used)
82
* @param[in] frequency the aggregation interval in which to calibrate the flows
83
* @param[in] name Calibrator name
84
* @param[in] output The output file for writing calibrator information
85
* @param[in] jamThreshold A threshold value to detect and clear unexpected jamming
86
* @param[in] vTypes space separated list of vehicle type ids to consider
87
* @param[in] parameters generic parameters
88
*/
89
GNECalibrator(const std::string& id, GNENet* net, const std::string& filename, GNELane* lane, double pos, SUMOTime frequency, const std::string& name,
90
const std::string& output, const double jamThreshold, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters);
91
92
/**@brief Constructor using lane and routeProbe
93
* @param[in] id The storage of gl-ids to get the one for this lane representation from
94
* @param[in] net pointer to GNENet of this additional element belongs
95
* @param[in] filename file in which this element is stored
96
* @param[in] lane Lane of this calibrator belongs
97
* @param[in] pos position of the calibrator on the edge (Currently not used)
98
* @param[in] frequency the aggregation interval in which to calibrate the flows
99
* @param[in] name Calibrator name
100
* @param[in] routeProbe route probe vinculated with this calibrator
101
* @param[in] output The output file for writing calibrator information
102
* @param[in] jamThreshold A threshold value to detect and clear unexpected jamming
103
* @param[in] vTypes space separated list of vehicle type ids to consider
104
* @param[in] parameters generic parameters
105
*/
106
GNECalibrator(const std::string& id, GNENet* net, const std::string& filename, GNELane* lane, double pos, SUMOTime frequency, const std::string& name,
107
const std::string& output, GNEAdditional* routeProbe, const double jamThreshold, const std::vector<std::string>& vTypes, const Parameterised::Map& parameters);
108
109
/// @brief Destructor
110
~GNECalibrator();
111
112
/**@brief get move operation
113
* @note returned GNEMoveOperation can be nullptr
114
*/
115
GNEMoveOperation* getMoveOperation();
116
117
/// @name members and functions relative to write additionals into XML
118
/// @{
119
120
/**@brief write additional element into a xml file
121
* @param[in] device device in which write parameters of additional element
122
*/
123
void writeAdditional(OutputDevice& device) const;
124
125
/// @brief check if current additional is valid to be written into XML (must be reimplemented in all detector children)
126
bool isAdditionalValid() const;
127
128
/// @brief return a string with the current additional problem (must be reimplemented in all detector children)
129
std::string getAdditionalProblem() const;
130
131
/// @brief fix additional problem (must be reimplemented in all detector children)
132
void fixAdditionalProblem();
133
134
/// @}
135
136
/// @name Function related with contour drawing
137
/// @{
138
139
/// @brief check if draw move contour (red)
140
bool checkDrawMoveContour() const;
141
142
/// @}
143
144
/// @brief open Calibrator Dialog
145
void openAdditionalDialog();
146
147
/// @name Functions related with geometry of element
148
/// @{
149
150
/// @brief update pre-computed geometry information
151
void updateGeometry();
152
153
/// @brief Returns position of additional in view
154
Position getPositionInView() const;
155
156
/// @brief update centering boundary (implies change in RTREE)
157
void updateCenteringBoundary(const bool updateGrid);
158
159
/// @brief split geometry
160
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
161
162
/// @}
163
164
/// @name inherited from GUIGlObject
165
/// @{
166
167
/**@brief Returns the name of the parent object
168
* @return This object's parent id
169
*/
170
std::string getParentName() const;
171
172
/**@brief Draws the object
173
* @param[in] s The settings for the current view (may influence drawing)
174
* @see GUIGlObject::drawGL
175
*/
176
void drawGL(const GUIVisualizationSettings& s) const;
177
178
/// @}
179
180
/// @name inherited from GNEAttributeCarrier
181
/// @{
182
183
/* @brief method for getting the Attribute of an XML key
184
* @param[in] key The attribute key
185
* @return string with the value associated to key
186
*/
187
std::string getAttribute(SumoXMLAttr key) const;
188
189
/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
190
* @param[in] key The attribute key
191
* @return double with the value associated to key
192
*/
193
double getAttributeDouble(SumoXMLAttr key) const;
194
195
/// @brief get parameters map
196
const Parameterised::Map& getACParametersMap() const;
197
198
/* @brief method for setting the attribute and letting the object perform additional changes
199
* @param[in] key The attribute key
200
* @param[in] value The new value
201
* @param[in] undoList The undoList on which to register changes
202
*/
203
void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
204
205
/* @brief method for checking if the key and their correspond attribute are valids
206
* @param[in] key The attribute key
207
* @param[in] value The value associated to key key
208
* @return true if the value is valid, false in other case
209
*/
210
bool isValid(SumoXMLAttr key, const std::string& value);
211
212
/// @brief get PopPup ID (Used in AC Hierarchy)
213
std::string getPopUpID() const;
214
215
/// @brief get Hierarchy Name (Used in AC Hierarchy)
216
std::string getHierarchyName() const;
217
218
/// @}
219
220
protected:
221
/// @brief position over Lane
222
double myPositionOverLane = 0;
223
224
/// @brief Frequency of calibrator
225
SUMOTime myFrequency = 0;
226
227
/// @brief output of calibrator
228
std::string myOutput;
229
230
/// @brief jamThreshold
231
double myJamThreshold = 0;
232
233
/// @brief vTypes
234
std::vector<std::string> myVTypes;
235
236
/// @brief extra calibrator geometries
237
std::vector<GUIGeometry> myEdgeCalibratorGeometries;
238
239
/// @brief calibrator contours
240
std::vector<GNEContour*>* myCalibratorContours;
241
242
private:
243
/// @brief draw calibrator symbol
244
void drawCalibratorSymbol(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
245
const double exaggeration, const Position& pos, const double rot,
246
const int symbolIndex) const;
247
248
/// @brief set attribute after validation
249
void setAttribute(SumoXMLAttr key, const std::string& value);
250
251
/// @brief set move shape
252
void setMoveShape(const GNEMoveResult& moveResult);
253
254
/// @brief commit move shape
255
void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
256
257
/// @brief Invalidated copy constructor.
258
GNECalibrator(const GNECalibrator&) = delete;
259
260
/// @brief Invalidated assignment operator.
261
GNECalibrator& operator=(const GNECalibrator&) = delete;
262
};
263
264