/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file netedit_main.cpp14/// @author Jakob Erdmann15/// @author Mirko Barthauer16/// @date Feb 201117///18// Main for netedit (adapted from guisim_main)19/****************************************************************************/2021#include <signal.h>22#include <utils/xml/XMLSubSys.h>23#include <utils/options/OptionsIO.h>24#include <utils/gui/settings/GUICompleteSchemeStorage.h>25#include <utils/foxtools/MsgHandlerSynchronized.h>26#include <utils/common/SystemFrame.h>2728#ifdef HAVE_VERSION_H29#include <version.h>30#endif3132#include "GNEApplicationWindow.h"33#include "GNEExternalRunner.h"34#include "GNELoadThread.h"35#include "GNETagPropertiesDatabase.h"363738// #define SECUREEXCEPTION3940// ===========================================================================41// main function42// ===========================================================================43int44main(int argc, char** argv) {45// make the output aware of threading46MsgHandler::setFactory(&MsgHandlerSynchronized::create);47// get the options48auto& neteditOptions = OptionsCont::getOptions();49neteditOptions.setApplicationDescription(TL("Graphical editor for SUMO networks, demand and additional infrastructure."));50neteditOptions.setApplicationName("netedit", "Eclipse SUMO netedit " VERSION_STRING);51// preload registry from sumo to decide on language52FXRegistry reg("SUMO GUI", "sumo-gui");53reg.read();54// set language55gLanguage = reg.readStringEntry("gui", "language", gLanguage.c_str());56int ret = 0;57// run netedit with try-catch if we're in debug-mode58#ifdef SECUREEXCEPTION59try {60#endif61// initialise subsystems62XMLSubSys::init();63// fill options64GNELoadThread::fillOptions(neteditOptions);65// set default options66GNELoadThread::setDefaultOptions(neteditOptions);6768// set arguments called through console69OptionsIO::setArgs(argc, argv);70OptionsIO::getOptions(true);71if (neteditOptions.processMetaOptions(false)) {72SystemFrame::close();73} else {74// create tagPropertiesdatabase75const GNETagPropertiesDatabase* tagPropertiesDatabase = new GNETagPropertiesDatabase();7677if (neteditOptions.isSet("attribute-help-output")) {78// write attribute help in console79tagPropertiesDatabase->writeAttributeHelp();80} else {81// create FX application82FXApp application("SUMO netedit", "netedit");83// Open display84application.init(argc, argv);85int minor, major;86if (!FXGLVisual::supported(&application, major, minor)) {87throw ProcessError(TL("This system has no OpenGL support. Exiting."));88} else {89// build the main window90GNEApplicationWindow* netedit = new GNEApplicationWindow(&application, tagPropertiesDatabase, "*.netc.cfg,*.netccfg");91// build external runner92GNEExternalRunner* externalRunner = new GNEExternalRunner(netedit);93// set language94gLanguage = neteditOptions.getString("language");95// initialize GUICompleteSchemeStorage96gSchemeStorage.init(&application, true);97// build dependent elements98netedit->dependentBuild();99// add signal handler for CTRL+Q100application.addSignal(SIGINT, netedit, MID_HOTKEY_CTRL_Q_CLOSE);101// Create app102application.create();103// Load configuration given on command line104if (argc > 1) {105// Set default options106OptionsIO::setArgs(argc, argv);107// load options108netedit->loadOptionOnStartup();109}110// focus window at startup111netedit->setFocus();112// Run113ret = application.run();114// delete external runner115delete externalRunner;116// delete netedit117delete netedit;118}119}120// delete tagPropertiesDatabase121delete tagPropertiesDatabase;122}123#ifdef SECUREEXCEPTION124} catch (const std::exception& e) {125if (std::string(e.what()) != std::string("")) {126WRITE_ERROR(e.what());127}128MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);129ret = 1;130} catch (...) {131MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);132ret = 1;133}134#endif135SystemFrame::close();136return ret;137}138139/****************************************************************************/140141142