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-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 change in the values of Rerouters in netedit
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
25 #include <netedit/GNENet.h>
26 #include <netedit/GNEViewNet.h>
34 
35 #include "GNEChange_RerouterItem.h"
36 
37 
38 // ===========================================================================
39 // FOX-declarations
40 // ===========================================================================
41 FXIMPLEMENT_ABSTRACT(GNEChange_RerouterItem, GNEChange, nullptr, 0)
42 
43 // ===========================================================================
44 // member method definitions
45 // ===========================================================================
46 
48  GNEChange(rerouterInterval->getRerouterParent()->getViewNet()->getNet(), forward),
49  myRerouterInterval(rerouterInterval),
50  myClosingReroute(nullptr),
51  myClosingLaneReroute(nullptr),
52  myDestProbReroute(nullptr),
53  myParkingAreaReroute(nullptr),
54  myRouteProbReroute(nullptr) {
55  myRerouterInterval->incRef("GNEChange_RerouterItem");
56 }
57 
58 
60  GNEChange(closingReroute->getRerouterIntervalParent()->getRerouterParent()->getViewNet()->getNet(), forward),
61  myRerouterInterval(nullptr),
62  myClosingReroute(closingReroute),
63  myClosingLaneReroute(nullptr),
64  myDestProbReroute(nullptr),
65  myParkingAreaReroute(nullptr),
66  myRouteProbReroute(nullptr) {
67  myClosingReroute->incRef("GNEChange_RerouterItem");
68 }
69 
70 
72  GNEChange(closingLaneReroute->getRerouterIntervalParent()->getRerouterParent()->getViewNet()->getNet(), forward),
73  myRerouterInterval(nullptr),
74  myClosingReroute(nullptr),
75  myClosingLaneReroute(closingLaneReroute),
76  myDestProbReroute(nullptr),
77  myParkingAreaReroute(nullptr),
78  myRouteProbReroute(nullptr) {
79  myClosingLaneReroute->incRef("GNEChange_RerouterItem");
80 }
81 
82 
84  GNEChange(destProbReroute->getRerouterIntervalParent()->getRerouterParent()->getViewNet()->getNet(), forward),
85  myRerouterInterval(nullptr),
86  myClosingReroute(nullptr),
87  myClosingLaneReroute(nullptr),
88  myDestProbReroute(destProbReroute),
89  myParkingAreaReroute(nullptr),
90  myRouteProbReroute(nullptr) {
91  myDestProbReroute->incRef("GNEChange_RerouterItem");
92 }
93 
94 
96  GNEChange(routeProbReroute->getRerouterIntervalParent()->getRerouterParent()->getViewNet()->getNet(), forward),
97  myRerouterInterval(nullptr),
98  myClosingReroute(nullptr),
99  myClosingLaneReroute(nullptr),
100  myDestProbReroute(nullptr),
101  myParkingAreaReroute(nullptr),
102  myRouteProbReroute(routeProbReroute) {
103  myRouteProbReroute->incRef("GNEChange_RerouterItem");
104 }
105 
107  GNEChange(parkingAreaReroute->getRerouterIntervalParent()->getRerouterParent()->getViewNet()->getNet(), forward),
108  myRerouterInterval(nullptr),
109  myClosingReroute(nullptr),
110  myClosingLaneReroute(nullptr),
111  myDestProbReroute(nullptr),
112  myParkingAreaReroute(parkingAreaReroute),
113  myRouteProbReroute(nullptr) {
114  myParkingAreaReroute->incRef("GNEChange_RerouterItem");
115 }
116 
117 
118 
119 
121  if (myRerouterInterval) {
122  myRerouterInterval->decRef("GNEChange_RerouterItem");
124  // show extra information for tests
125  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
126  WRITE_WARNING("Deleting rerouter Interval");
127  }
128  delete myRerouterInterval;
129  }
130  } else if (myClosingReroute) {
131  myClosingReroute->decRef("GNEChange_RerouterItem");
133  // show extra information for tests
134  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
135  WRITE_WARNING("Deleting Closing Reroute");
136  }
137  delete myClosingReroute;
138  }
139  } else if (myClosingLaneReroute) {
140  myClosingLaneReroute->decRef("GNEChange_RerouterItem");
142  // show extra information for tests
143  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
144  WRITE_WARNING("Deleting Closing lane Reroute");
145  }
146  delete myClosingLaneReroute;
147  }
148  } else if (myDestProbReroute) {
149  myDestProbReroute->decRef("GNEChange_RerouterItem");
151  // show extra information for tests
152  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
153  WRITE_WARNING("Deleting Destiny Probability Reroute");
154  }
155  delete myDestProbReroute;
156  }
157  } else if (myParkingAreaReroute) {
158  myParkingAreaReroute->decRef("GNEChange_RerouterItem");
160  // show extra information for tests
161  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
162  WRITE_WARNING("Deleting parkingAreaReroute");
163  }
164  delete myParkingAreaReroute;
165  }
166  } else if (myRouteProbReroute) {
167  myRouteProbReroute->decRef("GNEChange_RerouterItem");
169  // show extra information for tests
170  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
171  WRITE_WARNING("Deleting Route Probability Reroute");
172  }
173  delete myRouteProbReroute;
174  }
175  }
176 }
177 
178 
179 void
181  if (myForward) {
182  if (myRerouterInterval) {
183  // show extra information for tests
184  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
185  WRITE_WARNING("Removing Rerouter Interval from Reroute '" + myRerouterInterval->getRerouterParent()->getID() + "'");
186  }
187  // remove rerouter interval from Rerouter
189  } else if (myClosingReroute) {
190  // show extra information for tests
191  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
192  WRITE_WARNING("Removing Closing Reroute from Interval '" + myClosingReroute->getRerouterIntervalParent()->getID() + "'");
193  }
194  // remove Closing Reroute from Interval
196  } else if (myClosingLaneReroute) {
197  // show extra information for tests
198  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
199  WRITE_WARNING("Removing Closing Lane Reroute from Interval '" + myClosingLaneReroute->getRerouterIntervalParent()->getID() + "'");
200  }
201  // remove Closing Lane Reroute from Interval
203  } else if (myDestProbReroute) {
204  // show extra information for tests
205  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
206  WRITE_WARNING("Removing Dest Probability Reroute from Interval '" + myDestProbReroute->getRerouterIntervalParent()->getID() + "'");
207  }
208  // remove Destiny Probability Reroute from Interval
210  } else if (myParkingAreaReroute) {
211  // show extra information for tests
212  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
213  WRITE_WARNING("Removing parkingAreaReroute from Interval '" + myParkingAreaReroute->getRerouterIntervalParent()->getID() + "'");
214  }
215  // remove Destiny Probability Reroute from Interval
217  } else if (myRouteProbReroute) {
218  // show extra information for tests
219  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
220  WRITE_WARNING("Removing Route Probability Reroute from Interval '" + myRouteProbReroute->getRerouterIntervalParent()->getID() + "'");
221  }
222  // remove Route Probability Reroute from Interval
224  } else {
225  throw ProcessError("There isn't a defined Rerouter item");
226  }
227  } else {
228  if (myRerouterInterval) {
229  // show extra information for tests
230  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
231  WRITE_WARNING("Adding Rerouter Interval to Reroute '" + myRerouterInterval->getRerouterParent()->getID() + "'");
232  }
233  // add rerouter interval to Rerouter
235  } else if (myClosingReroute) {
236  // show extra information for tests
237  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
238  WRITE_WARNING("Adding Closing Reroute to Interval '" + myClosingReroute->getRerouterIntervalParent()->getID() + "'");
239  }
240  // add Closing Reroute to Interval
242  } else if (myClosingLaneReroute) {
243  // show extra information for tests
244  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
245  WRITE_WARNING("Adding Closing Lane Reroute to Interval '" + myClosingLaneReroute->getRerouterIntervalParent()->getID() + "'");
246  }
247  // add Closing Lane Reroute to Interval
249  } else if (myDestProbReroute) {
250  // show extra information for tests
251  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
252  WRITE_WARNING("Adding Dest Probability Reroute to Interval '" + myDestProbReroute->getRerouterIntervalParent()->getID() + "'");
253  }
254  // add Destiny Probability Reroute to Interval
256  } else if (myParkingAreaReroute) {
257  // show extra information for tests
258  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
259  WRITE_WARNING("Adding parkingAreaReroute to Interval '" + myParkingAreaReroute->getRerouterIntervalParent()->getID() + "'");
260  }
261  // add Destiny Probability Reroute to Interval
263  } else if (myRouteProbReroute) {
264  // show extra information for tests
265  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
266  WRITE_WARNING("Adding Route Probability Reroute to Interval '" + myRouteProbReroute->getRerouterIntervalParent()->getID() + "'");
267  }
268  // add Route Probability Reroute to Interval
270  } else {
271  throw ProcessError("There isn't a defined Rerouter item");
272  }
273  }
274  // enable save additionals
276 }
277 
278 
279 void
281  if (myForward) {
282  if (myRerouterInterval) {
283  // show extra information for tests
284  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
285  WRITE_WARNING("Adding Rerouter Interval to Reroute '" + myRerouterInterval->getRerouterParent()->getID() + "'");
286  }
287  // add rerouter interval to Rerouter
289  } else if (myClosingReroute) {
290  // show extra information for tests
291  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
292  WRITE_WARNING("Adding Closing Reroute to Interval '" + myClosingReroute->getRerouterIntervalParent()->getID() + "'");
293  }
294  // add Closing Reroute to Interval
296  } else if (myClosingLaneReroute) {
297  // show extra information for tests
298  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
299  WRITE_WARNING("Adding Closing Lane Reroute to Interval '" + myClosingLaneReroute->getRerouterIntervalParent()->getID() + "'");
300  }
301  // add Closing Lane Reroute to Interval
303  } else if (myDestProbReroute) {
304  // show extra information for tests
305  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
306  WRITE_WARNING("Adding Dest Probability Reroute to Interval '" + myDestProbReroute->getRerouterIntervalParent()->getID() + "'");
307  }
308  // add Destiny Probability Reroute to Interval
310  } else if (myParkingAreaReroute) {
311  // show extra information for tests
312  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
313  WRITE_WARNING("Adding parkingAreaReroute to Interval '" + myParkingAreaReroute->getRerouterIntervalParent()->getID() + "'");
314  }
315  // add Destiny Probability Reroute to Interval
317  } else if (myRouteProbReroute) {
318  // show extra information for tests
319  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
320  WRITE_WARNING("Adding Route Probability Reroute to Interval '" + myRouteProbReroute->getRerouterIntervalParent()->getID() + "'");
321  }
322  // add Route Probability Reroute to Interval
324  } else {
325  throw ProcessError("There isn't a defined Rerouter item");
326  }
327  } else {
328  if (myRerouterInterval) {
329  // show extra information for tests
330  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
331  WRITE_WARNING("Removing Rerouter Interval from Reroute '" + myRerouterInterval->getRerouterParent()->getID() + "'");
332  }
333  // remove rerouter interval from Rerouter
335  } else if (myClosingReroute) {
336  // show extra information for tests
337  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
338  WRITE_WARNING("Removing Closing Reroute from Interval '" + myClosingReroute->getRerouterIntervalParent()->getID() + "'");
339  }
340  // remove Closing Reroute from Interval
342  } else if (myClosingLaneReroute) {
343  // show extra information for tests
344  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
345  WRITE_WARNING("Removing Closing Lane Reroute from Interval '" + myClosingLaneReroute->getRerouterIntervalParent()->getID() + "'");
346  }
347  // remove Closing Lane Reroute from Interval
349  } else if (myDestProbReroute) {
350  // show extra information for tests
351  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
352  WRITE_WARNING("Removing Dest Probability Reroute from Interval '" + myDestProbReroute->getRerouterIntervalParent()->getID() + "'");
353  }
354  // remove Destiny Probability Reroute from Interval
356  } else if (myParkingAreaReroute) {
357  // show extra information for tests
358  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
359  WRITE_WARNING("Removing parkingAreaReroute from Interval '" + myParkingAreaReroute->getRerouterIntervalParent()->getID() + "'");
360  }
361  // remove Destiny Probability Reroute from Interval
363  } else if (myRouteProbReroute) {
364  // show extra information for tests
365  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
366  WRITE_WARNING("Removing Route Probability Reroute from Interval '" + myRouteProbReroute->getRerouterIntervalParent()->getID() + "'");
367  }
368  // remove Route Probability Reroute from Interval
370  } else {
371  throw ProcessError("There isn't a defined Rerouter item");
372  }
373  }
374  // enable save additionals
376 }
377 
378 
379 FXString
381  if (myRerouterInterval) {
382  return ("Undo change " + toString(myRerouterInterval->getTag()) + " values").c_str();
383  } else if (myClosingReroute) {
384  return ("Undo change " + toString(myClosingReroute->getTag()) + " values").c_str();
385  } else if (myClosingLaneReroute) {
386  return ("Undo change " + toString(myClosingLaneReroute->getTag()) + " values").c_str();
387  } else if (myDestProbReroute) {
388  return ("Undo change " + toString(myDestProbReroute->getTag()) + " values").c_str();
389  } else if (myParkingAreaReroute) {
390  return ("Undo change " + toString(myParkingAreaReroute->getTag()) + " values").c_str();
391  } else if (myRouteProbReroute) {
392  return ("Undo change " + toString(myRouteProbReroute->getTag()) + " values").c_str();
393  } else {
394  throw ProcessError("There isn't a defined Rerouter item");
395  }
396 }
397 
398 
399 FXString
401  if (myRerouterInterval) {
402  return ("Redo change " + toString(myRerouterInterval->getTag()) + " values").c_str();
403  } else if (myClosingReroute) {
404  return ("Redo change " + toString(myClosingReroute->getTag()) + " values").c_str();
405  } else if (myClosingLaneReroute) {
406  return ("Redo change " + toString(myClosingLaneReroute->getTag()) + " values").c_str();
407  } else if (myDestProbReroute) {
408  return ("Redo change " + toString(myDestProbReroute->getTag()) + " values").c_str();
409  } else if (myParkingAreaReroute) {
410  return ("Redo change " + toString(myParkingAreaReroute->getTag()) + " values").c_str();
411  } else if (myRouteProbReroute) {
412  return ("Redo change " + toString(myRouteProbReroute->getTag()) + " values").c_str();
413  } else {
414  throw ProcessError("There isn't a defined Rerouter item");
415  }
416 }
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:42
GNERerouter * getRerouterParent() const
get rerouter parent
void removeRerouterInterval(GNERerouterInterval *rerouterInterval)
add rerouter interval
GNEDestProbReroute * myDestProbReroute
modified Closing Interval
void addDestProbReroute(GNEDestProbReroute *destProbReroute)
add destiny probability reroute
FXString undoName() const
return undoName
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void removeParkingAreaReroute(GNEParkingAreaReroute *parkingAreaReroute)
add destiny probability reroute
FXString redoName() const
get Redo name
void removeDestProbReroute(GNEDestProbReroute *destProbReroute)
add destiny probability reroute
void addClosingReroute(GNEClosingReroute *closingReroute)
add closing reroute
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:193
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
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:49
GNERerouterInterval * getRerouterIntervalParent() const
get rerouter interval parent
void requiereSaveAdditionals(bool value)
inform that additionals has to be saved
Definition: GNENet.cpp:1851
void removeClosingLaneReroute(GNEClosingLaneReroute *closingLaneReroute)
add closing reroute
GNERerouterInterval * getRerouterIntervalParent() const
get rerouter interval parent
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
GNERerouterInterval * getRerouterIntervalParent() const
get rerouter interval parent
void decRef(const std::string &debugMsg="")
Decrease reference.
GNEClosingLaneReroute * myClosingLaneReroute
modified Closing lane Reroute
GNEChange_RerouterItem(GNERerouterInterval *rerouterInterval, bool forward)
Constructor.
GNEParkingAreaReroute * myParkingAreaReroute
modified parkingAreaReroute
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
GNEClosingReroute * myClosingReroute
modified Closing Reroute
GNERerouterInterval * getRerouterIntervalParent() const
get rerouter interval parent
void addParkingAreaReroute(GNEParkingAreaReroute *parkingAreaReroute)
add destiny probability reroute
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:80
SumoXMLTag getTag() const
get XML Tag assigned to this object
GNERerouterInterval * getRerouterIntervalParent() const
get rerouter interval parent
void addClosingLaneReroute(GNEClosingLaneReroute *closingLaneReroute)
add closing reroute
bool unreferenced()
check if object ins&#39;t referenced
void removeRouteProbReroute(GNERouteProbReroute *routeProbabilityReroute)
add reoute probability reroute
GNERerouterInterval * myRerouterInterval
modified rerouter interval