Skip to content

Commit

Permalink
Updated drawing of GNEStops. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 1233290 commit eab2550
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 109 deletions.
219 changes: 113 additions & 106 deletions src/netedit/elements/demand/GNEStop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,42 @@ void
GNEStop::drawGL(const GUIVisualizationSettings& s) const {
// check if draw an stop for person/containers or for vehicles/routes
if (canDrawVehicleStop()) {
// draw vehicle over stop
drawVehicleStop(s, getExaggeration(s));
// Draw name
drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
// get exaggeration
const auto exaggeration = getExaggeration(s);
// get lane
const auto& stopLane = getParentLanes().size() > 0 ? getParentLanes().front() : nullptr;
// get lane width
const double width = stopLane ? stopLane->getParentEdge()->getNBEdge()->getLaneWidth(stopLane->getIndex()) * 0.5 : exaggeration * 0.8;
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// get color
const auto color = drawUsingSelectColor() ? s.colorSettings.selectedRouteColor : getColor();
// Start drawing adding an gl identificator
GLHelper::pushName(getGlID());
// Add a layer matrix
GLHelper::pushMatrix();
// set Color
GLHelper::setColor(color);
// Start with the drawing of the area traslating matrix to origin
myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, getType());
// draw depending if is over lane or over stoppingP
if (getParentLanes().size() > 0) {
drawStopOverLane(s, color, width, exaggeration);
} else {
drawStopOverStoppingPlace(s, color, width, exaggeration);
}
// pop layer matrix
GLHelper::popMatrix();
// Pop name
GLHelper::popName();
// draw lock icon
GNEViewNetHelper::LockIcon::drawLockIcon(this, getType(), getPositionInView(), exaggeration);
// Draw name
drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
}
// draw dotted geometry
myContour.drawDottedContourExtruded(s, myDemandElementGeometry.getShape(), width, exaggeration, true, true,
s.dottedContourSettings.segmentWidth);
}
}

Expand Down Expand Up @@ -967,108 +999,6 @@ GNEStop::canDrawVehicleStop() const {
}


