Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2026 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
22#include <netbuild/NBFrame.h>
24#include <netimport/NIFrame.h>
25#include <netimport/NILoader.h>
26#include <netwrite/NWFrame.h>
33#include <utils/xml/XMLSubSys.h>
34
36#include "GNELoadThread.h"
37#include "GNENet.h"
38
39// ===========================================================================
40// member method definitions
41// ===========================================================================
54
55
63
64
65FXint
67 auto& neteditOptions = OptionsCont::getOptions();
68 // register message callbacks
72 // type of loading
74 // declare loaded file
75 std::string loadedFile;
76 // check conditions
77 if (neteditOptions.getBool("new")) {
78 // create new network
80 } else if (neteditOptions.getString("osm-files").size() > 0) {
81 // load an osm file
83 } else if (neteditOptions.getString("sumo-net-file").size() > 0) {
84 // load a network file
86 loadedFile = neteditOptions.getString("sumo-net-file");
87 // set network as default file in file bucket
89 } else if (neteditOptions.getString("netecfg-file").size() > 0) {
90 // load a sumo config file
92 // set sumo config as loaded file
93 loadedFile = neteditOptions.getString("netecfg-file");
94 } else if (neteditOptions.getString("sumocfg-file").size() > 0) {
95 // load a sumo config file
97 // set sumo config as loaded file
98 loadedFile = neteditOptions.getString("sumocfg-file");
99 } else if (neteditOptions.getString("netccfg-file").size() > 0) {
100 // load a netconvert config file
102 // set netconvert config file as loaded file
103 loadedFile = neteditOptions.getString("netccfg-file");
104 } else if (neteditOptions.getString("configuration-file").size() > 0) {
105 // get configuration
106 loadedFile = neteditOptions.getString("configuration-file");
107 // check the extension to determine what we're loading
108 if (StringUtils::endsWith(loadedFile, ".netccfg")) {
109 // load a netconvert config file
111 } else if (StringUtils::endsWith(loadedFile, ".sumocfg")) {
112 // load a sumo config file
114 } else if (StringUtils::endsWith(loadedFile, ".netecfg")) {
115 // load a netedit config file
117 } else {
118 // invalid config
120 // stop loading
121 return submitEndAndCleanup(type, nullptr, loadedFile);
122 }
123 } else if (loadConsoleOptions()) {
124 // load information through console
126 }
127 // run handlers
129 // declare parser for sumo config file
131 // if there is an error loading sumo config, stop
132 if (!confighandler.loadSumoConfig()) {
133 return submitEndAndCleanup(type, nullptr, loadedFile);
134 }
135 } else if (type == GNEEvent_FileLoaded::Type::NETCCFG) {
136 // declare parser for netedit config file
138 // if there is an error loading sumo config, stop
139 if (!confighandler.loadNetconvertConfig()) {
140 return submitEndAndCleanup(type, nullptr, loadedFile);
141 }
142 } else if (type == GNEEvent_FileLoaded::Type::NETECFG) {
143 // declare parser for netedit config file
145 // if there is an error loading sumo config, stop
146 if (!confighandler.loadNeteditConfig()) {
147 return submitEndAndCleanup(type, nullptr, loadedFile);
148 }
149 }
150 // check input
152 return submitEndAndCleanup(type, nullptr, loadedFile);
153 }
154 // update aggregate warnings
155 if (neteditOptions.isDefault("aggregate-warnings")) {
156 neteditOptions.setDefault("aggregate-warnings", "5");
157 }
158 // init output options
160 // if there is an error checking options, stop
161 if (!(NIFrame::checkOptions(neteditOptions) && NBFrame::checkOptions(neteditOptions) &&
162 NWFrame::checkOptions(neteditOptions) && SystemFrame::checkOptions(neteditOptions))) {
163 // options are not valid
165 }
166 // clear message instances
170 // init global random seed
172 // check if geo projection can be initialized
173 if (!GeoConvHelper::init(neteditOptions)) {
175 }
176 // set validation
177 XMLSubSys::setValidation(neteditOptions.getString("xml-validation"), neteditOptions.getString("xml-validation.net"), neteditOptions.getString("xml-validation.routes"));
178 // check if Debug has to be enabled
179 MsgHandler::enableDebugMessages(neteditOptions.getBool("gui-testing-debug"));
180 // check if GL Debug has to be enabled
181 MsgHandler::enableDebugGLMessages(neteditOptions.getBool("gui-testing-debug-gl"));
182 // create netBuilder (will be destroyed in GNENet destructor)
183 NBNetBuilder* netBuilder = new NBNetBuilder();
184 // apply netedit options in netBuilder. In this options we have all information for building network
185 netBuilder->applyOptions(neteditOptions);
186 // declare network
187 GNENet* net = nullptr;
188 // check if create a new net
189 if (neteditOptions.getBool("new")) {
190 // create new network
191 net = new GNENet(myApplicationWindow, netBuilder);
192 } else {
193 // declare net loader
194 NILoader nl(*netBuilder);
195 try {
196 // try to load network using netedit options
197 nl.load(neteditOptions);
198 if (true) { // CHECK
199 // make coordinate conversion usable before first netBuilder->compute()
201 } else {
202 WRITE_MESSAGE(TL("Performing initial computation ..."));
203 // perform one-time processing (i.e. edge removal)
204 netBuilder->compute(neteditOptions);
205 // @todo remove one-time processing options!
206 }
207 // check if ignore errors
208 if (neteditOptions.getBool("ignore-errors")) {
210 }
211 // check whether any errors occurred
212 if (MsgHandler::getErrorInstance()->wasInformed()) {
213 throw ProcessError();
214 } else {
215 // now create net with al information loaded in net builder
216 net = new GNENet(myApplicationWindow, netBuilder);
217 // check if change traffic direction
218 if (neteditOptions.getBool("lefthand")) {
219 // force initial geometry computation without volatile options because the net will look strange otherwise
220 net->computeAndUpdate(neteditOptions, false);
221 }
222 // check if add prefixes
223 if (neteditOptions.getString("prefix").size() > 0) {
224 // change prefixes in attributeCarriers
225 net->getAttributeCarriers()->addPrefixToEdges(neteditOptions.getString("prefix"));
226 net->getAttributeCarriers()->addPrefixToJunctions(neteditOptions.getString("prefix"));
227 // change prefix in containers
228 net->getNetBuilder()->getNodeCont().addPrefix(neteditOptions.getString("prefix"));
229 net->getNetBuilder()->getEdgeCont().addPrefix(neteditOptions.getString("prefix"));
230 }
231 }
232 } catch (ProcessError& e) {
233 if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
234 WRITE_ERROR(e.what());
235 }
236 WRITE_ERROR(TL("Failed to build network."));
237 // check if delete network
238 if (net != nullptr) {
239 delete net;
240 net = nullptr;
241 } else {
242 // GNENet not created, then delete netBuilder
243 delete netBuilder;
244 }
247 } catch (std::exception& e) {
248 WRITE_ERROR(e.what());
249 // check if delete network
250 if (net != nullptr) {
251 delete net;
252 net = nullptr;
253 } else {
254 // GNENet not created, then delete netBuilder
255 delete netBuilder;
256 }
257 }
258 }
259 // only a single setting file is supported
260 return submitEndAndCleanup(type, net, loadedFile, neteditOptions.getString("gui-settings-file"),
261 neteditOptions.getBool("registry-viewport"));
262}
263
264
265FXint
267 const std::string& guiSettingsFile, const bool viewportFromRegistry) {
268 // remove message callbacks
272 // inform parent about the process
273 myEventQueue.push_back(new GNEEvent_FileLoaded(type, net, loadedFile, guiSettingsFile, viewportFromRegistry));
275 return 0;
276}
277
278
279void
281 neteditOptions.clear();
282 neteditOptions.addCallExample("--new", TL("Start plain GUI with empty net"));
283 neteditOptions.addCallExample("-s <SUMO_NET>", TL("Open a SUMO network"));
284 neteditOptions.addCallExample("-c <CONFIGURATION>", TL("Open a configuration file (netedit or netconvert config)"));
285 neteditOptions.addCallExample("-sumocfg-file <CONFIGURATION>", TL("Open a SUMO config file"));
286
287 SystemFrame::addConfigurationOptions(neteditOptions); // this subtopic is filled here, too
288 neteditOptions.addOptionSubTopic("Input");
289 neteditOptions.addOptionSubTopic("Output");
291 neteditOptions.addOptionSubTopic("Processing");
292 neteditOptions.addOptionSubTopic("Building Defaults");
293 neteditOptions.addOptionSubTopic("TLS Building");
294 neteditOptions.addOptionSubTopic("Ramp Guessing");
295 neteditOptions.addOptionSubTopic("Edge Removal");
296 neteditOptions.addOptionSubTopic("Unregulated Nodes");
297 neteditOptions.addOptionSubTopic("Junctions");
298 neteditOptions.addOptionSubTopic("Pedestrian");
299 neteditOptions.addOptionSubTopic("Bicycle");
300 neteditOptions.addOptionSubTopic("Railway");
301 neteditOptions.addOptionSubTopic("Formats");
302 neteditOptions.addOptionSubTopic("Netedit");
303 neteditOptions.addOptionSubTopic("Visualisation");
304 neteditOptions.addOptionSubTopic("Time");
305
306 // TOPIC: Input
307 neteditOptions.doRegister("netecfg-file", new Option_FileName());
308 neteditOptions.addSynonyme("netecfg-file", "netecfg");
309 neteditOptions.addDescription("netecfg-file", "Input", TL("Load netedit config"));
310 neteditOptions.addXMLDefault("netecfg-file", "neteditConfiguration");
311 neteditOptions.setOptionEditable("netecfg-file", false);
312
313 neteditOptions.doRegister("sumocfg-file", new Option_FileName());
314 neteditOptions.addSynonyme("sumocfg-file", "sumocfg");
315 neteditOptions.addDescription("sumocfg-file", "Input", TL("Load sumo config"));
316 neteditOptions.addXMLDefault("sumocfg-file", "sumoConfiguration");
317 neteditOptions.setOptionEditable("sumocfg-file", false);
318
319 neteditOptions.doRegister("netccfg-file", new Option_FileName());
320 neteditOptions.addSynonyme("netccfg-file", "netccfg");
321 neteditOptions.addDescription("netccfg-file", "Input", TL("Load netconvert config"));
322 neteditOptions.addXMLDefault("netccfg-file", "netconvertConfiguration");
323 neteditOptions.setOptionEditable("netccfg-file", false);
324
325 neteditOptions.doRegister("additional-files", 'a', new Option_FileName());
326 neteditOptions.addSynonyme("additional-files", "additional");
327 neteditOptions.addDescription("additional-files", "Input", TL("Load additional and shapes descriptions from FILE(s)"));
328 neteditOptions.setOptionEditable("additional-files", false);
329
330 neteditOptions.doRegister("route-files", 'r', new Option_FileName());
331 neteditOptions.addSynonyme("route-files", "routes");
332 neteditOptions.addDescription("route-files", "Input", TL("Load demand elements descriptions from FILE(s)"));
333 neteditOptions.setOptionEditable("route-files", false);
334
335 neteditOptions.doRegister("data-files", 'd', new Option_FileName());
336 neteditOptions.addSynonyme("data-files", "data");
337 neteditOptions.addDescription("data-files", "Input", TL("Load data elements descriptions from FILE(s)"));
338 neteditOptions.setOptionEditable("data-files", false);
339
340 neteditOptions.doRegister("meandata-files", 'm', new Option_FileName());
341 neteditOptions.addSynonyme("meandata-files", "meandata");
342 neteditOptions.addDescription("meandata-files", "Input", TL("Load meanData descriptions from FILE(s)"));
343 neteditOptions.setOptionEditable("meandata-files", false);
344
345 neteditOptions.doRegister("ignore-missing-inputs", new Option_Bool(false));
346 neteditOptions.addDescription("ignore-missing-inputs", "Input", TL("Reset path values (additional, route, data...) after loading netedit config"));
347
348 neteditOptions.doRegister("autosave-netconvert-file", new Option_Bool(false));
349 neteditOptions.addDescription("autosave-netconvert-file", "Input", TL("If enabled, automatically save a netconvert configuration after saving a netedit config"));
350
351 neteditOptions.doRegister("selection-file", new Option_FileName());
352 neteditOptions.addDescription("selection-file", "Input", TL("Load element selection"));
353
354 neteditOptions.doRegister("test-file", new Option_FileName());
355 neteditOptions.addDescription("test-file", "Input", TL("Test file"));
356
357 // TOPIC: Output
358
359 neteditOptions.doRegister("tls-file", new Option_FileName());
360 neteditOptions.addDescription("tls-file", "Output", TL("File in which TLS Programs must be saved"));
361 neteditOptions.setOptionEditable("tls-file", false);
362
363 neteditOptions.doRegister("edgetypes-file", new Option_FileName());
364 neteditOptions.addDescription("edgetypes-file", "Output", TL("File in which edgeTypes must be saved"));
365 neteditOptions.setOptionEditable("edgetypes-file", false);
366
367 // TOPIC: Netedit
368
369 neteditOptions.doRegister("new-network", new Option_Bool(false));
370 neteditOptions.addSynonyme("new-network", "new");
371 neteditOptions.addDescription("new-network", "Netedit", TL("Start netedit with a new network"));
372
373 neteditOptions.doRegister("attribute-help-output", new Option_FileName());
374 neteditOptions.addDescription("attribute-help-output", "Netedit", TL("Write attribute help to file"));
375
376 neteditOptions.doRegister("ignore-supermode-question", new Option_Bool(false));
377 neteditOptions.addDescription("ignore-supermode-question", "Netedit", TL("Ignore question dialog during changing between supermodes in undo-redo"));
378
379 neteditOptions.doRegister("ignore.additionalelements", new Option_Bool(false));
380 neteditOptions.addDescription("ignore.additionalelements", "Netedit", TL("Ignore additional elements during loading of sumo-configs"));
381
382 neteditOptions.doRegister("ignore.routeelements", new Option_Bool(false));
383 neteditOptions.addDescription("ignore.routeelements", "Netedit", TL("Ignore route elements during loading of sumo-configs"));
384
385 neteditOptions.doRegister("e2.friendlyPos.automatic", new Option_Bool(true));
386 neteditOptions.addDescription("e2.friendlyPos.automatic", "Netedit", TL("If the lane is shorter than the additional, automatically enable friendlyPos"));
387
388 neteditOptions.doRegister("force-saving", new Option_Bool(false));
389 neteditOptions.addDescription("force-saving", "Netedit", TL("If enabled, loaded elements will be saved regardless of whether they have been edited or not (usually used in netedit test)"));
390
391 // network prefixes
392
393 neteditOptions.doRegister("node-prefix", new Option_String("J"));
394 neteditOptions.addDescription("node-prefix", "Netedit", TL("Prefix for node naming"));
395
396 neteditOptions.doRegister("edge-prefix", new Option_String("E"));
397 neteditOptions.addDescription("edge-prefix", "Netedit", TL("Prefix for edge naming"));
398
399 neteditOptions.doRegister("edge-infix", new Option_String(""));
400 neteditOptions.addDescription("edge-infix", "Netedit", TL("Enable edge-infix (<fromNodeID><infix><toNodeID>)"));
401
402 // additional prefixes
403
404 neteditOptions.doRegister("busStop-prefix", new Option_String("bs"));
405 neteditOptions.addDescription("busStop-prefix", "Netedit", TL("Prefix for busStop naming"));
406
407 neteditOptions.doRegister("trainStop-prefix", new Option_String("ts"));
408 neteditOptions.addDescription("trainStop-prefix", "Netedit", TL("Prefix for trainStop naming"));
409
410 neteditOptions.doRegister("containerStop-prefix", new Option_String("ct"));
411 neteditOptions.addDescription("containerStop-prefix", "Netedit", TL("Prefix for containerStop naming"));
412
413 neteditOptions.doRegister("chargingStation-prefix", new Option_String("cs"));
414 neteditOptions.addDescription("chargingStation-prefix", "Netedit", TL("Prefix for chargingStation naming"));
415
416 neteditOptions.doRegister("parkingArea-prefix", new Option_String("pa"));
417 neteditOptions.addDescription("parkingArea-prefix", "Netedit", TL("Prefix for parkingArea naming"));
418
419 neteditOptions.doRegister("e1Detector-prefix", new Option_String("e1"));
420 neteditOptions.addDescription("e1Detector-prefix", "Netedit", TL("Prefix for e1Detector naming"));
421
422 neteditOptions.doRegister("e2Detector-prefix", new Option_String("e2"));
423 neteditOptions.addDescription("e2Detector-prefix", "Netedit", TL("Prefix for e2Detector naming"));
424
425 neteditOptions.doRegister("e3Detector-prefix", new Option_String("e3"));
426 neteditOptions.addDescription("e3Detector-prefix", "Netedit", TL("Prefix for e3Detector naming"));
427
428 neteditOptions.doRegister("e1InstantDetector-prefix", new Option_String("e1i"));
429 neteditOptions.addDescription("e1InstantDetector-prefix", "Netedit", TL("Prefix for e1InstantDetector naming"));
430
431 neteditOptions.doRegister("rerouter-prefix", new Option_String("rr"));
432 neteditOptions.addDescription("rerouter-prefix", "Netedit", TL("Prefix for rerouter naming"));
433
434 neteditOptions.doRegister("calibrator-prefix", new Option_String("ca"));
435 neteditOptions.addDescription("calibrator-prefix", "Netedit", TL("Prefix for calibrator naming"));
436
437 neteditOptions.doRegister("routeProbe-prefix", new Option_String("rp"));
438 neteditOptions.addDescription("routeProbe-prefix", "Netedit", TL("Prefix for routeProbe naming"));
439
440 neteditOptions.doRegister("vss-prefix", new Option_String("vs"));
441 neteditOptions.addDescription("vss-prefix", "Netedit", TL("Prefix for variable speed sign naming"));
442
443 neteditOptions.doRegister("tractionSubstation-prefix", new Option_String("tr"));
444 neteditOptions.addDescription("tractionSubstation-prefix", "Netedit", TL("Prefix for traction substation naming"));
445
446 neteditOptions.doRegister("overheadWire-prefix", new Option_String("ow"));
447 neteditOptions.addDescription("overheadWire-prefix", "Netedit", TL("Prefix for overhead wire naming"));
448
449 neteditOptions.doRegister("polygon-prefix", new Option_String("po"));
450 neteditOptions.addDescription("polygon-prefix", "Netedit", TL("Prefix for polygon naming"));
451
452 neteditOptions.doRegister("poi-prefix", new Option_String("poi"));
453 neteditOptions.addDescription("poi-prefix", "Netedit", TL("Prefix for poi naming"));
454
455 neteditOptions.doRegister("jps.walkableArea-prefix", new Option_String("jps.walkable_area"));
456 neteditOptions.addDescription("jps.walkableArea-prefix", "Netedit", TL("Prefix for jps walkable area naming"));
457
458 neteditOptions.doRegister("jps.obstacle-prefix", new Option_String("jps.obstacle"));
459 neteditOptions.addDescription("jps.obstacle-prefix", "Netedit", TL("Prefix for jps obstacle naming"));
460
461 // demand prefixes
462
463 neteditOptions.doRegister("route-prefix", new Option_String("r"));
464 neteditOptions.addDescription("route-prefix", "Netedit", TL("Prefix for route naming"));
465
466 neteditOptions.doRegister("routeDistribution-prefix", new Option_String("rd"));
467 neteditOptions.addDescription("routeDistribution-prefix", "Netedit", TL("Prefix for route distribution naming"));
468
469 neteditOptions.doRegister("vType-prefix", new Option_String("t"));
470 neteditOptions.addDescription("vType-prefix", "Netedit", TL("Prefix for type naming"));
471
472 neteditOptions.doRegister("vTypeDistribution-prefix", new Option_String("td"));
473 neteditOptions.addDescription("vTypeDistribution-prefix", "Netedit", TL("Prefix for type distribution naming"));
474
475 neteditOptions.doRegister("vehicle-prefix", new Option_String("v"));
476 neteditOptions.addDescription("vehicle-prefix", "Netedit", TL("Prefix for vehicle naming"));
477
478 neteditOptions.doRegister("trip-prefix", new Option_String("t"));
479 neteditOptions.addDescription("trip-prefix", "Netedit", TL("Prefix for trip naming"));
480
481 neteditOptions.doRegister("flow-prefix", new Option_String("f"));
482 neteditOptions.addDescription("flow-prefix", "Netedit", TL("Prefix for flow naming"));
483
484 neteditOptions.doRegister("person-prefix", new Option_String("p"));
485 neteditOptions.addDescription("person-prefix", "Netedit", TL("Prefix for person naming"));
486
487 neteditOptions.doRegister("personflow-prefix", new Option_String("pf"));
488 neteditOptions.addDescription("personflow-prefix", "Netedit", TL("Prefix for personFlow naming"));
489
490 neteditOptions.doRegister("container-prefix", new Option_String("c"));
491 neteditOptions.addDescription("container-prefix", "Netedit", TL("Prefix for container naming"));
492
493 neteditOptions.doRegister("containerflow-prefix", new Option_String("cf"));
494 neteditOptions.addDescription("containerflow-prefix", "Netedit", TL("Prefix for containerFlow naming"));
495
496 // data prefixes
497
498 neteditOptions.doRegister("dataSet-prefix", new Option_String("ds"));
499 neteditOptions.addDescription("dataSet-prefix", "Netedit", TL("Prefix for dataSet naming"));
500
501 // mean data prefixes
502
503 neteditOptions.doRegister("meanDataEdge-prefix", new Option_String("ed"));
504 neteditOptions.addDescription("meanDataEdge-prefix", "Netedit", TL("Prefix for meanDataEdge naming"));
505
506 neteditOptions.doRegister("meanDataLane-prefix", new Option_String("ld"));
507 neteditOptions.addDescription("meanDataLane-prefix", "Netedit", TL("Prefix for meanDataLane naming"));
508
509 // TOPIC: Visualisation
510
511 // textures
512
513 neteditOptions.doRegister("disable-laneIcons", new Option_Bool(false));
514 neteditOptions.addDescription("disable-laneIcons", "Visualisation", TL("Disable icons of special lanes"));
515
516 neteditOptions.doRegister("disable-textures", 'T', new Option_Bool(false)); // !!!
517 neteditOptions.addDescription("disable-textures", "Visualisation", TL("Disable textures"));
518
519 neteditOptions.doRegister("gui-settings-file", 'g', new Option_FileName());
520 neteditOptions.addDescription("gui-settings-file", "Visualisation", TL("Load visualisation settings from FILE"));
521
522 // windows position
523
524 neteditOptions.doRegister("registry-viewport", new Option_Bool(false));
525 neteditOptions.addDescription("registry-viewport", "Visualisation", TL("Load current viewport from registry"));
526
527 neteditOptions.doRegister("window-size", new Option_StringVector());
528 neteditOptions.addDescription("window-size", "Visualisation", TL("Create initial window with the given x,y size"));
529
530 neteditOptions.doRegister("window-pos", new Option_StringVector());
531 neteditOptions.addDescription("window-pos", "Visualisation", TL("Create initial window at the given x,y position"));
532
533 // testing
534
535 neteditOptions.doRegister("gui-testing", new Option_Bool(false));
536 neteditOptions.addDescription("gui-testing", "Visualisation", TL("Enable overlay for screen recognition"));
537
538 neteditOptions.doRegister("gui-testing-debug", new Option_Bool(false));
539 neteditOptions.addDescription("gui-testing-debug", "Visualisation", TL("Enable output messages during GUI-Testing"));
540
541 neteditOptions.doRegister("gui-testing-debug-gl", new Option_Bool(false));
542 neteditOptions.addDescription("gui-testing-debug-gl", "Visualisation", TL("Enable output messages during GUI-Testing specific of gl functions"));
543
544 neteditOptions.doRegister("gui-testing.setting-output", new Option_FileName());
545 neteditOptions.addDescription("gui-testing.setting-output", "Visualisation", TL("Save gui settings in the given settings-output file"));
546
547 neteditOptions.doRegister("quit-on-fail", 'Q', new Option_Bool(false));
548 neteditOptions.addDescription("quit-on-fail", "Visualisation", TL("Quit the app if the initial net/config loading fails"));
549
550 // TOPIC: Time
551
552 // register the simulation settings (needed for GNERouteHandler)
553
554 neteditOptions.doRegister("begin", new Option_String("0", "TIME"));
555 neteditOptions.addDescription("begin", "Time", TL("Defines the begin time in seconds; The simulation starts at this time"));
556
557 neteditOptions.doRegister("end", new Option_String("-1", "TIME"));
558 neteditOptions.addDescription("end", "Time", TL("Defines the end time in seconds; The simulation ends at this time"));
559
560 neteditOptions.doRegister("default.action-step-length", new Option_Float(0.0));
561 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."));
562
563 neteditOptions.doRegister("default.speeddev", new Option_Float(-1));
564 neteditOptions.addDescription("default.speeddev", "Processing", TL("Select default speed deviation. A negative value implies vClass specific defaults (0.1 for the default passenger class)"));
565
566 // fill rest of options
567
568 NIFrame::fillOptions(neteditOptions, true);
569 NBFrame::fillOptions(neteditOptions, false);
570 NWFrame::fillOptions(neteditOptions, false);
571 RandHelper::insertRandOptions(neteditOptions);
572
573 // don't edit net and config file
574 neteditOptions.setOptionEditable("sumo-net-file", false);
575 neteditOptions.setOptionEditable("configuration-file", false);
576}
577
578
579void
581 neteditOptions.resetWritable();
582 neteditOptions.set("offset.disable-normalization", "true"); // preserve the given network as far as possible
583 neteditOptions.set("no-turnarounds", "true"); // otherwise it is impossible to manually removed turn-arounds
584}
585
586
587bool
589 // only loaded once
591 // get netedit options
592 auto& neteditOptions = OptionsCont::getOptions();
593 // fill (reset) all options
594 fillOptions(neteditOptions);
595 // set default options defined in GNELoadThread::setDefaultOptions(...)
596 setDefaultOptions(neteditOptions);
597 try {
598 // set all values writable, because certain attributes already setted can be updated through console
600 // load options from console
602 return true;
603 } catch (ProcessError& e) {
604 if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
605 WRITE_ERROR(e.what());
606 }
607 WRITE_ERROR(TL("Failed to reset options."));
608 return false;
609 }
610 } else {
611 return false;
612 }
613}
614
615
616void
618 auto& neteditOptions = OptionsCont::getOptions();
619 // reset netedit options
620 fillOptions(neteditOptions);
621 setDefaultOptions(neteditOptions);
622 // enable option "new"
623 neteditOptions.resetWritable();
624 neteditOptions.set("new", "true");
625 // start thread
626 start();
627}
628
629
630void
632 // start thread
633 start();
634}
635
636
637void
638GNELoadThread::retrieveMessage(const MsgHandler::MsgType type, const std::string& msg) {
641}
642
643/****************************************************************************/
#define WRITE_MESSAGE(msg)
Definition MsgHandler.h:288
#define WRITE_ERROR(msg)
Definition MsgHandler.h:295
#define TL(string)
Definition MsgHandler.h:304
void clearParseVehicleClassesCache()
resets parsing cache
void setDefaultFilenameFile(const FileBucket::Type type, const std::string &filename)
brief set default additional file
GNEApplicationWindowHelper::FileBucketHandler * getFileBucketHandler() const
get file bucket handler
bool consoleOptionsLoaded()
check if console options was already loaded
Type
type of loaded element
MFXSynchQue< GUIEvent * > & myEventQueue
event Queue
OutputDevice * myErrorRetriever
The instances of message retriever encapsulations Needed to be deleted from the handler later on.
void retrieveMessage(const MsgHandler::MsgType type, const std::string &msg)
Retrieves messages from the loading module.
FXint submitEndAndCleanup(GNEEvent_FileLoaded::Type type, GNENet *net, const std::string &loadedFile, const std::string &guiSettingsFile="", const bool viewportFromRegistry=false)
Closes the loading process.
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
GNEApplicationWindow * myApplicationWindow
netedit application windows
bool loadConsoleOptions()
load options through console
OutputDevice * myMessageRetriever
static void setDefaultOptions(OptionsCont &neteditOptions)
sets required options for proper functioning
virtual ~GNELoadThread()
destructor
OutputDevice * myGLDebugRetriever
OutputDevice * myDebugRetriever
FXEX::MFXThreadEvent & myEventThrow
event throw
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
void computeAndUpdate(OptionsCont &neteditOptions, bool volatileOptions)
recompute the network and update lane geometries
Definition GNENet.cpp:2985
NBNetBuilder * getNetBuilder() const
get net builder
Definition GNENet.cpp:168
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:174
static void resetLoaded()
resets loaded location elements
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)
virtual void addRetriever(OutputDevice *retriever)
Adds a further retriever to the instance responsible for a certain msg type.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
static void enableDebugGLMessages(bool enable)
enable/disable gl-debug messages
static void initOutputOptions()
init output options
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
static void enableDebugMessages(bool enable)
enable/disable debug messages
virtual void clear(bool resetInformed=true)
Clears information whether an error occurred previously and print aggregated message summary.
virtual void removeRetriever(OutputDevice *retriever)
Removes the retriever from the handler.
@ 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.
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:776
Instance responsible for building networks.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
NBEdgeCont & getEdgeCont()
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.
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:397
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:148
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 setOptionEditable(const std::string &name, const bool value)
set option editable
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.
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.
void addXMLDefault(const std::string &name, const std::string &xmlRoot="")
Adds an XML root element to handle by default. The special root "" denotes the default handler.
static OptionsCont & getOptions()
Retrieves the options.
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:75
static void insertRandOptions(OptionsCont &oc)
Initialises the given options container with random number options.
static void initRandGlobal(SumoRNG *which=nullptr)
Reads the given random number options and initialises the random number generator in accordance.
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
static bool checkOptions(OptionsCont &oc)
checks shared options and sets StdDefs
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme, const std::string &routeValidationScheme)
Enables or disables validation.
Definition XMLSubSys.cpp:88
void fillOptions()