Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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
22#include <netedit/GNENet.h>
23
24#include "GNEPersonTrip.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
35 GNEDemandElement("", net, "", tag, GNEPathElement::Options::DEMAND_ELEMENT),
36 GNEDemandElementPlan(this, -1, -1) {
37}
38
39
41 const double arrivalPosition, const std::vector<std::string>& types, const std::vector<std::string>& modes,
42 const std::vector<std::string>& lines, const double walkFactor, const std::string& group) :
43 GNEDemandElement(personParent, tag, GNEPathElement::Options::DEMAND_ELEMENT),
44 GNEDemandElementPlan(this, -1, arrivalPosition),
45 myVTypes(types),
46 myModes(modes),
47 myLines(lines),
48 myWalkFactor(walkFactor),
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 nullptr;
74}
75
76
77const Parameterised*
79 return nullptr;
80}
81
82
87
88
89void
91 // first write origin stop (if this element starts in a stoppingPlace)
92 writeOriginStop(device);
93 // write rest of attributes
96 if (myModes.size() > 0) {
98 }
99 if (myLines.size() > 0) {
101 }
102 if (myVTypes.size() > 0) {
104 }
105 if (myWalkFactor > 0) {
107 }
108 if (myGroup.size() > 0) {
110 }
111 device.closeTag();
112}
113
114
119
120
121std::string
125
126
127void
129 // currently the only solution is removing PersonTrip
130}
131
132
135 return SVC_PEDESTRIAN;
136}
137
138
139const RGBColor&
143
144
145void
149
150
155
156
157std::string
159 return getParentDemandElements().front()->getID();
160}
161
162
167
168
169void
170GNEPersonTrip::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
171 // geometry of this element cannot be splitted
172}
173
174
175void
179
180
181void
185
186
187void
191
192
193void
197
198
199GNELane*
203
204
205GNELane*
209
210
211std::string
213 switch (key) {
214 // specific person plan attributes
215 case SUMO_ATTR_MODES:
216 return joinToString(myModes, " ");
217 case SUMO_ATTR_VTYPES:
218 return joinToString(myVTypes, " ");
219 case SUMO_ATTR_LINES:
220 return joinToString(myLines, " ");
222 return toString(myWalkFactor);
223 case SUMO_ATTR_GROUP:
224 return toString(myGroup);
225 default:
226 return getPlanAttribute(key);
227 }
228}
229
230
231double
233 switch (key) {
235 return myWalkFactor;
236 default:
237 return getPlanAttributeDouble(key);
238 }
239}
240
241
246
247
248void
249GNEPersonTrip::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
250 switch (key) {
251 case SUMO_ATTR_MODES:
252 case SUMO_ATTR_VTYPES:
253 case SUMO_ATTR_LINES:
255 case SUMO_ATTR_GROUP:
256 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
257 break;
258 default:
259 setPlanAttribute(key, value, undoList);
260 break;
261 }
262}
263
264
265bool
266GNEPersonTrip::isValid(SumoXMLAttr key, const std::string& value) {
267 switch (key) {
268 // specific person plan attributes
269 case SUMO_ATTR_MODES: {
270 SVCPermissions dummyModeSet;
271 std::string dummyError;
272 return SUMOVehicleParameter::parsePersonModes(value, myTagProperty->getTagStr(), "", dummyModeSet, dummyError);
273 }
274 case SUMO_ATTR_VTYPES:
275 case SUMO_ATTR_LINES:
276 return true;
278 return canParse<double>(value) && (parse<double>(value) >= 0);
279 case SUMO_ATTR_GROUP:
280 return true;
281 default:
282 return isPlanValid(key, value);
283 }
284}
285
286
287bool
291
292
293std::string
295 return getTagStr();
296}
297
298
299std::string
303
304// ===========================================================================
305// private
306// ===========================================================================
307
308void
309GNEPersonTrip::setAttribute(SumoXMLAttr key, const std::string& value) {
310 switch (key) {
311 // specific person plan attributes
312 case SUMO_ATTR_MODES:
313 myModes = GNEAttributeCarrier::parse<std::vector<std::string> >(value);
314 break;
315 case SUMO_ATTR_VTYPES:
316 myVTypes = GNEAttributeCarrier::parse<std::vector<std::string> >(value);
317 break;
318 case SUMO_ATTR_LINES:
319 myLines = GNEAttributeCarrier::parse<std::vector<std::string> >(value);
320 break;
322 myWalkFactor = parse<double>(value);
323 break;
324 case SUMO_ATTR_GROUP:
325 myGroup = value;
326 break;
327 default:
328 setPlanAttribute(key, value);
329 break;
330 }
331}
332
333/****************************************************************************/
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_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.
GNEMoveElementPlan * myMoveElementPlan
move element plan
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
double getPlanAttributeDouble(SumoXMLAttr key) const
get plan attribute double
void setPlanAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
set plan attribute
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
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this personTrip
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
bool isValid(SumoXMLAttr key, const std::string &value) override
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
GNELane * getLastPathLane() const
get last path lane
std::string getAttribute(SumoXMLAttr key) const override
inherited from GNEAttributeCarrier
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
Position getPositionInView() const
Returns position of additional in view.
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
bool isAttributeEnabled(SumoXMLAttr key) const
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
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
Position getAttributePosition(SumoXMLAttr key) const override
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double myWalkFactor
walk factor
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.
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
~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...
Parameterised * getParameters() override
get parameters associated with this personTrip
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
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 updateGeometry() override
update pre-computed geometry information
double getAttributeDouble(SumoXMLAttr key) const override
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...
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.
An upper class for objects with additional parameters.
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