Skip to content

Commit

Permalink
Updated drawing of custom shapes. Refs #14858
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Sep 9, 2024
1 parent 13634ef commit 63d9091
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
17 changes: 13 additions & 4 deletions src/netedit/elements/network/GNEConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,16 @@ GNEConnection::drawGL(const GUIVisualizationSettings& s) const {
drawConnection(s, d, shapeSuperposed, connectionExaggeration);
// draw lock icon
GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), getPositionInView(), 0.1);
// draw dotted contour
myNetworkElementContour.drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
// draw dotted contour depending if we're editing the custom shape
const GNENetworkElement* editedNetworkElement = myNet->getViewNet()->getEditNetworkElementShapes().getEditedNetworkElement();
if (editedNetworkElement && (editedNetworkElement == this)) {
// draw dotted contour geometry points
myNetworkElementContour.drawDottedContourGeometryPoints(s, d, this, shapeSuperposed, s.neteditSizeSettings.connectionGeometryPointRadius,
connectionExaggeration, s.dottedContourSettings.segmentWidthSmall);
} else {
// draw dotted contour
myNetworkElementContour.drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
}
}
// calculate contour
calculateConnectionContour(s, d, shapeSuperposed, connectionExaggeration);
Expand Down Expand Up @@ -789,12 +797,13 @@ GNEConnection::calculateConnectionContour(const GUIVisualizationSettings& s, con
const PositionVector& shape, const double exaggeration) const {
// first check if junction parent was inserted with full boundary
if (!gViewObjectsHandler.checkBoundaryParentElement(this, myFromLane->getParentEdge()->getToJunction())) {
// calculate connection shape contour
myNetworkElementContour.calculateContourExtrudedShape(s, d, this, shape, s.connectionSettings.connectionWidth, exaggeration, true, true, 0);
// calculate geometry points contour if we're editing shape
if (myShapeEdited) {
myNetworkElementContour.calculateContourAllGeometryPoints(s, d, this, shape, s.neteditSizeSettings.connectionGeometryPointRadius,
exaggeration, true);
} else {
// calculate connection shape contour
myNetworkElementContour.calculateContourExtrudedShape(s, d, this, shape, s.connectionSettings.connectionWidth, exaggeration, true, true, 0);
}
}
}
Expand Down
23 changes: 19 additions & 4 deletions src/netedit/elements/network/GNECrossing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,16 @@ GNECrossing::drawGL(const GUIVisualizationSettings& s) const {
}
// draw lock icon
GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), getPositionInView(), 1);
// draw dotted contour
myNetworkElementContour.drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
// draw dotted contour depending if we're editing the custom shape
const GNENetworkElement* editedNetworkElement = myNet->getViewNet()->getEditNetworkElementShapes().getEditedNetworkElement();
if (editedNetworkElement && (editedNetworkElement == this)) {
// draw dotted contour geometry points
myNetworkElementContour.drawDottedContourGeometryPoints(s, d, this, myCrossingGeometry.getShape(), s.neteditSizeSettings.crossingGeometryPointRadius,
crossingExaggeration, s.dottedContourSettings.segmentWidthSmall);
} else {
// draw dotted contour
myNetworkElementContour.drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
}
}
// calculate contour
calculateCrossingContour(s, d, crossingWidth, crossingExaggeration);
Expand Down Expand Up @@ -549,6 +557,12 @@ GNECrossing::drawCrossing(const GUIVisualizationSettings& s, const GUIVisualizat
s.drawMovingGeometryPoint(exaggeration, s.neteditSizeSettings.crossingGeometryPointRadius)) {
// color
const RGBColor darkerColor = crossingColor.changedBrightness(-32);
// draw on top of of the white area between the rails
glTranslated(0, 0, 0.2);
// set color
GLHelper::setColor(darkerColor);
// draw shape
GUIGeometry::drawGeometry(d, myCrossingGeometry.getShape(), s.neteditSizeSettings.crossingGeometryPointRadius * 0.4);
// draw geometry points
GUIGeometry::drawGeometryPoints(d, myCrossingGeometry.getShape(), darkerColor,
s.neteditSizeSettings.crossingGeometryPointRadius, exaggeration,
Expand Down Expand Up @@ -615,13 +629,14 @@ GNECrossing::calculateCrossingContour(const GUIVisualizationSettings& s, const G
const double width, const double exaggeration) const {
// first check if junction parent was inserted with full boundary
if (!gViewObjectsHandler.checkBoundaryParentElement(this, myParentJunction)) {
// calculate contour
myNetworkElementContour.calculateContourExtrudedShape(s, d, this, myCrossingGeometry.getShape(), width, exaggeration, true, true, 0);
// check if calculate contour for geometry points
if (myShapeEdited) {
myNetworkElementContour.calculateContourAllGeometryPoints(s, d, this, myCrossingGeometry.getShape(),
s.neteditSizeSettings.crossingGeometryPointRadius,
exaggeration, true);
} else {
// calculate contour
myNetworkElementContour.calculateContourExtrudedShape(s, d, this, myCrossingGeometry.getShape(), width, exaggeration, true, true, 0);
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/netedit/elements/network/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1711,8 +1711,6 @@ GNEJunction::drawJunctionAsShape(const GUIVisualizationSettings& s, const GUIVis
// draw shape points only in Network supermode
if (myShapeEdited && myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
s.drawMovingGeometryPoint(exaggeration, s.neteditSizeSettings.junctionGeometryPointRadius)) {
// get mouse position
const auto mousePos = myNet->getViewNet()->getPositionInformation();
// set color
const RGBColor darkerColor = junctionShapeColor.changedBrightness(-32);
// calculate geometry
Expand Down

0 comments on commit 63d9091

Please sign in to comment.