SUMO - Simulation of Urban MObility
GNEChange_Edge.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A network change in which a single junction 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 
30 #include "GNEChange_Edge.h"
31 #include "GNENet.h"
32 #include "GNEEdge.h"
33 #include "GNELane.h"
34 
35 #ifdef CHECK_MEMORY_LEAKS
36 #include <foreign/nvwa/debug_new.h>
37 #endif
38 
39 
40 // ===========================================================================
41 // FOX-declarations
42 // ===========================================================================
43 FXIMPLEMENT_ABSTRACT(GNEChange_Edge, GNEChange, NULL, 0)
44 
45 // ===========================================================================
46 // member method definitions
47 // ===========================================================================
48 
49 
50 GNEChange_Edge::GNEChange_Edge(GNEEdge* edge, bool forward):
52  GNEChange(edge->getNet(), forward),
53  myEdge(edge) {
54  assert(myNet);
55  edge->incRef("GNEChange_Edge");
56  // Save additionals of edge
57  myAdditionalChilds = myEdge->getAdditionalChilds();
58 }
59 
60 
62  assert(myEdge);
63  myEdge->decRef("GNEChange_Edge");
64  if (myEdge->unreferenced()) {
65  delete myEdge;
66  }
67 }
68 
69 
70 void
72  if (myForward) {
74  // 1 - Remove additional sets vinculated with this edge of net
75  for (std::vector<GNEAdditional*>::iterator i = myAdditionalChilds.begin(); i != myAdditionalChilds.end(); i++) {
77  }
78  } else {
80  // 1 - add additional sets vinculated with this edge to the net
81  for (std::vector<GNEAdditional*>::iterator i = myAdditionalChilds.begin(); i != myAdditionalChilds.end(); i++) {
83  }
84  }
85 }
86 
87 
88 void
90  if (myForward) {
92  // 1 - Add additional sets vinculated with this edge to the net
93  for (std::vector<GNEAdditional*>::iterator i = myAdditionalChilds.begin(); i != myAdditionalChilds.end(); i++) {
95  }
96  } else {
98  // 1 - Remove additional sets vinculated with this edge of net
99  for (std::vector<GNEAdditional*>::iterator i = myAdditionalChilds.begin(); i != myAdditionalChilds.end(); i++) {
100  myNet->deleteAdditional(*i);
101  }
102  }
103 }
104 
105 
106 FXString
108  if (myForward) {
109  return ("Undo create " + toString(SUMO_TAG_EDGE)).c_str();
110  } else {
111  return ("Undo delete " + toString(SUMO_TAG_EDGE)).c_str();
112  }
113 }
114 
115 
116 FXString
118  if (myForward) {
119  return ("Redo create " + toString(SUMO_TAG_EDGE)).c_str();
120  } else {
121  return ("Redo delete " + toString(SUMO_TAG_EDGE)).c_str();
122  }
123 }
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:49
void undo()
undo action
void insertEdge(GNEEdge *edge)
inserts a single edge into the net and into the underlying netbuild-container
Definition: GNENet.cpp:1322
std::vector< GNEAdditional * > myAdditionalChilds
we need to preserve the list of additionals vinculated with this edge
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
void decRef(const std::string &debugMsg="")
begin/end of the description of an edge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:54
GNENet * myNet
the net to which operations shall be applied or which shall be informed about gui updates (we are not...
Definition: GNEChange.h:82
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:87
void deleteAdditional(GNEAdditional *additional)
delete additional element previously inserted
Definition: GNENet.cpp:1223
void deleteSingleEdge(GNEEdge *edge)
deletes a single edge
Definition: GNENet.cpp:1381
void insertAdditional(GNEAdditional *additional, bool hardFail=true)
Insert a additional element previously created in GNEAdditionalHandler.
Definition: GNENet.cpp:1207
~GNEChange_Edge()
Destructor.