Skip to content

Commit

Permalink
Fixed #15471
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Nov 15, 2024
1 parent e8b3a1c commit 424a984
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNEEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2897,7 +2897,7 @@ GNEEdge::calculateEdgeContour(const GUIVisualizationSettings& s, const GUIVisual
// if we're selecting using a boundary, first don't calculate contour bt check if edge boundary is within selection boundary
if (gViewObjectsHandler.getSelectionBoundary().isInitialised() && gViewObjectsHandler.getSelectionBoundary().contains2D(myEdgeBoundary)) {
// simply add object in ViewObjectsHandler with full boundary
gViewObjectsHandler.selectObject(this, layer, false, true);
gViewObjectsHandler.selectObject(this, layer, false, true, nullptr);
} else {
// get geometry point radius
const auto geometryPointRadius = getGeometryPointRadius();
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,7 @@ GNEJunction::calculateJunctioncontour(const GUIVisualizationSettings& s, const G
// if we're selecting using a boundary, first don't calculate contour bt check if edge boundary is within selection boundary
if (gViewObjectsHandler.getSelectionBoundary().isInitialised() && gViewObjectsHandler.getSelectionBoundary().contains2D(myJunctionBoundary)) {
// simply add object in ViewObjectsHandler with full boundary
gViewObjectsHandler.selectObject(this, getType(), false, true);
gViewObjectsHandler.selectObject(this, getType(), false, true, nullptr);
} else {
// always calculate for shape
myNetworkElementContour.calculateContourClosedShape(s, d, this, myNBNode->getShape(), getType(), exaggeration);
Expand Down
30 changes: 15 additions & 15 deletions src/utils/gui/div/GUIViewObjectsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ GUIViewObjectsHandler::checkBoundaryParentObject(const GUIGlObject* GLObject, co
// try to find parent in seleted object
auto finder = mySelectedObjects.find(parent);
// if parent was found and was inserted with full boundary, insert it
if (finder != mySelectedObjects.end() && finder->second && !isObjectSelected(GLObject)) {
if (finder != mySelectedObjects.end() && finder->second.first && !isObjectSelected(GLObject)) {
// insert element with full boundary
return selectObject(GLObject, layer, false, true);
return selectObject(GLObject, layer, false, true, nullptr);
} else {
return false;
}
Expand All @@ -121,32 +121,32 @@ GUIViewObjectsHandler::checkCircleObject(const GUIVisualizationSettings::Detail
}
// check if selection boundary contains the centering boundary of object
if (mySelectionBoundary.contains2D(GLObject->getCenteringBoundary())) {
return selectObject(GLObject, layer, false, true);
return selectObject(GLObject, layer, false, true, nullptr);
}
// check if boundary overlaps
if (mySelectionBoundary.overlapsWith(circleBoundary)) {
return selectObject(GLObject, layer, false, false);
return selectObject(GLObject, layer, false, false, nullptr);
}
// check if the four boundary vertex are within circle
for (const auto& vertex : mySelectionBoundaryShape) {
if (vertex.distanceSquaredTo2D(center) <= squaredRadius) {
return selectObject(GLObject, layer, false, false);
return selectObject(GLObject, layer, false, false, nullptr);
}
}
// no intersection, then return false
return false;
} else {
// check if center is within mySelectionBoundary
if (mySelectionBoundary.around2D(center)) {
return selectObject(GLObject, layer, false, false);
return selectObject(GLObject, layer, false, false, nullptr);
} else {
return false;
}
}
} else if (mySelectionPosition != Position::INVALID) {
// check distance between selection position and center
if (mySelectionPosition.distanceSquaredTo2D(center) <= squaredRadius) {
return selectObject(GLObject, layer, false, false);
return selectObject(GLObject, layer, false, false, nullptr);
} else {
return false;
}
Expand Down Expand Up @@ -241,20 +241,20 @@ GUIViewObjectsHandler::checkShapeObject(const GUIGlObject* GLObject, const Posit
}
// check if selection boundary contains the centering boundary of object
if (mySelectionBoundary.contains2D(shapeBoundary)) {
return selectObject(GLObject, layer, false, true);
return selectObject(GLObject, layer, false, true, segment);
}
// check if shape crosses to selection boundary
for (int i = 1; i < (int)shape.size(); i++) {
if (mySelectionBoundary.crosses(shape[i - 1], shape[i])) {
return selectObject(GLObject, layer, false, false);
return selectObject(GLObject, layer, false, false, segment);
}
}
// no intersection, then return false
return false;
} else if (mySelectionPosition != Position::INVALID) {
// check if selection position is around shape
if (shape.around(mySelectionPosition)) {
return selectObject(GLObject, layer, false, false);
return selectObject(GLObject, layer, false, false, segment);
} else {
return false;
}
Expand All @@ -265,15 +265,15 @@ GUIViewObjectsHandler::checkShapeObject(const GUIGlObject* GLObject, const Posit


bool
GUIViewObjectsHandler::selectObject(const GUIGlObject* GLObject, const double layer,
const bool checkDuplicated, const bool fullBoundary) {
GUIViewObjectsHandler::selectObject(const GUIGlObject* GLObject, const double layer, const bool checkDuplicated,
const bool fullBoundary, const GNESegment* segment) {
// first check that object doesn't exist
if (checkDuplicated && isObjectSelected(GLObject)) {
return false;
} else {
auto& layerContainer = mySortedSelectedObjects[layer * -1];
layerContainer.insert(layerContainer.begin(), ObjectContainer(GLObject));
mySelectedObjects[GLObject] = fullBoundary;
mySelectedObjects[GLObject] = std::make_pair(fullBoundary, segment);
return true;
}
}
Expand Down Expand Up @@ -302,7 +302,7 @@ GUIViewObjectsHandler::selectGeometryPoint(const GUIGlObject* GLObject, const in
auto& layerContainer = mySortedSelectedObjects[layer * -1];
auto it = layerContainer.insert(layerContainer.begin(), ObjectContainer(GLObject));
it->geometryPoints.push_back(newIndex);
mySelectedObjects[GLObject] = false;
mySelectedObjects[GLObject] = std::make_pair(false, nullptr);
return true;
}

Expand All @@ -329,7 +329,7 @@ GUIViewObjectsHandler::selectPositionOverShape(const GUIGlObject* GLObject, cons
auto& layerContainer = mySortedSelectedObjects[layer * -1];
auto it = layerContainer.insert(layerContainer.begin(), ObjectContainer(GLObject));
it->posOverShape = pos;
mySelectedObjects[GLObject] = false;
mySelectedObjects[GLObject] = std::make_pair(false, nullptr);
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/gui/div/GUIViewObjectsHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class GUIViewObjectsHandler {
/// @{
/// @brief add element into list of elements under cursor
bool selectObject(const GUIGlObject* GLObject, const double layer, const bool checkDuplicated,
const bool fullBoundary);
const bool fullBoundary, const GNESegment* segment);

/// @brief add geometryPoint into list of elements under cursor
bool selectGeometryPoint(const GUIGlObject* GLObject, const int newIndex, const double layer);
Expand Down Expand Up @@ -191,7 +191,7 @@ class GUIViewObjectsHandler {
GLObjectsSortedContainer mySortedSelectedObjects;

/// @brief map with selected elements and if was selected with full boundary (used only to avoid double selections)
std::map<const GUIGlObject*, bool> mySelectedObjects;
std::map<const GUIGlObject*, std::pair<bool, const GNESegment*> > mySelectedObjects;

/// @brief set with path elements marked for redrawing
std::set<const GNEPathElement*> myRedrawPathElements;
Expand Down

0 comments on commit 424a984

Please sign in to comment.