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