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
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
35 GNEDemandElement("", net, "", tag, GNEPathElement::Options::DEMAND_ELEMENT),
36 GNEDemandElementPlan(this, -1, -1) {
37}
38
39
40GNERide::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, GNEPathElement::Options::DEMAND_ELEMENT),
43 GNEDemandElementPlan(this, -1, arrivalPosition),
44 myLines(lines),
45 myGroup(group) {
46 // set parents
47 setParents<GNEJunction*>(planParameters.getJunctions());
48 setParents<GNEEdge*>(planParameters.getEdges());
50 setParents<GNEDemandElement*>(planParameters.getDemandElements(personParent));
51 // update centering boundary without updating grid
53}
54#ifdef _MSC_VER
55#pragma warning(pop)
56#endif
57
59
60
65
66
69 return nullptr;
70}
71
72
73const Parameterised*
75 return nullptr;
76}
77
78
81 return getPlanPopUpMenu(app, parent);
82}
83
84
85void
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);
92 // lines
93 if (myLines.size() > 0) {
95 }
96 // group
97 if (myGroup.size() > 0) {
99 }
100 device.closeTag();
101}
102
103
108
109
110std::string
114
115
116void
118 // currently the only solution is removing Ride
119}
120
121
124 return SVC_PEDESTRIAN;
125}
126
127
128const RGBColor&
130 return myNet->getViewNet()->getVisualisationSettings().colorSettings.rideColor;
131}
132
133
134void
138
139
144
145
146std::string
148 return getParentDemandElements().front()->getID();
149}
150
151
156
157
158void
159GNERide::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
160 // geometry of this element cannot be splitted
161}
162
163
164void
168
169
170void
174
175
176void
180
181
182void
186
187
188GNELane*
192
193
194GNELane*
198
199
200std::string
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
213double
217
218
223
224
225void
226GNERide::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
239bool
240GNERide::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
251bool
255
256
257std::string
259 return getTagStr();
260}
261
262
263std::string
267
268// ===========================================================================
269// private
270// ===========================================================================
271
272void
273GNERide::setAttribute(SumoXMLAttr key, const std::string& value) {
274 switch (key) {
275 case SUMO_ATTR_LINES:
277 break;
278 case SUMO_ATTR_GROUP:
279 myGroup = value;
280 break;
281 default:
283 break;
284 }
285}
286
287/****************************************************************************/
const std::string invalid_return< std::string >::value
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_GROUP
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition ToString.h:289
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
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
GNEDemandElement(const std::string &id, GNENet *net, const std::string &filename, SumoXMLTag tag, const GNEPathElement::Options pathOptions)
Constructor.
Problem
enum class for demandElement problems
friend class GNEDemandElementPlan
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
void setParents(const GNEHierarchicalContainerParents< ParentType > &parents)
set multiple parent element (ONLY use in constructors)
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEPathElement(const GNEPathElement::Options options)
constructor
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)
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const override
Draws partial object over junction.
Definition GNERide.cpp:183
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
Definition GNERide.cpp:226
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this ride
Definition GNERide.cpp:62
SUMOVehicleClass getVClass() const override
obtain VClass related with this demand element
Definition GNERide.cpp:123
std::string myGroup
group
Definition GNERide.h:217
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNERide.cpp:165
void fixDemandElementProblem() override
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition GNERide.cpp:117
Problem isDemandElementValid() const override
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
Definition GNERide.cpp:105
void writeDemandElement(OutputDevice &device) const override
write demand element element into a xml file
Definition GNERide.cpp:86
GNELane * getLastPathLane() const override
get last path lane
Definition GNERide.cpp:195
std::string getParentName() const override
Returns the name of the parent object.
Definition GNERide.cpp:147
GNERide(SumoXMLTag tag, GNENet *net)
default constructor
Definition GNERide.cpp:34
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const override
Draws partial object over lane.
Definition GNERide.cpp:177
~GNERide()
destructor
Definition GNERide.cpp:58
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNERide.cpp:264
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNERide.cpp:258
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNERide.cpp:214
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNERide.cpp:159
std::string getDemandElementProblem() const override
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition GNERide.cpp:111
std::vector< std::string > myLines
valid line or vehicle ids or ANY
Definition GNERide.h:214
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNERide.cpp:252
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNERide.cpp:153
std::string getAttribute(SumoXMLAttr key) const override
inherited from GNEAttributeCarrier
Definition GNERide.cpp:201
Position getPositionInView() const override
Returns position of additional in view.
Definition GNERide.cpp:141
GNELane * getFirstPathLane() const override
get first path lane
Definition GNERide.cpp:189
const RGBColor & getColor() const override
get color
Definition GNERide.cpp:129
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNERide.cpp:80
void computePathElement() override
compute pathElement
Definition GNERide.cpp:171
Parameterised * getParameters() override
get parameters associated with this ride
Definition GNERide.cpp:68
Position getAttributePosition(SumoXMLAttr key) const override
Definition GNERide.cpp:220
void updateGeometry() override
update pre-computed geometry information
Definition GNERide.cpp:135
bool isValid(SumoXMLAttr key, const std::string &value) override
Definition GNERide.cpp:240
The popup menu of a globject.
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
RGBColor selectedPersonPlanColor
person plan selection color (Rides, Walks, stopPersons...)