Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/demand/GNERide.cpp
185790 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 GNERide.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Jun 2019
17
///
18
// A class for visualizing rides in Netedit
19
/****************************************************************************/
20
21
#include <netedit/changes/GNEChange_Attribute.h>
22
#include <netedit/GNENet.h>
23
24
#include "GNERide.h"
25
26
27
// ===========================================================================
28
// method definitions
29
// ===========================================================================
30
#ifdef _MSC_VER
31
#pragma warning(push)
32
#pragma warning(disable: 4355) // mask warning about "this" in initializers
33
#endif
34
GNERide::GNERide(SumoXMLTag tag, GNENet* net) :
35
GNEDemandElement(net, tag),
36
GNEDemandElementPlan(this, -1, -1) {
37
}
38
39
40
GNERide::GNERide(SumoXMLTag tag, GNEDemandElement* personParent, const GNEPlanParents& planParameters,
41
const double arrivalPosition, const std::vector<std::string>& lines, const std::string& group) :
42
GNEDemandElement(personParent, tag),
43
GNEDemandElementPlan(this, -1, arrivalPosition),
44
myLines(lines),
45
myGroup(group) {
46
// set parents
47
setParents<GNEJunction*>(planParameters.getJunctions());
48
setParents<GNEEdge*>(planParameters.getEdges());
49
setParents<GNEAdditional*>(planParameters.getAdditionalElements());
50
setParents<GNEDemandElement*>(planParameters.getDemandElements(personParent));
51
// update centering boundary without updating grid
52
updatePlanCenteringBoundary(false);
53
}
54
#ifdef _MSC_VER
55
#pragma warning(pop)
56
#endif
57
58
GNERide::~GNERide() {}
59
60
61
GNEMoveElement*
62
GNERide::getMoveElement() const {
63
return myMoveElementPlan;
64
}
65
66
67
Parameterised*
68
GNERide::getParameters() {
69
return nullptr;
70
}
71
72
73
const Parameterised*
74
GNERide::getParameters() const {
75
return nullptr;
76
}
77
78
79
GUIGLObjectPopupMenu*
80
GNERide::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {
81
return getPlanPopUpMenu(app, parent);
82
}
83
84
85
void
86
GNERide::writeDemandElement(OutputDevice& device) const {
87
// first write origin stop (if this element starts in a stoppingPlace)
88
writeOriginStop(device);
89
// write rest of attributes
90
device.openTag(SUMO_TAG_RIDE);
91
writeLocationAttributes(device);
92
// lines
93
if (myLines.size() > 0) {
94
device.writeAttr(SUMO_ATTR_LINES, myLines);
95
}
96
// group
97
if (myGroup.size() > 0) {
98
device.writeAttr(SUMO_ATTR_GROUP, myGroup);
99
}
100
device.closeTag();
101
}
102
103
104
GNEDemandElement::Problem
105
GNERide::isDemandElementValid() const {
106
return isPlanPersonValid();
107
}
108
109
110
std::string
111
GNERide::getDemandElementProblem() const {
112
return getPersonPlanProblem();
113
}
114
115
116
void
117
GNERide::fixDemandElementProblem() {
118
// currently the only solution is removing Ride
119
}
120
121
122
SUMOVehicleClass
123
GNERide::getVClass() const {
124
return SVC_PEDESTRIAN;
125
}
126
127
128
const RGBColor&
129
GNERide::getColor() const {
130
return myNet->getViewNet()->getVisualisationSettings().colorSettings.rideColor;
131
}
132
133
134
void
135
GNERide::updateGeometry() {
136
updatePlanGeometry();
137
}
138
139
140
Position
141
GNERide::getPositionInView() const {
142
return getPlanPositionInView();
143
}
144
145
146
std::string
147
GNERide::getParentName() const {
148
return getParentDemandElements().front()->getID();
149
}
150
151
152
Boundary
153
GNERide::getCenteringBoundary() const {
154
return getPlanCenteringBoundary();
155
}
156
157
158
void
159
GNERide::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
160
// geometry of this element cannot be splitted
161
}
162
163
164
void
165
GNERide::drawGL(const GUIVisualizationSettings& s) const {
166
drawPlanGL(checkDrawPersonPlan(), s, s.colorSettings.rideColor, s.colorSettings.selectedPersonPlanColor);
167
}
168
169
170
void
171
GNERide::computePathElement() {
172
computePlanPathElement();
173
}
174
175
176
void
177
GNERide::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
178
drawPlanLanePartial(checkDrawPersonPlan(), s, segment, offsetFront, s.widthSettings.rideWidth, s.colorSettings.rideColor, s.colorSettings.selectedPersonPlanColor);
179
}
180
181
182
void
183
GNERide::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
184
drawPlanJunctionPartial(checkDrawPersonPlan(), s, segment, offsetFront, s.widthSettings.rideWidth, s.colorSettings.rideColor, s.colorSettings.selectedPersonPlanColor);
185
}
186
187
188
GNELane*
189
GNERide::getFirstPathLane() const {
190
return getFirstPlanPathLane();
191
}
192
193
194
GNELane*
195
GNERide::getLastPathLane() const {
196
return getLastPlanPathLane();
197
}
198
199
200
std::string
201
GNERide::getAttribute(SumoXMLAttr key) const {
202
switch (key) {
203
case SUMO_ATTR_LINES:
204
return joinToString(myLines, " ");
205
case SUMO_ATTR_GROUP:
206
return myGroup;
207
default:
208
return getPlanAttribute(key);
209
}
210
}
211
212
213
double
214
GNERide::getAttributeDouble(SumoXMLAttr key) const {
215
return getPlanAttributeDouble(key);
216
}
217
218
219
Position
220
GNERide::getAttributePosition(SumoXMLAttr key) const {
221
return getPlanAttributePosition(key);
222
}
223
224
225
void
226
GNERide::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
227
switch (key) {
228
case SUMO_ATTR_LINES:
229
case SUMO_ATTR_GROUP:
230
GNEChange_Attribute::changeAttribute(this, key, value, undoList);
231
break;
232
default:
233
setPlanAttribute(key, value, undoList);
234
break;
235
}
236
}
237
238
239
bool
240
GNERide::isValid(SumoXMLAttr key, const std::string& value) {
241
switch (key) {
242
case SUMO_ATTR_LINES:
243
case SUMO_ATTR_GROUP:
244
return true;
245
default:
246
return isPlanValid(key, value);
247
}
248
}
249
250
251
bool
252
GNERide::isAttributeEnabled(SumoXMLAttr key) const {
253
return isPlanAttributeEnabled(key);
254
}
255
256
257
std::string
258
GNERide::getPopUpID() const {
259
return getTagStr();
260
}
261
262
263
std::string
264
GNERide::getHierarchyName() const {
265
return getPlanHierarchyName();
266
}
267
268
// ===========================================================================
269
// private
270
// ===========================================================================
271
272
void
273
GNERide::setAttribute(SumoXMLAttr key, const std::string& value) {
274
switch (key) {
275
case SUMO_ATTR_LINES:
276
myLines = GNEAttributeCarrier::parse<std::vector<std::string> >(value);
277
break;
278
case SUMO_ATTR_GROUP:
279
myGroup = value;
280
break;
281
default:
282
setPlanAttribute(key, value);
283
break;
284
}
285
}
286
287
/****************************************************************************/
288
289