Skip to content

Commit

Permalink
Updated GNEJunction. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 87ff2c1 commit c8f6b9f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 31 deletions.
61 changes: 33 additions & 28 deletions src/netedit/elements/network/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ GNEJunction::drawGL(const GUIVisualizationSettings& s) const {
// draw junction name
drawJunctionName(s, detailLevel);
// draw Junction childs
drawJunctionChildren(s);
drawJunctionChildren(s, detailLevel);
// draw path additional elements
myNet->getPathManager()->drawJunctionPathElements(s, detailLevel, this);
}
Expand Down Expand Up @@ -1656,12 +1656,14 @@ GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s, GUIVisualiza
if (d <= GUIVisualizationSettings::DetailLevel::Level0) {
// draw shape with high detail
myTesselation.drawTesselation(myTesselation.getShape());
} else if (d < GUIVisualizationSettings::DetailLevel::Level1) {
} else if (d <= GUIVisualizationSettings::DetailLevel::Level1) {
// draw shape
GLHelper::drawFilledPoly(myTesselation.getShape(), true);
GLHelper::drawFilledPoly(myNBNode->getShape(), true);
} else {
// draw boundary
GLHelper::drawFilledPoly(myTesselation.getShape().getBoxBoundary().getShape(true), true);
// get shape boundary
const auto boundary = myNBNode->getShape().getBoxBoundary();
// draw rectangle
GLHelper::drawRectangle(myNBNode->getCenter(), boundary.getWidth(), boundary.getHeight());
}
// draw shape points only in Network supermode
if (myShapeEdited && myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
Expand Down Expand Up @@ -1701,7 +1703,7 @@ GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s, GUIVisualiza
void
GNEJunction::drawTLSIcon(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const {
// draw TLS icon if isn't being drawn for selecting
if ((d <= GUIVisualizationSettings::DetailLevel::Level4) && myNBNode->isTLControlled() &&
if ((d <= GUIVisualizationSettings::DetailLevel::Level3) && myNBNode->isTLControlled() &&
(myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_TLS) &&
!myAmTLSSelected && !s.drawForRectangleSelection) {
GLHelper::pushMatrix();
Expand Down Expand Up @@ -1729,29 +1731,32 @@ GNEJunction::drawJunctionName(const GUIVisualizationSettings& s, GUIVisualizatio


void
GNEJunction::drawJunctionChildren(const GUIVisualizationSettings& s) const {
// draw crossings
for (const auto& crossing : myGNECrossings) {
crossing->drawGL(s);
}
// draw walkingAreas
for (const auto& walkingArea : myGNEWalkingAreas) {
walkingArea->drawGL(s);
}
// draw internalLanes
for (const auto& internalLanes : myInternalLanes) {
internalLanes->drawGL(s);
}
// draw connections and route elements connections (Only for incoming edges)
for (const auto& incomingEdge : myGNEIncomingEdges) {
for (const auto& connection : incomingEdge->getGNEConnections()) {
connection->drawGL(s);
GNEJunction::drawJunctionChildren(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const {
// check detail level
if (d <= GUIVisualizationSettings::DetailLevel::Level2) {
// draw crossings
for (const auto& crossing : myGNECrossings) {
crossing->drawGL(s);
}
}
// draw child demand elements
for (const auto& demandElement : getChildDemandElements()) {
if (!demandElement->getTagProperty().isPlacedInRTree()) {
demandElement->drawGL(s);
// draw walkingAreas
for (const auto& walkingArea : myGNEWalkingAreas) {
walkingArea->drawGL(s);
}
// draw internalLanes
for (const auto& internalLanes : myInternalLanes) {
internalLanes->drawGL(s);
}
// draw connections and route elements connections (Only for incoming edges)
for (const auto& incomingEdge : myGNEIncomingEdges) {
for (const auto& connection : incomingEdge->getGNEConnections()) {
connection->drawGL(s);
}
}
// draw child demand elements
for (const auto& demandElement : getChildDemandElements()) {
if (!demandElement->getTagProperty().isPlacedInRTree()) {
demandElement->drawGL(s);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNEJunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ class GNEJunction : public GNENetworkElement, public GNECandidateElement {
void drawJunctionName(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const;

/// @brief draw junction childs
void drawJunctionChildren(const GUIVisualizationSettings& s) const;
void drawJunctionChildren(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const;

/// @brief method for setting the attribute and nothing else (used in GNEChange_Attribute)
void setAttribute(SumoXMLAttr key, const std::string& value);
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNELane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ GNELane::drawLane(const GUIVisualizationSettings& s, GUIVisualizationSettings::D
} else {
GLHelper::drawLine(myLaneGeometry.getShape());
}
} else if ((d <= GUIVisualizationSettings::DetailLevel::Level3) && myIndex == 0) {
} else if (myIndex == 0) {
// declare simple shape
const PositionVector simpleShape = {myLaneGeometry.getShape().front(), myLaneGeometry.getShape().back()};
// draw lane as line, depending of myShapeColors
Expand Down
15 changes: 14 additions & 1 deletion src/utils/gui/settings/GUIVisualizationSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2386,7 +2386,20 @@ GUIVisualizationSettings::flippedTextAngle(double objectAngle) const {

GUIVisualizationSettings::DetailLevel
GUIVisualizationSettings::getDetailLevel(const double exaggeration) const {
return GUIVisualizationSettings::DetailLevel::Level0;
// calculate factor
const auto factor = (scale * exaggeration);
// return detail level depending of factor
if (factor >= 10) {
return GUIVisualizationSettings::DetailLevel::Level0;
} else if (factor >= 5) {
return GUIVisualizationSettings::DetailLevel::Level1;
} else if (factor >= 2.5) {
return GUIVisualizationSettings::DetailLevel::Level2;
} else if (factor >= 1.25) {
return GUIVisualizationSettings::DetailLevel::Level3;
} else {
return GUIVisualizationSettings::DetailLevel::Level4;
}
}


Expand Down

0 comments on commit c8f6b9f

Please sign in to comment.