guisim_main.cpp
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #ifdef HAVE_VERSION_H
00031 #include <version.h>
00032 #endif
00033
00034 #include <ctime>
00035 #include <signal.h>
00036 #include <iostream>
00037 #include <fx.h>
00038 #include <fx3d.h>
00039 #include <microsim/MSNet.h>
00040 #include <microsim/MSEmitControl.h>
00041 #include <utils/options/Option.h>
00042 #include <utils/options/OptionsCont.h>
00043 #include <utils/options/OptionsIO.h>
00044 #include <utils/common/UtilExceptions.h>
00045 #include <utils/common/FileHelpers.h>
00046 #include <utils/common/MsgHandler.h>
00047 #include <utils/common/SystemFrame.h>
00048 #include <utils/xml/XMLSubSys.h>
00049 #include <gui/GUIApplicationWindow.h>
00050 #include <utils/gui/windows/GUIAppEnum.h>
00051 #include <gui/GUIGlobals.h>
00052 #include <guisim/GUIEdge.h>
00053 #include <utils/gui/windows/GUIAppGlobals.h>
00054 #include <utils/gui/images/GUIImageGlobals.h>
00055 #include <utils/gui/settings/GUICompleteSchemeStorage.h>
00056 #include <gui/GUIViewTraffic.h>
00057 #include <guisim/GUIVehicle.h>
00058
00059 #ifdef CHECK_MEMORY_LEAKS
00060 #include <foreign/nvwa/debug_new.h>
00061 #endif
00062
00063
00064
00065
00066
00067
00068
00069
00070 void
00071 fillOptions() {
00072 OptionsCont &oc = OptionsCont::getOptions();
00073 oc.addCallExample("");
00074 oc.addCallExample("-c <CONFIGURATION>");
00075
00076
00077 oc.addOptionSubTopic("Process");
00078 oc.addOptionSubTopic("Visualisation");
00079
00080 oc.doRegister("configuration-file", 'c', new Option_FileName());
00081 oc.addSynonyme("configuration-file", "configuration");
00082 oc.addDescription("configuration-file", "Process", "Loads the named config on startup");
00083
00084 oc.doRegister("quit-on-end", 'Q', new Option_Bool(false));
00085 oc.addDescription("quit-on-end", "Process", "Quits the gui when the simulation stops");
00086
00087 oc.doRegister("game", 'G', new Option_Bool(false));
00088 oc.addDescription("game", "Process", "Start the GUI in gaming mode");
00089
00090 oc.doRegister("no-start", 'N', new Option_Bool(false));
00091 oc.addDescription("no-start", "Process", "Does not start the simulation after loading");
00092
00093 oc.doRegister("disable-textures", 'T', new Option_Bool(false));
00094 oc.addDescription("disable-textures", "Visualisation", "");
00095 }
00096
00097
00098
00099
00100
00101 int
00102 main(int argc, char **argv) {
00103
00104 MFXMutex lock;
00105 MsgHandler::assignLock(&lock);
00106
00107 OptionsCont &oc = OptionsCont::getOptions();
00108
00109 oc.setApplicationDescription("GUI version of the simulation SUMO.");
00110 oc.setApplicationName("sumo-gui.exe", "SUMO gui Version " + (std::string)VERSION_STRING);
00111 int ret = 0;
00112 #ifndef _DEBUG
00113 try {
00114 #else
00115 {
00116 #endif
00117
00118 XMLSubSys::init(false);
00119 fillOptions();
00120 OptionsIO::getOptions(false, argc, argv);
00121
00122 MsgHandler::getErrorInstance()->report2cout(false);
00123 MsgHandler::getErrorInstance()->report2cerr(false);
00124 MsgHandler::getWarningInstance()->report2cout(false);
00125 MsgHandler::getWarningInstance()->report2cerr(false);
00126 MsgHandler::getMessageInstance()->report2cout(false);
00127 MsgHandler::getMessageInstance()->report2cerr(false);
00128
00129 FXApp application("SUMO GUISimulation", "DLR");
00130 gFXApp = &application;
00131
00132 application.init(argc,argv);
00133 int minor, major;
00134 if (!FXGLVisual::supported(&application, major, minor)) {
00135 throw ProcessError("This system has no OpenGL support. Exiting.");
00136 }
00137
00138 gQuitOnEnd = oc.getBool("quit-on-end");
00139 gAllowTextures = !oc.getBool("disable-textures");
00140
00141
00142 GUIApplicationWindow * window =
00143 new GUIApplicationWindow(&application, "*.sumo.cfg");
00144 window->dependentBuild(oc.getBool("game"));
00145 gSchemeStorage.init(&application);
00146
00147 initGuiShapeNames();
00148
00149 application.addSignal(SIGINT,window, MID_QUIT);
00150 application.create();
00151
00152 if (oc.isSet("configuration-file")) {
00153 window->loadOnStartup(oc.getString("configuration-file"),
00154 !oc.getBool("no-start"));
00155 }
00156
00157 ret = application.run();
00158 #ifndef _DEBUG
00159 } catch (...) {
00160 MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
00161 ret = 1;
00162 }
00163 #else
00164 }
00165 #endif
00166 SystemFrame::close();
00167 return ret;
00168 }
00169
00170
00171
00172
00173