SUMO - Simulation of Urban MObility
guisim_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 /****************************************************************************/
20 // Main for GUISIM
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #ifdef HAVE_VERSION_H
34 #include <version.h>
35 #endif
36 
37 #include <ctime>
38 #include <signal.h>
39 #include <iostream>
40 #include <microsim/MSFrame.h>
41 #include <microsim/MSNet.h>
42 #include <utils/options/Option.h>
49 #include <utils/xml/XMLSubSys.h>
53 
54 #ifndef NO_TRACI
56 #endif
57 
58 
59 // ===========================================================================
60 // main function
61 // ===========================================================================
62 int
63 main(int argc, char** argv) {
64  // make the output aware of threading
65  MFXMutex lock;
67  // get the options
69  // give some application descriptions
70  oc.setApplicationDescription("GUI version of the simulation SUMO.");
71  oc.setApplicationName("sumo-gui", "SUMO gui Version " VERSION_STRING);
72  int ret = 0;
73  try {
74  // initialise subsystems
77  OptionsIO::setArgs(argc, argv);
79  if (oc.processMetaOptions(false)) {
81  return 0;
82  }
83  // Make application
84  FXApp application("SUMO GUISimulation", "DLR");
85  // Open display
86  application.init(argc, argv);
87  int minor, major;
88  if (!FXGLVisual::supported(&application, major, minor)) {
89  throw ProcessError("This system has no OpenGL support. Exiting.");
90  }
91 
92  // build the main window
93  GUIApplicationWindow* window =
94  new GUIApplicationWindow(&application, "*.sumo.cfg,*.sumocfg");
95  gSchemeStorage.init(&application);
96  window->dependentBuild();
97  // Create app
98  application.addSignal(SIGINT, window, MID_QUIT);
99  application.create();
100  // Load configuration given on command line
101  if (argc > 1) {
102  window->loadOnStartup();
103  }
104  // Run
105  ret = application.run();
106  } catch (const ProcessError& e) {
107  if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
108  WRITE_ERROR(e.what());
109  }
110  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
111  ret = 1;
112 #ifndef _DEBUG
113  } catch (const std::exception& e) {
114  if (std::string(e.what()) != std::string("")) {
115  WRITE_ERROR(e.what());
116  }
117  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
118  ret = 1;
119  } catch (...) {
120  MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
121  ret = 1;
122 #endif
123  }
124 #ifndef NO_TRACI
126 #endif
128  return ret;
129 }
130 
131 
132 /****************************************************************************/
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
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
static void fillOptions()
Inserts options used by the simulation into the OptionsCont-singleton.
Definition: MSFrame.cpp:66
static void close()
request termination of connection
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 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
Main window closes.
Definition: GUIAppEnum.h:54
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.
int main(int argc, char **argv)
Definition: guisim_main.cpp:63
The main window of the SUMO-gui.