Eclipse SUMO - Simulation of Urban MObility
GNEChange_Connection.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A network change in which a single connection is created or deleted
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
24 #include <netedit/GNENet.h>
25 
26 #include "GNEChange_Connection.h"
27 
28 // ===========================================================================
29 // FOX-declarations
30 // ===========================================================================
31 FXIMPLEMENT_ABSTRACT(GNEChange_Connection, GNEChange, nullptr, 0)
32 
33 // ===========================================================================
34 // member method definitions
35 // ===========================================================================
36 
37 
38 GNEChange_Connection::GNEChange_Connection(GNEEdge* edge, NBEdge::Connection nbCon, bool selected, bool forward) :
39  GNEChange(edge->getNet(), forward),
40  myEdge(edge),
41  myNBEdgeConnection(nbCon),
42  mySelected(selected) {
43  assert(myEdge);
44 }
45 
46 
48  assert(myEdge);
49 }
50 
51 
52 void
54  if (myForward) {
55  // show extra information for tests
56  WRITE_DEBUG("Removing " + toString(SUMO_TAG_CONNECTION) + " '" +
58  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
59  // remove connection from edge
61  } else {
62  // show extra information for tests
63  std::string selected = mySelected ? ("a previously selected ") : ("");
64  WRITE_DEBUG("Adding " + selected + toString(SUMO_TAG_CONNECTION) + " '" +
66  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
67  // add connection into edge
69  }
70  // enable save netElements
71  myNet->requiereSaveNet(true);
72 }
73 
74 
75 void
77  if (myForward) {
78  // show extra information for tests
79  std::string selected = mySelected ? ("a previously selected ") : ("");
80  WRITE_DEBUG("Adding " + selected + toString(SUMO_TAG_CONNECTION) + " '" +
82  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
83  // add connection into edge
85  } else {
86  // show extra information for tests
87  WRITE_DEBUG("Removing " + toString(SUMO_TAG_CONNECTION) + " '" +
89  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
90  // remove connection from edge
92  }
93  // enable save netElements
94  myNet->requiereSaveNet(true);
95 }
96 
97 
98 FXString
100  if (myForward) {
101  return ("Undo create " + toString(SUMO_TAG_CONNECTION)).c_str();
102  } else {
103  return ("Undo delete " + toString(SUMO_TAG_CONNECTION)).c_str();
104  }
105 }
106 
107 
108 FXString
110  if (myForward) {
111  return ("Redo create " + toString(SUMO_TAG_CONNECTION)).c_str();
112  } else {
113  return ("Redo delete " + toString(SUMO_TAG_CONNECTION)).c_str();
114  }
115 }
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:43
int toLane
The lane the connections yields in.
Definition: NBEdge.h:209
bool mySelected
flag to indicates if crossing was previously selected
NBEdge * toEdge
The edge the connections yields in.
Definition: NBEdge.h:206
connectio between two lanes
The representation of a single edge during network building.
Definition: NBEdge.h:86
~GNEChange_Connection()
Destructor.
NBEdge::Connection myNBEdgeConnection
the data which must be copied because the original reference does not persist
FXString redoName() const
get Redo name
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:625
FXString undoName() const
return undoName
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
std::string getLaneID(int lane) const
get lane ID
Definition: NBEdge.cpp:3125
int fromLane
The lane the connections starts at.
Definition: NBEdge.h:203
const std::string getID() const
function to support debugging
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:246
begin/end of the description of an edge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
GNENet * myNet
the net to which operations shall be applied or which shall be informed about gui updates (we are not...
Definition: GNEChange.h:76
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition: GNEEdge.cpp:1755
void requiereSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:933
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:81
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:1791