Skip to content

Commit

Permalink
Updated Crossing and WalkingAreas. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent 41c7f32 commit b1d9528
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 33 deletions.
39 changes: 16 additions & 23 deletions src/netedit/elements/network/GNECrossing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,9 @@ GNECrossing::getNBCrossing() const {
void
GNECrossing::drawGL(const GUIVisualizationSettings& s) const {
// declare flag
bool drawLowDetail = false;
bool drawExtremeSymbols = false;
// continue depending of drawCrossing flag
if (checkDrawCrossing(s, drawLowDetail, drawExtremeSymbols)) {
if (checkDrawCrossing(s)) {
// get NBCrossing
const auto NBCrossing = getNBCrossing();
// get scaling depending if attribute carrier is selected
Expand All @@ -224,8 +223,8 @@ GNECrossing::drawGL(const GUIVisualizationSettings& s) const {
const double crossingWidth = NBCrossing->width * 0.5 * selectionScale;
// get detail level
const auto d = s.getDetailLevel(selectionScale);
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// check if draw geometry
if (!s.drawForObjectUnderCursor && (d <= GUIVisualizationSettings::Detail::Crossing)) {
// get color
RGBColor crossingColor = getCrossingColor(s, NBCrossing);
// don't draw crossing in TLS Mode (but draw the TLS links)
Expand All @@ -239,14 +238,19 @@ GNECrossing::drawGL(const GUIVisualizationSettings& s) const {
// set color
GLHelper::setColor(crossingColor);
// draw depending of level of detail
if (drawLowDetail) {
GLHelper::drawBoxLines(myCrossingGeometry.getShape(), crossingWidth);
} else {
if (d <= GUIVisualizationSettings::Detail::CrossingDetails) {
drawCrossingDetailed(selectionScale, crossingWidth);
} else {
GLHelper::drawBoxLines(myCrossingGeometry.getShape(), crossingWidth);
}
// draw shape points only in Network supemode
if (myShapeEdited && myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
s.drawMovingGeometryPoint(selectionScale, s.neteditSizeSettings.crossingGeometryPointRadius)) {
// get edit modes
const auto& editModes = myNet->getViewNet()->getEditModes();
// check if draw start und end
const bool drawExtremeSymbols = editModes.isCurrentSupermodeNetwork() &&
(editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE);
// color
const RGBColor darkerColor = crossingColor.changedBrightness(-32);
// draw geometry points
Expand Down Expand Up @@ -506,31 +510,20 @@ GNECrossing::checkEdgeBelong(const std::vector<GNEEdge*>& edges) const {


bool
GNECrossing::checkDrawCrossing(const GUIVisualizationSettings& s, bool& drawLowDetail, bool& drawExtremeSymbols) const {
// get edit modes
const auto& editModes = myNet->getViewNet()->getEditModes();
// check draw detail
if ((s.scale < 3.0) || s.drawForRectangleSelection) {
drawLowDetail = false;
}
// check if draw start und end
drawExtremeSymbols = editModes.isCurrentSupermodeNetwork() &&
(editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE);
// declare flag for drawing crossing
bool drawCrossing = s.drawCrossingsAndWalkingareas;
GNECrossing::checkDrawCrossing(const GUIVisualizationSettings& s) const {
// don't draw in supermode data
if (myNet->getViewNet()->getEditModes().isCurrentSupermodeData()) {
drawCrossing = false;
return false;
}
// check shape rotations
if (myCrossingGeometry.getShapeRotations().empty()) {
drawCrossing = false;
return false;
}
// check shape lengths
if (myCrossingGeometry.getShapeLengths().empty()) {
drawCrossing = false;
return false;
}
return drawCrossing;
return s.drawCrossingsAndWalkingareas;
}


Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNECrossing.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class GNECrossing : public GNENetworkElement {

private:
/// @brief check if draw crossing
bool checkDrawCrossing(const GUIVisualizationSettings& s, bool &drawLowDetail, bool &drawExtremeSymbols) const;
bool checkDrawCrossing(const GUIVisualizationSettings& s) const;

/// @brief get crossing color
RGBColor getCrossingColor(const GUIVisualizationSettings& s, const NBNode::Crossing* crossing) const;
Expand Down
34 changes: 25 additions & 9 deletions src/netedit/elements/network/GNEWalkingArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,12 @@ GNEWalkingArea::drawGL(const GUIVisualizationSettings& s) const {
// get walking area shape
const auto& walkingAreaShape = myParentJunction->getNBNode()->getWalkingArea(getID()).shape;
// only continue if exaggeration is greater than 0 and junction's shape is greater than 4
if ((myParentJunction->getNBNode()->getShape().area() > 4) && (walkingAreaShape.size() > 0) && s.drawCrossingsAndWalkingareas) {
if ((myParentJunction->getNBNode()->getShape().area() > 4) &&
(walkingAreaShape.size() > 0) && s.drawCrossingsAndWalkingareas) {
// get detail level
const auto d = s.getDetailLevel(1);
const auto d = s.getDetailLevel(walkingAreaExaggeration);
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
if (!s.drawForObjectUnderCursor && (d <= GUIVisualizationSettings::Detail::WalkingArea)) {
// set shape color
const RGBColor walkingAreaColor = myShapeEdited ? s.colorSettings.editShapeColor : isAttributeCarrierSelected() ? RGBColor::BLUE : s.junctionColorer.getScheme().getColor(6);
// adjust shape to exaggeration
Expand All @@ -169,11 +170,10 @@ GNEWalkingArea::drawGL(const GUIVisualizationSettings& s) const {
myTesselation.myTesselation.clear();
}
// check if draw walking area tesselated or contour
if (myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
(myNet->getViewNet()->getEditModes().networkEditMode != NetworkEditMode::NETWORK_MOVE)) {
drawTesselatedWalkingArea(s, d, walkingAreaExaggeration, walkingAreaColor);
} else {
if (drawInContourMode()) {
drawContourWalkingArea(s, walkingAreaShape, walkingAreaExaggeration, walkingAreaColor);
} else {
drawTesselatedWalkingArea(s, d, walkingAreaExaggeration, walkingAreaColor);
}
// draw walkingArea name
if (s.cwaEdgeName.show(this)) {
Expand Down Expand Up @@ -321,6 +321,22 @@ GNEWalkingArea::getACParametersMap() const {
// private
// ===========================================================================

bool
GNEWalkingArea::drawInContourMode() const {
const auto &modes = myNet->getViewNet()->getEditModes();
// check modes
if (!modes.isCurrentSupermodeNetwork()) {
return false;
} else if (modes.networkEditMode != NetworkEditMode::NETWORK_MOVE) {
return false;
} else if (modes.networkEditMode != NetworkEditMode::NETWORK_CONNECT) {
return false;
} else {
return true;
}
}


void
GNEWalkingArea::drawTesselatedWalkingArea(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const double exaggeration, const RGBColor& color) const {
Expand All @@ -335,15 +351,15 @@ GNEWalkingArea::drawTesselatedWalkingArea(const GUIVisualizationSettings& s, con
// set color
GLHelper::setColor(color);
// check if draw polygon or tesselation
if (true /*temporal */) {
if (d <= GUIVisualizationSettings::Detail::WalkingAreaDetails) {
// draw shape with high detail
myTesselation.drawTesselation(myTesselation.getShape());
} else {
// draw shape
GLHelper::drawFilledPoly(myTesselation.getShape(), true);
}
// draw shape points only in Network supemode
if (myShapeEdited && s.drawMovingGeometryPoint(1, s.neteditSizeSettings.crossingGeometryPointRadius) && myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
if (myShapeEdited && s.drawMovingGeometryPoint(1, s.neteditSizeSettings.crossingGeometryPointRadius)) {
// color
const RGBColor darkerColor = color.changedBrightness(-32);
// draw geometry points
Expand Down
3 changes: 3 additions & 0 deletions src/netedit/elements/network/GNEWalkingArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ class GNEWalkingArea : public GNENetworkElement {
GNEContour myInnenContour;

private:
/// @brief check if draw walking area in contour mode
bool drawInContourMode() const;

/// @brief draw tesselated walking area
void drawTesselatedWalkingArea(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const double exaggeration, const RGBColor& color) const;
Expand Down
4 changes: 4 additions & 0 deletions src/utils/gui/settings/GUIVisualizationSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,13 +547,17 @@ class GUIVisualizationSettings {
LaneDetails = 0, // offset, icons, indicators...
Text = 0,
VehiclePoly = 0,
CrossingDetails = 0,
WalkingAreaDetails = 0,

Level1 = 1, // circle resolution = 8, polygons, no lane details
CircleResolution16 = 1,
DrawPolygon = 1,
VehicleBox = 1,
AdditionalDetails = 1, // stoppingPlace signs, EntryExit arrows...
GeometryPoint = 1,
Crossing = 1,
WalkingArea = 1,

Level2 = 2, // circle as squares, squares instead polygons, no text, no geometry points and no junction/lane paths
CircleResolution8 = 2,
Expand Down

0 comments on commit b1d9528

Please sign in to comment.