Eclipse 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-2019 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 /****************************************************************************/
17 // Main for GUISIM
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #ifdef HAVE_VERSION_H
27 #include <version.h>
28 #endif
29 
30 #include <ctime>
31 #include <signal.h>
32 #include <iostream>
33 #include <microsim/MSFrame.h>
34 #include <microsim/MSNet.h>
35 #include <utils/options/Option.h>
43 #include <utils/xml/XMLSubSys.h>
48 
49 
50 // ===========================================================================
51 // main function
52 // ===========================================================================
53 int
54 main(int argc, char** argv) {
55  // make the output aware of threading
57  // get the options
59  // give some application descriptions
60  oc.setApplicationDescription("GUI version of the microscopic, multi-modal traffic simulation SUMO.");
61  oc.setApplicationName("sumo-gui", "Eclipse SUMO GUI Version " VERSION_STRING);
62  gSimulation = true;
63  int ret = 0;
64  try {
65  // initialise subsystems
68  OptionsIO::setArgs(argc, argv);
70  if (oc.processMetaOptions(false)) {
72  return 0;
73  }
74  // Make application
75  FXApp application("SUMO GUI", "Eclipse");
76  // Open display
77  application.init(argc, argv);
78  int minor, major;
79  if (!FXGLVisual::supported(&application, major, minor)) {
80  throw ProcessError("This system has no OpenGL support. Exiting.");
81  }
82 
83  // build the main window
84  GUIApplicationWindow* window =
85  new GUIApplicationWindow(&application, "*.sumo.cfg,*.sumocfg");
86  gSchemeStorage.init(&application);
87  window->dependentBuild();
88  // Create app
89  application.addSignal(SIGINT, window, MID_HOTKEY_CTRL_Q_CLOSE);
90  application.create();
91  // Load configuration given on command line
92  if (argc > 1) {
93  window->loadOnStartup();
94  }
95  // Run
96  ret = application.run();
97  } catch (const ProcessError& e) {
98  if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
99  WRITE_ERROR(e.what());
100  }
101  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
102  ret = 1;
103 #ifndef _DEBUG
104  } catch (const std::exception& e) {
105  if (std::string(e.what()) != std::string("")) {
106  WRITE_ERROR(e.what());
107  }
108  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
109  ret = 1;
110  } catch (...) {
111  MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
112  ret = 1;
113 #endif
114  }
117  return ret;
118 }
119 
120 
121 /****************************************************************************/
GUICompleteSchemeStorage.h
MSFrame::fillOptions
static void fillOptions()
Inserts options used by the simulation into the OptionsCont-singleton.
Definition: MSFrame.cpp:60
OptionsCont::processMetaOptions
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
Definition: OptionsCont.cpp:557
SystemFrame::close
static void close()
Closes all of an applications subsystems.
Definition: SystemFrame.cpp:133
MSNet.h
OptionsCont.h
MsgHandler.h
FileHelpers.h
MsgHandler::inform
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:118
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:57
TraCIServer::close
static void close()
request termination of connection
Definition: TraCIServer.cpp:303
gSimulation
bool gSimulation
Definition: StdDefs.cpp:29
GUIAppEnum.h
MsgHandlerSynchronized::create
static MsgHandler * create(MsgType type)
Definition: MsgHandlerSynchronized.h:50
MsgHandler::setFactory
static void setFactory(Factory func)
Sets the factory function to use for new MsgHandlers.
Definition: MsgHandler.h:63
OptionsCont::setApplicationName
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.
Definition: OptionsCont.cpp:481
SystemFrame.h
GUIApplicationWindow::loadOnStartup
void loadOnStartup()
Definition: GUIApplicationWindow.cpp:1818
GUIApplicationWindow
The main window of the SUMO-gui.
Definition: GUIApplicationWindow.h:65
ProcessError
Definition: UtilExceptions.h:39
GUIApplicationWindow.h
gSchemeStorage
GUICompleteSchemeStorage gSchemeStorage
Definition: GUICompleteSchemeStorage.cpp:38
UtilExceptions.h
XMLSubSys::init
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:47
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
GUIApplicationWindow::dependentBuild
void dependentBuild()
Definition: GUIApplicationWindow.cpp:231
MID_HOTKEY_CTRL_Q_CLOSE
Main window closes.
Definition: GUIAppEnum.h:99
OptionsIO::getOptions
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
Definition: OptionsIO.cpp:75
OptionsCont::setApplicationDescription
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
Definition: OptionsCont.cpp:489
Option.h
MsgHandlerSynchronized.h
OptionsIO::setArgs
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
Definition: OptionsIO.cpp:54
main
int main(int argc, char **argv)
Definition: guisim_main.cpp:54
TraCIServer.h
MSFrame.h
config.h
GUICompleteSchemeStorage::init
void init(FXApp *app, bool netedit=false)
Initialises the storage with some default settings.
Definition: GUICompleteSchemeStorage.cpp:111
MsgHandler::getErrorInstance
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:81
VERSION_STRING
#define VERSION_STRING
Definition: config.h:210
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:283
OptionsIO.h
XMLSubSys.h