Eclipse SUMO - Simulation of Urban MObility
netedit_main.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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>
34
36#include "GNELoadThread.h"
37
38
39// ===========================================================================
40// main function
41// ===========================================================================
42int
43main(int argc, char** argv) {
45 // make the output aware of threading
47 // get the options
49 // give some application descriptions
50 oc.setApplicationDescription("Graphical editor for SUMO networks.");
51 oc.setApplicationName("netedit", "Eclipse SUMO netedit Version " VERSION_STRING);
52 int ret = 0;
53#ifndef _DEBUG
54 try {
55#else
56 {
57#endif
58 // initialise subsystems
61 OptionsIO::setArgs(argc, argv);
63 if (oc.processMetaOptions(false)) {
65 return 0;
66 }
67 // Make application
68 FXApp application("SUMO netedit", "netedit");
69 // Open display
70 application.init(argc, argv);
71 int minor, major;
72 if (!FXGLVisual::supported(&application, major, minor)) {
73 throw ProcessError("This system has no OpenGL support. Exiting.");
74 }
75 // build the main window
76 GNEApplicationWindow* window =
77 new GNEApplicationWindow(&application, "*.netc.cfg,*.netccfg");
78 gSchemeStorage.init(&application, true);
79 window->dependentBuild();
80 // Create app
81 application.addSignal(SIGINT, window, MID_HOTKEY_CTRL_Q_CLOSE);
82 application.create();
83 // Load configuration given on command line
84 if (argc > 1) {
85 // Set default options
86 OptionsIO::setArgs(argc, argv);
87 // load options
88 window->loadOptionOnStartup();
89 }
90 // focus window at startup
91 window->setFocus();
92 // Run
93 ret = application.run();
94#ifndef _DEBUG
95 } catch (const std::exception& e) {
96 if (std::string(e.what()) != std::string("")) {
97 WRITE_ERROR(e.what());
98 }
99 MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
100 ret = 1;
101 } catch (...) {
102 MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
103 ret = 1;
104#endif
105 }
107 return ret;
108}
109
110
111/****************************************************************************/
@ MID_HOTKEY_CTRL_Q_CLOSE
Main window closes.
Definition: GUIAppEnum.h:105
GUICompleteSchemeStorage gSchemeStorage
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:274
The main window of the Netedit.
void loadOptionOnStartup()
load net on startup
void dependentBuild()
build dependent
static void fillOptions(OptionsCont &oc)
clears and initializes the OptionsCont
void init(FXApp *app, bool netedit=false)
Initialises the storage with some default settings.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:79
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:116
static void setupI18n(const std::string &locale="")
set up gettext stuff
Definition: MsgHandler.cpp:228
static void setFactory(Factory func)
Sets the factory function to use for new MsgHandlers.
Definition: MsgHandler.h:65
static MsgHandler * create(MsgType type)
A storage for options typed value containers)
Definition: OptionsCont.h:89
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:59
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
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:54
int main(int argc, char **argv)