Skip to content

Commit

Permalink
Updated network elements. Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent be55aeb commit 6e89c30
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 197 deletions.
3 changes: 1 addition & 2 deletions src/netedit/elements/network/GNEConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,7 @@ GNEConnection::drawGL(const GUIVisualizationSettings& s) const {
// declare flag to check if push glID
bool pushGLID = true;
if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
myNet->getViewNet()->getNetworkViewOptions().showConnections() &&
s.drawDetail(s.detailSettings.connectionsDemandMode, getExaggeration(s))) {
myNet->getViewNet()->getNetworkViewOptions().showConnections()) {
drawConnection = !myShapeDeprecated;
} else if (myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
if (myNet->getViewNet()->getNetworkViewOptions().showConnections() || isAttributeCarrierSelected()) {
Expand Down
252 changes: 123 additions & 129 deletions src/netedit/elements/network/GNEEdge.cpp

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions src/netedit/elements/network/GNEEdge.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,29 +460,31 @@ class GNEEdge : public GNENetworkElement, public GNECandidateElement {
const std::map<const GNELane*, std::vector<GNEDemandElement*> > getContainersOverEdgeMap() const;

/// @brief draw edge geometry points (note: This function is called by GNELane::drawGL(...)
void drawEdgeGeometryPoints(const GUIVisualizationSettings& s) const;
void drawEdgeGeometryPoints(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const;

/// @brief draw start extreme geometry point
void drawStartGeometryPoint(const GUIVisualizationSettings& scircleWidth, const double circleWidth, const double exaggeration) const;
void drawStartGeometryPoint(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d,
const double circleWidth, const double exaggeration) const;

/// @brief draw end extreme geometry point
void drawEndGeometryPoint(const GUIVisualizationSettings& s, const double circleWidth, const double exaggeration) const;
void drawEndGeometryPoint(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d,
const double circleWidth, const double exaggeration) const;

/// @brief draw edge name
void drawEdgeName(const GUIVisualizationSettings& s) const;
void drawEdgeName(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const;

/// @brief draw edgeStopOffset
void drawLaneStopOffset(const GUIVisualizationSettings& s) const;
void drawLaneStopOffset(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const;

/// @brief draw edge shape (only one line)
void drawEdgeShape(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const;

/// @brief draw children
void drawChildrens(const GUIVisualizationSettings& s) const;

/// @brief draw TAZElements
void drawTAZElements(const GUIVisualizationSettings& s) const;

/// @brief draw edge shape (only one line)
void drawEdgeShape(const GUIVisualizationSettings& s) const;

/// @brief check if draw big geometry points
bool drawBigGeometryPoints() const;

Expand Down
97 changes: 55 additions & 42 deletions src/netedit/elements/network/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ GNEJunction::drawGL(const GUIVisualizationSettings& s) const {
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 All @@ -609,14 +611,14 @@ GNEJunction::drawGL(const GUIVisualizationSettings& s) const {
} else {
// draw junction as shape
if (junctionShape) {
drawJunctionAsShape(s, junctionExaggeration, mousePosition);
drawJunctionAsShape(s, detailLevel, junctionExaggeration, mousePosition);
}
// draw junction as bubble
if (junctionBubble) {
drawJunctionAsBubble(s, junctionExaggeration, mousePosition);
drawJunctionAsBubble(s, detailLevel, junctionExaggeration, mousePosition);
}
// draw TLS
drawTLSIcon(s);
drawTLSIcon(s, detailLevel);
// draw elevation
if (!s.drawForRectangleSelection && myNet->getViewNet()->getNetworkViewOptions().editingElevation()) {
GLHelper::pushMatrix();
Expand All @@ -633,13 +635,8 @@ GNEJunction::drawGL(const GUIVisualizationSettings& s) const {
GLHelper::popName();
// draw lock icon
GNEViewNetHelper::LockIcon::drawLockIcon(this, getType(), getPositionInView(), 1);
// draw name and ID
if (!s.drawForRectangleSelection) {
drawName(myNBNode->getPosition(), s.scale, s.junctionID);
if (s.junctionName.show(this) && myNBNode->getName() != "") {
GLHelper::drawTextSettings(s.junctionName, myNBNode->getName(), myNBNode->getPosition(), s.scale, s.angle);
}
}
// draw junction name
drawJunctionName(s, detailLevel);
// draw Junction childs
drawJunctionChildren(s);
// draw path additional elements
Expand Down Expand Up @@ -1591,41 +1588,38 @@ GNEJunction::drawAsBubble(const GUIVisualizationSettings& s) const {


void
GNEJunction::drawJunctionAsBubble(const GUIVisualizationSettings& s,
GNEJunction::drawJunctionAsBubble(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d,
const double junctionExaggeration, const Position mousePosition) const {
// calculate bubble radius
const double bubbleRadius = s.neteditSizeSettings.junctionBubbleRadius * junctionExaggeration;
// set bubble color
const RGBColor bubbleColor = setColor(s, true);
// recognize full transparency and simply don't draw
if (bubbleColor.alpha() != 0) {
// push matrix
GLHelper::pushMatrix();
// set color
GLHelper::setColor(bubbleColor);
// move matrix junction center
glTranslated(myNBNode->getPosition().x(), myNBNode->getPosition().y(), 0.1);
// draw filled circle
GLHelper::drawFilledCircle(bubbleRadius, s.getCircleResolution());
// pop matrix
GLHelper::popMatrix();
}
// push matrix
GLHelper::pushMatrix();
// set color
GLHelper::setColor(bubbleColor);
// move matrix junction center
glTranslated(myNBNode->getPosition().x(), myNBNode->getPosition().y(), 0.1);
// draw filled circle
GLHelper::drawFilledCircleDetailled(d, bubbleRadius);
// pop matrix
GLHelper::popMatrix();
}


void
GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s,
GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d,
const double junctionExaggeration, const Position mousePosition) const {
// check if draw start und end
const bool drawExtremeSymbols = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE;
// set shape color
const RGBColor junctionShapeColor = setColor(s, false);
// recognize full transparency and simply don't draw
if (junctionShapeColor.alpha() != 0) {
// check if draw tesselation or or polygon
if (d <= GUIVisualizationSettings::DetailLevel::Level3) {
// check if draw start und end
const bool drawExtremeSymbols = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE;
// set shape color
const RGBColor junctionShapeColor = setColor(s, false);
// set color
GLHelper::setColor(junctionShapeColor);
// adjust shape to exaggeration
// adjust shape to exaggeration (check)
if ((junctionExaggeration > 1 || myExaggeration > 1) && junctionExaggeration != myExaggeration) {
myExaggeration = junctionExaggeration;
myTesselation.setShape(myNBNode->getShape());
Expand All @@ -1634,15 +1628,21 @@ GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s,
myTesselation.myTesselation.clear();
}
// check if draw tesselation or or polygon
if ((s.scale * junctionExaggeration * myMaxDrawingSize) >= 40) {
if (d <= GUIVisualizationSettings::DetailLevel::Level0) {
// draw shape with high detail
myTesselation.drawTesselation(myTesselation.getShape());
} else {
} else if (d < GUIVisualizationSettings::DetailLevel::Level1) {
// draw shape
GLHelper::drawFilledPoly(myTesselation.getShape(), true);
} else {
// draw boundary
GLHelper::drawFilledPoly(myTesselation.getShape().getBoxBoundary().getShape(true), true);
}
// draw shape points only in Network supermode
if (myShapeEdited && s.drawMovingGeometryPoint(junctionExaggeration, s.neteditSizeSettings.junctionGeometryPointRadius) && myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork()) {
if (myShapeEdited && myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
s.drawMovingGeometryPoint(junctionExaggeration, s.neteditSizeSettings.junctionGeometryPointRadius)) {
// get mouse position
const auto mousePos = myNet->getViewNet()->getPositionInformation();
// set color
const RGBColor darkerColor = junctionShapeColor.changedBrightness(-32);
// calculate geometry
Expand All @@ -1658,14 +1658,14 @@ GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s,
// set color
GLHelper::setColor(darkerColor);
// draw shape
GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), junctionGeometry, s.neteditSizeSettings.junctionGeometryPointRadius * 0.5);
GUIGeometry::drawGeometry(s, mousePos, junctionGeometry, s.neteditSizeSettings.junctionGeometryPointRadius * 0.5);
// draw geometry points
GUIGeometry::drawGeometryPoints(s, this, myNet->getViewNet()->getPositionInformation(), junctionOpenShape, darkerColor, RGBColor::BLACK,
GUIGeometry::drawGeometryPoints(s, this, mousePos, junctionOpenShape, darkerColor, RGBColor::BLACK,
s.neteditSizeSettings.junctionGeometryPointRadius, junctionExaggeration,
myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
// draw moving hint
if (myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_MOVE) {
GUIGeometry::drawMovingHint(s, this, myNet->getViewNet()->getPositionInformation(), junctionOpenShape, darkerColor,
GUIGeometry::drawMovingHint(s, this, mousePos, junctionOpenShape, darkerColor,
s.neteditSizeSettings.junctionGeometryPointRadius, junctionExaggeration);
}
}
Expand All @@ -1674,10 +1674,11 @@ GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s,


void
GNEJunction::drawTLSIcon(const GUIVisualizationSettings& s) const {
GNEJunction::drawTLSIcon(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const {
// draw TLS icon if isn't being drawn for selecting
if ((myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_TLS) &&
(myNBNode->isTLControlled()) && !myAmTLSSelected && !s.drawForRectangleSelection) {
if ((d <= GUIVisualizationSettings::DetailLevel::Level4) && myNBNode->isTLControlled() &&
(myNet->getViewNet()->getEditModes().networkEditMode == NetworkEditMode::NETWORK_TLS) &&
!myAmTLSSelected && !s.drawForRectangleSelection) {
GLHelper::pushMatrix();
const Position pos = myNBNode->getPosition();
glTranslated(pos.x(), pos.y(), 2.2);
Expand All @@ -1690,6 +1691,18 @@ GNEJunction::drawTLSIcon(const GUIVisualizationSettings& s) const {
}


void
GNEJunction::drawJunctionName(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const {
// draw name and ID
if (d <= GUIVisualizationSettings::DetailLevel::Level3) {
drawName(myNBNode->getPosition(), s.scale, s.junctionID);
if (s.junctionName.show(this) && myNBNode->getName() != "") {
GLHelper::drawTextSettings(s.junctionName, myNBNode->getName(), myNBNode->getPosition(), s.scale, s.angle);
}
}
}


void
GNEJunction::drawJunctionChildren(const GUIVisualizationSettings& s) const {
// draw crossings
Expand Down
9 changes: 6 additions & 3 deletions src/netedit/elements/network/GNEJunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,18 @@ class GNEJunction : public GNENetworkElement, public GNECandidateElement {
bool drawAsBubble(const GUIVisualizationSettings& s) const;

/// @brief draw junction as bubble
void drawJunctionAsBubble(const GUIVisualizationSettings& s,
void drawJunctionAsBubble(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d,
const double junctionExaggeration, const Position mousePosition) const;

/// @brief draw junction as bubble
void drawJunctionAsShape(const GUIVisualizationSettings& s,
void drawJunctionAsShape(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d,
const double junctionExaggeration, const Position mousePosition) const;

/// @brief draw TLS icon
void drawTLSIcon(const GUIVisualizationSettings& s) const;
void drawTLSIcon(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const;

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

/// @brief draw junction childs
void drawJunctionChildren(const GUIVisualizationSettings& s) const;
Expand Down
23 changes: 12 additions & 11 deletions src/netedit/elements/network/GNELane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,8 @@ GNELane::drawGL(const GUIVisualizationSettings& s) const {
const LaneDrawingConstants laneDrawingConstants(s, this);
// draw geometry only if we'rent in drawForObjectUnderCursor mode
if (!s.drawForObjectUnderCursor) {
// get detail level
const auto detailLevel = s.getDetailLevel(laneDrawingConstants.exaggeration);
// get lane color
const RGBColor color = setLaneColor(s);
// get flag for draw lane as railway
Expand Down Expand Up @@ -657,9 +659,9 @@ GNELane::drawGL(const GUIVisualizationSettings& s) const {
drawDirectionIndicators(s, laneDrawingConstants.exaggeration, drawRailway, spreadSuperposed);
}
// draw lane textures
drawTextures(s, laneDrawingConstants);
drawTextures(s, detailLevel, laneDrawingConstants);
// draw start end shape points
drawStartEndShapePoints(s);
drawStartEndShapePoints(s, detailLevel);
}
// draw stopOffsets
const auto& laneStopOffset = myParentEdge->getNBEdge()->getLaneStruct(myIndex).laneStopOffset;
Expand Down Expand Up @@ -1691,11 +1693,10 @@ GNELane::drawLaneAsRailway(const GUIVisualizationSettings& s, const LaneDrawingC


void
GNELane::drawTextures(const GUIVisualizationSettings& s, const LaneDrawingConstants& laneDrawingConstants) const {
GNELane::drawTextures(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d, const LaneDrawingConstants& laneDrawingConstants) const {
// check all conditions for drawing textures
if (!s.drawForRectangleSelection && !s.disableLaneIcons &&
(myLaneRestrictedTexturePositions.size() > 0) &&
s.drawDetail(s.detailSettings.laneTextures, laneDrawingConstants.exaggeration)) {
if (!s.drawForRectangleSelection && !s.disableLaneIcons && (myLaneRestrictedTexturePositions.size() > 0) &&
(d <= GUIVisualizationSettings::DetailLevel::Level2)) {
// Declare default width of icon (3)
double iconWidth = 1;
// Obtain width of icon, if width of lane is different
Expand Down Expand Up @@ -1729,7 +1730,7 @@ GNELane::drawTextures(const GUIVisualizationSettings& s, const LaneDrawingConsta


void
GNELane::drawStartEndShapePoints(const GUIVisualizationSettings& s) const {
GNELane::drawStartEndShapePoints(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const {
// draw a Start/endPoints if lane has a custom shape
if (!s.drawForRectangleSelection && (myParentEdge->getNBEdge()->getLaneStruct(myIndex).customShape.size() > 1)) {
GLHelper::setColor(s.junctionColorer.getSchemes()[0].getColor(2));
Expand All @@ -1744,13 +1745,13 @@ GNELane::drawStartEndShapePoints(const GUIVisualizationSettings& s) const {
// obtain custom shape
const PositionVector& customShape = myParentEdge->getNBEdge()->getLaneStruct(myIndex).customShape;
// draw s depending of detail
if (s.drawDetail(s.detailSettings.geometryPointsText, exaggeration)) {
if (d <= GUIVisualizationSettings::DetailLevel::Level2) {
// push start matrix
GLHelper::pushMatrix();
// move to shape start position
glTranslated(customShape.front().x(), customShape.front().y(), 0.1);
// draw circle
GLHelper::drawFilledCircle(circleWidth, s.getCircleResolution());
GLHelper::drawFilledCircleDetailled(d, circleWidth);
// move top
glTranslated(0, 0, 0.1);
// draw "S"
Expand All @@ -1769,13 +1770,13 @@ GNELane::drawStartEndShapePoints(const GUIVisualizationSettings& s) const {
// pop line matrix
GLHelper::popMatrix();
// draw "e" depending of detail
if (s.drawDetail(s.detailSettings.geometryPointsText, exaggeration)) {
if (d <= GUIVisualizationSettings::DetailLevel::Level2) {
// push start matrix
GLHelper::pushMatrix();
// move to end position
glTranslated(customShape.back().x(), customShape.back().y(), 0.1);
// draw filled circle
GLHelper::drawFilledCircle(circleWidth, s.getCircleResolution());
GLHelper::drawFilledCircleDetailled(d, circleWidth);
// move top
glTranslated(0, 0, 0.1);
// draw "E"
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/elements/network/GNELane.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ class GNELane : public GNENetworkElement, public GNECandidateElement, public FXD
void drawLaneAsRailway(const GUIVisualizationSettings& s, const LaneDrawingConstants& laneDrawingConstants) const;

/// @brief draw lane textures
void drawTextures(const GUIVisualizationSettings& s, const LaneDrawingConstants& laneDrawingConstants) const;
void drawTextures(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d, const LaneDrawingConstants& laneDrawingConstants) const;

/// @brief draw start and end shape points
void drawStartEndShapePoints(const GUIVisualizationSettings& s) const;
void drawStartEndShapePoints(const GUIVisualizationSettings& s, GUIVisualizationSettings::DetailLevel d) const;

/// @brief set color according to edit mode and visualisation settings
RGBColor setLaneColor(const GUIVisualizationSettings& s) const;
Expand Down

0 comments on commit 6e89c30

Please sign in to comment.