75 myParameterDialogParent(parameterDialogParent) {
82 FXScrollWindow* scrollWindow =
new FXScrollWindow(
this, LAYOUT_FILL);
96 for (
const auto& newParameter : newParameters) {
97 addParameter(newParameter);
105 myParameterRows.back()->enableRow(newParameter.first, newParameter.second);
107 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
109 myParameterRows.back()->toogleAddButton();
116 for (
const auto& parameterRow : myParameterRows) {
120 myParameterRows.clear();
122 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
124 myParameterRows.back()->toogleAddButton();
128 const std::vector<GNEMultipleParametersDialog::ParametersValues::ParameterRow*>
130 return myParameterRows;
137 for (
const auto& row : myParameterRows) {
138 if (row->keyField->getText().text() == key) {
149 if (myParameterRows.size() > 0) {
150 myKeyLabel->setWidth(myParameterRows.front()->keyField->getWidth());
152 return FXGroupBox::onPaint(o, f, p);
159 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
160 if (myParameterRows.at(i)->keyField == obj) {
163 myParameterRows.at(i)->keyField->setTextColor(FXRGB(0, 0, 255));
164 myParameterRows.at(i)->valueChanged =
true;
166 myParameterRows.at(i)->keyField->setTextColor(FXRGB(255, 0, 0));
167 myParameterRows.at(i)->keyField->killFocus();
169 }
else if (myParameterRows.at(i)->valueField == obj) {
170 myParameterRows.at(i)->valueField->setTextColor(FXRGB(0, 0, 255));
171 myParameterRows.at(i)->valueChanged =
true;
181 if (myParameterRows.back()->button == obj) {
183 addParameter(std::make_pair(
"",
""));
187 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
188 if (myParameterRows.at(i)->button == obj) {
190 delete myParameterRows.at(i);
192 myParameterRows.erase(myParameterRows.begin() + i);
203 valueChanged(false) {
209 if (verticalFrameParent->id()) {
219 delete horizontalFrame;
226 keyField->setText(
"");
228 valueField->setText(
"");
229 valueField->disable();
238 keyField->setText(parameter.c_str());
240 keyField->setTextColor(FXRGB(0, 0, 0));
242 keyField->setTextColor(FXRGB(255, 0, 0));
246 valueField->setText(value.c_str());
247 valueField->enable();
257 keyField->setText(
"");
259 valueField->setText(
"");
260 valueField->disable();
276 keyField->setText(other.
keyField->getText());
277 valueField->setText(other.
valueField->getText());
302 FXFileDialog opendialog(
this,
"Open Parameter Template");
304 opendialog.setSelectMode(SELECTFILE_EXISTING);
305 opendialog.setPatternList(
" Parameter Template files (*.xml)\nAll files (*)");
309 if (opendialog.execute()) {
311 std::string file = opendialog.getFilename().text();
313 const int numberOfParametersbeforeLoad = (int)myParameterDialogParent->myParametersValues->getParameterRows().size();
317 WRITE_MESSAGE(
"Loading of Parameters From " + file +
" failed.");
320 WRITE_MESSAGE(
"Loaded " +
toString((
int)myParameterDialogParent->myParametersValues->getParameterRows().size() - numberOfParametersbeforeLoad) +
" Parameters.");
330 "Select name of the Parameter Template file",
".xml",
342 for (
const auto& row : myParameterDialogParent->myParametersValues->getParameterRows()) {
344 if (row != myParameterDialogParent->myParametersValues->getParameterRows().back()) {
365 myParameterDialogParent->myParametersValues->clearParameters();
373 std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
374 std::vector<std::string> emptyKeyValues;
376 for (
const auto& parameterRow : myParameterDialogParent->myParametersValues->getParameterRows()) {
378 if (!parameterRow->keyField->getText().empty()) {
379 nonEmptyKeyValues.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
380 }
else if (!parameterRow->valueField->getText().empty()) {
381 emptyKeyValues.push_back(parameterRow->valueField->getText().text());
385 std::sort(nonEmptyKeyValues.begin(), nonEmptyKeyValues.end());
387 std::sort(emptyKeyValues.begin(), emptyKeyValues.end());
389 for (
const auto& emptyKeyValue : emptyKeyValues) {
390 nonEmptyKeyValues.push_back(std::make_pair(
"", emptyKeyValue));
393 myParameterDialogParent->myParametersValues->setParameters(nonEmptyKeyValues);
401 FXDialogBox* ParameterHelpDialog =
new FXDialogBox(
this,
" Parameters Help",
GUIDesignDialogBox);
404 std::ostringstream help;
406 <<
"- Parameters are defined by a Key and a Value.\n"
407 <<
"- In Netedit can be defined using format key1=parameter1|key2=parameter2|...\n"
408 <<
" - Duplicated and empty Keys aren't valid.\n"
409 <<
" - Certain characters aren't allowed (\t\n\r@$%^&/|\\....)\n";
423 ParameterHelpDialog->create();
425 ParameterHelpDialog->show(PLACEMENT_CURSOR);
429 getApp()->runModalFor(ParameterHelpDialog);
438 myParametersOperationsParent(ParametersOperationsParent) {
462 if (key.size() == 0) {
465 WRITE_WARNING(
"Key '" + key +
"' of Parameter contains invalid characters");
467 }
else if (myParametersOperationsParent->myParameterDialogParent->myParametersValues->keyExist(key)) {
471 myParametersOperationsParent->myParameterDialogParent->myParametersValues->addParameter(std::make_pair(key, value));
493 return (myOnlyForExistentKeys->getCheck() == TRUE);
518 std::vector<std::pair<std::string, std::string> > parametersChanged;
520 std::vector<std::string> keepKeys;
526 keepKeys.push_back(parameterRow->keyField->getText().text());
528 if (parameterRow->valueChanged) {
529 if (parameterRow->keyField->getText().empty()) {
531 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
533 FXMessageBox::warning(getApp(), MBOX_OK,
"Empty Parameter key",
"%s",
"Parameters with empty keys aren't allowed");
535 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
539 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
541 FXMessageBox::warning(getApp(), MBOX_OK,
"Invalid Parameter key",
"%s",
"There are keys with invalid characters");
543 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
547 parametersChanged.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
552 std::sort(parametersChanged.begin(), parametersChanged.end());
554 for (
auto i = parametersChanged.begin(); i != parametersChanged.end(); i++) {
555 if (((i + 1) != parametersChanged.end()) && (i->first) == (i + 1)->first) {
557 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
559 FXMessageBox::warning(getApp(), MBOX_OK,
"Duplicated Parameters",
"%s",
"Parameters with the same Key aren't allowed");
561 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
566 undoList->
p_begin(
"change parameters");
570 AC->removeACParametersKeys(keepKeys, undoList);
572 for (
const auto& parameter : parametersChanged) {
576 AC->addACParameters(parameter.first, parameter.second, undoList);
583 getApp()->stopModal(
this, TRUE);
591 getApp()->stopModal(
this, FALSE);
599 std::map<std::string, std::vector<std::string> > keyValuesMap;
602 for (
const auto& keyAttribute : AC->getACParametersMap()) {
603 keyValuesMap[keyAttribute.first].push_back(keyAttribute.second);
607 std::vector<std::pair<std::string, std::string> > keyValues;
608 for (
const auto& keyAttribute : keyValuesMap) {
610 std::set<std::string> valuesNonDuplicated;
611 for (
const auto& value : keyAttribute.second) {
612 valuesNonDuplicated.insert(value);
616 for (
const auto& value : valuesNonDuplicated) {
617 values.append(value +
" ");
619 if (!values.empty()) {
623 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 wdth of 100
#define GUIDesignHorizontalSeparator
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frames used to pack another frames extended in all directions
#define GUIDesignHorizontalFrame
#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)
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ 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
GNEMultipleParametersDialog * myParameterDialogParent
pointer to Shape Frame Parent
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
bool onlyForExistentKeys() const
apply changes to all elements
~ParametersOptions()
destructor
ParametersOptions(FXVerticalFrame *frame, GNEMultipleParametersDialog *ParameterDialogParent)
constructor
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 rlow
void copyValues(const ParameterRow &other)
copy values of other parameter Row
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
void toogleAddButton()
toogle add button
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
GNEMultipleParametersDialog * myParameterDialogParent
pointer to ParameterDialog parent
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::ParametersEditorInspector *parametersEditorInspector)
Constructor for parameter editor inspector.
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
GNEInspectorFrame::ParametersEditorInspector * myParametersEditorInspector
FOX need this.
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
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.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
void close()
Closes the device and removes it from the dictionary.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
Encapsulated SAX-Attributes.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
SAX-handler base for SUMO-files.
static bool isValidParameterKey(const std::string &value)
whether the given string is a valid key for a parameter
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false)
Runs the given handler on the given file; returns if everything's ok.