Eclipse SUMO - Simulation of Urban MObility
GNEMultipleParametersDialog.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-2020 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 multiple parameters
19 /****************************************************************************/
20 #include <config.h>
21 
24 #include <utils/xml/XMLSubSys.h>
25 #include <netedit/GNEViewNet.h>
26 #include <netedit/GNEUndoList.h>
28 
30 
31 
32 // ===========================================================================
33 // FOX callback mapping
34 // ===========================================================================
35 
36 FXDEFMAP(GNEMultipleParametersDialog) GNEMultipleParametersDialogMap[] = {
40  FXMAPFUNC(SEL_CHORE, FXDialogBox::ID_CANCEL, GNEMultipleParametersDialog::onCmdCancel),
41  FXMAPFUNC(SEL_TIMEOUT, FXDialogBox::ID_CANCEL, GNEMultipleParametersDialog::onCmdCancel),
42  FXMAPFUNC(SEL_COMMAND, FXDialogBox::ID_CANCEL, GNEMultipleParametersDialog::onCmdCancel),
43  FXMAPFUNC(SEL_CLOSE, 0, GNEMultipleParametersDialog::onCmdCancel),
44 };
45 
50 };
51 
58 };
59 
60 // Object implementation
61 FXIMPLEMENT(GNEMultipleParametersDialog, FXDialogBox, GNEMultipleParametersDialogMap, ARRAYNUMBER(GNEMultipleParametersDialogMap))
62 FXIMPLEMENT(GNEMultipleParametersDialog::ParametersValues, FXGroupBox, ParametersValuesMap, ARRAYNUMBER(ParametersValuesMap))
63 FXIMPLEMENT(GNEMultipleParametersDialog::ParametersOperations, FXGroupBox, ParametersOperationsMap, ARRAYNUMBER(ParametersOperationsMap))
64 
65 // ===========================================================================
66 // member method definitions
67 // ===========================================================================
68 
69 // ---------------------------------------------------------------------------
70 // GNEMultipleParametersDialog::ParametersValues - methods
71 // ---------------------------------------------------------------------------
72 
74  FXGroupBox(frame, "Parameters", GUIDesignGroupBoxFrameFill),
75  myParameterDialogParent(parameterDialogParent) {
76  // create labels for keys and values
77  FXHorizontalFrame* horizontalFrameLabels = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
78  myKeyLabel = new FXLabel(horizontalFrameLabels, "key", nullptr, GUIDesignLabelThick100);
79  new FXLabel(horizontalFrameLabels, "value", nullptr, GUIDesignLabelCenterThick);
80  new FXLabel(horizontalFrameLabels, "", nullptr, GUIDesignLabelIconThick);
81  // create scroll windows
82  FXScrollWindow* scrollWindow = new FXScrollWindow(this, LAYOUT_FILL);
83  // create vertical frame for rows
84  myVerticalFrameRow = new FXVerticalFrame(scrollWindow, GUIDesignAuxiliarFrame);
85 }
86 
87 
89 
90 
91 void
92 GNEMultipleParametersDialog::ParametersValues::setParameters(const std::vector<std::pair<std::string, std::string> >& newParameters) {
93  // clear rows
94  clearParameters();
95  // iterate over parameteres
96  for (const auto& newParameter : newParameters) {
97  addParameter(newParameter);
98  }
99 }
100 
101 
102 void
103 GNEMultipleParametersDialog::ParametersValues::addParameter(std::pair<std::string, std::string> newParameter) {
104  // enable last row
105  myParameterRows.back()->enableRow(newParameter.first, newParameter.second);
106  // add row
107  myParameterRows.push_back(new ParameterRow(this, myVerticalFrameRow));
108  // enable add button in the last row
109  myParameterRows.back()->toogleAddButton();
110 }
111 
112 
113 void
115  // iterate over all rows
116  for (const auto& parameterRow : myParameterRows) {
117  delete parameterRow;
118  }
119  //clear myParameterRows;
120  myParameterRows.clear();
121  // add row
122  myParameterRows.push_back(new ParameterRow(this, myVerticalFrameRow));
123  // enable add button in the last row
124  myParameterRows.back()->toogleAddButton();
125 }
126 
127 
128 const std::vector<GNEMultipleParametersDialog::ParametersValues::ParameterRow*>
130  return myParameterRows;
131 }
132 
133 
134 bool
136  // just interate over myParameterRows and compare key
137  for (const auto& row : myParameterRows) {
138  if (row->keyField->getText().text() == key) {
139  return true;
140  }
141  }
142  return false;
143 }
144 
145 
146 long
147 GNEMultipleParametersDialog::ParametersValues::onPaint(FXObject* o, FXSelector f, void* p) {
148  // size of key label has to be updated in every interation
149  if (myParameterRows.size() > 0) {
150  myKeyLabel->setWidth(myParameterRows.front()->keyField->getWidth());
151  }
152  return FXGroupBox::onPaint(o, f, p);
153 }
154 
155 
156 long
158  // find what value was changed
159  for (int i = 0; i < (int)myParameterRows.size(); i++) {
160  if (myParameterRows.at(i)->keyField == obj) {
161  // change color of text field depending if key is valid or empty
162  if (myParameterRows.at(i)->keyField->getText().empty() || SUMOXMLDefinitions::isValidParameterKey(myParameterRows.at(i)->keyField->getText().text())) {
163  myParameterRows.at(i)->keyField->setTextColor(FXRGB(0, 0, 255));
164  myParameterRows.at(i)->valueChanged = true;
165  } else {
166  myParameterRows.at(i)->keyField->setTextColor(FXRGB(255, 0, 0));
167  myParameterRows.at(i)->keyField->killFocus();
168  }
169  } else if (myParameterRows.at(i)->valueField == obj) {
170  myParameterRows.at(i)->valueField->setTextColor(FXRGB(0, 0, 255));
171  myParameterRows.at(i)->valueChanged = true;
172  }
173  }
174  return 1;
175 }
176 
177 
178 long
180  // first check if add button was pressed
181  if (myParameterRows.back()->button == obj) {
182  // create new parameter
183  addParameter(std::make_pair("", ""));
184  return 1;
185  } else {
186  // in other case, button press was a "remove button". Find id and remove the Parameter
187  for (int i = 0; i < (int)myParameterRows.size(); i++) {
188  if (myParameterRows.at(i)->button == obj) {
189  // delete row
190  delete myParameterRows.at(i);
191  // just remove row
192  myParameterRows.erase(myParameterRows.begin() + i);
193  return 1;
194  }
195  }
196  }
197  // Nothing to do
198  return 1;
199 }
200 
201 
203  valueChanged(false) {
204  horizontalFrame = new FXHorizontalFrame(verticalFrameParent, GUIDesignAuxiliarHorizontalFrame);
208  // only create elements if vertical frame was previously created
209  if (verticalFrameParent->id()) {
210  horizontalFrame->create();
211  }
212  // by defaults rows are disabled
213  disableRow();
214 }
215 
216 
218  // simply delete horizontalFrame (rest of elements will be automatic deleted due they are children of horizontal frame)
219  delete horizontalFrame;
220 }
221 
222 
223 void
225  // hide all
226  keyField->setText("");
227  keyField->disable();
228  valueField->setText("");
229  valueField->disable();
230  button->disable();
231  button->setIcon(GUIIconSubSys::getIcon(GUIIcon::REMOVE));
232 }
233 
234 
235 void
236 GNEMultipleParametersDialog::ParametersValues::ParameterRow::enableRow(const std::string& parameter, const std::string& value) const {
237  // restore color and enable key field
238  keyField->setText(parameter.c_str());
239  if (parameter.empty() || SUMOXMLDefinitions::isValidParameterKey(parameter)) {
240  keyField->setTextColor(FXRGB(0, 0, 0));
241  } else {
242  keyField->setTextColor(FXRGB(255, 0, 0));
243  }
244  keyField->enable();
245  // restore color and enable value field
246  valueField->setText(value.c_str());
247  valueField->enable();
248  // enable button and set icon remove
249  button->enable();
250  button->setIcon(GUIIconSubSys::getIcon(GUIIcon::REMOVE));
251 }
252 
253 
254 void
256  // clear and disable parameter and value fields
257  keyField->setText("");
258  keyField->disable();
259  valueField->setText("");
260  valueField->disable();
261  // enable remove button and set "add" icon and focus
262  button->enable();
263  button->setIcon(GUIIconSubSys::getIcon(GUIIcon::ADD));
264  button->setFocus();
265 }
266 
267 
268 bool
270  return (button->getIcon() == GUIIconSubSys::getIcon(GUIIcon::ADD));
271 }
272 
273 
274 void
276  keyField->setText(other.keyField->getText());
277  valueField->setText(other.valueField->getText());
278 }
279 
280 // ---------------------------------------------------------------------------
281 // GNEMultipleParametersDialog::ParametersOperations - methods
282 // ---------------------------------------------------------------------------
283 
285  FXGroupBox(frame, "Operations", GUIDesignGroupBoxFrame100),
286  myParameterDialogParent(ParameterDialogParent) {
287  // create buttons
293 }
294 
295 
297 
298 
299 long
301  // get the Additional file name
302  FXFileDialog opendialog(this, "Open Parameter Template");
303  opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::GREENVEHICLE));
304  opendialog.setSelectMode(SELECTFILE_EXISTING);
305  opendialog.setPatternList(" Parameter Template files (*.xml)\nAll files (*)");
306  if (gCurrentFolder.length() != 0) {
307  opendialog.setDirectory(gCurrentFolder);
308  }
309  if (opendialog.execute()) {
310  gCurrentFolder = opendialog.getDirectory();
311  std::string file = opendialog.getFilename().text();
312  // save current number of parameters
313  const int numberOfParametersbeforeLoad = (int)myParameterDialogParent->myParametersValues->getParameterRows().size();
314  // Create additional handler and run parser
315  GNEParameterHandler handler(this, file);
316  if (!XMLSubSys::runParser(handler, file, false)) {
317  WRITE_MESSAGE("Loading of Parameters From " + file + " failed.");
318  }
319  // show loaded attributes
320  WRITE_MESSAGE("Loaded " + toString((int)myParameterDialogParent->myParametersValues->getParameterRows().size() - numberOfParametersbeforeLoad) + " Parameters.");
321  }
322  return 1;
323 }
324 
325 
326 long
328  // obtain file to save parameters
329  FXString file = MFXUtils::getFilename2Write(this,
330  "Select name of the Parameter Template file", ".xml",
333  if (file == "") {
334  // None parameter file was selected, then stop function
335  return 1;
336  } else {
337  // open device
338  OutputDevice& device = OutputDevice::getDevice(file.text());
339  // write header
340  device.writeXMLHeader("Parameter", "parameter_file.xsd");
341  // iterate over all parameters and save it in the filename
342  for (const auto& row : myParameterDialogParent->myParametersValues->getParameterRows()) {
343  // write all except last
344  if (row != myParameterDialogParent->myParametersValues->getParameterRows().back()) {
345  // open tag
346  device.openTag(SUMO_TAG_PARAM);
347  // write key
348  device.writeAttr(SUMO_ATTR_KEY, row->keyField->getText().text());
349  // write value
350  device.writeAttr(SUMO_ATTR_VALUE, row->valueField->getText().text());
351  // close tag
352  device.closeTag();
353  }
354  }
355  // close device
356  device.close();
357  }
358  return 1;
359 }
360 
361 
362 long
364  // simply clear parameters from ParametersValues
365  myParameterDialogParent->myParametersValues->clearParameters();
366  return 1;
367 }
368 
369 
370 long
372  // declare two containers for parameters
373  std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
374  std::vector<std::string> emptyKeyValues;
375  // first extract empty values
376  for (const auto& parameterRow : myParameterDialogParent->myParametersValues->getParameterRows()) {
377  // check if key is empty
378  if (!parameterRow->keyField->getText().empty()) {
379  nonEmptyKeyValues.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
380  } else if (!parameterRow->valueField->getText().empty()) {
381  emptyKeyValues.push_back(parameterRow->valueField->getText().text());
382  }
383  }
384  // sort non-empty parameters
385  std::sort(nonEmptyKeyValues.begin(), nonEmptyKeyValues.end());
386  // sort non-empty parameters
387  std::sort(emptyKeyValues.begin(), emptyKeyValues.end());
388  // add values without key
389  for (const auto& emptyKeyValue : emptyKeyValues) {
390  nonEmptyKeyValues.push_back(std::make_pair("", emptyKeyValue));
391  }
392  // finally setparameters in myParametersValues
393  myParameterDialogParent->myParametersValues->setParameters(nonEmptyKeyValues);
394  return 1;
395 }
396 
397 
398 long
400  // Create dialog box
401  FXDialogBox* ParameterHelpDialog = new FXDialogBox(this, " Parameters Help", GUIDesignDialogBox);
402  ParameterHelpDialog->setIcon(GUIIconSubSys::getIcon(GUIIcon::APP_TABLE));
403  // set help text
404  std::ostringstream help;
405  help
406  << "- Parameters are defined by a Key and a Value.\n"
407  << "- In Netedit can be defined using format key1=parameter1|key2=parameter2|...\n"
408  << " - Duplicated and empty Keys aren't valid.\n"
409  << " - Certain characters aren't allowed (\t\n\r@$%^&/|\\....)\n";
410  // Create label with the help text
411  new FXLabel(ParameterHelpDialog, help.str().c_str(), nullptr, GUIDesignLabelFrameInformation);
412  // Create horizontal separator
413  new FXHorizontalSeparator(ParameterHelpDialog, GUIDesignHorizontalSeparator);
414  // Create frame for OK Button
415  FXHorizontalFrame* myHorizontalFrameOKButton = new FXHorizontalFrame(ParameterHelpDialog, GUIDesignAuxiliarHorizontalFrame);
416  // Create Button Close (And two more horizontal frames to center it)
417  new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
418  new FXButton(myHorizontalFrameOKButton, "OK\t\tclose", GUIIconSubSys::getIcon(GUIIcon::ACCEPT), ParameterHelpDialog, FXDialogBox::ID_ACCEPT, GUIDesignButtonOK);
419  new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
420  // Write Warning in console if we're in testing mode
421  WRITE_DEBUG("Opening Parameter help dialog");
422  // create Dialog
423  ParameterHelpDialog->create();
424  // show in the given position
425  ParameterHelpDialog->show(PLACEMENT_CURSOR);
426  // refresh APP
427  getApp()->refresh();
428  // open as modal dialog (will block all windows until stop() or stopModal() is called)
429  getApp()->runModalFor(ParameterHelpDialog);
430  // Write Warning in console if we're in testing mode
431  WRITE_DEBUG("Closing Parameter help dialog");
432  return 1;
433 }
434 
435 
437  SUMOSAXHandler(file),
438  myParametersOperationsParent(ParametersOperationsParent) {
439 }
440 
441 
443 
444 
445 void
447  // Obtain tag of element
448  SumoXMLTag tag = static_cast<SumoXMLTag>(element);
449  // only continue if tag is valid
450  if (tag == SUMO_TAG_PARAM) {
451  // Check that format of Parameter is correct
452  if (!attrs.hasAttribute(SUMO_ATTR_KEY)) {
453  WRITE_WARNING("Key of Parameter not defined");
454  } else if (!attrs.hasAttribute(SUMO_ATTR_VALUE)) {
455  WRITE_WARNING("Value of Parameter not defined");
456  } else {
457  // obtain Key and value
458  const std::string key = attrs.getString(SUMO_ATTR_KEY);
459  const std::string value = attrs.getString(SUMO_ATTR_VALUE);
460  // check that parsed values are correct
462  if (key.size() == 0) {
463  WRITE_WARNING("Key of Parameter cannot be empty");
464  } else {
465  WRITE_WARNING("Key '" + key + "' of Parameter contains invalid characters");
466  }
467  } else if (myParametersOperationsParent->myParameterDialogParent->myParametersValues->keyExist(key)) {
468  WRITE_WARNING("Key '" + key + "' already exist");
469  } else {
470  // add parameter to vector of myParameterDialogParent
471  myParametersOperationsParent->myParameterDialogParent->myParametersValues->addParameter(std::make_pair(key, value));
472  }
473  }
474  }
475 }
476 
477 // ---------------------------------------------------------------------------
478 // GNEMultipleParametersDialog::ParametersOptions - methods
479 // ---------------------------------------------------------------------------
480 
482  FXGroupBox(frame, "Options", GUIDesignGroupBoxFrame100),
483  myParameterDialogParent(parameterDialogParent) {
484  myOnlyForExistentKeys = new FXCheckButton(this, "Only for\nexistent keys", this, MID_GNE_SET_ATTRIBUTE_BOOL, GUIDesignCheckButtonExtraHeight);
485 }
486 
487 
489 
490 
491 bool
493  return (myOnlyForExistentKeys->getCheck() == TRUE);
494 }
495 
496 // ---------------------------------------------------------------------------
497 // GNEMultipleParametersDialog - methods
498 // ---------------------------------------------------------------------------
499 
501  FXDialogBox(parametersEditorInspector->getInspectorFrameParent()->getViewNet()->getApp(), "Edit parameters", GUIDesignDialogBoxExplicitStretchable(430, 300)),
502  myParametersEditorInspector(parametersEditorInspector) {
503  // call auxiliar constructor
504  constructor();
505  // reset
506  onCmdReset(nullptr, 0, nullptr);
507 }
508 
509 
511 
512 
513 long
514 GNEMultipleParametersDialog::onCmdAccept(FXObject*, FXSelector, void*) {
515  // get undo list
517  // declare vector for parameters in stringvector format
518  std::vector<std::pair<std::string, std::string> > parametersChanged;
519  // declare keep keys vector
520  std::vector<std::string> keepKeys;
521  // check if all edited parameters are valid
522  for (const auto& parameterRow : myParametersValues->getParameterRows()) {
523  // ignore last row
524  if (parameterRow != myParametersValues->getParameterRows().back()) {
525  // insert in keepKeys
526  keepKeys.push_back(parameterRow->keyField->getText().text());
527  // continue if we're going to modify key
528  if (parameterRow->valueChanged) {
529  if (parameterRow->keyField->getText().empty()) {
530  // write warning if netedit is running in testing mode
531  WRITE_DEBUG("Opening FXMessageBox of type 'warning'");
532  // open warning Box
533  FXMessageBox::warning(getApp(), MBOX_OK, "Empty Parameter key", "%s", "Parameters with empty keys aren't allowed");
534  // write warning if netedit is running in testing mode
535  WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
536  return 1;
537  } else if (!SUMOXMLDefinitions::isValidParameterKey(parameterRow->keyField->getText().text())) {
538  // write warning if netedit is running in testing mode
539  WRITE_DEBUG("Opening FXMessageBox of type 'warning'");
540  // open warning Box
541  FXMessageBox::warning(getApp(), MBOX_OK, "Invalid Parameter key", "%s", "There are keys with invalid characters");
542  // write warning if netedit is running in testing mode
543  WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
544  return 1;
545  }
546  // insert in parameters
547  parametersChanged.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
548  }
549  }
550  }
551  // sort sortedParameters
552  std::sort(parametersChanged.begin(), parametersChanged.end());
553  // check if there is duplicated keys
554  for (auto i = parametersChanged.begin(); i != parametersChanged.end(); i++) {
555  if (((i + 1) != parametersChanged.end()) && (i->first) == (i + 1)->first) {
556  // write warning if netedit is running in testing mode
557  WRITE_DEBUG("Opening FXMessageBox of type 'warning'");
558  // open warning Box
559  FXMessageBox::warning(getApp(), MBOX_OK, "Duplicated Parameters", "%s", "Parameters with the same Key aren't allowed");
560  // write warning if netedit is running in testing mode
561  WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
562  return 1;
563  }
564  }
565  // begin change
566  undoList->p_begin("change parameters");
567  // iterate over ACs
569  // remove keys
570  AC->removeACParametersKeys(keepKeys, undoList);
571  // update parameters
572  for (const auto& parameter : parametersChanged) {
573  if (myParametersOptions->onlyForExistentKeys() && (AC->getACParametersMap().count(parameter.first) == 0)) {
574  continue;
575  } else {
576  AC->addACParameters(parameter.first, parameter.second, undoList);
577  }
578  }
579  }
580  // end change
581  undoList->p_end();
582  // all ok, then close dialog
583  getApp()->stopModal(this, TRUE);
584  return 1;
585 }
586 
587 
588 long
589 GNEMultipleParametersDialog::onCmdCancel(FXObject*, FXSelector, void*) {
590  // Stop Modal
591  getApp()->stopModal(this, FALSE);
592  return 1;
593 }
594 
595 
596 long
597 GNEMultipleParametersDialog::onCmdReset(FXObject*, FXSelector, void*) {
598  // declare a map for key-values
599  std::map<std::string, std::vector<std::string> > keyValuesMap;
600  // fill keys
602  for (const auto& keyAttribute : AC->getACParametersMap()) {
603  keyValuesMap[keyAttribute.first].push_back(keyAttribute.second);
604  }
605  }
606  // transform map to string vector
607  std::vector<std::pair<std::string, std::string> > keyValues;
608  for (const auto& keyAttribute : keyValuesMap) {
609  // remove duplicated values
610  std::set<std::string> valuesNonDuplicated;
611  for (const auto& value : keyAttribute.second) {
612  valuesNonDuplicated.insert(value);
613  }
614  // merge values
615  std::string values;
616  for (const auto& value : valuesNonDuplicated) {
617  values.append(value + " ");
618  }
619  if (!values.empty()) {
620  values.pop_back();
621  }
622  // update key values
623  keyValues.push_back(std::make_pair(keyAttribute.first, values));
624  }
625  // fill myParametersValues
626  myParametersValues->setParameters(keyValues);
627  return 1;
628 }
629 
630 
631 void
633  // set vehicle icon for this dialog
635  // create main frame
636  FXVerticalFrame* mainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
637  // create frame for Parameters, operations and options
638  FXHorizontalFrame* horizontalFrameExtras = new FXHorizontalFrame(mainFrame, GUIDesignAuxiliarFrame);
639  // create parameters values
640  myParametersValues = new ParametersValues(horizontalFrameExtras, this);
641  // create vertical frame frame
642  FXVerticalFrame* verticalFrameExtras = new FXVerticalFrame(horizontalFrameExtras, GUIDesignAuxiliarVerticalFrame);
643  // create parameters operations
644  myParametersOperations = new ParametersOperations(verticalFrameExtras, this);
645  // create parameters options
646  myParametersOptions = new ParametersOptions(verticalFrameExtras, this);
647  // add separator
648  new FXHorizontalSeparator(mainFrame, GUIDesignHorizontalSeparator);
649  // create dialog buttons bot centered
650  FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(mainFrame, GUIDesignHorizontalFrame);
651  new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
652  myAcceptButton = new FXButton(buttonsFrame, "accept\t\tclose", GUIIconSubSys::getIcon(GUIIcon::ACCEPT), this, MID_GNE_BUTTON_ACCEPT, GUIDesignButtonAccept);
653  myCancelButton = new FXButton(buttonsFrame, "cancel\t\tclose", GUIIconSubSys::getIcon(GUIIcon::CANCEL), this, MID_GNE_BUTTON_CANCEL, GUIDesignButtonCancel);
654  myResetButton = new FXButton(buttonsFrame, "reset\t\tclose", GUIIconSubSys::getIcon(GUIIcon::RESET), this, MID_GNE_BUTTON_RESET, GUIDesignButtonReset);
655  new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
656 }
657 
658 /****************************************************************************/
FXDEFMAP(GNEMultipleParametersDialog) GNEMultipleParametersDialogMap[]
@ MID_GNE_SET_ATTRIBUTE
attribute edited
Definition: GUIAppEnum.h:717
@ MID_GNE_REMOVE_ATTRIBUTE
attribute removed
Definition: GUIAppEnum.h:715
@ MID_GNE_BUTTON_CANCEL
cancel button
Definition: GUIAppEnum.h:1094
@ MID_GNE_BUTTON_RESET
reset button
Definition: GUIAppEnum.h:1096
@ MID_GNE_BUTTON_SAVE
save button
Definition: GUIAppEnum.h:1100
@ MID_GNE_BUTTON_SORT
sort button
Definition: GUIAppEnum.h:1104
@ MID_HELP
help button
Definition: GUIAppEnum.h:578
@ MID_GNE_BUTTON_LOAD
load button
Definition: GUIAppEnum.h:1098
@ MID_GNE_BUTTON_CLEAR
clear button
Definition: GUIAppEnum.h:1102
@ MID_GNE_BUTTON_ACCEPT
accept button
Definition: GUIAppEnum.h:1092
@ MID_GNE_SET_ATTRIBUTE_BOOL
bool attribute edited
Definition: GUIAppEnum.h:747
#define GUIDesignGroupBoxFrame100
Group box design for elements of width 100.
Definition: GUIDesigns.h:284
#define GUIDesignButtonIcon
button only with icon
Definition: GUIDesigns.h:71
#define GUIDesignButtonAccept
Accept Button.
Definition: GUIDesigns.h:118
#define GUIDesignButtonCancel
Cancel Button.
Definition: GUIDesigns.h:121
#define GUIDesignTextField
Definition: GUIDesigns.h:36
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:313
#define GUIDesignDialogBox
Definition: GUIDesigns.h:494
#define GUIDesignButtonRectangular100
button rectangular with thick and raise frame with a width of 100
Definition: GUIDesigns.h:77
#define GUIDesignTextFieldNCol
Num of column of text field.
Definition: GUIDesigns.h:54
#define GUIDesignButtonOK
Definition: GUIDesigns.h:115
#define GUIDesignAuxiliarVerticalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:316
#define GUIDesignLabelCenterThick
label extended over frame with thick and with text justify to center
Definition: GUIDesigns.h:193
#define GUIDesignGroupBoxFrameFill
Group box design extended over frame (X and Y)
Definition: GUIDesigns.h:281
#define GUIDesignButtonReset
Reset Button.
Definition: GUIDesigns.h:124
#define GUIDesignLabelThick100
label with thick, text justify to left and wdth of 100
Definition: GUIDesigns.h:229
#define GUIDesignHorizontalSeparator
Definition: GUIDesigns.h:362
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frames used to pack another frames extended in all directions
Definition: GUIDesigns.h:310
#define GUIDesignHorizontalFrame
Definition: GUIDesigns.h:263
#define GUIDesignCheckButtonExtraHeight
checkButton placed in left position with double size
Definition: GUIDesigns.h:136
#define GUIDesignDialogBoxExplicitStretchable(width, height)
design for dialog box with specift width and height that can be stretched (But not shrinked)
Definition: GUIDesigns.h:509
#define GUIDesignLabelIconThick
label squared over frame with thick and with text justify to center
Definition: GUIDesigns.h:196
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:223
FXString gCurrentFolder
The folder used as last.
@ CLEANJUNCTIONS
@ GREENVEHICLE
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:286
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:278
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ 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:44
GNEViewNet * getViewNet() const
get view net
Definition: GNEFrame.cpp:133
GNEInspectorFrame * getInspectorFrameParent() const
get inspector frame parent
GNEParameterHandler(ParametersOperations *ParametersOperationsParent, const std::string &file)
Constructor.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
long onCmdSortParameters(FXObject *, FXSelector, void *)
event when user press sort parameters button
long onCmdHelpParameter(FXObject *, FXSelector, void *)
event when user press help parameters button
long onCmdSaveParameters(FXObject *, FXSelector, void *)
event when user press save parameters button
long onCmdClearParameters(FXObject *, FXSelector, void *)
event when user press clear parameters button
GNEMultipleParametersDialog * myParameterDialogParent
pointer to Shape Frame Parent
ParametersOperations(FXVerticalFrame *frame, GNEMultipleParametersDialog *ParameterDialogParent)
FOX-declaration.
FXCheckButton * myOnlyForExistentKeys
apply changes only for existent keys
bool onlyForExistentKeys() const
apply changes to all elements
ParametersOptions(FXVerticalFrame *frame, GNEMultipleParametersDialog *ParameterDialogParent)
constructor
void enableRow(const std::string &parameter, const std::string &value) const
enable rlow
void copyValues(const ParameterRow &other)
copy values of other parameter Row
FXHorizontalFrame * horizontalFrame
frame in which elements of ParameterRow are placed
bool isButtonInAddMode() const
check if remove button is in mode "add"
ParameterRow(ParametersValues *ParametersValues, FXVerticalFrame *verticalFrameParent)
constructor
bool keyExist(const std::string &key) const
check if given key exist already
long onPaint(FXObject *o, FXSelector f, void *p)
void setParameters(const std::vector< std::pair< std::string, std::string > > &newParameters)
set parameters
GNEMultipleParametersDialog * myParameterDialogParent
pointer to ParameterDialog parent
const std::vector< ParameterRow * > getParameterRows() const
get vector with the ParameterRows
long onCmdSetAttribute(FXObject *, FXSelector, void *)
event when user change an attribute
void addParameter(std::pair< std::string, std::string > newParameter)
add a single parameter
long onCmdButtonPress(FXObject *, FXSelector, void *)
event when user press a remove (or add) button
ParametersOperations * myParametersOperations
pointer to parameters operations
long onCmdAccept(FXObject *, FXSelector, void *)
long onCmdCancel(FXObject *, FXSelector, void *)
event after press cancel button
GNEMultipleParametersDialog(GNEInspectorFrame::ParametersEditorInspector *parametersEditorInspector)
Constructor for parameter editor inspector.
ParametersOptions * myParametersOptions
pointer to parameters options
ParametersValues * myParametersValues
pointer to parameters values
long onCmdReset(FXObject *, FXSelector, void *)
event after press reset button
void constructor()
auxiliar constructor
GNEInspectorFrame::ParametersEditorInspector * myParametersEditorInspector
FOX need this.
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:71
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
Definition: GNEUndoList.cpp:78
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
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
void close()
Closes the device and removes it from the dictionary.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:239
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
Encapsulated SAX-Attributes.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
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:148