11
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
13
/* ***************************************************************************/
14
- // / @file GNESingleParametersDialog .cpp
14
+ // / @file GNEParametersDialog .cpp
15
15
// / @author Pablo Alvarez Lopez
16
16
// / @date Jul 2018
17
17
// /
29
29
#include < utils/gui/div/GUIDesigns.h>
30
30
#include < utils/xml/XMLSubSys.h>
31
31
32
- #include " GNESingleParametersDialog .h"
32
+ #include " GNEParametersDialog .h"
33
33
34
34
// ===========================================================================
35
35
// FOX callback mapping
36
36
// ===========================================================================
37
37
38
- FXDEFMAP (GNESingleParametersDialog) GNESingleParametersDialogMap [] = {
39
- FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_ACCEPT, GNESingleParametersDialog ::onCmdAccept),
40
- FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_CANCEL, GNESingleParametersDialog ::onCmdCancel),
41
- FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_RESET, GNESingleParametersDialog ::onCmdReset),
42
- FXMAPFUNC (SEL_CHORE, FXDialogBox::ID_CANCEL, GNESingleParametersDialog ::onCmdCancel),
43
- FXMAPFUNC (SEL_TIMEOUT, FXDialogBox::ID_CANCEL, GNESingleParametersDialog ::onCmdCancel),
44
- FXMAPFUNC (SEL_COMMAND, FXDialogBox::ID_CANCEL, GNESingleParametersDialog ::onCmdCancel),
45
- FXMAPFUNC (SEL_CLOSE, 0 , GNESingleParametersDialog ::onCmdCancel),
38
+ FXDEFMAP (GNEParametersDialog) GNEParametersDialogMap [] = {
39
+ FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_ACCEPT, GNEParametersDialog ::onCmdAccept),
40
+ FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_CANCEL, GNEParametersDialog ::onCmdCancel),
41
+ FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_RESET, GNEParametersDialog ::onCmdReset),
42
+ FXMAPFUNC (SEL_CHORE, FXDialogBox::ID_CANCEL, GNEParametersDialog ::onCmdCancel),
43
+ FXMAPFUNC (SEL_TIMEOUT, FXDialogBox::ID_CANCEL, GNEParametersDialog ::onCmdCancel),
44
+ FXMAPFUNC (SEL_COMMAND, FXDialogBox::ID_CANCEL, GNEParametersDialog ::onCmdCancel),
45
+ FXMAPFUNC (SEL_CLOSE, 0 , GNEParametersDialog ::onCmdCancel),
46
46
};
47
47
48
- FXDEFMAP (GNESingleParametersDialog ::ParametersValues) ParametersValuesMap[] = {
49
- FXMAPFUNC (SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNESingleParametersDialog ::ParametersValues::onCmdSetAttribute),
50
- FXMAPFUNC (SEL_COMMAND, MID_GNE_REMOVE_ATTRIBUTE, GNESingleParametersDialog ::ParametersValues::onCmdButtonPress),
51
- FXMAPFUNC (SEL_PAINT, 0 , GNESingleParametersDialog ::ParametersValues::onPaint),
48
+ FXDEFMAP (GNEParametersDialog ::ParametersValues) ParametersValuesMap[] = {
49
+ FXMAPFUNC (SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNEParametersDialog ::ParametersValues::onCmdSetAttribute),
50
+ FXMAPFUNC (SEL_COMMAND, MID_GNE_REMOVE_ATTRIBUTE, GNEParametersDialog ::ParametersValues::onCmdButtonPress),
51
+ FXMAPFUNC (SEL_PAINT, 0 , GNEParametersDialog ::ParametersValues::onPaint),
52
52
};
53
53
54
- FXDEFMAP (GNESingleParametersDialog ::ParametersOperations) ParametersOperationsMap[] = {
55
- FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_LOAD, GNESingleParametersDialog ::ParametersOperations::onCmdLoadParameters),
56
- FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_SAVE, GNESingleParametersDialog ::ParametersOperations::onCmdSaveParameters),
57
- FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_CLEAR, GNESingleParametersDialog ::ParametersOperations::onCmdClearParameters),
58
- FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_SORT, GNESingleParametersDialog ::ParametersOperations::onCmdSortParameters),
59
- FXMAPFUNC (SEL_COMMAND, MID_HELP, GNESingleParametersDialog ::ParametersOperations::onCmdHelpParameter),
54
+ FXDEFMAP (GNEParametersDialog ::ParametersOperations) ParametersOperationsMap[] = {
55
+ FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_LOAD, GNEParametersDialog ::ParametersOperations::onCmdLoadParameters),
56
+ FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_SAVE, GNEParametersDialog ::ParametersOperations::onCmdSaveParameters),
57
+ FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_CLEAR, GNEParametersDialog ::ParametersOperations::onCmdClearParameters),
58
+ FXMAPFUNC (SEL_COMMAND, MID_GNE_BUTTON_SORT, GNEParametersDialog ::ParametersOperations::onCmdSortParameters),
59
+ FXMAPFUNC (SEL_COMMAND, MID_HELP, GNEParametersDialog ::ParametersOperations::onCmdHelpParameter),
60
60
};
61
61
62
62
// Object implementation
63
- FXIMPLEMENT (GNESingleParametersDialog , GNEDialog, GNESingleParametersDialogMap , ARRAYNUMBER(GNESingleParametersDialogMap ))
64
- FXIMPLEMENT(GNESingleParametersDialog ::ParametersValues, FXGroupBox, ParametersValuesMap, ARRAYNUMBER(ParametersValuesMap))
65
- FXIMPLEMENT(GNESingleParametersDialog ::ParametersOperations, FXGroupBox, ParametersOperationsMap, ARRAYNUMBER(ParametersOperationsMap))
63
+ FXIMPLEMENT (GNEParametersDialog , GNEDialog, GNEParametersDialogMap , ARRAYNUMBER(GNEParametersDialogMap ))
64
+ FXIMPLEMENT(GNEParametersDialog ::ParametersValues, FXGroupBox, ParametersValuesMap, ARRAYNUMBER(ParametersValuesMap))
65
+ FXIMPLEMENT(GNEParametersDialog ::ParametersOperations, FXGroupBox, ParametersOperationsMap, ARRAYNUMBER(ParametersOperationsMap))
66
66
67
67
// ===========================================================================
68
68
// member method definitions
69
69
// ===========================================================================
70
70
71
71
// ---------------------------------------------------------------------------
72
- // GNESingleParametersDialog ::ParametersValues - methods
72
+ // GNEParametersDialog ::ParametersValues - methods
73
73
// ---------------------------------------------------------------------------
74
74
75
- GNESingleParametersDialog ::ParametersValues::ParametersValues(FXHorizontalFrame* frame, const std::string& name) :
75
+ GNEParametersDialog ::ParametersValues::ParametersValues(FXHorizontalFrame* frame, const std::string& name) :
76
76
FXGroupBox(frame, name.c_str(), GUIDesignGroupBoxFrameFill) {
77
77
// create labels for keys and values
78
78
FXHorizontalFrame* horizontalFrameLabels = new FXHorizontalFrame (this , GUIDesignAuxiliarHorizontalFrame);
@@ -85,11 +85,11 @@ GNESingleParametersDialog::ParametersValues::ParametersValues(FXHorizontalFrame*
85
85
}
86
86
87
87
88
- GNESingleParametersDialog ::ParametersValues::~ParametersValues () {}
88
+ GNEParametersDialog ::ParametersValues::~ParametersValues () {}
89
89
90
90
91
91
void
92
- GNESingleParametersDialog ::ParametersValues::setParameters (const Parameterised::Map& newParameters) {
92
+ GNEParametersDialog ::ParametersValues::setParameters (const Parameterised::Map& newParameters) {
93
93
// clear rows
94
94
clearParameters ();
95
95
// iterate over parameteres
@@ -100,7 +100,7 @@ GNESingleParametersDialog::ParametersValues::setParameters(const Parameterised::
100
100
101
101
102
102
void
103
- GNESingleParametersDialog ::ParametersValues::setParameters (const std::vector<std::pair<std::string, std::string> >& newParameters) {
103
+ GNEParametersDialog ::ParametersValues::setParameters (const std::vector<std::pair<std::string, std::string> >& newParameters) {
104
104
// clear rows
105
105
clearParameters ();
106
106
// iterate over parameteres
@@ -111,7 +111,7 @@ GNESingleParametersDialog::ParametersValues::setParameters(const std::vector<std
111
111
112
112
113
113
void
114
- GNESingleParametersDialog ::ParametersValues::addParameter (std::pair<std::string, std::string> newParameter) {
114
+ GNEParametersDialog ::ParametersValues::addParameter (std::pair<std::string, std::string> newParameter) {
115
115
// enable last row
116
116
myParameterRows.back ()->enableRow (newParameter.first , newParameter.second );
117
117
// add row
@@ -122,7 +122,7 @@ GNESingleParametersDialog::ParametersValues::addParameter(std::pair<std::string,
122
122
123
123
124
124
void
125
- GNESingleParametersDialog ::ParametersValues::clearParameters () {
125
+ GNEParametersDialog ::ParametersValues::clearParameters () {
126
126
// iterate over all rows
127
127
for (const auto & parameterRow : myParameterRows) {
128
128
delete parameterRow;
@@ -136,14 +136,14 @@ GNESingleParametersDialog::ParametersValues::clearParameters() {
136
136
}
137
137
138
138
139
- const std::vector<GNESingleParametersDialog ::ParametersValues::ParameterRow*>
140
- GNESingleParametersDialog ::ParametersValues::getParameterRows () const {
139
+ const std::vector<GNEParametersDialog ::ParametersValues::ParameterRow*>
140
+ GNEParametersDialog ::ParametersValues::getParameterRows () const {
141
141
return myParameterRows;
142
142
}
143
143
144
144
145
145
bool
146
- GNESingleParametersDialog ::ParametersValues::keyExist (const std::string& key) const {
146
+ GNEParametersDialog ::ParametersValues::keyExist (const std::string& key) const {
147
147
// just interate over myParameterRows and compare key
148
148
for (const auto & row : myParameterRows) {
149
149
if (row->keyField ->getText ().text () == key) {
@@ -155,7 +155,7 @@ GNESingleParametersDialog::ParametersValues::keyExist(const std::string& key) co
155
155
156
156
157
157
long
158
- GNESingleParametersDialog ::ParametersValues::onPaint (FXObject* o, FXSelector f, void * p) {
158
+ GNEParametersDialog ::ParametersValues::onPaint (FXObject* o, FXSelector f, void * p) {
159
159
// size of key label has to be updated in every interation
160
160
if (myParameterRows.size () > 0 ) {
161
161
myKeyLabel->setWidth (myParameterRows.front ()->keyField ->getWidth ());
@@ -165,7 +165,7 @@ GNESingleParametersDialog::ParametersValues::onPaint(FXObject* o, FXSelector f,
165
165
166
166
167
167
long
168
- GNESingleParametersDialog ::ParametersValues::onCmdSetAttribute (FXObject* obj, FXSelector, void *) {
168
+ GNEParametersDialog ::ParametersValues::onCmdSetAttribute (FXObject* obj, FXSelector, void *) {
169
169
// find what value was changed
170
170
for (int i = 0 ; i < (int )myParameterRows.size (); i++) {
171
171
if (myParameterRows.at (i)->keyField == obj) {
@@ -183,7 +183,7 @@ GNESingleParametersDialog::ParametersValues::onCmdSetAttribute(FXObject* obj, FX
183
183
184
184
185
185
long
186
- GNESingleParametersDialog ::ParametersValues::onCmdButtonPress (FXObject* obj, FXSelector, void *) {
186
+ GNEParametersDialog ::ParametersValues::onCmdButtonPress (FXObject* obj, FXSelector, void *) {
187
187
// first check if add button was pressed
188
188
if (myParameterRows.back ()->button == obj) {
189
189
// create new parameter
@@ -206,7 +206,7 @@ GNESingleParametersDialog::ParametersValues::onCmdButtonPress(FXObject* obj, FXS
206
206
}
207
207
208
208
209
- GNESingleParametersDialog ::ParametersValues::ParameterRow::ParameterRow (ParametersValues* ParametersValues, FXVerticalFrame* verticalFrameParent) {
209
+ GNEParametersDialog ::ParametersValues::ParameterRow::ParameterRow (ParametersValues* ParametersValues, FXVerticalFrame* verticalFrameParent) {
210
210
horizontalFrame = new FXHorizontalFrame (verticalFrameParent, GUIDesignAuxiliarHorizontalFrame);
211
211
keyField = new FXTextField (horizontalFrame, GUIDesignTextFieldNCol, ParametersValues, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
212
212
valueField = new FXTextField (horizontalFrame, GUIDesignTextFieldNCol, ParametersValues, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
@@ -220,14 +220,14 @@ GNESingleParametersDialog::ParametersValues::ParameterRow::ParameterRow(Paramete
220
220
}
221
221
222
222
223
- GNESingleParametersDialog ::ParametersValues::ParameterRow::~ParameterRow () {
223
+ GNEParametersDialog ::ParametersValues::ParameterRow::~ParameterRow () {
224
224
// simply delete horizontalFrame (rest of elements will be automatic deleted due they are children of horizontal frame)
225
225
delete horizontalFrame;
226
226
}
227
227
228
228
229
229
void
230
- GNESingleParametersDialog ::ParametersValues::ParameterRow::disableRow () {
230
+ GNEParametersDialog ::ParametersValues::ParameterRow::disableRow () {
231
231
// hide all
232
232
keyField->setText (" " );
233
233
keyField->disable ();
@@ -239,7 +239,7 @@ GNESingleParametersDialog::ParametersValues::ParameterRow::disableRow() {
239
239
240
240
241
241
void
242
- GNESingleParametersDialog ::ParametersValues::ParameterRow::enableRow (const std::string& parameter, const std::string& value) const {
242
+ GNEParametersDialog ::ParametersValues::ParameterRow::enableRow (const std::string& parameter, const std::string& value) const {
243
243
// restore color and enable key field
244
244
keyField->setText (parameter.c_str ());
245
245
if (parameter.empty () || SUMOXMLDefinitions::isValidParameterKey (parameter)) {
@@ -258,7 +258,7 @@ GNESingleParametersDialog::ParametersValues::ParameterRow::enableRow(const std::
258
258
259
259
260
260
void
261
- GNESingleParametersDialog ::ParametersValues::ParameterRow::toggleAddButton () {
261
+ GNEParametersDialog ::ParametersValues::ParameterRow::toggleAddButton () {
262
262
// clear and disable parameter and value fields
263
263
keyField->setText (" " );
264
264
keyField->disable ();
@@ -272,22 +272,22 @@ GNESingleParametersDialog::ParametersValues::ParameterRow::toggleAddButton() {
272
272
273
273
274
274
bool
275
- GNESingleParametersDialog ::ParametersValues::ParameterRow::isButtonInAddMode () const {
275
+ GNEParametersDialog ::ParametersValues::ParameterRow::isButtonInAddMode () const {
276
276
return (button->getIcon () == GUIIconSubSys::getIcon (GUIIcon::ADD));
277
277
}
278
278
279
279
280
280
void
281
- GNESingleParametersDialog ::ParametersValues::ParameterRow::copyValues (const ParameterRow& other) {
281
+ GNEParametersDialog ::ParametersValues::ParameterRow::copyValues (const ParameterRow& other) {
282
282
keyField->setText (other.keyField ->getText ());
283
283
valueField->setText (other.valueField ->getText ());
284
284
}
285
285
286
286
// ---------------------------------------------------------------------------
287
- // GNESingleParametersDialog ::ParametersOperations - methods
287
+ // GNEParametersDialog ::ParametersOperations - methods
288
288
// ---------------------------------------------------------------------------
289
289
290
- GNESingleParametersDialog ::ParametersOperations::ParametersOperations (FXHorizontalFrame* frame, GNESingleParametersDialog * ParameterDialogParent) :
290
+ GNEParametersDialog ::ParametersOperations::ParametersOperations (FXHorizontalFrame* frame, GNEParametersDialog * ParameterDialogParent) :
291
291
FXGroupBox(frame, " Operations" , GUIDesignGroupBoxFrame100),
292
292
myParameterDialogParent(ParameterDialogParent) {
293
293
// create buttons
@@ -299,11 +299,11 @@ GNESingleParametersDialog::ParametersOperations::ParametersOperations(FXHorizont
299
299
}
300
300
301
301
302
- GNESingleParametersDialog ::ParametersOperations::~ParametersOperations () {}
302
+ GNEParametersDialog ::ParametersOperations::~ParametersOperations () {}
303
303
304
304
305
305
long
306
- GNESingleParametersDialog ::ParametersOperations::onCmdLoadParameters (FXObject*, FXSelector, void *) {
306
+ GNEParametersDialog ::ParametersOperations::onCmdLoadParameters (FXObject*, FXSelector, void *) {
307
307
// get the Additional file name
308
308
FXFileDialog opendialog (this , TL (" Open Parameter Template" ));
309
309
opendialog.setIcon (GUIIconSubSys::getIcon (GUIIcon::GREENVEHICLE));
@@ -330,7 +330,7 @@ GNESingleParametersDialog::ParametersOperations::onCmdLoadParameters(FXObject*,
330
330
331
331
332
332
long
333
- GNESingleParametersDialog ::ParametersOperations::onCmdSaveParameters (FXObject*, FXSelector, void *) {
333
+ GNEParametersDialog ::ParametersOperations::onCmdSaveParameters (FXObject*, FXSelector, void *) {
334
334
// obtain file to save parameters
335
335
FXString file = MFXUtils::getFilename2Write (this ,
336
336
TL (" Save Parameter Template file" ),
@@ -367,15 +367,15 @@ GNESingleParametersDialog::ParametersOperations::onCmdSaveParameters(FXObject*,
367
367
368
368
369
369
long
370
- GNESingleParametersDialog ::ParametersOperations::onCmdClearParameters (FXObject*, FXSelector, void *) {
370
+ GNEParametersDialog ::ParametersOperations::onCmdClearParameters (FXObject*, FXSelector, void *) {
371
371
// simply clear parameters from ParametersValues
372
372
myParameterDialogParent->myParametersValues ->clearParameters ();
373
373
return 1 ;
374
374
}
375
375
376
376
377
377
long
378
- GNESingleParametersDialog ::ParametersOperations::onCmdSortParameters (FXObject*, FXSelector, void *) {
378
+ GNEParametersDialog ::ParametersOperations::onCmdSortParameters (FXObject*, FXSelector, void *) {
379
379
// declare two containers for parameters
380
380
std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
381
381
std::vector<std::string> emptyKeyValues;
@@ -403,7 +403,7 @@ GNESingleParametersDialog::ParametersOperations::onCmdSortParameters(FXObject*,
403
403
404
404
405
405
long
406
- GNESingleParametersDialog ::ParametersOperations::onCmdHelpParameter (FXObject*, FXSelector, void *) {
406
+ GNEParametersDialog ::ParametersOperations::onCmdHelpParameter (FXObject*, FXSelector, void *) {
407
407
// set help text
408
408
std::ostringstream help;
409
409
help
@@ -418,17 +418,17 @@ GNESingleParametersDialog::ParametersOperations::onCmdHelpParameter(FXObject*, F
418
418
}
419
419
420
420
421
- GNESingleParametersDialog ::ParametersOperations::GNEParameterHandler::GNEParameterHandler (ParametersOperations* ParametersOperationsParent, const std::string& file) :
421
+ GNEParametersDialog ::ParametersOperations::GNEParameterHandler::GNEParameterHandler (ParametersOperations* ParametersOperationsParent, const std::string& file) :
422
422
SUMOSAXHandler(file),
423
423
myParametersOperationsParent(ParametersOperationsParent) {
424
424
}
425
425
426
426
427
- GNESingleParametersDialog ::ParametersOperations::GNEParameterHandler::~GNEParameterHandler () {}
427
+ GNEParametersDialog ::ParametersOperations::GNEParameterHandler::~GNEParameterHandler () {}
428
428
429
429
430
430
void
431
- GNESingleParametersDialog ::ParametersOperations::GNEParameterHandler::myStartElement (int element, const SUMOSAXAttributes& attrs) {
431
+ GNEParametersDialog ::ParametersOperations::GNEParameterHandler::myStartElement (int element, const SUMOSAXAttributes& attrs) {
432
432
// only continue if tag is valid
433
433
if (element != SUMO_TAG_NOTHING) {
434
434
// Call parse and build depending of tag
@@ -465,10 +465,10 @@ GNESingleParametersDialog::ParametersOperations::GNEParameterHandler::myStartEle
465
465
}
466
466
467
467
// ---------------------------------------------------------------------------
468
- // GNESingleParametersDialog - methods
468
+ // GNEParametersDialog - methods
469
469
// ---------------------------------------------------------------------------
470
470
471
- GNESingleParametersDialog::GNESingleParametersDialog (GNEApplicationWindow* applicationWindow, const Parameterised::Map& parameters) :
471
+ GNEParametersDialog::GNEParametersDialog (GNEApplicationWindow* applicationWindow, const Parameterised::Map& parameters) :
472
472
GNEDialog(applicationWindow, TL(" Edit parameters" ), GUIIcon::APP_TABLE, GNEDialog::Buttons::ACCEPT_CANCEL_RESET,
473
473
OpenType::MODAL, GNEDialog::ResizeMode::RESIZABLE, 400, 300),
474
474
myOriginalParameters(parameters) {
@@ -484,17 +484,17 @@ GNESingleParametersDialog::GNESingleParametersDialog(GNEApplicationWindow* appli
484
484
openDialog ();
485
485
}
486
486
487
- GNESingleParametersDialog ::~GNESingleParametersDialog () {}
487
+ GNEParametersDialog ::~GNEParametersDialog () {}
488
488
489
489
490
490
void
491
- GNESingleParametersDialog ::runInternalTest (const InternalTestStep::DialogArgument* /* dialogArgument*/ ) {
491
+ GNEParametersDialog ::runInternalTest (const InternalTestStep::DialogArgument* /* dialogArgument*/ ) {
492
492
// nothing to do (yet)
493
493
}
494
494
495
495
496
496
std::vector<std::pair<std::string, std::string> >
497
- GNESingleParametersDialog ::getEditedParameters () const {
497
+ GNEParametersDialog ::getEditedParameters () const {
498
498
std::vector<std::pair<std::string, std::string> > parameters;
499
499
for (const auto & parameterRow : myParametersValues->getParameterRows ()) {
500
500
// ignore last row (the row with + button)
@@ -508,7 +508,7 @@ GNESingleParametersDialog::getEditedParameters() const {
508
508
509
509
510
510
long
511
- GNESingleParametersDialog ::onCmdAccept (FXObject*, FXSelector, void *) {
511
+ GNEParametersDialog ::onCmdAccept (FXObject*, FXSelector, void *) {
512
512
// declare vector for parameters in stringvector format
513
513
std::vector<std::pair<std::string, std::string> > editedParameters = getEditedParameters ();
514
514
// check keys
@@ -539,7 +539,7 @@ GNESingleParametersDialog::onCmdAccept(FXObject*, FXSelector, void*) {
539
539
540
540
541
541
long
542
- GNESingleParametersDialog ::onCmdReset (FXObject*, FXSelector, void *) {
542
+ GNEParametersDialog ::onCmdReset (FXObject*, FXSelector, void *) {
543
543
// restore original parameters
544
544
myParametersValues->setParameters (myOriginalParameters);
545
545
return 1 ;
0 commit comments