Skip to content

Commit

Permalink
Updated optimization. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent b7e1388 commit 1237184
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
12 changes: 8 additions & 4 deletions src/netedit/GNEPathManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,10 @@ GNEPathManager::removePath(PathElement* pathElement) {


void
GNEPathManager::drawLanePathElements(const GUIVisualizationSettings& s, const GNELane* lane) const {
if (myLaneSegments.count(lane) > 0) {
GNEPathManager::drawLanePathElements(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d,
const GNELane* lane) const {
// check detail level and lane segments
if ((d <= GUIVisualizationSettings::DetailLevel::Level2) && (myLaneSegments.count(lane) > 0)) {
int numRoutes = 0;
// first draw selected elements (for drawing over other elements)
for (const auto& segment : myLaneSegments.at(lane)) {
Expand Down Expand Up @@ -842,8 +844,10 @@ GNEPathManager::drawLanePathElements(const GUIVisualizationSettings& s, const GN


void
GNEPathManager::drawJunctionPathElements(const GUIVisualizationSettings& s, const GNEJunction* junction) const {
if (myJunctionSegments.count(junction) > 0) {
GNEPathManager::drawJunctionPathElements(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d,
const GNEJunction* junction) const {
// check detail level and junction segments
if ((d <= GUIVisualizationSettings::DetailLevel::Level2) && (myJunctionSegments.count(junction) > 0)) {
// first draw selected elements (for drawing over other elements)
for (const auto& segment : myJunctionSegments.at(junction)) {
if (segment->getPathElement()->isPathElementSelected()) {
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 GNELane* lane) const;
void drawLanePathElements(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d, const GNELane* lane) const;

/// @brief draw junction path elements
void drawJunctionPathElements(const GUIVisualizationSettings& s, const GNEJunction* junction) const;
void drawJunctionPathElements(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d, 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/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,15 +587,15 @@ GNEJunction::drawGL(const GUIVisualizationSettings& s) const {
GLHelper::drawBoundary(s, getCenteringBoundary());
// get junction exaggeration
const double junctionExaggeration = getExaggeration(s);
// get detail level
const auto detailLevel = s.getDetailLevel(junctionExaggeration);
// check if draw junction as shape
const bool junctionShape = ((myNBNode->getShape().size() > 0) && s.drawJunctionShape);
const bool junctionBubble = drawAsBubble(s);
// only continue if exaggeration is greater than 0
if (junctionExaggeration > 0) {
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// get detail level
const auto detailLevel = s.getDetailLevel(junctionExaggeration);
// get mouse position
const Position mousePosition = myNet->getViewNet()->getPositionInformation();
// push junction name
Expand Down Expand Up @@ -640,7 +640,7 @@ GNEJunction::drawGL(const GUIVisualizationSettings& s) const {
// draw Junction childs
drawJunctionChildren(s);
// draw path additional elements
myNet->getPathManager()->drawJunctionPathElements(s, this);
myNet->getPathManager()->drawJunctionPathElements(s, detailLevel, this);
}
// continue depending of shapes
if (junctionShape) {
Expand Down
28 changes: 13 additions & 15 deletions src/netedit/elements/network/GNELane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,10 @@ void
GNELane::drawGL(const GUIVisualizationSettings& s) const {
// get lane drawing constants
const LaneDrawingConstants laneDrawingConstants(s, this);
// get detail level
const auto detailLevel = s.getDetailLevel(laneDrawingConstants.exaggeration);
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// get detail level
const auto detailLevel = s.getDetailLevel(laneDrawingConstants.exaggeration);
// Push edge parent name
GLHelper::pushName(myParentEdge->getGlID());
// Push lane name
Expand Down Expand Up @@ -614,7 +614,7 @@ GNELane::drawGL(const GUIVisualizationSettings& s) const {
// draw children
drawChildren(s);
// draw path additional elements
myNet->getPathManager()->drawLanePathElements(s, this);
myNet->getPathManager()->drawLanePathElements(s, detailLevel, this);
// draw dotted geometry
myContour.drawDottedContourExtruded(s, getLaneShape(), laneDrawingConstants.width, 1, true, true,
s.dottedContourSettings.segmentWidth);
Expand Down Expand Up @@ -1194,10 +1194,10 @@ GNELane::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList)
void
GNELane::drawLane(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d,
const LaneDrawingConstants &laneDrawingConstants) const {
// set lane colors
setLaneColor(s);
// continue depending of detail level
if (d <= GUIVisualizationSettings::DetailLevel::Level2) {
// get lane color
const RGBColor color = setLaneColor(s);
if (d <= GUIVisualizationSettings::DetailLevel::Level1) {
// 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)
Expand Down Expand Up @@ -1236,14 +1236,14 @@ GNELane::drawLane(const GUIVisualizationSettings& s, GUIVisualizationSettings::D
drawShapeEdited(s);
// draw stopOffsets
drawLaneStopOffset(s, d);
} else if (d <= GUIVisualizationSettings::DetailLevel::Level3){
} else if (d <= GUIVisualizationSettings::DetailLevel::Level2){
// draw lane as line, depending of myShapeColors
if (myShapeColors.size() > 0) {
GLHelper::drawLine(myLaneGeometry.getShape(), myShapeColors);
} else {
GLHelper::drawLine(myLaneGeometry.getShape());
}
} else if (myIndex == 0) {
} else if ((d <= GUIVisualizationSettings::DetailLevel::Level3) && myIndex == 0) {
// declare simple shape
const PositionVector simpleShape = {myLaneGeometry.getShape().front(), myLaneGeometry.getShape().back()};
// draw lane as line, depending of myShapeColors
Expand Down Expand Up @@ -1616,9 +1616,7 @@ GNELane::drawDirectionIndicators(const GUIVisualizationSettings& s, GUIVisualiza
// Draw direction indicators if the correspondient option is enabled
if (s.showLaneDirection && (d <= GUIVisualizationSettings::DetailLevel::Level1)) {
// improve visibility of superposed rail edges
if (drawAsRailway) {
setLaneColor(s);
} else {
if (!drawAsRailway) {
glColor3d(0.3, 0.3, 0.3);
}
// get width and sideOffset
Expand Down Expand Up @@ -1701,7 +1699,7 @@ GNELane::drawLaneAsRailway(const GUIVisualizationSettings& s, const LaneDrawingC
void
GNELane::drawTextures(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d, const LaneDrawingConstants& laneDrawingConstants) const {
// check all conditions for drawing textures
if (!s.disableLaneIcons && (d <= GUIVisualizationSettings::DetailLevel::Level2) && (myLaneRestrictedTexturePositions.size() > 0)) {
if (!s.disableLaneIcons && (d <= GUIVisualizationSettings::DetailLevel::Level0) && (myLaneRestrictedTexturePositions.size() > 0)) {
// Declare default width of icon (3)
const double iconWidth = laneDrawingConstants.halfLaneWidth;
// Draw list of icons
Expand Down Expand Up @@ -1733,7 +1731,7 @@ GNELane::drawTextures(const GUIVisualizationSettings& s, GUIVisualizationSetting
void
GNELane::drawStartEndShapePoints(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d, const LaneDrawingConstants& laneDrawingConstants) const {
// draw a Start/endPoints if lane has a custom shape
if ((d <= GUIVisualizationSettings::DetailLevel::Level2) && (myParentEdge->getNBEdge()->getLaneStruct(myIndex).customShape.size() > 1)) {
if ((d <= GUIVisualizationSettings::DetailLevel::Level1) && (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 @@ -1751,7 +1749,7 @@ GNELane::drawStartEndShapePoints(const GUIVisualizationSettings& s, GUIVisualiza
// draw circle
GLHelper::drawFilledCircleDetailled(d, circleWidth);
// draw s depending of detail
if (d <= GUIVisualizationSettings::DetailLevel::Level1) {
if (d <= GUIVisualizationSettings::DetailLevel::Level0) {
// move top
glTranslated(0, 0, 0.1);
// draw "S"
Expand All @@ -1776,7 +1774,7 @@ GNELane::drawStartEndShapePoints(const GUIVisualizationSettings& s, GUIVisualiza
// draw filled circle
GLHelper::drawFilledCircleDetailled(d, circleWidth);
// draw "e" depending of detail
if (d <= GUIVisualizationSettings::DetailLevel::Level1) {
if (d <= GUIVisualizationSettings::DetailLevel::Level0) {
// move top
glTranslated(0, 0, 0.1);
// draw "E"
Expand Down
4 changes: 2 additions & 2 deletions src/utils/gui/settings/GUIVisualizationSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,8 @@ class GUIVisualizationSettings {
enum class DetailLevel : int {
Level0, // All detail (tesselations)
Level1, // circle resolution = 8, polygons, no lane details
Level2, // circle as squares, squares instead polygons, no text
Level3, // no geometry points
Level2, // circle as squares, squares instead polygons, no text, no geometry points and no junction/lane paths
Level3, // minimum number of lanes
Level4,
};

Expand Down

0 comments on commit 1237184

Please sign in to comment.