LCOV - code coverage report
Current view: top level - src - guisim_main.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 79.1 % 43 34
Test Date: 2024-11-20 15:55:46 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    guisim_main.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Michael Behrisch
      18              : /// @author  Felix Brack
      19              : /// @date    Tue, 20 Nov 2001
      20              : ///
      21              : // Main for GUISIM
      22              : /****************************************************************************/
      23              : #include <config.h>
      24              : 
      25              : #ifdef HAVE_VERSION_H
      26              : #include <version.h>
      27              : #endif
      28              : 
      29              : #include <ctime>
      30              : #include <signal.h>
      31              : #include <iostream>
      32              : #include <microsim/MSFrame.h>
      33              : #include <microsim/MSNet.h>
      34              : #include <utils/options/Option.h>
      35              : #include <utils/options/OptionsCont.h>
      36              : #include <utils/options/OptionsIO.h>
      37              : #include <utils/common/UtilExceptions.h>
      38              : #include <utils/common/FileHelpers.h>
      39              : #include <utils/common/MsgHandler.h>
      40              : #include <utils/common/SystemFrame.h>
      41              : #include <utils/foxtools/MsgHandlerSynchronized.h>
      42              : #include <utils/xml/XMLSubSys.h>
      43              : #include <gui/GUIApplicationWindow.h>
      44              : #include <utils/gui/windows/GUIAppEnum.h>
      45              : #include <utils/gui/settings/GUICompleteSchemeStorage.h>
      46              : #include <traci-server/TraCIServer.h>
      47              : 
      48              : 
      49              : // ===========================================================================
      50              : // main function
      51              : // ===========================================================================
      52              : int
      53         7063 : main(int argc, char** argv) {
      54              :     // make the output aware of threading
      55              :     MsgHandler::setFactory(&MsgHandlerSynchronized::create);
      56         7063 :     OptionsCont& oc = OptionsCont::getOptions();
      57         7063 :     oc.setApplicationDescription(TL("GUI version of the microscopic, multi-modal traffic simulation SUMO."));
      58        14126 :     oc.setApplicationName("sumo-gui", "Eclipse SUMO GUI Version " VERSION_STRING);
      59         7063 :     gSimulation = true;
      60              :     // preload registry from sumo to decide on language
      61         7063 :     FXRegistry reg("SUMO GUI", "sumo-gui");
      62         7063 :     reg.read();
      63         7063 :     gLanguage = reg.readStringEntry("gui", "language", gLanguage.c_str());
      64              :     int ret = 0;
      65              :     try {
      66              :         // initialise subsystems
      67         7063 :         XMLSubSys::init();
      68         7063 :         MSFrame::fillOptions();
      69         7063 :         OptionsIO::setArgs(argc, argv);
      70         7063 :         OptionsIO::getOptions(true);
      71         7051 :         if (oc.processMetaOptions(false)) {
      72            0 :             SystemFrame::close();
      73            0 :             return 0;
      74              :         }
      75              :         // Make application
      76         7051 :         FXApp application("SUMO GUI", "sumo-gui");
      77              :         // Open display
      78         7051 :         application.init(argc, argv);
      79              :         int minor, major;
      80         7051 :         if (!FXGLVisual::supported(&application, major, minor)) {
      81            0 :             throw ProcessError(TL("This system has no OpenGL support. Exiting."));
      82              :         }
      83              : 
      84              :         // build the main window
      85         7051 :         GUIApplicationWindow* window = new GUIApplicationWindow(&application, "*.sumo.cfg,*.sumocfg");
      86         7051 :         gLanguage = oc.getString("language");
      87         7051 :         gSchemeStorage.init(&application);
      88         7051 :         window->dependentBuild(false);
      89              :         // Create app
      90         7051 :         application.addSignal(SIGINT, window, MID_HOTKEY_CTRL_Q_CLOSE);
      91         7051 :         application.create();
      92              :         // Load configuration given on command line
      93         7051 :         if (argc > 1) {
      94         7051 :             window->loadOnStartup();
      95              :         }
      96              :         // Run
      97         7051 :         window->setFocus();
      98         7051 :         ret = application.run();
      99         7063 :     } catch (const ProcessError& e) {
     100           36 :         if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
     101           24 :             WRITE_ERROR(e.what());
     102              :         }
     103           12 :         MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
     104              :         ret = 1;
     105              : #ifndef _DEBUG
     106           12 :     } catch (const std::exception& e) {
     107            0 :         if (std::string(e.what()) != std::string("")) {
     108            0 :             WRITE_ERROR(e.what());
     109              :         }
     110            0 :         MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
     111              :         ret = 1;
     112            0 :     } catch (...) {
     113            0 :         MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
     114              :         ret = 1;
     115              : #endif
     116            0 :     }
     117         7063 :     TraCIServer::close();
     118         7063 :     SystemFrame::close();
     119              :     return ret;
     120         7063 : }
     121              : 
     122              : 
     123              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1