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