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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // A network change in which a single connection is created or deleted
18 /****************************************************************************/
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #ifdef _MSC_VER
24 #include <windows_config.h>
25 #else
26 #include <config.h>
27 #endif
28 
30 #include <cassert>
31 
32 #include "GNEChange_Connection.h"
33 #include "GNEConnection.h"
34 #include "GNEEdge.h"
35 #include "GNENet.h"
36 #include "GNEViewNet.h"
37 
38 
39 // ===========================================================================
40 // FOX-declarations
41 // ===========================================================================
42 FXIMPLEMENT_ABSTRACT(GNEChange_Connection, GNEChange, NULL, 0)
43 
44 // ===========================================================================
45 // member method definitions
46 // ===========================================================================
47 
48 
49 GNEChange_Connection::GNEChange_Connection(GNEEdge* edge, NBEdge::Connection nbCon, bool selected, bool forward) :
50  GNEChange(edge->getNet(), forward),
51  myEdge(edge),
52  myNBEdgeConnection(nbCon),
53  mySelected(selected) {
54  assert(myEdge);
55 }
56 
57 
59  assert(myEdge);
60 }
61 
62 
63 void
65  if (myForward) {
66  // show extra information for tests
67  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
68  WRITE_WARNING("Removing " + toString(SUMO_TAG_CONNECTION) + " '" +
70  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
71  }
72  // remove connection from edge
74  } else {
75  // show extra information for tests
76  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
77  std::string selected = mySelected ? ("a previously selected ") : ("");
78  WRITE_WARNING("Adding " + selected + toString(SUMO_TAG_CONNECTION) + " '" +
80  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
81  }
82  // add connection into edge
84  }
85 }
86 
87 
88 void
90  if (myForward) {
91  // show extra information for tests
92  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
93  std::string selected = mySelected ? ("a previously selected ") : ("");
94  WRITE_WARNING("Adding " + selected + toString(SUMO_TAG_CONNECTION) + " '" +
96  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
97  }
98  // add connection into edge
100  } else {
101  // show extra information for tests
102  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
103  WRITE_WARNING("Removing " + toString(SUMO_TAG_CONNECTION) + " '" +
105  toString(SUMO_TAG_EDGE) + " '" + myEdge->getID() + "'");
106  }
107  // remove connection from edge
109  }
110 }
111 
112 
113 FXString
115  if (myForward) {
116  return ("Undo create " + toString(SUMO_TAG_CONNECTION)).c_str();
117  } else {
118  return ("Undo delete " + toString(SUMO_TAG_CONNECTION)).c_str();
119  }
120 }
121 
122 
123 FXString
125  if (myForward) {
126  return ("Redo create " + toString(SUMO_TAG_CONNECTION)).c_str();
127  } else {
128  return ("Redo delete " + toString(SUMO_TAG_CONNECTION)).c_str();
129  }
130 }
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:48
int toLane
The lane the connections yields in.
Definition: NBEdge.h:189
bool mySelected
flag to indicates if crossing was previously selected
NBEdge * toEdge
The edge the connections yields in.
Definition: NBEdge.h:186
connectio between two lanes
The representation of a single edge during network building.
Definition: NBEdge.h:70
~GNEChange_Connection()
Destructor.
NBEdge::Connection myNBEdgeConnection
the data which must be copied because the original reference does not persist
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
FXString redoName() const
get Redo name
FXString undoName() const
return undoName
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
std::string getLaneID(int lane) const
get Lane ID (Secure)
Definition: NBEdge.cpp:2783
int fromLane
The lane the connections starts at.
Definition: NBEdge.h:183
const std::string getID() const
function to support debugging
begin/end of the description of an edge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:56
void addConnection(NBEdge::Connection nbCon, bool selectAfterCreation=false)
adds a connection
Definition: GNEEdge.cpp:1159
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:86
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:1180
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:412