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 
24 #include <netedit/GNENet.h>
28 #include <netedit/GNEViewNet.h>
30 #include <netedit/GNEViewParent.h>
31 
32 #include "GNEChange_Edge.h"
33 
34 // ===========================================================================
35 // FOX-declarations
36 // ===========================================================================
37 FXIMPLEMENT_ABSTRACT(GNEChange_Edge, GNEChange, nullptr, 0)
38 
39 // ===========================================================================
40 // member method definitions
41 // ===========================================================================
42 
43 
44 GNEChange_Edge::GNEChange_Edge(GNEEdge* edge, bool forward):
46  GNEChange(edge->getNet(), forward),
47  myEdge(edge) {
48  assert(myNet);
49  edge->incRef("GNEChange_Edge");
50 }
51 
52 
54  assert(myEdge);
55  myEdge->decRef("GNEChange_Edge");
56  if (myEdge->unreferenced()) {
57  // show extra information for tests
58  WRITE_DEBUG("Deleting unreferenced " + toString(myEdge->getTag()) + " '" + myEdge->getID() + "' GNEChange_Edge");
59  delete myEdge;
60  }
61 }
62 
63 
64 void
66  if (myForward) {
67  // show extra information for tests
68  WRITE_DEBUG("Removing " + toString(myEdge->getTag()) + " '" + myEdge->getID() + "' from " + toString(SUMO_TAG_NET));
69  // delete edge from net
71  } else {
72  // show extra information for tests
73  WRITE_DEBUG("Adding " + toString(myEdge->getTag()) + " '" + myEdge->getID() + "' from " + toString(SUMO_TAG_NET));
74  // insert edge into net
76  }
77  // check if inspector frame has to be updated
78  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
80  }
81  // enable save netElements
82  myNet->requiereSaveNet(true);
83 }
84 
85 
86 void
88  if (myForward) {
89  // show extra information for tests
90  WRITE_DEBUG("Adding " + toString(myEdge->getTag()) + " '" + myEdge->getID() + "' from " + toString(SUMO_TAG_NET));
91  // insert edge into net
93  } else {
94  // show extra information for tests
95  WRITE_DEBUG("Removing " + toString(myEdge->getTag()) + " '" + myEdge->getID() + "' from " + toString(SUMO_TAG_NET));
96  // delte edge from net
98  }
99  // check if inspector frame has to be updated
100  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
102  }
103  // enable save netElements
104  myNet->requiereSaveNet(true);
105 }
106 
107 
108 FXString
110  if (myForward) {
111  return ("Undo create " + toString(SUMO_TAG_EDGE)).c_str();
112  } else {
113  return ("Undo delete " + toString(SUMO_TAG_EDGE)).c_str();
114  }
115 }
116 
117 
118 FXString
120  if (myForward) {
121  return ("Redo create " + toString(SUMO_TAG_EDGE)).c_str();
122  } else {
123  return ("Redo delete " + toString(SUMO_TAG_EDGE)).c_str();
124  }
125 }
GNEInspectorFrame * getInspectorFrame() const
get frame for GNE_MODE_INSPECT
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:42
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:2221
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:117
const std::string getID() const
function to support debugging
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:249
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:75
void redo()
redo action
void requiereSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:844
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:80
void deleteSingleEdge(GNEEdge *edge)
deletes a single edge
Definition: GNENet.cpp:2297
~GNEChange_Edge()
Destructor.
bool unreferenced()
check if object ins&#39;t referenced
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1737
SumoXMLTag getTag() const
get XML Tag assigned to this object