Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
netedit_main.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-2023 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// Main for netedit (adapted from guisim_main)
19/****************************************************************************/
20#include <config.h>
21
22#ifdef HAVE_VERSION_H
23#include <version.h>
24#endif
25
26#include <signal.h>
33#include <utils/xml/XMLSubSys.h>
35
37#include "GNELoadThread.h"
38
39
40// ===========================================================================
41// main function
42// ===========================================================================
43int
44main(int argc, char** argv) {
45 // make the output aware of threading
47 // get the options
48 auto& neteditOptions = OptionsCont::getOptions();
49 neteditOptions.setApplicationDescription(TL("Graphical editor for SUMO networks, demand and additional infrastructure."));
50 neteditOptions.setApplicationName("netedit", "Eclipse SUMO netedit Version " VERSION_STRING);
51 int ret = 0;
52#ifndef _DEBUG
53 try {
54#else
55 {
56#endif
57 // initialise subsystems
59 // fill options
60 GNELoadThread::fillOptions(neteditOptions);
61 // set default options
63 // set argumentos called throught console
64 OptionsIO::setArgs(argc, argv);
66 if (neteditOptions.processMetaOptions(false)) {
68 return 0;
69 }
70 if (neteditOptions.isSet("attribute-help-output")) {
73 return 0;
74 }
75 // Make application
76 FXApp application("SUMO netedit", "netedit");
77 // Open display
78 application.init(argc, argv);
79 int minor, major;
80 if (!FXGLVisual::supported(&application, major, minor)) {
81 throw ProcessError(TL("This system has no OpenGL support. Exiting."));
82 }
83 // build the main window
84 GNEApplicationWindow* window = new GNEApplicationWindow(&application, "*.netc.cfg,*.netccfg");
85 gLanguage = neteditOptions.getString("language");
86 gSchemeStorage.init(&application, true);
87 window->dependentBuild();
88 // Create app
89 application.addSignal(SIGINT, window, MID_HOTKEY_CTRL_Q_CLOSE);
90 application.create();
91 // Load configuration given on command line
92 if (argc > 1) {
93 // Set default options
94 OptionsIO::setArgs(argc, argv);
95 // load options
96 window->loadOptionOnStartup();
97 }
98 // focus window at startup
99 window->setFocus();
100 // Run
101 ret = application.run();
102#ifndef _DEBUG
103 } catch (const std::exception& e) {
104 if (std::string(e.what()) != std::string("")) {
105 WRITE_ERROR(e.what());
106 }
107 MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
108 ret = 1;
109 } catch (...) {
110 MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
111 ret = 1;
112#endif
113 }
115 return ret;
116}
117
118
119/****************************************************************************/
@ MID_HOTKEY_CTRL_Q_CLOSE
Main window closes.
Definition GUIAppEnum.h:113
GUICompleteSchemeStorage gSchemeStorage
#define WRITE_ERROR(msg)
Definition MsgHandler.h:279
#define TL(string)
Definition MsgHandler.h:287
std::string gLanguage
the language for GUI elements and messages
Definition StdDefs.cpp:33
The main window of Netedit.
void loadOptionOnStartup()
load net on startup
void dependentBuild()
build dependent
static void writeAttributeHelp()
write machine readable attribute help to file
static void fillOptions(OptionsCont &neteditOptions)
clears and initializes the OptionsCont
static void setDefaultOptions(OptionsCont &neteditOptions)
sets required options for proper functioning
void init(FXApp *app, bool netedit=false)
Initialises the storage with some default settings.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
static void setFactory(Factory func)
Sets the factory function to use for new MsgHandlers.
Definition MsgHandler.h:64
static MsgHandler * create(MsgType type)
static OptionsCont & getOptions()
Retrieves the options.
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
Definition OptionsIO.cpp:58
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
Definition OptionsIO.cpp:74
static void close()
Closes all of an applications subsystems.
static void init()
Initialises the xml-subsystem.
Definition XMLSubSys.cpp:55
int main(int argc, char **argv)