Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/dialogs/tools/GNEPythonToolDialog.h
169684 views
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
/****************************************************************************/
14
/// @file GNEPythonToolDialog.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Jun 2022
17
///
18
// Dialog for tools
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <netedit/dialogs/GNEDialog.h>
24
#include <utils/options/OptionsCont.h>
25
26
#include "GNEPythonToolDialogElements.h"
27
28
// ===========================================================================
29
// class declarations
30
// ===========================================================================
31
32
class GNEPythonTool;
33
class MFXCheckableButton;
34
35
// ===========================================================================
36
// class definitions
37
// ===========================================================================
38
39
class GNEPythonToolDialog : protected GNEDialog {
40
/// @brief FOX-declaration
41
FXDECLARE(GNEPythonToolDialog)
42
43
/// @brief declare friend class
44
friend class GNEPythonToolDialogElements;
45
46
public:
47
/// @brief Constructor
48
GNEPythonToolDialog(GNEApplicationWindow* applicationWindow, GNEPythonTool* tool);
49
50
/// @brief destructor
51
~GNEPythonToolDialog();
52
53
/// @brief run internal test
54
void runInternalTest(const InternalTestStep::DialogArgument* dialogArgument);
55
56
/// @brief get python tool
57
const GNEPythonTool* getPythonTool() const;
58
59
/// @name FOX-callbacks
60
/// @{
61
62
/// @brief enable/disable show toolTip
63
long onCmdShowToolTipsMenu(FXObject*, FXSelector, void*);
64
65
/// @brief save options
66
long onCmdSave(FXObject*, FXSelector, void*);
67
68
/// @brief load options
69
long onCmdLoad(FXObject*, FXSelector, void*);
70
71
/// @brief set visualization (sorting and grouping)
72
long onCmdSetVisualization(FXObject*, FXSelector, void*);
73
74
/// @brief event after press run button
75
long onCmdRun(FXObject*, FXSelector, void*);
76
77
/// @brief event after press reset button
78
long onCmdReset(FXObject*, FXSelector, void*);
79
80
/// @brief event for check if required attributes was set
81
long onUpdRequiredAttributes(FXObject* sender, FXSelector, void*);
82
83
/// @}
84
85
protected:
86
/// @brief internal class used for sorting options by categories
87
class CategoryOptions : public std::string {
88
89
public:
90
/// @brief constructor
91
CategoryOptions(const std::string& category);
92
93
/// @brief add option
94
void addOption(const std::string& name, Option* option);
95
96
/// @brief get options
97
const std::vector<std::pair<std::string, Option*> >& getOptions() const;
98
99
/// @brief sort options by name
100
void sortByName();
101
102
private:
103
/// @brief options for this category
104
std::vector<std::pair<std::string, Option*> > myOptions;
105
106
/// @brief default constructor
107
CategoryOptions() {}
108
};
109
110
/// @brief FOX needs this
111
FOX_CONSTRUCTOR(GNEPythonToolDialog);
112
113
/// @brief build arguments
114
void buildArguments(bool sortByName, bool groupedByCategories);
115
116
/// @brief adjust parameter column
117
void adjustParameterColumn();
118
119
/// @brief custom tools options
120
OptionsCont myCustomToolsOptions;
121
122
/// @brief get options
123
std::vector<GNEPythonToolDialog::CategoryOptions> getOptions(OptionsCont& optionsCont) const;
124
125
/// @brief get options sorted by category
126
std::vector<CategoryOptions> getOptionsByCategories(OptionsCont& optionsCont) const;
127
128
/// @brief get number of row colums
129
int getNumRowColums() const;
130
131
/// @brief get argument frame left
132
FXVerticalFrame* getArgumentFrameLeft() const;
133
134
/// @brief get argument frame right
135
FXVerticalFrame* getArgumentFrameRight() const;
136
137
/// @brief list of arguments sorted by categories
138
std::vector<GNEPythonToolDialogElements::Argument*> myArguments;
139
140
/// @brief list of categories
141
std::vector<GNEPythonToolDialogElements::Category*> myCategories;
142
143
private:
144
/// @brief menu for tooltips menu
145
MFXCheckableButton* myShowToolTipsMenu = nullptr;
146
147
/// @brief check button to enable/diasble sorting
148
FXCheckButton* mySortedCheckButton = nullptr;
149
150
/// @brief check button to enable/diasble grouping
151
FXCheckButton* myGroupedCheckButton = nullptr;
152
153
/// @brief argument frame left
154
FXVerticalFrame* myArgumentFrameLeft = nullptr;
155
156
/// @brief argument frame right
157
FXVerticalFrame* myArgumentFrameRight = nullptr;
158
159
/// @brief python tool
160
GNEPythonTool* myPythonTool = nullptr;
161
162
/// @brief Invalidated copy constructor.
163
GNEPythonToolDialog(const GNEPythonToolDialog&) = delete;
164
165
/// @brief Invalidated assignment operator.
166
GNEPythonToolDialog& operator=(const GNEPythonToolDialog&) = delete;
167
};
168
169