80 FXScrollWindow* scrollWindow =
new FXScrollWindow(
this, LAYOUT_FILL);
94 for (
const auto& newParameter : newParameters) {
95 addParameter(newParameter);
103 myParameterRows.back()->enableRow(newParameter.first, newParameter.second);
105 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
107 myParameterRows.back()->toggleAddButton();
114 for (
const auto& parameterRow : myParameterRows) {
118 myParameterRows.clear();
120 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
122 myParameterRows.back()->toggleAddButton();
126const std::vector<GNEMultipleParametersDialog::ParametersValues::ParameterRow*>
128 return myParameterRows;
135 for (
const auto& row : myParameterRows) {
136 if (row->keyField->getText().text() == key) {
147 if (myParameterRows.size() > 0) {
148 myKeyLabel->setWidth(myParameterRows.front()->keyField->getWidth());
150 return FXGroupBox::onPaint(o, f, p);
157 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
158 if (myParameterRows.at(i)->keyField == obj) {
161 myParameterRows.at(i)->keyField->setTextColor(FXRGB(0, 0, 255));
162 myParameterRows.at(i)->valueChanged =
true;
164 myParameterRows.at(i)->keyField->setTextColor(FXRGB(255, 0, 0));
165 myParameterRows.at(i)->keyField->killFocus();
167 }
else if (myParameterRows.at(i)->valueField == obj) {
168 myParameterRows.at(i)->valueField->setTextColor(FXRGB(0, 0, 255));
169 myParameterRows.at(i)->valueChanged =
true;
179 if (myParameterRows.back()->button == obj) {
181 addParameter(std::make_pair(
"",
""));
185 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
186 if (myParameterRows.at(i)->button == obj) {
188 delete myParameterRows.at(i);
190 myParameterRows.erase(myParameterRows.begin() + i);
201 valueChanged(false) {
207 if (verticalFrameParent->id()) {
217 delete horizontalFrame;
224 keyField->setText(
"");
226 valueField->setText(
"");
227 valueField->disable();
236 keyField->setText(parameter.c_str());
238 keyField->setTextColor(FXRGB(0, 0, 0));
240 keyField->setTextColor(FXRGB(255, 0, 0));
244 valueField->setText(value.c_str());
245 valueField->enable();
255 keyField->setText(
"");
257 valueField->setText(
"");
258 valueField->disable();
274 keyField->setText(other.
keyField->getText());
275 valueField->setText(other.
valueField->getText());
284 myParameterDialogParent(ParameterDialogParent) {
300 FXFileDialog opendialog(
this,
TL(
"Open Parameter Template"));
302 opendialog.setSelectMode(SELECTFILE_EXISTING);
303 opendialog.setPatternList(
" Parameter Template files (*.xml,*.xml.gz)\nAll files (*)");
307 if (opendialog.execute()) {
309 std::string file = opendialog.getFilename().text();
311 const int numberOfParametersbeforeLoad = (int)myParameterDialogParent->myParametersValues->getParameterRows().size();
318 WRITE_MESSAGEF(
TL(
"Loaded % Parameters."),
toString((
int)myParameterDialogParent->myParametersValues->getParameterRows().size() - numberOfParametersbeforeLoad));
328 TL(
"Save Parameter Template file"),
".xml",
340 for (
const auto& row : myParameterDialogParent->myParametersValues->getParameterRows()) {
342 if (row != myParameterDialogParent->myParametersValues->getParameterRows().back()) {
363 myParameterDialogParent->myParametersValues->clearParameters();
371 std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
372 std::vector<std::string> emptyKeyValues;
374 for (
const auto& parameterRow : myParameterDialogParent->myParametersValues->getParameterRows()) {
376 if (!parameterRow->keyField->getText().empty()) {
377 nonEmptyKeyValues.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
378 }
else if (!parameterRow->valueField->getText().empty()) {
379 emptyKeyValues.push_back(parameterRow->valueField->getText().text());
383 std::sort(nonEmptyKeyValues.begin(), nonEmptyKeyValues.end());
385 std::sort(emptyKeyValues.begin(), emptyKeyValues.end());
387 for (
const auto& emptyKeyValue : emptyKeyValues) {
388 nonEmptyKeyValues.push_back(std::make_pair(
"", emptyKeyValue));
391 myParameterDialogParent->myParametersValues->setParameters(nonEmptyKeyValues);
399 FXDialogBox* ParameterHelpDialog =
new FXDialogBox(
this,
" Parameters Help",
GUIDesignDialogBox);
402 std::ostringstream help;
404 <<
TL(
"- Parameters are defined by a Key and a Value.\n")
405 <<
TL(
"- In Netedit can be defined using format key1=parameter1|key2=parameter2|...\n")
406 <<
TL(
" - Duplicated and empty Keys aren't valid.\n")
407 <<
TL(
" - Whitespace and certain characters aren't allowed (@$%^&/|\\....)\n");
421 ParameterHelpDialog->create();
423 ParameterHelpDialog->show(PLACEMENT_CURSOR);
427 getApp()->runModalFor(ParameterHelpDialog);
436 myParametersOperationsParent(ParametersOperationsParent) {
458 if (key.size() == 0) {
461 WRITE_WARNINGF(
TL(
"Key '%' of Parameter contains invalid characters"), key);
463 }
else if (myParametersOperationsParent->myParameterDialogParent->myParametersValues->keyExist(key)) {
467 myParametersOperationsParent->myParameterDialogParent->myParametersValues->addParameter(std::make_pair(key, value));
488 return (myOnlyForExistentKeys->getCheck() == TRUE);
511 if (inspectedElements.isInspectingElements()) {
515 std::vector<std::pair<std::string, std::string> > parametersChanged;
517 std::vector<std::string> keepKeys;
523 keepKeys.push_back(parameterRow->keyField->getText().text());
525 if (parameterRow->valueChanged) {
526 if (parameterRow->keyField->getText().empty()) {
528 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
530 FXMessageBox::warning(getApp(), MBOX_OK,
"Empty Parameter key",
"%s",
"Parameters with empty keys aren't allowed");
532 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
536 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
538 FXMessageBox::warning(getApp(), MBOX_OK,
"Invalid Parameter key",
"%s",
"There are keys with invalid characters");
540 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
544 parametersChanged.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
549 std::sort(parametersChanged.begin(), parametersChanged.end());
551 for (
auto i = parametersChanged.begin(); i != parametersChanged.end(); i++) {
552 if (((i + 1) != parametersChanged.end()) && (i->first) == (i + 1)->first) {
554 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
556 FXMessageBox::warning(getApp(), MBOX_OK,
"Duplicated Parameters",
"%s",
"Parameters with the same Key aren't allowed");
558 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
563 undoList->
begin(inspectedElements.getFirstAC(),
"change parameters");
565 for (
const auto& AC : inspectedElements.getACs()) {
567 AC->removeACParametersKeys(keepKeys, undoList);
569 for (
const auto& parameter : parametersChanged) {
573 AC->addACParameters(parameter.first, parameter.second, undoList);
581 getApp()->stopModal(
this, TRUE);
589 getApp()->stopModal(
this, FALSE);
597 std::map<std::string, std::vector<std::string> > keyValuesMap;
600 for (
const auto& keyAttribute : AC->getACParametersMap()) {
601 keyValuesMap[keyAttribute.first].push_back(keyAttribute.second);
605 std::vector<std::pair<std::string, std::string> > keyValues;
606 for (
const auto& keyAttribute : keyValuesMap) {
608 std::set<std::string> valuesNonDuplicated;
609 for (
const auto& value : keyAttribute.second) {
610 valuesNonDuplicated.insert(value);
614 for (
const auto& value : valuesNonDuplicated) {
615 values.append(value +
" ");
617 if (!values.empty()) {
621 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 GUIDesignTextFieldNCol
Num of column of text field.
#define GUIDesignButtonOK
#define GUIDesignAuxiliarVerticalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
#define GUIDesignLabelThick(justify)
label extended over frame with thick and with text justify to left
#define GUIDesignGroupBoxFrameFill
Group box design extended over frame (X and Y)
#define GUIDesignButtonReset
Reset Button.
#define GUIDesignHorizontalSeparator
#define GUIDesignButtonFixed(width)
button rectangular with thick and raise frame with the given width
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frame extended in all directions
#define GUIDesignLabelThickedFixed(width)
label thicked, icon before text, text centered and custom width
#define GUIDesignHorizontalFrame
Horizontal frame extended over frame parent with padding and spacing.
#define GUIDesignCheckButtonExtraHeight
checkButton placed in left position with double size
#define GUIDesignDialogBoxExplicitStretchable(width, height)
design for dialog box with specific width and height that can be stretched (But not shrunk)
#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_WARNINGF(...)
#define WRITE_MESSAGEF(...)
#define WRITE_WARNING(msg)
@ SUMO_TAG_PARAM
parameter associated to a certain key
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
GNEInspectorFrame * getInspectorFrameParent() const
get inspector frame parent
GNEViewNet * getViewNet() const
get view net
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(GNEFrameAttributeModules::ParametersEditor *parametersEditorInspector)
Constructor for parameter editor inspector.
FXButton * myAcceptButton
accept button
GNEFrameAttributeModules::ParametersEditor * myParametersEditor
FOX need this.
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...
const std::unordered_set< GNEAttributeCarrier * > & getACs() const
get hash table with all inspected ACs
GNEViewNetHelper::InspectedElements & getInspectedElements()
get inspected elements
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
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, const bool isExternal=false, const bool catchExceptions=true)
Runs the given handler on the given file; returns if everything's ok.