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 
35 #include "GNEApplicationWindow.h"
36 #include "GNELoadThread.h"
37 
38 
39 // ===========================================================================
40 // main function
41 // ===========================================================================
42 int
43 main(int argc, char** argv) {
44  // make the output aware of threading
46  // get the options
48  // give some application descriptions
49  oc.setApplicationDescription("Graphical editor for SUMO networks.");
50  oc.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
60  OptionsIO::setArgs(argc, argv);
62  if (oc.processMetaOptions(false)) {
64  return 0;
65  }
66  // Make application
67  FXApp application("SUMO netedit", "netedit");
68  // Open display
69  application.init(argc, argv);
70  int minor, major;
71  if (!FXGLVisual::supported(&application, major, minor)) {
72  throw ProcessError("This system has no OpenGL support. Exiting.");
73  }
74  // build the main window
75  GNEApplicationWindow* window =
76  new GNEApplicationWindow(&application, "*.netc.cfg,*.netccfg");
77  gSchemeStorage.init(&application, true);
78  window->dependentBuild();
79  // Create app
80  application.addSignal(SIGINT, window, MID_HOTKEY_CTRL_Q_CLOSE);
81  application.create();
82  // Load configuration given on command line
83  if (argc > 1) {
84  // Set default options
85  OptionsIO::setArgs(argc, argv);
86  // load options
87  window->loadOptionOnStartup();
88  }
89  // focus window at startup
90  window->setFocus();
91  // Run
92  ret = application.run();
93 #ifndef _DEBUG
94  } catch (const std::exception& e) {
95  if (std::string(e.what()) != std::string("")) {
96  WRITE_ERROR(e.what());
97  }
98  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
99  ret = 1;
100  } catch (...) {
101  MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
102  ret = 1;
103 #endif
104  }
106  return ret;
107 }
108 
109 
110 /****************************************************************************/
@ MID_HOTKEY_CTRL_Q_CLOSE
Main window closes.
Definition: GUIAppEnum.h:103
GUICompleteSchemeStorage gSchemeStorage
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:288
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:80
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:117
static void setFactory(Factory func)
Sets the factory function to use for new MsgHandlers.
Definition: MsgHandler.h:62
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:58
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:85
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)