Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
run/GNERunNetgenerateDialog.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 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/****************************************************************************/
18// Dialog for running tools
19/****************************************************************************/
20
23
25
26// ============================================-===============================
27// member method definitions
28// ===========================================================================
29
31 GNERunDialog(applicationWindow, TL("Running netgenerate results"), GUIIcon::NETGENERATE),
32 myNetgenerateOptions(netgenerateOptions) {
33 // run tool
34 applicationWindow->getExternalRunner()->runTool(this);
35 // open modal dialog
36 openDialog();
37}
38
39
41
42
43void
45 // nothing to do
46}
47
48
49std::string
51 // set command
52#ifdef WIN32
53 const std::string exePath = "netgenerate.exe";
54#else
55 const std::string exePath = "netgenerate";
56#endif
57 const char* sumoHomeEnv = getenv("SUMO_HOME");
58 std::string sumoHome = "";
59 if (sumoHomeEnv != nullptr && sumoHomeEnv != std::string("")) {
60 sumoHome = std::string(sumoHomeEnv);
61 // harmonise slash
62 if (sumoHome.back() == '\\') {
63 sumoHome = sumoHome.substr(0, sumoHome.size() - 1);
64 }
65 // prevent double quotes
66 if (sumoHome.front() == '"') {
67 sumoHome.erase(sumoHome.begin());
68 }
69 if (sumoHome.size() > 0 && sumoHome.back() == '"') {
70 sumoHome.pop_back();
71 }
72 sumoHome += "/bin/";
73 }
74 // quote to handle spaces. note that this differs from GNEPythonTool because the python interpreter is a bit smarter
75 // when handling quoted parts within a path
76 std::string runCommand = "\"" + sumoHome + exePath + "\"";
77
78 // iterate over all topics
79 for (const auto& topic : myNetgenerateOptions->getSubTopics()) {
80 // ignore configuration
81 if (topic != "Configuration") {
82 const std::vector<std::string> entries = myNetgenerateOptions->getSubTopicsEntries(topic);
83 for (const auto& entry : entries) {
84 if (!myNetgenerateOptions->isDefault(entry)) {
85 runCommand += " --" + entry + " " + myNetgenerateOptions->getValueString(entry);
86 }
87 }
88 }
89 }
90 return runCommand;
91}
92
93
94long
95GNERunNetgenerateDialog::onCmdBack(FXObject*, FXSelector, void*) {
96 // close run dialog and open tool dialog
98 return myApplicationWindow->handle(this, FXSEL(SEL_COMMAND, MID_GNE_NETGENERATE), nullptr);
99}
100
101
102long
103GNERunNetgenerateDialog::onCmdAccept(FXObject*, FXSelector, void*) {
104 // close run dialog and call postprocessing
106 // abort tool
108 // reset text
109 myText->setText("", 0);
110 // call postprocessing dialog
111 if (myError) {
112 return 1;
113 } else {
114 // don't run this again
115 myError = true;
116 return myApplicationWindow->handle(this, FXSEL(SEL_COMMAND, MID_GNE_POSTPROCESSINGNETGENERATE), nullptr);
117 }
118}
119
120/****************************************************************************/
@ MID_GNE_NETGENERATE
netgenerate dialog
Definition GUIAppEnum.h:761
@ MID_GNE_POSTPROCESSINGNETGENERATE
postprocesing netgenerate
Definition GUIAppEnum.h:775
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define TL(string)
Definition MsgHandler.h:305
The main window of Netedit.
GNEExternalRunner * getExternalRunner() const
get external runner
GNEApplicationWindow * myApplicationWindow
FOX needs this.
Definition GNEDialog.h:132
void openDialog(FXWindow *focusableElement=nullptr)
open dialog
long closeDialogCanceling()
close dialog declining the changes
void runTool(GNERunDialog *runDialog)
run tool called from dialog
void abort()
abort running
void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)
run internal test
bool myError
flag to check if there is an error
GNERunNetgenerateDialog(GNEApplicationWindow *applicationWindow, const OptionsCont *netgenerateOptions)
Constructor.
long onCmdAccept(FXObject *, FXSelector, void *)
event after press close button
long onCmdBack(FXObject *, FXSelector, void *)
event after press back button
std::string getRunCommand() const
get run command
const OptionsCont * myNetgenerateOptions
netgenerate options
dialog arguments, used for certain modal dialogs that can not be edited using tab
A storage for options typed value containers)
Definition OptionsCont.h:89
const std::vector< std::string > & getSubTopics() const
return the list of subtopics
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
std::string getValueString(const std::string &name) const
Returns the string-value of the named option (all options)
std::vector< std::string > getSubTopicsEntries(const std::string &subtopic) const
return the list of entries for the given subtopic