Eclipse SUMO - Simulation of Urban MObility
GNESingleParametersDialog.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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 edit parameters
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
23#include <netedit/GNEUndoList.h>
24#include <netedit/GNEViewNet.h>
27#include <utils/xml/XMLSubSys.h>
28
30
31
32// ===========================================================================
33// FOX callback mapping
34// ===========================================================================
35
36FXDEFMAP(GNESingleParametersDialog) GNESingleParametersDialogMap[] = {
40 FXMAPFUNC(SEL_CHORE, FXDialogBox::ID_CANCEL, GNESingleParametersDialog::onCmdCancel),
41 FXMAPFUNC(SEL_TIMEOUT, FXDialogBox::ID_CANCEL, GNESingleParametersDialog::onCmdCancel),
42 FXMAPFUNC(SEL_COMMAND, FXDialogBox::ID_CANCEL, GNESingleParametersDialog::onCmdCancel),
43 FXMAPFUNC(SEL_CLOSE, 0, GNESingleParametersDialog::onCmdCancel),
44};
45
50};
51
58};
59
60// Object implementation
61FXIMPLEMENT(GNESingleParametersDialog, FXDialogBox, GNESingleParametersDialogMap, ARRAYNUMBER(GNESingleParametersDialogMap))
62FXIMPLEMENT(GNESingleParametersDialog::ParametersValues, FXGroupBox, ParametersValuesMap, ARRAYNUMBER(ParametersValuesMap))
63FXIMPLEMENT(GNESingleParametersDialog::ParametersOperations, FXGroupBox, ParametersOperationsMap, ARRAYNUMBER(ParametersOperationsMap))
64
65// ===========================================================================
66// member method definitions
67// ===========================================================================
68
69// ---------------------------------------------------------------------------
70// GNESingleParametersDialog::ParametersValues - methods
71// ---------------------------------------------------------------------------
72
73GNESingleParametersDialog::ParametersValues::ParametersValues(FXHorizontalFrame* frame, const std::string& name) :
74 FXGroupBox(frame, name.c_str(), GUIDesignGroupBoxFrameFill) {
75 // create labels for keys and values
76 FXHorizontalFrame* horizontalFrameLabels = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
77 myKeyLabel = new FXLabel(horizontalFrameLabels, "key", nullptr, GUIDesignLabelThick100);
78 new FXLabel(horizontalFrameLabels, "value", nullptr, GUIDesignLabelCenterThick);
79 // create scroll windows
80 FXScrollWindow* scrollWindow = new FXScrollWindow(this, LAYOUT_FILL);
81 // create vertical frame for rows
82 myVerticalFrameRow = new FXVerticalFrame(scrollWindow, GUIDesignAuxiliarFrame);
83}
84
85
87
88
89void
90GNESingleParametersDialog::ParametersValues::setParameters(const std::vector<std::pair<std::string, std::string> >& newParameters) {
91 // clear rows
92 clearParameters();
93 // iterate over parameteres
94 for (const auto& newParameter : newParameters) {
95 addParameter(newParameter);
96 }
97}
98
99
100void
101GNESingleParametersDialog::ParametersValues::addParameter(std::pair<std::string, std::string> newParameter) {
102 // enable last row
103 myParameterRows.back()->enableRow(newParameter.first, newParameter.second);
104 // add row
105 myParameterRows.push_back(new ParameterRow(this, myVerticalFrameRow));
106 // enable add button in the last row
107 myParameterRows.back()->toggleAddButton();
108}
109
110
111void
113 // iterate over all rows
114 for (const auto& parameterRow : myParameterRows) {
115 delete parameterRow;
116 }
117 //clear myParameterRows;
118 myParameterRows.clear();
119 // add row
120 myParameterRows.push_back(new ParameterRow(this, myVerticalFrameRow));
121 // enable add button in the last row
122 myParameterRows.back()->toggleAddButton();
123}
124
125
126const std::vector<GNESingleParametersDialog::ParametersValues::ParameterRow*>
128 return myParameterRows;
129}
130
131
132bool
134 // just interate over myParameterRows and compare key
135 for (const auto& row : myParameterRows) {
136 if (row->keyField->getText().text() == key) {
137 return true;
138 }
139 }
140 return false;
141}
142
143
144long
145GNESingleParametersDialog::ParametersValues::onPaint(FXObject* o, FXSelector f, void* p) {
146 // size of key label has to be updated in every interation
147 if (myParameterRows.size() > 0) {
148 myKeyLabel->setWidth(myParameterRows.front()->keyField->getWidth());
149 }
150 return FXGroupBox::onPaint(o, f, p);
151}
152
153
154long
156 // find what value was changed
157 for (int i = 0; i < (int)myParameterRows.size(); i++) {
158 if (myParameterRows.at(i)->keyField == obj) {
159 // change color of text field depending if key is valid or empty
160 if (myParameterRows.at(i)->keyField->getText().empty() || SUMOXMLDefinitions::isValidParameterKey(myParameterRows.at(i)->keyField->getText().text())) {
161 myParameterRows.at(i)->keyField->setTextColor(FXRGB(0, 0, 0));
162 } else {
163 myParameterRows.at(i)->keyField->setTextColor(FXRGB(255, 0, 0));
164 myParameterRows.at(i)->keyField->killFocus();
165 }
166 }
167 }
168 return 1;
169}
170
171
172long
174 // first check if add button was pressed
175 if (myParameterRows.back()->button == obj) {
176 // create new parameter
177 addParameter(std::make_pair("", ""));
178 return 1;
179 } else {
180 // in other case, button press was a "remove button". Find id and remove the Parameter
181 for (int i = 0; i < (int)myParameterRows.size(); i++) {
182 if (myParameterRows.at(i)->button == obj) {
183 // delete row
184 delete myParameterRows.at(i);
185 // just remove row
186 myParameterRows.erase(myParameterRows.begin() + i);
187 return 1;
188 }
189 }
190 }
191 // Nothing to do
192 return 1;
193}
194
195
197 horizontalFrame = new FXHorizontalFrame(verticalFrameParent, GUIDesignAuxiliarHorizontalFrame);
198 keyField = new FXTextField(horizontalFrame, GUIDesignTextFieldNCol, ParametersValues, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
199 valueField = new FXTextField(horizontalFrame, GUIDesignTextFieldNCol, ParametersValues, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
201 // only create elements if vertical frame was previously created
202 if (verticalFrameParent->id()) {
203 horizontalFrame->create();
204 }
205 // by defaults rows are disabled
206 disableRow();
207}
208
209
211 // simply delete horizontalFrame (rest of elements will be automatic deleted due they are children of horizontal frame)
212 delete horizontalFrame;
213}
214
215
216void
218 // hide all
219 keyField->setText("");
220 keyField->disable();
221 valueField->setText("");
222 valueField->disable();
223 button->disable();
224 button->setIcon(GUIIconSubSys::getIcon(GUIIcon::REMOVE));
225}
226
227
228void
229GNESingleParametersDialog::ParametersValues::ParameterRow::enableRow(const std::string& parameter, const std::string& value) const {
230 // restore color and enable key field
231 keyField->setText(parameter.c_str());
232 if (parameter.empty() || SUMOXMLDefinitions::isValidParameterKey(parameter)) {
233 keyField->setTextColor(FXRGB(0, 0, 0));
234 } else {
235 keyField->setTextColor(FXRGB(255, 0, 0));
236 }
237 keyField->enable();
238 // restore color and enable value field
239 valueField->setText(value.c_str());
240 valueField->enable();
241 // enable button and set icon remove
242 button->enable();
243 button->setIcon(GUIIconSubSys::getIcon(GUIIcon::REMOVE));
244}
245
246
247void
249 // clear and disable parameter and value fields
250 keyField->setText("");
251 keyField->disable();
252 valueField->setText("");
253 valueField->disable();
254 // enable remove button and set "add" icon and focus
255 button->enable();
256 button->setIcon(GUIIconSubSys::getIcon(GUIIcon::ADD));
257 button->setFocus();
258}
259
260
261bool
263 return (button->getIcon() == GUIIconSubSys::getIcon(GUIIcon::ADD));
264}
265
266
267void
269 keyField->setText(other.keyField->getText());
270 valueField->setText(other.valueField->getText());
271}
272
273// ---------------------------------------------------------------------------
274// GNESingleParametersDialog::ParametersOperations - methods
275// ---------------------------------------------------------------------------
276
278 FXGroupBox(frame, "Operations", GUIDesignGroupBoxFrame100),
279 myParameterDialogParent(ParameterDialogParent) {
280 // create buttons
286}
287
288
290
291
292long
294 // get the Additional file name
295 FXFileDialog opendialog(this, TL("Open Parameter Template"));
297 opendialog.setSelectMode(SELECTFILE_EXISTING);
298 opendialog.setPatternList(" Parameter Template files (*.xml,*.xml.gz)\nAll files (*)");
299 if (gCurrentFolder.length() != 0) {
300 opendialog.setDirectory(gCurrentFolder);
301 }
302 if (opendialog.execute()) {
303 gCurrentFolder = opendialog.getDirectory();
304 std::string file = opendialog.getFilename().text();
305 // save current number of parameters
306 const int numberOfParametersbeforeLoad = (int)myParameterDialogParent->myParametersValues->getParameterRows().size();
307 // Create additional handler and run parser
308 GNEParameterHandler handler(this, file);
309 if (!XMLSubSys::runParser(handler, file, false)) {
310 WRITE_MESSAGE("Loading of Parameters From " + file + " failed.");
311 }
312 // show loaded attributes
313 WRITE_MESSAGE("Loaded " + toString((int)myParameterDialogParent->myParametersValues->getParameterRows().size() - numberOfParametersbeforeLoad) + " Parameters.");
314 }
315 return 1;
316}
317
318
319long
321 // obtain file to save parameters
322 FXString file = MFXUtils::getFilename2Write(this,
323 TL("Save Parameter Template file"), ".xml",
326 if (file == "") {
327 // None parameter file was selected, then stop function
328 return 1;
329 } else {
330 // open device
331 OutputDevice& device = OutputDevice::getDevice(file.text());
332 // write header
333 device.writeXMLHeader("Parameter", "parameter_file.xsd");
334 // iterate over all parameters and save it in the filename
335 for (const auto& row : myParameterDialogParent->myParametersValues->getParameterRows()) {
336 // write all except last
337 if (row != myParameterDialogParent->myParametersValues->getParameterRows().back()) {
338 // open tag
339 device.openTag(SUMO_TAG_PARAM);
340 // write key
341 device.writeAttr(SUMO_ATTR_KEY, row->keyField->getText().text());
342 // write value
343 device.writeAttr(SUMO_ATTR_VALUE, row->valueField->getText().text());
344 // close tag
345 device.closeTag();
346 }
347 }
348 // close device
349 device.close();
350 }
351 return 1;
352}
353
354
355long
357 // simply clear parameters from ParametersValues
358 myParameterDialogParent->myParametersValues->clearParameters();
359 return 1;
360}
361
362
363long
365 // declare two containers for parameters
366 std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
367 std::vector<std::string> emptyKeyValues;
368 // first extract empty values
369 for (const auto& parameterRow : myParameterDialogParent->myParametersValues->getParameterRows()) {
370 // check if key is empty
371 if (!parameterRow->keyField->getText().empty()) {
372 nonEmptyKeyValues.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
373 } else if (!parameterRow->valueField->getText().empty()) {
374 emptyKeyValues.push_back(parameterRow->valueField->getText().text());
375 }
376 }
377 // sort non-empty parameters
378 std::sort(nonEmptyKeyValues.begin(), nonEmptyKeyValues.end());
379 // sort non-empty parameters
380 std::sort(emptyKeyValues.begin(), emptyKeyValues.end());
381 // add values without key
382 for (const auto& emptyKeyValue : emptyKeyValues) {
383 nonEmptyKeyValues.push_back(std::make_pair("", emptyKeyValue));
384 }
385 // finally setparameters in myParametersValues
386 myParameterDialogParent->myParametersValues->setParameters(nonEmptyKeyValues);
387 return 1;
388}
389
390
391long
393 // Create dialog box
394 FXDialogBox* ParameterHelpDialog = new FXDialogBox(this, " Parameters Help", GUIDesignDialogBox);
395 ParameterHelpDialog->setIcon(GUIIconSubSys::getIcon(GUIIcon::APP_TABLE));
396 // set help text
397 std::ostringstream help;
398 help
399 << TL("- Parameters are defined by a Key and a Value.\n")
400 << TL("- In Netedit can be defined using format key1=parameter1|key2=parameter2|...\n")
401 << TL(" - Duplicated and empty Keys aren't valid.\n")
402 << TL(" - Whitespace and certain characters aren't allowed (@$%^&/|\\....)\n");
403 // Create label with the help text
404 new FXLabel(ParameterHelpDialog, help.str().c_str(), nullptr, GUIDesignLabelFrameInformation);
405 // Create horizontal separator
406 new FXHorizontalSeparator(ParameterHelpDialog, GUIDesignHorizontalSeparator);
407 // Create frame for OK Button
408 FXHorizontalFrame* myHorizontalFrameOKButton = new FXHorizontalFrame(ParameterHelpDialog, GUIDesignAuxiliarHorizontalFrame);
409 // Create Button Close (And two more horizontal frames to center it)
410 new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
411 new FXButton(myHorizontalFrameOKButton, TL("OK\t\tclose"), GUIIconSubSys::getIcon(GUIIcon::ACCEPT), ParameterHelpDialog, FXDialogBox::ID_ACCEPT, GUIDesignButtonOK);
412 new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
413 // Write Warning in console if we're in testing mode
414 WRITE_DEBUG("Opening Parameter help dialog");
415 // create Dialog
416 ParameterHelpDialog->create();
417 // show in the given position
418 ParameterHelpDialog->show(PLACEMENT_CURSOR);
419 // refresh APP
420 getApp()->refresh();
421 // open as modal dialog (will block all windows until stop() or stopModal() is called)
422 getApp()->runModalFor(ParameterHelpDialog);
423 // Write Warning in console if we're in testing mode
424 WRITE_DEBUG("Closing Parameter help dialog");
425 return 1;
426}
427
428
430 SUMOSAXHandler(file),
431 myParametersOperationsParent(ParametersOperationsParent) {
432}
433
434
436
437
438void
440 // only continue if tag is valid
441 if (element != SUMO_TAG_NOTHING) {
442 // Call parse and build depending of tag
443 switch (element) {
444 case SUMO_TAG_PARAM:
445 // Check that format of Parameter is correct
446 if (!attrs.hasAttribute(SUMO_ATTR_KEY)) {
447 WRITE_WARNING(TL("Key of Parameter not defined"));
448 } else if (!attrs.hasAttribute(SUMO_ATTR_VALUE)) {
449 WRITE_WARNING(TL("Value of Parameter not defined"));
450 } else {
451 // obtain Key and value
452 std::string key = attrs.getString(SUMO_ATTR_KEY);
453 std::string value = attrs.getString(SUMO_ATTR_VALUE);
454 // check that parsed values are correct
456 if (key.size() == 0) {
457 WRITE_WARNING(TL("Key of Parameter cannot be empty"));
458 } else {
459 WRITE_WARNING("Key '" + key + "' of Parameter contains invalid characters");
460 }
461 } else if (myParametersOperationsParent->myParameterDialogParent->myParametersValues->keyExist(key)) {
462 WRITE_WARNING("Key '" + key + "' already exist");
463 } else {
464 // add parameter to vector of myParameterDialogParent
465 myParametersOperationsParent->myParameterDialogParent->myParametersValues->addParameter(std::make_pair(key, value));
466 }
467 }
468 break;
469 default:
470 break;
471 }
472 }
473}
474
475// ---------------------------------------------------------------------------
476// GNESingleParametersDialog - methods
477// ---------------------------------------------------------------------------
478
480 FXDialogBox(genericDataAttributes->getFrameParent()->getViewNet()->getApp(), "Edit attributes", GUIDesignDialogBoxExplicitStretchable(400, 300)),
481 myGenericDataAttributes(genericDataAttributes),
482 myParametersEditor(nullptr),
483 VTypeAttributeRow(nullptr),
484 myAttributeCarrier(nullptr),
485 myTLDef(nullptr) {
486 // call auxiliar constructor for elements
487 constructor("Attributes");
488 // fill myParametersValues
489 myParametersValues->setParameters(genericDataAttributes->getParameters());
490}
491
492
494 FXDialogBox(parametersEditor->getInspectorFrameParent()->getViewNet()->getApp(), "Edit parameters", GUIDesignDialogBoxExplicitStretchable(400, 300)),
495 myGenericDataAttributes(nullptr),
496 myParametersEditor(parametersEditor),
497 VTypeAttributeRow(nullptr),
498 myAttributeCarrier(nullptr),
499 myTLDef(nullptr) {
500 // call auxiliar constructor
501 constructor("Parameters");
502 // get AC Front
503 const GNEAttributeCarrier* AC = parametersEditor->getInspectorFrameParent()->getViewNet()->getInspectedAttributeCarriers().front();
504 // fill myParametersValues
505 myParametersValues->setParameters(AC->getACParameters<std::vector<std::pair<std::string, std::string> > >());
506}
507
508
509
511 FXDialogBox(viewNet->getApp(), "Edit parameters", GUIDesignDialogBoxExplicitStretchable(400, 300)),
512 myGenericDataAttributes(nullptr),
513 myParametersEditor(nullptr),
514 VTypeAttributeRow(VTypeAttributeRow),
515 myAttributeCarrier(nullptr),
516 myTLDef(nullptr) {
517 // call auxiliar constructor
518 constructor("Parameters");
519 // fill myEditedParameters
521}
522
523
525 FXDialogBox(attributeCarrier->getNet()->getViewNet()->getApp(), "Edit parameters", GUIDesignDialogBoxExplicitStretchable(400, 300)),
526 myGenericDataAttributes(nullptr),
527 myParametersEditor(nullptr),
528 VTypeAttributeRow(nullptr),
529 myAttributeCarrier(attributeCarrier),
530 myTLDef(nullptr) {
531 // call auxiliar constructor
532 constructor("Parameters");
533 // fill myEditedParameters
534 myParametersValues->setParameters(myAttributeCarrier->getACParameters<std::vector<std::pair<std::string, std::string> > >());
535}
536
537
539 FXDialogBox(app, "Edit parameters", GUIDesignDialogBoxExplicitStretchable(400, 300)),
540 myGenericDataAttributes(nullptr),
541 myParametersEditor(nullptr),
542 VTypeAttributeRow(nullptr),
543 myAttributeCarrier(nullptr),
544 myTLDef(TLDef) {
545 // call auxiliar constructor
546 constructor("Parameters");
547 // transform parameters to a=b|c=d... format
548 std::vector<std::pair<std::string, std::string> > parametersStr;
549 // Generate a vector string using the following structure: "<key1,value1>, <key2, value2>,...
550 for (const auto& parameter : TLDef->getParametersMap()) {
551 parametersStr.push_back(std::make_pair(parameter.first, parameter.second));
552 }
553 // set parameters
554 myParametersValues->setParameters(parametersStr);
555}
556
557
559
560
561long
562GNESingleParametersDialog::onCmdAccept(FXObject*, FXSelector, void*) {
563 // declare vector for parameters in stringvector format
564 std::vector<std::pair<std::string, std::string> > parameters;
565 // check if all edited parameters are valid
566 for (const auto& parameterRow : myParametersValues->getParameterRows()) {
567 // ignore last row
568 if (parameterRow != myParametersValues->getParameterRows().back()) {
569 if (parameterRow->keyField->getText().empty()) {
570 // write warning if netedit is running in testing mode
571 WRITE_DEBUG("Opening FXMessageBox of type 'warning'");
572 // open warning Box
573 FXMessageBox::warning(getApp(), MBOX_OK, "Empty Parameter key", "%s", "Parameters with empty keys aren't allowed");
574 // write warning if netedit is running in testing mode
575 WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
576 return 1;
577 } else if (!SUMOXMLDefinitions::isValidParameterKey(parameterRow->keyField->getText().text())) {
578 // write warning if netedit is running in testing mode
579 WRITE_DEBUG("Opening FXMessageBox of type 'warning'");
580 // open warning Box
581 FXMessageBox::warning(getApp(), MBOX_OK, "Invalid Parameter key", "%s", "There are keys with invalid characters");
582 // write warning if netedit is running in testing mode
583 WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
584 return 1;
585 }
586 // insert in parameters
587 parameters.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
588 }
589 }
590 // sort sortedParameters
591 std::sort(parameters.begin(), parameters.end());
592 // check if there is duplicated keys
593 for (auto i = parameters.begin(); i != parameters.end(); i++) {
594 if (((i + 1) != parameters.end()) && (i->first) == (i + 1)->first) {
595 // write warning if netedit is running in testing mode
596 WRITE_DEBUG("Opening FXMessageBox of type 'warning'");
597 // open warning Box
598 FXMessageBox::warning(getApp(), MBOX_OK, "Duplicated Parameters", "%s", "Parameters with the same Key aren't allowed");
599 // write warning if netedit is running in testing mode
600 WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
601 return 1;
602 }
603 }
604 // set parameters in Parameters editor parents
606 // set parameter in editor creator
608 } else if (myParametersEditor) {
609 // get inspected AC
611 // set parameter in AC using undoList
615 } else if (VTypeAttributeRow) {
616 // set parameter in VTypeAttributeRow
617 VTypeAttributeRow->setParameters(parameters);
618 } else if (myAttributeCarrier) {
619 // set parameter in AC using undoList
623 } else if (myTLDef) {
624 // declare parametersMap
625 Parameterised::Map parametersMap;
626 // Generate an string using the following structure: "key1=value1|key2=value2|...
627 for (const auto& parameter : parameters) {
628 parametersMap[parameter.first] = parameter.second;
629 }
630 // set setACParameters map
631 myTLDef->setParametersMap(parametersMap);
632 }
633 // all ok, then close dialog
634 getApp()->stopModal(this, TRUE);
635 return 1;
636}
637
638
639long
640GNESingleParametersDialog::onCmdCancel(FXObject*, FXSelector, void*) {
641 // Stop Modal
642 getApp()->stopModal(this, FALSE);
643 return 1;
644}
645
646
647long
648GNESingleParametersDialog::onCmdReset(FXObject*, FXSelector, void*) {
649 // restore original parameters
652 } else if (myParametersEditor) {
654 myParametersValues->setParameters(AC->getACParameters<std::vector<std::pair<std::string, std::string> > >());
655 } else if (VTypeAttributeRow) {
657 } else if (myAttributeCarrier) {
658 myParametersValues->setParameters(myAttributeCarrier->getACParameters<std::vector<std::pair<std::string, std::string> > >());
659 } else if (myTLDef) {
660 // transform parameters to a=b|c=d... format
661 std::vector<std::pair<std::string, std::string> > parametersStr;
662 // Generate a vector string using the following structure: "<key1,value1>, <key2, value2>,...
663 for (const auto& parameter : myTLDef->getParametersMap()) {
664 parametersStr.push_back(std::make_pair(parameter.first, parameter.second));
665 }
666 // set parameters
667 myParametersValues->setParameters(parametersStr);
668 }
669 return 1;
670}
671
672
673void
675 // set vehicle icon for this dialog
677 // create main frame
678 FXVerticalFrame* mainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
679 // create frame for Parameters and operations
680 FXHorizontalFrame* horizontalFrameExtras = new FXHorizontalFrame(mainFrame, GUIDesignAuxiliarFrame);
681 // create parameters values
682 myParametersValues = new ParametersValues(horizontalFrameExtras, name);
683 // create parameters operations
684 myParametersOperations = new ParametersOperations(horizontalFrameExtras, this);
685 // add separator
686 new FXHorizontalSeparator(mainFrame, GUIDesignHorizontalSeparator);
687 // create dialog buttons bot centered
688 FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(mainFrame, GUIDesignHorizontalFrame);
689 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
690 myAcceptButton = new FXButton(buttonsFrame, TL("accept\t\tclose"), GUIIconSubSys::getIcon(GUIIcon::ACCEPT), this, MID_GNE_BUTTON_ACCEPT, GUIDesignButtonAccept);
691 myCancelButton = new FXButton(buttonsFrame, TL("cancel\t\tclose"), GUIIconSubSys::getIcon(GUIIcon::CANCEL), this, MID_GNE_BUTTON_CANCEL, GUIDesignButtonCancel);
692 myResetButton = new FXButton(buttonsFrame, "reset\t\tclose", GUIIconSubSys::getIcon(GUIIcon::RESET), this, MID_GNE_BUTTON_RESET, GUIDesignButtonReset);
693 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
694}
695
696/****************************************************************************/
FXDEFMAP(GNESingleParametersDialog) GNESingleParametersDialogMap[]
@ MID_GNE_SET_ATTRIBUTE
attribute edited
Definition: GUIAppEnum.h:870
@ MID_GNE_REMOVE_ATTRIBUTE
attribute removed
Definition: GUIAppEnum.h:868
@ MID_GNE_BUTTON_CANCEL
cancel button
Definition: GUIAppEnum.h:1296
@ MID_GNE_BUTTON_RESET
reset button
Definition: GUIAppEnum.h:1298
@ MID_GNE_BUTTON_SAVE
save button
Definition: GUIAppEnum.h:1302
@ MID_GNE_BUTTON_SORT
sort button
Definition: GUIAppEnum.h:1306
@ MID_HELP
help button
Definition: GUIAppEnum.h:641
@ MID_GNE_BUTTON_LOAD
load button
Definition: GUIAppEnum.h:1300
@ MID_GNE_BUTTON_CLEAR
clear button
Definition: GUIAppEnum.h:1304
@ MID_GNE_BUTTON_ACCEPT
accept button
Definition: GUIAppEnum.h:1294
#define GUIDesignGroupBoxFrame100
Group box design for elements of width 100.
Definition: GUIDesigns.h:356
#define GUIDesignButtonIcon
button only with icon
Definition: GUIDesigns.h:86
#define GUIDesignButtonAccept
Accept Button.
Definition: GUIDesigns.h:145
#define GUIDesignButtonCancel
Cancel Button.
Definition: GUIDesigns.h:148
#define GUIDesignTextField
Definition: GUIDesigns.h:48
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:397
#define GUIDesignDialogBox
Definition: GUIDesigns.h:584
#define GUIDesignButtonRectangular100
button rectangular with thick and raise frame with a width of 100
Definition: GUIDesigns.h:92
#define GUIDesignTextFieldNCol
Num of column of text field.
Definition: GUIDesigns.h:69
#define GUIDesignButtonOK
Definition: GUIDesigns.h:142
#define GUIDesignLabelCenterThick
label extended over frame with thick and with text justify to center
Definition: GUIDesigns.h:235
#define GUIDesignGroupBoxFrameFill
Group box design extended over frame (X and Y)
Definition: GUIDesigns.h:353
#define GUIDesignButtonReset
Reset Button.
Definition: GUIDesigns.h:151
#define GUIDesignLabelThick100
label with thick, text justify to left and width of 100
Definition: GUIDesigns.h:277
#define GUIDesignHorizontalSeparator
Definition: GUIDesigns.h:452
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frames used to pack another frames extended in all directions
Definition: GUIDesigns.h:394
#define GUIDesignHorizontalFrame
Horizontal frame extended over frame parent.
Definition: GUIDesigns.h:335
#define GUIDesignDialogBoxExplicitStretchable(width, height)
design for dialog box with specift width and height that can be stretched (But not shrinked)
Definition: GUIDesigns.h:599
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:271
FXString gCurrentFolder
The folder used as last.
@ CLEANJUNCTIONS
@ GREENVEHICLE
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:276
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:267
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:265
#define TL(string)
Definition: MsgHandler.h:282
@ SUMO_TAG_NOTHING
invalid tag
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_KEY
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
void setACParameters(const std::string &parameters, GNEUndoList *undoList)
set parameters (string)
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * getNet() const
get pointer to net
T getACParameters() const
get parameters
std::vector< std::pair< std::string, std::string > > getParameters() const
get parameters as vector of strings
void setParameters(const std::vector< std::pair< std::string, std::string > > &parameters)
set parameters
GNEViewNet * getViewNet() const
get view net
Definition: GNEFrame.cpp:150
GNEInspectorFrame * getInspectorFrameParent() const
get inspector frame parent
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1987
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
GNEParameterHandler(ParametersOperations *ParametersOperationsParent, const std::string &file)
Constructor.
ParametersOperations(FXHorizontalFrame *frame, GNESingleParametersDialog *ParameterDialogParent)
FOX-declaration.
long onCmdSaveParameters(FXObject *, FXSelector, void *)
event when user press save parameters button
long onCmdClearParameters(FXObject *, FXSelector, void *)
event when user press clear parameters button
long onCmdLoadParameters(FXObject *, FXSelector, void *)
long onCmdSortParameters(FXObject *, FXSelector, void *)
event when user press sort parameters button
long onCmdHelpParameter(FXObject *, FXSelector, void *)
event when user press help parameters button
bool isButtonInAddMode() const
check if remove button is in mode "add"
ParameterRow(ParametersValues *ParametersValues, FXVerticalFrame *verticalFrameParent)
constructor
void copyValues(const ParameterRow &other)
copy values of other parameter Row
void enableRow(const std::string &parameter, const std::string &value) const
enable row
long onPaint(FXObject *o, FXSelector f, void *p)
long onCmdSetAttribute(FXObject *, FXSelector, void *)
event when user change an attribute
const std::vector< ParameterRow * > getParameterRows() const
get vector with the ParameterRows
void setParameters(const std::vector< std::pair< std::string, std::string > > &newParameters)
set parameters
bool keyExist(const std::string &key) const
check if given key exist already
long onCmdButtonPress(FXObject *, FXSelector, void *)
event when user press a remove (or add) button
void addParameter(std::pair< std::string, std::string > newParameter)
add a single parameter
Dialog for edit parameters.
FXButton * myResetButton
cancel button
ParametersValues * myParametersValues
pointer to parameters values
long onCmdCancel(FXObject *, FXSelector, void *)
event after press cancel button
long onCmdReset(FXObject *, FXSelector, void *)
event after press reset button
GNEVehicleTypeDialog::VTypeAtributes::VTypeAttributeRow * VTypeAttributeRow
pointer to VTypeAttributeRow
FXButton * myAcceptButton
accept button
FXButton * myCancelButton
cancel button
void constructor(const std::string &name)
auxiliar constructor
ParametersOperations * myParametersOperations
pointer to parameters operations
GNEAttributeCarrier * myAttributeCarrier
pointer to GNEAttributeCarrier
NBLoadedSUMOTLDef * myTLDef
pointer to TLDef
GNESingleParametersDialog(GNEFrameAttributeModules::GenericDataAttributes *genericDataAttributes)
Constructor for generic data attributes.
GNEInspectorFrame::ParametersEditor * myParametersEditor
pointer to ParametersEditor
GNEFrameAttributeModules::GenericDataAttributes * myGenericDataAttributes
FOX need this.
long onCmdAccept(FXObject *, FXSelector, void *)
GUIIcon getGUIIcon() const
get GUI icon associated to this Tag
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
class used for represent rows with Vehicle Type parameters
void setParameters(const std::vector< std::pair< std::string, std::string > > &parameters)
set parameters
std::vector< std::pair< std::string, std::string > > getParametersVectorStr() const
get parameters as vector of strings
GNEUndoList * getUndoList() const
get the undoList object
const std::vector< GNEAttributeCarrier * > & getInspectedAttributeCarriers() const
get inspected attribute carriers
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString &currentFolder)
Returns the file name to write.
Definition: MFXUtils.cpp:82
A loaded (complete) traffic light logic.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:251
void close()
Closes the device and removes it from the dictionary.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >(), bool includeConfig=true)
Writes an XML header with optional configuration.
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
void setParametersMap(const Parameterised::Map &paramsMap)
set the inner key/value map in map<string, string> format
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
SAX-handler base for SUMO-files.
static bool isValidParameterKey(const std::string &value)
whether the given string is a valid key for a parameter
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false)
Runs the given handler on the given file; returns if everything's ok.
Definition: XMLSubSys.cpp:137
Definition: json.hpp:4471