void
GNEStop::drawVehicleStop(const GUIVisualizationSettings& s, const double exaggeration) const {
// get lane
const auto& stopLane = getParentLanes().size() > 0 ? getParentLanes().front() : nullptr;
// get lane width
const double width = stopLane ? stopLane->getParentEdge()->getNBEdge()->getLaneWidth(stopLane->getIndex()) * 0.5 : exaggeration * 0.8;
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// declare value to save stop color
const RGBColor stopColor = drawUsingSelectColor() ? s.colorSettings.selectedRouteColor : getColor();
// Start drawing adding an gl identificator
GLHelper::pushName(getGlID());
// Add a layer matrix
GLHelper::pushMatrix();
// set Color
GLHelper::setColor(stopColor);
// Start with the drawing of the area traslating matrix to origin
myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, getType());
// draw depending of details
if (s.drawDetail(s.detailSettings.stopsDetails, exaggeration) && stopLane) {
// Draw top and bot lines using shape, shapeRotations, shapeLengths and value of exaggeration
GLHelper::drawBoxLines(myDemandElementGeometry.getShape(),
myDemandElementGeometry.getShapeRotations(),
myDemandElementGeometry.getShapeLengths(),
exaggeration * 0.1, 0, width);
GLHelper::drawBoxLines(myDemandElementGeometry.getShape(),
myDemandElementGeometry.getShapeRotations(),
myDemandElementGeometry.getShapeLengths(),
exaggeration * 0.1, 0, width * -1);
// Add a detail matrix
GLHelper::pushMatrix();
// move to geometry front
glTranslated(myDemandElementGeometry.getShape().back().x(), myDemandElementGeometry.getShape().back().y(), 0.1);
// rotate
if (myDemandElementGeometry.getShapeRotations().size() > 0) {
glRotated(myDemandElementGeometry.getShapeRotations().back(), 0, 0, 1);
}
// move again
glTranslated(0, exaggeration * 0.5, 0);
// draw stop front
GLHelper::drawBoxLine(Position(0, 0), 0, exaggeration * 0.5, width);
// move to "S" position
glTranslated(0, 1, 0.1);
// only draw text if isn't being drawn for selecting
if (s.drawForRectangleSelection) {
GLHelper::setColor(stopColor);
GLHelper::drawBoxLine(Position(0, 1), 0, 2, 1);
} else if (s.drawDetail(s.detailSettings.stopsText, exaggeration)) {
// draw "S" symbol
GLHelper::drawText(myTagProperty.isVehicleWaypoint() ? "W" : "S", Position(), .1, 2.8, stopColor, 180);
// move to subtitle position
glTranslated(0, 1.4, 0);
// draw subtitle depending of tag
GLHelper::drawText("lane", Position(), .1, 1, stopColor, 180);
// check if draw index
if (drawIndex()) {
// move to index position
glTranslated(-2.1, -2.4, 0);
glRotated(-90, 0, 0, 1);
// draw index
GLHelper::drawText(getAttribute(GNE_ATTR_STOPINDEX), Position(0, getAttributeDouble(GNE_ATTR_STOPINDEX) * -1, 0), .1, 1, stopColor, 180);
}
}
// pop detail matrix
GLHelper::popMatrix();
// draw geometry points
drawGeometryPoints(s, stopColor);
} else {
// Draw the area using shape, shapeRotations, shapeLengths and value of exaggeration taked from stoppingPlace parent
GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), myDemandElementGeometry, width);
// only draw text if isn't being drawn for selecting
if (s.drawDetail(s.detailSettings.stopsText, exaggeration) && drawIndex()) {
// Add a detail matrix
GLHelper::pushMatrix();
// move to geometry front
glTranslated(myDemandElementGeometry.getShape().back().x(), myDemandElementGeometry.getShape().back().y(), 0.1);
// rotate
if (myDemandElementGeometry.getShapeRotations().size() > 0) {
glRotated(myDemandElementGeometry.getShapeRotations().back(), 0, 0, 1);
}
// move to index position
glTranslated(-1.4, exaggeration * 0.5, 0.1);
glRotated(-90, 0, 0, 1);
// draw index
GLHelper::drawText(getAttribute(GNE_ATTR_STOPINDEX), Position(0, getAttributeDouble(GNE_ATTR_STOPINDEX) * -1, 0), .1, 1, stopColor, 180);
}
// pop detail matrix
GLHelper::popMatrix();
}
// pop layer matrix
GLHelper::popMatrix();
// Pop name
GLHelper::popName();
// draw lock icon
GNEViewNetHelper::LockIcon::drawLockIcon(this, getType(), getPositionInView(), exaggeration);
}
// draw dotted geometry
myContour.drawDottedContourExtruded(s, myDemandElementGeometry.getShape(), width, exaggeration, true, true,
s.dottedContourSettings.segmentWidth);
}


bool
GNEStop::drawIndex() const {
// get stop frame
Expand All @@ -1083,6 +1013,83 @@ GNEStop::drawIndex() const {
}
}



