SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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.sourceforge.net/
13 // Copyright (C) 2001-2013 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 // methods
62 // ===========================================================================
63 /* -------------------------------------------------------------------------
64  * main
65  * ----------------------------------------------------------------------- */
66 int
67 main(int argc, char** argv) {
68  // make the output aware of threading
69  MFXMutex lock;
71  // get the options
73  // give some application descriptions
74  oc.setApplicationDescription("GUI version of the simulation SUMO.");
75  oc.setApplicationName("sumo-gui.exe", "SUMO gui Version " + (std::string)VERSION_STRING);
76  int ret = 0;
77 #ifndef _DEBUG
78  try {
79 #else
80  {
81 #endif
82  // initialise subsystems
85  OptionsIO::getOptions(false, argc, argv);
86  if (oc.processMetaOptions(false)) {
88  return 0;
89  }
90  XMLSubSys::setValidation(oc.getBool("xml-validation"));
91  // Make application
92  FXApp application("SUMO GUISimulation", "DLR");
93  // Open display
94  application.init(argc, argv);
95  int minor, major;
96  if (!FXGLVisual::supported(&application, major, minor)) {
97  throw ProcessError("This system has no OpenGL support. Exiting.");
98  }
99 
100  // build the main window
101  GUIApplicationWindow* window =
102  new GUIApplicationWindow(&application, "*.sumo.cfg,*.sumocfg");
103  window->dependentBuild(oc.getBool("game"));
104  gSchemeStorage.init(&application);
105  // Create app
106  application.addSignal(SIGINT, window, MID_QUIT);
107  application.create();
108  // Load configuration given on command line
109  if (oc.isSet("configuration-file") || oc.isSet("net-file")) {
110  window->loadOnStartup();
111  }
112  // Run
113  ret = application.run();
114 #ifndef _DEBUG
115  } catch (const std::exception& e) {
116  if (std::string(e.what()) != std::string("")) {
117  WRITE_ERROR(e.what());
118  }
119  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
120  ret = 1;
121  } catch (...) {
122  MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
123  ret = 1;
124 #endif
125  }
127  return ret;
128 }
129 
130 
131 
132 /****************************************************************************/
133