Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNESingleParametersDialog.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 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
23#include <netedit/GNENet.h>
24#include <netedit/GNEUndoList.h>
30#include <utils/xml/XMLSubSys.h>
31
33
34// ===========================================================================
35// FOX callback mapping
36// ===========================================================================
37
38FXDEFMAP(GNESingleParametersDialog) GNESingleParametersDialogMap[] = {
42 FXMAPFUNC(SEL_CHORE, FXDialogBox::ID_CANCEL, GNESingleParametersDialog::onCmdCancel),
43 FXMAPFUNC(SEL_TIMEOUT, FXDialogBox::ID_CANCEL, GNESingleParametersDialog::onCmdCancel),
44 FXMAPFUNC(SEL_COMMAND, FXDialogBox::ID_CANCEL, GNESingleParametersDialog::onCmdCancel),
45 FXMAPFUNC(SEL_CLOSE, 0, GNESingleParametersDialog::onCmdCancel),
46};
47
53
61
62// Object implementation
63FXIMPLEMENT(GNESingleParametersDialog, GNEDialog, GNESingleParametersDialogMap, ARRAYNUMBER(GNESingleParametersDialogMap))
64FXIMPLEMENT(GNESingleParametersDialog::ParametersValues, FXGroupBox, ParametersValuesMap, ARRAYNUMBER(ParametersValuesMap))
65FXIMPLEMENT(GNESingleParametersDialog::ParametersOperations, FXGroupBox, ParametersOperationsMap, ARRAYNUMBER(ParametersOperationsMap))
66
67// ===========================================================================
68// member method definitions
69// ===========================================================================
70
71// ---------------------------------------------------------------------------
72// GNESingleParametersDialog::ParametersValues - methods
73// ---------------------------------------------------------------------------
74
75GNESingleParametersDialog::ParametersValues::ParametersValues(FXHorizontalFrame* frame, const std::string& name) :
76 FXGroupBox(frame, name.c_str(), GUIDesignGroupBoxFrameFill) {
77 // create labels for keys and values
78 FXHorizontalFrame* horizontalFrameLabels = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
79 myKeyLabel = new FXLabel(horizontalFrameLabels, "key", nullptr, GUIDesignLabelThickedFixed(100));
80 new FXLabel(horizontalFrameLabels, "value", nullptr, GUIDesignLabelThick(JUSTIFY_NORMAL));
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
91void
92GNESingleParametersDialog::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
102void
103GNESingleParametersDialog::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()->toggleAddButton();
110}
111
112
113void
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()->toggleAddButton();
125}
126
127
128const std::vector<GNESingleParametersDialog::ParametersValues::ParameterRow*>
130 return myParameterRows;
131}
132
133
134bool
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
146long
147GNESingleParametersDialog::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
156long
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(GUIDesignTextColorBlack);
164 } else {
165 myParameterRows.at(i)->keyField->setTextColor(GUIDesignTextColorRed);
166 myParameterRows.at(i)->keyField->killFocus();
167 }
168 }
169 }
170 return 1;
171}
172
173
174long
176 // first check if add button was pressed
177 if (myParameterRows.back()->button == obj) {
178 // create new parameter
179 addParameter(std::make_pair("", ""));
180 return 1;
181 } else {
182 // in other case, button press was a "remove button". Find id and remove the Parameter
183 for (int i = 0; i < (int)myParameterRows.size(); i++) {
184 if (myParameterRows.at(i)->button == obj) {
185 // delete row
186 delete myParameterRows.at(i);
187 // just remove row
188 myParameterRows.erase(myParameterRows.begin() + i);
189 return 1;
190 }
191 }
192 }
193 // Nothing to do
194 return 1;
195}
196
197
199 horizontalFrame = new FXHorizontalFrame(verticalFrameParent, GUIDesignAuxiliarHorizontalFrame);
200 keyField = new FXTextField(horizontalFrame, GUIDesignTextFieldNCol, ParametersValues, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
201 valueField = new FXTextField(horizontalFrame, GUIDesignTextFieldNCol, ParametersValues, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
203 // only create elements if vertical frame was previously created
204 if (verticalFrameParent->id()) {
205 horizontalFrame->create();
206 }
207 // by defaults rows are disabled
208 disableRow();
209}
210
211
213 // simply delete horizontalFrame (rest of elements will be automatic deleted due they are children of horizontal frame)
214 delete horizontalFrame;
215}
216
217
218void
220 // hide all
221 keyField->setText("");
222 keyField->disable();
223 valueField->setText("");
224 valueField->disable();
225 button->disable();
226 button->setIcon(GUIIconSubSys::getIcon(GUIIcon::REMOVE));
227}
228
229
230void
231GNESingleParametersDialog::ParametersValues::ParameterRow::enableRow(const std::string& parameter, const std::string& value) const {
232 // restore color and enable key field
233 keyField->setText(parameter.c_str());
234 if (parameter.empty() || SUMOXMLDefinitions::isValidParameterKey(parameter)) {
235 keyField->setTextColor(GUIDesignTextColorBlack);
236 } else {
237 keyField->setTextColor(GUIDesignTextColorRed);
238 }
239 keyField->enable();
240 // restore color and enable value field
241 valueField->setText(value.c_str());
242 valueField->enable();
243 // enable button and set icon remove
244 button->enable();
245 button->setIcon(GUIIconSubSys::getIcon(GUIIcon::REMOVE));
246}
247
248
249void
251 // clear and disable parameter and value fields
252 keyField->setText("");
253 keyField->disable();
254 valueField->setText("");
255 valueField->disable();
256 // enable remove button and set "add" icon and focus
257 button->enable();
258 button->setIcon(GUIIconSubSys::getIcon(GUIIcon::ADD));
259 button->setFocus();
260}
261
262
263bool
267
268
269void
271 keyField->setText(other.keyField->getText());
272 valueField->setText(other.valueField->getText());
273}
274
275// ---------------------------------------------------------------------------
276// GNESingleParametersDialog::ParametersOperations - methods
277// ---------------------------------------------------------------------------
278
289
290
292
293
294long
296 // get the Additional file name
297 FXFileDialog opendialog(this, TL("Open Parameter Template"));
299 opendialog.setSelectMode(SELECTFILE_EXISTING);
300 opendialog.setPatternList(SUMOXMLDefinitions::XMLFileExtensions.getMultilineString().c_str());
301 if (gCurrentFolder.length() != 0) {
302 opendialog.setDirectory(gCurrentFolder);
303 }
304 if (opendialog.execute()) {
305 gCurrentFolder = opendialog.getDirectory();
306 std::string file = opendialog.getFilename().text();
307 // save current number of parameters
308 const int numberOfParametersbeforeLoad = (int)myParameterDialogParent->myParametersValues->getParameterRows().size();
309 // Create additional handler and run parser
310 GNEParameterHandler handler(this, file);
311 if (!XMLSubSys::runParser(handler, file, false)) {
312 WRITE_MESSAGEF(TL("Loading of Parameters From % failed."), file);
313 }
314 // show loaded attributes
315 WRITE_MESSAGEF(TL("Loaded % Parameters."), toString((int)myParameterDialogParent->myParametersValues->getParameterRows().size() - numberOfParametersbeforeLoad));
316 }
317 return 1;
318}
319
320
321long
323 // obtain file to save parameters
324 FXString file = MFXUtils::getFilename2Write(this,
325 TL("Save Parameter Template file"),
326 SUMOXMLDefinitions::XMLFileExtensions.getMultilineString().c_str(),
329 if (file == "") {
330 // None parameter file was selected, then stop function
331 return 1;
332 } else {
333 // open device
334 OutputDevice& device = OutputDevice::getDevice(file.text());
335 // write header
336 device.writeXMLHeader("Parameter", "parameter_file.xsd");
337 // iterate over all parameters and save it in the filename
338 for (const auto& row : myParameterDialogParent->myParametersValues->getParameterRows()) {
339 // write all except last
340 if (row != myParameterDialogParent->myParametersValues->getParameterRows().back()) {
341 // open tag
342 device.openTag(SUMO_TAG_PARAM);
343 // write key
344 device.writeAttr(SUMO_ATTR_KEY, row->keyField->getText().text());
345 // write value
346 device.writeAttr(SUMO_ATTR_VALUE, row->valueField->getText().text());
347 // close tag
348 device.closeTag();
349 }
350 }
351 // close device
352 device.close();
353 }
354 return 1;
355}
356
357
358long
360 // simply clear parameters from ParametersValues
361 myParameterDialogParent->myParametersValues->clearParameters();
362 return 1;
363}
364
365
366long
368 // declare two containers for parameters
369 std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
370 std::vector<std::string> emptyKeyValues;
371 // first extract empty values
372 for (const auto& parameterRow : myParameterDialogParent->myParametersValues->getParameterRows()) {
373 // check if key is empty
374 if (!parameterRow->keyField->getText().empty()) {
375 nonEmptyKeyValues.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
376 } else if (!parameterRow->valueField->getText().empty()) {
377 emptyKeyValues.push_back(parameterRow->valueField->getText().text());
378 }
379 }
380 // sort non-empty parameters
381 std::sort(nonEmptyKeyValues.begin(), nonEmptyKeyValues.end());
382 // sort non-empty parameters
383 std::sort(emptyKeyValues.begin(), emptyKeyValues.end());
384 // add values without key
385 for (const auto& emptyKeyValue : emptyKeyValues) {
386 nonEmptyKeyValues.push_back(std::make_pair("", emptyKeyValue));
387 }
388 // finally setparameters in myParametersValues
389 myParameterDialogParent->myParametersValues->setParameters(nonEmptyKeyValues);
390 return 1;
391}
392
393
394long
396 // set help text
397 std::ostringstream help;
398 help
399 << TL("- Parameters are defined by a Key and a Value.") << "\n"
400 << TL("- In Netedit can be defined using format key1=parameter1|key2=parameter2|...") << "\n"
401 << TL(" - Duplicated and empty Keys aren't valid.") << "\n"
402 << TL(" - Whitespace and certain characters aren't allowed (@$%^&/|\\....)");
403 // create and open dialog
404 GNEHelpBasicDialog(myParameterDialogParent->myAttributesEditor->getFrameParent()->getViewNet()->getViewParent()->getGNEAppWindows(),
405 TL("Parameters Help"), help);
406 return 1;
407}
408
409
411 SUMOSAXHandler(file),
412 myParametersOperationsParent(ParametersOperationsParent) {
413}
414
415
417
418
419void
421 // only continue if tag is valid
422 if (element != SUMO_TAG_NOTHING) {
423 // Call parse and build depending of tag
424 switch (element) {
425 case SUMO_TAG_PARAM:
426 // Check that format of Parameter is correct
427 if (!attrs.hasAttribute(SUMO_ATTR_KEY)) {
428 WRITE_WARNING(TL("Key of Parameter not defined"));
429 } else if (!attrs.hasAttribute(SUMO_ATTR_VALUE)) {
430 WRITE_WARNING(TL("Value of Parameter not defined"));
431 } else {
432 // obtain Key and value
433 std::string key = attrs.getString(SUMO_ATTR_KEY);
434 std::string value = attrs.getString(SUMO_ATTR_VALUE);
435 // check that parsed values are correct
437 if (key.size() == 0) {
438 WRITE_WARNING(TL("Key of Parameter cannot be empty"));
439 } else {
440 WRITE_WARNINGF(TL("Key '%' of Parameter contains invalid characters"), key);
441 }
442 } else if (myParametersOperationsParent->myParameterDialogParent->myParametersValues->keyExist(key)) {
443 WRITE_WARNINGF(TL("Key '%' already exist"), key);
444 } else {
445 // add parameter to vector of myParameterDialogParent
446 myParametersOperationsParent->myParameterDialogParent->myParametersValues->addParameter(std::make_pair(key, value));
447 }
448 }
449 break;
450 default:
451 break;
452 }
453 }
454}
455
456// ---------------------------------------------------------------------------
457// GNESingleParametersDialog - methods
458// ---------------------------------------------------------------------------
459
461 GNEDialog(attributesEditor->getFrameParent()->getViewNet()->getViewParent()->getGNEAppWindows(),
464 myAttributesEditor(attributesEditor) {
465 // create frame for Parameters and operations
466 FXHorizontalFrame* horizontalFrame = new FXHorizontalFrame(myContentFrame, GUIDesignAuxiliarFrame);
467 // create parameters values
468 myParametersValues = new ParametersValues(horizontalFrame, TL("Parameters"));
469 // create parameters operations
470 myParametersOperations = new ParametersOperations(horizontalFrame, this);
471 // fill myParametersValues
472 myParametersValues->setParameters(attributesEditor->getEditedAttributeCarriers().front()->getACParameters<std::vector<std::pair<std::string, std::string> > >());
473 // open modal dialog
474 openDialog();
475}
476
477
480 GNEDialog(applicationWindow, TL("Edit parameters"), GUIIcon::APP_TABLE,
481 GNEDialog::Buttons::ACCEPT_CANCEL_RESET, OpenType::MODAL,
482 GNEDialog::ResizeMode::RESIZABLE, 400, 300),
483 VTypeAttributeRow(VTypeAttributeRow) {
484 // create frame for Parameters and operations
485 FXHorizontalFrame* horizontalFrame = new FXHorizontalFrame(myContentFrame, GUIDesignAuxiliarFrame);
486 // create parameters values
487 myParametersValues = new ParametersValues(horizontalFrame, TL("Parameters"));
488 // create parameters operations
489 myParametersOperations = new ParametersOperations(horizontalFrame, this);
490 // fill myEditedParameters
492 // open modal dialog
493 openDialog();
494}
495
496
498 GNEDialog(attributeCarrier->getNet()->getViewNet()->getViewParent()->getGNEAppWindows(),
499 TL("Edit parameters"), GUIIcon::APP_TABLE, GNEDialog::Buttons::ACCEPT_CANCEL_RESET,
500 OpenType::MODAL, GNEDialog::ResizeMode::RESIZABLE, 400, 300),
501 myAttributeCarrier(attributeCarrier) {
502 // create frame for Parameters and operations
503 FXHorizontalFrame* horizontalFrame = new FXHorizontalFrame(myContentFrame, GUIDesignAuxiliarFrame);
504 // create parameters values
505 myParametersValues = new ParametersValues(horizontalFrame, TL("Parameters"));
506 // create parameters operations
507 myParametersOperations = new ParametersOperations(horizontalFrame, this);
508 // fill myEditedParameters
509 myParametersValues->setParameters(myAttributeCarrier->getACParameters<std::vector<std::pair<std::string, std::string> > >());
510 // open modal dialog
511 openDialog();
512}
513
514
516 NBLoadedSUMOTLDef* TLDef) :
517 GNEDialog(applicationWindow, TL("Edit parameters"), GUIIcon::APP_TABLE,
518 GNEDialog::Buttons::ACCEPT_CANCEL_RESET, OpenType::MODAL,
519 GNEDialog::ResizeMode::RESIZABLE, 400, 300),
520 myTLDef(TLDef) {
521 // create frame for Parameters and operations
522 FXHorizontalFrame* horizontalFrame = new FXHorizontalFrame(myContentFrame, GUIDesignAuxiliarFrame);
523 // create parameters values
524 myParametersValues = new ParametersValues(horizontalFrame, TL("Parameters"));
525 // create parameters operations
526 myParametersOperations = new ParametersOperations(horizontalFrame, this);
527 // transform parameters to a=b|c=d... format
528 std::vector<std::pair<std::string, std::string> > parametersStr;
529 // Generate a vector string using the following structure: "<key1,value1>, <key2, value2>,...
530 for (const auto& parameter : TLDef->getParametersMap()) {
531 parametersStr.push_back(std::make_pair(parameter.first, parameter.second));
532 }
533 // set parameters
534 myParametersValues->setParameters(parametersStr);
535 // open modal dialog
536 openDialog();
537}
538
539
541
542
543void
545 // nothing to do
546}
547
548
549long
550GNESingleParametersDialog::onCmdAccept(FXObject*, FXSelector, void*) {
551 // declare vector for parameters in stringvector format
552 std::vector<std::pair<std::string, std::string> > parameters;
553 // check if all edited parameters are valid
554 for (const auto& parameterRow : myParametersValues->getParameterRows()) {
555 // ignore last row
556 if (parameterRow != myParametersValues->getParameterRows().back()) {
557 if (parameterRow->keyField->getText().empty()) {
558 // open warning Box
559 GNEWarningBasicDialog(myApplicationWindow, TL("Empty Parameter key"), TL("Parameters with empty keys aren't allowed"));
560 return 1;
561 } else if (!SUMOXMLDefinitions::isValidParameterKey(parameterRow->keyField->getText().text())) {
562 // open warning Box
563 GNEWarningBasicDialog(myApplicationWindow, TL("Invalid Parameter key"), TL("There are keys with invalid characters"));
564 return 1;
565 }
566 // insert in parameters
567 parameters.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
568 }
569 }
570 // sort sortedParameters
571 std::sort(parameters.begin(), parameters.end());
572 // check if there is duplicated keys
573 for (auto i = parameters.begin(); i != parameters.end(); i++) {
574 if (((i + 1) != parameters.end()) && (i->first) == (i + 1)->first) {
575 // open warning Box
576 GNEWarningBasicDialog(myApplicationWindow, TL("Duplicated Parameters"), TL("Parameters with the same Key aren't allowed"));
577 return 1;
578 }
579 }
580 // set parameters in Parameters editor parents
581 if (myAttributesEditor) {
582 auto editedAC = myAttributesEditor->getEditedAttributeCarriers().front();
583 // set parameter in AC using undoList
584 myAttributesEditor->getFrameParent()->getViewNet()->getUndoList()->begin(editedAC, "change parameters");
585 editedAC->setACParameters(parameters, myAttributesEditor->getFrameParent()->getViewNet()->getUndoList());
587 } else if (VTypeAttributeRow) {
588 // set parameter in VTypeAttributeRow
589 VTypeAttributeRow->setParameters(parameters);
590 } else if (myAttributeCarrier) {
591 // set parameter in AC using undoList
595 } else if (myTLDef) {
597 for (const auto& parameter : parameters) {
598 myTLDef->setParameter(parameter.first, parameter.second);
599 }
600 }
601 // close dialog accepting
602 return closeDialogAccepting();
603}
604
605
606long
607GNESingleParametersDialog::onCmdReset(FXObject*, FXSelector, void*) {
608 // restore original parameters
609 if (myAttributesEditor) {
610 myParametersValues->setParameters(myAttributesEditor->getEditedAttributeCarriers().front()->getACParameters<std::vector<std::pair<std::string, std::string> > >());
611 } else if (VTypeAttributeRow) {
613 } else if (myAttributeCarrier) {
614 myParametersValues->setParameters(myAttributeCarrier->getACParameters<std::vector<std::pair<std::string, std::string> > >());
615 } else if (myTLDef) {
616 // transform parameters to a=b|c=d... format
617 std::vector<std::pair<std::string, std::string> > parametersStr;
618 // Generate a vector string using the following structure: "<key1,value1>, <key2, value2>,...
619 for (const auto& parameter : myTLDef->getParametersMap()) {
620 parametersStr.push_back(std::make_pair(parameter.first, parameter.second));
621 }
622 // set parameters
623 myParametersValues->setParameters(parametersStr);
624 }
625 return 1;
626}
627
628/****************************************************************************/
FXDEFMAP(GNESingleParametersDialog) GNESingleParametersDialogMap[]
@ MID_GNE_SET_ATTRIBUTE
attribute edited
Definition GUIAppEnum.h:991
@ MID_GNE_REMOVE_ATTRIBUTE
attribute removed
Definition GUIAppEnum.h:989
@ MID_GNE_BUTTON_CANCEL
cancel button
@ MID_GNE_BUTTON_RESET
reset button
@ MID_GNE_BUTTON_SAVE
save button
@ MID_GNE_BUTTON_SORT
sort button
@ MID_HELP
help button
Definition GUIAppEnum.h:653
@ MID_GNE_BUTTON_LOAD
load button
@ MID_GNE_BUTTON_CLEAR
clear button
@ MID_GNE_BUTTON_ACCEPT
accept button
#define GUIDesignGroupBoxFrame100
Group box design for elements of width 100.
Definition GUIDesigns.h:365
#define GUIDesignTextColorRed
red color (for invalid text)
Definition GUIDesigns.h:44
#define GUIDesignButtonIcon
button only with icon
Definition GUIDesigns.h:106
#define GUIDesignTextField
Definition GUIDesigns.h:74
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:418
#define GUIDesignTextFieldNCol
Num of column of text field.
Definition GUIDesigns.h:89
#define GUIDesignLabelThick(justify)
label extended over frame with thick and with text justify to left
Definition GUIDesigns.h:245
#define GUIDesignTextColorBlack
black color (for correct text)
Definition GUIDesigns.h:38
#define GUIDesignGroupBoxFrameFill
Group box design extended over frame (X and Y)
Definition GUIDesigns.h:362
#define GUIDesignButtonFixed(width)
button rectangular with thick and raise frame with the given width
Definition GUIDesigns.h:112
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frame extended in all directions
Definition GUIDesigns.h:403
#define GUIDesignLabelThickedFixed(width)
label thicked, icon before text, text centered and custom width
Definition GUIDesigns.h:248
FXString gCurrentFolder
The folder used as last.
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
@ CLEANJUNCTIONS
@ GREENVEHICLE
@ OPEN
open icons
@ SAVE
save icons
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:288
#define WRITE_MESSAGEF(...)
Definition MsgHandler.h:290
#define WRITE_WARNING(msg)
Definition MsgHandler.h:287
#define TL(string)
Definition MsgHandler.h:305
@ SUMO_TAG_NOTHING
invalid tag, must be the last one
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_KEY
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
The main window of Netedit.
void setACParameters(const std::string &parameters, GNEUndoList *undoList)
set parameters (string)
GNENet * getNet() const
get pointer to net
T getACParameters() const
get parameters
GNEFrame * getFrameParent() const
pointer to GNEFrame parent
const std::vector< GNEAttributeCarrier * > & getEditedAttributeCarriers() const
get edited attribute carriers
FXVerticalFrame * myContentFrame
content frame
Definition GNEDialog.h:136
GNEApplicationWindow * myApplicationWindow
FOX needs this.
Definition GNEDialog.h:133
long closeDialogAccepting()
close dialog accepting the changes
OpenType
Open dialog type.
Definition GNEDialog.h:56
void openDialog()
open dialog
virtual long onCmdCancel(FXObject *, FXSelector, void *)
called when cancel or no button is pressed (can be reimplemented in children)
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:152
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
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 onCmdSortParameters(FXObject *, FXSelector, void *)
event when user press sort parameters button
long onCmdHelpParameter(FXObject *, FXSelector, void *)
event when user press help parameters button
bool isButtonInAddMode() const
check if remove button is in mode "add"
ParameterRow(ParametersValues *ParametersValues, FXVerticalFrame *verticalFrameParent)
constructor
void copyValues(const ParameterRow &other)
copy values of other parameter Row
void enableRow(const std::string &parameter, const std::string &value) const
enable row
long onPaint(FXObject *o, FXSelector f, void *p)
long onCmdSetAttribute(FXObject *, FXSelector, void *)
event when user change an attribute
const std::vector< ParameterRow * > getParameterRows() const
get vector with the ParameterRows
void setParameters(const std::vector< std::pair< std::string, std::string > > &newParameters)
set parameters
bool keyExist(const std::string &key) const
check if given key exist already
long onCmdButtonPress(FXObject *, FXSelector, void *)
event when user press a remove (or add) button
void addParameter(std::pair< std::string, std::string > newParameter)
add a single parameter
void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)
run internal test
ParametersValues * myParametersValues
pointer to parameters values
long onCmdReset(FXObject *, FXSelector, void *)
event after press reset button
GNEVehicleTypeDialog::VTypeAttributes::VTypeAttributeRow * VTypeAttributeRow
pointer to VTypeAttributeRow
GNESingleParametersDialog(GNEAttributesEditorType *attributesEditor)
Constructor for attributes editor.
ParametersOperations * myParametersOperations
pointer to parameters operations
GNEAttributeCarrier * myAttributeCarrier
pointer to GNEAttributeCarrier
NBLoadedSUMOTLDef * myTLDef
pointer to TLDef
GNEAttributesEditorType * myAttributesEditor
FOX need this.
long onCmdAccept(FXObject *, FXSelector, void *)
event after press accept button
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
class used for represent rows with Vehicle Type parameters
std::vector< std::pair< std::string, std::string > > getParametersVectorStr() const
get parameters as vector of strings
void setParameters(const std::vector< std::pair< std::string, std::string > > &parameters)
set parameters
GNEUndoList * getUndoList() const
get the undoList object
static FXButton * buildFXButton(FXComposite *p, const std::string &text, const std::string &tip, const std::string &help, FXIcon *ic, FXObject *tgt, FXSelector sel, FXuint opts=BUTTON_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
build button
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
dialog arguments, used for certain modal dialogs that can not be edited using tab
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extensions, FXIcon *icon, FXString &currentFolder)
Returns the file name to write.
Definition MFXUtils.cpp:116
A loaded (complete) traffic light logic.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
void close()
Closes the device and removes it from the dictionary.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >(), bool includeConfig=true)
Writes an XML header with optional configuration.
void clearParameter()
Clears the parameter map.
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
SAX-handler base for SUMO-files.
static StringBijection< XMLFileExtension > XMLFileExtensions
XML file Extensions.
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, const bool isExternal=false, const bool catchExceptions=true)
Runs the given handler on the given file; returns if everything's ok.
Definition json.hpp:4471