Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/GNELoadThread.cpp
169665 views
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
/****************************************************************************/
14
/// @file GNELoadThread.cpp
15
/// @author Jakob Erdmann
16
/// @date Feb 2011
17
///
18
// The thread that performs the loading of a Netedit-net (adapted from
19
// GUILoadThread)
20
/****************************************************************************/
21
22
#include <netbuild/NBFrame.h>
23
#include <netbuild/NBNetBuilder.h>
24
#include <netimport/NIFrame.h>
25
#include <netimport/NILoader.h>
26
#include <netwrite/NWFrame.h>
27
#include <utils/common/MsgRetrievingFunction.h>
28
#include <utils/common/SystemFrame.h>
29
#include <utils/gui/events/GUIEvent_Message.h>
30
#include <utils/options/OptionsCont.h>
31
#include <utils/options/OptionsIO.h>
32
#include <utils/xml/XMLSubSys.h>
33
34
#include "GNEApplicationWindow.h"
35
#include "GNEEvent_NetworkLoaded.h"
36
#include "GNELoadThread.h"
37
#include "GNENet.h"
38
39
// ===========================================================================
40
// member method definitions
41
// ===========================================================================
42
GNELoadThread::GNELoadThread(GNEApplicationWindow* applicationWindow, MFXSynchQue<GUIEvent*>& eq, FXEX::MFXThreadEvent& ev) :
43
MFXSingleEventThread(applicationWindow->getApp(), applicationWindow),
44
myApplicationWindow(applicationWindow),
45
myEventQueue(eq),
46
myEventThrow(ev) {
47
myDebugRetriever = new MsgRetrievingFunction<GNELoadThread>(this, &GNELoadThread::retrieveMessage, MsgHandler::MsgType::MT_DEBUG);
48
myGLDebugRetriever = new MsgRetrievingFunction<GNELoadThread>(this, &GNELoadThread::retrieveMessage, MsgHandler::MsgType::MT_GLDEBUG);
49
myErrorRetriever = new MsgRetrievingFunction<GNELoadThread>(this, &GNELoadThread::retrieveMessage, MsgHandler::MsgType::MT_ERROR);
50
myMessageRetriever = new MsgRetrievingFunction<GNELoadThread>(this, &GNELoadThread::retrieveMessage, MsgHandler::MsgType::MT_MESSAGE);
51
myWarningRetriever = new MsgRetrievingFunction<GNELoadThread>(this, &GNELoadThread::retrieveMessage, MsgHandler::MsgType::MT_WARNING);
52
MsgHandler::getErrorInstance()->addRetriever(myErrorRetriever);
53
}
54
55
56
GNELoadThread::~GNELoadThread() {
57
delete myDebugRetriever;
58
delete myGLDebugRetriever;
59
delete myErrorRetriever;
60
delete myMessageRetriever;
61
delete myWarningRetriever;
62
}
63
64
65
FXint
66
GNELoadThread::run() {
67
auto& neteditOptions = OptionsCont::getOptions();
68
// register message callbacks
69
MsgHandler::getMessageInstance()->addRetriever(myMessageRetriever);
70
MsgHandler::getErrorInstance()->addRetriever(myErrorRetriever);
71
MsgHandler::getWarningInstance()->addRetriever(myWarningRetriever);
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
93
GNEApplicationWindowHelper::GNESumoConfigHandler confighandler(myApplicationWindow->getSumoOptions(), loadedFile);
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
106
GNEApplicationWindowHelper::GNENeteditConfigHandler confighandler(loadedFile);
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
129
MsgHandler::initOutputOptions();
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
// clear message instances
139
MsgHandler::getErrorInstance()->clear();
140
MsgHandler::getWarningInstance()->clear();
141
MsgHandler::getMessageInstance()->clear();
142
// init global random seed
143
RandHelper::initRandGlobal();
144
// check if geo projection can be initialized
145
if (!GeoConvHelper::init(neteditOptions)) {
146
WRITE_ERROR(TL("Could not build projection!"));
147
submitEndAndCleanup(net, loadedFile);
148
return 0;
149
}
150
// set validation
151
XMLSubSys::setValidation(neteditOptions.getString("xml-validation"), neteditOptions.getString("xml-validation.net"), neteditOptions.getString("xml-validation.routes"));
152
// check if Debug has to be enabled
153
MsgHandler::enableDebugMessages(neteditOptions.getBool("gui-testing-debug"));
154
// check if GL Debug has to be enabled
155
MsgHandler::enableDebugGLMessages(neteditOptions.getBool("gui-testing-debug-gl"));
156
// create netBuilder (will be destroyed in GNENet destructor)
157
NBNetBuilder* netBuilder = new NBNetBuilder();
158
// apply netedit options in netBuilder. In this options we have all information for building network
159
netBuilder->applyOptions(neteditOptions);
160
// check if create a new net
161
if (neteditOptions.getBool("new")) {
162
// create new network
163
net = new GNENet(netBuilder, myApplicationWindow->getTagPropertiesDatabase());
164
} else {
165
// declare net loader
166
NILoader nl(*netBuilder);
167
try {
168
// try to load network using netedit options
169
nl.load(neteditOptions);
170
if (true) { // CHECK
171
// make coordinate conversion usable before first netBuilder->compute()
172
GeoConvHelper::computeFinal();
173
} else {
174
WRITE_MESSAGE(TL("Performing initial computation ..."));
175
// perform one-time processing (i.e. edge removal)
176
netBuilder->compute(neteditOptions);
177
// @todo remove one-time processing options!
178
}
179
// check if ignore errors
180
if (neteditOptions.getBool("ignore-errors")) {
181
MsgHandler::getErrorInstance()->clear();
182
}
183
// check whether any errors occurred
184
if (MsgHandler::getErrorInstance()->wasInformed()) {
185
throw ProcessError();
186
} else {
187
// now create net with al information loaded in net builder
188
net = new GNENet(netBuilder, myApplicationWindow->getTagPropertiesDatabase());
189
// check if change traffic direction
190
if (neteditOptions.getBool("lefthand")) {
191
// force initial geometry computation without volatile options because the net will look strange otherwise
192
net->computeAndUpdate(neteditOptions, false);
193
}
194
// check if add prefixes
195
if (neteditOptions.getString("prefix").size() > 0) {
196
// change prefixes in attributeCarriers
197
net->getAttributeCarriers()->addPrefixToEdges(neteditOptions.getString("prefix"));
198
net->getAttributeCarriers()->addPrefixToJunctions(neteditOptions.getString("prefix"));
199
// change prefix in containers
200
net->getNetBuilder()->getNodeCont().addPrefix(neteditOptions.getString("prefix"));
201
net->getNetBuilder()->getEdgeCont().addPrefix(neteditOptions.getString("prefix"));
202
}
203
}
204
} catch (ProcessError& e) {
205
if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
206
WRITE_ERROR(e.what());
207
}
208
WRITE_ERROR(TL("Failed to build network."));
209
// check if delete network
210
if (net != nullptr) {
211
delete net;
212
net = nullptr;
213
} else {
214
// GNENet not created, then delete netBuilder
215
delete netBuilder;
216
}
217
} catch (std::exception& e) {
218
WRITE_ERROR(e.what());
219
// check if delete network
220
if (net != nullptr) {
221
delete net;
222
net = nullptr;
223
} else {
224
// GNENet not created, then delete netBuilder
225
delete netBuilder;
226
}
227
}
228
}
229
// only a single setting file is supported
230
submitEndAndCleanup(net, loadedFile, neteditOptions.getString("gui-settings-file"), neteditOptions.getBool("registry-viewport"));
231
return 0;
232
}
233
234
235
236
void
237
GNELoadThread::submitEndAndCleanup(GNENet* net, const std::string& loadedFile, const std::string& guiSettingsFile, const bool viewportFromRegistry) {
238
// remove message callbacks
239
MsgHandler::getErrorInstance()->removeRetriever(myErrorRetriever);
240
MsgHandler::getWarningInstance()->removeRetriever(myWarningRetriever);
241
MsgHandler::getMessageInstance()->removeRetriever(myMessageRetriever);
242
// inform parent about the process
243
myEventQueue.push_back(new GNEEvent_NetworkLoaded(net, loadedFile, guiSettingsFile, viewportFromRegistry));
244
myEventThrow.signal();
245
}
246
247
248
void
249
GNELoadThread::fillOptions(OptionsCont& neteditOptions) {
250
neteditOptions.clear();
251
neteditOptions.addCallExample("--new", TL("Start plain GUI with empty net"));
252
neteditOptions.addCallExample("-s <SUMO_NET>", TL("Open a SUMO network"));
253
neteditOptions.addCallExample("-c <CONFIGURATION>", TL("Open a configuration file (netedit or netconvert config)"));
254
neteditOptions.addCallExample("-sumocfg-file <CONFIGURATION>", TL("Open a SUMO config file"));
255
256
SystemFrame::addConfigurationOptions(neteditOptions); // this subtopic is filled here, too
257
neteditOptions.addOptionSubTopic("Input");
258
neteditOptions.addOptionSubTopic("Output");
259
GeoConvHelper::addProjectionOptions(neteditOptions);
260
neteditOptions.addOptionSubTopic("Processing");
261
neteditOptions.addOptionSubTopic("Building Defaults");
262
neteditOptions.addOptionSubTopic("TLS Building");
263
neteditOptions.addOptionSubTopic("Ramp Guessing");
264
neteditOptions.addOptionSubTopic("Edge Removal");
265
neteditOptions.addOptionSubTopic("Unregulated Nodes");
266
neteditOptions.addOptionSubTopic("Junctions");
267
neteditOptions.addOptionSubTopic("Pedestrian");
268
neteditOptions.addOptionSubTopic("Bicycle");
269
neteditOptions.addOptionSubTopic("Railway");
270
neteditOptions.addOptionSubTopic("Formats");
271
neteditOptions.addOptionSubTopic("Netedit");
272
neteditOptions.addOptionSubTopic("Visualisation");
273
neteditOptions.addOptionSubTopic("Time");
274
275
// TOPIC: Input
276
277
neteditOptions.doRegister("sumocfg-file", new Option_FileName());
278
neteditOptions.addSynonyme("sumocfg-file", "sumocfg");
279
neteditOptions.addDescription("sumocfg-file", "Input", TL("Load sumo config"));
280
neteditOptions.addXMLDefault("sumocfg-file", "sumoConfiguration");
281
282
neteditOptions.doRegister("additional-files", 'a', new Option_FileName());
283
neteditOptions.addSynonyme("additional-files", "additional");
284
neteditOptions.addDescription("additional-files", "Input", TL("Load additional and shapes descriptions from FILE(s)"));
285
286
neteditOptions.doRegister("route-files", 'r', new Option_FileName());
287
neteditOptions.addSynonyme("route-files", "routes");
288
neteditOptions.addDescription("route-files", "Input", TL("Load demand elements descriptions from FILE(s)"));
289
290
neteditOptions.doRegister("data-files", 'd', new Option_FileName());
291
neteditOptions.addSynonyme("data-files", "data");
292
neteditOptions.addDescription("data-files", "Input", TL("Load data elements descriptions from FILE(s)"));
293
294
neteditOptions.doRegister("meandata-files", 'm', new Option_FileName());
295
neteditOptions.addSynonyme("meandata-files", "meandata");
296
neteditOptions.addDescription("meandata-files", "Input", TL("Load meanData descriptions from FILE(s)"));
297
298
neteditOptions.doRegister("ignore-missing-inputs", new Option_Bool(false));
299
neteditOptions.addDescription("ignore-missing-inputs", "Input", TL("Reset path values (additional, route, data...) after loading netedit config"));
300
301
neteditOptions.doRegister("selection-file", new Option_FileName());
302
neteditOptions.addDescription("selection-file", "Input", TL("Load element selection"));
303
304
neteditOptions.doRegister("test-file", new Option_FileName());
305
neteditOptions.addDescription("test-file", "Input", TL("Test file"));
306
307
// TOPIC: Output
308
309
neteditOptions.doRegister("tls-file", new Option_String());
310
neteditOptions.addDescription("tls-file", "Output", TL("File in which TLS Programs must be saved"));
311
312
neteditOptions.doRegister("edgetypes-file", new Option_String());
313
neteditOptions.addDescription("edgetypes-file", "Output", TL("File in which edgeTypes must be saved"));
314
315
// TOPIC: Netedit
316
317
neteditOptions.doRegister("new-network", new Option_Bool(false));
318
neteditOptions.addSynonyme("new-network", "new");
319
neteditOptions.addDescription("new-network", "Netedit", TL("Start netedit with a new network"));
320
321
neteditOptions.doRegister("attribute-help-output", new Option_FileName());
322
neteditOptions.addDescription("attribute-help-output", "Netedit", TL("Write attribute help to file"));
323
324
neteditOptions.doRegister("ignore-supermode-question", new Option_Bool(false));
325
neteditOptions.addDescription("ignore-supermode-question", "Netedit", TL("Ignore question dialog during changing between supermodes in undo-redo"));
326
327
neteditOptions.doRegister("ignore.additionalelements", new Option_Bool(false));
328
neteditOptions.addDescription("ignore.additionalelements", "Netedit", TL("Ignore additional elements during loading of sumo-configs"));
329
330
neteditOptions.doRegister("ignore.routeelements", new Option_Bool(false));
331
neteditOptions.addDescription("ignore.routeelements", "Netedit", TL("Ignore route elements during loading of sumo-configs"));
332
333
neteditOptions.doRegister("e2.friendlyPos.automatic", new Option_Bool(true));
334
neteditOptions.addDescription("e2.friendlyPos.automatic", "Netedit", TL("If the lane is shorter than the additional, automatically enable friendlyPos"));
335
336
neteditOptions.doRegister("force-saving", new Option_Bool(false));
337
neteditOptions.addDescription("force-saving", "Netedit", TL("If enabled, elements will be saved regardless of whether they have been edited or not"));
338
339
// network prefixes
340
341
neteditOptions.doRegister("node-prefix", new Option_String("J"));
342
neteditOptions.addDescription("node-prefix", "Netedit", TL("Prefix for node naming"));
343
344
neteditOptions.doRegister("edge-prefix", new Option_String("E"));
345
neteditOptions.addDescription("edge-prefix", "Netedit", TL("Prefix for edge naming"));
346
347
neteditOptions.doRegister("edge-infix", new Option_String(""));
348
neteditOptions.addDescription("edge-infix", "Netedit", TL("Enable edge-infix (<fromNodeID><infix><toNodeID>)"));
349
350
// additional prefixes
351
352
neteditOptions.doRegister("busStop-prefix", new Option_String("bs"));
353
neteditOptions.addDescription("busStop-prefix", "Netedit", TL("Prefix for busStop naming"));
354
355
neteditOptions.doRegister("trainStop-prefix", new Option_String("ts"));
356
neteditOptions.addDescription("trainStop-prefix", "Netedit", TL("Prefix for trainStop naming"));
357
358
neteditOptions.doRegister("containerStop-prefix", new Option_String("ct"));
359
neteditOptions.addDescription("containerStop-prefix", "Netedit", TL("Prefix for containerStop naming"));
360
361
neteditOptions.doRegister("chargingStation-prefix", new Option_String("cs"));
362
neteditOptions.addDescription("chargingStation-prefix", "Netedit", TL("Prefix for chargingStation naming"));
363
364
neteditOptions.doRegister("parkingArea-prefix", new Option_String("pa"));
365
neteditOptions.addDescription("parkingArea-prefix", "Netedit", TL("Prefix for parkingArea naming"));
366
367
neteditOptions.doRegister("e1Detector-prefix", new Option_String("e1"));
368
neteditOptions.addDescription("e1Detector-prefix", "Netedit", TL("Prefix for e1Detector naming"));
369
370
neteditOptions.doRegister("e2Detector-prefix", new Option_String("e2"));
371
neteditOptions.addDescription("e2Detector-prefix", "Netedit", TL("Prefix for e2Detector naming"));
372
373
neteditOptions.doRegister("e3Detector-prefix", new Option_String("e3"));
374
neteditOptions.addDescription("e3Detector-prefix", "Netedit", TL("Prefix for e3Detector naming"));
375
376
neteditOptions.doRegister("e1InstantDetector-prefix", new Option_String("e1i"));
377
neteditOptions.addDescription("e1InstantDetector-prefix", "Netedit", TL("Prefix for e1InstantDetector naming"));
378
379
neteditOptions.doRegister("rerouter-prefix", new Option_String("rr"));
380
neteditOptions.addDescription("rerouter-prefix", "Netedit", TL("Prefix for rerouter naming"));
381
382
neteditOptions.doRegister("calibrator-prefix", new Option_String("ca"));
383
neteditOptions.addDescription("calibrator-prefix", "Netedit", TL("Prefix for calibrator naming"));
384
385
neteditOptions.doRegister("routeProbe-prefix", new Option_String("rp"));
386
neteditOptions.addDescription("routeProbe-prefix", "Netedit", TL("Prefix for routeProbe naming"));
387
388
neteditOptions.doRegister("vss-prefix", new Option_String("vs"));
389
neteditOptions.addDescription("vss-prefix", "Netedit", TL("Prefix for variable speed sign naming"));
390
391
neteditOptions.doRegister("tractionSubstation-prefix", new Option_String("tr"));
392
neteditOptions.addDescription("tractionSubstation-prefix", "Netedit", TL("Prefix for traction substation naming"));
393
394
neteditOptions.doRegister("overheadWire-prefix", new Option_String("ow"));
395
neteditOptions.addDescription("overheadWire-prefix", "Netedit", TL("Prefix for overhead wire naming"));
396
397
neteditOptions.doRegister("polygon-prefix", new Option_String("po"));
398
neteditOptions.addDescription("polygon-prefix", "Netedit", TL("Prefix for polygon naming"));
399
400
neteditOptions.doRegister("poi-prefix", new Option_String("poi"));
401
neteditOptions.addDescription("poi-prefix", "Netedit", TL("Prefix for poi naming"));
402
403
neteditOptions.doRegister("jps.walkableArea-prefix", new Option_String("jps.walkable_area"));
404
neteditOptions.addDescription("jps.walkableArea-prefix", "Netedit", TL("Prefix for jps walkable area naming"));
405
406
neteditOptions.doRegister("jps.obstacle-prefix", new Option_String("jps.obstacle"));
407
neteditOptions.addDescription("jps.obstacle-prefix", "Netedit", TL("Prefix for jps obstacle naming"));
408
409
// demand prefixes
410
411
neteditOptions.doRegister("route-prefix", new Option_String("r"));
412
neteditOptions.addDescription("route-prefix", "Netedit", TL("Prefix for route naming"));
413
414
neteditOptions.doRegister("routeDistribution-prefix", new Option_String("rd"));
415
neteditOptions.addDescription("routeDistribution-prefix", "Netedit", TL("Prefix for route distribution naming"));
416
417
neteditOptions.doRegister("vType-prefix", new Option_String("t"));
418
neteditOptions.addDescription("vType-prefix", "Netedit", TL("Prefix for type naming"));
419
420
neteditOptions.doRegister("vTypeDistribution-prefix", new Option_String("td"));
421
neteditOptions.addDescription("vTypeDistribution-prefix", "Netedit", TL("Prefix for type distribution naming"));
422
423
neteditOptions.doRegister("vehicle-prefix", new Option_String("v"));
424
neteditOptions.addDescription("vehicle-prefix", "Netedit", TL("Prefix for vehicle naming"));
425
426
neteditOptions.doRegister("trip-prefix", new Option_String("t"));
427
neteditOptions.addDescription("trip-prefix", "Netedit", TL("Prefix for trip naming"));
428
429
neteditOptions.doRegister("flow-prefix", new Option_String("f"));
430
neteditOptions.addDescription("flow-prefix", "Netedit", TL("Prefix for flow naming"));
431
432
neteditOptions.doRegister("person-prefix", new Option_String("p"));
433
neteditOptions.addDescription("person-prefix", "Netedit", TL("Prefix for person naming"));
434
435
neteditOptions.doRegister("personflow-prefix", new Option_String("pf"));
436
neteditOptions.addDescription("personflow-prefix", "Netedit", TL("Prefix for personFlow naming"));
437
438
neteditOptions.doRegister("container-prefix", new Option_String("c"));
439
neteditOptions.addDescription("container-prefix", "Netedit", TL("Prefix for container naming"));
440
441
neteditOptions.doRegister("containerflow-prefix", new Option_String("cf"));
442
neteditOptions.addDescription("containerflow-prefix", "Netedit", TL("Prefix for containerFlow naming"));
443
444
// data prefixes
445
446
neteditOptions.doRegister("dataSet-prefix", new Option_String("ds"));
447
neteditOptions.addDescription("dataSet-prefix", "Netedit", TL("Prefix for dataSet naming"));
448
449
// mean data prefixes
450
451
neteditOptions.doRegister("meanDataEdge-prefix", new Option_String("ed"));
452
neteditOptions.addDescription("meanDataEdge-prefix", "Netedit", TL("Prefix for meanDataEdge naming"));
453
454
neteditOptions.doRegister("meanDataLane-prefix", new Option_String("ld"));
455
neteditOptions.addDescription("meanDataLane-prefix", "Netedit", TL("Prefix for meanDataLane naming"));
456
457
// TOPIC: Visualisation
458
459
// textures
460
461
neteditOptions.doRegister("disable-laneIcons", new Option_Bool(false));
462
neteditOptions.addDescription("disable-laneIcons", "Visualisation", TL("Disable icons of special lanes"));
463
464
neteditOptions.doRegister("disable-textures", 'T', new Option_Bool(false)); // !!!
465
neteditOptions.addDescription("disable-textures", "Visualisation", TL("Disable textures"));
466
467
neteditOptions.doRegister("gui-settings-file", 'g', new Option_FileName());
468
neteditOptions.addDescription("gui-settings-file", "Visualisation", TL("Load visualisation settings from FILE"));
469
470
// windows position
471
472
neteditOptions.doRegister("registry-viewport", new Option_Bool(false));
473
neteditOptions.addDescription("registry-viewport", "Visualisation", TL("Load current viewport from registry"));
474
475
neteditOptions.doRegister("window-size", new Option_StringVector());
476
neteditOptions.addDescription("window-size", "Visualisation", TL("Create initial window with the given x,y size"));
477
478
neteditOptions.doRegister("window-pos", new Option_StringVector());
479
neteditOptions.addDescription("window-pos", "Visualisation", TL("Create initial window at the given x,y position"));
480
481
// testing
482
483
neteditOptions.doRegister("gui-testing", new Option_Bool(false));
484
neteditOptions.addDescription("gui-testing", "Visualisation", TL("Enable overlay for screen recognition"));
485
486
neteditOptions.doRegister("gui-testing-debug", new Option_Bool(false));
487
neteditOptions.addDescription("gui-testing-debug", "Visualisation", TL("Enable output messages during GUI-Testing"));
488
489
neteditOptions.doRegister("gui-testing-debug-gl", new Option_Bool(false));
490
neteditOptions.addDescription("gui-testing-debug-gl", "Visualisation", TL("Enable output messages during GUI-Testing specific of gl functions"));
491
492
neteditOptions.doRegister("gui-testing.setting-output", new Option_FileName());
493
neteditOptions.addDescription("gui-testing.setting-output", "Visualisation", TL("Save gui settings in the given settings-output file"));
494
495
// TOPIC: Time
496
497
// register the simulation settings (needed for GNERouteHandler)
498
499
neteditOptions.doRegister("begin", new Option_String("0", "TIME"));
500
neteditOptions.addDescription("begin", "Time", TL("Defines the begin time in seconds; The simulation starts at this time"));
501
502
neteditOptions.doRegister("end", new Option_String("-1", "TIME"));
503
neteditOptions.addDescription("end", "Time", TL("Defines the end time in seconds; The simulation ends at this time"));
504
505
neteditOptions.doRegister("default.action-step-length", new Option_Float(0.0));
506
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."));
507
508
neteditOptions.doRegister("default.speeddev", new Option_Float(-1));
509
neteditOptions.addDescription("default.speeddev", "Processing", TL("Select default speed deviation. A negative value implies vClass specific defaults (0.1 for the default passenger class)"));
510
511
// fill rest of options
512
513
NIFrame::fillOptions(neteditOptions, true);
514
NBFrame::fillOptions(neteditOptions, false);
515
NWFrame::fillOptions(neteditOptions, false);
516
RandHelper::insertRandOptions(neteditOptions);
517
}
518
519
520
void
521
GNELoadThread::setDefaultOptions(OptionsCont& neteditOptions) {
522
neteditOptions.resetWritable();
523
neteditOptions.set("offset.disable-normalization", "true"); // preserve the given network as far as possible
524
neteditOptions.set("no-turnarounds", "true"); // otherwise it is impossible to manually removed turn-arounds
525
}
526
527
528
bool
529
GNELoadThread::loadConsoleOptions() {
530
// only loaded once
531
if (myApplicationWindow->consoleOptionsLoaded()) {
532
// get netedit options
533
auto& neteditOptions = OptionsCont::getOptions();
534
// fill (reset) all options
535
fillOptions(neteditOptions);
536
// set default options defined in GNELoadThread::setDefaultOptions(...)
537
setDefaultOptions(neteditOptions);
538
try {
539
// set all values writable, because certain attributes already setted can be updated through console
540
OptionsCont::getOptions().resetWritable();
541
// load options from console
542
OptionsIO::getOptions();
543
return true;
544
} catch (ProcessError& e) {
545
if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
546
WRITE_ERROR(e.what());
547
}
548
WRITE_ERROR(TL("Failed to reset options."));
549
return false;
550
}
551
} else {
552
return false;
553
}
554
}
555
556
557
void
558
GNELoadThread::newNetwork() {
559
auto& neteditOptions = OptionsCont::getOptions();
560
// reset netedit options
561
fillOptions(neteditOptions);
562
setDefaultOptions(neteditOptions);
563
// enable option "new"
564
neteditOptions.resetWritable();
565
neteditOptions.set("new", "true");
566
// start thread
567
start();
568
}
569
570
571
void
572
GNELoadThread::loadNetworkOrConfig() {
573
// start thread
574
start();
575
}
576
577
578
void
579
GNELoadThread::retrieveMessage(const MsgHandler::MsgType type, const std::string& msg) {
580
myEventQueue.push_back(new GUIEvent_Message(type, msg));
581
myEventThrow.signal();
582
}
583
584
/****************************************************************************/
585
586