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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // A network change in which a single junction is created or deleted
18 /****************************************************************************/
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #ifdef _MSC_VER
24 #include <windows_config.h>
25 #else
26 #include <config.h>
27 #endif
28 
30 
31 #include "GNEChange_Junction.h"
32 #include "GNENet.h"
33 #include "GNEJunction.h"
34 #include "GNEViewNet.h"
35 
36 
37 // ===========================================================================
38 // FOX-declarations
39 // ===========================================================================
40 FXIMPLEMENT_ABSTRACT(GNEChange_Junction, GNEChange, NULL, 0)
41 
42 // ===========================================================================
43 // member method definitions
44 // ===========================================================================
45 
46 
47 GNEChange_Junction::GNEChange_Junction(GNEJunction* junction, bool forward):
49  GNEChange(junction->getNet(), forward),
50  myJunction(junction) {
51  assert(myNet);
52  junction->incRef("GNEChange_Junction");
53 }
54 
55 
57  assert(myJunction);
58  myJunction->decRef("GNEChange_Junction");
59  if (myJunction->unreferenced()) {
60  // show extra information for tests
61  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
62  WRITE_WARNING("Deleting unreferenced " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "' in GNEChange_Junction");
63  }
64  delete myJunction;
65  }
66 }
67 
68 
69 void
71  if (myForward) {
72  // show extra information for tests
73  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
74  WRITE_WARNING("Removing " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "' from " + toString(SUMO_TAG_NET));
75  }
76  // add junction to net
78  } else {
79  // show extra information for tests
80  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
81  WRITE_WARNING("Adding " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "' into " + toString(SUMO_TAG_NET));
82  }
83  // delete junction from net
85  }
86 }
87 
88 
89 void
91  if (myForward) {
92  // show extra information for tests
93  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
94  WRITE_WARNING("Adding " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "' into " + toString(SUMO_TAG_NET));
95  }
96  // add junction into net
98  } else {
99  // show extra information for tests
100  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
101  WRITE_WARNING("Removing " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "' from " + toString(SUMO_TAG_NET));
102  }
103  // delete junction from net
105  }
106 }
107 
108 
109 FXString
111  if (myForward) {
112  return ("Undo create " + toString(SUMO_TAG_JUNCTION)).c_str();
113  } else {
114  return ("Undo delete " + toString(SUMO_TAG_JUNCTION)).c_str();
115  }
116 }
117 
118 
119 FXString
121  if (myForward) {
122  return ("Redo create " + toString(SUMO_TAG_JUNCTION)).c_str();
123  } else {
124  return ("Redo delete " + toString(SUMO_TAG_JUNCTION)).c_str();
125  }
126 }
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:48
void undo()
undo action
root element of a network file
begin/end of the description of a junction
void insertJunction(GNEJunction *junction)
inserts a single junction into the net and into the underlying netbuild-container ...
Definition: GNENet.cpp:2148
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
~GNEChange_Junction()
Destructor.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
GNEJunction * myJunction
full information regarding the junction that is to be created/deleted
const std::string getID() const
function to support debugging
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:81
void deleteSingleJunction(GNEJunction *junction)
deletes a single junction
Definition: GNENet.cpp:2201
void redo()
redo action
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:86
bool unreferenced()
check if object ins&#39;t referenced
SumoXMLTag getTag() const
get XML Tag assigned to this object