SUMO - Simulation of Urban MObility
GNEChange_Connection.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A network change in which a single connection is created or deleted
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
31 #include <cassert>
32 
33 #include "GNEChange_Connection.h"
34 #include "GNEConnection.h"
35 #include "GNEEdge.h"
36 #include "GNENet.h"
37 #include "GNEViewNet.h"
38 
39 
40 // ===========================================================================
41 // FOX-declarations
42 // ===========================================================================
43 FXIMPLEMENT_ABSTRACT(GNEChange_Connection, GNEChange, NULL, 0)
44 
45 // ===========================================================================
46 // member method definitions
47 // ===========================================================================
48 
49 
50 GNEChange_Connection::GNEChange_Connection(GNEEdge* edge, NBEdge::Connection nbCon, bool forward) :
51  GNEChange(edge->getNet(), forward),
52  myEdge(edge),
53  myNBEdgeConnection(nbCon),
54  myConnection(myEdge->retrieveConnection(nbCon.fromLane, nbCon.toEdge, nbCon.toLane)) {
55  assert(myEdge);
56 }
57 
58 
60  assert(myEdge);
61 }
62 
63 
64 void
66  if (myForward) {
67  // show extra information for tests
69  WRITE_WARNING("Deleting " + toString(myConnection->getTag()) + " '" + myConnection->getID() + "'");
70  }
71  // remove connection from edge
73  } else {
74  // show extra information for tests
76  WRITE_WARNING("Deleting " + toString(myConnection->getTag()) + " '" + myConnection->getID() + "'");
77  }
78  // add connection into edge
80  }
81 }
82 
83 
84 void
86  if (myForward) {
87  // show extra information for tests
89  WRITE_WARNING("Deleting " + toString(myConnection->getTag()) + " '" + myConnection->getID() + "'");
90  }
91  // add connection into edge
93  } else {
94  // show extra information for tests
96  WRITE_WARNING("Deleting " + toString(myConnection->getTag()) + " '" + myConnection->getID() + "'");
97  }
98  // remove connection from edge
100  }
101 }
102 
103 
104 FXString
106  if (myForward) {
107  return ("Undo create " + toString(SUMO_TAG_CONNECTION)).c_str();
108  } else {
109  return ("Undo delete " + toString(SUMO_TAG_CONNECTION)).c_str();
110  }
111 }
112 
113 
114 FXString
116  if (myForward) {
117  return ("Redo create " + toString(SUMO_TAG_CONNECTION)).c_str();
118  } else {
119  return ("Redo delete " + toString(SUMO_TAG_CONNECTION)).c_str();
120  }
121 }
void addConnection(NBEdge::Connection nbCon, GNEConnection *con)
adds a connection
Definition: GNEEdge.cpp:981
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:49
GNENet * getNet() const
get Net in which this element is placed
connectio between two lanes
The representation of a single edge during network building.
Definition: NBEdge.h:71
~GNEChange_Connection()
Destructor.
NBEdge::Connection myNBEdgeConnection
the data which must be copied because the original reference does not persist
GNEConnection * myConnection
We only keep this to retain the GUIGlID.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
bool isTestingModeEnabled() const
check if netedit is running in testing mode
Definition: GNEViewNet.cpp:405
FXString redoName() const
get Redo name
FXString undoName() const
return undoName
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
const std::string getID() const
function to support debugging
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:57
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:87
void removeConnection(NBEdge::Connection nbCon)
removes a connection
Definition: GNEEdge.cpp:995
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1165
SumoXMLTag getTag() const
get XML Tag assigned to this object