Skip to content

Commit

Permalink
Fixed #15978
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Jan 14, 2025
1 parent a7e2e1e commit f3214c4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/netedit/GNENet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ void
GNENet::mergeJunctions(GNEJunction* moved, GNEJunction* target, GNEUndoList* undoList) {
undoList->begin(moved, TL("merge junctions"));
// place moved junction in the same position of target junction
moved->setAttribute(SUMO_ATTR_POSITION, target->getAttribute(SUMO_ATTR_POSITION), undoList);
moved->setAttribute(GNE_ATTR_POSITION_MERGED, target->getAttribute(SUMO_ATTR_POSITION), undoList);
// deleting edges changes in the underlying EdgeVector so we have to make a copy
const EdgeVector incomingNBEdges = moved->getNBNode()->getIncomingEdges();
for (const auto& incomingNBEdge : incomingNBEdges) {
Expand Down
15 changes: 15 additions & 0 deletions src/netedit/elements/network/GNEJunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,21 @@ GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList
GNEChange_Attribute::changeAttribute(this, key, value, undoList, true);
break;
case SUMO_ATTR_POSITION: {
// parse position
const Position newPosition = GNEAttributeCarrier::parse<Position>(value);
// retrieve all junctions placed in this position
myNet->getViewNet()->updateObjectsInPosition(newPosition);
for (const auto& junction : myNet->getViewNet()->getViewObjectsSelector().getJunctions()) {
// check distance position
if ((junction != this) && (junction->getPositionInView().distanceTo2D(newPosition) < POSITION_EPS) &&
myNet->getViewNet()->askMergeJunctions(this, junction)) {
myNet->mergeJunctions(this, junction, undoList);
break;
}
}
// note: in this point we don't need a break because we jump directly to setting the position merged
}
case GNE_ATTR_POSITION_MERGED: {
// change Keep Clear attribute in all connections
undoList->begin(this, TL("change junction position"));
// obtain NBNode position
Expand Down
27 changes: 0 additions & 27 deletions src/netedit/frames/GNEAttributesEditorRow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,31 +767,4 @@ GNEAttributesEditorRow::isAttributeEnabled(const GNEAttributeProperties& attrPro
}
}

/*
bool
GNEAttributesEditorRow::mergeJunction(SumoXMLAttr attr, const std::string& newVal) const {
const auto viewNet = myAttributesEditorParent->getFrameParent()->getViewNet();
const auto& inspectedElements = viewNet->getInspectedElements();
// check if we're editing junction position
if (inspectedElements.isInspectingSingleElement() && (inspectedElements.getFirstAC()->getTagProperty().getTag() == SUMO_TAG_JUNCTION) && (attr == SUMO_ATTR_POSITION)) {
// retrieve original junction
GNEJunction* movedJunction = viewNet->getNet()->getAttributeCarriers()->retrieveJunction(inspectedElements.getFirstAC()->getID());
// parse position
const Position newPosition = GNEAttributeCarrier::parse<Position>(newVal);
// iterate over network junction
for (const auto& targetjunction : viewNet->getNet()->getAttributeCarriers()->getJunctions()) {
// check distance position
if ((targetjunction.second->getPositionInView().distanceTo2D(newPosition) < POSITION_EPS) &&
viewNet->askMergeJunctions(movedJunction, targetjunction.second)) {
viewNet->getNet()->mergeJunctions(movedJunction, targetjunction.second, viewNet->getUndoList());
return true;
}
}
}
// nothing to merge
return false;
}
*/


/****************************************************************************/
1 change: 1 addition & 0 deletions src/utils/xml/SUMOXMLDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,7 @@ SequentialStringBijection::Entry SUMOXMLDefinitions::attrs[] = {
{ "tazCentroid", GNE_ATTR_TAZ_CENTROID },
{ "terminate", GNE_ATTR_FLOW_TERMINATE },
{ "spacing", GNE_ATTR_FLOW_SPACING },
{ "positionMerged", GNE_ATTR_POSITION_MERGED},
// mapped to additional elements on writing
{ "fromBusStop", GNE_ATTR_FROM_BUSSTOP },
{ "fromTrainStop", GNE_ATTR_FROM_TRAINSTOP },
Expand Down
2 changes: 2 additions & 0 deletions src/utils/xml/SUMOXMLDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,8 @@ enum SumoXMLAttr {
GNE_ATTR_FLOW_TERMINATE,
/// @brief flow spacing
GNE_ATTR_FLOW_SPACING,
/// @brief position merged (used in netedit for junctions)
GNE_ATTR_POSITION_MERGED,
// virtual attributes for easier UI
GNE_ATTR_FROM_BUSSTOP,
GNE_ATTR_FROM_TRAINSTOP,
Expand Down

0 comments on commit f3214c4

Please sign in to comment.