Skip to content

Commit 7f7c024

Browse files
committed
Fixed #16956
1 parent e209ab8 commit 7f7c024

File tree

1 file changed

+41
-7
lines changed

1 file changed

+41
-7
lines changed

src/netedit/elements/network/GNEConnection.cpp

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,51 @@ GNEConnection::updateGeometry() {
7272
// Get shape of from and to lanes
7373
const NBEdge::Connection& nbCon = getNBEdgeConnection();
7474
// obtain lane shapes
75-
const auto& laneShapeFrom = getParentLanes().front()->getLaneShape();
76-
const auto& laneShapeTo = getParentLanes().back()->getLaneShape();
75+
PositionVector laneShapeFrom = getParentLanes().front()->getLaneShape();
76+
PositionVector laneShapeTo = getParentLanes().back()->getLaneShape();
7777
// Calculate shape of connection depending of the size of Junction shape
7878
if (nbCon.customShape.size() > 0) {
7979
myConnectionGeometry.updateGeometry(nbCon.customShape);
8080
} else if (nbCon.shape.size() > 1) {
8181
PositionVector connectionShape;
8282
if ((nbCon.shape.length() < 3) && !nbCon.haveVia) {
83+
// apply offset to lane shape if we're in lane spread function center
84+
if (getParentLanes().front()->getParentEdge()->getNBEdge()->getLaneSpreadFunction() == LaneSpreadFunction::CENTER) {
85+
laneShapeFrom.move2side(0.3);
86+
}
87+
if (getParentLanes().back()->getParentEdge()->getNBEdge()->getLaneSpreadFunction() == LaneSpreadFunction::CENTER) {
88+
laneShapeTo.move2side(0.3);
89+
}
90+
// check if this connetion is a turn around
91+
bool turnAround = false;
92+
const auto fromOppositeEdges = getParentLanes().front()->getParentEdge()->getOppositeEdges();
93+
for (const auto& edge : fromOppositeEdges) {
94+
if (edge == getParentLanes().back()->getParentEdge()) {
95+
turnAround = true;
96+
break;
97+
}
98+
}
99+
// add from lane shape one step before
83100
if (laneShapeFrom.length() > 1) {
84-
connectionShape.push_back(laneShapeFrom.positionAtOffset(laneShapeFrom.length() - 1));
101+
// set lenght depending of turn arounds
102+
if (turnAround) {
103+
connectionShape.push_back(laneShapeFrom.positionAtOffset(laneShapeFrom.length() - 0.5));
104+
} else {
105+
connectionShape.push_back(laneShapeFrom.positionAtOffset(laneShapeFrom.length() - 1));
106+
}
85107
}
108+
// add from lane shape
86109
connectionShape.push_back(laneShapeFrom.back());
110+
// add to lane shape
87111
connectionShape.push_back(laneShapeTo.front());
112+
// add to lane shape one step after
88113
if (laneShapeTo.length() > 1) {
89-
connectionShape.push_back(laneShapeTo.positionAtOffset(1));
114+
// set lenght depending of turn arounds
115+
if (turnAround) {
116+
connectionShape.push_back(laneShapeTo.positionAtOffset(0.5));
117+
} else {
118+
connectionShape.push_back(laneShapeTo.positionAtOffset(1));
119+
}
90120
}
91121
} else {
92122
connectionShape = nbCon.shape;
@@ -711,6 +741,10 @@ GNEConnection::drawConnection(const GUIVisualizationSettings& s, const GUIVisual
711741
RGBColor connectionColor = getConnectionColor(s);
712742
// Push layer matrix
713743
GLHelper::pushMatrix();
744+
// move top if is selected
745+
if (mySelected) {
746+
glTranslated(0, 0, 0.2);
747+
}
714748
// translate to front
715749
if (myNet->getViewNet()->getEditNetworkElementShapes().getEditedNetworkElement() == this) {
716750
drawInLayer(GLO_CONNECTION, 200);
@@ -760,9 +794,9 @@ GNEConnection::drawConnectionArrows(const GUIVisualizationSettings& s, const GUI
760794
GLHelper::setColor(color.changedBrightness(51));
761795
// draw triangles
762796
for (int i = 1; i < (int)superposedGeometry.getShape().size(); i++) {
763-
const auto posA = superposedGeometry.getShape()[i - 1];
764-
const auto posB = superposedGeometry.getShape()[i];
765-
GLHelper::drawTriangleAtEnd(posA, posB, (double) 1, (double) .2);
797+
const auto& posA = superposedGeometry.getShape()[i - 1];
798+
const auto& posB = superposedGeometry.getShape()[i];
799+
GLHelper::drawTriangleAtEnd(posA, posB, (double) .2, (double) .1);
766800
}
767801
// Pop matrix
768802
GLHelper::popMatrix();

0 commit comments

Comments
 (0)