Eclipse SUMO - Simulation of Urban MObility
GNEParametersDialog.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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // Dialog for edit parameters
15 /****************************************************************************/
16 
17 // ===========================================================================
18 // included modules
19 // ===========================================================================
20 #include <config.h>
21 
24 #include <utils/xml/XMLSubSys.h>
25 #include <netedit/GNEViewNet.h>
27 
28 #include "GNEParametersDialog.h"
29 
30 
31 // ===========================================================================
32 // FOX callback mapping
33 // ===========================================================================
34 
35 FXDEFMAP(GNEParametersDialog) GNEParametersDialogMap[] = {
39  FXMAPFUNC(SEL_CHORE, FXDialogBox::ID_CANCEL, GNEParametersDialog::onCmdCancel),
40  FXMAPFUNC(SEL_TIMEOUT, FXDialogBox::ID_CANCEL, GNEParametersDialog::onCmdCancel),
41  FXMAPFUNC(SEL_COMMAND, FXDialogBox::ID_CANCEL, GNEParametersDialog::onCmdCancel),
42  FXMAPFUNC(SEL_CLOSE, 0, GNEParametersDialog::onCmdCancel),
43 };
44 
45 FXDEFMAP(GNEParametersDialog::ParametersValues) ParametersValuesMap[] = {
48  FXMAPFUNC(SEL_PAINT, 0, GNEParametersDialog::ParametersValues::onPaint),
49 };
50 
51 FXDEFMAP(GNEParametersDialog::ParametersOptions) ParametersOptionsMap[] = {
57 };
58 
59 // Object implementation
60 FXIMPLEMENT(GNEParametersDialog, FXDialogBox, GNEParametersDialogMap, ARRAYNUMBER(GNEParametersDialogMap))
61 FXIMPLEMENT(GNEParametersDialog::ParametersValues, FXGroupBox, ParametersValuesMap, ARRAYNUMBER(ParametersValuesMap))
62 FXIMPLEMENT(GNEParametersDialog::ParametersOptions, FXGroupBox, ParametersOptionsMap, ARRAYNUMBER(ParametersOptionsMap))
63 
64 // ===========================================================================
65 // member method definitions
66 // ===========================================================================
67 
68 // ---------------------------------------------------------------------------
69 // GNEParametersDialog::ParametersValues - methods
70 // ---------------------------------------------------------------------------
71 
72 GNEParametersDialog::ParametersValues::ParametersValues(FXHorizontalFrame* frame, GNEParametersDialog* ParameterDialogParent) :
73  FXGroupBox(frame, " Parameters", GUIDesignGroupBoxFrameFill),
74  myParameterDialogParent(ParameterDialogParent) {
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  // update values
84  updateValues();
85 }
86 
87 
89 
90 
91 void
93  // first show the correct number of rows
94  while ((myParameterDialogParent->myEditedParameters.size() + 1) < myParameterRows.size()) {
95  delete myParameterRows.back();
96  myParameterRows.pop_back();
97  }
98  while ((myParameterDialogParent->myEditedParameters.size() + 1) > myParameterRows.size()) {
99  myParameterRows.push_back(new ParameterRow(this, myVerticalFrameRow));
100  }
101  // fill rows
102  for (int i = 0; i < (int)myParameterDialogParent->myEditedParameters.size(); i++) {
103  myParameterRows.at(i)->enableRow(myParameterDialogParent->myEditedParameters.at(i).first, myParameterDialogParent->myEditedParameters.at(i).second);
104  }
105  // set last myParameterRows with the add button
106  myParameterRows.back()->toogleAddButton();
107 }
108 
109 
110 void
111 GNEParametersDialog::ParametersValues::setParameters(const std::vector<std::pair<std::string, std::string> >& newParameters) {
112  myParameterDialogParent->myEditedParameters = newParameters;
113  // update values
114  updateValues();
115 }
116 
117 
118 void
119 GNEParametersDialog::ParametersValues::addParameter(std::pair<std::string, std::string> newParameter) {
120  myParameterDialogParent->myEditedParameters.push_back(newParameter);
121  // update values
122  updateValues();
123 }
124 
125 
126 void
128  myParameterDialogParent->myEditedParameters.clear();
129  // update values
130  updateValues();
131 }
132 
133 
134 long
135 GNEParametersDialog::ParametersValues::onPaint(FXObject* o, FXSelector f, void* p) {
136  // size of key label has to be updated in every interation
137  if (myParameterRows.size() > 0) {
138  myKeyLabel->setWidth(myParameterRows.front()->keyField->getWidth());
139  }
140  return FXGroupBox::onPaint(o, f, p);
141 }
142 
143 
144 long
146  // find what value was changed
147  for (int i = 0; i < (int)myParameterRows.size(); i++) {
148  if (myParameterRows.at(i)->keyField == obj) {
149  // change key of Parameter
150  myParameterDialogParent->myEditedParameters.at(i).first = myParameterRows.at(i)->keyField->getText().text();
151  // change color of text field depending if key is valid or empty
152  if (myParameterDialogParent->myEditedParameters.at(i).first.empty() || SUMOXMLDefinitions::isValidParameterKey(myParameterDialogParent->myEditedParameters.at(i).first)) {
153  myParameterRows.at(i)->keyField->setTextColor(FXRGB(0, 0, 0));
154  } else {
155  myParameterRows.at(i)->keyField->setTextColor(FXRGB(255, 0, 0));
156  myParameterRows.at(i)->keyField->killFocus();
157  }
158  } else if (myParameterRows.at(i)->valueField == obj) {
159  // change value of Parameter
160  myParameterDialogParent->myEditedParameters.at(i).second = myParameterRows.at(i)->valueField->getText().text();
161  // change color of text field depending if attribute is valid
162  if (SUMOXMLDefinitions::isValidParameterValue(myParameterDialogParent->myEditedParameters.at(i).second)) {
163  myParameterRows.at(i)->valueField->setTextColor(FXRGB(0, 0, 0));
164  } else {
165  myParameterRows.at(i)->valueField->setTextColor(FXRGB(255, 0, 0));
166  myParameterRows.at(i)->valueField->killFocus();
167  }
168  }
169  }
170  return 1;
171 }
172 
173 
174 long
176  // first check if add button was pressed
177  if (myParameterRows.back()->button == obj) {
178  // create new parameter
179  myParameterDialogParent->myEditedParameters.push_back(std::make_pair("", ""));
180  // update values and finish
181  updateValues();
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 && i < (int)myParameterDialogParent->myEditedParameters.size()) {
187  // remove parameter
188  myParameterDialogParent->myEditedParameters.erase(myParameterDialogParent->myEditedParameters.begin() + i);
189  // update values and finish
190  updateValues();
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(ICON_REMOVE));
229 }
230 
231 
232 void
233 GNEParametersDialog::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());
245  valueField->setTextColor(FXRGB(0, 0, 0));
246  } else {
247  valueField->setTextColor(FXRGB(255, 0, 0));
248  }
249  valueField->enable();
250  // enable button and set icon remove
251  button->enable();
252  button->setIcon(GUIIconSubSys::getIcon(ICON_REMOVE));
253 }
254 
255 
256 void
258  // clear and disable parameter and value fields
259  keyField->setText("");
260  keyField->disable();
261  valueField->setText("");
262  valueField->disable();
263  // enable remove button and set "add" icon and focus
264  button->enable();
265  button->setIcon(GUIIconSubSys::getIcon(ICON_ADD));
266  button->setFocus();
267 }
268 
269 
270 bool
272  return (button->getIcon() == GUIIconSubSys::getIcon(ICON_ADD));
273 }
274 
275 
276 void
278  keyField->setText(other.keyField->getText());
279  valueField->setText(other.valueField->getText());
280 }
281 
282 // ---------------------------------------------------------------------------
283 // GNEParametersDialog::ParametersOptions - methods
284 // ---------------------------------------------------------------------------
285 
286 GNEParametersDialog::ParametersOptions::ParametersOptions(FXHorizontalFrame* frame, GNEParametersDialog* ParameterDialogParent) :
287  FXGroupBox(frame, "Options", GUIDesignGroupBoxFrame100),
288  myParameterDialogParent(ParameterDialogParent) {
289  // create buttons
295 }
296 
297 
299 
300 
301 long
303  // get the Additional file name
304  FXFileDialog opendialog(this, "Open Parameter Template");
305  opendialog.setIcon(GUIIconSubSys::getIcon(ICON_GREENVEHICLE));
306  opendialog.setSelectMode(SELECTFILE_EXISTING);
307  opendialog.setPatternList(" Parameter Template files (*.xml)\nAll files (*)");
308  if (gCurrentFolder.length() != 0) {
309  opendialog.setDirectory(gCurrentFolder);
310  }
311  if (opendialog.execute()) {
312  gCurrentFolder = opendialog.getDirectory();
313  std::string file = opendialog.getFilename().text();
314  // save current number of parameters
315  int numberOfParametersbeforeLoad = (int)myParameterDialogParent->myEditedParameters.size();
316  // Create additional handler and run parser
317  GNEParameterHandler handler(this, file);
318  if (!XMLSubSys::runParser(handler, file, false)) {
319  WRITE_MESSAGE("Loading of Parameters From " + file + " failed.");
320  }
321  // show loaded attributes
322  WRITE_MESSAGE("Loaded " + toString((int)myParameterDialogParent->myEditedParameters.size() - numberOfParametersbeforeLoad) + " Parameters.");
323  // update values
324  myParameterDialogParent->myParametersValues->updateValues();
325  }
326  return 1;
327 }
328 
329 
330 long
332  // obtain file to save parameters
333  FXString file = MFXUtils::getFilename2Write(this,
334  "Select name of the Parameter Template file", ".xml",
337  if (file == "") {
338  // None parameter file was selected, then stop function
339  return 1;
340  } else {
341  OutputDevice& device = OutputDevice::getDevice(file.text());
342  device.writeXMLHeader("Parameter", "parameter_file.xsd");
343  // iterate over all parameters and save it in the filename
344  for (auto i = myParameterDialogParent->myEditedParameters.begin(); i != myParameterDialogParent->myEditedParameters.end(); i++) {
345  device.openTag(SUMO_TAG_PARAM);
346  device.writeAttr(SUMO_ATTR_KEY, i->first);
347  device.writeAttr(SUMO_ATTR_VALUE, i->second);
348  device.closeTag();
349  }
350  device.close();
351  }
352  return 1;
353 }
354 
355 
356 long
358  // simply clear parameters from ParametersValues
359  myParameterDialogParent->myParametersValues->clearParameters();
360  return 1;
361 }
362 
363 
364 long
366  std::vector<std::pair<std::string, std::string> > ParametersNoEmpty;
367  std::vector<std::string> valuesEmpty;
368  // first extract empty values
369  for (auto i = myParameterDialogParent->myEditedParameters.begin(); i != myParameterDialogParent->myEditedParameters.end(); i++) {
370  if (!i->first.empty()) {
371  ParametersNoEmpty.push_back(*i);
372  } else if (i->first.empty() && !i->second.empty()) {
373  valuesEmpty.push_back(i->second);
374  }
375  }
376  // now sort non-empty parameters
377  std::sort(ParametersNoEmpty.begin(), ParametersNoEmpty.end());
378  // add values without key
379  for (auto i : valuesEmpty) {
380  ParametersNoEmpty.push_back(std::make_pair("", i));
381  }
382  // fill ParametersNoEmpty with empty values
383  while (ParametersNoEmpty.size() < myParameterDialogParent->myEditedParameters.size()) {
384  ParametersNoEmpty.push_back(std::make_pair("", ""));
385  }
386  // finally replace parameters in myParametersValues with ParametersNoEmpty
387  myParameterDialogParent->myParametersValues->setParameters(ParametersNoEmpty);
388  // update values
389  myParameterDialogParent->myParametersValues->updateValues();
390  return 1;
391 }
392 
393 
394 long
396  // Create dialog box
397  FXDialogBox* ParameterHelpDialog = new FXDialogBox(this, " Parameters Help", GUIDesignDialogBox);
398  ParameterHelpDialog->setIcon(GUIIconSubSys::getIcon(ICON_APP_TABLE));
399  // set help text
400  std::ostringstream help;
401  help
402  << "- Parameters are defined by a Key and a Value.\n"
403  << "- In Netedit can be defined using format key1=parameter1|key2=parameter2|...\n"
404  << " - Duplicated and empty Keys aren't valid.\n"
405  << " - Certain characters aren't allowed (\t\n\r@$%^&/|\\....)\n";
406  // Create label with the help text
407  new FXLabel(ParameterHelpDialog, help.str().c_str(), nullptr, GUIDesignLabelFrameInformation);
408  // Create horizontal separator
409  new FXHorizontalSeparator(ParameterHelpDialog, GUIDesignHorizontalSeparator);
410  // Create frame for OK Button
411  FXHorizontalFrame* myHorizontalFrameOKButton = new FXHorizontalFrame(ParameterHelpDialog, GUIDesignAuxiliarHorizontalFrame);
412  // Create Button Close (And two more horizontal frames to center it)
413  new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
414  new FXButton(myHorizontalFrameOKButton, "OK\t\tclose", GUIIconSubSys::getIcon(ICON_ACCEPT), ParameterHelpDialog, FXDialogBox::ID_ACCEPT, GUIDesignButtonOK);
415  new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
416  // Write Warning in console if we're in testing mode
417  WRITE_DEBUG("Opening Parameter help dialog");
418  // create Dialog
419  ParameterHelpDialog->create();
420  // show in the given position
421  ParameterHelpDialog->show(PLACEMENT_CURSOR);
422  // refresh APP
423  getApp()->refresh();
424  // open as modal dialog (will block all windows until stop() or stopModal() is called)
425  getApp()->runModalFor(ParameterHelpDialog);
426  // Write Warning in console if we're in testing mode
427  WRITE_DEBUG("Closing Parameter help dialog");
428  return 1;
429 }
430 
431 
433  SUMOSAXHandler(file),
434  myParametersOptionsParent(ParametersOptionsParent) {
435 }
436 
437 
439 
440 
441 void
443  // Obtain tag of element
444  SumoXMLTag tag = static_cast<SumoXMLTag>(element);
445  // only continue if tag is valid
446  if (tag != SUMO_TAG_NOTHING) {
447  // Call parse and build depending of tag
448  switch (tag) {
449  case SUMO_TAG_PARAM:
450  // Check that format of Parameter is correct
451  if (!attrs.hasAttribute(SUMO_ATTR_KEY)) {
452  WRITE_WARNING("Key of Parameter not defined");
453  } else if (!attrs.hasAttribute(SUMO_ATTR_VALUE)) {
454  WRITE_WARNING("Value of Parameter not defined");
455  } else {
456  // obtain Key and value
457  std::string key = attrs.getString(SUMO_ATTR_KEY);
458  std::string value = attrs.getString(SUMO_ATTR_VALUE);
459  // check that parsed values are correct
461  if (key.size() == 0) {
462  WRITE_WARNING("Key of Parameter cannot be empty");
463  } else {
464  WRITE_WARNING("Key '" + key + "' of Parameter contains invalid characters");
465  }
466  } else if (!SUMOXMLDefinitions::isValidParameterValue(value)) {
467  WRITE_WARNING("Value '" + value + "'of Parameter contains invalid characters");
468  } else {
469  // add parameter to vector of myParameterDialogParent
470  myParametersOptionsParent->myParameterDialogParent->myParametersValues->addParameter(std::make_pair(key, value));
471  }
472  }
473  break;
474  default:
475  break;
476  }
477  }
478 }
479 
480 // ---------------------------------------------------------------------------
481 // GNEParametersDialog - methods
482 // ---------------------------------------------------------------------------
483 
485  FXDialogBox(ParametersEditor->getFrameParent()->getViewNet()->getApp(), "Edit parameters", GUIDesignDialogBoxExplicitStretchable(400, 300)),
486  myParametersEditor(ParametersEditor),
487  myEditedParameters(ParametersEditor->getParametersVectorStr()),
488  myCopyOfParameters(ParametersEditor->getParametersVectorStr()) {
489  // set vehicle icon for this dialog
491  // create main frame
492  FXVerticalFrame* mainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
493  // create frame for Parameters and options
494  FXHorizontalFrame* horizontalFrameParametersAndOptions = new FXHorizontalFrame(mainFrame, GUIDesignAuxiliarFrame);
495  // create parameters values
496  myParametersValues = new ParametersValues(horizontalFrameParametersAndOptions, this);
497  // create parameters options
498  myParametersOptions = new ParametersOptions(horizontalFrameParametersAndOptions, this);
499  // add separator
500  new FXHorizontalSeparator(mainFrame, GUIDesignHorizontalSeparator);
501  // create dialog buttons bot centered
502  FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(mainFrame, GUIDesignHorizontalFrame);
503  new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
504  myAcceptButton = new FXButton(buttonsFrame, "accept\t\tclose", GUIIconSubSys::getIcon(ICON_ACCEPT), this, MID_GNE_ADDITIONALDIALOG_BUTTONACCEPT, GUIDesignButtonAccept);
505  myCancelButton = new FXButton(buttonsFrame, "cancel\t\tclose", GUIIconSubSys::getIcon(ICON_CANCEL), this, MID_GNE_ADDITIONALDIALOG_BUTTONCANCEL, GUIDesignButtonCancel);
506  myResetButton = new FXButton(buttonsFrame, "reset\t\tclose", GUIIconSubSys::getIcon(ICON_RESET), this, MID_GNE_ADDITIONALDIALOG_BUTTONRESET, GUIDesignButtonReset);
507  new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
508 }
509 
510 
512 
513 
514 long
515 GNEParametersDialog::onCmdAccept(FXObject*, FXSelector, void*) {
516  // check if all edited parameters are valid
517  for (const auto& i : myEditedParameters) {
518  if (i.first.empty()) {
519  // write warning if netedit is running in testing mode
520  WRITE_DEBUG("Opening FXMessageBox of type 'warning'");
521  // open warning Box
522  FXMessageBox::warning(getApp(), MBOX_OK, "Empty Parameter key", "%s", " Parameters with empty keys aren't allowed");
523  // write warning if netedit is running in testing mode
524  WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
525  return 1;
526  } else if (!SUMOXMLDefinitions::isValidParameterKey(i.first)) {
527  // write warning if netedit is running in testing mode
528  WRITE_DEBUG("Opening FXMessageBox of type 'warning'");
529  // open warning Box
530  FXMessageBox::warning(getApp(), MBOX_OK, "Invalid Parameter key", "%s", "There are keys of Parameters with invalid characters");
531  // write warning if netedit is running in testing mode
532  WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
533  return 1;
534  } else if (!SUMOXMLDefinitions::isValidParameterValue(i.second)) {
535  // write warning if netedit is running in testing mode
536  WRITE_DEBUG("Opening FXMessageBox of type 'warning'");
537  // open warning Box
538  FXMessageBox::warning(getApp(), MBOX_OK, "Invalid Parameter value", "%s", "There are values of Parameters with invalid characters");
539  // write warning if netedit is running in testing mode
540  WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
541  return 1;
542  }
543  }
544  // now check if there is duplicates parameters
545  std::vector<std::pair<std::string, std::string> > sortedParameters = myEditedParameters;
546  std::sort(sortedParameters.begin(), sortedParameters.end());
547  for (auto i = sortedParameters.begin(); i != sortedParameters.end(); i++) {
548  if (((i + 1) != sortedParameters.end()) && (i->first) == (i + 1)->first) {
549  // write warning if netedit is running in testing mode
550  WRITE_DEBUG("Opening FXMessageBox of type 'warning'");
551  // open warning Box
552  FXMessageBox::warning(getApp(), MBOX_OK, "Duplicated Parameters", "%s", " Parameters with the same Key aren't allowed");
553  // write warning if netedit is running in testing mode
554  WRITE_DEBUG("Closed FXMessageBox of type 'warning' with 'OK'");
555  return 1;
556  }
557  }
558  // set parameters in Parameters editor parents
560  // all ok, then close dialog
561  getApp()->stopModal(this, TRUE);
562  return 1;
563 }
564 
565 
566 long
567 GNEParametersDialog::onCmdCancel(FXObject*, FXSelector, void*) {
568  // restore copy of parameters
570  // Stop Modal
571  getApp()->stopModal(this, FALSE);
572  return 1;
573 }
574 
575 
576 long
577 GNEParametersDialog::onCmdReset(FXObject*, FXSelector, void*) {
578  // simply restore copy of parameters and continue editing
580  return 1;
581 }
582 
583 /****************************************************************************/
GNEParametersDialog::ParametersValues::onCmdSetAttribute
long onCmdSetAttribute(FXObject *, FXSelector, void *)
event when user change an attribute
Definition: GNEParametersDialog.cpp:145
GUIDesignAuxiliarHorizontalFrame
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:273
ICON_ACCEPT
Definition: GUIIcons.h:386
XMLSubSys::runParser
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything's ok.
Definition: XMLSubSys.cpp:112
SUMOSAXAttributes::hasAttribute
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
GUIDesignTextFieldNCol
#define GUIDesignTextFieldNCol
Num of column of text field.
Definition: GUIDesigns.h:42
GNEParametersDialog::ParametersValues::ParameterRow::keyField
FXTextField * keyField
TextField for parameter.
Definition: GNEParametersDialog.h:120
GNEParametersDialog::onCmdReset
long onCmdReset(FXObject *, FXSelector, void *)
event after press reset button
Definition: GNEParametersDialog.cpp:577
GNEParametersDialog::ParametersValues::ParameterRow::toogleAddButton
void toogleAddButton()
toogle add button
Definition: GNEParametersDialog.cpp:257
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:275
GNEParametersDialog::~GNEParametersDialog
~GNEParametersDialog()
destructor
Definition: GNEParametersDialog.cpp:511
GUIDesignButtonRectangular100x23
#define GUIDesignButtonRectangular100x23
button rectangular with thick and raise frame with a size of 100x23
Definition: GUIDesigns.h:65
SUMOSAXAttributes::getString
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
SUMOSAXHandler
SAX-handler base for SUMO-files.
Definition: SUMOSAXHandler.h:41
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
ICON_CLEANJUNCTIONS
Definition: GUIIcons.h:248
GNEParametersDialog::ParametersOptions::~ParametersOptions
~ParametersOptions()
destructor
Definition: GNEParametersDialog.cpp:298
GNEParametersDialog::ParametersOptions::myLoadButton
FXButton * myLoadButton
load button
Definition: GNEParametersDialog.h:219
SUMO_TAG_PARAM
parameter associated to a certain key
Definition: SUMOXMLDefinitions.h:169
GNEParametersDialog::ParametersValues
FOX-declaration.
Definition: GNEParametersDialog.h:54
ICON_SAVE
Definition: GUIIcons.h:48
GNEParametersDialog::ParametersOptions
Definition: GNEParametersDialog.h:149
GUIDesignButtonOK
#define GUIDesignButtonOK
Definition: GUIDesigns.h:98
GNEParametersDialog::ParametersValues::ParameterRow::isButtonInAddMode
bool isButtonInAddMode() const
check if remove button is in mode "add"
Definition: GNEParametersDialog.cpp:271
GNEParametersDialog::ParametersOptions::GNEParameterHandler::myStartElement
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: GNEParametersDialog.cpp:442
ICON_OPEN_CONFIG
Definition: GUIIcons.h:42
GUIDesignGroupBoxFrame100
#define GUIDesignGroupBoxFrame100
Group box design for elements of width 100.
Definition: GUIDesigns.h:245
SUMO_TAG_NOTHING
invalid tag
Definition: SUMOXMLDefinitions.h:43
GUIDesigns.h
GNEParametersDialog::myParametersValues
ParametersValues * myParametersValues
pointer to parameters values
Definition: GNEParametersDialog.h:253
GUIDesignTextField
#define GUIDesignTextField
Definition: GUIDesigns.h:33
MID_GNE_SET_ATTRIBUTE
attribute edited
Definition: GUIAppEnum.h:646
GNEParametersDialog::onCmdAccept
long onCmdAccept(FXObject *, FXSelector, void *)
Definition: GNEParametersDialog.cpp:515
GUIIconSubSys::getIcon
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
Definition: GUIIconSubSys.cpp:609
OutputDevice::close
void close()
Closes the device and removes it from the dictionary.
Definition: OutputDevice.cpp:207
GNEParametersDialog::ParametersOptions::GNEParameterHandler::GNEParameterHandler
GNEParameterHandler(ParametersOptions *ParametersOptionsParent, const std::string &file)
Constructor.
Definition: GNEParametersDialog.cpp:432
GNEParametersDialog::ParametersOptions::onCmdSortParameters
long onCmdSortParameters(FXObject *, FXSelector, void *)
event when user press sort parameters button
Definition: GNEParametersDialog.cpp:365
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:41
ICON_APP_TABLE
Definition: GUIIcons.h:113
MFXUtils::getFilename2Write
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString &currentFolder)
Returns the file name to write.
Definition: MFXUtils.cpp:83
ICON_REMOVE
Definition: GUIIcons.h:184
GNEParametersDialog::ParametersOptions::onCmdSaveParameters
long onCmdSaveParameters(FXObject *, FXSelector, void *)
event when user press save parameters button
Definition: GNEParametersDialog.cpp:331
OutputDevice::closeTag
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition: OutputDevice.cpp:253
GUIAppEnum.h
GNEParametersDialog::myEditedParameters
std::vector< std::pair< std::string, std::string > > myEditedParameters
current edited parameters
Definition: GNEParametersDialog.h:268
GUIDesignLabelFrameInformation
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:194
GNEParametersDialog::ParametersValues::clearParameters
void clearParameters()
clear all parameters
Definition: GNEParametersDialog.cpp:127
GNEParametersDialog::ParametersOptions::myClearButton
FXButton * myClearButton
clear button
Definition: GNEParametersDialog.h:216
MID_HELP
help button
Definition: GUIAppEnum.h:553
OutputDevice::writeAttr
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:255
GNEParametersDialog::ParametersOptions::GNEParameterHandler
load parameters from a filename
Definition: GNEParametersDialog.h:186
GNEParametersDialog::ParametersValues::~ParametersValues
~ParametersValues()
destructor
Definition: GNEParametersDialog.cpp:88
ICON_RELOAD
Definition: GUIIcons.h:47
GNEParametersDialog::ParametersValues::ParameterRow::disableRow
void disableRow()
disable row
Definition: GNEParametersDialog.cpp:221
SUMOXMLDefinitions::isValidParameterKey
static bool isValidParameterKey(const std::string &value)
whether the given string is a valid key for a parameter
Definition: SUMOXMLDefinitions.cpp:1041
GUIDesignButtonIcon
#define GUIDesignButtonIcon
button only with icon (23x23)
Definition: GUIDesigns.h:59
GNEParametersDialog::ParametersValues::ParameterRow
class for parameters Row
Definition: GNEParametersDialog.h:95
GNEParametersDialog::ParametersValues::ParameterRow::copyValues
void copyValues(const ParameterRow &other)
copy values of other parameter Row
Definition: GNEParametersDialog.cpp:277
MID_GNE_ADDITIONALDIALOG_BUTTONRESET
reset button
Definition: GUIAppEnum.h:973
GUIDesignHorizontalSeparator
#define GUIDesignHorizontalSeparator
Definition: GUIDesigns.h:321
GUIDesignHorizontalFrame
#define GUIDesignHorizontalFrame
Definition: GUIDesigns.h:224
ICON_ADD
Definition: GUIIcons.h:183
GNEViewNet.h
MID_GNE_ADDITIONALDIALOG_BUTTONACCEPT
accept button
Definition: GUIAppEnum.h:969
FXDEFMAP
FXDEFMAP(GNEParametersDialog) GNEParametersDialogMap[]
SUMOXMLDefinitions::isValidParameterValue
static bool isValidParameterValue(const std::string &value)
whether the given string is a valid value for a parameter
Definition: SUMOXMLDefinitions.cpp:1052
MID_GNE_PARAMETERS_SORT
sort parameters
Definition: GUIAppEnum.h:1074
GNEFrameAttributesModuls::ParametersEditor::setParameters
void setParameters(const std::vector< std::pair< std::string, std::string > > &parameters)
set parameters
Definition: GNEFrameAttributesModuls.cpp:2239
GUIDesignButtonReset
#define GUIDesignButtonReset
Reset Button.
Definition: GUIDesigns.h:107
ICON_RESET
Definition: GUIIcons.h:390
MID_GNE_PARAMETERS_CLEAR
clear parameters
Definition: GUIAppEnum.h:1072
GNEFrameAttributesModuls::ParametersEditor
Definition: GNEFrameAttributesModuls.h:554
MID_GNE_REMOVE_ATTRIBUTE
attribute removed
Definition: GUIAppEnum.h:644
GUIDesignGroupBoxFrameFill
#define GUIDesignGroupBoxFrameFill
Group box design extended over frame (X and Y)
Definition: GUIDesigns.h:242
GNEParametersDialog
Dialog for edit parameters.
Definition: GNEParametersDialog.h:44
gCurrentFolder
FXString gCurrentFolder
The folder used as last.
Definition: GUIIOGlobals.cpp:32
GNEParametersDialog.h
GNEParametersDialog::myParametersEditor
GNEFrameAttributesModuls::ParametersEditor * myParametersEditor
pointer to ParametersEditor
Definition: GNEParametersDialog.h:250
GUIDesignLabelCenterThick
#define GUIDesignLabelCenterThick
label extended over frame with thick and with text justify to center and height of 23
Definition: GUIDesigns.h:167
GNEParametersDialog::ParametersValues::ParameterRow::ParameterRow
ParameterRow(ParametersValues *ParametersValues, FXVerticalFrame *verticalFrameParent)
constructor
Definition: GNEParametersDialog.cpp:200
GNEParametersDialog::onCmdCancel
long onCmdCancel(FXObject *, FXSelector, void *)
event after press cancel button
Definition: GNEParametersDialog.cpp:567
GUIDesignButtonAccept
#define GUIDesignButtonAccept
Accept Button.
Definition: GUIDesigns.h:101
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:239
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
GUIDesignLabelThick100
#define GUIDesignLabelThick100
label with thick, text justify to left and size of 100x23
Definition: GUIDesigns.h:197
MID_GNE_ADDITIONALDIALOG_BUTTONCANCEL
cancel button
Definition: GUIAppEnum.h:971
OutputDevice::getDevice
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
Definition: OutputDevice.cpp:54
MID_GNE_PARAMETERS_LOAD
load parameters
Definition: GUIAppEnum.h:1068
GNEParametersDialog::ParametersValues::setParameters
void setParameters(const std::vector< std::pair< std::string, std::string > > &newParameters)
set parameters
Definition: GNEParametersDialog.cpp:111
GNEParametersDialog::ParametersOptions::mySaveButton
FXButton * mySaveButton
save button
Definition: GNEParametersDialog.h:222
GNEParametersDialog::myCopyOfParameters
const std::vector< std::pair< std::string, std::string > > myCopyOfParameters
Definition: GNEParametersDialog.h:271
ICON_CANCEL
Definition: GUIIcons.h:387
SUMO_ATTR_KEY
Definition: SUMOXMLDefinitions.h:408
SUMO_ATTR_VALUE
Definition: SUMOXMLDefinitions.h:779
GNEParametersDialog::myCancelButton
FXButton * myCancelButton
cancel button
Definition: GNEParametersDialog.h:262
GNEParametersDialog::ParametersOptions::GNEParameterHandler::~GNEParameterHandler
~GNEParameterHandler()
Destructor.
Definition: GNEParametersDialog.cpp:438
GNEParametersDialog::ParametersValues::onPaint
long onPaint(FXObject *o, FXSelector f, void *p)
Definition: GNEParametersDialog.cpp:135
GNEParametersDialog::ParametersValues::ParameterRow::~ParameterRow
~ParameterRow()
destructor
Definition: GNEParametersDialog.cpp:214
GNEParametersDialog::ParametersOptions::onCmdLoadParameters
long onCmdLoadParameters(FXObject *, FXSelector, void *)
Definition: GNEParametersDialog.cpp:302
GNEParametersDialog::myResetButton
FXButton * myResetButton
cancel button
Definition: GNEParametersDialog.h:265
GUIDesignDialogBoxExplicitStretchable
#define GUIDesignDialogBoxExplicitStretchable(width, height)
design for dialog box with specift width and height that can be stretched (But not shrinked)
Definition: GUIDesigns.h:448
GNEParametersDialog::ParametersOptions::ParametersOptions
ParametersOptions(FXHorizontalFrame *frame, GNEParametersDialog *ParameterDialogParent)
FOX-declaration.
Definition: GNEParametersDialog.cpp:286
GNEParametersDialog::ParametersOptions::onCmdHelpParameter
long onCmdHelpParameter(FXObject *, FXSelector, void *)
event when user press help parameters button
Definition: GNEParametersDialog.cpp:395
GUIDesignAuxiliarFrame
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frames used to pack another frames extended in all directions
Definition: GUIDesigns.h:270
GNEParametersDialog::ParametersOptions::onCmdClearParameters
long onCmdClearParameters(FXObject *, FXSelector, void *)
event when user press clear parameters button
Definition: GNEParametersDialog.cpp:357
GUIDesignButtonCancel
#define GUIDesignButtonCancel
Cancel Button.
Definition: GUIDesigns.h:104
config.h
GNEParametersDialog::ParametersValues::onCmdButtonPress
long onCmdButtonPress(FXObject *, FXSelector, void *)
event when user press a remove (or add) button
Definition: GNEParametersDialog.cpp:175
GNEParametersDialog::ParametersOptions::mySortButton
FXButton * mySortButton
sort button
Definition: GNEParametersDialog.h:213
GNEParametersDialog::ParametersValues::ParameterRow::valueField
FXTextField * valueField
TextField for value.
Definition: GNEParametersDialog.h:123
GNEParametersDialog::ParametersOptions::myHelpButton
FXButton * myHelpButton
help button
Definition: GNEParametersDialog.h:225
OutputDevice::writeXMLHeader
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.
Definition: OutputDevice.cpp:227
GNEParametersDialog::ParametersValues::addParameter
void addParameter(std::pair< std::string, std::string > newParameter)
add a single parameter
Definition: GNEParametersDialog.cpp:119
GNEParametersDialog::ParametersValues::ParameterRow::enableRow
void enableRow(const std::string &parameter, const std::string &value) const
enable rlow
Definition: GNEParametersDialog.cpp:233
GNEFrame.h
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:56
GNEParametersDialog::myAcceptButton
FXButton * myAcceptButton
accept button
Definition: GNEParametersDialog.h:259
ICON_GREENVEHICLE
Definition: GUIIcons.h:90
MID_GNE_PARAMETERS_SAVE
save parameters
Definition: GUIAppEnum.h:1070
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:277
WRITE_DEBUG
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:284
GNEParametersDialog::GNEParametersDialog
GNEParametersDialog(GNEFrameAttributesModuls::ParametersEditor *ParametersEditor)
Constructor.
Definition: GNEParametersDialog.cpp:484
GNEParametersDialog::ParametersValues::updateValues
void updateValues()
update values
Definition: GNEParametersDialog.cpp:92
ICON_HELP
Definition: GUIIcons.h:50
XMLSubSys.h
GUIDesignDialogBox
#define GUIDesignDialogBox
Definition: GUIDesigns.h:433
GNEParametersDialog::myParametersOptions
ParametersOptions * myParametersOptions
pointer to parameters options
Definition: GNEParametersDialog.h:256