64 FXIMPLEMENT(
GNESingleParametersDialog, FXDialogBox, GNESingleParametersDialogMap, ARRAYNUMBER(GNESingleParametersDialogMap))
78 myParameterDialogParent(ParameterDialogParent) {
84 FXScrollWindow* scrollWindow =
new FXScrollWindow(
this, LAYOUT_FILL);
98 for (
const auto& newParameter : newParameters) {
99 addParameter(newParameter);
107 myParameterRows.back()->enableRow(newParameter.first, newParameter.second);
109 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
111 myParameterRows.back()->toogleAddButton();
118 for (
const auto& parameterRow : myParameterRows) {
122 myParameterRows.clear();
124 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
126 myParameterRows.back()->toogleAddButton();
130 const std::vector<GNESingleParametersDialog::ParametersValues::ParameterRow*>
132 return myParameterRows;
139 for (
const auto& row : myParameterRows) {
140 if (row->keyField->getText().text() == key) {
151 if (myParameterRows.size() > 0) {
152 myKeyLabel->setWidth(myParameterRows.front()->keyField->getWidth());
154 return FXGroupBox::onPaint(o, f, p);
161 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
162 if (myParameterRows.at(i)->keyField == obj) {
165 myParameterRows.at(i)->keyField->setTextColor(FXRGB(0, 0, 0));
167 myParameterRows.at(i)->keyField->setTextColor(FXRGB(255, 0, 0));
168 myParameterRows.at(i)->keyField->killFocus();
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);
206 if (verticalFrameParent->id()) {
207 horizontalFrame->create();
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,
"Open Parameter Template");
301 opendialog.setSelectMode(SELECTFILE_EXISTING);
302 opendialog.setPatternList(
" Parameter Template files (*.xml)\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 "Select name of the 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 <<
"- Parameters are defined by a Key and a Value.\n"
404 <<
"- In Netedit can be defined using format key1=parameter1|key2=parameter2|...\n"
405 <<
" - Duplicated and empty Keys aren't valid.\n"
406 <<
" - Certain characters aren't allowed (\t\n\r@$%^&/|\\....)\n";
420 ParameterHelpDialog->create();
422 ParameterHelpDialog->show(PLACEMENT_CURSOR);
426 getApp()->runModalFor(ParameterHelpDialog);
435 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));
500 myParametersEditorCreator(nullptr),
501 myParametersEditorInspector(parametersEditorInspector),
502 VTypeAttributeRow(nullptr),
503 myAttributeCarrier(nullptr) {
516 myParametersEditorCreator(nullptr),
517 myParametersEditorInspector(nullptr),
518 VTypeAttributeRow(VTypeAttributeRow),
519 myAttributeCarrier(nullptr) {
529 myParametersEditorCreator(nullptr),
530 myParametersEditorInspector(nullptr),
531 VTypeAttributeRow(nullptr),
532 myAttributeCarrier(attributeCarrier) {
546 std::vector<std::pair<std::string, std::string> > parameters;
551 if (parameterRow->keyField->getText().empty()) {
553 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
555 FXMessageBox::warning(getApp(), MBOX_OK,
"Empty Parameter key",
"%s",
"Parameters with empty keys aren't allowed");
557 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
561 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
563 FXMessageBox::warning(getApp(), MBOX_OK,
"Invalid Parameter key",
"%s",
"There are keys with invalid characters");
565 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
569 !GNEAttributeCarrier::canParse<double>(parameterRow->valueField->getText().text())) {
571 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
573 FXMessageBox::warning(getApp(), MBOX_OK,
"Invalid double Parameter value",
"%s",
"There are values that cannot be parsed to floats");
575 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
579 parameters.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
583 std::sort(parameters.begin(), parameters.end());
585 for (
auto i = parameters.begin(); i != parameters.end(); i++) {
586 if (((i + 1) != parameters.end()) && (i->first) == (i + 1)->first) {
588 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
590 FXMessageBox::warning(getApp(), MBOX_OK,
"Duplicated Parameters",
"%s",
"Parameters with the same Key aren't allowed");
592 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
617 getApp()->stopModal(
this, TRUE);
625 getApp()->stopModal(
this, FALSE);
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 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 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)
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ 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)
GNENet * getNet() const
get pointer to net
T getACParameters() const
get parameters
void setParameters(const std::vector< std::pair< std::string, std::string > > ¶meters)
set parameters
Parameterised::ParameterisedAttrType getAttrType() const
get current parameter type
std::vector< std::pair< std::string, std::string > > getParameters() const
get parameters as vector of strings
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 toogleAddButton()
toogle add button
void copyValues(const ParameterRow &other)
copy values of other parameter Row
void disableRow()
disable row
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
GNEInspectorFrame::ParametersEditorInspector * myParametersEditorInspector
pointer to ParametersEditorInspector
ParametersOperations * myParametersOperations
pointer to parameters operations
GNEAttributeCarrier * myAttributeCarrier
pointer to GNEAttributeCarrier
GNEFrameAttributesModuls::ParametersEditorCreator * myParametersEditorCreator
FOX need this.
void constructor()
auxiliar constructor
long onCmdAccept(FXObject *, FXSelector, void *)
GNESingleParametersDialog(GNEFrameAttributesModuls::ParametersEditorCreator *parametersEditorCreator)
Constructor for parameter editor creator.
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,...
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.
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.
@ DOUBLE
Parameterised only accept doubles.
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.