From 9857596430963b53c85ed57401ba9292324649ca Mon Sep 17 00:00:00 2001 From: Pablo Alvarez Lopez Date: Thu, 19 Dec 2024 12:38:34 +0100 Subject: [PATCH] Partial solution for #15929 --- src/netedit/elements/demand/GNEContainer.cpp | 6 +++--- src/netedit/elements/demand/GNEDemandElement.cpp | 9 +++++++-- src/netedit/elements/demand/GNEDemandElement.h | 3 ++- .../elements/demand/GNEDemandElementFlow.cpp | 9 +++++++-- .../elements/demand/GNEDemandElementFlow.h | 3 ++- src/netedit/elements/demand/GNEPerson.cpp | 6 +++--- src/netedit/elements/demand/GNEVehicle.cpp | 16 ++++++++-------- 7 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/netedit/elements/demand/GNEContainer.cpp b/src/netedit/elements/demand/GNEContainer.cpp index 2f9736e41329..529107700511 100644 --- a/src/netedit/elements/demand/GNEContainer.cpp +++ b/src/netedit/elements/demand/GNEContainer.cpp @@ -390,7 +390,7 @@ GNEContainer::drawGL(const GUIVisualizationSettings& s) const { } // draw stack label if (myStackedLabelNumber > 0) { - drawStackLabel(myStackedLabelNumber, "container", Position(containerPosition.x() - 2.5, containerPosition.y() - 0.8), -90, 1.3, 5, getExaggeration(s)); + drawStackLabel(myStackedLabelNumber, "container", Position(containerPosition.x() - 2.5, containerPosition.y() - 0.8), -90, 1.3, 5, getExaggeration(s), false); } else if (getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_STOPCONTAINER_CONTAINERSTOP) { // declare counter for stacked containers over stops int stackedCounter = 0; @@ -409,12 +409,12 @@ GNEContainer::drawGL(const GUIVisualizationSettings& s) const { } // if we have more than two stacked elements, draw label if (stackedCounter > 1) { - drawStackLabel(stackedCounter, "container", Position(containerPosition.x() - 2.5, containerPosition.y() - 0.8), -90, 1.3, 5, getExaggeration(s)); + drawStackLabel(stackedCounter, "container", Position(containerPosition.x() - 2.5, containerPosition.y() - 0.8), -90, 1.3, 5, getExaggeration(s), false); } } // draw flow label if (myTagProperty.isFlow()) { - drawFlowLabel(Position(containerPosition.x() - 1, containerPosition.y() - 4.25), -90, 1.8, 2, getExaggeration(s)); + drawFlowLabel(Position(containerPosition.x() - 1, containerPosition.y() - 4.25), -90, 1.8, 2, getExaggeration(s), false); } // draw name drawName(containerPosition, s.scale, s.containerName, s.angle); diff --git a/src/netedit/elements/demand/GNEDemandElement.cpp b/src/netedit/elements/demand/GNEDemandElement.cpp index a7cbb7dc2a59..62eaf606190a 100644 --- a/src/netedit/elements/demand/GNEDemandElement.cpp +++ b/src/netedit/elements/demand/GNEDemandElement.cpp @@ -523,7 +523,8 @@ GNEDemandElement::drawJunctionLine(const GNEDemandElement* element) const { void -GNEDemandElement::drawStackLabel(const int number, const std::string& element, const Position& position, const double rotation, const double width, const double length, const double exaggeration) const { +GNEDemandElement::drawStackLabel(const int number, const std::string& element, const Position& position, const double rotation, + const double width, const double length, const double exaggeration, const bool contour) const { // declare contour width const double contourWidth = (0.05 * exaggeration); // Push matrix @@ -531,7 +532,11 @@ GNEDemandElement::drawStackLabel(const int number, const std::string& element, c // Traslate to top glTranslated(position.x(), position.y(), GLO_ROUTE + getType() + 0.1 + GLO_PERSONFLOW); glRotated(rotation, 0, 0, -1); - glTranslated((width * exaggeration * 0.5) + (0.35 * exaggeration), 0, 0); + if (contour) { + glTranslated((width * exaggeration * 0.5) + (0.35 * exaggeration) + 0.4, 0, 0); + } else { + glTranslated((width * exaggeration * 0.5) + (0.35 * exaggeration), 0, 0); + } // draw external box GLHelper::setColor(RGBColor::GREY); GLHelper::drawBoxLine(Position(), 0, (length * exaggeration), 0.3 * exaggeration); diff --git a/src/netedit/elements/demand/GNEDemandElement.h b/src/netedit/elements/demand/GNEDemandElement.h index 4c204a31ac84..ddc824c41bd0 100644 --- a/src/netedit/elements/demand/GNEDemandElement.h +++ b/src/netedit/elements/demand/GNEDemandElement.h @@ -373,7 +373,8 @@ class GNEDemandElement : public GNEPathElement, public GNEHierarchicalElement, p void drawJunctionLine(const GNEDemandElement* element) const; /// @brief draw stack label - void drawStackLabel(const int number, const std::string& element, const Position& position, const double rotation, const double width, const double length, const double exaggeration) const; + void drawStackLabel(const int number, const std::string& element, const Position& position, const double rotation, + const double width, const double length, const double exaggeration, const bool contour) const; /// @name replace parent elements /// @{ diff --git a/src/netedit/elements/demand/GNEDemandElementFlow.cpp b/src/netedit/elements/demand/GNEDemandElementFlow.cpp index 91c2030ecf19..4c50096ce197 100644 --- a/src/netedit/elements/demand/GNEDemandElementFlow.cpp +++ b/src/netedit/elements/demand/GNEDemandElementFlow.cpp @@ -46,7 +46,8 @@ GNEDemandElementFlow::~GNEDemandElementFlow() {} void -GNEDemandElementFlow::drawFlowLabel(const Position& position, const double rotation, const double width, const double length, const double exaggeration) const { +GNEDemandElementFlow::drawFlowLabel(const Position& position, const double rotation, const double width, const double length, + const double exaggeration, const bool contour) const { // declare contour width const double contourWidth = (0.05 * exaggeration); // Push matrix @@ -55,7 +56,11 @@ GNEDemandElementFlow::drawFlowLabel(const Position& position, const double rotat glTranslated(position.x(), position.y(), GLO_PERSONFLOW + 0.1); // glTranslated(position.x(), position.y(), GLO_ROUTE + getType() + 0.1 + GLO_PERSONFLOW + 0.1); glRotated(rotation, 0, 0, -1); - glTranslated(-1 * ((width * 0.5 * exaggeration) + (0.35 * exaggeration)), 0, 0); + if (contour) { + glTranslated(-1 * ((width * 0.5 * exaggeration) + (0.35 * exaggeration)) - 0.4, 0, 0); + } else { + glTranslated(-1 * ((width * 0.5 * exaggeration) + (0.35 * exaggeration)), 0, 0); + } // draw external box GLHelper::setColor(RGBColor::GREY); GLHelper::drawBoxLine(Position(), Position(), 0, (length * exaggeration), 0.3 * exaggeration); diff --git a/src/netedit/elements/demand/GNEDemandElementFlow.h b/src/netedit/elements/demand/GNEDemandElementFlow.h index d22ee8f81380..7a72a776c106 100644 --- a/src/netedit/elements/demand/GNEDemandElementFlow.h +++ b/src/netedit/elements/demand/GNEDemandElementFlow.h @@ -48,7 +48,8 @@ class GNEDemandElementFlow : public SUMOVehicleParameter { ~GNEDemandElementFlow(); /// @brief draw flow label - void drawFlowLabel(const Position& position, const double rotation, const double width, const double length, const double exaggeration) const; + void drawFlowLabel(const Position& position, const double rotation, const double width, const double length, + const double exaggeration, const bool contour) const; /// @brief write flow attributes void writeFlowAttributes(const GNEDemandElement* flowElement, OutputDevice& device) const; diff --git a/src/netedit/elements/demand/GNEPerson.cpp b/src/netedit/elements/demand/GNEPerson.cpp index 1f7e287d529f..80b3b726c7fc 100644 --- a/src/netedit/elements/demand/GNEPerson.cpp +++ b/src/netedit/elements/demand/GNEPerson.cpp @@ -381,7 +381,7 @@ GNEPerson::drawGL(const GUIVisualizationSettings& s) const { GLHelper::popMatrix(); // draw stack label if (myStackedLabelNumber > 0) { - drawStackLabel(myStackedLabelNumber, "person", Position(personPosition.x() - 2.5, personPosition.y()), -90, 1.3, 5, getExaggeration(s)); + drawStackLabel(myStackedLabelNumber, "person", Position(personPosition.x() - 2.5, personPosition.y()), -90, 1.3, 5, getExaggeration(s), false); } else if ((getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_STOPPERSON_BUSSTOP) || (getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_STOPPERSON_TRAINSTOP)) { // declare counter for stacked persons over stops @@ -402,12 +402,12 @@ GNEPerson::drawGL(const GUIVisualizationSettings& s) const { } // if we have more than two stacked elements, draw label if (stackedCounter > 1) { - drawStackLabel(stackedCounter, "person", Position(personPosition.x() - 2.5, personPosition.y()), -90, 1.3, 5, getExaggeration(s)); + drawStackLabel(stackedCounter, "person", Position(personPosition.x() - 2.5, personPosition.y()), -90, 1.3, 5, getExaggeration(s), false); } } // draw flow label if (myTagProperty.isFlow()) { - drawFlowLabel(Position(personPosition.x() - 1, personPosition.y() - 0.25), -90, 1.8, 2, getExaggeration(s)); + drawFlowLabel(Position(personPosition.x() - 1, personPosition.y() - 0.25), -90, 1.8, 2, getExaggeration(s), false); } // draw lock icon GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), personPosition, exaggeration, s.dottedContourSettings.segmentWidth); diff --git a/src/netedit/elements/demand/GNEVehicle.cpp b/src/netedit/elements/demand/GNEVehicle.cpp index f37b31d4fa5a..c46cc6ebbce7 100644 --- a/src/netedit/elements/demand/GNEVehicle.cpp +++ b/src/netedit/elements/demand/GNEVehicle.cpp @@ -931,18 +931,18 @@ GNEVehicle::drawGL(const GUIVisualizationSettings& s) const { if ((getParentJunctions().size() > 0) && !myNet->getDemandPathManager()->isPathValid(this)) { drawJunctionLine(this); } + // draw lock icon + GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), vehiclePosition, exaggeration); + // draw dotted contour + const bool dottedContorDrawn = myVehicleContour.drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true); // draw stack label if ((myStackedLabelNumber > 0) && !drawSpreadVehicles) { - drawStackLabel(myStackedLabelNumber, "Vehicle", vehiclePosition, vehicleRotation, width, length, exaggeration); + drawStackLabel(myStackedLabelNumber, "Vehicle", vehiclePosition, vehicleRotation, width, length, exaggeration, dottedContorDrawn); } // draw flow label if (myTagProperty.isFlow()) { - drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration); + drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration, dottedContorDrawn); } - // draw lock icon - GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), vehiclePosition, exaggeration); - // draw dotted contour - myVehicleContour.drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true); } // draw squared shape myVehicleContour.calculateContourRectangleShape(s, d, this, vehiclePosition, length * 0.5, width * 0.5, getType(), @@ -1139,10 +1139,10 @@ GNEVehicle::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegmen } // calculate contour and draw dotted geometry if (segment->isFirstSegment() || segment->isLastSegment()) { - segment->getContour()->calculateContourExtrudedShape(s, d, this, vehicleGeometry.getShape(), getType(), width, 1, segment->isFirstSegment(), segment->isLastSegment(), + segment->getContour()->calculateContourExtrudedShape(s, d, this, vehicleGeometry.getShape(), getType(), width, 1, false, segment->isLastSegment(), 0, segment, segment->getLane()->getParentEdge()); } else { - segment->getContour()->calculateContourExtrudedShape(s, d, this, segment->getLane()->getLaneShape(), getType(), width, 1, segment->isFirstSegment(), segment->isLastSegment(), + segment->getContour()->calculateContourExtrudedShape(s, d, this, segment->getLane()->getLaneShape(), getType(), width, 1, false, segment->isLastSegment(), 0, segment, segment->getLane()->getParentEdge()); } // check if add this path element to redraw buffer