Skip to content

Commit

Permalink
Refactored GNELane. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 5866b6f commit b7e1388
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 262 deletions.
2 changes: 1 addition & 1 deletion src/netedit/GNEViewNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5414,7 +5414,7 @@ GNEViewNet::drawTemporalSplitJunction() const {
const auto laneDrawingConstants = GNELane::LaneDrawingConstants(*myVisualizationSettings, lane);
auto shape = lane->getLaneShape();
// move shape to side
shape.move2side(laneDrawingConstants.halfWidth * -1);
shape.move2side(laneDrawingConstants.width * -1);
const auto offset = shape.nearest_offset_to_point2D(snapToActiveGrid(getPositionInformation()));
const auto splitPosition = shape.positionAtOffset2D(offset);
// get junction exaggeration
Expand Down
8 changes: 4 additions & 4 deletions src/netedit/elements/GNEContour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,14 @@ GNEContour::buildDottedContourEdge(const GUIVisualizationSettings& s, const GNEE
GNELane::LaneDrawingConstants laneDrawingConstantsBot(s, botLane);
// check shapes and widths
if ((myCachedShapes->at(0) != topLane->getLaneGeometry().getShape()) ||
(myCachedDoubles->at(0) != (laneDrawingConstantsTop.halfWidth * laneDrawingConstantsTop.exaggeration)) ||
(myCachedDoubles->at(0) != (laneDrawingConstantsTop.width * laneDrawingConstantsTop.exaggeration)) ||
(myCachedShapes->at(1) != botLane->getLaneGeometry().getShape()) ||
(myCachedDoubles->at(1) != (laneDrawingConstantsBot.halfWidth * laneDrawingConstantsBot.exaggeration))) {
(myCachedDoubles->at(1) != (laneDrawingConstantsBot.width * laneDrawingConstantsBot.exaggeration))) {
// update cached values
myCachedShapes->at(0) = topLane->getLaneGeometry().getShape();
myCachedDoubles->at(0) = (laneDrawingConstantsTop.halfWidth * laneDrawingConstantsTop.exaggeration);
myCachedDoubles->at(0) = (laneDrawingConstantsTop.width * laneDrawingConstantsTop.exaggeration);
myCachedShapes->at(1) = botLane->getLaneGeometry().getShape();
myCachedDoubles->at(1) = (laneDrawingConstantsBot.halfWidth * laneDrawingConstantsBot.exaggeration);
myCachedDoubles->at(1) = (laneDrawingConstantsBot.width * laneDrawingConstantsBot.exaggeration);
// create top and bot geometries
myDottedGeometries->at(0) = GUIDottedGeometry(s, myCachedShapes->at(0), false, true);
myDottedGeometries->at(2) = GUIDottedGeometry(s, myCachedShapes->at(1).reverse(), false, true);
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/elements/demand/GNEStopPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ GNEStopPlan::updateGeometry() {
GNELane::LaneDrawingConstants laneDrawingConstantsFront(myNet->getViewNet()->getVisualisationSettings(), frontLane);
GNELane::LaneDrawingConstants laneDrawingConstantBack(myNet->getViewNet()->getVisualisationSettings(), backLane);
// calculate front position
const Position frontPosition = frontLane->getLaneShape().positionAtOffset2D(getAttributeDouble(GNE_ATTR_PLAN_GEOMETRY_ENDPOS), laneDrawingConstantsFront.halfWidth);
const Position frontPosition = frontLane->getLaneShape().positionAtOffset2D(getAttributeDouble(GNE_ATTR_PLAN_GEOMETRY_ENDPOS), laneDrawingConstantsFront.width);
// calulate length between both shapes
const double length = backLane->getLaneShape().distance2D(frontPosition, true);
// calculate back position
const Position backPosition = frontLane->getLaneShape().positionAtOffset2D(getAttributeDouble(GNE_ATTR_PLAN_GEOMETRY_ENDPOS), (length + laneDrawingConstantBack.halfWidth - laneDrawingConstantsFront.halfWidth) * -1);
const Position backPosition = frontLane->getLaneShape().positionAtOffset2D(getAttributeDouble(GNE_ATTR_PLAN_GEOMETRY_ENDPOS), (length + laneDrawingConstantBack.width - laneDrawingConstantsFront.width) * -1);
// update demand element geometry using both positions
myDemandElementGeometry.updateGeometry({frontPosition, backPosition});
}
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/elements/network/GNEEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2672,7 +2672,7 @@ GNEEdge::drawLaneStopOffset(const GUIVisualizationSettings& s, GUIVisualizationS
}
if (myNBEdge->myEdgeStopOffset.isDefined() && (myNBEdge->myEdgeStopOffset.getPermissions() & SVC_PASSENGER) != 0) {
for (const auto& lane : getLanes()) {
lane->drawLaneStopOffset(s, myNBEdge->myEdgeStopOffset.getOffset());
lane->drawLaneStopOffset(s, d);
}
}
// Push stopOffset matrix
Expand Down Expand Up @@ -2764,7 +2764,7 @@ GNEEdge::drawTAZElements(const GUIVisualizationSettings& s) const {
}
// draw as box lines
GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(),
lane->getLaneGeometry(), laneDrawingConstants.halfWidth);
lane->getLaneGeometry(), laneDrawingConstants.width);
// Pop layer matrix
GLHelper::popMatrix();
}
Expand Down

0 comments on commit b7e1388

Please sign in to comment.