void
GNEStop::drawStopOverLane(const GUIVisualizationSettings& s, const RGBColor &color, const double width, const double exaggeration) const {
// Draw top and bot lines using shape, shapeRotations, shapeLengths and value of exaggeration
GLHelper::drawBoxLines(myDemandElementGeometry.getShape(),
myDemandElementGeometry.getShapeRotations(),
myDemandElementGeometry.getShapeLengths(),
exaggeration * 0.1, 0, width);
GLHelper::drawBoxLines(myDemandElementGeometry.getShape(),
myDemandElementGeometry.getShapeRotations(),
myDemandElementGeometry.getShapeLengths(),
exaggeration * 0.1, 0, width * -1);
// Add a detail matrix
GLHelper::pushMatrix();
// move to geometry front
glTranslated(myDemandElementGeometry.getShape().back().x(), myDemandElementGeometry.getShape().back().y(), 0.1);
// rotate
if (myDemandElementGeometry.getShapeRotations().size() > 0) {
glRotated(myDemandElementGeometry.getShapeRotations().back(), 0, 0, 1);
}
// move again
glTranslated(0, exaggeration * 0.5, 0);
// draw stop front
GLHelper::drawBoxLine(Position(0, 0), 0, exaggeration * 0.5, width);
// move to "S" position
glTranslated(0, 1, 0.1);
// only draw text if isn't being drawn for selecting
if (s.drawForRectangleSelection) {
GLHelper::drawBoxLine(Position(0, 1), 0, 2, 1);
} else if (s.drawDetail(s.detailSettings.stopsText, exaggeration)) {
// draw "S" symbol
GLHelper::drawText(myTagProperty.isVehicleWaypoint() ? "W" : "S", Position(), .1, 2.8, color, 180);
// move to subtitle position
glTranslated(0, 1.4, 0);
// draw subtitle depending of tag
GLHelper::drawText("lane", Position(), .1, 1, color, 180);
// check if draw index
if (drawIndex()) {
// move to index position
glTranslated(-2.1, -2.4, 0);
glRotated(-90, 0, 0, 1);
// draw index
GLHelper::drawText(getAttribute(GNE_ATTR_STOPINDEX), Position(0, getAttributeDouble(GNE_ATTR_STOPINDEX) * -1, 0), .1, 1, color, 180);
}
}
// pop detail matrix
GLHelper::popMatrix();
// draw geometry points
drawGeometryPoints(s, color);
}


void
GNEStop::drawStopOverStoppingPlace(const GUIVisualizationSettings& s, const RGBColor &color, const double width, const double exaggeration) const {
// Draw the area using shape, shapeRotations, shapeLengths and value of exaggeration taked from stoppingPlace parent
GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), myDemandElementGeometry, width);
// only draw text if isn't being drawn for selecting
if (s.drawDetail(s.detailSettings.stopsText, exaggeration) && drawIndex()) {
// Add a detail matrix
GLHelper::pushMatrix();
// move to geometry front
glTranslated(myDemandElementGeometry.getShape().back().x(), myDemandElementGeometry.getShape().back().y(), 0.1);
// rotate
if (myDemandElementGeometry.getShapeRotations().size() > 0) {
glRotated(myDemandElementGeometry.getShapeRotations().back(), 0, 0, 1);
}
// move to index position
glTranslated(-1.4, exaggeration * 0.5, 0.1);
glRotated(-90, 0, 0, 1);
// draw index
GLHelper::drawText(getAttribute(GNE_ATTR_STOPINDEX), Position(0, getAttributeDouble(GNE_ATTR_STOPINDEX) * -1, 0), .1, 1, color, 180);
// pop detail matrix
GLHelper::popMatrix();
}
}

// ===========================================================================
// private
// ===========================================================================
Expand Down
9 changes: 6 additions & 3 deletions src/netedit/elements/demand/GNEStop.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,15 @@ class GNEStop : public GNEDemandElement, public SUMOVehicleParameter::Stop, publ
/// @brief check if vehicle stop can be draw
bool canDrawVehicleStop() const;

/// @brief draw vehicle stop
void drawVehicleStop(const GUIVisualizationSettings& s, const double exaggeration) const;

/// @brief draw index
bool drawIndex() const;

/// @brief draw stop over lane
void drawStopOverLane(const GUIVisualizationSettings& s, const RGBColor &color, const double width, const double exaggeration) const;

/// @brief draw stop over stoppingPlace
void drawStopOverStoppingPlace(const GUIVisualizationSettings& s, const RGBColor &color, const double width, const double exaggeration) const;

private:
/// @brief method for setting the attribute and nothing else
void setAttribute(SumoXMLAttr key, const std::string& value);
Expand Down

0 comments on commit eab2550

Please sign in to comment.