Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/changes/GNEChange_Connection.cpp
169678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file GNEChange_Connection.cpp
15
/// @author Jakob Erdmann
16
/// @date May 2011
17
///
18
// A network change in which a single connection is created or deleted
19
/****************************************************************************/
20
21
#include <netedit/GNENet.h>
22
23
#include "GNEChange_Connection.h"
24
25
// ===========================================================================
26
// FOX-declarations
27
// ===========================================================================
28
29
FXIMPLEMENT_ABSTRACT(GNEChange_Connection, GNEChange, nullptr, 0)
30
31
// ===========================================================================
32
// member method definitions
33
// ===========================================================================
34
35
36
GNEChange_Connection::GNEChange_Connection(GNEEdge* edge, NBEdge::Connection nbCon, bool selected, bool forward) :
37
GNEChange(Supermode::NETWORK, forward, selected),
38
myEdge(edge),
39
myNBEdgeConnection(nbCon) {
40
}
41
42
43
GNEChange_Connection::~GNEChange_Connection() {
44
}
45
46
47
void
48
GNEChange_Connection::undo() {
49
if (myForward) {
50
// remove connection from edge
51
myEdge->removeConnection(myNBEdgeConnection);
52
} else {
53
// add connection into edge
54
myEdge->addConnection(myNBEdgeConnection, mySelectedElement);
55
}
56
// enable save networkElements
57
myEdge->getNet()->getSavingStatus()->requireSaveNetwork();
58
}
59
60
61
void
62
GNEChange_Connection::redo() {
63
if (myForward) {
64
// add connection into edge
65
myEdge->addConnection(myNBEdgeConnection, mySelectedElement);
66
} else {
67
// remove connection from edge
68
myEdge->removeConnection(myNBEdgeConnection);
69
}
70
// enable save networkElements
71
myEdge->getNet()->getSavingStatus()->requireSaveNetwork();
72
}
73
74
75
std::string
76
GNEChange_Connection::undoName() const {
77
if (myForward) {
78
return (TL("Undo create ") + toString(SUMO_TAG_CONNECTION) + " '" +
79
toString(myNBEdgeConnection.fromLane) + "->" + toString(myNBEdgeConnection.fromLane) + "'");
80
} else {
81
return (TL("Undo delete ") + toString(SUMO_TAG_CONNECTION) + " '" +
82
toString(myNBEdgeConnection.fromLane) + "->" + toString(myNBEdgeConnection.fromLane) + "'");
83
}
84
}
85
86
87
std::string
88
GNEChange_Connection::redoName() const {
89
if (myForward) {
90
return (TL("Redo create connection '") +
91
toString(myNBEdgeConnection.fromLane) + "->" + toString(myNBEdgeConnection.fromLane) + "'");
92
} else {
93
return (TL("Redo delete connection '") +
94
toString(myNBEdgeConnection.fromLane) + "->" + toString(myNBEdgeConnection.fromLane) + "'");
95
}
96
}
97
98