Skip to content

Commit

Permalink
Reduced calls to lane drawing constants. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent b084f04 commit 21d1da3
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 99 deletions.
3 changes: 1 addition & 2 deletions src/netedit/GNEViewNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5357,10 +5357,9 @@ GNEViewNet::drawTemporalSplitJunction() const {
(gPostDrawing.markedEdge != nullptr)) {
// calculate split position
const auto lane = gPostDrawing.markedEdge->getLanes().back();
const auto laneDrawingConstants = GNELane::LaneDrawingConstants(*myVisualizationSettings, lane);
auto shape = lane->getLaneShape();
// move shape to side
shape.move2side(laneDrawingConstants.width * -1);
shape.move2side(lane->getLaneDrawingConstants()->getWidth() * -1);
const auto offset = shape.nearest_offset_to_point2D(snapToActiveGrid(getPositionInformation()));
const auto splitPosition = shape.positionAtOffset2D(offset);
// get junction exaggeration
Expand Down
7 changes: 2 additions & 5 deletions src/netedit/elements/GNEContour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,12 @@ GNEContour::buildDottedContourEdge(const GUIVisualizationSettings& s, const GNEE
// obtain lanes
const GNELane* topLane = lefthand ? edge->getLanes().front() : edge->getLanes().back();
const GNELane* botLane = lefthand ? edge->getLanes().back() : edge->getLanes().front();
// obtain both LaneDrawingConstants
GNELane::LaneDrawingConstants laneDrawingConstantsTop(s, topLane);
GNELane::LaneDrawingConstants laneDrawingConstantsBot(s, botLane);
// create top and bot geometries
myDottedGeometries->at(0) = GUIDottedGeometry(s, topLane->getLaneGeometry().getShape(), false, true);
myDottedGeometries->at(2) = GUIDottedGeometry(s, botLane->getLaneGeometry().getShape().reverse(), false, true);
// move geometries top and bot
myDottedGeometries->at(0).moveShapeToSide((laneDrawingConstantsTop.width * laneDrawingConstantsTop.exaggeration) * -1);
myDottedGeometries->at(2).moveShapeToSide((laneDrawingConstantsBot.width * laneDrawingConstantsBot.exaggeration) * -1);
myDottedGeometries->at(0).moveShapeToSide(topLane->getLaneDrawingConstants()->getWidth() * topLane->getLaneDrawingConstants()->getExaggeration() * -1);
myDottedGeometries->at(2).moveShapeToSide(botLane->getLaneDrawingConstants()->getWidth() * botLane->getLaneDrawingConstants()->getExaggeration() * -1);
// create left and right geometries
if (drawFirstExtrem) {
myDottedGeometries->at(3) = GUIDottedGeometry(s, {
Expand Down
9 changes: 4 additions & 5 deletions src/netedit/elements/demand/GNEStopPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,14 @@ GNEStopPlan::updateGeometry() {
// get front and back lane
const GNELane* frontLane = getParentEdges().front()->getLanes().front();
const GNELane* backLane = getParentEdges().front()->getLanes().back();
// get lane drawing constants
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.width);
const Position frontPosition = frontLane->getLaneShape().positionAtOffset2D(getAttributeDouble(GNE_ATTR_PLAN_GEOMETRY_ENDPOS),
frontLane->getLaneDrawingConstants()->getWidth());
// 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.width - laneDrawingConstantsFront.width) * -1);
const Position backPosition = frontLane->getLaneShape().positionAtOffset2D(getAttributeDouble(GNE_ATTR_PLAN_GEOMETRY_ENDPOS),
(length + backLane->getLaneDrawingConstants()->getWidth() - frontLane->getLaneDrawingConstants()->getWidth()) * -1);
// update demand element geometry using both positions
myDemandElementGeometry.updateGeometry({frontPosition, backPosition});
}
Expand Down
6 changes: 2 additions & 4 deletions src/netedit/elements/network/GNEEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2751,8 +2751,6 @@ GNEEdge::drawTAZElements(const GUIVisualizationSettings& s) const {
}
// iterate over lanes
for (const auto& lane : myLanes) {
// get lane drawing constants
GNELane::LaneDrawingConstants laneDrawingConstants(s, lane);
// Push layer matrix
GLHelper::pushMatrix();
// translate to front (note: Special case)
Expand All @@ -2772,8 +2770,8 @@ GNEEdge::drawTAZElements(const GUIVisualizationSettings& s) const {
GLHelper::setColor(RGBColor::CYAN);
}
// draw as box lines
GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(),
lane->getLaneGeometry(), laneDrawingConstants.width);
GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), lane->getLaneGeometry(),
lane->getLaneDrawingConstants()->getWidth());
// Pop layer matrix
GLHelper::popMatrix();
}
Expand Down

0 comments on commit 21d1da3

Please sign in to comment.