SUMO - Simulation of Urban MObility
guisim_main.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // Main for GUISIM
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #ifdef HAVE_VERSION_H
35 #include <version.h>
36 #endif
37 
38 #include <ctime>
39 #include <signal.h>
40 #include <iostream>
41 #include <microsim/MSFrame.h>
42 #include <microsim/MSNet.h>
43 #include <utils/options/Option.h>
50 #include <utils/xml/XMLSubSys.h>
54 
55 #ifdef CHECK_MEMORY_LEAKS
56 #include <foreign/nvwa/debug_new.h>
57 #endif
58 
59 
60 // ===========================================================================
61 // main function
62 // ===========================================================================
63 int
64 main(int argc, char** argv) {
65  // make the output aware of threading
66  MFXMutex lock;
68  // get the options
70  // give some application descriptions
71  oc.setApplicationDescription("GUI version of the simulation SUMO.");
72  oc.setApplicationName("sumo-gui.exe", "SUMO gui Version " VERSION_STRING);
73  int ret = 0;
74  try {
75  // initialise subsystems
77  // Make application
78  FXApp application("SUMO GUISimulation", "DLR");
79  // Open display
80  application.init(argc, argv);
81  int minor, major;
82  if (!FXGLVisual::supported(&application, major, minor)) {
83  throw ProcessError("This system has no OpenGL support. Exiting.");
84  }
85 
86  // build the main window
87  GUIApplicationWindow* window =
88  new GUIApplicationWindow(&application, "*.sumo.cfg,*.sumocfg");
89  gSchemeStorage.init(&application);
90  window->dependentBuild();
91  // Create app
92  application.addSignal(SIGINT, window, MID_QUIT);
93  application.create();
94  // Load configuration given on command line
95  if (argc > 1) {
96  OptionsIO::setArgs(argc, argv);
97  window->loadOnStartup();
98  }
99  // Run
100  ret = application.run();
101  } catch (const ProcessError& e) {
102  if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
103  WRITE_ERROR(e.what());
104  }
105  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
106  ret = 1;
107 #ifndef _DEBUG
108  } catch (const std::exception& e) {
109  if (std::string(e.what()) != std::string("")) {
110  WRITE_ERROR(e.what());
111  }
112  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
113  ret = 1;
114  } catch (...) {
115  MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
116  ret = 1;
117 #endif
118  }
120  return ret;
121 }
122 
123 
124 /****************************************************************************/
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:58
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:80
GUICompleteSchemeStorage gSchemeStorage
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:279
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:65
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
Main window closes.
Definition: GUIAppEnum.h:55
#define VERSION_STRING
Definition: version.h:1
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:89
A storage for options typed value containers)
Definition: OptionsCont.h:108
void init(FXApp *app)
Initialises the storage with some default settings.
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.
int main(int argc, char **argv)
Definition: guisim_main.cpp:64
The main window of the SUMO-gui.