Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEChange_Connection.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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/****************************************************************************/
18// A network change in which a single connection is created or deleted
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23
25
26// ===========================================================================
27// FOX-declarations
28// ===========================================================================
29FXIMPLEMENT_ABSTRACT(GNEChange_Connection, GNEChange, nullptr, 0)
30
31// ===========================================================================
32// member method definitions
33// ===========================================================================
34
35
36GNEChange_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
45
46
47void
49 if (myForward) {
50 // show extra information for tests
51 WRITE_DEBUG("Removing " + toString(SUMO_TAG_CONNECTION) + " '" +
53 toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
54 // remove connection from edge
56 } else {
57 // show extra information for tests
58 std::string selected = mySelectedElement ? ("a previously selected ") : ("");
59 WRITE_DEBUG("Adding " + selected + toString(SUMO_TAG_CONNECTION) + " '" +
61 toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
62 // add connection into edge
64 }
65 // enable save networkElements
67}
68
69
70void
72 if (myForward) {
73 // show extra information for tests
74 std::string selected = mySelectedElement ? ("a previously selected ") : ("");
75 WRITE_DEBUG("Adding " + selected + toString(SUMO_TAG_CONNECTION) + " '" +
77 toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
78 // add connection into edge
80 } else {
81 // show extra information for tests
82 WRITE_DEBUG("Removing " + toString(SUMO_TAG_CONNECTION) + " '" +
84 toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
85 // remove connection from edge
87 }
88 // enable save networkElements
90}
91
92
93std::string
95 if (myForward) {
96 return (TL("Undo create ") + toString(SUMO_TAG_CONNECTION) + " '" +
98 } else {
99 return (TL("Undo delete ") + toString(SUMO_TAG_CONNECTION) + " '" +
101 }
102}
103
104
105std::string
107 if (myForward) {
108 return (TL("Redo create connection '") +
110 } else {
111 return (TL("Redo delete connection '") +
113 }
114}
Supermode
@brie enum for supermodes
@ NETWORK
Network mode (Edges, junctions, etc..)
#define WRITE_DEBUG(msg)
Definition MsgHandler.h:306
#define TL(string)
Definition MsgHandler.h:315
@ SUMO_TAG_CONNECTION
connectioon between two lanes
@ SUMO_TAG_EDGE
begin/end of the description of an edge
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
const std::string getID() const
get ID (all Attribute Carriers have one)
GNENet * getNet() const
get pointer to net
std::string undoName() const
return undoName
NBEdge::Connection myNBEdgeConnection
the data which must be copied because the original reference does not persist
std::string redoName() const
get Redo name
the function-object for an editing operation (abstract base)
Definition GNEChange.h:56
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag
Definition GNEChange.h:212
const bool mySelectedElement
flag for check if element is selected
Definition GNEChange.h:215
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:779
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition GNEEdge.cpp:2265
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition GNEEdge.cpp:2241
void requireSaveNetwork()
inform that network has to be saved
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition GNENet.cpp:131
The representation of a single edge during network building.
Definition NBEdge.h:92
std::string getLaneID(int lane) const
get lane ID
Definition NBEdge.cpp:4016
int fromLane
The lane the connections starts at.
Definition NBEdge.h:210
int toLane
The lane the connections yields in.
Definition NBEdge.h:216
NBEdge * toEdge
The edge the connections yields in.
Definition NBEdge.h:213