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-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 parameters
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <netedit/GNENet.h>
23 #include <netedit/GNEUndoList.h>
24 #include <netedit/GNEViewNet.h>
30 #include <utils/xml/XMLSubSys.h>
31 
33 
34 
35 // ===========================================================================
36 // FOX callback mapping
37 // ===========================================================================
38 
39 FXDEFMAP(GNESingleParametersDialog) GNESingleParametersDialogMap[] = {
43  FXMAPFUNC(SEL_CHORE, FXDialogBox::ID_CANCEL, GNESingleParametersDialog::onCmdCancel),
44  FXMAPFUNC(SEL_TIMEOUT, FXDialogBox::ID_CANCEL, GNESingleParametersDialog::onCmdCancel),
45  FXMAPFUNC(SEL_COMMAND, FXDialogBox::ID_CANCEL, GNESingleParametersDialog::onCmdCancel),
46  FXMAPFUNC(SEL_CLOSE, 0, GNESingleParametersDialog::onCmdCancel),
47 };
48 
53 };
54 
61 };
62 
63 // Object implementation
64 FXIMPLEMENT(GNESingleParametersDialog, FXDialogBox, GNESingleParametersDialogMap, ARRAYNUMBER(GNESingleParametersDialogMap))
65 FXIMPLEMENT(GNESingleParametersDialog::ParametersValues, FXGroupBox, ParametersValuesMap, ARRAYNUMBER(ParametersValuesMap))
66 FXIMPLEMENT(GNESingleParametersDialog::ParametersOperations, FXGroupBox, ParametersOperationsMap, ARRAYNUMBER(ParametersOperationsMap))
67 
68 // ===========================================================================
69 // member method definitions
70 // ===========================================================================
71 
72 // ---------------------------------------------------------------------------
73 // GNESingleParametersDialog::ParametersValues - methods
74 // ---------------------------------------------------------------------------
75 
76 GNESingleParametersDialog::ParametersValues::ParametersValues(FXHorizontalFrame* frame, GNESingleParametersDialog* ParameterDialogParent) :
77  FXGroupBox(frame, " Parameters", GUIDesignGroupBoxFrameFill),
78  myParameterDialogParent(ParameterDialogParent) {
79  // create labels for keys and values
80  FXHorizontalFrame* horizontalFrameLabels = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
81  myKeyLabel = new FXLabel(horizontalFrameLabels, "key", nullptr, GUIDesignLabelThick100);
82  new FXLabel(horizontalFrameLabels, "value", nullptr, GUIDesignLabelCenterThick);
83  // create scroll windows
84  FXScrollWindow* scrollWindow = new FXScrollWindow(this, LAYOUT_FILL);
85  // create vertical frame for rows
86  myVerticalFrameRow = new FXVerticalFrame(scrollWindow, GUIDesignAuxiliarFrame);
87 }
88 
89 
91 
92 
93 void
94 GNESingleParametersDialog::ParametersValues::setParameters(const std::vector<std::pair<std::string, std::string> >& newParameters) {
95  // clear rows
96  clearParameters();
97  // iterate over parameteres
98  for (const auto& newParameter : newParameters) {
99  addParameter(newParameter);
100  }
101 }
102 
103 
104 void
105 GNESingleParametersDialog::ParametersValues::addParameter(std::pair<std::string, std::string> newParameter) {
106  // enable last row
107  myParameterRows.back()->enableRow(newParameter.first, newParameter.second);
108  // add row
109  myParameterRows.push_back(new ParameterRow(this, myVerticalFrameRow));
110  // enable add button in the last row
111  myParameterRows.back()->toogleAddButton();
112 }
113 
114 
115 void
117  // iterate over all rows
118  for (const auto& parameterRow : myParameterRows) {
119  delete parameterRow;
120  }
121  //clear myParameterRows;
122  myParameterRows.clear();
123  // add row
124  myParameterRows.push_back(new ParameterRow(this, myVerticalFrameRow));
125  // enable add button in the last row
126  myParameterRows.back()->toogleAddButton();
127 }
128 
129 
130 const std::vector<GNESingleParametersDialog::ParametersValues::ParameterRow*>
132  return myParameterRows;
133 }
134 
135 
136 bool
138  // just interate over myParameterRows and compare key
139  for (const auto& row : myParameterRows) {
140  if (row->keyField->getText().text() == key) {
141  return true;
142  }
143  }
144  return false;
145 }
146 
147 
148 long
149 GNESingleParametersDialog::ParametersValues::onPaint(FXObject* o, FXSelector f, void* p) {
150  // size of key label has to be updated in every interation
151  if (myParameterRows.size() > 0) {
152  myKeyLabel->setWidth(myParameterRows.front()->keyField->getWidth());
153  }
154  return FXGroupBox::onPaint(o, f, p);
155 }
156 
157 
158 long
160  // find what value was changed
161  for (int i = 0; i < (int)myParameterRows.size(); i++) {
162  if (myParameterRows.at(i)->keyField == obj) {
163  // change color of text field depending if key is valid or empty
164  if (myParameterRows.at(i)->keyField->getText().empty() || SUMOXMLDefinitions::isValidParameterKey(myParameterRows.at(i)->keyField->getText().text())) {
165  myParameterRows.at(i)->keyField->setTextColor(FXRGB(0, 0, 0));
166  } else {
167  myParameterRows.at(i)->keyField->setTextColor(FXRGB(255, 0, 0));
168  myParameterRows.at(i)->keyField->killFocus();
169  }
170  }
171  }
172  return 1;
173 }
174 
175 
176 long
178  // first check if add button was pressed
179  if (myParameterRows.back()->button == obj) {
180  // create new parameter
181  addParameter(std::make_pair("", ""));
182  return 1;
183  } else {
184  // in other case, button press was a "remove button". Find id and remove the Parameter
185  for (int i = 0; i < (int)myParameterRows.size(); i++) {
186  if (myParameterRows.at(i)->button == obj) {
187  // delete row
188  delete myParameterRows.at(i);
189  // just remove row
190  myParameterRows.erase(myParameterRows.begin() + i);
191  return 1;
192  }
193  }
194  }
195  // Nothing to do
196  return 1;
197 }
198 
199 
201  horizontalFrame = new FXHorizontalFrame(verticalFrameParent, GUIDesignAuxiliarHorizontalFrame);
202  keyField = new FXTextField(horizontalFrame, GUIDesignTextFieldNCol, ParametersValues, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
203  valueField = new FXTextField(horizontalFrame, GUIDesignTextFieldNCol, ParametersValues, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
205  // only create elements if vertical frame was previously created
206  if (verticalFrameParent->id()) {
207  horizontalFrame->create();
208  }
209  // by defaults rows are disabled
210  disableRow();
211 }
212 
213 
215  // simply delete horizontalFrame (rest of elements will be automatic deleted due they are children of horizontal frame)
216  delete horizontalFrame;
217 }
218 
219 
220 void
222  // hide all
223  keyField->setText("");
224  keyField->disable();
225  valueField->setText("");
226  valueField->disable();
227  button->disable();
228  button->setIcon(GUIIconSubSys::getIcon(GUIIcon::REMOVE));
229 }
230 
231 
232 void
233 GNESingleParametersDialog::ParametersValues::ParameterRow::enableRow(const std::string& parameter, const std::string& value) const {
234  // restore color and enable key field
235  keyField->setText(parameter.c_str());
236  if (parameter.empty() || SUMOXMLDefinitions::isValidParameterKey(parameter)) {
237  keyField->setTextColor(FXRGB(0, 0, 0));
238  } else {
239  keyField->setTextColor(FXRGB(255, 0, 0));
240  }
241  keyField->enable();
242  // restore color and enable value field
243  valueField->setText(value.c_str());
244  valueField->enable();
245  // enable button and set icon remove
246  button->enable();
247  button->setIcon(GUIIconSubSys::getIcon(GUIIcon::REMOVE));
248 }
249 
250 
251 void
253  // clear and disable parameter and value fields
254  keyField->setText("");
255  keyField->disable();
256  valueField->setText("");
257  valueField->disable();
258  // enable remove button and set "add" icon and focus
259  button->enable();
260  button->setIcon(GUIIconSubSys::getIcon(GUIIcon::ADD));
261  button->setFocus();
262 }
263 
264 
265 bool
267  return (button->getIcon() == GUIIconSubSys::getIcon(GUIIcon::ADD));
268 }
269 
270 
271 void
273  keyField->setText(other.keyField->getText());
274  valueField->setText(other.valueField->getText());
275 }
276 
277 // ---------------------------------------------------------------------------
278 // GNESingleParametersDialog::ParametersOperations - methods
279 // ---------------------------------------------------------------------------
280 
282  FXGroupBox(frame, "Operations", GUIDesignGroupBoxFrame100),
283  myParameterDialogParent(ParameterDialogParent) {
284  // create buttons
290 }
291 
292 
294 
295 
296 long
298  // get the Additional file name
299  FXFileDialog opendialog(this, "Open Parameter Template");
300  opendialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::GREENVEHICLE));
301  opendialog.setSelectMode(SELECTFILE_EXISTING);
302  opendialog.setPatternList(" Parameter Template files (*.xml)\nAll files (*)");
303  if (gCurrentFolder.length() != 0) {
304  opendialog.setDirectory(gCurrentFolder);
305  }
306  if (opendialog.execute()) {
307  gCurrentFolder = opendialog.getDirectory();
308  std::string file = opendialog.getFilename().text();
309  // save current number of parameters
310  const int numberOfParametersbeforeLoad = (int)myParameterDialogParent->myParametersValues->getParameterRows().size();
311  // Create additional handler and run parser
312  GNEParameterHandler handler(this, file);
313  if (!XMLSubSys::runParser(handler, file, false)) {
314  WRITE_MESSAGE("Loading of Parameters From " + file + " failed.");
315  }
316  // show loaded attributes
317  WRITE_MESSAGE("Loaded " + toString((int)myParameterDialogParent->myParametersValues->getParameterRows().size() - numberOfParametersbeforeLoad) + " Parameters.");
318  }
319  return 1;
320 }
321 
322 
323 long
325  // obtain file to save parameters
326  FXString file = MFXUtils::getFilename2Write(this,
327  "Select name of the Parameter Template file", ".xml",
330  if (file == "") {
331  // None parameter file was selected, then stop function
332  return 1;
333  } else {
334  // open device
335  OutputDevice& device = OutputDevice::getDevice(file.text());
336  // write header
337  device.writeXMLHeader("Parameter", "parameter_file.xsd");
338  // iterate over all parameters and save it in the filename
339  for (const auto& row : myParameterDialogParent->myParametersValues->getParameterRows()) {
340  // write all except last
341  if (row != myParameterDialogParent->myParametersValues->getParameterRows().back()) {
342  // open tag
343  device.openTag(SUMO_TAG_PARAM);
344  // write key
345  device.writeAttr(SUMO_ATTR_KEY, row->keyField->getText().text());
346  // write value
347  device.writeAttr(SUMO_ATTR_VALUE, row->valueField->getText().text());
348  // close tag
349  device.closeTag();
350  }
351  }
352  // close device
353  device.close();
354  }
355  return 1;
356 }
357 
358 
359 long
361  // simply clear parameters from ParametersValues
362  myParameterDialogParent->myParametersValues->clearParameters();
363  return 1;
364 }
365 
366 
367 long
369  // declare two containers for parameters
370  std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
371  std::vector<std::string> emptyKeyValues;
372  // first extract empty values
373  for (const auto& parameterRow : myParameterDialogParent->myParametersValues->getParameterRows()) {
374  // check if key is empty
375  if (!parameterRow->keyField->getText().empty()) {
376  nonEmptyKeyValues.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
377  } else if (!parameterRow->valueField->getText().empty()) {
378  emptyKeyValues.push_back(parameterRow->valueField->getText().text());
379  }
380  }
381  // sort non-empty parameters
382  std::sort(nonEmptyKeyValues.begin(), nonEmptyKeyValues.end());
383  // sort non-empty parameters
384  std::sort(emptyKeyValues.begin(), emptyKeyValues.end());
385  // add values without key
386  for (const auto& emptyKeyValue : emptyKeyValues) {
387  nonEmptyKeyValues.push_back(std::make_pair("", emptyKeyValue));
388  }
389  // finally setparameters in myParametersValues
390  myParameterDialogParent->myParametersValues->setParameters(nonEmptyKeyValues);
391  return 1;
392 }
393 
394 
395 long
397  // Create dialog box
398  FXDialogBox* ParameterHelpDialog = new FXDialogBox(this, " Parameters Help", GUIDesignDialogBox);
399  ParameterHelpDialog->setIcon(GUIIconSubSys::getIcon(GUIIcon::APP_TABLE));
400  // set help text
401  std::ostringstream help;
402  help
403  << "- Parameters are defined by a Key and a Value.\n"
404  << "- In Netedit can be defined using format key1=parameter1|key2=parameter2|...\n"
405  << " - Duplicated and empty Keys aren't valid.\n"
406  << " - Certain characters aren't allowed (\t\n\r@$%^&/|\\....)\n";
407  // Create label with the help text
408  new FXLabel(ParameterHelpDialog, help.str().c_str(), nullptr, GUIDesignLabelFrameInformation);
409  // Create horizontal separator
410  new FXHorizontalSeparator(ParameterHelpDialog, GUIDesignHorizontalSeparator);
411  // Create frame for OK Button
412  FXHorizontalFrame* myHorizontalFrameOKButton = new FXHorizontalFrame(ParameterHelpDialog, GUIDesignAuxiliarHorizontalFrame);
413  // Create Button Close (And two more horizontal frames to center it)
414  new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
415  new FXButton(myHorizontalFrameOKButton, "OK\t\tclose", GUIIconSubSys::getIcon(GUIIcon::ACCEPT), ParameterHelpDialog, FXDialogBox::ID_ACCEPT, GUIDesignButtonOK);
416  new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
417  // Write Warning in console if we're in testing mode
418  WRITE_DEBUG("Opening Parameter help dialog");
419  // create Dialog
420  ParameterHelpDialog->create();
421  // show in the given position
422  ParameterHelpDialog->show(PLACEMENT_CURSOR);
423  // refresh APP
424  getApp()->refresh();
425  // open as modal dialog (will block all windows until stop() or stopModal() is called)
426  getApp()->runModalFor(ParameterHelpDialog);
427  // Write Warning in console if we're in testing mode
428  WRITE_DEBUG("Closing Parameter help dialog");
429  return 1;
430 }
431 
432 
434  SUMOSAXHandler(file),
435  myParametersOperationsParent(ParametersOperationsParent) {
436 }
437 
438 
440 
441 
442 void
444  // Obtain tag of element
445  SumoXMLTag tag = static_cast<SumoXMLTag>(element);
446  // only continue if tag is valid
447  if (tag != SUMO_TAG_NOTHING) {
448  // Call parse and build depending of tag
449  switch (tag) {
450  case 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  std::string key = attrs.getString(SUMO_ATTR_KEY);
459  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  break;
475  default:
476  break;
477  }
478  }
479 }
480 
481 // ---------------------------------------------------------------------------
482 // GNESingleParametersDialog - methods
483 // ---------------------------------------------------------------------------
484 
486  FXDialogBox(parametersEditorCreator->getFrameParent()->getViewNet()->getApp(), "Edit parameters", GUIDesignDialogBoxExplicitStretchable(400, 300)),
487  myParametersEditorCreator(parametersEditorCreator),
489  VTypeAttributeRow(nullptr),
490  myAttributeCarrier(nullptr) {
491  // call auxiliar constructor for elements
492  constructor();
493  // fill myParametersValues
494  myParametersValues->setParameters(parametersEditorCreator->getParameters());
495 }
496 
497 
499  FXDialogBox(parametersEditorInspector->getInspectorFrameParent()->getViewNet()->getApp(), "Edit parameters", GUIDesignDialogBoxExplicitStretchable(400, 300)),
500  myParametersEditorCreator(nullptr),
501  myParametersEditorInspector(parametersEditorInspector),
502  VTypeAttributeRow(nullptr),
503  myAttributeCarrier(nullptr) {
504  // call auxiliar constructor
505  constructor();
506  // get AC Front
507  const GNEAttributeCarrier* AC = parametersEditorInspector->getInspectorFrameParent()->getViewNet()->getInspectedAttributeCarriers().front();
508  // fill myParametersValues
509  myParametersValues->setParameters(AC->getACParameters<std::vector<std::pair<std::string, std::string> > >());
510 }
511 
512 
513 
515  FXDialogBox(viewNet->getApp(), "Edit parameters", GUIDesignDialogBoxExplicitStretchable(400, 300)),
516  myParametersEditorCreator(nullptr),
517  myParametersEditorInspector(nullptr),
518  VTypeAttributeRow(VTypeAttributeRow),
519  myAttributeCarrier(nullptr) {
520  // call auxiliar constructor
521  constructor();
522  // fill myEditedParameters
524 }
525 
526 
528  FXDialogBox(attributeCarrier->getNet()->getViewNet()->getApp(), "Edit parameters", GUIDesignDialogBoxExplicitStretchable(400, 300)),
529  myParametersEditorCreator(nullptr),
530  myParametersEditorInspector(nullptr),
531  VTypeAttributeRow(nullptr),
532  myAttributeCarrier(attributeCarrier) {
533  // call auxiliar constructor
534  constructor();
535  // fill myEditedParameters
536  myParametersValues->setParameters(myAttributeCarrier->getACParameters<std::vector<std::pair<std::string, std::string> > >());
537 }
538 
539 
541 
542 
543 long
544 GNESingleParametersDialog::onCmdAccept(FXObject*, FXSelector, void*) {
545  // declare vector for parameters in stringvector format
546  std::vector<std::pair<std::string, std::string> > parameters;
547  // check if all edited parameters are valid
548  for (const auto& parameterRow : myParametersValues->getParameterRows()) {
549  // ignore last row
550  if (parameterRow != myParametersValues->getParameterRows().back()) {
551  if (parameterRow->keyField->getText().empty()) {
552  // write warning if netedit is running in testing mode
553  WRITE_DEBUG("Opening FXMessageBox of type 'warning'");
554  // open warning Box
555  FXMessageBox::warning(getApp(), MBOX_OK, "Empty Parameter key", "%s", "Parameters with empty keys aren't allowed");
556  // write warning if netedit is running in testing mode
557  WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
558  return 1;
559  } else if (!SUMOXMLDefinitions::isValidParameterKey(parameterRow->keyField->getText().text())) {
560  // write warning if netedit is running in testing mode
561  WRITE_DEBUG("Opening FXMessageBox of type 'warning'");
562  // open warning Box
563  FXMessageBox::warning(getApp(), MBOX_OK, "Invalid Parameter key", "%s", "There are keys with invalid characters");
564  // write warning if netedit is running in testing mode
565  WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
566  return 1;
567  } else if (myParametersEditorCreator &&
569  !GNEAttributeCarrier::canParse<double>(parameterRow->valueField->getText().text())) {
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, "Invalid double Parameter value", "%s", "There are values that cannot be parsed to floats");
574  // write warning if netedit is running in testing mode
575  WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
576  return 1;
577  }
578  // insert in parameters
579  parameters.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
580  }
581  }
582  // sort sortedParameters
583  std::sort(parameters.begin(), parameters.end());
584  // check if there is duplicated keys
585  for (auto i = parameters.begin(); i != parameters.end(); i++) {
586  if (((i + 1) != parameters.end()) && (i->first) == (i + 1)->first) {
587  // write warning if netedit is running in testing mode
588  WRITE_DEBUG("Opening FXMessageBox of type 'warning'");
589  // open warning Box
590  FXMessageBox::warning(getApp(), MBOX_OK, "Duplicated Parameters", "%s", "Parameters with the same Key aren't allowed");
591  // write warning if netedit is running in testing mode
592  WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
593  return 1;
594  }
595  }
596  // set parameters in Parameters editor parents
598  // set parameter in editor creator
600  } else if (myParametersEditorInspector) {
601  // get inspected AC
603  // set parameter in AC using undoList
607  } else if (VTypeAttributeRow) {
608  // set parameter in VTypeAttributeRow
609  VTypeAttributeRow->setParameters(parameters);
610  } else if (myAttributeCarrier) {
611  // set parameter in AC using undoList
612  myAttributeCarrier->getNet()->getViewNet()->getUndoList()->p_begin("change parameters");
615  }
616  // all ok, then close dialog
617  getApp()->stopModal(this, TRUE);
618  return 1;
619 }
620 
621 
622 long
623 GNESingleParametersDialog::onCmdCancel(FXObject*, FXSelector, void*) {
624  // Stop Modal
625  getApp()->stopModal(this, FALSE);
626  return 1;
627 }
628 
629 
630 long
631 GNESingleParametersDialog::onCmdReset(FXObject*, FXSelector, void*) {
632  // restore original parameters
635  } else if (myParametersEditorInspector) {
637  myParametersValues->setParameters(AC->getACParameters<std::vector<std::pair<std::string, std::string> > >());
638  } else if (VTypeAttributeRow) {
640  } else {
641  myParametersValues->setParameters(myAttributeCarrier->getACParameters<std::vector<std::pair<std::string, std::string> > >());
642  }
643  return 1;
644 }
645 
646 
647 void
649  // set vehicle icon for this dialog
651  // create main frame
652  FXVerticalFrame* mainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
653  // create frame for Parameters and operations
654  FXHorizontalFrame* horizontalFrameExtras = new FXHorizontalFrame(mainFrame, GUIDesignAuxiliarFrame);
655  // create parameters values
656  myParametersValues = new ParametersValues(horizontalFrameExtras, this);
657  // create parameters operations
658  myParametersOperations = new ParametersOperations(horizontalFrameExtras, this);
659  // add separator
660  new FXHorizontalSeparator(mainFrame, GUIDesignHorizontalSeparator);
661  // create dialog buttons bot centered
662  FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(mainFrame, GUIDesignHorizontalFrame);
663  new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
664  myAcceptButton = new FXButton(buttonsFrame, "accept\t\tclose", GUIIconSubSys::getIcon(GUIIcon::ACCEPT), this, MID_GNE_BUTTON_ACCEPT, GUIDesignButtonAccept);
665  myCancelButton = new FXButton(buttonsFrame, "cancel\t\tclose", GUIIconSubSys::getIcon(GUIIcon::CANCEL), this, MID_GNE_BUTTON_CANCEL, GUIDesignButtonCancel);
666  myResetButton = new FXButton(buttonsFrame, "reset\t\tclose", GUIIconSubSys::getIcon(GUIIcon::RESET), this, MID_GNE_BUTTON_RESET, GUIDesignButtonReset);
667  new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
668 }
669 
670 /****************************************************************************/
FXDEFMAP(GNESingleParametersDialog) GNESingleParametersDialogMap[]
@ 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
#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 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 GUIDesignDialogBoxExplicitStretchable(width, height)
design for dialog box with specift width and height that can be stretched (But not shrinked)
Definition: GUIDesigns.h:509
#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_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:44
void setACParameters(const std::string &parameters, GNEUndoList *undoList)
set parameters (string)
GNENet * getNet() const
get pointer to net
T getACParameters() const
get parameters
void setParameters(const std::vector< std::pair< std::string, std::string > > &parameters)
set parameters
Parameterised::ParameterisedAttrType getAttrType() const
get current parameter type
std::vector< std::pair< std::string, std::string > > getParameters() const
get parameters as vector of strings
GNEViewNet * getViewNet() const
get view net
Definition: GNEFrame.cpp:133
GNEInspectorFrame * getInspectorFrameParent() const
get inspector frame parent
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2245
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 rlow
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
GNEInspectorFrame::ParametersEditorInspector * myParametersEditorInspector
pointer to ParametersEditorInspector
ParametersOperations * myParametersOperations
pointer to parameters operations
GNEAttributeCarrier * myAttributeCarrier
pointer to GNEAttributeCarrier
GNEFrameAttributesModuls::ParametersEditorCreator * myParametersEditorCreator
FOX need this.
void constructor()
auxiliar constructor
long onCmdAccept(FXObject *, FXSelector, void *)
GNESingleParametersDialog(GNEFrameAttributesModuls::ParametersEditorCreator *parametersEditorCreator)
Constructor for parameter editor creator.
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
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
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.
@ DOUBLE
Parameterised only accept doubles.
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