Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/additional/GNEClosingReroute.cpp
193697 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2026 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 GNEClosingReroute.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Jan 2017
17
///
18
//
19
/****************************************************************************/
20
#include <config.h>
21
22
#include <netedit/changes/GNEChange_Attribute.h>
23
#include <netedit/GNENet.h>
24
25
#include "GNEClosingReroute.h"
26
27
// ===========================================================================
28
// member method definitions
29
// ===========================================================================
30
31
GNEClosingReroute::GNEClosingReroute(GNENet* net) :
32
GNEAdditional(net, SUMO_TAG_CLOSING_REROUTE),
33
GNEAdditionalListed(this) {
34
}
35
36
37
GNEClosingReroute::GNEClosingReroute(GNEAdditional* rerouterIntervalParent, GNEEdge* closedEdge, SVCPermissions permissions) :
38
GNEAdditional(rerouterIntervalParent, SUMO_TAG_CLOSING_REROUTE, ""),
39
GNEAdditionalListed(this),
40
myClosedEdge(closedEdge),
41
myPermissions(permissions) {
42
// set parents
43
setParent<GNEAdditional*>(rerouterIntervalParent);
44
setParent<GNEEdge*>(closedEdge);
45
// update boundary of rerouter parent
46
rerouterIntervalParent->getParentAdditionals().front()->updateCenteringBoundary(true);
47
}
48
49
50
GNEClosingReroute::~GNEClosingReroute() {}
51
52
53
GNEMoveElement*
54
GNEClosingReroute::getMoveElement() const {
55
return nullptr;
56
}
57
58
59
Parameterised*
60
GNEClosingReroute::getParameters() {
61
return nullptr;
62
}
63
64
65
const Parameterised*
66
GNEClosingReroute::getParameters() const {
67
return nullptr;
68
}
69
70
71
void
72
GNEClosingReroute::writeAdditional(OutputDevice& device) const {
73
device.openTag(SUMO_TAG_CLOSING_REROUTE);
74
// write common additional attributes
75
writeAdditionalAttributes(device);
76
// write specific attributes
77
device.writeAttr(SUMO_ATTR_ID, getAttribute(SUMO_ATTR_EDGE));
78
if (getAttribute(SUMO_ATTR_ALLOW) != getVehicleClassNames(SVCAll)) {
79
if (!getAttribute(SUMO_ATTR_ALLOW).empty()) {
80
device.writeAttr(SUMO_ATTR_ALLOW, getAttribute(SUMO_ATTR_ALLOW));
81
} else {
82
device.writeAttr(SUMO_ATTR_DISALLOW, getAttribute(SUMO_ATTR_DISALLOW));
83
}
84
}
85
device.closeTag();
86
}
87
88
89
bool
90
GNEClosingReroute::isAdditionalValid() const {
91
return true;
92
}
93
94
95
std::string
96
GNEClosingReroute::getAdditionalProblem() const {
97
return "";
98
}
99
100
101
void
102
GNEClosingReroute::fixAdditionalProblem() {
103
// nothing to fix
104
}
105
106
107
bool
108
GNEClosingReroute::checkDrawMoveContour() const {
109
return false;
110
}
111
112
113
void
114
GNEClosingReroute::updateGeometry() {
115
updateGeometryListedAdditional();
116
}
117
118
119
Position
120
GNEClosingReroute::getPositionInView() const {
121
return getListedPositionInView();
122
}
123
124
125
void
126
GNEClosingReroute::updateCenteringBoundary(const bool /*updateGrid*/) {
127
// nothing to update
128
}
129
130
131
void
132
GNEClosingReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
133
// geometry of this element cannot be splitted
134
}
135
136
137
std::string
138
GNEClosingReroute::getParentName() const {
139
return getParentAdditionals().at(0)->getID();
140
}
141
142
143
void
144
GNEClosingReroute::drawGL(const GUIVisualizationSettings& s) const {
145
// draw closing reroute as listed attribute
146
drawListedAdditional(s, RGBColor::RED, RGBColor::YELLOW, GUITexture::REROUTER_CLOSINGREROUTE,
147
getAttribute(SUMO_ATTR_EDGE));
148
}
149
150
151
std::string
152
GNEClosingReroute::getAttribute(SumoXMLAttr key) const {
153
switch (key) {
154
case SUMO_ATTR_ID:
155
return getMicrosimID();
156
case SUMO_ATTR_EDGE:
157
return myClosedEdge->getID();
158
case SUMO_ATTR_ALLOW:
159
return getVehicleClassNames(myPermissions);
160
case SUMO_ATTR_DISALLOW:
161
return getVehicleClassNames(invertPermissions(myPermissions));
162
case GNE_ATTR_PARENT:
163
return getParentAdditionals().at(0)->getID();
164
default:
165
return getCommonAttribute(key);
166
}
167
}
168
169
170
double
171
GNEClosingReroute::getAttributeDouble(SumoXMLAttr key) const {
172
return getCommonAttributeDouble(key);
173
}
174
175
176
Position
177
GNEClosingReroute::getAttributePosition(SumoXMLAttr key) const {
178
return getCommonAttributePosition(key);
179
}
180
181
182
PositionVector
183
GNEClosingReroute::getAttributePositionVector(SumoXMLAttr key) const {
184
return getCommonAttributePositionVector(key);
185
}
186
187
188
void
189
GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
190
if (value == getAttribute(key)) {
191
return; //avoid needless changes, later logic relies on the fact that attributes have changed
192
}
193
switch (key) {
194
case SUMO_ATTR_ID:
195
case SUMO_ATTR_EDGE:
196
case SUMO_ATTR_ALLOW:
197
case SUMO_ATTR_DISALLOW:
198
GNEChange_Attribute::changeAttribute(this, key, value, undoList);
199
break;
200
default:
201
setCommonAttribute(key, value, undoList);
202
break;
203
}
204
}
205
206
207
bool
208
GNEClosingReroute::isValid(SumoXMLAttr key, const std::string& value) {
209
switch (key) {
210
case SUMO_ATTR_ID:
211
return isValidAdditionalID(value);
212
case SUMO_ATTR_EDGE:
213
return (myNet->getAttributeCarriers()->retrieveEdge(value, false) != nullptr);
214
case SUMO_ATTR_ALLOW:
215
return canParseVehicleClasses(value);
216
case SUMO_ATTR_DISALLOW:
217
return canParseVehicleClasses(value);
218
default:
219
return isCommonAttributeValid(key, value);
220
}
221
}
222
223
224
std::string
225
GNEClosingReroute::getPopUpID() const {
226
return getTagStr();
227
}
228
229
230
std::string
231
GNEClosingReroute::getHierarchyName() const {
232
return getTagStr() + ": " + myClosedEdge->getID();
233
}
234
235
// ===========================================================================
236
// private
237
// ===========================================================================
238
239
void
240
GNEClosingReroute::setAttribute(SumoXMLAttr key, const std::string& value) {
241
switch (key) {
242
case SUMO_ATTR_ID:
243
// update microsimID
244
setAdditionalID(value);
245
break;
246
case SUMO_ATTR_EDGE:
247
myClosedEdge = myNet->getAttributeCarriers()->retrieveEdge(value);
248
break;
249
case SUMO_ATTR_ALLOW:
250
myPermissions = parseVehicleClasses(value);
251
break;
252
case SUMO_ATTR_DISALLOW:
253
myPermissions = invertPermissions(parseVehicleClasses(value));
254
break;
255
default:
256
setCommonAttribute(key, value);
257
break;
258
}
259
}
260
261
/****************************************************************************/
262
263