Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/netedit_main.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 netedit_main.cpp
15
/// @author Jakob Erdmann
16
/// @author Mirko Barthauer
17
/// @date Feb 2011
18
///
19
// Main for netedit (adapted from guisim_main)
20
/****************************************************************************/
21
22
#include <signal.h>
23
#include <utils/xml/XMLSubSys.h>
24
#include <utils/options/OptionsIO.h>
25
#include <utils/gui/settings/GUICompleteSchemeStorage.h>
26
#include <utils/foxtools/MsgHandlerSynchronized.h>
27
#include <utils/common/SystemFrame.h>
28
29
#ifdef HAVE_VERSION_H
30
#include <version.h>
31
#endif
32
33
#include "GNEApplicationWindow.h"
34
#include "GNEExternalRunner.h"
35
#include "GNELoadThread.h"
36
#include "GNETagPropertiesDatabase.h"
37
38
39
// #define SECUREEXCEPTION
40
41
// ===========================================================================
42
// main function
43
// ===========================================================================
44
int
45
main(int argc, char** argv) {
46
// make the output aware of threading
47
MsgHandler::setFactory(&MsgHandlerSynchronized::create);
48
// get the options
49
auto& neteditOptions = OptionsCont::getOptions();
50
neteditOptions.setApplicationDescription(TL("Graphical editor for SUMO networks, demand and additional infrastructure."));
51
neteditOptions.setApplicationName("netedit", "Eclipse SUMO netedit " VERSION_STRING);
52
// preload registry from sumo to decide on language
53
FXRegistry reg("SUMO GUI", "sumo-gui");
54
reg.read();
55
// set language
56
gLanguage = reg.readStringEntry("gui", "language", gLanguage.c_str());
57
int ret = 0;
58
// run netedit with try-catch if we're in debug-mode
59
#ifdef SECUREEXCEPTION
60
try {
61
#endif
62
// initialise subsystems
63
XMLSubSys::init();
64
// fill options
65
GNELoadThread::fillOptions(neteditOptions);
66
// set default options
67
GNELoadThread::setDefaultOptions(neteditOptions);
68
69
// set arguments called through console
70
OptionsIO::setArgs(argc, argv);
71
OptionsIO::getOptions(true);
72
if (neteditOptions.processMetaOptions(false)) {
73
SystemFrame::close();
74
} else {
75
// create tagPropertiesdatabase
76
const GNETagPropertiesDatabase* tagPropertiesDatabase = new GNETagPropertiesDatabase();
77
78
if (neteditOptions.isSet("attribute-help-output")) {
79
// write attribute help in console
80
tagPropertiesDatabase->writeAttributeHelp();
81
} else {
82
// create FX application
83
FXApp application("SUMO netedit", "netedit");
84
// Open display
85
application.init(argc, argv);
86
int minor, major;
87
if (!FXGLVisual::supported(&application, major, minor)) {
88
throw ProcessError(TL("This system has no OpenGL support. Exiting."));
89
} else {
90
// build the main window
91
GNEApplicationWindow* netedit = new GNEApplicationWindow(&application, tagPropertiesDatabase, "*.netc.cfg,*.netccfg");
92
// build external runner
93
GNEExternalRunner* externalRunner = new GNEExternalRunner(netedit);
94
// set language
95
gLanguage = neteditOptions.getString("language");
96
// initialize GUICompleteSchemeStorage
97
gSchemeStorage.init(&application, true);
98
// build dependent elements
99
netedit->dependentBuild();
100
// add signal handler for CTRL+Q
101
application.addSignal(SIGINT, netedit, MID_HOTKEY_CTRL_Q_CLOSE);
102
// Create app
103
application.create();
104
// Load configuration given on command line
105
if (argc > 1) {
106
// Set default options
107
OptionsIO::setArgs(argc, argv);
108
// load options
109
netedit->loadOptionOnStartup();
110
}
111
// focus window at startup
112
netedit->setFocus();
113
// Run
114
ret = application.run();
115
// delete external runner
116
delete externalRunner;
117
// delete netedit
118
delete netedit;
119
}
120
}
121
// delete tagPropertiesDatabase
122
delete tagPropertiesDatabase;
123
}
124
#ifdef SECUREEXCEPTION
125
} catch (const std::exception& e) {
126
if (std::string(e.what()) != std::string("")) {
127
WRITE_ERROR(e.what());
128
}
129
MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
130
ret = 1;
131
} catch (...) {
132
MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
133
ret = 1;
134
}
135
#endif
136
SystemFrame::close();
137
return ret;
138
}
139
140
/****************************************************************************/
141
142