SUMO - Simulation of Urban MObility
GNEChange_Junction.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>
26 #include <netedit/GNEViewNet.h>
28 #include <netedit/GNEViewParent.h>
29 
30 #include "GNEChange_Junction.h"
31 
32 // ===========================================================================
33 // FOX-declarations
34 // ===========================================================================
35 FXIMPLEMENT_ABSTRACT(GNEChange_Junction, GNEChange, nullptr, 0)
36 
37 // ===========================================================================
38 // member method definitions
39 // ===========================================================================
40 
41 
42 GNEChange_Junction::GNEChange_Junction(GNEJunction* junction, bool forward):
44  GNEChange(junction->getNet(), forward),
45  myJunction(junction) {
46  assert(myNet);
47  junction->incRef("GNEChange_Junction");
48 }
49 
50 
52  assert(myJunction);
53  myJunction->decRef("GNEChange_Junction");
54  if (myJunction->unreferenced()) {
55  // show extra information for tests
56  WRITE_DEBUG("Deleting unreferenced " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "' in GNEChange_Junction");
57  delete myJunction;
58  }
59 }
60 
61 
62 void
64  if (myForward) {
65  // show extra information for tests
66  WRITE_DEBUG("Removing " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "' from " + toString(SUMO_TAG_NET));
67  // add junction to net
69  } else {
70  // show extra information for tests
71  WRITE_DEBUG("Adding " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "' into " + toString(SUMO_TAG_NET));
72  // delete junction from net
74  }
75  // check if inspector frame has to be updated
76  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
78  }
79  // enable save netElements
80  myNet->requiereSaveNet(true);
81 }
82 
83 
84 void
86  if (myForward) {
87  // show extra information for tests
88  WRITE_DEBUG("Adding " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "' into " + toString(SUMO_TAG_NET));
89  // add junction into net
91  } else {
92  // show extra information for tests
93  WRITE_DEBUG("Removing " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "' from " + toString(SUMO_TAG_NET));
94  // delete junction from net
96  }
97  // check if inspector frame has to be updated
98  if (myNet->getViewNet()->getViewParent()->getInspectorFrame()->shown()) {
100  }
101  // enable save netElements
102  myNet->requiereSaveNet(true);
103 }
104 
105 
106 FXString
108  if (myForward) {
109  return ("Undo create " + toString(SUMO_TAG_JUNCTION)).c_str();
110  } else {
111  return ("Undo delete " + toString(SUMO_TAG_JUNCTION)).c_str();
112  }
113 }
114 
115 
116 FXString
118  if (myForward) {
119  return ("Redo create " + toString(SUMO_TAG_JUNCTION)).c_str();
120  } else {
121  return ("Redo delete " + toString(SUMO_TAG_JUNCTION)).c_str();
122  }
123 }
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
begin/end of the description of a junction
GNEViewParent * getViewParent() const
get the net object
void insertJunction(GNEJunction *junction)
inserts a single junction into the net and into the underlying netbuild-container ...
Definition: GNENet.cpp:2222
~GNEChange_Junction()
Destructor.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
GNEFrame::ACHierarchy * getACHierarchy() const
get ACHierarchy
GNEJunction * myJunction
full information regarding the junction that is to be created/deleted
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
FXString undoName() const
return undoName
void decRef(const std::string &debugMsg="")
Decrease reference.
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 deleteSingleJunction(GNEJunction *junction)
deletes a single junction
Definition: GNENet.cpp:2287
void requiereSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:852
void redo()
redo action
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:80
bool unreferenced()
check if object ins&#39;t referenced
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1745
SumoXMLTag getTag() const
get XML Tag assigned to this object