61FXIMPLEMENT(
GNESingleParametersDialog, FXDialogBox, GNESingleParametersDialogMap, ARRAYNUMBER(GNESingleParametersDialogMap))
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<GNESingleParametersDialog::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, 0));
163 myParameterRows.at(i)->keyField->setTextColor(FXRGB(255, 0, 0));
164 myParameterRows.at(i)->keyField->killFocus();
175 if (myParameterRows.back()->button == obj) {
177 addParameter(std::make_pair(
"",
""));
181 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
182 if (myParameterRows.at(i)->button == obj) {
184 delete myParameterRows.at(i);
186 myParameterRows.erase(myParameterRows.begin() + i);
202 if (verticalFrameParent->id()) {
203 horizontalFrame->create();
212 delete horizontalFrame;
219 keyField->setText(
"");
221 valueField->setText(
"");
222 valueField->disable();
231 keyField->setText(parameter.c_str());
233 keyField->setTextColor(FXRGB(0, 0, 0));
235 keyField->setTextColor(FXRGB(255, 0, 0));
239 valueField->setText(value.c_str());
240 valueField->enable();
250 keyField->setText(
"");
252 valueField->setText(
"");
253 valueField->disable();
269 keyField->setText(other.
keyField->getText());
270 valueField->setText(other.
valueField->getText());
279 myParameterDialogParent(ParameterDialogParent) {
295 FXFileDialog opendialog(
this,
TL(
"Open Parameter Template"));
297 opendialog.setSelectMode(SELECTFILE_EXISTING);
298 opendialog.setPatternList(
" Parameter Template files (*.xml,*.xml.gz)\nAll files (*)");
302 if (opendialog.execute()) {
304 std::string file = opendialog.getFilename().text();
306 const int numberOfParametersbeforeLoad = (int)myParameterDialogParent->myParametersValues->getParameterRows().size();
310 WRITE_MESSAGE(
"Loading of Parameters From " + file +
" failed.");
313 WRITE_MESSAGE(
"Loaded " +
toString((
int)myParameterDialogParent->myParametersValues->getParameterRows().size() - numberOfParametersbeforeLoad) +
" Parameters.");
323 TL(
"Save Parameter Template file"),
".xml",
335 for (
const auto& row : myParameterDialogParent->myParametersValues->getParameterRows()) {
337 if (row != myParameterDialogParent->myParametersValues->getParameterRows().back()) {
358 myParameterDialogParent->myParametersValues->clearParameters();
366 std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
367 std::vector<std::string> emptyKeyValues;
369 for (
const auto& parameterRow : myParameterDialogParent->myParametersValues->getParameterRows()) {
371 if (!parameterRow->keyField->getText().empty()) {
372 nonEmptyKeyValues.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
373 }
else if (!parameterRow->valueField->getText().empty()) {
374 emptyKeyValues.push_back(parameterRow->valueField->getText().text());
378 std::sort(nonEmptyKeyValues.begin(), nonEmptyKeyValues.end());
380 std::sort(emptyKeyValues.begin(), emptyKeyValues.end());
382 for (
const auto& emptyKeyValue : emptyKeyValues) {
383 nonEmptyKeyValues.push_back(std::make_pair(
"", emptyKeyValue));
386 myParameterDialogParent->myParametersValues->setParameters(nonEmptyKeyValues);
394 FXDialogBox* ParameterHelpDialog =
new FXDialogBox(
this,
" Parameters Help",
GUIDesignDialogBox);
397 std::ostringstream 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 (@$%^&/|\\....)\n");
416 ParameterHelpDialog->create();
418 ParameterHelpDialog->show(PLACEMENT_CURSOR);
422 getApp()->runModalFor(ParameterHelpDialog);
431 myParametersOperationsParent(ParametersOperationsParent) {
456 if (key.size() == 0) {
459 WRITE_WARNING(
"Key '" + key +
"' of Parameter contains invalid characters");
461 }
else if (myParametersOperationsParent->myParameterDialogParent->myParametersValues->keyExist(key)) {
465 myParametersOperationsParent->myParameterDialogParent->myParametersValues->addParameter(std::make_pair(key, value));
495 myGenericDataAttributes(nullptr),
496 myParametersEditor(parametersEditor),
497 VTypeAttributeRow(nullptr),
498 myAttributeCarrier(nullptr),
512 myGenericDataAttributes(nullptr),
513 myParametersEditor(nullptr),
514 VTypeAttributeRow(VTypeAttributeRow),
515 myAttributeCarrier(nullptr),
526 myGenericDataAttributes(nullptr),
527 myParametersEditor(nullptr),
528 VTypeAttributeRow(nullptr),
529 myAttributeCarrier(attributeCarrier),
540 myGenericDataAttributes(nullptr),
541 myParametersEditor(nullptr),
542 VTypeAttributeRow(nullptr),
543 myAttributeCarrier(nullptr),
548 std::vector<std::pair<std::string, std::string> > parametersStr;
551 parametersStr.push_back(std::make_pair(parameter.first, parameter.second));
564 std::vector<std::pair<std::string, std::string> > parameters;
569 if (parameterRow->keyField->getText().empty()) {
571 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
573 FXMessageBox::warning(getApp(), MBOX_OK,
"Empty Parameter key",
"%s",
"Parameters with empty keys aren't allowed");
575 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
579 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
581 FXMessageBox::warning(getApp(), MBOX_OK,
"Invalid Parameter key",
"%s",
"There are keys with invalid characters");
583 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
587 parameters.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
591 std::sort(parameters.begin(), parameters.end());
593 for (
auto i = parameters.begin(); i != parameters.end(); i++) {
594 if (((i + 1) != parameters.end()) && (i->first) == (i + 1)->first) {
596 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
598 FXMessageBox::warning(getApp(), MBOX_OK,
"Duplicated Parameters",
"%s",
"Parameters with the same Key aren't allowed");
600 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
627 for (
const auto& parameter : parameters) {
628 parametersMap[parameter.first] = parameter.second;
634 getApp()->stopModal(
this, TRUE);
642 getApp()->stopModal(
this, FALSE);
661 std::vector<std::pair<std::string, std::string> > parametersStr;
664 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
Horizontal frame extended over frame parent.
#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 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
~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.
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.
std::map< std::string, std::string > Map
parameters map
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
void setParametersMap(const Parameterised::Map ¶msMap)
set the inner key/value map in map<string, string> format
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.