SUMO - Simulation of Urban MObility
GNEChange_CalibratorItem.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 Calibrators 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 
33 #include "GNENet.h"
34 #include "GNEViewNet.h"
35 #include "GNECalibrator.h"
36 #include "GNECalibratorFlow.h"
37 #include "GNECalibratorRoute.h"
39 
40 
41 // ===========================================================================
42 // FOX-declarations
43 // ===========================================================================
44 FXIMPLEMENT_ABSTRACT(GNEChange_CalibratorItem, GNEChange, NULL, 0)
45 
46 // ===========================================================================
47 // member method definitions
48 // ===========================================================================
49 
50 
52  GNEChange(calibratorFlow->getCalibratorParent()->getViewNet()->getNet(), forward),
53  myCalibratorFlow(calibratorFlow),
54  myCalibratorRoute(NULL),
55  myCalibratorVehicleType(NULL) {
56  myCalibratorFlow->incRef("GNEChange_CalibratorItem");
57 }
58 
59 
61  GNEChange(calibratorRoute->getCalibratorParent()->getViewNet()->getNet(), forward),
62  myCalibratorFlow(NULL),
63  myCalibratorRoute(calibratorRoute),
64  myCalibratorVehicleType(NULL) {
65  myCalibratorRoute->incRef("GNEChange_CalibratorItem");
66 }
67 
68 
70  GNEChange(calibratorVehicleType->getCalibratorParent()->getViewNet()->getNet(), forward),
71  myCalibratorFlow(NULL),
72  myCalibratorRoute(NULL),
73  myCalibratorVehicleType(calibratorVehicleType) {
74  myCalibratorVehicleType->incRef("GNEChange_CalibratorItem");
75 }
76 
77 
79  if (myCalibratorFlow) {
80  myCalibratorFlow->decRef("GNEChange_CalibratorItem");
82  // show extra information for tests
83  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
84  WRITE_WARNING("Deleting calibrator flow of calibrator '" + myCalibratorFlow->getCalibratorParent()->getID() + "'");
85  }
86  // make sure that calibrator flow isn't in net before removing
89  }
90  delete myCalibratorFlow;
91  }
92  } else if (myCalibratorRoute) {
93  myCalibratorRoute->decRef("GNEChange_CalibratorItem");
95  // show extra information for tests
96  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
97  WRITE_WARNING("Deleting calibrator route of calibrator '" + myCalibratorRoute->getCalibratorParent()->getID() + "'");
98  }
99  // make sure that calibrator route isn't in net before removing
102  }
103  delete myCalibratorRoute;
104  }
105  } else if (myCalibratorVehicleType) {
106  myCalibratorVehicleType->decRef("GNEChange_CalibratorItem");
108  // show extra information for tests
109  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
110  WRITE_WARNING("Deleting calibrator vehicle type of calibrator '" + myCalibratorVehicleType->getCalibratorParent()->getID() + "'");
111  }
112  // make sure that calibrator Vehicle Type isn't in net before removing
115  }
117  }
118  }
119 }
120 
121 
122 void
124  if (myForward) {
125  if (myCalibratorFlow) {
126  // show extra information for tests
127  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
128  WRITE_WARNING("Removing calibrator flow of calibrator '" + myCalibratorFlow->getCalibratorParent()->getID() + "'");
129  }
130  // remove calibrator flow of calibrator and net
133  } else if (myCalibratorRoute) {
134  // show extra information for tests
135  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
136  WRITE_WARNING("Removing calibrator route of calibrator '" + myCalibratorRoute->getCalibratorParent()->getID() + "'");
137  }
138  // remove calibrator route of calibrator and net
141  } else if (myCalibratorVehicleType) {
142  // show extra information for tests
143  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
144  WRITE_WARNING("Removing calibrator vehicle type of calibrator '" + myCalibratorVehicleType->getCalibratorParent()->getID() + "'");
145  }
146  // remove calibrator vehicle type of calibrator and net
149  } else {
150  throw ProcessError("There isn't a defined Calibrator item");
151  }
152  } else {
153  if (myCalibratorFlow) {
154  // show extra information for tests
155  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
156  WRITE_WARNING("Adding calibrator flow into calibrator '" + myCalibratorFlow->getCalibratorParent()->getID() + "'");
157  }
158  // add calibrator flow into calibrator and net
161  } else if (myCalibratorRoute) {
162  // show extra information for tests
163  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
164  WRITE_WARNING("Adding calibrator route into calibrator '" + myCalibratorRoute->getCalibratorParent()->getID() + "'");
165  }
166  // add calibrator route into calibrator and net
169  } else if (myCalibratorVehicleType) {
170  // show extra information for tests
171  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
172  WRITE_WARNING("Adding calibrator vehicle type into calibrator '" + myCalibratorVehicleType->getCalibratorParent()->getID() + "'");
173  }
174  // add calibrator vehicle type into calibrator and net
177  } else {
178  throw ProcessError("There isn't a defined Calibrator item");
179  }
180  }
181  // enable save additionals
183 }
184 
185 
186 void
188  if (myForward) {
189  if (myCalibratorFlow) {
190  // show extra information for tests
191  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
192  WRITE_WARNING("Adding calibrator flow into calibrator '" + myCalibratorFlow->getCalibratorParent()->getID() + "'");
193  }
194  // add calibrator flow into calibrator and net
197  } else if (myCalibratorRoute) {
198  // show extra information for tests
199  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
200  WRITE_WARNING("Adding calibrator route into calibrator '" + myCalibratorRoute->getCalibratorParent()->getID() + "'");
201  }
202  // add calibrator route into calibrator and net
205  } else if (myCalibratorVehicleType) {
206  // show extra information for tests
207  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
208  WRITE_WARNING("Adding calibrator vehicle type into calibrator '" + myCalibratorVehicleType->getCalibratorParent()->getID() + "'");
209  }
210  // add calibrator vehicle type into calibrator and net
213  } else {
214  throw ProcessError("There isn't a defined Calibrator item");
215  }
216  } else {
217  if (myCalibratorFlow) {
218  // show extra information for tests
219  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
220  WRITE_WARNING("Removing calibrator flow of calibrator '" + myCalibratorFlow->getCalibratorParent()->getID() + "'");
221  }
222  // remove calibrator flow of calibrator and net
225  } else if (myCalibratorRoute) {
226  // show extra information for tests
227  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
228  WRITE_WARNING("Removing calibrator route of calibrator '" + myCalibratorRoute->getCalibratorParent()->getID() + "'");
229  }
230  // remove calibrator route of calibrator and net
233  } else if (myCalibratorVehicleType) {
234  // show extra information for tests
235  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
236  WRITE_WARNING("Removing calibrator vehicle type of calibrator '" + myCalibratorVehicleType->getCalibratorParent()->getID() + "'");
237  }
238  // remove calibrator vehicle type of calibrator and net
241  } else {
242  throw ProcessError("There isn't a defined Calibrator item");
243  }
244  }
245  // enable save additionals
247 }
248 
249 
250 FXString
252  if (myCalibratorFlow) {
253  return ("Undo change " + toString(myCalibratorFlow->getTag()) + " values").c_str();
254  } else if (myCalibratorRoute) {
255  return ("Undo change " + toString(myCalibratorRoute->getTag()) + " values").c_str();
256  } else if (myCalibratorVehicleType) {
257  return ("Undo change " + toString(myCalibratorVehicleType->getTag()) + " values").c_str();
258  } else {
259  throw ProcessError("There isn't a defined Calibrator item");
260  }
261 }
262 
263 
264 FXString
266  if (myCalibratorFlow) {
267  return ("Redo change " + toString(myCalibratorFlow->getTag()) + " values").c_str();
268  } else if (myCalibratorRoute) {
269  return ("Redo change " + toString(myCalibratorRoute->getTag()) + " values").c_str();
270  } else if (myCalibratorVehicleType) {
271  return ("Redo change " + toString(myCalibratorVehicleType->getTag()) + " values").c_str();
272  } else {
273  throw ProcessError("There isn't a defined Calibrator item");
274  }
275 }
void insertCalibratorVehicleType(GNECalibratorVehicleType *vehicleType)
insert Calibrator VehicleType in net
Definition: GNENet.cpp:2095
void removeCalibratorFlow(GNECalibratorFlow *flow)
remove calibrator flow
FXString undoName() const
return undoName
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 deleteCalibratorRoute(GNECalibratorRoute *route)
delete Calibrator Route in net
Definition: GNENet.cpp:2063
GNECalibratorRoute * myCalibratorRoute
modified calibrator route
void removeCalibratorVehicleType(GNECalibratorVehicleType *vehicleType)
remove calibrator vehicleType
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void deleteCalibratorVehicleType(GNECalibratorVehicleType *vehicleType)
delete Calibrator VehicleType in net
Definition: GNENet.cpp:2105
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
GNEChange_CalibratorItem(GNECalibratorFlow *calibratorFlow, bool forward)
Constructor.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
void insertCalibratorRoute(GNECalibratorRoute *route)
insert Calibrator Route in net
Definition: GNENet.cpp:2053
void addCalibratorRoute(GNECalibratorRoute *route)
add calibrator route
void deleteCalibratorFlow(GNECalibratorFlow *flow)
delete Calibrator Flow in net
Definition: GNENet.cpp:2084
void removeCalibratorRoute(GNECalibratorRoute *route)
add calibrator route
void insertCalibratorFlow(GNECalibratorFlow *flow)
insert Calibrator Flow in net
Definition: GNENet.cpp:2074
const std::string getID() const
function to support debugging
GNECalibratorRoute * retrieveCalibratorRoute(const std::string &id, bool hardFail=true) const
Returns the named calibrator route.
Definition: GNENet.cpp:1800
void incRef(const std::string &debugMsg="")
Increarse reference.
GNECalibrator * getCalibratorParent() const
get pointer to calibrator parent
void decRef(const std::string &debugMsg="")
Decrease reference.
void addCalibratorVehicleType(GNECalibratorVehicleType *vehicleType)
add calibrator vehicleType
void addCalibratorFlow(GNECalibratorFlow *flow)
add calibrator flow
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
GNECalibratorVehicleType * myCalibratorVehicleType
modified calibrator vehicle type
GNECalibratorVehicleType * retrieveCalibratorVehicleType(const std::string &id, bool hardFail=true) const
Returns the named calibrator vehicle type.
Definition: GNENet.cpp:1816
GNECalibrator * getCalibratorParent() const
get pointer to calibrator parent
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:86
GNECalibratorFlow * myCalibratorFlow
modified calibrator flow
bool unreferenced()
check if object ins&#39;t referenced
GNECalibratorFlow * retrieveCalibratorFlow(const std::string &id, bool hardFail=true) const
Returns the named calibrator flow.
Definition: GNENet.cpp:1832
FXString redoName() const
get Redo name
SumoXMLTag getTag() const
get XML Tag assigned to this object
GNECalibrator * getCalibratorParent() const
get pointer to calibrator parent