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