Skip to content

Commit

Permalink
Updated GNEJunction. Refs #13421
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Jun 15, 2023
1 parent 0461bb7 commit 2950676
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
25 changes: 20 additions & 5 deletions src/netedit/elements/network/GNEJunction.cpp
Expand Up @@ -1034,6 +1034,7 @@ GNEJunction::getAttribute(SumoXMLAttr key) const {
case SUMO_ATTR_ID:
return getMicrosimID();
case SUMO_ATTR_POSITION:
case GNE_ATTR_SINGLE_POSITION:
return toString(myNBNode->getPosition());
case SUMO_ATTR_TYPE:
return toString(myNBNode->getType());
Expand Down Expand Up @@ -1102,6 +1103,7 @@ GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList
switch (key) {
case SUMO_ATTR_ID:
case SUMO_ATTR_POSITION:
case GNE_ATTR_SINGLE_POSITION:
case GNE_ATTR_MODIFICATION_STATUS:
case SUMO_ATTR_SHAPE:
case SUMO_ATTR_RADIUS:
Expand Down Expand Up @@ -1244,6 +1246,7 @@ GNEJunction::isValid(SumoXMLAttr key, const std::string& value) {
case SUMO_ATTR_TYPE:
return SUMOXMLDefinitions::NodeTypes.hasString(value);
case SUMO_ATTR_POSITION:
case GNE_ATTR_SINGLE_POSITION:
return canParse<Position>(value);
case SUMO_ATTR_SHAPE:
// empty shapes are allowed
Expand Down Expand Up @@ -1628,7 +1631,16 @@ GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value) {
}
case SUMO_ATTR_POSITION: {
// set new position in NBNode updating edge boundaries
moveJunctionGeometry(parse<Position>(value), true);
moveJunctionGeometry(parse<Position>(value), true, true);
// mark this connections and all of the junction's Neighbours as deprecated
markConnectionsDeprecated(true);
// update centering boundary and grid
updateCenteringBoundary(true);
break;
}
case GNE_ATTR_SINGLE_POSITION: {
// set new position in NBNode updating edge boundaries
moveJunctionGeometry(parse<Position>(value), false, false);
// mark this connections and all of the junction's Neighbours as deprecated
markConnectionsDeprecated(true);
// update centering boundary and grid
Expand Down Expand Up @@ -1723,7 +1735,7 @@ GNEJunction::setMoveShape(const GNEMoveResult& moveResult) {
// set new shape
myNBNode->setCustomShape(moveResult.shapeToUpdate);
} else if (moveResult.shapeToUpdate.size() > 0) {
moveJunctionGeometry(moveResult.shapeToUpdate.front(), false);
moveJunctionGeometry(moveResult.shapeToUpdate.front(), false, true);
}
updateGeometry();
}
Expand Down Expand Up @@ -1751,6 +1763,7 @@ GNEJunction::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoL
undoList->end();
} else if (!myNet->getViewNet()->mergeJunctions(this, secondJunction)) {
undoList->begin(GUIIcon::JUNCTION, "position of " + getTagStr());
//
undoList->changeAttribute(new GNEChange_Attribute(this, SUMO_ATTR_POSITION, toString(moveResult.shapeToUpdate.front())));
undoList->end();
}
Expand Down Expand Up @@ -1842,14 +1855,16 @@ GNEJunction::checkMissingConnections() {


void
GNEJunction::moveJunctionGeometry(const Position& pos, const bool updateEdgeBoundaries) {
GNEJunction::moveJunctionGeometry(const Position& pos, const bool updateEdgeBoundaries, const bool moveAdjacentEdges) {
// obtain NBNode position
const Position orig = myNBNode->getPosition();
// reinit NBNode
myNBNode->reinit(pos, myNBNode->getType());
// set new position of adjacent edges
for (const auto& edge : getNBNode()->getEdges()) {
myNet->getAttributeCarriers()->retrieveEdge(edge->getID())->updateJunctionPosition(this, orig);
if (moveAdjacentEdges) {
for (const auto& edge : getNBNode()->getEdges()) {
myNet->getAttributeCarriers()->retrieveEdge(edge->getID())->updateJunctionPosition(this, orig);
}
}
// declare three sets with all affected GNEJunctions, GNEEdges and GNEConnections
std::set<GNEJunction*> affectedJunctions;
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/elements/network/GNEJunction.h
Expand Up @@ -341,7 +341,7 @@ class GNEJunction : public GNENetworkElement, public GNECandidateElement {
* @param[in] pos The new position
* @note: those operations are not added to the undoList.
*/
void moveJunctionGeometry(const Position& pos, const bool updateEdgeBoundaries);
void moveJunctionGeometry(const Position& pos, const bool updateEdgeBoundaries, const bool moveAdjacentEdges);

/// @brief sets junction color depending on circumstances
RGBColor setColor(const GUIVisualizationSettings& s, bool bubble) const;
Expand Down
1 change: 1 addition & 0 deletions src/utils/xml/SUMOXMLDefinitions.cpp
Expand Up @@ -980,6 +980,7 @@ StringBijection<int>::Entry SUMOXMLDefinitions::attrs[] = {
{ "stopIndex", GNE_ATTR_STOPINDEX },
{ "pathStopIndex", GNE_ATTR_PATHSTOPINDEX },
{ "additionalChildren", GNE_ATTR_ADDITIONALCHILDREN },
{ "singlePosition", GNE_ATTR_SINGLE_POSITION },

{ "carriageLength", SUMO_ATTR_CARRIAGE_LENGTH },
{ "locomotiveLength", SUMO_ATTR_LOCOMOTIVE_LENGTH },
Expand Down
2 changes: 2 additions & 0 deletions src/utils/xml/SUMOXMLDefinitions.h
Expand Up @@ -1429,6 +1429,8 @@ enum SumoXMLAttr {
GNE_ATTR_PATHSTOPINDEX,
/// @brief check number of additional children (used in vTypeDistribution)
GNE_ATTR_ADDITIONALCHILDREN,
/// @brief move single position (used during moving of selected junctions)
GNE_ATTR_SINGLE_POSITION,

// @}

Expand Down

0 comments on commit 2950676

Please sign in to comment.