Skip to content

Commit

Permalink
fix #16260
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Feb 27, 2025
1 parent 1418ec4 commit c8a9603
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/guinetload/GUITriggerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ void
GUITriggerBuilder::endStoppingPlace() {
if (myCurrentStop != nullptr) {
static_cast<GUINet*>(MSNet::getInstance())->registerRenderedObject(dynamic_cast<GUIGlObject*>(myCurrentStop));
myCurrentStop->finishedLoading();
myCurrentStop = nullptr;
} else {
throw InvalidArgument("Could not end a stopping place that is not opened.");
Expand Down
19 changes: 18 additions & 1 deletion src/guisim/GUIBusStop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ GUIBusStop::GUIBusStop(const std::string& id, SumoXMLTag element, const std::vec
double frompos, double topos, const std::string name, int personCapacity,
double parkingLength, const RGBColor& color) :
MSStoppingPlace(id, element, lines, lane, frompos, topos, name, personCapacity, parkingLength, color),
GUIGlObject_AbstractAdd(GLO_BUS_STOP, id, GUIIconSubSys::getIcon(GUIIcon::BUSSTOP)) {
GUIGlObject_AbstractAdd(GLO_BUS_STOP, id, GUIIconSubSys::getIcon(GUIIcon::BUSSTOP)),
myEmptyColor(RGBColor::INVISIBLE)
{
// see MSVehicleControl defContainerType
myWidth = MAX2(1.0, ceil((double)personCapacity / getTransportablesAbreast()) * myTransportableDepth);
initShape(myFGShape, myFGShapeRotations, myFGShapeLengths, myFGSignPos, myFGSignRot);
Expand Down Expand Up @@ -102,6 +104,18 @@ GUIBusStop::initShape(PositionVector& fgShape,
}


void
GUIBusStop::finishedLoading() {
if (hasParameter("emptyColor")) {
try {
myEmptyColor = RGBColor::parseColor(getParameter("emptyColor"));
} catch (ProcessError& e) {
WRITE_WARNINGF("Could not parse color '%' (%)", getParameter("emptyColor"), e.what());
}
}
}


bool
GUIBusStop::addAccess(MSLane* const lane, const double startPos, const double endPos, double length, const MSStoppingPlace::AccessExit exit) {
const bool added = MSStoppingPlace::addAccess(lane, startPos, endPos, length, exit);
Expand Down Expand Up @@ -185,6 +199,9 @@ GUIBusStop::drawGL(const GUIVisualizationSettings& s) const {
if (getColor() != RGBColor::INVISIBLE) {
color = getColor();
}
if (myEmptyColor != RGBColor::INVISIBLE && myEndPositions.empty() && myWaitingTransportables.empty()) {
color = myEmptyColor;
}
const bool s2 = s.secondaryShape;
const Position& signPos = s2 ? myFGSignPos2 : myFGSignPos;
// recognize full transparency and simply don't draw
Expand Down
3 changes: 2 additions & 1 deletion src/guisim/GUIBusStop.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class GUIBusStop : public MSStoppingPlace, public GUIGlObject_AbstractAdd {
/// @brief Destructor
~GUIBusStop();

void finishedLoading();

/// @brief adds an access point to this stop
bool addAccess(MSLane* const lane, const double startPos, const double endPos, double length, const MSStoppingPlace::AccessExit exit);
Expand Down Expand Up @@ -168,5 +169,5 @@ class GUIBusStop : public MSStoppingPlace, public GUIGlObject_AbstractAdd {
/// @brief The coordinates of access points
PositionVector myAccessCoords;


RGBColor myEmptyColor;
};
3 changes: 3 additions & 0 deletions src/microsim/MSStoppingPlace.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ class MSStoppingPlace : public Named, public Parameterised {
/// @brief get IDs of persons waiting at this stop
void getWaitingPersonIDs(std::vector<std::string>& into) const;

/// @brief perform extra processing after element has been loaded
virtual void finishedLoading() {};

/** @brief Remove all vehicles before quick-loading state */
void clearState();

Expand Down
1 change: 1 addition & 0 deletions src/netload/NLTriggerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ NLTriggerBuilder::endParkingArea() {
void
NLTriggerBuilder::endStoppingPlace() {
if (myCurrentStop != nullptr) {
myCurrentStop->finishedLoading();
myCurrentStop = nullptr;
} else {
throw InvalidArgument("Could not end a stopping place that is not opened.");
Expand Down

0 comments on commit c8a9603

Please sign in to comment.