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-2012 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 <fx.h>
42 #include <fx3d.h>
43 #include <microsim/MSFrame.h>
44 #include <microsim/MSNet.h>
45 #include <utils/options/Option.h>
52 #include <utils/xml/XMLSubSys.h>
55 #include <gui/GUIGlobals.h>
56 #include <guisim/GUIEdge.h>
58 #include <gui/GUIViewTraffic.h>
59 #include <guisim/GUIVehicle.h>
60 
61 #ifdef CHECK_MEMORY_LEAKS
62 #include <foreign/nvwa/debug_new.h>
63 #endif
64 
65 
66 // ===========================================================================
67 // methods
68 // ===========================================================================
69 /* -------------------------------------------------------------------------
70  * main
71  * ----------------------------------------------------------------------- */
72 int
73 main(int argc, char** argv) {
74  // make the output aware of threading
75  MFXMutex lock;
77  // get the options
79  // give some application descriptions
80  oc.setApplicationDescription("GUI version of the simulation SUMO.");
81  oc.setApplicationName("sumo-gui.exe", "SUMO gui Version " + (std::string)VERSION_STRING);
82  int ret = 0;
83 #ifndef _DEBUG
84  try {
85 #else
86  {
87 #endif
88  // initialise subsystems
89  XMLSubSys::init(false);
91  OptionsIO::getOptions(false, argc, argv);
92  if (oc.processMetaOptions(false)) {
94  return 0;
95  }
96  // Make application
97  FXApp application("SUMO GUISimulation", "DLR");
98  // Open display
99  application.init(argc, argv);
100  int minor, major;
101  if (!FXGLVisual::supported(&application, major, minor)) {
102  throw ProcessError("This system has no OpenGL support. Exiting.");
103  }
104 
105  // build the main window
106  GUIApplicationWindow* window =
107  new GUIApplicationWindow(&application, "*.sumo.cfg,*.sumocfg");
108  window->dependentBuild(oc.getBool("game"));
109  gSchemeStorage.init(&application);
110  // Create app
111  application.addSignal(SIGINT, window, MID_QUIT);
112  application.create();
113  // Load configuration given on command line
114  if (oc.isSet("configuration-file") || oc.isSet("net-file")) {
115  window->loadOnStartup();
116  }
117  // Run
118  ret = application.run();
119 #ifndef _DEBUG
120  } catch (...) {
121  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
122  ret = 1;
123  }
124 #else
125  }
126 #endif
128  return ret;
129 }
130 
131 
132 
133 /****************************************************************************/
134