Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/dialogs/options/GNEOptionsEditorRow.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 GNEOptionsEditorRow.h
15
/// @author Pablo Alvarez Lopez
16
/// @date May 2023
17
///
18
// Row used in GNEOptionsEditor to edit options
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <string>
24
#include <utils/foxtools/fxheader.h>
25
26
// ===========================================================================
27
// class declaration
28
// ===========================================================================
29
30
class GNEOptionsEditor;
31
class MFXLabelTooltip;
32
33
// ===========================================================================
34
// class definitions
35
// ===========================================================================
36
37
class GNEOptionsEditorRow {
38
39
public:
40
41
/// @brief input option
42
class OptionRow : public FXHorizontalFrame {
43
/// @brief FOX-declaration
44
FXDECLARE_ABSTRACT(GNEOptionsEditorRow::OptionRow)
45
46
public:
47
/// @brief constructor
48
OptionRow(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
49
const std::string& name, const std::string& description, const std::string& defaultValue);
50
51
/// @brief adjust input name size
52
void adjustNameSize();
53
54
/// @brief get topic
55
const std::string& getTopic() const;
56
57
/// @brief get name (Lower)
58
const std::string getNameLower() const;
59
60
/// @brief get description (Lower)
61
const std::string getDescriptionLower() const;
62
63
/// @brief update option (used after load options)
64
virtual void updateOption() = 0;
65
66
/// @brief restore option (used for setting original options)
67
virtual void restoreOption() = 0;
68
69
/// @brief called when user set value in textField/button/checkBox
70
virtual long onCmdSetOption(FXObject*, FXSelector, void*) = 0;
71
72
/// @brief called when user press reset button
73
virtual long onCmdResetOption(FXObject*, FXSelector, void*) = 0;
74
75
protected:
76
/// @brief FOX needs this
77
FOX_CONSTRUCTOR(OptionRow)
78
79
/// @brief GNEOptionsEditor parent
80
GNEOptionsEditor* myOptionsEditor = nullptr;
81
82
/// @brief topic
83
const std::string myTopic;
84
85
/// @brief name
86
const std::string myName;
87
88
/// @brief description
89
const std::string myDescription;
90
91
/// @brief default value
92
const std::string myDefaultValue;
93
94
/// @brief content frame
95
FXHorizontalFrame* myContentFrame = nullptr;
96
97
/// @brief update reset button
98
void updateResetButton();
99
100
private:
101
/// @brief get value
102
virtual std::string getValue() const = 0;
103
104
/// @brief tooltip label for name
105
MFXLabelTooltip* myNameLabel = nullptr;
106
107
// @brief reset button
108
FXButton* myResetButton = nullptr;
109
};
110
111
/// @brief input string
112
class OptionString : public OptionRow {
113
114
public:
115
/// @brief constructor
116
OptionString(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
117
const std::string& name, const std::string& description, const std::string& defaultValue);
118
119
/// @brief update option
120
void updateOption();
121
122
/// @brief restore option
123
void restoreOption();
124
125
/// @brief called when user set value in textField/button/checkBox
126
long onCmdSetOption(FXObject*, FXSelector, void*);
127
128
/// @brief called when user press reset button
129
long onCmdResetOption(FXObject*, FXSelector, void*);
130
131
private:
132
/// @brief get value
133
std::string getValue() const;
134
135
/// @brief text field
136
FXTextField* myStringTextField = nullptr;
137
};
138
139
/// @brief input string vector
140
class OptionStringVector : public OptionRow {
141
142
public:
143
/// @brief constructor
144
OptionStringVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
145
const std::string& name, const std::string& description, const std::string& defaultValue);
146
147
/// @brief update option
148
void updateOption();
149
150
/// @brief restore option
151
void restoreOption();
152
153
/// @brief called when user set value in textField/button/checkBox
154
long onCmdSetOption(FXObject*, FXSelector, void*);
155
156
/// @brief called when user press reset button
157
long onCmdResetOption(FXObject*, FXSelector, void*);
158
159
private:
160
/// @brief get value
161
std::string getValue() const;
162
163
/// @brief text field
164
FXTextField* myStringVectorTextField = nullptr;
165
};
166
167
/// @brief input bool
168
class OptionBool : public OptionRow {
169
170
public:
171
/// @brief constructor
172
OptionBool(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
173
const std::string& name, const std::string& description, const std::string& defaultValue);
174
175
/// @brief update option
176
void updateOption();
177
178
/// @brief restore option
179
void restoreOption();
180
181
/// @brief called when user set value in textField/button/checkBox
182
long onCmdSetOption(FXObject*, FXSelector, void*);
183
184
/// @brief called when user press reset button
185
long onCmdResetOption(FXObject*, FXSelector, void*);
186
187
private:
188
/// @brief get value
189
std::string getValue() const;
190
191
/// @brief menu check
192
FXCheckButton* myCheckButton = nullptr;
193
};
194
195
/// @brief input int
196
class OptionInt : public OptionRow {
197
198
public:
199
/// @brief
200
OptionInt(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
201
const std::string& name, const std::string& description, const std::string& defaultValue);
202
203
/// @brief update option
204
void updateOption();
205
206
/// @brief restore option
207
void restoreOption();
208
209
/// @brief called when user set value in textField/button/checkBox
210
long onCmdSetOption(FXObject*, FXSelector, void*);
211
212
/// @brief called when user press reset button
213
long onCmdResetOption(FXObject*, FXSelector, void*);
214
215
private:
216
/// @brief get value
217
std::string getValue() const;
218
219
/// @brief text field
220
FXTextField* myIntTextField = nullptr;
221
};
222
223
/// @brief input int vector
224
class OptionIntVector : public OptionRow {
225
226
public:
227
/// @brief
228
OptionIntVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
229
const std::string& name, const std::string& description, const std::string& defaultValue);
230
231
/// @brief update option
232
void updateOption();
233
234
/// @brief restore option
235
void restoreOption();
236
237
/// @brief called when user set value in textField/button/checkBox
238
long onCmdSetOption(FXObject*, FXSelector, void*);
239
240
/// @brief called when user press reset button
241
long onCmdResetOption(FXObject*, FXSelector, void*);
242
243
private:
244
/// @brief get value
245
std::string getValue() const;
246
247
/// @brief text field
248
FXTextField* myIntVectorTextField = nullptr;
249
};
250
251
/// @brief input float
252
class OptionFloat : public OptionRow {
253
254
public:
255
/// @brief constructor
256
OptionFloat(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
257
const std::string& name, const std::string& description, const std::string& defaultValue);
258
259
/// @brief update option
260
void updateOption();
261
262
/// @brief restore option
263
void restoreOption();
264
265
/// @brief called when user set value in textField/button/checkBox
266
long onCmdSetOption(FXObject*, FXSelector, void*);
267
268
/// @brief called when user press reset button
269
long onCmdResetOption(FXObject*, FXSelector, void*);
270
271
private:
272
/// @brief get value
273
std::string getValue() const;
274
275
/// @brief parse float xx to xx.00
276
std::string parseFloat(const std::string& value) const;
277
278
/// @brief text field
279
FXTextField* myFloatTextField = nullptr;
280
};
281
282
/// @brief input float
283
class OptionTime : public OptionRow {
284
285
public:
286
/// @brief constructor
287
OptionTime(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
288
const std::string& name, const std::string& description, const std::string& defaultValue);
289
290
/// @brief update option
291
void updateOption();
292
293
/// @brief restore option
294
void restoreOption();
295
296
/// @brief called when user set value in textField/button/checkBox
297
long onCmdSetOption(FXObject*, FXSelector, void*);
298
299
/// @brief called when user press reset button
300
long onCmdResetOption(FXObject*, FXSelector, void*);
301
302
private:
303
/// @brief get value
304
std::string getValue() const;
305
306
/// @brief parse float xx to xx.00
307
std::string parseTime(const std::string& value) const;
308
309
/// @brief text field
310
FXTextField* myTimeTextField = nullptr;
311
};
312
313
/// @brief input filename
314
class OptionFilename : public OptionRow {
315
/// @brief FOX-declaration
316
FXDECLARE(GNEOptionsEditorRow::OptionFilename)
317
318
public:
319
/// @brief constructor
320
OptionFilename(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
321
const std::string& name, const std::string& description, const std::string& defaultValue);
322
323
/// @brief update option
324
void updateOption();
325
326
/// @brief restore option
327
void restoreOption();
328
329
/// @brief called when user press open dialog button
330
long onCmdOpenDialog(FXObject*, FXSelector, void*);
331
332
/// @brief called when user set value in textField/button/checkBox
333
long onCmdSetOption(FXObject*, FXSelector, void*);
334
335
/// @brief called when user press reset button
336
long onCmdResetOption(FXObject*, FXSelector, void*);
337
338
protected:
339
/// @brief FOX needs this
340
OptionFilename();
341
342
private:
343
/// @brief get value
344
std::string getValue() const;
345
346
/// @brief open filename button
347
FXButton* myOpenFilenameButton = nullptr;
348
349
/// @brief text field
350
FXTextField* myFilenameTextField = nullptr;
351
};
352
};
353
354