SUMO - Simulation of Urban MObility
GNEChange_RerouterItem.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 change in the values of Rerouters in netedit
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 
31 
32 #include "GNEChange_RerouterItem.h"
33 #include "GNENet.h"
34 #include "GNEViewNet.h"
35 #include "GNERerouter.h"
36 #include "GNERerouterInterval.h"
37 #include "GNEClosingReroute.h"
38 #include "GNEClosingLaneReroute.h"
39 #include "GNEDestProbReroute.h"
40 #include "GNERouteProbReroute.h"
41 
42 
43 // ===========================================================================
44 // FOX-declarations
45 // ===========================================================================
46 FXIMPLEMENT_ABSTRACT(GNEChange_RerouterItem, GNEChange, NULL, 0)
47 
48 // ===========================================================================
49 // member method definitions
50 // ===========================================================================
51 
53  GNEChange(rerouterInterval->getRerouterParent()->getViewNet()->getNet(), forward),
54  myRerouterInterval(rerouterInterval),
55  myClosingReroute(NULL),
56  myClosingLaneReroute(NULL),
57  myDestProbReroute(NULL),
58  myRouteProbReroute(NULL) {
59  myRerouterInterval->incRef("GNEChange_RerouterItem");
60 }
61 
62 
64  GNEChange(closingReroute->getRerouterIntervalParent()->getRerouterParent()->getViewNet()->getNet(), forward),
65  myRerouterInterval(NULL),
66  myClosingReroute(closingReroute),
67  myClosingLaneReroute(NULL),
68  myDestProbReroute(NULL),
69  myRouteProbReroute(NULL) {
70  myClosingReroute->incRef("GNEChange_RerouterItem");
71 }
72 
73 
75  GNEChange(closingLaneReroute->getRerouterIntervalParent()->getRerouterParent()->getViewNet()->getNet(), forward),
76  myRerouterInterval(NULL),
77  myClosingReroute(NULL),
78  myClosingLaneReroute(closingLaneReroute),
79  myDestProbReroute(NULL),
80  myRouteProbReroute(NULL) {
81  myClosingLaneReroute->incRef("GNEChange_RerouterItem");
82 }
83 
84 
86  GNEChange(destProbReroute->getRerouterIntervalParent()->getRerouterParent()->getViewNet()->getNet(), forward),
87  myRerouterInterval(NULL),
88  myClosingReroute(NULL),
90  myDestProbReroute(destProbReroute),
91  myRouteProbReroute(NULL) {
92  myDestProbReroute->incRef("GNEChange_RerouterItem");
93 }
94 
95 
97  GNEChange(routeProbReroute->getRerouterIntervalParent()->getRerouterParent()->getViewNet()->getNet(), forward),
98  myRerouterInterval(NULL),
99  myClosingReroute(NULL),
100  myClosingLaneReroute(NULL),
101  myDestProbReroute(NULL),
102  myRouteProbReroute(routeProbReroute) {
103  myRouteProbReroute->incRef("GNEChange_RerouterItem");
104 }
105 
106 
108  if (myRerouterInterval) {
109  myRerouterInterval->decRef("GNEChange_RerouterItem");
111  // show extra information for tests
112  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
113  WRITE_WARNING("Deleting Interval of rerouter '" + myRerouterInterval->getRerouterParent()->getID() + "'");
114  }
115  delete myRerouterInterval;
116  }
117  } else if (myClosingReroute) {
118  myClosingReroute->decRef("GNEChange_RerouterItem");
120  // show extra information for tests
121  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
122  WRITE_WARNING("Deleting Closing Reroute of rerouter '" + myClosingReroute->getRerouterIntervalParent()->getRerouterParent()->getID() + "'");
123  }
124  delete myClosingReroute;
125  }
126  } else if (myClosingLaneReroute) {
127  myClosingLaneReroute->decRef("GNEChange_RerouterItem");
129  // show extra information for tests
130  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
131  WRITE_WARNING("Deleting Closing lane Reroute type of rerouter '" + myClosingLaneReroute->getRerouterIntervalParent()->getRerouterParent()->getID() + "'");
132  }
133  delete myClosingLaneReroute;
134  }
135  } else if (myDestProbReroute) {
136  myDestProbReroute->decRef("GNEChange_RerouterItem");
138  // show extra information for tests
139  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
140  WRITE_WARNING("Deleting Destiny Probability Reroute of rerouter '" + myDestProbReroute->getRerouterIntervalParent()->getRerouterParent()->getID() + "'");
141  }
142  delete myDestProbReroute;
143  }
144  } else if (myRouteProbReroute) {
145  myRouteProbReroute->decRef("GNEChange_RerouterItem");
147  // show extra information for tests
148  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
149  WRITE_WARNING("Deleting Route Probability Reroute of rerouter '" + myRouteProbReroute->getRerouterIntervalParent()->getRerouterParent()->getID() + "'");
150  }
151  delete myRouteProbReroute;
152  }
153  }
154 }
155 
156 
157 void
159  if (myForward) {
160  if (myRerouterInterval) {
161  // show extra information for tests
162  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
163  WRITE_WARNING("Removing Rerouter Interval from Reroute '" + myRerouterInterval->getRerouterParent()->getID() + "'");
164  }
165  // remove rerouter interval from Rerouter
167  } else if (myClosingReroute) {
168  // show extra information for tests
169  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
170  WRITE_WARNING("Removing Closing Reroute from Interval '" + myClosingReroute->getRerouterIntervalParent()->getID() + "'");
171  }
172  // remove Closing Reroute from Interval
174  } else if (myClosingLaneReroute) {
175  // show extra information for tests
176  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
177  WRITE_WARNING("Removing Closing Lane Reroute from Interval '" + myClosingLaneReroute->getRerouterIntervalParent()->getID() + "'");
178  }
179  // remove Closing Lane Reroute from Interval
181  } else if (myDestProbReroute) {
182  // show extra information for tests
183  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
184  WRITE_WARNING("Removing Dest Probability Reroute from Interval '" + myDestProbReroute->getRerouterIntervalParent()->getID() + "'");
185  }
186  // remove Destiny Probability Reroute from Interval
188  } else if (myRouteProbReroute) {
189  // show extra information for tests
190  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
191  WRITE_WARNING("Removing Route Probability Reroute from Interval '" + myRouteProbReroute->getRerouterIntervalParent()->getID() + "'");
192  }
193  // remove Route Probability Reroute from Interval
195  } else {
196  throw ProcessError("There isn't a defined Rerouter item");
197  }
198  } else {
199  if (myRerouterInterval) {
200  // show extra information for tests
201  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
202  WRITE_WARNING("Adding Rerouter Interval to Reroute '" + myRerouterInterval->getRerouterParent()->getID() + "'");
203  }
204  // add rerouter interval to Rerouter
206  } else if (myClosingReroute) {
207  // show extra information for tests
208  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
209  WRITE_WARNING("Adding Closing Reroute to Interval '" + myClosingReroute->getRerouterIntervalParent()->getID() + "'");
210  }
211  // add Closing Reroute to Interval
213  } else if (myClosingLaneReroute) {
214  // show extra information for tests
215  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
216  WRITE_WARNING("Adding Closing Lane Reroute to Interval '" + myClosingLaneReroute->getRerouterIntervalParent()->getID() + "'");
217  }
218  // add Closing Lane Reroute to Interval
220  } else if (myDestProbReroute) {
221  // show extra information for tests
222  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
223  WRITE_WARNING("Adding Dest Probability Reroute to Interval '" + myDestProbReroute->getRerouterIntervalParent()->getID() + "'");
224  }
225  // add Destiny Probability Reroute to Interval
227  } else if (myRouteProbReroute) {
228  // show extra information for tests
229  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
230  WRITE_WARNING("Adding Route Probability Reroute to Interval '" + myRouteProbReroute->getRerouterIntervalParent()->getID() + "'");
231  }
232  // add Route Probability Reroute to Interval
234  } else {
235  throw ProcessError("There isn't a defined Rerouter item");
236  }
237  }
238  // enable save additionals
240 }
241 
242 
243 void
245  if (myForward) {
246  if (myRerouterInterval) {
247  // show extra information for tests
248  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
249  WRITE_WARNING("Adding Rerouter Interval to Reroute '" + myRerouterInterval->getRerouterParent()->getID() + "'");
250  }
251  // add rerouter interval to Rerouter
253  } else if (myClosingReroute) {
254  // show extra information for tests
255  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
256  WRITE_WARNING("Adding Closing Reroute to Interval '" + myClosingReroute->getRerouterIntervalParent()->getID() + "'");
257  }
258  // add Closing Reroute to Interval
260  } else if (myClosingLaneReroute) {
261  // show extra information for tests
262  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
263  WRITE_WARNING("Adding Closing Lane Reroute to Interval '" + myClosingLaneReroute->getRerouterIntervalParent()->getID() + "'");
264  }
265  // add Closing Lane Reroute to Interval
267  } else if (myDestProbReroute) {
268  // show extra information for tests
269  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
270  WRITE_WARNING("Adding Dest Probability Reroute to Interval '" + myDestProbReroute->getRerouterIntervalParent()->getID() + "'");
271  }
272  // add Destiny Probability Reroute to Interval
274  } else if (myRouteProbReroute) {
275  // show extra information for tests
276  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
277  WRITE_WARNING("Adding Route Probability Reroute to Interval '" + myRouteProbReroute->getRerouterIntervalParent()->getID() + "'");
278  }
279  // add Route Probability Reroute to Interval
281  } else {
282  throw ProcessError("There isn't a defined Rerouter item");
283  }
284  } else {
285  if (myRerouterInterval) {
286  // show extra information for tests
287  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
288  WRITE_WARNING("Removing Rerouter Interval from Reroute '" + myRerouterInterval->getRerouterParent()->getID() + "'");
289  }
290  // remove rerouter interval from Rerouter
292  } else if (myClosingReroute) {
293  // show extra information for tests
294  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
295  WRITE_WARNING("Removing Closing Reroute from Interval '" + myClosingReroute->getRerouterIntervalParent()->getID() + "'");
296  }
297  // remove Closing Reroute from Interval
299  } else if (myClosingLaneReroute) {
300  // show extra information for tests
301  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
302  WRITE_WARNING("Removing Closing Lane Reroute from Interval '" + myClosingLaneReroute->getRerouterIntervalParent()->getID() + "'");
303  }
304  // remove Closing Lane Reroute from Interval
306  } else if (myDestProbReroute) {
307  // show extra information for tests
308  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
309  WRITE_WARNING("Removing Dest Probability Reroute from Interval '" + myDestProbReroute->getRerouterIntervalParent()->getID() + "'");
310  }
311  // remove Destiny Probability Reroute from Interval
313  } else if (myRouteProbReroute) {
314  // show extra information for tests
315  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
316  WRITE_WARNING("Removing Route Probability Reroute from Interval '" + myRouteProbReroute->getRerouterIntervalParent()->getID() + "'");
317  }
318  // remove Route Probability Reroute from Interval
320  } else {
321  throw ProcessError("There isn't a defined Rerouter item");
322  }
323  }
324  // enable save additionals
326 }
327 
328 
329 FXString
331  if (myRerouterInterval) {
332  return ("Undo change " + toString(myRerouterInterval->getTag()) + " values").c_str();
333  } else if (myClosingReroute) {
334  return ("Undo change " + toString(myClosingReroute->getTag()) + " values").c_str();
335  } else if (myClosingLaneReroute) {
336  return ("Undo change " + toString(myClosingLaneReroute->getTag()) + " values").c_str();
337  } else if (myDestProbReroute) {
338  return ("Undo change " + toString(myDestProbReroute->getTag()) + " values").c_str();
339  } else if (myRouteProbReroute) {
340  return ("Undo change " + toString(myRouteProbReroute->getTag()) + " values").c_str();
341  } else {
342  throw ProcessError("There isn't a defined Rerouter item");
343  }
344 }
345 
346 
347 FXString
349  if (myRerouterInterval) {
350  return ("Redo change " + toString(myRerouterInterval->getTag()) + " values").c_str();
351  } else if (myClosingReroute) {
352  return ("Redo change " + toString(myClosingReroute->getTag()) + " values").c_str();
353  } else if (myClosingLaneReroute) {
354  return ("Redo change " + toString(myClosingLaneReroute->getTag()) + " values").c_str();
355  } else if (myDestProbReroute) {
356  return ("Redo change " + toString(myDestProbReroute->getTag()) + " values").c_str();
357  } else if (myRouteProbReroute) {
358  return ("Redo change " + toString(myRouteProbReroute->getTag()) + " values").c_str();
359  } else {
360  throw ProcessError("There isn't a defined Rerouter item");
361  }
362 }
void requiereSaveAdditionals()
inform that additionals has to be saved
Definition: GNENet.cpp:1736
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:48
void removeRerouterInterval(GNERerouterInterval *rerouterInterval)
add rerouter interval
GNERerouterInterval * getRerouterIntervalParent() const
get rerouter interval parent
GNEDestProbReroute * myDestProbReroute
modified Closing Interval
void addDestProbReroute(GNEDestProbReroute *destProbReroute)
add destiny probability reroute
FXString redoName() const
get Redo name
void removeDestProbReroute(GNEDestProbReroute *destProbReroute)
add destiny probability reroute
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void addClosingReroute(GNEClosingReroute *closingReroute)
add closing reroute
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
GNERerouterInterval * getRerouterIntervalParent() const
get rerouter interval parent
void addRerouterInterval(GNERerouterInterval *rerouterInterval)
add rerouter interval
void removeClosingReroute(GNEClosingReroute *closingReroute)
add closing reroute
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
GNERerouterInterval * getRerouterIntervalParent() const
get rerouter interval parent
GNERerouter * getRerouterParent() const
get rerouter parent
void removeClosingLaneReroute(GNEClosingLaneReroute *closingLaneReroute)
add closing reroute
const std::string getID() const
function to support debugging
void addRouteProbReroute(GNERouteProbReroute *routeProbabilityReroute)
add reoute probability reroute
void incRef(const std::string &debugMsg="")
Increarse reference.
GNERouteProbReroute * myRouteProbReroute
modified Route Probability Reroute
void decRef(const std::string &debugMsg="")
Decrease reference.
GNEClosingLaneReroute * myClosingLaneReroute
modified Closing lane Reroute
GNEChange_RerouterItem(GNERerouterInterval *rerouterInterval, bool forward)
Constructor.
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
GNEClosingReroute * myClosingReroute
modified Closing Reroute
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:86
void addClosingLaneReroute(GNEClosingLaneReroute *closingLaneReroute)
add closing reroute
bool unreferenced()
check if object ins&#39;t referenced
void removeRouteProbReroute(GNERouteProbReroute *routeProbabilityReroute)
add reoute probability reroute
FXString undoName() const
return undoName
GNERerouterInterval * myRerouterInterval
modified rerouter interval
GNERerouterInterval * getRerouterIntervalParent() const
get rerouter interval parent
SumoXMLTag getTag() const
get XML Tag assigned to this object