Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNERide.cpp
Go to the documentation of this file.
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/****************************************************************************/
18// A class for visualizing rides in Netedit
19/****************************************************************************/
20
23#include <netedit/GNENet.h>
24#include <netedit/GNEUndoList.h>
25#include <netedit/GNEViewNet.h>
27
28#include "GNERide.h"
29
30
31// ===========================================================================
32// method definitions
33// ===========================================================================
34#ifdef _MSC_VER
35#pragma warning(push)
36#pragma warning(disable: 4355) // mask warning about "this" in initializers
37#endif
39 GNEDemandElement("", net, "", tag, GNEPathElement::Options::DEMAND_ELEMENT),
40 GNEDemandElementPlan(this, -1, -1) {
41}
42
43
44GNERide::GNERide(SumoXMLTag tag, GNEDemandElement* personParent, const GNEPlanParents& planParameters,
45 const double arrivalPosition, const std::vector<std::string>& lines, const std::string& group) :
46 GNEDemandElement(personParent, tag, GNEPathElement::Options::DEMAND_ELEMENT),
47 GNEDemandElementPlan(this, -1, arrivalPosition),
48 myLines(lines),
49 myGroup(group) {
50 // set parents
51 setParents<GNEJunction*>(planParameters.getJunctions());
52 setParents<GNEEdge*>(planParameters.getEdges());
53 setParents<GNEAdditional*>(planParameters.getAdditionalElements());
54 setParents<GNEDemandElement*>(planParameters.getDemandElements(personParent));
55 // update centering boundary without updating grid
57}
58#ifdef _MSC_VER
59#pragma warning(pop)
60#endif
61
63
64
69
70
73 return getPlanPopUpMenu(app, parent);
74}
75
76
77void
79 // first write origin stop (if this element starts in a stoppingPlace)
80 writeOriginStop(device);
81 // write rest of attributes
82 device.openTag(SUMO_TAG_RIDE);
84 // lines
85 if (myLines.size() > 0) {
87 }
88 // group
89 if (myGroup.size() > 0) {
91 }
92 device.closeTag();
93}
94
95
100
101
102std::string
106
107
108void
110 // currently the only solution is removing Ride
111}
112
113
116 return SVC_PEDESTRIAN;
117}
118
119
120const RGBColor&
124
125
126void
130
131
136
137
138std::string
140 return getParentDemandElements().front()->getID();
141}
142
143
148
149
150void
151GNERide::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
152 // geometry of this element cannot be splitted
153}
154
155
156void
160
161
162void
166
167
168void
172
173
174void
178
179
180GNELane*
184
185
186GNELane*
190
191
192std::string
194 switch (key) {
195 case SUMO_ATTR_LINES:
196 return joinToString(myLines, " ");
197 case SUMO_ATTR_GROUP:
198 return myGroup;
199 default:
200 return getPlanAttribute(key);
201 }
202}
203
204
205double
209
210
215
216
217void
218GNERide::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
219 switch (key) {
220 case SUMO_ATTR_LINES:
221 case SUMO_ATTR_GROUP:
222 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
223 break;
224 default:
225 setPlanAttribute(key, value, undoList);
226 break;
227 }
228}
229
230
231bool
232GNERide::isValid(SumoXMLAttr key, const std::string& value) {
233 switch (key) {
234 case SUMO_ATTR_LINES:
235 case SUMO_ATTR_GROUP:
236 return true;
237 default:
238 return isPlanValid(key, value);
239 }
240}
241
242
243bool
247
248
249std::string
251 return getTagStr();
252}
253
254
255std::string
259
260
265
266// ===========================================================================
267// private
268// ===========================================================================
269
270void
271GNERide::setAttribute(SumoXMLAttr key, const std::string& value) {
272 switch (key) {
273 case SUMO_ATTR_LINES:
274 myLines = GNEAttributeCarrier::parse<std::vector<std::string> >(value);
275 break;
276 case SUMO_ATTR_GROUP:
277 myGroup = value;
278 break;
279 default:
280 setPlanAttribute(key, value);
281 break;
282 }
283}
284
285
286void
288 // change both position
289 myArrivalPosition = moveResult.newLastPos;
290 // update geometry
292}
293
294
295void
297 undoList->begin(this, "arrivalPos of " + getTagStr());
298 // now adjust start position
300 undoList->end();
301}
302
303/****************************************************************************/
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_PEDESTRIAN
pedestrian
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_RIDE
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LINES
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_GROUP
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition ToString.h:283
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
const std::string & getTagStr() const
get tag assigned to this object in string format
GNENet * myNet
pointer to net
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
Problem
enum class for demandElement problems
bool isPlanValid(SumoXMLAttr key, const std::string &value)
check if plan attribute is valid
Boundary getPlanCenteringBoundary() const
get plan centering boundary
Position getPlanPositionInView() const
Returns position of additional in view.
std::string getPersonPlanProblem() const
get plan problem
void computePlanPathElement()
compute plan pathElement
Position getPlanAttributePosition(SumoXMLAttr key) const
get plan attribute position
GNEDemandElement::Problem isPlanPersonValid() const
check if plan is valid
GUIGLObjectPopupMenu * getPlanPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
std::string getPlanHierarchyName() const
get plan Hierarchy Name (Used in AC Hierarchy)
void writeLocationAttributes(OutputDevice &device) const
write plan element common attributes
bool checkDrawPersonPlan() const
check if person plan can be drawn
GNEMoveOperation * getPlanMoveOperation()
get move operation
double getPlanAttributeDouble(SumoXMLAttr key) const
get plan attribute double
void setPlanAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
set plan attribute
double myArrivalPosition
arrival position (used in all plans over edges)
std::string getPlanAttribute(SumoXMLAttr key) const
get plan attribute string
bool isPlanAttributeEnabled(SumoXMLAttr key) const
check if plan attribute is enabled
GNELane * getLastPlanPathLane() const
get last plan path lane
void updatePlanCenteringBoundary(const bool updateGrid)
update plan centering boundary
void drawPlanGL(const bool drawPlan, const GUIVisualizationSettings &s, const RGBColor &planColor, const RGBColor &planSelectedColor) const
draw plan
void updatePlanGeometry()
update pre-computed geometry information
GNELane * getFirstPlanPathLane() const
get first plan path lane
void drawPlanLanePartial(const bool drawPlan, const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront, const double planWidth, const RGBColor &planColor, const RGBColor &planSelectedColor) const
draw plan partial lane
void drawPlanJunctionPartial(const bool drawPlan, const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront, const double planWidth, const RGBColor &planColor, const RGBColor &planSelectedColor) const
draw plan partial junction
void writeOriginStop(OutputDevice &device) const
write initial stop stage if plan starts at a stopping place
const GNEHierarchicalContainerParents< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
move operation
move result
double newFirstPos
new first position
double newLastPos
new last position
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2195
GNEPlanParents (used for group all plan parents)
std::vector< GNEDemandElement * > getDemandElements(GNEDemandElement *parent) const
get demand elements (used in plan constructors)
std::vector< GNEAdditional * > getAdditionalElements() const
get additionalElements (used in plan constructors)
std::vector< GNEEdge * > getEdges() const
get edges (used in plan constructors)
std::vector< GNEJunction * > getJunctions() const
get junctions (used in plan constructors)
std::string myGroup
group
Definition GNERide.h:211
double getAttributeDouble(SumoXMLAttr key) const
Definition GNERide.cpp:206
Position getPositionInView() const
Returns position of additional in view.
Definition GNERide.cpp:133
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition GNERide.cpp:109
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition GNERide.cpp:151
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition GNERide.cpp:115
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition GNERide.cpp:103
GNERide(SumoXMLTag tag, GNENet *net)
default constructor
Definition GNERide.cpp:38
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition GNERide.cpp:250
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNERide.cpp:145
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition GNERide.cpp:296
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition GNERide.cpp:157
std::string getParentName() const
Returns the name of the parent object.
Definition GNERide.cpp:139
~GNERide()
destructor
Definition GNERide.cpp:62
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
Definition GNERide.cpp:169
GNEMoveOperation * getMoveOperation()
get move operation
Definition GNERide.cpp:66
void updateGeometry()
update pre-computed geometry information
Definition GNERide.cpp:127
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
Definition GNERide.cpp:97
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition GNERide.cpp:72
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition GNERide.cpp:232
const RGBColor & getColor() const
get color
Definition GNERide.cpp:121
Position getAttributePosition(SumoXMLAttr key) const
Definition GNERide.cpp:212
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition GNERide.cpp:262
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
Definition GNERide.cpp:175
std::vector< std::string > myLines
valid line or vehicle ids or ANY
Definition GNERide.h:208
GNELane * getLastPathLane() const
get last path lane
Definition GNERide.cpp:187
bool isAttributeEnabled(SumoXMLAttr key) const
Definition GNERide.cpp:244
void computePathElement()
compute pathElement
Definition GNERide.cpp:163
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
Definition GNERide.cpp:218
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition GNERide.cpp:193
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition GNERide.cpp:287
GNELane * getFirstPathLane() const
get first path lane
Definition GNERide.cpp:181
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition GNERide.cpp:256
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
Definition GNERide.cpp:78
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
The popup menu of a globject.
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
Stores the information about how to visualize structures.
GUIVisualizationWidthSettings widthSettings
width settings
GUIVisualizationColorSettings colorSettings
color settings
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
std::map< std::string, std::string > Map
parameters map
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
RGBColor selectedPersonPlanColor
person plan selection color (Rides, Walks, stopPersons...)