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 b671973 commit cc03dff
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 65 deletions.
6 changes: 2 additions & 4 deletions src/netedit/GNEPathManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,7 @@ GNEPathManager::removePath(PathElement* pathElement) {


void
GNEPathManager::drawLanePathElements(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const GNELane* lane) const {
GNEPathManager::drawLanePathElements(const GUIVisualizationSettings& s, const GNELane* lane) const {
// check detail level and lane segments
if (myLaneSegments.count(lane) > 0) {
int numRoutes = 0;
Expand Down Expand Up @@ -844,8 +843,7 @@ GNEPathManager::drawLanePathElements(const GUIVisualizationSettings& s, const GU


void
GNEPathManager::drawJunctionPathElements(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const GNEJunction* junction) const {
GNEPathManager::drawJunctionPathElements(const GUIVisualizationSettings& s, const GNEJunction* junction) const {
// check detail level and junction segments
if (myJunctionSegments.count(junction) > 0) {
// first draw selected elements (for drawing over other elements)
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/GNEPathManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ class GNEPathManager {
void removePath(PathElement* pathElement);

/// @brief draw lane path elements
void drawLanePathElements(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const GNELane* lane) const;
void drawLanePathElements(const GUIVisualizationSettings& s, const GNELane* lane) const;

/// @brief draw junction path elements
void drawJunctionPathElements(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const GNEJunction* junction) const;
void drawJunctionPathElements(const GUIVisualizationSettings& s, const GNEJunction* junction) const;

/// @brief force draw path (used carefully, ONLY when we're inspecting a path element, due slowdowns)
void forceDrawPath(const GUIVisualizationSettings& s, const PathElement* pathElement) const;
Expand Down
6 changes: 3 additions & 3 deletions src/netedit/elements/network/GNEEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,6 @@ GNEEdge::getOppositeEdges() const {

void
GNEEdge::drawGL(const GUIVisualizationSettings& s) const {
// get detail level
const auto d = s.getDetailLevel(1);
// draw boundaries
GLHelper::drawBoundary(s, getCenteringBoundary());
// draw draw lanes
Expand All @@ -569,6 +567,8 @@ GNEEdge::drawGL(const GUIVisualizationSettings& s) const {
// draw junctions
getFromJunction()->drawGL(s);
getToJunction()->drawGL(s);
// get detail level from the first lane
const auto d = myLanes.front()->getDrawingConstants()->getDetail();
// draw geometry points
drawEdgeGeometryPoints(s, d);
// check if draw details
Expand Down Expand Up @@ -2689,7 +2689,7 @@ GNEEdge::drawLaneStopOffset(const GUIVisualizationSettings& s, const GUIVisualiz
}
if (myNBEdge->myEdgeStopOffset.isDefined() && (myNBEdge->myEdgeStopOffset.getPermissions() & SVC_PASSENGER) != 0) {
for (const auto& lane : getLanes()) {
lane->drawLaneStopOffset(s, d);
lane->drawLaneStopOffset(s);
}
}
// Push stopOffset matrix
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,7 @@ GNEJunction::drawJunctionChildren(const GUIVisualizationSettings& s, const GUIVi
demandElement->drawGL(s);
}
// draw path additional elements
myNet->getPathManager()->drawJunctionPathElements(s, d, this);
myNet->getPathManager()->drawJunctionPathElements(s, this);
}
}

Expand Down
91 changes: 49 additions & 42 deletions src/netedit/elements/network/GNELane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ GNELane::DrawingConstants::update(const GUIVisualizationSettings& s) {
myHalfLaneWidth = myExaggeration * (myLane->myParentEdge->getNBEdge()->getLaneWidth(myLane->getIndex()) / 2);
myMarkWidth = myHalfLaneWidth - (SUMO_const_laneMarkWidth / 2);
myWidth = myLane->drawUsingSelectColor() ? (myMarkWidth - myExaggeration * 0.3) : myMarkWidth;

// get detail level
myDetail = s.getDetailLevel(myExaggeration);
}


Expand All @@ -103,6 +106,12 @@ GNELane::DrawingConstants::getWidth() const {
return myWidth;
}


GUIVisualizationSettings::Detail
GNELane::DrawingConstants::getDetail() const {
return myDetail;
}

// ---------------------------------------------------------------------------
// GNELane - methods
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -404,7 +413,7 @@ GNELane::removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoLi


void
GNELane::drawLinkNo(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d) const {
GNELane::drawLinkNo(const GUIVisualizationSettings& s) const {
// check draw conditions
if (s.drawLinkJunctionIndex.show(myParentEdge->getToJunction())) {
// get connections
Expand Down Expand Up @@ -441,9 +450,9 @@ GNELane::drawLinkNo(const GUIVisualizationSettings& s, const GUIVisualizationSet


void
GNELane::drawTLSLinkNo(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d) const {
GNELane::drawTLSLinkNo(const GUIVisualizationSettings& s) const {
// check conditions
if ((d <= GUIVisualizationSettings::Detail::LaneDetails) && s.drawLinkTLIndex.show(myParentEdge->getToJunction()) &&
if ((myDrawingConstants->getDetail() <= GUIVisualizationSettings::Detail::LaneDetails) && s.drawLinkTLIndex.show(myParentEdge->getToJunction()) &&
(myParentEdge->getToJunction()->getNBNode()->getControllingTLS().size() > 0)) {
// get connections
const auto &connections = myParentEdge->getNBEdge()->getConnectionsFromLane(myIndex);
Expand Down Expand Up @@ -478,7 +487,7 @@ GNELane::drawTLSLinkNo(const GUIVisualizationSettings& s, const GUIVisualization


void
GNELane::drawLaneArrows(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const bool spreadSuperposed) const {
GNELane::drawLaneArrows(const GUIVisualizationSettings& s, const bool spreadSuperposed) const {
if (s.showLinkDecals && myParentEdge->getToJunction()->isLogicValid()) {
// calculate begin, end and rotation
const Position& begin = myLaneGeometry.getShape()[-2];
Expand Down Expand Up @@ -615,8 +624,6 @@ void
GNELane::drawGL(const GUIVisualizationSettings& s) const {
// update lane drawing constan
myDrawingConstants->update(s);
// get detail level
const auto d = s.getDetailLevel(myDrawingConstants->getExaggeration());
// check drawing conditions
if (!s.drawForObjectUnderCursor) {
// Push layer matrix
Expand All @@ -630,16 +637,16 @@ GNELane::drawGL(const GUIVisualizationSettings& s) const {
myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, GLO_LANE);
}
// draw lane
drawLane(s, d);
drawLane(s);
// Pop layer matrix
GLHelper::popMatrix();
// draw lock icon
GNEViewNetHelper::LockIcon::drawLockIcon(this, getType(), getPositionInView(), 1);
}
// draw children
drawChildren(s, d);
drawChildren(s);
// draw dotted geometry
myContour.drawDottedContourExtruded(s, d, getLaneShape(), myDrawingConstants->getWidth(), 1, true, true,
myContour.drawDottedContourExtruded(s, myDrawingConstants->getDetail(), getLaneShape(), myDrawingConstants->getWidth(), 1, true, true,
s.dottedContourSettings.segmentWidth);
}

Expand All @@ -660,9 +667,9 @@ GNELane::updateGLObject() {


void
GNELane::drawChildren(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d) const {
GNELane::drawChildren(const GUIVisualizationSettings& s) const {
// check if draw children elements
if (s.drawForObjectUnderCursor || (d <= GUIVisualizationSettings::Detail::Additionals)) {
if (s.drawForObjectUnderCursor || (myDrawingConstants->getDetail() <= GUIVisualizationSettings::Detail::Additionals)) {
// draw additional children
for (const auto& additional : getChildAdditionals()) {
// check that ParkingAreas aren't draw two times
Expand All @@ -675,13 +682,13 @@ GNELane::drawChildren(const GUIVisualizationSettings& s, const GUIVisualizationS
}
}
// draw path additional elements
myNet->getPathManager()->drawLanePathElements(s, d, this);
myNet->getPathManager()->drawLanePathElements(s, this);
}
}


void
GNELane::drawLaneMarkings(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const bool drawRailway) const {
GNELane::drawLaneMarkings(const GUIVisualizationSettings& s, const bool drawRailway) const {
// check conditions
if (s.laneShowBorders && (myDrawingConstants->getExaggeration() == 1) && !drawRailway) {
// optionally draw inverse markings
Expand Down Expand Up @@ -1221,19 +1228,19 @@ GNELane::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList)


void
GNELane::drawLane(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d) const {
GNELane::drawLane(const GUIVisualizationSettings& s) const {
// set lane colors
setLaneColor(s);
// continue depending of detail level
if (d <= GUIVisualizationSettings::Detail::Lane) {
if (myDrawingConstants->getDetail() <= GUIVisualizationSettings::Detail::Lane) {
// get flag for draw lane as railway
const bool drawRailway = drawAsRailway(s);
// we draw the lanes with reduced width so that the lane markings below are visible (this avoids artifacts at geometry corners without having to)
const bool drawSpreadSuperposed = s.spreadSuperposed && myParentEdge->getNBEdge()->isBidiRail();
// Check if lane has to be draw as railway and if isn't being drawn for selecting
if (drawRailway && drawSpreadSuperposed) {
// draw as railway
drawLaneAsRailway(s, d);
drawLaneAsRailway(s);
} else {
// create visible gap depending of draw spread superposed
const double offset = drawSpreadSuperposed? myDrawingConstants->getWidth() * 0.5 : 0;
Expand All @@ -1245,30 +1252,30 @@ GNELane::drawLane(const GUIVisualizationSettings& s, const GUIVisualizationSetti
myDrawingConstants->getWidth() * widthFactor, false, offset);
}
// draw back edge
drawBackEdge(s, d, drawSpreadSuperposed);
drawBackEdge(s, drawSpreadSuperposed);
// draw start end shape points
drawStartEndGeometryPoints(s, d);
drawStartEndGeometryPoints(s);
// check if draw details
if (d <= GUIVisualizationSettings::Detail::LaneDetails) {
if (myDrawingConstants->getDetail() <= GUIVisualizationSettings::Detail::LaneDetails) {
// draw markings
drawLaneMarkings(s, d, drawRailway);
drawLaneMarkings(s, drawRailway);
// Draw direction indicators
drawDirectionIndicators(s, d, drawRailway, drawSpreadSuperposed);
drawDirectionIndicators(s, drawRailway, drawSpreadSuperposed);
// draw lane textures
drawTextures(s, d);
drawTextures(s);
// draw lane arrows
drawLaneArrows(s, d, drawSpreadSuperposed);
drawLaneArrows(s, drawSpreadSuperposed);
// draw link numbers
drawLinkNo(s, d);
drawLinkNo(s);
// draw TLS link numbers
drawTLSLinkNo(s, d);
drawTLSLinkNo(s);
// draw stopOffsets
drawLaneStopOffset(s, d);
drawLaneStopOffset(s);
}
// draw shape edited
drawShapeEdited(s, d);
} else if ((d <= GUIVisualizationSettings::Detail::LaneSimple) ||
((d <= GUIVisualizationSettings::Detail::LaneSimpleOnlyFirst) && (myIndex == 0))) {
drawShapeEdited(s);
} else if ((myDrawingConstants->getDetail() <= GUIVisualizationSettings::Detail::LaneSimple) ||
((myDrawingConstants->getDetail() <= GUIVisualizationSettings::Detail::LaneSimpleOnlyFirst) && (myIndex == 0))) {
// draw lane as line, depending of myShapeColors
if (myShapeColors.size() > 0) {
GLHelper::drawLine(myLaneGeometry.getShape(), myShapeColors);
Expand All @@ -1280,7 +1287,7 @@ GNELane::drawLane(const GUIVisualizationSettings& s, const GUIVisualizationSetti


void
GNELane::drawBackEdge(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const bool drawSpreadSuperposed) const {
GNELane::drawBackEdge(const GUIVisualizationSettings& s, const bool drawSpreadSuperposed) const {
// only draw if width and mark width are differents
if (myDrawingConstants->getWidth() != myDrawingConstants->getMarkWidth()) {
// Push matrix
Expand All @@ -1304,7 +1311,7 @@ GNELane::drawBackEdge(const GUIVisualizationSettings& s, const GUIVisualizationS


void
GNELane::drawShapeEdited(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d) const {
GNELane::drawShapeEdited(const GUIVisualizationSettings& s) const {
// if shape is being edited, draw point and green line
if (myShapeEdited) {
// push shape edited matrix
Expand Down Expand Up @@ -1602,7 +1609,7 @@ GNELane::drawOverlappedRoutes(const int numRoutes) const {


void
GNELane::drawLaneStopOffset(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d) const {
GNELane::drawLaneStopOffset(const GUIVisualizationSettings& s) const {
const auto& laneStopOffset = myParentEdge->getNBEdge()->getLaneStruct(myIndex).laneStopOffset;
// check conditions
if (laneStopOffset.isDefined() && (laneStopOffset.getPermissions() & SVC_PASSENGER) != 0) {
Expand Down Expand Up @@ -1632,7 +1639,7 @@ GNELane::drawAsWaterway(const GUIVisualizationSettings& s) const {


void
GNELane::drawDirectionIndicators(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
GNELane::drawDirectionIndicators(const GUIVisualizationSettings& s,
const bool drawAsRailway, const bool spreadSuperposed) const {
// Draw direction indicators if the correspondient option is enabled
if (s.showLaneDirection) {
Expand Down Expand Up @@ -1676,7 +1683,7 @@ GNELane::drawDirectionIndicators(const GUIVisualizationSettings& s, const GUIVis


void
GNELane::drawLaneAsRailway(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d) const {
GNELane::drawLaneAsRailway(const GUIVisualizationSettings& s) const {
// we draw the lanes with reduced width so that the lane markings below are visible
// (this avoids artifacts at geometry corners without having to
const bool spreadSuperposed = s.spreadSuperposed && myParentEdge->getNBEdge()->getBidiEdge() != nullptr;
Expand Down Expand Up @@ -1713,12 +1720,12 @@ GNELane::drawLaneAsRailway(const GUIVisualizationSettings& s, const GUIVisualiza
// Draw crossties
GLHelper::drawCrossTies(shape, myLaneGeometry.getShapeRotations(), myLaneGeometry.getShapeLengths(), 0.26 * myDrawingConstants->getExaggeration(), 0.6 * myDrawingConstants->getExaggeration(), halfCrossTieWidth, s.drawForRectangleSelection);
// check if dotted contours has to be drawn
myContour.drawDottedContourExtruded(s, d, shape, halfGauge, 1, true, true, s.dottedContourSettings.segmentWidth);
myContour.drawDottedContourExtruded(s, myDrawingConstants->getDetail(), shape, halfGauge, 1, true, true, s.dottedContourSettings.segmentWidth);
}


void
GNELane::drawTextures(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d) const {
GNELane::drawTextures(const GUIVisualizationSettings& s) const {
// check all conditions for drawing textures
if (!s.disableLaneIcons && (myLaneRestrictedTexturePositions.size() > 0)) {
// Declare default width of icon (3)
Expand Down Expand Up @@ -1750,9 +1757,9 @@ GNELane::drawTextures(const GUIVisualizationSettings& s, const GUIVisualizationS


void
GNELane::drawStartEndGeometryPoints(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d) const {
GNELane::drawStartEndGeometryPoints(const GUIVisualizationSettings& s) const {
// draw a Start/endPoints if lane has a custom shape
if ((d <= GUIVisualizationSettings::Detail::GeometryPoint) && (myParentEdge->getNBEdge()->getLaneStruct(myIndex).customShape.size() > 1)) {
if ((myDrawingConstants->getDetail() <= GUIVisualizationSettings::Detail::GeometryPoint) && (myParentEdge->getNBEdge()->getLaneStruct(myIndex).customShape.size() > 1)) {
// obtain circle width and resolution
const double circleWidth = GNEEdge::SNAP_RADIUS * MIN2((double)1, s.laneWidthExaggeration) / 2;
// obtain custom shape
Expand All @@ -1768,9 +1775,9 @@ GNELane::drawStartEndGeometryPoints(const GUIVisualizationSettings& s, const GUI
// move to shape start position
glTranslated(customShape.front().x(), customShape.front().y(), 0.1);
// draw circle
GLHelper::drawFilledCircleDetailled(d, circleWidth);
GLHelper::drawFilledCircleDetailled(myDrawingConstants->getDetail(), circleWidth);
// draw s depending of detail
if (d <= GUIVisualizationSettings::Detail::Text) {
if (myDrawingConstants->getDetail() <= GUIVisualizationSettings::Detail::Text) {
// move top
glTranslated(0, 0, 0.1);
// draw "S"
Expand All @@ -1793,9 +1800,9 @@ GNELane::drawStartEndGeometryPoints(const GUIVisualizationSettings& s, const GUI
// move to end position
glTranslated(customShape.back().x(), customShape.back().y(), 0.1);
// draw filled circle
GLHelper::drawFilledCircleDetailled(d, circleWidth);
GLHelper::drawFilledCircleDetailled(myDrawingConstants->getDetail(), circleWidth);
// draw "e" depending of detail
if (d <= GUIVisualizationSettings::Detail::Text) {
if (myDrawingConstants->getDetail() <= GUIVisualizationSettings::Detail::Text) {
// move top
glTranslated(0, 0, 0.1);
// draw "E"
Expand Down

0 comments on commit cc03dff

Please sign in to comment.