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-2018 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 junction is created or deleted
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 #include <netedit/GNENet.h>
26 #include <netedit/GNEViewParent.h>
27 
28 #include "GNEChange_Edge.h"
29 
30 // ===========================================================================
31 // FOX-declarations
32 // ===========================================================================
33 FXIMPLEMENT_ABSTRACT(GNEChange_Edge, GNEChange, nullptr, 0)
34 
35 // ===========================================================================
36 // member method definitions
37 // ===========================================================================
38 
39 
40 GNEChange_Edge::GNEChange_Edge(GNEEdge* edge, bool forward):
42  GNEChange(edge->getNet(), forward),
43  myEdge(edge) {
44  assert(myNet);
45  edge->incRef("GNEChange_Edge");
46 }
47 
48 
50  assert(myEdge);
51  myEdge->decRef("GNEChange_Edge");
52  if (myEdge->unreferenced()) {
53  // show extra information for tests
54  WRITE_DEBUG("Deleting unreferenced " + myEdge->getTagStr() + " '" + myEdge->getID() + "' GNEChange_Edge");
55  delete myEdge;
56  }
57 }
58 
59 
60 void
62  if (myForward) {
63  // show extra information for tests
64  WRITE_DEBUG("Removing " + myEdge->getTagStr() + " '" + myEdge->getID() + "' from " + toString(SUMO_TAG_NET));
65  // delete edge from net
67  } else {
68  // show extra information for tests
69  WRITE_DEBUG("Adding " + myEdge->getTagStr() + " '" + myEdge->getID() + "' from " + toString(SUMO_TAG_NET));
70  // insert edge into net
72  }
73  // check if inspector frame has to be updated
74  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
76  }
77  // enable save netElements
78  myNet->requiereSaveNet(true);
79 }
80 
81 
82 void
84  if (myForward) {
85  // show extra information for tests
86  WRITE_DEBUG("Adding " + myEdge->getTagStr() + " '" + myEdge->getID() + "' from " + toString(SUMO_TAG_NET));
87  // insert edge into net
89  } else {
90  // show extra information for tests
91  WRITE_DEBUG("Removing " + myEdge->getTagStr() + " '" + myEdge->getID() + "' from " + toString(SUMO_TAG_NET));
92  // delte edge from net
94  }
95  // check if inspector frame has to be updated
96  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
98  }
99  // enable save netElements
100  myNet->requiereSaveNet(true);
101 }
102 
103 
104 FXString
106  if (myForward) {
107  return ("Undo create " + toString(SUMO_TAG_EDGE)).c_str();
108  } else {
109  return ("Undo delete " + toString(SUMO_TAG_EDGE)).c_str();
110  }
111 }
112 
113 
114 FXString
116  if (myForward) {
117  return ("Redo create " + toString(SUMO_TAG_EDGE)).c_str();
118  } else {
119  return ("Redo delete " + toString(SUMO_TAG_EDGE)).c_str();
120  }
121 }
GNEInspectorFrame * getInspectorFrame() const
get frame for GNE_MODE_INSPECT
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:43
void undo()
undo action
root element of a network file
GNEViewParent * getViewParent() const
get the net object
void insertEdge(GNEEdge *edge)
inserts a single edge into the net and into the underlying netbuild-container
Definition: GNENet.cpp:2243
FXString undoName() const
return undoName
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
GNEFrame::ACHierarchy * getACHierarchy() const
get ACHierarchy
void refreshACHierarchy()
refresh ACHierarchy
Definition: GNEFrame.cpp:594
const std::string getID() const
function to support debugging
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:248
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:50
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:76
void redo()
redo action
const std::string & getTagStr() const
get tag assigned to this object in string format
void requiereSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:837
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:81
void deleteSingleEdge(GNEEdge *edge)
deletes a single edge
Definition: GNENet.cpp:2319
~GNEChange_Edge()
Destructor.
bool unreferenced()
check if object ins&#39;t referenced
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1730