Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNEPersonTrip.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 person trips in Netedit
19/****************************************************************************/
20
23#include <netedit/GNENet.h>
24#include <netedit/GNEUndoList.h>
25#include <netedit/GNEViewNet.h>
27
28#include "GNEPersonTrip.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
45 const double arrivalPosition, const std::vector<std::string>& types, const std::vector<std::string>& modes,
46 const std::vector<std::string>& lines, const double walkFactor, const std::string& group) :
47 GNEDemandElement(personParent, tag, GNEPathElement::Options::DEMAND_ELEMENT),
48 GNEDemandElementPlan(this, -1, arrivalPosition),
49 myVTypes(types),
50 myModes(modes),
51 myLines(lines),
52 myWalkFactor(walkFactor),
53 myGroup(group) {
54 // set parents
55 setParents<GNEJunction*>(planParameters.getJunctions());
56 setParents<GNEEdge*>(planParameters.getEdges());
57 setParents<GNEAdditional*>(planParameters.getAdditionalElements());
58 setParents<GNEDemandElement*>(planParameters.getDemandElements(personParent));
59 // update centering boundary without updating grid
61}
62#ifdef _MSC_VER
63#pragma warning(pop)
64#endif
65
67
68
73
74
79
80
81void
83 // first write origin stop (if this element starts in a stoppingPlace)
84 writeOriginStop(device);
85 // write rest of attributes
88 if (myModes.size() > 0) {
90 }
91 if (myLines.size() > 0) {
93 }
94 if (myVTypes.size() > 0) {
96 }
97 if (myWalkFactor > 0) {
99 }
100 if (myGroup.size() > 0) {
102 }
103 device.closeTag();
104}
105
106
111
112
113std::string
117
118
119void
121 // currently the only solution is removing PersonTrip
122}
123
124
127 return SVC_PEDESTRIAN;
128}
129
130
131const RGBColor&
135
136
137void
141
142
147
148
149std::string
151 return getParentDemandElements().front()->getID();
152}
153
154
159
160
161void
162GNEPersonTrip::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
163 // geometry of this element cannot be splitted
164}
165
166
167void
171
172
173void
177
178
179void
183
184
185void
189
190
191GNELane*
195
196
197GNELane*
201
202
203std::string
205 switch (key) {
206 // specific person plan attributes
207 case SUMO_ATTR_MODES:
208 return joinToString(myModes, " ");
209 case SUMO_ATTR_VTYPES:
210 return joinToString(myVTypes, " ");
211 case SUMO_ATTR_LINES:
212 return joinToString(myLines, " ");
214 return toString(myWalkFactor);
215 case SUMO_ATTR_GROUP:
216 return toString(myGroup);
217 default:
218 return getPlanAttribute(key);
219 }
220}
221
222
223double
225 switch (key) {
227 return myWalkFactor;
228 default:
229 return getPlanAttributeDouble(key);
230 }
231}
232
233
238
239
240void
241GNEPersonTrip::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
242 switch (key) {
243 case SUMO_ATTR_MODES:
244 case SUMO_ATTR_VTYPES:
245 case SUMO_ATTR_LINES:
247 case SUMO_ATTR_GROUP:
248 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
249 break;
250 default:
251 setPlanAttribute(key, value, undoList);
252 break;
253 }
254}
255
256
257bool
258GNEPersonTrip::isValid(SumoXMLAttr key, const std::string& value) {
259 switch (key) {
260 // specific person plan attributes
261 case SUMO_ATTR_MODES: {
262 SVCPermissions dummyModeSet;
263 std::string dummyError;
264 return SUMOVehicleParameter::parsePersonModes(value, myTagProperty->getTagStr(), "", dummyModeSet, dummyError);
265 }
266 case SUMO_ATTR_VTYPES:
267 case SUMO_ATTR_LINES:
268 return true;
270 return canParse<double>(value) && (parse<double>(value) >= 0);
271 case SUMO_ATTR_GROUP:
272 return true;
273 default:
274 return isPlanValid(key, value);
275 }
276}
277
278
279bool
283
284
285std::string
287 return getTagStr();
288}
289
290
291std::string
295
296
301
302// ===========================================================================
303// private
304// ===========================================================================
305
306void
307GNEPersonTrip::setAttribute(SumoXMLAttr key, const std::string& value) {
308 switch (key) {
309 // specific person plan attributes
310 case SUMO_ATTR_MODES:
311 myModes = GNEAttributeCarrier::parse<std::vector<std::string> >(value);
312 break;
313 case SUMO_ATTR_VTYPES:
314 myVTypes = GNEAttributeCarrier::parse<std::vector<std::string> >(value);
315 break;
316 case SUMO_ATTR_LINES:
317 myLines = GNEAttributeCarrier::parse<std::vector<std::string> >(value);
318 break;
320 myWalkFactor = parse<double>(value);
321 break;
322 case SUMO_ATTR_GROUP:
323 myGroup = value;
324 break;
325 default:
326 setPlanAttribute(key, value);
327 break;
328 }
329}
330
331
332void
334 // change both position
335 myArrivalPosition = moveResult.newFirstPos;
336 // update geometry
338}
339
340
341void
343 undoList->begin(this, "arrivalPos of " + getTagStr());
344 // now adjust start position
346 undoList->end();
347}
348
349/****************************************************************************/
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
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_PERSONTRIP
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LINES
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_MODES
@ SUMO_ATTR_VTYPES
@ SUMO_ATTR_GROUP
@ SUMO_ATTR_WALKFACTOR
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
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
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
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2194
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
GNELane * getLastPathLane() const
get last path lane
GNEMoveOperation * getMoveOperation()
get move operation
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
Position getPositionInView() const
Returns position of additional in view.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
bool isAttributeEnabled(SumoXMLAttr key) const
void updateGeometry()
update pre-computed geometry information
std::vector< std::string > myModes
valid line or modes
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
std::string myGroup
group
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Position getAttributePosition(SumoXMLAttr key) const
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
double myWalkFactor
walk factor
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
const RGBColor & getColor() const
get color
std::vector< std::string > myVTypes
valid line or vehicle types
std::string getParentName() const
Returns the name of the parent object.
double getAttributeDouble(SumoXMLAttr key) const
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
~GNEPersonTrip()
destructor
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
const Parameterised::Map & getACParametersMap() const
get parameters map
GNEPersonTrip(SumoXMLTag tag, GNENet *net)
default constructor
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
std::vector< std::string > myLines
valid line or vehicle ids or ANY
void computePathElement()
compute pathElement
GNELane * getFirstPathLane() const
get first path lane
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)
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
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
static bool parsePersonModes(const std::string &modes, const std::string &element, const std::string &id, SVCPermissions &modeSet, std::string &error)
Validates a given person modes value.
RGBColor selectedPersonPlanColor
person plan selection color (Rides, Walks, stopPersons...)
RGBColor personTripColor
color for stopPersons
double personTripWidth
width for person trips