SUMO - Simulation of Urban MObility
GNEChange_Edge.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 junction 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 
31 #include "GNEChange_Edge.h"
32 #include "GNENet.h"
33 #include "GNEEdge.h"
34 #include "GNELane.h"
35 #include "GNERerouter.h"
36 #include "GNEViewNet.h"
37 
38 
39 // ===========================================================================
40 // FOX-declarations
41 // ===========================================================================
42 FXIMPLEMENT_ABSTRACT(GNEChange_Edge, GNEChange, NULL, 0)
43 
44 // ===========================================================================
45 // member method definitions
46 // ===========================================================================
47 
48 
49 GNEChange_Edge::GNEChange_Edge(GNEEdge* edge, bool forward):
51  GNEChange(edge->getNet(), forward),
52  myEdge(edge) {
53  assert(myNet);
54  edge->incRef("GNEChange_Edge");
55 }
56 
57 
59  assert(myEdge);
60  myEdge->decRef("GNEChange_Edge");
61  if (myEdge->unreferenced()) {
62  // show extra information for tests
63  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
64  WRITE_WARNING("Deleting unreferenced " + toString(myEdge->getTag()) + " '" + myEdge->getID() + "' GNEChange_Edge");
65  }
66  delete myEdge;
67  }
68 }
69 
70 
71 void
73  if (myForward) {
74  // show extra information for tests
75  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
76  WRITE_WARNING("Removing " + toString(myEdge->getTag()) + " '" + myEdge->getID() + "' from " + toString(SUMO_TAG_NET));
77  }
78  // delete edge from net
80  } else {
81  // show extra information for tests
82  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
83  WRITE_WARNING("Adding " + toString(myEdge->getTag()) + " '" + myEdge->getID() + "' from " + toString(SUMO_TAG_NET));
84  }
85  // insert edge into net
87  }
88 }
89 
90 
91 void
93  if (myForward) {
94  // show extra information for tests
95  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
96  WRITE_WARNING("Adding " + toString(myEdge->getTag()) + " '" + myEdge->getID() + "' from " + toString(SUMO_TAG_NET));
97  }
98  // insert edge into net
100  } else {
101  // show extra information for tests
102  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
103  WRITE_WARNING("Removing " + toString(myEdge->getTag()) + " '" + myEdge->getID() + "' from " + toString(SUMO_TAG_NET));
104  }
105  // delte edge from net
107  }
108 }
109 
110 
111 FXString
113  if (myForward) {
114  return ("Undo create " + toString(SUMO_TAG_EDGE)).c_str();
115  } else {
116  return ("Undo delete " + toString(SUMO_TAG_EDGE)).c_str();
117  }
118 }
119 
120 
121 FXString
123  if (myForward) {
124  return ("Redo create " + toString(SUMO_TAG_EDGE)).c_str();
125  } else {
126  return ("Redo delete " + toString(SUMO_TAG_EDGE)).c_str();
127  }
128 }
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:48
void undo()
undo action
root element of a network file
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void insertEdge(GNEEdge *edge)
inserts a single edge into the net and into the underlying netbuild-container
Definition: GNENet.cpp:2155
FXString undoName() const
return undoName
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
const std::string getID() const
function to support debugging
void decRef(const std::string &debugMsg="")
Decrease reference.
begin/end of the description of an edge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:56
FXString redoName() const
get Redo name
GNENet * myNet
the net to which operations shall be applied or which shall be informed about gui updates (we are not...
Definition: GNEChange.h:81
void redo()
redo action
GNEEdge * myEdge
full information regarding the edge that is to be created/deleted
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:86
void deleteSingleEdge(GNEEdge *edge)
deletes a single edge
Definition: GNENet.cpp:2214
~GNEChange_Edge()
Destructor.
bool unreferenced()
check if object ins&#39;t referenced
SumoXMLTag getTag() const
get XML Tag assigned to this object