Skip to content

Commit

Permalink
fix #16026
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Jan 17, 2025
1 parent e76e7c5 commit 7a8d15c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
31 changes: 27 additions & 4 deletions src/utils/gui/windows/GUISUMOAbstractView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,16 +704,29 @@ GUISUMOAbstractView::displayLegends() {
if (myVisualizationSettings->showSizeLegend) {
displayLegend();
}
std::string key = "";
if (myVisualizationSettings->showColorLegend) {
displayColorLegend(myVisualizationSettings->getLaneEdgeScheme(), false);
auto const& scheme = myVisualizationSettings->getLaneEdgeScheme();
if (scheme.getName() == GUIVisualizationSettings::SCHEME_NAME_EDGEDATA_NUMERICAL) {
key = myVisualizationSettings->edgeData;
} else if (scheme.getName() == GUIVisualizationSettings::SCHEME_NAME_EDGE_PARAM_NUMERICAL) {
key = myVisualizationSettings->edgeParam;
} else if (scheme.getName() == GUIVisualizationSettings::SCHEME_NAME_LANE_PARAM_NUMERICAL) {
key = myVisualizationSettings->laneParam;
}
displayColorLegend(scheme, false, key);
}
if (myVisualizationSettings->showVehicleColorLegend) {
displayColorLegend(myVisualizationSettings->vehicleColorer.getScheme(), true);
auto const& scheme = myVisualizationSettings->vehicleColorer.getScheme();
if (scheme.getName() == GUIVisualizationSettings::SCHEME_NAME_PARAM_NUMERICAL) {
key = myVisualizationSettings->vehicleParam;
}
displayColorLegend(myVisualizationSettings->vehicleColorer.getScheme(), true, key);
}
}

void
GUISUMOAbstractView::displayColorLegend(const GUIColorScheme& scheme, bool leftSide) {
GUISUMOAbstractView::displayColorLegend(const GUIColorScheme& scheme, bool leftSide, const std::string& key) {
// compute the scale bar length
glLineWidth(1.0);
glMatrixMode(GL_PROJECTION);
Expand Down Expand Up @@ -839,7 +852,17 @@ GUISUMOAbstractView::displayColorLegend(const GUIColorScheme& scheme, bool leftS
}
// draw scheme name
std::string name = scheme.getName();
if (StringUtils::startsWith(name, "by ")) {
if (name == GUIVisualizationSettings::SCHEME_NAME_EDGEDATA_NUMERICAL) {
name = "edgeData (" + key + ")";
} else if (name == GUIVisualizationSettings::SCHEME_NAME_EDGE_PARAM_NUMERICAL) {
name = "edgeParam (" + key + ")";
} else if (name == GUIVisualizationSettings::SCHEME_NAME_LANE_PARAM_NUMERICAL) {
name = "laneParam (" + key + ")";
} else if (name == GUIVisualizationSettings::SCHEME_NAME_PARAM_NUMERICAL) {
name = "param (" + key + ")";
} else if (name == GUIVisualizationSettings::SCHEME_NAME_DATA_ATTRIBUTE_NUMERICAL) {
name = "attribute (" + key + ")";
} else if (StringUtils::startsWith(name, "by ")) {
name = name.substr(3);
}
const double topN = -0.8;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/gui/windows/GUISUMOAbstractView.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ class GUISUMOAbstractView : public FXGLCanvas {
void displayLegends();

/// @brief Draws a legend for the given scheme
void displayColorLegend(const GUIColorScheme& scheme, bool leftSide);
void displayColorLegend(const GUIColorScheme& scheme, bool leftSide, const std::string& key);

/// @brief Draws frames-per-second indicator
void drawFPS();
Expand Down

0 comments on commit 7a8d15c

Please sign in to comment.