SUMO - Simulation of Urban MObility
GNEChange_Junction.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A network change in which a single junction is created or deleted
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
31 
32 #include "GNEChange_Junction.h"
33 #include "GNENet.h"
34 #include "GNEJunction.h"
35 #include "GNEViewNet.h"
36 
37 
38 // ===========================================================================
39 // FOX-declarations
40 // ===========================================================================
41 FXIMPLEMENT_ABSTRACT(GNEChange_Junction, GNEChange, NULL, 0)
42 
43 // ===========================================================================
44 // member method definitions
45 // ===========================================================================
46 
47 
48 GNEChange_Junction::GNEChange_Junction(GNEJunction* junction, bool forward):
50  GNEChange(junction->getNet(), forward),
51  myJunction(junction) {
52  assert(myNet);
53  junction->incRef("GNEChange_Junction");
54 }
55 
56 
58  assert(myJunction);
59  myJunction->decRef("GNEChange_Junction");
60  if (myJunction->unreferenced()) {
61  // show extra information for tests
63  WRITE_WARNING("Deleting unreferenced " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "'");
64  }
65  delete myJunction;
66  }
67 }
68 
69 
70 void
72  if (myForward) {
73  // show extra information for tests
75  WRITE_WARNING("Deleting " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "'");
76  }
77  // add junction to net
79  } else {
80  // show extra information for tests
82  WRITE_WARNING("Adding " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "'");
83  }
84  // delete junction from net
86  }
87 }
88 
89 
90 void
92  if (myForward) {
93  // show extra information for tests
95  WRITE_WARNING("Adding " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "'");
96  }
97  // add junction into net
99  } else {
100  // show extra information for tests
102  WRITE_WARNING("Deleting " + toString(myJunction->getTag()) + " '" + myJunction->getID() + "'");
103  }
104  // delete junction from net
106  }
107 }
108 
109 
110 FXString
112  if (myForward) {
113  return ("Undo create " + toString(SUMO_TAG_JUNCTION)).c_str();
114  } else {
115  return ("Undo delete " + toString(SUMO_TAG_JUNCTION)).c_str();
116  }
117 }
118 
119 
120 FXString
122  if (myForward) {
123  return ("Redo create " + toString(SUMO_TAG_JUNCTION)).c_str();
124  } else {
125  return ("Redo delete " + toString(SUMO_TAG_JUNCTION)).c_str();
126  }
127 }
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:49
void undo()
undo action
begin/end of the description of a junction
GNENet * getNet() const
get Net in which this element is placed
void insertJunction(GNEJunction *junction)
inserts a single junction into the net and into the underlying netbuild-container ...
Definition: GNENet.cpp:1459
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
bool isTestingModeEnabled() const
check if netedit is running in testing mode
Definition: GNEViewNet.cpp:405
~GNEChange_Junction()
Destructor.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
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="")
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:82
void deleteSingleJunction(GNEJunction *junction)
deletes a single junction
Definition: GNENet.cpp:1512
void redo()
redo action
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:87
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1165
SumoXMLTag getTag() const
get XML Tag assigned to this object