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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // Main for NETEDIT (adapted from guisim_main)
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #ifdef HAVE_VERSION_H
25 #include <version.h>
26 #endif
27 
28 #include <signal.h>
34 #include <utils/xml/XMLSubSys.h>
35 
36 #include "GNEApplicationWindow.h"
37 #include "GNELoadThread.h"
38 
39 
40 // ===========================================================================
41 // main function
42 // ===========================================================================
43 int
44 main(int argc, char** argv) {
45  // make the output aware of threading
46  MFXMutex lock;
48  // get the options
50  // give some application descriptions
51  oc.setApplicationDescription("Graphical editor for SUMO networks.");
52  oc.setApplicationName("netedit", "Eclipse SUMO netedit Version " VERSION_STRING);
53  int ret = 0;
54 #ifndef _DEBUG
55  try {
56 #else
57  {
58 #endif
59  // initialise subsystems
62  OptionsIO::setArgs(argc, argv);
64  if (oc.processMetaOptions(false)) {
66  return 0;
67  }
68  // Make application
69  FXApp application("SUMO netedit", "Eclipse");
70  // Open display
71  application.init(argc, argv);
72  int minor, major;
73  if (!FXGLVisual::supported(&application, major, minor)) {
74  throw ProcessError("This system has no OpenGL support. Exiting.");
75  }
76  // build the main window
77  GNEApplicationWindow* window =
78  new GNEApplicationWindow(&application, "*.netc.cfg,*.netccfg");
79  gSchemeStorage.init(&application, true);
80  window->dependentBuild();
81  // Create app
82  application.addSignal(SIGINT, window, MID_QUIT);
83  application.create();
84  // Load configuration given on command line
85  if (argc > 1) {
86  // Set default options
87  OptionsIO::setArgs(argc, argv);
88  // load options
89  window->loadOptionOnStartup();
90  }
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 
111 /****************************************************************************/
112 
void init(FXApp *app, bool netedit=false)
Initialises the storage with some default settings.
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:48
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:76
GUICompleteSchemeStorage gSchemeStorage
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
Definition: OptionsIO.cpp:76
The main window of the Netedit.
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
static void assignLock(AbstractMutex *lock)
Sets the lock to use The lock will not be deleted.
Definition: MsgHandler.cpp:313
static void close()
Closes all of an applications subsystems.
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
Definition: OptionsIO.cpp:55
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.
#define VERSION_STRING
Definition: config.h:207
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:247
Main window closes.
Definition: GUIAppEnum.h:48
void loadOptionOnStartup()
load net on startup
int main(int argc, char **argv)
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:113
A storage for options typed value containers)
Definition: OptionsCont.h:92
void dependentBuild()
build dependent
static void fillOptions(OptionsCont &oc)
clears and initializes the OptionsCont
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.