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/windows/GUIAppGlobals.h>
00058 #include <utils/gui/images/GUITexturesHelper.h>
00059 #include <utils/gui/settings/GUICompleteSchemeStorage.h>
00060 #include <gui/GUIViewTraffic.h>
00061 #include <guisim/GUIVehicle.h>
00062 
00063 #ifdef CHECK_MEMORY_LEAKS
00064 #include <foreign/nvwa/debug_new.h>
00065 #endif
00066 
00067 
00068 // ===========================================================================
00069 // methods
00070 // ===========================================================================
00071 /* -------------------------------------------------------------------------
00072  * main
00073  * ----------------------------------------------------------------------- */
00074 int
00075 main(int argc, char** argv) {
00076     // make the output aware of threading
00077     MFXMutex lock;
00078     MsgHandler::assignLock(&lock);
00079     // get the options
00080     OptionsCont& oc = OptionsCont::getOptions();
00081     // give some application descriptions
00082     oc.setApplicationDescription("GUI version of the simulation SUMO.");
00083     oc.setApplicationName("sumo-gui.exe", "SUMO gui Version " + (std::string)VERSION_STRING);
00084     int ret = 0;
00085 #ifndef _DEBUG
00086     try {
00087 #else
00088     {
00089 #endif
00090         // initialise subsystems
00091         XMLSubSys::init(false);
00092         MSFrame::fillOptions();
00093         OptionsIO::getOptions(false, argc, argv);
00094         if (oc.processMetaOptions(false)) {
00095             SystemFrame::close();
00096             return 0;
00097         }
00098         // within gui-based applications, nothing is reported to the console
00099         MsgHandler::getErrorInstance()->report2cout(false);
00100         MsgHandler::getErrorInstance()->report2cerr(false);
00101         MsgHandler::getWarningInstance()->report2cout(false);
00102         MsgHandler::getWarningInstance()->report2cerr(false);
00103         MsgHandler::getMessageInstance()->report2cout(false);
00104         MsgHandler::getMessageInstance()->report2cerr(false);
00105         // Make application
00106         FXApp application("SUMO GUISimulation", "DLR");
00107         gFXApp = &application;
00108         // Open display
00109         application.init(argc, argv);
00110         int minor, major;
00111         if (!FXGLVisual::supported(&application, major, minor)) {
00112             throw ProcessError("This system has no OpenGL support. Exiting.");
00113         }
00114         // initialise global settings
00115         gQuitOnEnd = oc.getBool("quit-on-end");
00116         gAllowTextures = !oc.getBool("disable-textures");
00117 
00118         // build the main window
00119         GUIApplicationWindow* window =
00120         new GUIApplicationWindow(&application, "*.sumo.cfg,*.sumocfg");
00121         window->dependentBuild(oc.getBool("game"));
00122         gSchemeStorage.init(&application);
00123         // Create app
00124         application.addSignal(SIGINT, window, MID_QUIT);
00125         application.create();
00126         // Load configuration given on command line
00127         if (oc.isSet("configuration-file") || oc.isSet("net-file")) {
00128             window->loadOnStartup(!oc.getBool("no-start"));
00129         }
00130         // Run
00131         ret = application.run();
00132 #ifndef _DEBUG
00133     } catch (...) {
00134         MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
00135         ret = 1;
00136     }
00137 #else
00138     }
00139 #endif
00140     SystemFrame::close();
00141     return ret;
00142 }
00143 
00144 
00145 
00146 /****************************************************************************/
00147 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines