62 FXIMPLEMENT(
GNESingleParametersDialog, FXDialogBox, GNESingleParametersDialogMap, ARRAYNUMBER(GNESingleParametersDialogMap))
81 FXScrollWindow* scrollWindow =
new FXScrollWindow(
this, LAYOUT_FILL);
95 for (
const auto& newParameter : newParameters) {
96 addParameter(newParameter);
104 myParameterRows.back()->enableRow(newParameter.first, newParameter.second);
106 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
108 myParameterRows.back()->toggleAddButton();
115 for (
const auto& parameterRow : myParameterRows) {
119 myParameterRows.clear();
121 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
123 myParameterRows.back()->toggleAddButton();
127 const std::vector<GNESingleParametersDialog::ParametersValues::ParameterRow*>
129 return myParameterRows;
136 for (
const auto& row : myParameterRows) {
137 if (row->keyField->getText().text() == key) {
148 if (myParameterRows.size() > 0) {
149 myKeyLabel->setWidth(myParameterRows.front()->keyField->getWidth());
151 return FXGroupBox::onPaint(o, f, p);
158 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
159 if (myParameterRows.at(i)->keyField == obj) {
162 myParameterRows.at(i)->keyField->setTextColor(FXRGB(0, 0, 0));
164 myParameterRows.at(i)->keyField->setTextColor(FXRGB(255, 0, 0));
165 myParameterRows.at(i)->keyField->killFocus();
176 if (myParameterRows.back()->button == obj) {
178 addParameter(std::make_pair(
"",
""));
182 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
183 if (myParameterRows.at(i)->button == obj) {
185 delete myParameterRows.at(i);
187 myParameterRows.erase(myParameterRows.begin() + i);
203 if (verticalFrameParent->id()) {
204 horizontalFrame->create();
213 delete horizontalFrame;
220 keyField->setText(
"");
222 valueField->setText(
"");
223 valueField->disable();
232 keyField->setText(parameter.c_str());
234 keyField->setTextColor(FXRGB(0, 0, 0));
236 keyField->setTextColor(FXRGB(255, 0, 0));
240 valueField->setText(value.c_str());
241 valueField->enable();
251 keyField->setText(
"");
253 valueField->setText(
"");
254 valueField->disable();
270 keyField->setText(other.
keyField->getText());
271 valueField->setText(other.
valueField->getText());
280 myParameterDialogParent(ParameterDialogParent) {
296 FXFileDialog opendialog(
this,
"Open Parameter Template");
298 opendialog.setSelectMode(SELECTFILE_EXISTING);
299 opendialog.setPatternList(
" Parameter Template files (*.xml)\nAll files (*)");
303 if (opendialog.execute()) {
305 std::string file = opendialog.getFilename().text();
307 const int numberOfParametersbeforeLoad = (int)myParameterDialogParent->myParametersValues->getParameterRows().size();
311 WRITE_MESSAGE(
"Loading of Parameters From " + file +
" failed.");
314 WRITE_MESSAGE(
"Loaded " +
toString((
int)myParameterDialogParent->myParametersValues->getParameterRows().size() - numberOfParametersbeforeLoad) +
" Parameters.");
324 "Save Parameter Template file",
".xml",
336 for (
const auto& row : myParameterDialogParent->myParametersValues->getParameterRows()) {
338 if (row != myParameterDialogParent->myParametersValues->getParameterRows().back()) {
359 myParameterDialogParent->myParametersValues->clearParameters();
367 std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
368 std::vector<std::string> emptyKeyValues;
370 for (
const auto& parameterRow : myParameterDialogParent->myParametersValues->getParameterRows()) {
372 if (!parameterRow->keyField->getText().empty()) {
373 nonEmptyKeyValues.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
374 }
else if (!parameterRow->valueField->getText().empty()) {
375 emptyKeyValues.push_back(parameterRow->valueField->getText().text());
379 std::sort(nonEmptyKeyValues.begin(), nonEmptyKeyValues.end());
381 std::sort(emptyKeyValues.begin(), emptyKeyValues.end());
383 for (
const auto& emptyKeyValue : emptyKeyValues) {
384 nonEmptyKeyValues.push_back(std::make_pair(
"", emptyKeyValue));
387 myParameterDialogParent->myParametersValues->setParameters(nonEmptyKeyValues);
395 FXDialogBox* ParameterHelpDialog =
new FXDialogBox(
this,
" Parameters Help",
GUIDesignDialogBox);
398 std::ostringstream help;
400 <<
"- Parameters are defined by a Key and a Value.\n"
401 <<
"- In Netedit can be defined using format key1=parameter1|key2=parameter2|...\n"
402 <<
" - Duplicated and empty Keys aren't valid.\n"
403 <<
" - Certain characters aren't allowed (\t\n\r@$%^&/|\\....)\n";
417 ParameterHelpDialog->create();
419 ParameterHelpDialog->show(PLACEMENT_CURSOR);
423 getApp()->runModalFor(ParameterHelpDialog);
432 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));
496 myGenericDataAttributes(nullptr),
497 myParametersEditor(parametersEditor),
498 VTypeAttributeRow(nullptr),
499 myAttributeCarrier(nullptr),
513 myGenericDataAttributes(nullptr),
514 myParametersEditor(nullptr),
515 VTypeAttributeRow(VTypeAttributeRow),
516 myAttributeCarrier(nullptr),
527 myGenericDataAttributes(nullptr),
528 myParametersEditor(nullptr),
529 VTypeAttributeRow(nullptr),
530 myAttributeCarrier(attributeCarrier),
541 myGenericDataAttributes(nullptr),
542 myParametersEditor(nullptr),
543 VTypeAttributeRow(nullptr),
544 myAttributeCarrier(nullptr),
549 std::vector<std::pair<std::string, std::string> > parametersStr;
552 parametersStr.push_back(std::make_pair(parameter.first, parameter.second));
565 std::vector<std::pair<std::string, std::string> > parameters;
570 if (parameterRow->keyField->getText().empty()) {
572 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
574 FXMessageBox::warning(getApp(), MBOX_OK,
"Empty Parameter key",
"%s",
"Parameters with empty keys aren't allowed");
576 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
580 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
582 FXMessageBox::warning(getApp(), MBOX_OK,
"Invalid Parameter key",
"%s",
"There are keys with invalid characters");
584 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
588 parameters.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
592 std::sort(parameters.begin(), parameters.end());
594 for (
auto i = parameters.begin(); i != parameters.end(); i++) {
595 if (((i + 1) != parameters.end()) && (i->first) == (i + 1)->first) {
597 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
599 FXMessageBox::warning(getApp(), MBOX_OK,
"Duplicated Parameters",
"%s",
"Parameters with the same Key aren't allowed");
601 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
626 std::map<std::string, std::string> parametersMap;
628 for (
const auto& parameter : parameters) {
629 parametersMap[parameter.first] = parameter.second;
635 getApp()->stopModal(
this, TRUE);
643 getApp()->stopModal(
this, FALSE);
662 std::vector<std::pair<std::string, std::string> > parametersStr;
665 parametersStr.push_back(std::make_pair(parameter.first, parameter.second));
FXDEFMAP(GNESingleParametersDialog) GNESingleParametersDialogMap[]
@ 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
#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 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
#define GUIDesignDialogBoxExplicitStretchable(width, height)
design for dialog box with specift width and height that can be stretched (But not shrinked)
#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_NOTHING
invalid tag
@ SUMO_TAG_PARAM
parameter associated to a certain key
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void setACParameters(const std::string ¶meters, GNEUndoList *undoList)
set parameters (string)
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * getNet() const
get pointer to net
T getACParameters() const
get parameters
std::vector< std::pair< std::string, std::string > > getParameters() const
get parameters as vector of strings
void setParameters(const std::vector< std::pair< std::string, std::string > > ¶meters)
set parameters
GNEViewNet * getViewNet() const
get view net
GNEInspectorFrame * getInspectorFrameParent() const
get inspector frame parent
GNEViewNet * getViewNet() const
get view net
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
GNEParameterHandler(ParametersOperations *ParametersOperationsParent, const std::string &file)
Constructor.
~GNEParameterHandler()
Destructor.
FXButton * mySaveButton
save button
ParametersOperations(FXHorizontalFrame *frame, GNESingleParametersDialog *ParameterDialogParent)
FOX-declaration.
long onCmdSaveParameters(FXObject *, FXSelector, void *)
event when user press save parameters button
FXButton * myClearButton
clear button
long onCmdClearParameters(FXObject *, FXSelector, void *)
event when user press clear parameters button
long onCmdLoadParameters(FXObject *, FXSelector, void *)
~ParametersOperations()
destructor
long onCmdSortParameters(FXObject *, FXSelector, void *)
event when user press sort parameters button
FXButton * myLoadButton
load button
FXButton * myHelpButton
help button
FXButton * mySortButton
sort 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
FXTextField * keyField
TextField for parameter.
~ParameterRow()
destructor
void copyValues(const ParameterRow &other)
copy values of other parameter Row
void disableRow()
disable row
void toggleAddButton()
toggle add button
FXTextField * valueField
TextField for value.
void enableRow(const std::string ¶meter, const std::string &value) const
enable rlow
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
~ParametersValues()
destructor
bool keyExist(const std::string &key) const
check if given key exist already
void clearParameters()
clear all parameters
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
Dialog for edit parameters.
FXButton * myResetButton
cancel button
ParametersValues * myParametersValues
pointer to parameters values
long onCmdCancel(FXObject *, FXSelector, void *)
event after press cancel button
long onCmdReset(FXObject *, FXSelector, void *)
event after press reset button
GNEVehicleTypeDialog::VTypeAtributes::VTypeAttributeRow * VTypeAttributeRow
pointer to VTypeAttributeRow
FXButton * myAcceptButton
accept button
FXButton * myCancelButton
cancel button
~GNESingleParametersDialog()
destructor
void constructor(const std::string &name)
auxiliar constructor
ParametersOperations * myParametersOperations
pointer to parameters operations
GNEAttributeCarrier * myAttributeCarrier
pointer to GNEAttributeCarrier
NBLoadedSUMOTLDef * myTLDef
pointer to TLDef
GNESingleParametersDialog(GNEFrameAttributeModules::GenericDataAttributes *genericDataAttributes)
Constructor for generic data attributes.
GNEInspectorFrame::ParametersEditor * myParametersEditor
pointer to ParametersEditor
GNEFrameAttributeModules::GenericDataAttributes * myGenericDataAttributes
FOX need this.
long onCmdAccept(FXObject *, FXSelector, void *)
GUIIcon getGUIIcon() const
get GUI icon associated to this Tag
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
void setParameters(const std::vector< std::pair< std::string, std::string > > ¶meters)
set parameters
std::vector< std::pair< std::string, std::string > > getParametersVectorStr() const
get parameters as vector of strings
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.
A loaded (complete) traffic light logic.
Static storage of an output device and its base (abstract) implementation.
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.
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.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
void setParametersMap(const std::map< std::string, std::string > ¶msMap)
set the inner key/value map in map<string, string> format
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
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.