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-2025 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>
32#include <utils/xml/XMLSubSys.h>
33
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 // flag for check if input is valid
73 bool validInput = false;
74 // declare network
75 GNENet* net = nullptr;
76 // declare loaded file
77 std::string loadedFile;
78 // check conditions
79 if (neteditOptions.getBool("new")) {
80 // create new network
81 validInput = true;
82 } else if (neteditOptions.getString("osm-files").size() > 0) {
83 // load an osm file
84 validInput = true;
85 } else if (neteditOptions.getString("net-file").size() > 0) {
86 // load a network file
87 validInput = true;
88 loadedFile = neteditOptions.getString("net-file");
89 } else if (neteditOptions.getString("sumocfg-file").size() > 0) {
90 // set sumo config as loaded file
91 loadedFile = neteditOptions.getString("sumocfg-file");
92 // declare parser for sumo config file
94 // if there is an error loading sumo config, stop
95 if (confighandler.loadSumoConfig()) {
96 validInput = true;
97 } else {
98 WRITE_ERRORF(TL("Loading of sumo config file '%' failed."), loadedFile);
99 submitEndAndCleanup(net, loadedFile);
100 return 0;
101 }
102 } else if (neteditOptions.getString("configuration-file").size() > 0) {
103 // set netedit config as loaded file
104 loadedFile = neteditOptions.getString("configuration-file");
105 // declare parser for netedit config file
107 // if there is an error loading sumo config, stop
108 if (confighandler.loadNeteditConfig()) {
109 validInput = true;
110 } else {
111 WRITE_ERRORF(TL("Loading of netedit config file '%' failed."), loadedFile);
112 submitEndAndCleanup(net, loadedFile);
113 return 0;
114 }
115 } else if (loadConsoleOptions()) {
116 validInput = true;
117 }
118 // check input
119 if (!validInput) {
120 WRITE_ERROR(TL("Invalid input network option. Load with either sumo/netedit/netconvert config or with -new option"));
121 submitEndAndCleanup(net, loadedFile);
122 return 0;
123 }
124 // update aggregate warnings
125 if (neteditOptions.isDefault("aggregate-warnings")) {
126 neteditOptions.setDefault("aggregate-warnings", "5");
127 }
128 // init output options
130 // if there is an error checking options, stop
131 if (!(NIFrame::checkOptions(neteditOptions) && NBFrame::checkOptions(neteditOptions) &&
132 NWFrame::checkOptions(neteditOptions) && SystemFrame::checkOptions(neteditOptions))) {
133 // options are not valid
134 WRITE_ERROR(TL("Invalid Options. Nothing loaded"));
135 submitEndAndCleanup(net, loadedFile);
136 return 0;
137 }
138 // do not try to load a net if no relevant option has been given (just to load the GUI)
139 if (!neteditOptions.getBool("new") && neteditOptions.getString("osm-files").size() == 0 && loadedFile.size() == 0) {
140 submitEndAndCleanup(net, loadedFile);
141 return 0;
142 }
143 // clear message instances
147 // init global random seed
149 // check if geo projection can be initialized
150 if (!GeoConvHelper::init(neteditOptions)) {
151 WRITE_ERROR(TL("Could not build projection!"));
152 submitEndAndCleanup(net, loadedFile);
153 return 0;
154 }
155 // set validation
156 XMLSubSys::setValidation(neteditOptions.getString("xml-validation"), neteditOptions.getString("xml-validation.net"), neteditOptions.getString("xml-validation.routes"));
157 // check if Debug has to be enabled
158 MsgHandler::enableDebugMessages(neteditOptions.getBool("gui-testing-debug"));
159 // check if GL Debug has to be enabled
160 MsgHandler::enableDebugGLMessages(neteditOptions.getBool("gui-testing-debug-gl"));
161 // create netBuilder (will be destroyed in GNENet destructor)
162 NBNetBuilder* netBuilder = new NBNetBuilder();
163 // apply netedit options in netBuilder. In this options we have all information for building network
164 netBuilder->applyOptions(neteditOptions);
165 // check if create a new net
166 if (neteditOptions.getBool("new")) {
167 // create new network
168 net = new GNENet(netBuilder, myApplicationWindow->getTagPropertiesDatabase());
169 } else {
170 // declare net loader
171 NILoader nl(*netBuilder);
172 try {
173 // try to load network using netedit options
174 nl.load(neteditOptions);
175 if (true) { // CHECK
176 // make coordinate conversion usable before first netBuilder->compute()
178 } else {
179 WRITE_MESSAGE(TL("Performing initial computation ..."));
180 // perform one-time processing (i.e. edge removal)
181 netBuilder->compute(neteditOptions);
182 // @todo remove one-time processing options!
183 }
184 // check if ignore errors
185 if (neteditOptions.getBool("ignore-errors")) {
187 }
188 // check whether any errors occurred
189 if (MsgHandler::getErrorInstance()->wasInformed()) {
190 throw ProcessError();
191 } else {
192 // now create net with al information loaded in net builder
193 net = new GNENet(netBuilder, myApplicationWindow->getTagPropertiesDatabase());
194 // check if change traffic direction
195 if (neteditOptions.getBool("lefthand")) {
196 // force initial geometry computation without volatile options because the net will look strange otherwise
197 net->computeAndUpdate(neteditOptions, false);
198 }
199 // check if add prefixes
200 if (neteditOptions.getString("prefix").size() > 0) {
201 // change prefixes in attributeCarriers
202 net->getAttributeCarriers()->addPrefixToEdges(neteditOptions.getString("prefix"));
203 net->getAttributeCarriers()->addPrefixToJunctions(neteditOptions.getString("prefix"));
204 // change prefix in containers
205 net->getNetBuilder()->getNodeCont().addPrefix(neteditOptions.getString("prefix"));
206 net->getNetBuilder()->getEdgeCont().addPrefix(neteditOptions.getString("prefix"));
207 }
208 }
209 } catch (ProcessError& e) {
210 if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
211 WRITE_ERROR(e.what());
212 }
213 WRITE_ERROR(TL("Failed to build network."));
214 // check if delete network
215 if (net != nullptr) {
216 delete net;
217 net = nullptr;
218 } else {
219 // GNENet not created, then delete netBuilder
220 delete netBuilder;
221 }
222 } catch (std::exception& e) {
223 WRITE_ERROR(e.what());
224 // check if delete network
225 if (net != nullptr) {
226 delete net;
227 net = nullptr;
228 } else {
229 // GNENet not created, then delete netBuilder
230 delete netBuilder;
231 }
232 }
233 }
234 // only a single setting file is supported
235 submitEndAndCleanup(net, loadedFile, neteditOptions.getString("gui-settings-file"), neteditOptions.getBool("registry-viewport"));
236 return 0;
237}
238
239
240
241void
242GNELoadThread::submitEndAndCleanup(GNENet* net, const std::string& loadedFile, const std::string& guiSettingsFile, const bool viewportFromRegistry) {
243 // remove message callbacks
247 // inform parent about the process
248 myEventQueue.push_back(new GNEEvent_NetworkLoaded(net, loadedFile, guiSettingsFile, viewportFromRegistry));
250}
251
252
253void
255 neteditOptions.clear();
256 neteditOptions.addCallExample("--new", TL("Start plain GUI with empty net"));
257 neteditOptions.addCallExample("-s <SUMO_NET>", TL("Open a SUMO network"));
258 neteditOptions.addCallExample("-c <CONFIGURATION>", TL("Open a configuration file (netedit or netconvert config)"));
259 neteditOptions.addCallExample("-sumocfg-file <CONFIGURATION>", TL("Open a SUMO config file"));
260
261 SystemFrame::addConfigurationOptions(neteditOptions); // this subtopic is filled here, too
262 neteditOptions.addOptionSubTopic("Input");
263 neteditOptions.addOptionSubTopic("Output");
265 neteditOptions.addOptionSubTopic("Processing");
266 neteditOptions.addOptionSubTopic("Building Defaults");
267 neteditOptions.addOptionSubTopic("TLS Building");
268 neteditOptions.addOptionSubTopic("Ramp Guessing");
269 neteditOptions.addOptionSubTopic("Edge Removal");
270 neteditOptions.addOptionSubTopic("Unregulated Nodes");
271 neteditOptions.addOptionSubTopic("Junctions");
272 neteditOptions.addOptionSubTopic("Pedestrian");
273 neteditOptions.addOptionSubTopic("Bicycle");
274 neteditOptions.addOptionSubTopic("Railway");
275 neteditOptions.addOptionSubTopic("Formats");
276 neteditOptions.addOptionSubTopic("Netedit");
277 neteditOptions.addOptionSubTopic("Visualisation");
278 neteditOptions.addOptionSubTopic("Time");
279
280 // TOPIC: Input
281
282 neteditOptions.doRegister("sumocfg-file", new Option_FileName());
283 neteditOptions.addSynonyme("sumocfg-file", "sumocfg");
284 neteditOptions.addDescription("sumocfg-file", "Input", TL("Load sumo config"));
285 neteditOptions.addXMLDefault("sumocfg-file", "sumoConfiguration");
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 neteditOptions.doRegister("selection-file", new Option_FileName());
307 neteditOptions.addDescription("selection-file", "Input", TL("Load element selection"));
308
309 neteditOptions.doRegister("test-file", new Option_FileName());
310 neteditOptions.addDescription("test-file", "Input", TL("Test file"));
311
312 // TOPIC: Output
313
314 neteditOptions.doRegister("tls-file", new Option_String());
315 neteditOptions.addDescription("tls-file", "Output", TL("File in which TLS Programs must be saved"));
316
317 neteditOptions.doRegister("edgetypes-file", new Option_String());
318 neteditOptions.addDescription("edgetypes-file", "Output", TL("File in which edgeTypes must be saved"));
319
320 // TOPIC: Netedit
321
322 neteditOptions.doRegister("new-network", new Option_Bool(false));
323 neteditOptions.addSynonyme("new-network", "new");
324 neteditOptions.addDescription("new-network", "Netedit", TL("Start netedit with a new network"));
325
326 neteditOptions.doRegister("attribute-help-output", new Option_FileName());
327 neteditOptions.addDescription("attribute-help-output", "Netedit", TL("Write attribute help to file"));
328
329 neteditOptions.doRegister("ignore-supermode-question", new Option_Bool(false));
330 neteditOptions.addDescription("ignore-supermode-question", "Netedit", TL("Ignore question dialog during changing between supermodes in undo-redo"));
331
332 neteditOptions.doRegister("ignore.additionalelements", new Option_Bool(false));
333 neteditOptions.addDescription("ignore.additionalelements", "Netedit", TL("Ignore additional elements during loading of sumo-configs"));
334
335 neteditOptions.doRegister("ignore.routeelements", new Option_Bool(false));
336 neteditOptions.addDescription("ignore.routeelements", "Netedit", TL("Ignore route elements during loading of sumo-configs"));
337
338 neteditOptions.doRegister("e2.friendlyPos.automatic", new Option_Bool(true));
339 neteditOptions.addDescription("e2.friendlyPos.automatic", "Netedit", TL("If the lane is shorter than the additional, automatically enable friendlyPos"));
340
341 neteditOptions.doRegister("force-saving", new Option_Bool(false));
342 neteditOptions.addDescription("force-saving", "Netedit", TL("If enabled, elements will be saved regardless of whether they have been edited or not"));
343
344 // network prefixes
345
346 neteditOptions.doRegister("node-prefix", new Option_String("J"));
347 neteditOptions.addDescription("node-prefix", "Netedit", TL("Prefix for node naming"));
348
349 neteditOptions.doRegister("edge-prefix", new Option_String("E"));
350 neteditOptions.addDescription("edge-prefix", "Netedit", TL("Prefix for edge naming"));
351
352 neteditOptions.doRegister("edge-infix", new Option_String(""));
353 neteditOptions.addDescription("edge-infix", "Netedit", TL("Enable edge-infix (<fromNodeID><infix><toNodeID>)"));
354
355 // additional prefixes
356
357 neteditOptions.doRegister("busStop-prefix", new Option_String("bs"));
358 neteditOptions.addDescription("busStop-prefix", "Netedit", TL("Prefix for busStop naming"));
359
360 neteditOptions.doRegister("trainStop-prefix", new Option_String("ts"));
361 neteditOptions.addDescription("trainStop-prefix", "Netedit", TL("Prefix for trainStop naming"));
362
363 neteditOptions.doRegister("containerStop-prefix", new Option_String("ct"));
364 neteditOptions.addDescription("containerStop-prefix", "Netedit", TL("Prefix for containerStop naming"));
365
366 neteditOptions.doRegister("chargingStation-prefix", new Option_String("cs"));
367 neteditOptions.addDescription("chargingStation-prefix", "Netedit", TL("Prefix for chargingStation naming"));
368
369 neteditOptions.doRegister("parkingArea-prefix", new Option_String("pa"));
370 neteditOptions.addDescription("parkingArea-prefix", "Netedit", TL("Prefix for parkingArea naming"));
371
372 neteditOptions.doRegister("e1Detector-prefix", new Option_String("e1"));
373 neteditOptions.addDescription("e1Detector-prefix", "Netedit", TL("Prefix for e1Detector naming"));
374
375 neteditOptions.doRegister("e2Detector-prefix", new Option_String("e2"));
376 neteditOptions.addDescription("e2Detector-prefix", "Netedit", TL("Prefix for e2Detector naming"));
377
378 neteditOptions.doRegister("e3Detector-prefix", new Option_String("e3"));
379 neteditOptions.addDescription("e3Detector-prefix", "Netedit", TL("Prefix for e3Detector naming"));
380
381 neteditOptions.doRegister("e1InstantDetector-prefix", new Option_String("e1i"));
382 neteditOptions.addDescription("e1InstantDetector-prefix", "Netedit", TL("Prefix for e1InstantDetector naming"));
383
384 neteditOptions.doRegister("rerouter-prefix", new Option_String("rr"));
385 neteditOptions.addDescription("rerouter-prefix", "Netedit", TL("Prefix for rerouter naming"));
386
387 neteditOptions.doRegister("calibrator-prefix", new Option_String("ca"));
388 neteditOptions.addDescription("calibrator-prefix", "Netedit", TL("Prefix for calibrator naming"));
389
390 neteditOptions.doRegister("routeProbe-prefix", new Option_String("rp"));
391 neteditOptions.addDescription("routeProbe-prefix", "Netedit", TL("Prefix for routeProbe naming"));
392
393 neteditOptions.doRegister("vss-prefix", new Option_String("vs"));
394 neteditOptions.addDescription("vss-prefix", "Netedit", TL("Prefix for variable speed sign naming"));
395
396 neteditOptions.doRegister("tractionSubstation-prefix", new Option_String("tr"));
397 neteditOptions.addDescription("tractionSubstation-prefix", "Netedit", TL("Prefix for traction substation naming"));
398
399 neteditOptions.doRegister("overheadWire-prefix", new Option_String("ow"));
400 neteditOptions.addDescription("overheadWire-prefix", "Netedit", TL("Prefix for overhead wire naming"));
401
402 neteditOptions.doRegister("polygon-prefix", new Option_String("po"));
403 neteditOptions.addDescription("polygon-prefix", "Netedit", TL("Prefix for polygon naming"));
404
405 neteditOptions.doRegister("poi-prefix", new Option_String("poi"));
406 neteditOptions.addDescription("poi-prefix", "Netedit", TL("Prefix for poi naming"));
407
408 neteditOptions.doRegister("jps.walkableArea-prefix", new Option_String("jps.walkable_area"));
409 neteditOptions.addDescription("jps.walkableArea-prefix", "Netedit", TL("Prefix for jps walkable area naming"));
410
411 neteditOptions.doRegister("jps.obstacle-prefix", new Option_String("jps.obstacle"));
412 neteditOptions.addDescription("jps.obstacle-prefix", "Netedit", TL("Prefix for jps obstacle naming"));
413
414 // demand prefixes
415
416 neteditOptions.doRegister("route-prefix", new Option_String("r"));
417 neteditOptions.addDescription("route-prefix", "Netedit", TL("Prefix for route naming"));
418
419 neteditOptions.doRegister("routeDistribution-prefix", new Option_String("rd"));
420 neteditOptions.addDescription("routeDistribution-prefix", "Netedit", TL("Prefix for route distribution naming"));
421
422 neteditOptions.doRegister("vType-prefix", new Option_String("t"));
423 neteditOptions.addDescription("vType-prefix", "Netedit", TL("Prefix for type naming"));
424
425 neteditOptions.doRegister("vTypeDistribution-prefix", new Option_String("td"));
426 neteditOptions.addDescription("vTypeDistribution-prefix", "Netedit", TL("Prefix for type distribution naming"));
427
428 neteditOptions.doRegister("vehicle-prefix", new Option_String("v"));
429 neteditOptions.addDescription("vehicle-prefix", "Netedit", TL("Prefix for vehicle naming"));
430
431 neteditOptions.doRegister("trip-prefix", new Option_String("t"));
432 neteditOptions.addDescription("trip-prefix", "Netedit", TL("Prefix for trip naming"));
433
434 neteditOptions.doRegister("flow-prefix", new Option_String("f"));
435 neteditOptions.addDescription("flow-prefix", "Netedit", TL("Prefix for flow naming"));
436
437 neteditOptions.doRegister("person-prefix", new Option_String("p"));
438 neteditOptions.addDescription("person-prefix", "Netedit", TL("Prefix for person naming"));
439
440 neteditOptions.doRegister("personflow-prefix", new Option_String("pf"));
441 neteditOptions.addDescription("personflow-prefix", "Netedit", TL("Prefix for personFlow naming"));
442
443 neteditOptions.doRegister("container-prefix", new Option_String("c"));
444 neteditOptions.addDescription("container-prefix", "Netedit", TL("Prefix for container naming"));
445
446 neteditOptions.doRegister("containerflow-prefix", new Option_String("cf"));
447 neteditOptions.addDescription("containerflow-prefix", "Netedit", TL("Prefix for containerFlow naming"));
448
449 // data prefixes
450
451 neteditOptions.doRegister("dataSet-prefix", new Option_String("ds"));
452 neteditOptions.addDescription("dataSet-prefix", "Netedit", TL("Prefix for dataSet naming"));
453
454 // mean data prefixes
455
456 neteditOptions.doRegister("meanDataEdge-prefix", new Option_String("ed"));
457 neteditOptions.addDescription("meanDataEdge-prefix", "Netedit", TL("Prefix for meanDataEdge naming"));
458
459 neteditOptions.doRegister("meanDataLane-prefix", new Option_String("ld"));
460 neteditOptions.addDescription("meanDataLane-prefix", "Netedit", TL("Prefix for meanDataLane naming"));
461
462 // TOPIC: Visualisation
463
464 // textures
465
466 neteditOptions.doRegister("disable-laneIcons", new Option_Bool(false));
467 neteditOptions.addDescription("disable-laneIcons", "Visualisation", TL("Disable icons of special lanes"));
468
469 neteditOptions.doRegister("disable-textures", 'T', new Option_Bool(false)); // !!!
470 neteditOptions.addDescription("disable-textures", "Visualisation", TL("Disable textures"));
471
472 neteditOptions.doRegister("gui-settings-file", 'g', new Option_FileName());
473 neteditOptions.addDescription("gui-settings-file", "Visualisation", TL("Load visualisation settings from FILE"));
474
475 // windows position
476
477 neteditOptions.doRegister("registry-viewport", new Option_Bool(false));
478 neteditOptions.addDescription("registry-viewport", "Visualisation", TL("Load current viewport from registry"));
479
480 neteditOptions.doRegister("window-size", new Option_StringVector());
481 neteditOptions.addDescription("window-size", "Visualisation", TL("Create initial window with the given x,y size"));
482
483 neteditOptions.doRegister("window-pos", new Option_StringVector());
484 neteditOptions.addDescription("window-pos", "Visualisation", TL("Create initial window at the given x,y position"));
485
486 // testing
487
488 neteditOptions.doRegister("gui-testing", new Option_Bool(false));
489 neteditOptions.addDescription("gui-testing", "Visualisation", TL("Enable overlay for screen recognition"));
490
491 neteditOptions.doRegister("gui-testing-debug", new Option_Bool(false));
492 neteditOptions.addDescription("gui-testing-debug", "Visualisation", TL("Enable output messages during GUI-Testing"));
493
494 neteditOptions.doRegister("gui-testing-debug-gl", new Option_Bool(false));
495 neteditOptions.addDescription("gui-testing-debug-gl", "Visualisation", TL("Enable output messages during GUI-Testing specific of gl functions"));
496
497 neteditOptions.doRegister("gui-testing.setting-output", new Option_FileName());
498 neteditOptions.addDescription("gui-testing.setting-output", "Visualisation", TL("Save gui settings in the given settings-output file"));
499
500 // TOPIC: Time
501
502 // register the simulation settings (needed for GNERouteHandler)
503
504 neteditOptions.doRegister("begin", new Option_String("0", "TIME"));
505 neteditOptions.addDescription("begin", "Time", TL("Defines the begin time in seconds; The simulation starts at this time"));
506
507 neteditOptions.doRegister("end", new Option_String("-1", "TIME"));
508 neteditOptions.addDescription("end", "Time", TL("Defines the end time in seconds; The simulation ends at this time"));
509
510 neteditOptions.doRegister("default.action-step-length", new Option_Float(0.0));
511 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."));
512
513 neteditOptions.doRegister("default.speeddev", new Option_Float(-1));
514 neteditOptions.addDescription("default.speeddev", "Processing", TL("Select default speed deviation. A negative value implies vClass specific defaults (0.1 for the default passenger class)"));
515
516 // fill rest of options
517
518 NIFrame::fillOptions(neteditOptions, true);
519 NBFrame::fillOptions(neteditOptions, false);
520 NWFrame::fillOptions(neteditOptions, false);
521 RandHelper::insertRandOptions(neteditOptions);
522}
523
524
525void
527 neteditOptions.resetWritable();
528 neteditOptions.set("offset.disable-normalization", "true"); // preserve the given network as far as possible
529 neteditOptions.set("no-turnarounds", "true"); // otherwise it is impossible to manually removed turn-arounds
530}
531
532
533bool
535 // only loaded once
537 // get netedit options
538 auto& neteditOptions = OptionsCont::getOptions();
539 // fill (reset) all options
540 fillOptions(neteditOptions);
541 // set default options defined in GNELoadThread::setDefaultOptions(...)
542 setDefaultOptions(neteditOptions);
543 try {
544 // set all values writable, because certain attributes already setted can be updated through console
546 // load options from console
548 return true;
549 } catch (ProcessError& e) {
550 if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
551 WRITE_ERROR(e.what());
552 }
553 WRITE_ERROR(TL("Failed to reset options."));
554 return false;
555 }
556 } else {
557 return false;
558 }
559}
560
561
562void
564 auto& neteditOptions = OptionsCont::getOptions();
565 // reset netedit options
566 fillOptions(neteditOptions);
567 setDefaultOptions(neteditOptions);
568 // enable option "new"
569 neteditOptions.resetWritable();
570 neteditOptions.set("new", "true");
571 // start thread
572 start();
573}
574
575
576void
578 // start thread
579 start();
580}
581
582
583void
584GNELoadThread::retrieveMessage(const MsgHandler::MsgType type, const std::string& msg) {
587}
588
589/****************************************************************************/
#define WRITE_ERRORF(...)
Definition MsgHandler.h:296
#define WRITE_MESSAGE(msg)
Definition MsgHandler.h:288
#define WRITE_ERROR(msg)
Definition MsgHandler.h:295
#define TL(string)
Definition MsgHandler.h:304
The main window of Netedit.
OptionsCont & getSumoOptions()
get SUMO options container
const GNETagPropertiesDatabase * getTagPropertiesDatabase() const
get tag properties database
bool consoleOptionsLoaded()
check if console options was already loaded
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.
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
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
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:3005
NBNetBuilder * getNetBuilder() const
get net builder
Definition GNENet.cpp:1616
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:144
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:764
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 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:74
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 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:83
void fillOptions()