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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // Main for NETEDIT (adapted from guisim_main)
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
30 #ifdef HAVE_VERSION_H
31 #include <version.h>
32 #endif
33 
34 #include <ctime>
35 #include <signal.h>
36 #include <iostream>
37 #include <utils/options/Option.h>
45 #include <utils/xml/XMLSubSys.h>
50 #include <netimport/NIFrame.h>
51 #include <netbuild/NBFrame.h>
52 #include <netwrite/NWFrame.h>
53 
54 #include "GNEApplicationWindow.h"
55 #include "GNELoadThread.h"
56 
57 
58 // ===========================================================================
59 // main function
60 // ===========================================================================
61 int
62 main(int argc, char** argv) {
63  // make the output aware of threading
64  MFXMutex lock;
66  // get the options
68  // give some application descriptions
69  oc.setApplicationDescription("Graphical editor for SUMO networks.");
70  oc.setApplicationName("netedit", "Netedit Version " VERSION_STRING);
71  int ret = 0;
72 #ifndef _DEBUG
73  try {
74 #else
75  {
76 #endif
77  // initialise subsystems
80  OptionsIO::setArgs(argc, argv);
82  if (oc.processMetaOptions(false)) {
84  return 0;
85  }
86  // Make application
87  FXApp application("Netedit", "DLR");
88  // Open display
89  application.init(argc, argv);
90  int minor, major;
91  if (!FXGLVisual::supported(&application, major, minor)) {
92  throw ProcessError("This system has no OpenGL support. Exiting.");
93  }
94  // build the main window
95  GNEApplicationWindow* window =
96  new GNEApplicationWindow(&application, "*.netc.cfg,*.netccfg");
97  gSchemeStorage.init(&application, true);
98  window->dependentBuild();
99  // Create app
100  application.addSignal(SIGINT, window, MID_QUIT);
101  application.create();
102  // Load configuration given on command line
103  if (argc > 1) {
104  // Set default options
105  OptionsIO::setArgs(argc, argv);
106  // load options
107  window->loadOptionOnStartup();
108  }
109  // Run
110  ret = application.run();
111 #ifndef _DEBUG
112  } catch (const std::exception& e) {
113  if (std::string(e.what()) != std::string("")) {
114  WRITE_ERROR(e.what());
115  }
116  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
117  ret = 1;
118  } catch (...) {
119  MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
120  ret = 1;
121 #endif
122  }
124  return ret;
125 }
126 
127 
128 
129 /****************************************************************************/
130 
void init(FXApp *app, bool netedit=false)
Initialises the storage with some default settings.
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:53
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:75
GUICompleteSchemeStorage gSchemeStorage
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
Definition: OptionsIO.cpp:82
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:274
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:61
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
#define VERSION_STRING
Definition: config.h:210
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
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:84
A storage for options typed value containers)
Definition: OptionsCont.h:98
void dependentBuild()
build dependent
static void fillOptions(OptionsCont &oc)
clears and initializes the OptionsCont
Main window closes.
Definition: GUIAppEnum.h:54
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.