Eclipse SUMO - Simulation of Urban MObility
GNELoadThread.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // The thread that performs the loading of a Netedit-net (adapted from
19 // GUILoadThread)
20 /****************************************************************************/
21 #include <netbuild/NBFrame.h>
22 #include <netbuild/NBNetBuilder.h>
23 #include <netimport/NIFrame.h>
24 #include <netimport/NILoader.h>
25 #include <netwrite/NWFrame.h>
31 #include <utils/xml/XMLSubSys.h>
32 
33 #include "GNEApplicationWindow.h"
34 #include "GNEEvent_NetworkLoaded.h"
35 #include "GNELoadThread.h"
36 #include "GNENet.h"
37 
38 
39 // ===========================================================================
40 // member method definitions
41 // ===========================================================================
43  MFXSingleEventThread(applicationWindow->getApp(), applicationWindow),
44  myApplicationWindow(applicationWindow),
45  myEventQueue(eq),
46  myEventThrow(ev) {
53 }
54 
55 
57  delete myDebugRetriever;
58  delete myGLDebugRetriever;
59  delete myErrorRetriever;
60  delete myMessageRetriever;
61  delete myWarningRetriever;
62 }
63 
64 
65 FXint
67  auto& neteditOptions = OptionsCont::getOptions();
68  // register message callbacks
74  // flag for check if input is valid
75  bool validInput = false;
76  // declare network
77  GNENet* net = nullptr;
78  // declare loaded file
79  std::string loadedFile;
80  // check conditions
81  if (neteditOptions.getBool("new")) {
82  // create new network
83  validInput = true;
84  } else if (neteditOptions.getString("osm-files").size() > 0) {
85  // load an osm file
86  validInput = true;
87  } else if (neteditOptions.getString("net-file").size() > 0) {
88  // load a network file
89  validInput = true;
90  loadedFile = neteditOptions.getString("net-file");
91  } else if (neteditOptions.getString("sumocfg-file").size() > 0) {
92  // set sumo config as loaded file
93  loadedFile = neteditOptions.getString("sumocfg-file");
94  // declare parser for sumo config file
96  // if there is an error loading sumo config, stop
97  if (confighandler.loadSumoConfig()) {
98  validInput = true;
99  } else {
100  WRITE_ERRORF(TL("Loading of sumo config file '%' failed."), loadedFile);
101  submitEndAndCleanup(net, loadedFile);
102  return 0;
103  }
104  } else if (neteditOptions.getString("configuration-file").size() > 0) {
105  // set netedit config as loaded file
106  loadedFile = neteditOptions.getString("configuration-file");
107  // declare parser for netedit config file
108  GNEApplicationWindowHelper::GNENeteditConfigHandler confighandler(loadedFile);
109  // if there is an error loading sumo config, stop
110  if (confighandler.loadNeteditConfig()) {
111  validInput = true;
112  } else {
113  WRITE_ERRORF(TL("Loading of netedit config file '%' failed."), loadedFile);
114  submitEndAndCleanup(net, loadedFile);
115  return 0;
116  }
117  } else if (loadConsoleOptions()) {
118  validInput = true;
119  }
120  // check input
121  if (!validInput) {
122  WRITE_ERROR(TL("Invalid input network option. Load with either sumo/netedit/netconvert config or with -new option"));
123  submitEndAndCleanup(net, loadedFile);
124  return 0;
125  }
126  // update aggregate warnings
127  if (neteditOptions.isDefault("aggregate-warnings")) {
128  neteditOptions.setDefault("aggregate-warnings", "5");
129  }
130  // init output options
132  // if there is an error checking options, stop
133  if (!(NIFrame::checkOptions(neteditOptions) && NBFrame::checkOptions(neteditOptions) &&
134  NWFrame::checkOptions(neteditOptions) && SystemFrame::checkOptions(neteditOptions))) {
135  // options are not valid
136  WRITE_ERROR(TL("Invalid Options. Nothing loaded"));
137  submitEndAndCleanup(net, loadedFile);
138  return 0;
139  }
140  // clear message instances
146  // init global random seed
148  // check if geo projection can be initialized
149  if (!GeoConvHelper::init(neteditOptions)) {
150  WRITE_ERROR(TL("Could not build projection!"));
151  submitEndAndCleanup(net, loadedFile);
152  return 0;
153  }
154  // set validation
155  XMLSubSys::setValidation(neteditOptions.getString("xml-validation"), neteditOptions.getString("xml-validation.net"), neteditOptions.getString("xml-validation.routes"));
156  // check if Debug has to be enabled
157  MsgHandler::enableDebugMessages(neteditOptions.getBool("gui-testing-debug"));
158  // check if GL Debug has to be enabled
159  MsgHandler::enableDebugGLMessages(neteditOptions.getBool("gui-testing-debug-gl"));
160  // create netBuilder (will be destroyed in GNENet destructor)
161  NBNetBuilder* netBuilder = new NBNetBuilder();
162  // apply netedit options in netBuilder. In this options we have all information for building network
163  netBuilder->applyOptions(neteditOptions);
164  // check if create a new net
165  if (neteditOptions.getBool("new")) {
166  // create new network
167  net = new GNENet(netBuilder);
168  } else {
169  // declare net loader
170  NILoader nl(*netBuilder);
171  try {
172  // try to load network using netedit options
173  nl.load(neteditOptions);
174  if (true) { // CHECK
175  // make coordinate conversion usable before first netBuilder->compute()
177  } else {
178  WRITE_MESSAGE(TL("Performing initial computation ..."));
179  // perform one-time processing (i.e. edge removal)
180  netBuilder->compute(neteditOptions);
181  // @todo remove one-time processing options!
182  }
183  // check if ignore errors
184  if (neteditOptions.getBool("ignore-errors")) {
186  }
187  // check whether any errors occurred
188  if (MsgHandler::getErrorInstance()->wasInformed()) {
189  throw ProcessError();
190  } else {
191  // now create net with al information loaded in net builder
192  net = new GNENet(netBuilder);
193  // check if change traffic direction
194  if (neteditOptions.getBool("lefthand")) {
195  // force initial geometry computation without volatile options because the net will look strange otherwise
196  net->computeAndUpdate(neteditOptions, false);
197  }
198  // check if add prefixes
199  if (neteditOptions.getString("prefix").size() > 0) {
200  // change prefixes in attributeCarriers
201  net->getAttributeCarriers()->addPrefixToEdges(neteditOptions.getString("prefix"));
202  net->getAttributeCarriers()->addPrefixToJunctions(neteditOptions.getString("prefix"));
203  // change prefix in containers
204  net->getNetBuilder()->getNodeCont().addPrefix(neteditOptions.getString("prefix"));
205  net->getNetBuilder()->getEdgeCont().addPrefix(neteditOptions.getString("prefix"));
206  }
207  }
208  } catch (ProcessError& e) {
209  if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
210  WRITE_ERROR(e.what());
211  }
212  WRITE_ERROR(TL("Failed to build network."));
213  // check if delete network
214  if (net != nullptr) {
215  delete net;
216  net = nullptr;
217  } else {
218  // GNENet not created, then delete netBuilder
219  delete netBuilder;
220  }
221  } catch (std::exception& e) {
222  WRITE_ERROR(e.what());
223  // check if delete network
224  if (net != nullptr) {
225  delete net;
226  net = nullptr;
227  } else {
228  // GNENet not created, then delete netBuilder
229  delete netBuilder;
230  }
231  }
232  }
233  // only a single setting file is supported
234  submitEndAndCleanup(net, loadedFile, neteditOptions.getString("gui-settings-file"), neteditOptions.getBool("registry-viewport"));
235  return 0;
236 }
237 
238 
239 
240 void
241 GNELoadThread::submitEndAndCleanup(GNENet* net, const std::string& loadedFile, const std::string& guiSettingsFile, const bool viewportFromRegistry) {
242  // remove message callbacks
248  // inform parent about the process
249  myEventQueue.push_back(new GNEEvent_NetworkLoaded(net, loadedFile, guiSettingsFile, viewportFromRegistry));
251 }
252 
253 
254 void
256  neteditOptions.clear();
257  neteditOptions.addCallExample("--new", TL("Start plain GUI with empty net"));
258  neteditOptions.addCallExample("-s <SUMO_NET>", TL("Open a SUMO network"));
259  neteditOptions.addCallExample("-c <CONFIGURATION>", TL("Open a configuration file (netedit or netconvert config)"));
260  neteditOptions.addCallExample("-sumocfg-file <CONFIGURATION>", TL("Open a SUMO config file"));
261 
262  SystemFrame::addConfigurationOptions(neteditOptions); // this subtopic is filled here, too
263  neteditOptions.addOptionSubTopic("Input");
264  neteditOptions.addOptionSubTopic("Output");
265  GeoConvHelper::addProjectionOptions(neteditOptions);
266  neteditOptions.addOptionSubTopic("Processing");
267  neteditOptions.addOptionSubTopic("Building Defaults");
268  neteditOptions.addOptionSubTopic("TLS Building");
269  neteditOptions.addOptionSubTopic("Ramp Guessing");
270  neteditOptions.addOptionSubTopic("Edge Removal");
271  neteditOptions.addOptionSubTopic("Unregulated Nodes");
272  neteditOptions.addOptionSubTopic("Junctions");
273  neteditOptions.addOptionSubTopic("Pedestrian");
274  neteditOptions.addOptionSubTopic("Bicycle");
275  neteditOptions.addOptionSubTopic("Railway");
276  neteditOptions.addOptionSubTopic("Formats");
277  neteditOptions.addOptionSubTopic("Netedit");
278  neteditOptions.addOptionSubTopic("Visualisation");
279  neteditOptions.addOptionSubTopic("Time");
280 
281  // TOPIC: Input
282 
283  neteditOptions.doRegister("sumocfg-file", new Option_FileName());
284  neteditOptions.addSynonyme("sumocfg-file", "sumocfg");
285  neteditOptions.addDescription("sumocfg-file", "Input", TL("Load sumo config"));
286 
287  neteditOptions.doRegister("additional-files", 'a', new Option_FileName());
288  neteditOptions.addSynonyme("additional-files", "additional");
289  neteditOptions.addDescription("additional-files", "Input", TL("Load additional and shapes descriptions from FILE(s)"));
290 
291  neteditOptions.doRegister("route-files", 'r', new Option_FileName());
292  neteditOptions.addSynonyme("route-files", "routes");
293  neteditOptions.addDescription("route-files", "Input", TL("Load demand elements descriptions from FILE(s)"));
294 
295  neteditOptions.doRegister("data-files", 'd', new Option_FileName());
296  neteditOptions.addSynonyme("data-files", "data");
297  neteditOptions.addDescription("data-files", "Input", TL("Load data elements descriptions from FILE(s)"));
298 
299  neteditOptions.doRegister("meandata-files", 'm', new Option_FileName());
300  neteditOptions.addSynonyme("meandata-files", "meandata");
301  neteditOptions.addDescription("meandata-files", "Input", TL("Load meanData descriptions from FILE(s)"));
302 
303  neteditOptions.doRegister("ignore-missing-inputs", new Option_Bool(false));
304  neteditOptions.addDescription("ignore-missing-inputs", "Input", TL("Reset path values (additional, route, data...) after loading netedit config"));
305 
306  // TOPIC: Output
307 
308  neteditOptions.doRegister("tls-file", new Option_String());
309  neteditOptions.addDescription("tls-file", "Output", TL("File in which TLS Programs must be saved"));
310 
311  neteditOptions.doRegister("edgetypes-file", new Option_String());
312  neteditOptions.addDescription("edgetypes-file", "Output", TL("File in which edgeTypes must be saved"));
313 
314  // TOPIC: Netedit
315 
316  neteditOptions.doRegister("new-network", new Option_Bool(false));
317  neteditOptions.addSynonyme("new-network", "new");
318  neteditOptions.addDescription("new-network", "Netedit", TL("Start netedit with a new network"));
319 
320  neteditOptions.doRegister("attribute-help-output", new Option_FileName());
321  neteditOptions.addDescription("attribute-help-output", "Netedit", TL("Write attribute help to file"));
322 
323  neteditOptions.doRegister("ignore-supermode-question", new Option_Bool(false));
324  neteditOptions.addDescription("ignore-supermode-question", "Netedit", TL("Ignore question dialog during changing between supermodes in undo-redo"));
325 
326  neteditOptions.doRegister("ignore.additionalelements", new Option_Bool(false));
327  neteditOptions.addDescription("ignore.additionalelements", "Netedit", TL("Ignore additional elements during loading of sumo-configs"));
328 
329  neteditOptions.doRegister("ignore.routeelements", new Option_Bool(false));
330  neteditOptions.addDescription("ignore.routeelements", "Netedit", TL("Ignore route elements during loading of sumo-configs"));
331 
332  // network prefixes
333 
334  neteditOptions.doRegister("node-prefix", new Option_String("J"));
335  neteditOptions.addDescription("node-prefix", "Netedit", TL("Prefix for node naming"));
336 
337  neteditOptions.doRegister("edge-prefix", new Option_String("E"));
338  neteditOptions.addDescription("edge-prefix", "Netedit", TL("Prefix for edge naming"));
339 
340  neteditOptions.doRegister("edge-infix", new Option_String(""));
341  neteditOptions.addDescription("edge-infix", "Netedit", TL("Enable edge-infix (<fromNodeID><infix><toNodeID>)"));
342 
343  // additional prefixes
344 
345  neteditOptions.doRegister("busStop-prefix", new Option_String("bs"));
346  neteditOptions.addDescription("busStop-prefix", "Netedit", TL("Prefix for busStop naming"));
347 
348  neteditOptions.doRegister("trainStop-prefix", new Option_String("ts"));
349  neteditOptions.addDescription("trainStop-prefix", "Netedit", TL("Prefix for trainStop naming"));
350 
351  neteditOptions.doRegister("containerStop-prefix", new Option_String("ct"));
352  neteditOptions.addDescription("containerStop-prefix", "Netedit", TL("Prefix for containerStop naming"));
353 
354  neteditOptions.doRegister("chargingStation-prefix", new Option_String("cs"));
355  neteditOptions.addDescription("chargingStation-prefix", "Netedit", TL("Prefix for chargingStation naming"));
356 
357  neteditOptions.doRegister("parkingArea-prefix", new Option_String("pa"));
358  neteditOptions.addDescription("parkingArea-prefix", "Netedit", TL("Prefix for parkingArea naming"));
359 
360  neteditOptions.doRegister("e1Detector-prefix", new Option_String("e1"));
361  neteditOptions.addDescription("e1Detector-prefix", "Netedit", TL("Prefix for e1Detector naming"));
362 
363  neteditOptions.doRegister("e2Detector-prefix", new Option_String("e2"));
364  neteditOptions.addDescription("e2Detector-prefix", "Netedit", TL("Prefix for e2Detector naming"));
365 
366  neteditOptions.doRegister("e3Detector-prefix", new Option_String("e3"));
367  neteditOptions.addDescription("e3Detector-prefix", "Netedit", TL("Prefix for e3Detector naming"));
368 
369  neteditOptions.doRegister("e1InstantDetector-prefix", new Option_String("e1i"));
370  neteditOptions.addDescription("e1InstantDetector-prefix", "Netedit", TL("Prefix for e1InstantDetector naming"));
371 
372  neteditOptions.doRegister("rerouter-prefix", new Option_String("rr"));
373  neteditOptions.addDescription("rerouter-prefix", "Netedit", TL("Prefix for rerouter naming"));
374 
375  neteditOptions.doRegister("calibrator-prefix", new Option_String("ca"));
376  neteditOptions.addDescription("calibrator-prefix", "Netedit", TL("Prefix for calibrator naming"));
377 
378  neteditOptions.doRegister("routeProbe-prefix", new Option_String("rp"));
379  neteditOptions.addDescription("routeProbe-prefix", "Netedit", TL("Prefix for routeProbe naming"));
380 
381  neteditOptions.doRegister("vss-prefix", new Option_String("vs"));
382  neteditOptions.addDescription("vss-prefix", "Netedit", TL("Prefix for variable speed sign naming"));
383 
384  neteditOptions.doRegister("tractionSubstation-prefix", new Option_String("tr"));
385  neteditOptions.addDescription("tractionSubstation-prefix", "Netedit", TL("Prefix for traction substation naming"));
386 
387  neteditOptions.doRegister("overheadWire-prefix", new Option_String("ow"));
388  neteditOptions.addDescription("overheadWire-prefix", "Netedit", TL("Prefix for overhead wire naming"));
389 
390  neteditOptions.doRegister("polygon-prefix", new Option_String("po"));
391  neteditOptions.addDescription("polygon-prefix", "Netedit", TL("Prefix for polygon naming"));
392 
393  neteditOptions.doRegister("poi-prefix", new Option_String("poi"));
394  neteditOptions.addDescription("poi-prefix", "Netedit", TL("Prefix for poi naming"));
395 
396  neteditOptions.doRegister("jps.walkableArea-prefix", new Option_String("jps.walkable_area"));
397  neteditOptions.addDescription("jps.walkableArea-prefix", "Netedit", TL("Prefix for jps walkable area naming"));
398 
399  neteditOptions.doRegister("jps.obstacle-prefix", new Option_String("jps.obstacle"));
400  neteditOptions.addDescription("jps.obstacle-prefix", "Netedit", TL("Prefix for jps obstacle naming"));
401 
402  // demand prefixes
403 
404  neteditOptions.doRegister("route-prefix", new Option_String("r"));
405  neteditOptions.addDescription("route-prefix", "Netedit", TL("Prefix for route naming"));
406 
407  neteditOptions.doRegister("routeDistribution-prefix", new Option_String("rd"));
408  neteditOptions.addDescription("routeDistribution-prefix", "Netedit", TL("Prefix for route distribution naming"));
409 
410  neteditOptions.doRegister("vType-prefix", new Option_String("t"));
411  neteditOptions.addDescription("vType-prefix", "Netedit", TL("Prefix for type naming"));
412 
413  neteditOptions.doRegister("vTypeDistribution-prefix", new Option_String("td"));
414  neteditOptions.addDescription("vTypeDistribution-prefix", "Netedit", TL("Prefix for type distribution naming"));
415 
416  neteditOptions.doRegister("vehicle-prefix", new Option_String("v"));
417  neteditOptions.addDescription("vehicle-prefix", "Netedit", TL("Prefix for vehicle naming"));
418 
419  neteditOptions.doRegister("trip-prefix", new Option_String("t"));
420  neteditOptions.addDescription("trip-prefix", "Netedit", TL("Prefix for trip naming"));
421 
422  neteditOptions.doRegister("flow-prefix", new Option_String("f"));
423  neteditOptions.addDescription("flow-prefix", "Netedit", TL("Prefix for flow naming"));
424 
425  neteditOptions.doRegister("person-prefix", new Option_String("p"));
426  neteditOptions.addDescription("person-prefix", "Netedit", TL("Prefix for person naming"));
427 
428  neteditOptions.doRegister("personflow-prefix", new Option_String("pf"));
429  neteditOptions.addDescription("personflow-prefix", "Netedit", TL("Prefix for personFlow naming"));
430 
431  neteditOptions.doRegister("container-prefix", new Option_String("c"));
432  neteditOptions.addDescription("container-prefix", "Netedit", TL("Prefix for container naming"));
433 
434  neteditOptions.doRegister("containerflow-prefix", new Option_String("cf"));
435  neteditOptions.addDescription("containerflow-prefix", "Netedit", TL("Prefix for containerFlow naming"));
436 
437  // data prefixes
438 
439  // mean data prefixes
440 
441  neteditOptions.doRegister("meanDataEdge-prefix", new Option_String("ed"));
442  neteditOptions.addDescription("meanDataEdge-prefix", "Netedit", TL("Prefix for meanDataEdge naming"));
443 
444  neteditOptions.doRegister("meanDataLane-prefix", new Option_String("ld"));
445  neteditOptions.addDescription("meanDataLane-prefix", "Netedit", TL("Prefix for meanDataLane naming"));
446 
447  // TOPIC: Visualisation
448 
449  // textures
450 
451  neteditOptions.doRegister("disable-laneIcons", new Option_Bool(false));
452  neteditOptions.addDescription("disable-laneIcons", "Visualisation", TL("Disable icons of special lanes"));
453 
454  neteditOptions.doRegister("disable-textures", 'T', new Option_Bool(false)); // !!!
455  neteditOptions.addDescription("disable-textures", "Visualisation", TL("Disable textures"));
456 
457  neteditOptions.doRegister("gui-settings-file", 'g', new Option_FileName());
458  neteditOptions.addDescription("gui-settings-file", "Visualisation", TL("Load visualisation settings from FILE"));
459 
460  // windows position
461 
462  neteditOptions.doRegister("registry-viewport", new Option_Bool(false));
463  neteditOptions.addDescription("registry-viewport", "Visualisation", TL("Load current viewport from registry"));
464 
465  neteditOptions.doRegister("window-size", new Option_StringVector());
466  neteditOptions.addDescription("window-size", "Visualisation", TL("Create initial window with the given x,y size"));
467 
468  neteditOptions.doRegister("window-pos", new Option_StringVector());
469  neteditOptions.addDescription("window-pos", "Visualisation", TL("Create initial window at the given x,y position"));
470 
471  // testing
472 
473  neteditOptions.doRegister("gui-testing", new Option_Bool(false));
474  neteditOptions.addDescription("gui-testing", "Visualisation", TL("Enable overlay for screen recognition"));
475 
476  neteditOptions.doRegister("gui-testing-debug", new Option_Bool(false));
477  neteditOptions.addDescription("gui-testing-debug", "Visualisation", TL("Enable output messages during GUI-Testing"));
478 
479  neteditOptions.doRegister("gui-testing-debug-gl", new Option_Bool(false));
480  neteditOptions.addDescription("gui-testing-debug-gl", "Visualisation", TL("Enable output messages during GUI-Testing specific of gl functions"));
481 
482  neteditOptions.doRegister("gui-testing.setting-output", new Option_FileName());
483  neteditOptions.addDescription("gui-testing.setting-output", "Visualisation", TL("Save gui settings in the given settings-output file"));
484 
485  // TOPIC: Time
486 
487  // register the simulation settings (needed for GNERouteHandler)
488 
489  neteditOptions.doRegister("begin", new Option_String("0", "TIME"));
490  neteditOptions.addDescription("begin", "Time", TL("Defines the begin time in seconds; The simulation starts at this time"));
491 
492  neteditOptions.doRegister("end", new Option_String("-1", "TIME"));
493  neteditOptions.addDescription("end", "Time", TL("Defines the end time in seconds; The simulation ends at this time"));
494 
495  neteditOptions.doRegister("default.action-step-length", new Option_Float(0.0));
496  neteditOptions.addDescription("default.action-step-length", "Processing", TL("Length of the default interval length between action points for the car-following and lane-change models (in seconds). If not specified, the simulation step-length is used per default. Vehicle- or VType-specific settings override the default. Must be a multiple of the simulation step-length."));
497 
498  neteditOptions.doRegister("default.speeddev", new Option_Float(-1));
499  neteditOptions.addDescription("default.speeddev", "Processing", TL("Select default speed deviation. A negative value implies vClass specific defaults (0.1 for the default passenger class)"));
500 
501  // fill rest of options
502 
503  NIFrame::fillOptions(neteditOptions, true);
504  NBFrame::fillOptions(neteditOptions, false);
505  NWFrame::fillOptions(neteditOptions, false);
506  RandHelper::insertRandOptions(neteditOptions);
507 }
508 
509 
510 void
512  neteditOptions.resetWritable();
513  neteditOptions.set("offset.disable-normalization", "true"); // preserve the given network as far as possible
514  neteditOptions.set("no-turnarounds", "true"); // otherwise it is impossible to manually removed turn-arounds
515 }
516 
517 
518 bool
520  // only loaded once
522  // get netedit options
523  auto& neteditOptions = OptionsCont::getOptions();
524  // fill (reset) all options
525  fillOptions(neteditOptions);
526  // set default options defined in GNELoadThread::setDefaultOptions(...)
527  setDefaultOptions(neteditOptions);
528  try {
529  // set all values writable, because certain attributes already setted can be updated through console
531  // load options from console
533  return true;
534  } catch (ProcessError& e) {
535  if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
536  WRITE_ERROR(e.what());
537  }
538  WRITE_ERROR(TL("Failed to reset options."));
539  return false;
540  }
541  } else {
542  return false;
543  }
544 }
545 
546 
547 void
549  auto& neteditOptions = OptionsCont::getOptions();
550  // reset netedit options
551  fillOptions(neteditOptions);
552  setDefaultOptions(neteditOptions);
553  // enable option "new"
554  neteditOptions.resetWritable();
555  neteditOptions.set("new", "true");
556  // start thread
557  start();
558 }
559 
560 
561 void
563  // start thread
564  start();
565 }
566 
567 
568 void
569 GNELoadThread::retrieveMessage(const MsgHandler::MsgType type, const std::string& msg) {
570  myEventQueue.push_back(new GUIEvent_Message(type, msg));
572 }
573 
574 /****************************************************************************/
#define WRITE_ERRORF(...)
Definition: MsgHandler.h:305
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:297
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:304
#define TL(string)
Definition: MsgHandler.h:315
The main window of Netedit.
OptionsCont & getSumoOptions()
get SUMO options container
bool consoleOptionsLoaded()
check if console options was already loaded
MFXSynchQue< GUIEvent * > & myEventQueue
event Queue
Definition: GNELoadThread.h:89
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations Needed to be deleted from the handler later on.
Definition: GNELoadThread.h:86
void retrieveMessage(const MsgHandler::MsgType type, const std::string &msg)
Retrieves messages from the loading module.
void newNetwork()
begins the creation of an empty network
static void fillOptions(OptionsCont &neteditOptions)
clears and initializes the OptionsCont
void loadNetworkOrConfig()
begins the loading of an existent network or config
OutputDevice * myWarningRetriever
Definition: GNELoadThread.h:86
GNEApplicationWindow * myApplicationWindow
netedit application windows
Definition: GNELoadThread.h:83
bool loadConsoleOptions()
load options through console
OutputDevice * myMessageRetriever
Definition: GNELoadThread.h:86
static void setDefaultOptions(OptionsCont &neteditOptions)
sets required options for proper functioning
virtual ~GNELoadThread()
destructor
OutputDevice * myGLDebugRetriever
Definition: GNELoadThread.h:86
OutputDevice * myDebugRetriever
Definition: GNELoadThread.h:86
void submitEndAndCleanup(GNENet *net, const std::string &loadedFile, const std::string &guiSettingsFile="", const bool viewportFromRegistry=false)
Closes the loading process.
FXEX::MFXThreadEvent & myEventThrow
event throw
Definition: GNELoadThread.h:92
FXint run()
starts the thread. The thread ends after the net has been loaded
GNELoadThread(GNEApplicationWindow *applicationWindow, MFXSynchQue< GUIEvent * > &eq, FXEX::MFXThreadEvent &ev)
constructor
void addPrefixToJunctions(const std::string &prefix)
add prefix to all junctions
void addPrefixToEdges(const std::string &prefix)
add prefix to all edges
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
void computeAndUpdate(OptionsCont &neteditOptions, bool volatileOptions)
recompute the network and update lane geometries
Definition: GNENet.cpp:2793
NBNetBuilder * getNetBuilder() const
get net builder
Definition: GNENet.cpp:1451
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:121
static void addProjectionOptions(OptionsCont &oc)
Adds projection options to the given container.
static bool init(OptionsCont &oc)
Initialises the processing and the final instance using the given options.
static void computeFinal(bool lefthand=false)
compute the location attributes which will be used for output based on the loaded location data,...
void push_back(T what)
Definition: MFXSynchQue.h:113
virtual void addRetriever(OutputDevice *retriever)
Adds a further retriever to the instance responsible for a certain msg type.
Definition: MsgHandler.cpp:237
static MsgHandler * getGLDebugInstance()
Returns the instance to add GLdebug to.
Definition: MsgHandler.cpp:110
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:92
static void enableDebugGLMessages(bool enable)
enable/disable gl-debug messages
Definition: MsgHandler.cpp:124
static void initOutputOptions()
init output options
Definition: MsgHandler.cpp:316
static MsgHandler * getDebugInstance()
Returns the instance to add debug to.
Definition: MsgHandler.cpp:101
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Definition: MsgHandler.cpp:79
static void enableDebugMessages(bool enable)
enable/disable debug messages
Definition: MsgHandler.cpp:119
virtual void clear(bool resetInformed=true)
Clears information whether an error occurred previously and print aggregated message summary.
Definition: MsgHandler.cpp:213
virtual void removeRetriever(OutputDevice *retriever)
Removes the retriever from the handler.
Definition: MsgHandler.cpp:245
@ MT_GLDEBUG
The message is GL debug output.
@ MT_DEBUG
The message is debug output.
@ MT_MESSAGE
The message is only something to show.
@ MT_ERROR
The message is an error.
@ MT_WARNING
The message is a warning.
static MsgHandler * getMessageInstance()
Returns the instance to add normal messages to.
Definition: MsgHandler.cpp:66
Encapsulates an object's method for using it as a message retriever.
void addPrefix(const std::string &prefix)
add prefix to all edges
static void fillOptions(OptionsCont &oc, bool forNetgen)
Inserts options used by the network converter.
Definition: NBFrame.cpp:48
static bool checkOptions(OptionsCont &oc)
Checks set options from the OptionsCont-singleton for being valid.
Definition: NBFrame.cpp:732
Instance responsible for building networks.
Definition: NBNetBuilder.h:107
NBEdgeCont & getEdgeCont()
Definition: NBNetBuilder.h:139
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
void compute(OptionsCont &oc, const std::set< std::string > &explicitTurnarounds=std::set< std::string >(), bool mayAddOrRemove=true)
Performs the network building steps.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
Definition: NBNetBuilder.h:144
void addPrefix(const std::string &prefix)
add prefix to all nodes
static bool checkOptions(OptionsCont &oc)
Checks set options for being valid.
Definition: NIFrame.cpp:391
static void fillOptions(OptionsCont &oc, bool forNetedit=false)
Inserts options used by the network importer and network building modules.
Definition: NIFrame.cpp:48
Perfoms network import.
Definition: NILoader.h:48
void load(OptionsCont &oc)
Definition: NILoader.cpp:70
static void fillOptions(OptionsCont &oc, bool forNetgen)
Inserts options used by the network writer.
Definition: NWFrame.cpp:49
static bool checkOptions(OptionsCont &oc)
Checks set options for being valid.
Definition: NWFrame.cpp:139
A storage for options typed value containers)
Definition: OptionsCont.h:89
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
void doRegister(const std::string &name, Option *o)
Adds an option under the given name.
Definition: OptionsCont.cpp:76
void clear()
Removes all information from the container.
bool set(const std::string &name, const std::string &value, const bool append=false)
Sets the given value for the named option.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
void resetWritable()
Resets all options to be writeable.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:60
void addCallExample(const std::string &example, const std::string &desc)
Add a call example.
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
Definition: OptionsIO.cpp:74
static void insertRandOptions(OptionsCont &oc)
Initialises the given options container with random number options.
Definition: RandHelper.cpp:59
static void initRandGlobal(SumoRNG *which=nullptr)
Reads the given random number options and initialises the random number generator in accordance.
Definition: RandHelper.cpp:87
static bool checkOptions(OptionsCont &oc)
checks shared options and sets StdDefs
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
Definition: SystemFrame.cpp:38
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme, const std::string &routeValidationScheme)
Enables or disables validation.
Definition: XMLSubSys.cpp:83