79 FXScrollWindow* scrollWindow =
new FXScrollWindow(
this, LAYOUT_FILL);
93 for (
const auto& newParameter : newParameters) {
94 addParameter(newParameter);
102 myParameterRows.back()->enableRow(newParameter.first, newParameter.second);
104 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
106 myParameterRows.back()->toggleAddButton();
113 for (
const auto& parameterRow : myParameterRows) {
117 myParameterRows.clear();
119 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
121 myParameterRows.back()->toggleAddButton();
125const std::vector<GNEMultipleParametersDialog::ParametersValues::ParameterRow*>
127 return myParameterRows;
134 for (
const auto& row : myParameterRows) {
135 if (row->keyField->getText().text() == key) {
146 if (myParameterRows.size() > 0) {
147 myKeyLabel->setWidth(myParameterRows.front()->keyField->getWidth());
149 return FXGroupBox::onPaint(o, f, p);
156 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
157 if (myParameterRows.at(i)->keyField == obj) {
160 myParameterRows.at(i)->keyField->setTextColor(FXRGB(0, 0, 255));
161 myParameterRows.at(i)->valueChanged =
true;
163 myParameterRows.at(i)->keyField->setTextColor(FXRGB(255, 0, 0));
164 myParameterRows.at(i)->keyField->killFocus();
166 }
else if (myParameterRows.at(i)->valueField == obj) {
167 myParameterRows.at(i)->valueField->setTextColor(FXRGB(0, 0, 255));
168 myParameterRows.at(i)->valueChanged =
true;
178 if (myParameterRows.back()->button == obj) {
180 addParameter(std::make_pair(
"",
""));
184 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
185 if (myParameterRows.at(i)->button == obj) {
187 delete myParameterRows.at(i);
189 myParameterRows.erase(myParameterRows.begin() + i);
200 valueChanged(false) {
206 if (verticalFrameParent->id()) {
216 delete horizontalFrame;
223 keyField->setText(
"");
225 valueField->setText(
"");
226 valueField->disable();
235 keyField->setText(parameter.c_str());
237 keyField->setTextColor(FXRGB(0, 0, 0));
239 keyField->setTextColor(FXRGB(255, 0, 0));
243 valueField->setText(value.c_str());
244 valueField->enable();
254 keyField->setText(
"");
256 valueField->setText(
"");
257 valueField->disable();
273 keyField->setText(other.
keyField->getText());
274 valueField->setText(other.
valueField->getText());
283 myParameterDialogParent(ParameterDialogParent) {
299 FXFileDialog opendialog(
this,
TL(
"Open Parameter Template"));
301 opendialog.setSelectMode(SELECTFILE_EXISTING);
302 opendialog.setPatternList(
" Parameter Template files (*.xml,*.xml.gz)\nAll files (*)");
306 if (opendialog.execute()) {
308 std::string file = opendialog.getFilename().text();
310 const int numberOfParametersbeforeLoad = (int)myParameterDialogParent->myParametersValues->getParameterRows().size();
314 WRITE_MESSAGE(
"Loading of Parameters From " + file +
" failed.");
317 WRITE_MESSAGE(
"Loaded " +
toString((
int)myParameterDialogParent->myParametersValues->getParameterRows().size() - numberOfParametersbeforeLoad) +
" Parameters.");
327 TL(
"Save Parameter Template file"),
".xml",
339 for (
const auto& row : myParameterDialogParent->myParametersValues->getParameterRows()) {
341 if (row != myParameterDialogParent->myParametersValues->getParameterRows().back()) {
362 myParameterDialogParent->myParametersValues->clearParameters();
370 std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
371 std::vector<std::string> emptyKeyValues;
373 for (
const auto& parameterRow : myParameterDialogParent->myParametersValues->getParameterRows()) {
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());
382 std::sort(nonEmptyKeyValues.begin(), nonEmptyKeyValues.end());
384 std::sort(emptyKeyValues.begin(), emptyKeyValues.end());
386 for (
const auto& emptyKeyValue : emptyKeyValues) {
387 nonEmptyKeyValues.push_back(std::make_pair(
"", emptyKeyValue));
390 myParameterDialogParent->myParametersValues->setParameters(nonEmptyKeyValues);
398 FXDialogBox* ParameterHelpDialog =
new FXDialogBox(
this,
" Parameters Help",
GUIDesignDialogBox);
401 std::ostringstream help;
403 <<
TL(
"- Parameters are defined by a Key and a Value.\n")
404 <<
TL(
"- In Netedit can be defined using format key1=parameter1|key2=parameter2|...\n")
405 <<
TL(
" - Duplicated and empty Keys aren't valid.\n")
406 <<
TL(
" - Whitespace and certain characters aren't allowed (@$%^&/|\\....)\n");
420 ParameterHelpDialog->create();
422 ParameterHelpDialog->show(PLACEMENT_CURSOR);
426 getApp()->runModalFor(ParameterHelpDialog);
435 myParametersOperationsParent(ParametersOperationsParent) {
457 if (key.size() == 0) {
460 WRITE_WARNING(
"Key '" + key +
"' of Parameter contains invalid characters");
462 }
else if (myParametersOperationsParent->myParameterDialogParent->myParametersValues->keyExist(key)) {
466 myParametersOperationsParent->myParameterDialogParent->myParametersValues->addParameter(std::make_pair(key, value));
487 return (myOnlyForExistentKeys->getCheck() == TRUE);
510 if (ACs.size() > 0) {
514 std::vector<std::pair<std::string, std::string> > parametersChanged;
516 std::vector<std::string> keepKeys;
522 keepKeys.push_back(parameterRow->keyField->getText().text());
524 if (parameterRow->valueChanged) {
525 if (parameterRow->keyField->getText().empty()) {
527 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
529 FXMessageBox::warning(getApp(), MBOX_OK,
"Empty Parameter key",
"%s",
"Parameters with empty keys aren't allowed");
531 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
535 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
537 FXMessageBox::warning(getApp(), MBOX_OK,
"Invalid Parameter key",
"%s",
"There are keys with invalid characters");
539 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
543 parametersChanged.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
548 std::sort(parametersChanged.begin(), parametersChanged.end());
550 for (
auto i = parametersChanged.begin(); i != parametersChanged.end(); i++) {
551 if (((i + 1) != parametersChanged.end()) && (i->first) == (i + 1)->first) {
553 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
555 FXMessageBox::warning(getApp(), MBOX_OK,
"Duplicated Parameters",
"%s",
"Parameters with the same Key aren't allowed");
557 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
562 undoList->
begin(ACs.front()->getTagProperty().getGUIIcon(),
"change parameters");
564 for (
const auto& AC : ACs) {
566 AC->removeACParametersKeys(keepKeys, undoList);
568 for (
const auto& parameter : parametersChanged) {
572 AC->addACParameters(parameter.first, parameter.second, undoList);
580 getApp()->stopModal(
this, TRUE);
588 getApp()->stopModal(
this, FALSE);
596 std::map<std::string, std::vector<std::string> > keyValuesMap;
599 for (
const auto& keyAttribute : AC->getACParametersMap()) {
600 keyValuesMap[keyAttribute.first].push_back(keyAttribute.second);
604 std::vector<std::pair<std::string, std::string> > keyValues;
605 for (
const auto& keyAttribute : keyValuesMap) {
607 std::set<std::string> valuesNonDuplicated;
608 for (
const auto& value : keyAttribute.second) {
609 valuesNonDuplicated.insert(value);
613 for (
const auto& value : valuesNonDuplicated) {
614 values.append(value +
" ");
616 if (!values.empty()) {
620 keyValues.push_back(std::make_pair(keyAttribute.first, values));
FXDEFMAP(GNEMultipleParametersDialog) GNEMultipleParametersDialogMap[]
@ MID_GNE_SET_ATTRIBUTE
attribute edited
@ MID_GNE_REMOVE_ATTRIBUTE
attribute removed
@ 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_GNE_BUTTON_LOAD
load button
@ MID_GNE_BUTTON_CLEAR
clear button
@ MID_GNE_BUTTON_ACCEPT
accept button
@ MID_GNE_SET_ATTRIBUTE_BOOL
bool attribute edited
#define GUIDesignGroupBoxFrame100
Group box design for elements of width 100.
#define GUIDesignButtonIcon
button only with icon
#define GUIDesignButtonAccept
Accept Button.
#define GUIDesignButtonCancel
Cancel Button.
#define GUIDesignTextField
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
#define GUIDesignDialogBox
#define GUIDesignButtonRectangular100
button rectangular with thick and raise frame with a width of 100
#define GUIDesignTextFieldNCol
Num of column of text field.
#define GUIDesignButtonOK
#define GUIDesignAuxiliarVerticalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
#define GUIDesignLabelCenterThick
label extended over frame with thick and with text justify to center
#define GUIDesignGroupBoxFrameFill
Group box design extended over frame (X and Y)
#define GUIDesignButtonReset
Reset Button.
#define GUIDesignLabelThick100
label with thick, text justify to left and width of 100
#define GUIDesignHorizontalSeparator
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frames used to pack another frames extended in all directions
#define GUIDesignHorizontalFrame
Horizontal frame extended over frame parent.
#define GUIDesignCheckButtonExtraHeight
checkButton placed in left position with double size
#define GUIDesignDialogBoxExplicitStretchable(width, height)
design for dialog box with specift width and height that can be stretched (But not shrinked)
#define GUIDesignLabelIconThick
label squared over frame with thick and with text justify to center
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
FXString gCurrentFolder
The folder used as last.
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
@ SUMO_TAG_PARAM
parameter associated to a certain key
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
GNEViewNet * getViewNet() const
get view net
GNEInspectorFrame * getInspectorFrameParent() const
get inspector frame parent
GNEParameterHandler(ParametersOperations *ParametersOperationsParent, const std::string &file)
Constructor.
~GNEParameterHandler()
Destructor.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
long onCmdLoadParameters(FXObject *, FXSelector, void *)
FXButton * mySortButton
sort 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
FXButton * myClearButton
clear button
long onCmdSaveParameters(FXObject *, FXSelector, void *)
event when user press save parameters button
long onCmdClearParameters(FXObject *, FXSelector, void *)
event when user press clear parameters button
~ParametersOperations()
destructor
FXButton * myHelpButton
help button
ParametersOperations(FXVerticalFrame *frame, GNEMultipleParametersDialog *ParameterDialogParent)
FOX-declaration.
FXButton * myLoadButton
load button
FXButton * mySaveButton
save button
FXCheckButton * myOnlyForExistentKeys
apply changes only for existent keys
ParametersOptions(FXVerticalFrame *frame)
constructor
bool onlyForExistentKeys() const
apply changes to all elements
~ParametersOptions()
destructor
FXButton * button
Button for add or remove row.
FXTextField * valueField
TextField for value.
void enableRow(const std::string ¶meter, const std::string &value) const
enable row
void copyValues(const ParameterRow &other)
copy values of other parameter Row
void toggleAddButton()
toggle add button
FXHorizontalFrame * horizontalFrame
frame in which elements of ParameterRow are placed
bool isButtonInAddMode() const
check if remove button is in mode "add"
ParameterRow(ParametersValues *ParametersValues, FXVerticalFrame *verticalFrameParent)
constructor
void disableRow()
disable row
FXTextField * keyField
TextField for parameter.
~ParameterRow()
destructor
bool keyExist(const std::string &key) const
check if given key exist already
long onPaint(FXObject *o, FXSelector f, void *p)
void setParameters(const std::vector< std::pair< std::string, std::string > > &newParameters)
set parameters
const std::vector< ParameterRow * > getParameterRows() const
get vector with the ParameterRows
long onCmdSetAttribute(FXObject *, FXSelector, void *)
event when user change an attribute
void addParameter(std::pair< std::string, std::string > newParameter)
add a single parameter
void clearParameters()
clear all parameters
~ParametersValues()
destructor
long onCmdButtonPress(FXObject *, FXSelector, void *)
event when user press a remove (or add) button
Dialog for edit parameters.
ParametersOperations * myParametersOperations
pointer to parameters operations
~GNEMultipleParametersDialog()
destructor
long onCmdAccept(FXObject *, FXSelector, void *)
long onCmdCancel(FXObject *, FXSelector, void *)
event after press cancel button
FXButton * myCancelButton
cancel button
GNEMultipleParametersDialog(GNEInspectorFrame::ParametersEditor *parametersEditorInspector)
Constructor for parameter editor inspector.
GNEInspectorFrame::ParametersEditor * myParametersEditor
FOX need this.
FXButton * myAcceptButton
accept button
ParametersOptions * myParametersOptions
pointer to parameters options
ParametersValues * myParametersValues
pointer to parameters values
long onCmdReset(FXObject *, FXSelector, void *)
event after press reset button
FXButton * myResetButton
cancel button
void constructor()
auxiliar constructor
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...
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 ¤tFolder)
Returns the file name to write.
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.
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
SAX-handler base for SUMO-files.
static bool isValidParameterKey(const std::string &value)
whether the given string is a valid key for a parameter
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false)
Runs the given handler on the given file; returns if everything's ok.