SUMO - Simulation of Urban MObility
guisim_main.cpp
Go to the documentation of this file.
00001 /****************************************************************************/
00010 // Main for GUISIM
00011 /****************************************************************************/
00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00014 /****************************************************************************/
00015 //
00016 //   This file is part of SUMO.
00017 //   SUMO is free software: you can redistribute it and/or modify
00018 //   it under the terms of the GNU General Public License as published by
00019 //   the Free Software Foundation, either version 3 of the License, or
00020 //   (at your option) any later version.
00021 //
00022 /****************************************************************************/
00023 
00024 
00025 // ===========================================================================
00026 // included modules
00027 // ===========================================================================
00028 #ifdef _MSC_VER
00029 #include <windows_config.h>
00030 #else
00031 #include <config.h>
00032 #endif
00033 
00034 #ifdef HAVE_VERSION_H
00035 #include <version.h>
00036 #endif
00037 
00038 #include <ctime>
00039 #include <signal.h>
00040 #include <iostream>
00041 #include <fx.h>
00042 #include <fx3d.h>
00043 #include <microsim/MSFrame.h>
00044 #include <microsim/MSNet.h>
00045 #include <utils/options/Option.h>
00046 #include <utils/options/OptionsCont.h>
00047 #include <utils/options/OptionsIO.h>
00048 #include <utils/common/UtilExceptions.h>
00049 #include <utils/common/FileHelpers.h>
00050 #include <utils/common/MsgHandler.h>
00051 #include <utils/common/SystemFrame.h>
00052 #include <utils/xml/XMLSubSys.h>
00053 #include <gui/GUIApplicationWindow.h>
00054 #include <utils/gui/windows/GUIAppEnum.h>
00055 #include <gui/GUIGlobals.h>
00056 #include <guisim/GUIEdge.h>
00057 #include <utils/gui/settings/GUICompleteSchemeStorage.h>
00058 #include <gui/GUIViewTraffic.h>
00059 #include <guisim/GUIVehicle.h>
00060 
00061 #ifdef CHECK_MEMORY_LEAKS
00062 #include <foreign/nvwa/debug_new.h>
00063 #endif
00064 
00065 
00066 // ===========================================================================
00067 // methods
00068 // ===========================================================================
00069 /* -------------------------------------------------------------------------
00070  * main
00071  * ----------------------------------------------------------------------- */
00072 int
00073 main(int argc, char** argv) {
00074     // make the output aware of threading
00075     MFXMutex lock;
00076     MsgHandler::assignLock(&lock);
00077     // get the options
00078     OptionsCont& oc = OptionsCont::getOptions();
00079     // give some application descriptions
00080     oc.setApplicationDescription("GUI version of the simulation SUMO.");
00081     oc.setApplicationName("sumo-gui.exe", "SUMO gui Version " + (std::string)VERSION_STRING);
00082     int ret = 0;
00083 #ifndef _DEBUG
00084     try {
00085 #else
00086     {
00087 #endif
00088         // initialise subsystems
00089         XMLSubSys::init(false);
00090         MSFrame::fillOptions();
00091         OptionsIO::getOptions(false, argc, argv);
00092         if (oc.processMetaOptions(false)) {
00093             SystemFrame::close();
00094             return 0;
00095         }
00096         // Make application
00097         FXApp application("SUMO GUISimulation", "DLR");
00098         // Open display
00099         application.init(argc, argv);
00100         int minor, major;
00101         if (!FXGLVisual::supported(&application, major, minor)) {
00102             throw ProcessError("This system has no OpenGL support. Exiting.");
00103         }
00104 
00105         // build the main window
00106         GUIApplicationWindow* window =
00107         new GUIApplicationWindow(&application, "*.sumo.cfg,*.sumocfg");
00108         window->dependentBuild(oc.getBool("game"));
00109         gSchemeStorage.init(&application);
00110         // Create app
00111         application.addSignal(SIGINT, window, MID_QUIT);
00112         application.create();
00113         // Load configuration given on command line
00114         if (oc.isSet("configuration-file") || oc.isSet("net-file")) {
00115             window->loadOnStartup();
00116         }
00117         // Run
00118         ret = application.run();
00119 #ifndef _DEBUG
00120     } catch (...) {
00121         MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
00122         ret = 1;
00123     }
00124 #else
00125     }
00126 #endif
00127     SystemFrame::close();
00128     return ret;
00129 }
00130 
00131 
00132 
00133 /****************************************************************************/
00134 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines