Path: blob/main/src/netedit/changes/GNEChange_Connection.cpp
169678 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GNEChange_Connection.cpp14/// @author Jakob Erdmann15/// @date May 201116///17// A network change in which a single connection is created or deleted18/****************************************************************************/1920#include <netedit/GNENet.h>2122#include "GNEChange_Connection.h"2324// ===========================================================================25// FOX-declarations26// ===========================================================================2728FXIMPLEMENT_ABSTRACT(GNEChange_Connection, GNEChange, nullptr, 0)2930// ===========================================================================31// member method definitions32// ===========================================================================333435GNEChange_Connection::GNEChange_Connection(GNEEdge* edge, NBEdge::Connection nbCon, bool selected, bool forward) :36GNEChange(Supermode::NETWORK, forward, selected),37myEdge(edge),38myNBEdgeConnection(nbCon) {39}404142GNEChange_Connection::~GNEChange_Connection() {43}444546void47GNEChange_Connection::undo() {48if (myForward) {49// remove connection from edge50myEdge->removeConnection(myNBEdgeConnection);51} else {52// add connection into edge53myEdge->addConnection(myNBEdgeConnection, mySelectedElement);54}55// enable save networkElements56myEdge->getNet()->getSavingStatus()->requireSaveNetwork();57}585960void61GNEChange_Connection::redo() {62if (myForward) {63// add connection into edge64myEdge->addConnection(myNBEdgeConnection, mySelectedElement);65} else {66// remove connection from edge67myEdge->removeConnection(myNBEdgeConnection);68}69// enable save networkElements70myEdge->getNet()->getSavingStatus()->requireSaveNetwork();71}727374std::string75GNEChange_Connection::undoName() const {76if (myForward) {77return (TL("Undo create ") + toString(SUMO_TAG_CONNECTION) + " '" +78toString(myNBEdgeConnection.fromLane) + "->" + toString(myNBEdgeConnection.fromLane) + "'");79} else {80return (TL("Undo delete ") + toString(SUMO_TAG_CONNECTION) + " '" +81toString(myNBEdgeConnection.fromLane) + "->" + toString(myNBEdgeConnection.fromLane) + "'");82}83}848586std::string87GNEChange_Connection::redoName() const {88if (myForward) {89return (TL("Redo create connection '") +90toString(myNBEdgeConnection.fromLane) + "->" + toString(myNBEdgeConnection.fromLane) + "'");91} else {92return (TL("Redo delete connection '") +93toString(myNBEdgeConnection.fromLane) + "->" + toString(myNBEdgeConnection.fromLane) + "'");94}95}969798