Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEBusStop.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-2026 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 lane area vehicles can halt at (GNE version)
19/****************************************************************************/
20#include <config.h>
21
24#include <netedit/GNENet.h>
28
29#include "GNEBusStop.h"
30
31// ===========================================================================
32// method definitions
33// ===========================================================================
34
39
40
45
46
48GNEBusStop::buildBusStop(const std::string& id, GNENet* net, FileBucket* fileBucket, GNELane* lane,
49 const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines,
50 const int personCapacity, const double parkingLength, const RGBColor& color, const bool friendlyPosition,
51 const double angle, const Parameterised::Map& parameters) {
52 return new GNEBusStop(SUMO_TAG_BUS_STOP, id, net, fileBucket, lane, startPos, endPos, name, lines,
53 personCapacity, parkingLength, color, friendlyPosition, angle, parameters);
54}
55
56
58GNEBusStop::buildTrainStop(const std::string& id, GNENet* net, FileBucket* fileBucket, GNELane* lane,
59 const double startPos, const double endPos, const std::string& name, const std::vector<std::string>& lines,
60 const int personCapacity, const double parkingLength, const RGBColor& color, const bool friendlyPosition,
61 const double angle, const Parameterised::Map& parameters) {
62 return new GNEBusStop(SUMO_TAG_TRAIN_STOP, id, net, fileBucket, lane, startPos, endPos, name, lines,
63 personCapacity, parkingLength, color, friendlyPosition, angle, parameters);
64}
65
66
68
69
70void
72 device.openTag(getTagProperty()->getTag());
73 // write common attributes
75 // write specific attributes
78 }
81 }
84 }
85 // write all access
86 for (const auto& access : getChildAdditionals()) {
87 access->writeAdditional(device);
88 }
89 // write parameters (Always after children to avoid problems with additionals.xsd)
90 XMLHelpers::writeParams(device, *this);
91 device.closeTag();
92}
93
94
95void
97 // Get value of option "lefthand"
98 double offsetSign = OptionsCont::getOptions().getBool("lefthand") ? -1 : 1;
99 // Update common geometry of stopping place
100 setStoppingPlaceGeometry(getParentLanes().front()->getParentEdge()->getNBEdge()->getLaneWidth(getParentLanes().front()->getIndex()) * 0.5);
101 // Obtain a copy of the shape
103 // Move shape to side
105 // Get position of the sign
106 mySymbolPosition = tmpShape.getLineCenter();
107 // update demand element children
108 for (const auto& demandElement : getChildDemandElements()) {
109 demandElement->updateGeometry();
110 }
111}
112
113
114void
116 // check if additional has to be drawn
118 // Obtain exaggeration of the draw
119 const double busStopExaggeration = getExaggeration(s);
120 // check if draw moving geometry points
121 const bool movingGeometryPoints = drawMovingGeometryPoints();
122 // get width
124 // get detail level
125 const auto d = s.getDetailLevel(busStopExaggeration);
126 // draw geometry only if we'rent in drawForObjectUnderCursor mode
128 // declare colors
129 RGBColor baseColor, signColor;
130 // set colors
131 if (mySpecialColor) {
132 baseColor = *mySpecialColor;
133 signColor = baseColor.changedBrightness(-32);
134 } else if (drawUsingSelectColor()) {
136 signColor = baseColor.changedBrightness(-32);
137 } else if (myColor != RGBColor::INVISIBLE) {
138 baseColor = myColor;
139 signColor = s.colorSettings.busStopColorSign;
140 } else if (myTagProperty->getTag() == SUMO_TAG_TRAIN_STOP) {
141 baseColor = s.colorSettings.trainStopColor;
142 signColor = s.colorSettings.trainStopColorSign;
143 } else {
144 baseColor = s.colorSettings.busStopColor;
145 signColor = s.colorSettings.busStopColorSign;
146 }
147 // draw parent and child lines
148 drawParentChildLines(s, baseColor);
149 // Add layer matrix
151 // translate to front
153 // set base color
154 GLHelper::setColor(baseColor);
155 // Draw the area using shape, shapeRotations, shapeLengths and value of exaggeration
156 GUIGeometry::drawGeometry(d, myAdditionalGeometry, stopWidth * MIN2(1.0, busStopExaggeration));
157 // draw lines
158 drawLines(d, myLines, baseColor);
159 // draw sign
160 drawSign(s, d, busStopExaggeration, baseColor, signColor, (myTagProperty->getTag() == SUMO_TAG_BUS_STOP) ? "H" : "T");
161 // draw geometry points
162 if (movingGeometryPoints && (myStartPosOverLane != INVALID_DOUBLE)) {
164 }
165 if (movingGeometryPoints && (myEndPosPosOverLane != INVALID_DOUBLE)) {
167 }
168 // pop layer matrix
170 // draw lock icon
173 } else {
175 }
176 // Draw additional ID
178 // draw additional name
180 // draw dotted contours
181 if (movingGeometryPoints) {
184 } else {
187 }
188 }
189 // draw demand element children
191 // calculate contours
192 calculateStoppingPlaceContour(s, d, stopWidth, busStopExaggeration, movingGeometryPoints);
193 }
194}
195
196
197std::string
199 switch (key) {
200 case SUMO_ATTR_LINES:
201 return joinToString(myLines, " ");
206 default:
207 return getStoppingPlaceAttribute(key);
208 }
209}
210
211
212double
216
217
218void
219GNEBusStop::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
220 switch (key) {
221 case SUMO_ATTR_LINES:
224 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
225 break;
226 default:
227 setStoppingPlaceAttribute(key, value, undoList);
228 break;
229 }
230}
231
232
233bool
234GNEBusStop::isValid(SumoXMLAttr key, const std::string& value) {
235 switch (key) {
236 case SUMO_ATTR_LINES:
237 return true;
239 return canParse<int>(value) && (parse<int>(value) > 0 || parse<int>(value) == -1);
241 return canParse<double>(value) && (parse<double>(value) >= 0);
242 default:
243 return isStoppingPlaceValid(key, value);
244 }
245}
246
247// ===========================================================================
248// private
249// ===========================================================================
250
251void
252GNEBusStop::setAttribute(SumoXMLAttr key, const std::string& value) {
253 switch (key) {
254 case SUMO_ATTR_LINES:
255 myLines = GNEAttributeCarrier::parse<std::vector<std::string> >(value);
256 break;
258 myPersonCapacity = GNEAttributeCarrier::parse<int>(value);
259 break;
261 myParkingLength = GNEAttributeCarrier::parse<double>(value);
262 break;
263 default:
264 setStoppingPlaceAttribute(key, value);
265 break;
266 }
267}
268
269
273
274
275GNEBusStop::GNEBusStop(SumoXMLTag tag, const std::string& id, GNENet* net, FileBucket* fileBucket,
276 GNELane* lane, const double startPos, const double endPos, const std::string& name,
277 const std::vector<std::string>& lines, const int personCapacity, const double parkingLength,
278 const RGBColor& color, const bool friendlyPosition, const double angle,
279 const Parameterised::Map& parameters) :
280 GNEStoppingPlace(id, net, fileBucket, tag, lane, startPos, endPos, name, friendlyPosition, color, angle, parameters),
281 myLines(lines),
282 myPersonCapacity(personCapacity),
283 myParkingLength(parkingLength) {
284}
285
286/****************************************************************************/
@ GLO_BUS_STOP
a busStop
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LINES
@ SUMO_ATTR_PARKING_LENGTH
@ SUMO_ATTR_PERSON_CAPACITY
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:68
T MIN2(T a, T b)
Definition StdDefs.h:80
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition ToString.h:322
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:57
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
void drawRightGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw right geometry point
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
void drawDemandElementChildren(const GUIVisualizationSettings &s) const
draw demand element children
const RGBColor * mySpecialColor
pointer to special color (used for drawing Additional with a certain color, mainly used for selection...
void drawLeftGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw left geometry point
void drawParentChildLines(const GUIVisualizationSettings &s, const RGBColor &color, const bool onlySymbols=false) const
draw parent and child lines
bool drawMovingGeometryPoints() const
check if draw moving geometry points
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * myNet
pointer to net
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
double getAttributeDouble(SumoXMLAttr key) const override
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
static GNEBusStop * buildTrainStop(GNENet *net)
default constructor
std::string getAttribute(SumoXMLAttr key) const override
GNEBusStop(SumoXMLTag tag, GNENet *net)
default constructor
double myParkingLength
custom space for vehicles that park at this stop
Definition GNEBusStop.h:145
bool isValid(SumoXMLAttr key, const std::string &value) override
void updateGeometry() override
update pre-computed geometry information
std::vector< std::string > myLines
The list of lines that are assigned to this stop.
Definition GNEBusStop.h:139
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
~GNEBusStop()
Destructor.
static GNEBusStop * buildBusStop(GNENet *net)
default constructor
int myPersonCapacity
maximum number of persons that can wait at this stop
Definition GNEBusStop.h:142
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void drawDottedContourGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const PositionVector &shape, const double radius, const double scale, const double lineWidth) const
draw dotted contour for geometry points
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
const GNEHierarchicalContainerChildren< GNEAdditional * > & getChildAdditionals() const
return child additionals
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
GNEViewNet * getViewNet() const
get view net (used for simplify code)
Definition GNENet.cpp:144
bool isStoppingPlaceValid(SumoXMLAttr key, const std::string &value) const
void setStoppingPlaceAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
double myEndPosPosOverLane
The end position over lane.
void writeStoppingPlaceAttributes(OutputDevice &device) const
write common stoppingPlace attributes
void drawSign(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration, const RGBColor &baseColor, const RGBColor &signColor, const std::string &word) const
draw sign
double getStoppingPlaceAttributeDouble(SumoXMLAttr key) const
RGBColor myColor
RGB color.
void calculateStoppingPlaceContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double width, const double exaggeration, const bool movingGeometryPoints) const
check object in view
void drawLines(const GUIVisualizationSettings::Detail d, const std::vector< std::string > &lines, const RGBColor &color) const
draw lines
Position mySymbolPosition
The position of the sign.
double myStartPosOverLane
The start position over lane.
void setStoppingPlaceGeometry(double movingToSide)
set geometry common to all stopping places
GNEContour mySymbolContour
circle contour
std::string getStoppingPlaceAttribute(SumoXMLAttr key) const
double getDefaultDoubleValue(SumoXMLAttr attr) const
get default double value
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
int getDefaultIntValue(SumoXMLAttr attr) const
get default int value
const std::string & getDefaultStringValue(SumoXMLAttr attr) const
default values
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
const PositionVector & getShape() const
The shape of the additional element.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
Stores the information about how to visualize structures.
bool checkDrawAdditional(Detail d, const bool selected) const
check if draw additionals
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
GUIVisualizationStoppingPlaceSettings stoppingPlaceSettings
StoppingPlace settings.
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false, const bool escape=false)
writes a named attribute
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
A list of positions.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
Position getLineCenter() const
get line center
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
static const RGBColor INVISIBLE
Definition RGBColor.h:214
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:228
static OutputDevice & writeParams(OutputDevice &device, const Parameterised &params)
write the parameters of the given object as param tags
bool showAdditionals() const
check if additionals has to be drawn
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
RGBColor trainStopColorSign
color for trainStops signs
RGBColor busStopColorSign
color for busStops signs
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
RGBColor busStopColor
color for busStops
RGBColor trainStopColor
color for trainStops
static const double segmentWidthSmall
width of small dotted contour segments
static const double segmentWidth
width of dotted contour segments
static const double additionalGeometryPointRadius
moving additional geometry point radius
static const double stoppingPlaceSignOffset
busStop offset
static const double busStopWidth
busStop width
static const double trainStopWidth
trainStop width