Skip to content

Commit

Permalink
Now Network elements use checkBoundaryParentElement(). Refs #13894
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Dec 19, 2023
1 parent b1ab211 commit 0707bde
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 46 deletions.
17 changes: 10 additions & 7 deletions src/netedit/elements/network/GNEConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,13 +750,16 @@ GNEConnection::drawEdgeValues(const GUIVisualizationSettings& s, const PositionV
void
GNEConnection::calculateConnectionContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const PositionVector &shape, const double exaggeration) const {
// calculate connection shape contour
myContour.calculateContourExtrudedShape(s, d, shape, s.connectionSettings.connectionWidth, exaggeration, true, true, 0);
// calculate geometry points contour if we're editing shape
if (myShapeEdited) {
myContour.calculateContourGeometryPoints(s, d, shape, GNEContour::GeometryPoint::ALL,
s.neteditSizeSettings.connectionGeometryPointRadius, exaggeration,
s.dottedContourSettings.segmentWidthSmall);
// first check if junction parent was inserted with full boundary
if (!gViewObjectsHandler.checkBoundaryParentElement(this, myFromLane->getParentEdge()->getToJunction())) {
// calculate connection shape contour
myContour.calculateContourExtrudedShape(s, d, shape, s.connectionSettings.connectionWidth, exaggeration, true, true, 0);
// calculate geometry points contour if we're editing shape
if (myShapeEdited) {
myContour.calculateContourGeometryPoints(s, d, shape, GNEContour::GeometryPoint::ALL,
s.neteditSizeSettings.connectionGeometryPointRadius, exaggeration,
s.dottedContourSettings.segmentWidthSmall);
}
}
}

Expand Down
17 changes: 10 additions & 7 deletions src/netedit/elements/network/GNECrossing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,16 @@ GNECrossing::drawCrossingDetailed(const double width, const double exaggeration)
void
GNECrossing::calculateCrossingContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,
const double width, const double exaggeration) const {
// calculate contour
myContour.calculateContourExtrudedShape(s, d, myCrossingGeometry.getShape(), width, exaggeration, true, true, 0);
// check if calculate contour for geometry points
if (myShapeEdited) {
myContour.calculateContourGeometryPoints(s, d, myCrossingGeometry.getShape(), GNEContour::GeometryPoint::ALL,
s.neteditSizeSettings.crossingGeometryPointRadius, exaggeration,
s.dottedContourSettings.segmentWidth);
// first check if junction parent was inserted with full boundary
if (!gViewObjectsHandler.checkBoundaryParentElement(this, myParentJunction)) {
// calculate contour
myContour.calculateContourExtrudedShape(s, d, myCrossingGeometry.getShape(), width, exaggeration, true, true, 0);
// check if calculate contour for geometry points
if (myShapeEdited) {
myContour.calculateContourGeometryPoints(s, d, myCrossingGeometry.getShape(), GNEContour::GeometryPoint::ALL,
s.neteditSizeSettings.crossingGeometryPointRadius, exaggeration,
s.dottedContourSettings.segmentWidth);
}
}
}

Expand Down
21 changes: 11 additions & 10 deletions src/netedit/elements/network/GNELane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1378,17 +1378,18 @@ GNELane::drawLane2LaneConnections() const {

void
GNELane::calculateLaneContour(const GUIVisualizationSettings& s) const {
// calculate contour
myContour.calculateContourExtrudedShape(s, myDrawingConstants->getDetail(), myLaneGeometry.getShape(),
myDrawingConstants->getDrawingWidth(), 1, true, true, myDrawingConstants->getOffset());

// calculate geometry points contour if we're editing shape
if (myShapeEdited) {
myContour.calculateContourGeometryPoints(s, myDrawingConstants->getDetail(), myLaneGeometry.getShape(), GNEContour::GeometryPoint::ALL,
s.neteditSizeSettings.laneGeometryPointRadius, myDrawingConstants->getExaggeration(),
s.dottedContourSettings.segmentWidthSmall);
// first check if edge parent was inserted with full boundary
if (!gViewObjectsHandler.checkBoundaryParentElement(this, myParentEdge)) {
// calculate contour
myContour.calculateContourExtrudedShape(s, myDrawingConstants->getDetail(), myLaneGeometry.getShape(),
myDrawingConstants->getDrawingWidth(), 1, true, true, myDrawingConstants->getOffset());
// calculate geometry points contour if we're editing shape
if (myShapeEdited) {
myContour.calculateContourGeometryPoints(s, myDrawingConstants->getDetail(), myLaneGeometry.getShape(), GNEContour::GeometryPoint::ALL,
s.neteditSizeSettings.laneGeometryPointRadius, myDrawingConstants->getExaggeration(),
s.dottedContourSettings.segmentWidthSmall);
}
}

}


Expand Down
4 changes: 2 additions & 2 deletions src/netedit/elements/network/GNEWalkingArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ GNEWalkingArea::drawGL(const GUIVisualizationSettings& s) const {
// draw dotted contour
myContour.drawDottedContours(s, d, s.dottedContourSettings.segmentWidth, true);
}
// draw dotted contour (except in contour mode)
if (!drawInContourMode()) {
// draw dotted contour (except in contour mode) checking if junction parent was inserted with full boundary
if (!drawInContourMode() && !gViewObjectsHandler.checkBoundaryParentElement(this, myParentJunction)) {
myContour.calculateContourClosedShape(s, d, walkingAreaShape, walkingAreaExaggeration);
}
}
Expand Down
39 changes: 20 additions & 19 deletions src/utils/gui/div/GUIViewObjectsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,16 @@ GUIViewObjectsHandler::isElementSelected(const GUIGlObject* GLObject) const {

bool
GUIViewObjectsHandler::checkBoundaryParentElement(const GUIGlObject* GLObject, const GUIGlObject* parent) {
// first check if we're selecting for boundary
if (!mySelectionBoundary.isInitialised()) {
return false;
}
if (parent == nullptr) {
return false;
}
// try to find parent in seleted object
auto finder = mySelectedObjects.find(parent);
if (finder != mySelectedObjects.end() && finder->second) {
return addElementUnderCursor(GLObject, true);
// if parent was found and was inserted with full boundary, insert it
if (finder != mySelectedObjects.end() && finder->second && !isElementSelected(GLObject)) {
// insert element with full boundary
return addElementUnderCursor(GLObject, false, true);
} else {
return false;
}
Expand All @@ -111,32 +112,32 @@ GUIViewObjectsHandler::checkCircleElement(const GUIVisualizationSettings::Detail
b.grow(radius);
// check if selection boundary contains the centering boundary of object
if (mySelectionBoundary.contains(GLObject->getCenteringBoundary())) {
return addElementUnderCursor(GLObject, true);
return addElementUnderCursor(GLObject, false, true);
}
// check if boundary overlaps
if (mySelectionBoundary.overlapsWith(b)) {
return addElementUnderCursor(GLObject, false);
return addElementUnderCursor(GLObject, false, false);
}
// check if the four boundary vertex are within circle
for (const auto &vertex : mySelectionBoundaryShape) {
if (vertex.distanceSquaredTo2D(center) <= squaredRadius) {
return addElementUnderCursor(GLObject, false);
return addElementUnderCursor(GLObject, false, false);
}
}
// no intersection, then return false
return false;
} else {
// check if center is within mySelectionBoundary
if (mySelectionBoundary.around(center)) {
return addElementUnderCursor(GLObject, false);
return addElementUnderCursor(GLObject, false, false);
} else {
return false;
}
}
} else if (mySelectionPosition != Position::INVALID) {
// check distance between selection position and center
if (mySelectionPosition.distanceSquaredTo2D(center) <= squaredRadius) {
return addElementUnderCursor(GLObject, false);
return addElementUnderCursor(GLObject, false, false);
} else {
return false;
}
Expand All @@ -162,24 +163,24 @@ GUIViewObjectsHandler::checkGeometryPoint(const GUIVisualizationSettings::Detail
b.grow(radius);
// check if selection boundary contains the centering boundary of object
if (mySelectionBoundary.contains(GLObject->getCenteringBoundary())) {
return addElementUnderCursor(GLObject, true);
return addElementUnderCursor(GLObject, true, true);
}
// check if boundary overlaps
if (mySelectionBoundary.overlapsWith(b)) {
return addElementUnderCursor(GLObject, false);
return addElementUnderCursor(GLObject, true, false);
}
// check if the four boundary vertex are within circle
for (const auto &vertex : mySelectionBoundaryShape) {
if (vertex.distanceSquaredTo2D(center) <= squaredRadius) {
return addElementUnderCursor(GLObject, false);
return addElementUnderCursor(GLObject, true, false);
}
}
// no intersection, then return false
return false;
} else {
// check if center is within mySelectionBoundary
if (mySelectionBoundary.around(center)) {
return addElementUnderCursor(GLObject, false);
return addElementUnderCursor(GLObject, true, false);
} else {
return false;
}
Expand Down Expand Up @@ -225,20 +226,20 @@ GUIViewObjectsHandler::checkShapeElement(const GUIVisualizationSettings::Detail
}else if (mySelectionBoundary.isInitialised()) {
// check if selection boundary contains the centering boundary of object
if (mySelectionBoundary.contains(GLObject->getCenteringBoundary())) {
return addElementUnderCursor(GLObject, true);
return addElementUnderCursor(GLObject, false, true);
}
// check if shape crosses to selection boundary
for (int i = 1; i < shape.size(); i++) {
if (mySelectionBoundary.crosses(shape[i-1], shape[i])) {
return addElementUnderCursor(GLObject, false);
return addElementUnderCursor(GLObject, false, false);
}
}
// no intersection, then return false
return false;
} else if (mySelectionPosition != Position::INVALID) {
// check if selection position is around shape
if (shape.around(mySelectionPosition)) {
return addElementUnderCursor(GLObject, false);
return addElementUnderCursor(GLObject, false, false);
} else {
return false;
}
Expand Down Expand Up @@ -308,9 +309,9 @@ GUIViewObjectsHandler::updateFrontElement(const GUIGlObject* GLObject) {


bool
GUIViewObjectsHandler::addElementUnderCursor(const GUIGlObject* GLObject, const bool fullBoundary) {
GUIViewObjectsHandler::addElementUnderCursor(const GUIGlObject* GLObject, const bool checkDuplicated, const bool fullBoundary) {
// first check that object doesn't exist
if (isElementSelected(GLObject)) {
if (checkDuplicated && isElementSelected(GLObject)) {
return false;
} else {
// check if this is an element with an associated layer
Expand Down
2 changes: 1 addition & 1 deletion src/utils/gui/div/GUIViewObjectsHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class GUIViewObjectsHandler {
std::map<const GUIGlObject*, bool> mySelectedObjects;

/// @brief add element into list of elements under cursor
bool addElementUnderCursor(const GUIGlObject* GLObject, const bool fullBoundary);
bool addElementUnderCursor(const GUIGlObject* GLObject, const bool checkDuplicated, const bool fullBoundary);

/// @brief add geometryPoint into list of elements under cursor
bool addGeometryPointUnderCursor(const GUIGlObject* GLObject, const int newIndex);
Expand Down

0 comments on commit 0707bde

Please sign in to comment.