Skip to content

Commit

Permalink
Updated GNELane. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 62127b7 commit b9bcb39
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
41 changes: 21 additions & 20 deletions src/netedit/elements/network/GNELane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,23 @@ GNELane::DrawingConstants::update(const GUIVisualizationSettings& s) {
// adjust rest of parameters depending if draw as railway
if (myDrawAsRailway) {
// draw as railway: assume standard gauge of 1435mm when lane width is not set
// draw foot width 150mm, assume that distance between rail feet inner sides is reduced on both sides by 39mm with regard to the gauge
// assume crosstie length of 181% gauge (2600mm for standard gauge)
myDrawingWidth = (laneWidth == SUMO_const_laneWidth ? 1.4350 : laneWidth) * myExaggeration;
// set offset
myOffset = myDrawingWidth * 0.8;
// update half gauge
myDrawingWidth *= 0.4;
// calculate internal drawing width
myInternalDrawingWidth = myDrawingWidth * 0.6;
} else {
// calculate exaggerated drawing width
myDrawingWidth = laneWidth * myExaggeration * 0.5;
// calculate internal drawing width
myInternalDrawingWidth = myDrawingWidth - (2 * SUMO_const_laneMarkWidth);
}

// check if draw superposed
myDrawSuperposed = (s.spreadSuperposed && myLane->getParentEdge()->getNBEdge()->isBidiRail());
if (myDrawSuperposed) {
if (myDrawAsRailway || myDrawSuperposed) {
// apply offset
myOffset = myDrawingWidth * 0.5;
// reduce width
myDrawingWidth *= 0.4;
myOffset = myDrawingWidth * 0.5;
myInternalDrawingWidth *= 0.4;
}
}

Expand Down Expand Up @@ -1317,7 +1314,7 @@ GNELane::drawLane(const GUIVisualizationSettings& s) const {
// Check if lane has to be draw as railway and if isn't being drawn for selecting
if (myDrawingConstants->drawAsRailway()) {
// draw as railway
drawLaneAsRailway(s);
drawLaneAsRailway();
} else if (myShapeColors.size() > 0) {
// draw box lines with own colors
GLHelper::drawBoxLines(myLaneGeometry.getShape(), myLaneGeometry.getShapeRotations(),
Expand Down Expand Up @@ -1377,7 +1374,7 @@ GNELane::drawSelectedLane(const GUIVisualizationSettings& s) const {
// draw internal box line
GLHelper::drawBoxLines(myLaneGeometry.getShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), myDrawingConstants->getInternalDrawingWidth(),
myDrawingConstants->getOffset());
0, myDrawingConstants->getOffset());
// Pop matrix
GLHelper::popMatrix();
}
Expand Down Expand Up @@ -1746,22 +1743,24 @@ GNELane::drawDirectionIndicators(const GUIVisualizationSettings& s) const {


void
GNELane::drawLaneAsRailway(const GUIVisualizationSettings& s) const {
// calculate constant
const double halfInnerFeetWidth = myDrawingConstants->getDrawingWidth() - 0.039 * myDrawingConstants->getExaggeration();
const double halfRailWidth = halfInnerFeetWidth + 0.15 * myDrawingConstants->getExaggeration();
const double halfCrossTieWidth = myDrawingConstants->getDrawingWidth() * 1.81;
GNELane::drawLaneAsRailway() const {
// draw foot width 150mm, assume that distance between rail feet inner sides is reduced on both sides by 39mm with regard to the gauge
// assume crosstie length of 181% gauge (2600mm for standard gauge)
// draw as box lines
if (myShapeColors.size() > 0) {
GLHelper::drawBoxLines(myLaneGeometry.getShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), myShapeColors, halfRailWidth,
myLaneGeometry.getShapeLengths(), myShapeColors,
myDrawingConstants->getInternalDrawingWidth(), 0,
myDrawingConstants->getOffset());
} else {
GLHelper::drawBoxLines(myLaneGeometry.getShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), halfRailWidth, myDrawingConstants->getOffset());
myLaneGeometry.getShapeLengths(), myDrawingConstants->getInternalDrawingWidth(),
0, myDrawingConstants->getOffset());
}
// continue depending of detail
if (myDrawingConstants->getDetail() <= GUIVisualizationSettings::Detail::LaneDetails) {
// calculate intern geometry width
const double internGeometryWidth = myDrawingConstants->getInternalDrawingWidth() - (2 * SUMO_const_laneMarkWidth);
// Save current color
RGBColor current = GLHelper::getColor();
// Draw gray on top with reduced width (the area between the two tracks)
Expand All @@ -1770,12 +1769,14 @@ GNELane::drawLaneAsRailway(const GUIVisualizationSettings& s) const {
glTranslated(0, 0, 0.1);
// draw as box lines
GLHelper::drawBoxLines(myLaneGeometry.getShape(), myLaneGeometry.getShapeRotations(),
myLaneGeometry.getShapeLengths(), halfInnerFeetWidth,
myLaneGeometry.getShapeLengths(), internGeometryWidth, 0,
myDrawingConstants->getOffset());
// Set current color back
GLHelper::setColor(current);
// Draw crossties
GLHelper::drawCrossTies(myLaneGeometry.getShape(), myLaneGeometry.getShapeRotations(), myLaneGeometry.getShapeLengths(), 0.26 * myDrawingConstants->getExaggeration(), 0.6 * myDrawingConstants->getExaggeration(), halfCrossTieWidth, s.drawForRectangleSelection);
GLHelper::drawCrossTies(myLaneGeometry.getShape(), myLaneGeometry.getShapeRotations(), myLaneGeometry.getShapeLengths(),
0.26 * myDrawingConstants->getExaggeration(), 0.6 * myDrawingConstants->getExaggeration(),
myDrawingConstants->getDrawingWidth(), false);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNELane.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ class GNELane : public GNENetworkElement, public GNECandidateElement, public FXD
void drawDirectionIndicators(const GUIVisualizationSettings& s) const;

/// @brief draw lane as railway
void drawLaneAsRailway(const GUIVisualizationSettings& s) const;
void drawLaneAsRailway() const;

/// @brief draw lane textures
void drawTextures(const GUIVisualizationSettings& s) const;
Expand Down

0 comments on commit b9bcb39

Please sign in to comment.