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 
23 #include <netedit/GNENet.h>
26 #include <netedit/GNEViewParent.h>
27 
28 #include "GNEChange_Junction.h"
29 
30 // ===========================================================================
31 // FOX-declarations
32 // ===========================================================================
33 FXIMPLEMENT_ABSTRACT(GNEChange_Junction, GNEChange, nullptr, 0)
34 
35 // ===========================================================================
36 // member method definitions
37 // ===========================================================================
38 
39 
40 GNEChange_Junction::GNEChange_Junction(GNEJunction* junction, bool forward):
42  GNEChange(junction->getNet(), forward),
43  myJunction(junction) {
44  assert(myNet);
45  junction->incRef("GNEChange_Junction");
46 }
47 
48 
50  assert(myJunction);
51  myJunction->decRef("GNEChange_Junction");
52  if (myJunction->unreferenced()) {
53  // show extra information for tests
54  WRITE_DEBUG("Deleting unreferenced " + myJunction->getTagStr() + " '" + myJunction->getID() + "' in GNEChange_Junction");
55  delete myJunction;
56  }
57 }
58 
59 
60 void
62  if (myForward) {
63  // show extra information for tests
64  WRITE_DEBUG("Removing " + myJunction->getTagStr() + " '" + myJunction->getID() + "' from " + toString(SUMO_TAG_NET));
65  // add junction to net
67  } else {
68  // show extra information for tests
69  WRITE_DEBUG("Adding " + myJunction->getTagStr() + " '" + myJunction->getID() + "' into " + toString(SUMO_TAG_NET));
70  // delete junction from 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 " + myJunction->getTagStr() + " '" + myJunction->getID() + "' into " + toString(SUMO_TAG_NET));
87  // add junction into net
89  } else {
90  // show extra information for tests
91  WRITE_DEBUG("Removing " + myJunction->getTagStr() + " '" + myJunction->getID() + "' from " + toString(SUMO_TAG_NET));
92  // delete junction 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_JUNCTION)).c_str();
108  } else {
109  return ("Undo delete " + toString(SUMO_TAG_JUNCTION)).c_str();
110  }
111 }
112 
113 
114 FXString
116  if (myForward) {
117  return ("Redo create " + toString(SUMO_TAG_JUNCTION)).c_str();
118  } else {
119  return ("Redo delete " + toString(SUMO_TAG_JUNCTION)).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
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:2236
~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:594
const std::string getID() const
function to support debugging
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:248
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:76
void deleteSingleJunction(GNEJunction *junction)
deletes a single junction
Definition: GNENet.cpp:2301
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
void redo()
redo action
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:81
bool unreferenced()
check if object ins&#39;t referenced
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1730