Path: blob/main/src/netedit/dialogs/run/GNERunNetgenerateDialog.cpp
169684 views
/****************************************************************************/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 GNERunNetgenerateDialog.cpp14/// @author Pablo Alvarez Lopez15/// @date Mar 202316///17// Dialog for running tools18/****************************************************************************/1920#include <netedit/GNEApplicationWindow.h>21#include <netedit/GNEExternalRunner.h>2223#include "GNERunNetgenerateDialog.h"2425// ============================================-===============================26// member method definitions27// ===========================================================================2829GNERunNetgenerateDialog::GNERunNetgenerateDialog(GNEApplicationWindow* applicationWindow, const OptionsCont* netgenerateOptions) :30GNERunDialog(applicationWindow, TL("Running netgenerate results"), GUIIcon::NETGENERATE),31myNetgenerateOptions(netgenerateOptions) {32// run tool33applicationWindow->getExternalRunner()->runTool(this);34// open modal dialog35openDialog();36}373839GNERunNetgenerateDialog::~GNERunNetgenerateDialog() {}404142void43GNERunNetgenerateDialog::runInternalTest(const InternalTestStep::DialogArgument* /*dialogArgument*/) {44// nothing to do45}464748std::string49GNERunNetgenerateDialog::getRunCommand() const {50// set command51#ifdef WIN3252const std::string exePath = "netgenerate.exe";53#else54const std::string exePath = "netgenerate";55#endif56const char* sumoHomeEnv = getenv("SUMO_HOME");57std::string sumoHome = "";58if (sumoHomeEnv != nullptr && sumoHomeEnv != std::string("")) {59sumoHome = std::string(sumoHomeEnv);60// harmonise slash61if (sumoHome.back() == '\\') {62sumoHome = sumoHome.substr(0, sumoHome.size() - 1);63}64// prevent double quotes65if (sumoHome.front() == '"') {66sumoHome.erase(sumoHome.begin());67}68if (sumoHome.size() > 0 && sumoHome.back() == '"') {69sumoHome.pop_back();70}71sumoHome += "/bin/";72}73// quote to handle spaces. note that this differs from GNEPythonTool because the python interpreter is a bit smarter74// when handling quoted parts within a path75std::string runCommand = "\"" + sumoHome + exePath + "\"";7677// iterate over all topics78for (const auto& topic : myNetgenerateOptions->getSubTopics()) {79// ignore configuration80if (topic != "Configuration") {81const std::vector<std::string> entries = myNetgenerateOptions->getSubTopicsEntries(topic);82for (const auto& entry : entries) {83if (!myNetgenerateOptions->isDefault(entry)) {84runCommand += " --" + entry + " " + myNetgenerateOptions->getValueString(entry);85}86}87}88}89return runCommand;90}919293long94GNERunNetgenerateDialog::onCmdBack(FXObject*, FXSelector, void*) {95// close run dialog and open tool dialog96closeDialogCanceling();97return myApplicationWindow->handle(this, FXSEL(SEL_COMMAND, MID_GNE_NETGENERATE), nullptr);98}99100101long102GNERunNetgenerateDialog::onCmdAccept(FXObject*, FXSelector, void*) {103// close run dialog and call postprocessing104closeDialogCanceling();105// abort tool106myApplicationWindow->getExternalRunner()->abort();107// reset text108myText->setText("", 0);109// call postprocessing dialog110if (myError) {111return 1;112} else {113// don't run this again114myError = true;115return myApplicationWindow->handle(this, FXSEL(SEL_COMMAND, MID_GNE_POSTPROCESSINGNETGENERATE), nullptr);116}117}118119/****************************************************************************/120121122