Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNETransport.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 transports in Netedit
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
23
24#include "GNETransport.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
40GNETransport::GNETransport(SumoXMLTag tag, GNEDemandElement* containerParent, const GNEPlanParents& planParameters,
41 const double arrivalPosition, const std::vector<std::string>& lines, const std::string& group) :
42 GNEDemandElement(containerParent, 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());
49 setParents<GNEAdditional*>(planParameters.getAdditionalElements());
50 setParents<GNEDemandElement*>(planParameters.getDemandElements(containerParent));
51 // update centering boundary without updating grid
53}
54#ifdef _MSC_VER
55#pragma warning(pop)
56#endif
57
58
60
61
66
67
70 return nullptr;
71}
72
73
74const Parameterised*
76 return nullptr;
77}
78
79
84
85
86void
88 // first write origin stop (if this element starts in a stoppingPlace)
89 writeOriginStop(device);
90 // write rest of attributes
93 if (myLines.size() > 0) {
95 }
96 if (myGroup.size() > 0) {
98 }
99 device.closeTag();
100}
101
102
107
108
109std::string
113
114
115void
117 // currently the only solution is removing Transport
118}
119
120
123 return SVC_IGNORING;
124}
125
126
127const RGBColor&
131
132
133void
137
138
143
144
145std::string
147 return getParentDemandElements().front()->getID();
148}
149
150
155
156
157void
158GNETransport::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
159 // Nothing to do
160}
161
162
163void
167
168
169void
173
174
175void
179
180
181void
185
186
187GNELane*
191
192
193GNELane*
197
198
199std::string
201 switch (key) {
202 // specific person plan attributes
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
226GNETransport::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
240GNETransport::isValid(SumoXMLAttr key, const std::string& value) {
241 switch (key) {
242 // specific person plan attributes
243 case SUMO_ATTR_LINES:
244 return true;
245 case SUMO_ATTR_GROUP:
246 return true;
247 default:
248 return isPlanValid(key, value);
249 }
250}
251
252
253bool
257
258
259std::string
261 return getTagStr();
262}
263
264
265std::string
269
270// ===========================================================================
271// private
272// ===========================================================================
273
274void
275GNETransport::setAttribute(SumoXMLAttr key, const std::string& value) {
276 switch (key) {
277 // specific person plan attributes
278 case SUMO_ATTR_LINES:
279 myLines = GNEAttributeCarrier::parse<std::vector<std::string> >(value);
280 break;
281 case SUMO_ATTR_GROUP:
282 myGroup = value;
283 break;
284 default:
285 setPlanAttribute(key, value);
286 break;
287 }
288}
289
290/****************************************************************************/
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_TRANSPORT
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:283
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.
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
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
bool checkDrawContainerPlan() const
check if container plan can be drawn
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
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)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GNELane * getLastPathLane() const
get last path lane
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
double getAttributeDouble(SumoXMLAttr key) const override
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
void computePathElement()
compute pathElement
std::string myGroup
group
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
GNELane * getFirstPathLane() const
get first path lane
bool isValid(SumoXMLAttr key, const std::string &value) override
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
const RGBColor & getColor() const
get color
std::string getAttribute(SumoXMLAttr key) const override
inherited from GNEAttributeCarrier
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GNETransport(SumoXMLTag tag, GNENet *net)
default constructor
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
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
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
bool isAttributeEnabled(SumoXMLAttr key) const
std::vector< std::string > myLines
The list of lines that are assigned to this stop.
std::string getParentName() const
Returns the name of the parent object.
~GNETransport()
destructor
Parameterised * getParameters() override
get parameters associated with this transport
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this transport
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Position getAttributePosition(SumoXMLAttr key) const override
Position getPositionInView() const
Returns position of additional in view.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
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
RGBColor transportColor
color for transport
RGBColor selectedContainerPlanColor
container plan selection color (Rides, Walks, containerStops...)