63FXIMPLEMENT(
GNESingleParametersDialog, FXDialogBox, GNESingleParametersDialogMap, ARRAYNUMBER(GNESingleParametersDialogMap))
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()->toggleAddButton();
116 for (
const auto& parameterRow : myParameterRows) {
120 myParameterRows.clear();
122 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
124 myParameterRows.back()->toggleAddButton();
128const std::vector<GNESingleParametersDialog::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, 0));
165 myParameterRows.at(i)->keyField->setTextColor(FXRGB(255, 0, 0));
166 myParameterRows.at(i)->keyField->killFocus();
177 if (myParameterRows.back()->button == obj) {
179 addParameter(std::make_pair(
"",
""));
183 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
184 if (myParameterRows.at(i)->button == obj) {
186 delete myParameterRows.at(i);
188 myParameterRows.erase(myParameterRows.begin() + i);
204 if (verticalFrameParent->id()) {
205 horizontalFrame->create();
214 delete horizontalFrame;
221 keyField->setText(
"");
223 valueField->setText(
"");
224 valueField->disable();
233 keyField->setText(parameter.c_str());
235 keyField->setTextColor(FXRGB(0, 0, 0));
237 keyField->setTextColor(FXRGB(255, 0, 0));
241 valueField->setText(value.c_str());
242 valueField->enable();
252 keyField->setText(
"");
254 valueField->setText(
"");
255 valueField->disable();
271 keyField->setText(other.
keyField->getText());
272 valueField->setText(other.
valueField->getText());
281 myParameterDialogParent(ParameterDialogParent) {
297 FXFileDialog opendialog(
this,
TL(
"Open Parameter Template"));
299 opendialog.setSelectMode(SELECTFILE_EXISTING);
300 opendialog.setPatternList(
" Parameter Template files (*.xml,*.xml.gz)\nAll files (*)");
304 if (opendialog.execute()) {
306 std::string file = opendialog.getFilename().text();
308 const int numberOfParametersbeforeLoad = (int)myParameterDialogParent->myParametersValues->getParameterRows().size();
315 WRITE_MESSAGEF(
TL(
"Loaded % Parameters."),
toString((
int)myParameterDialogParent->myParametersValues->getParameterRows().size() - numberOfParametersbeforeLoad));
325 TL(
"Save Parameter Template file"),
".xml",
337 for (
const auto& row : myParameterDialogParent->myParametersValues->getParameterRows()) {
339 if (row != myParameterDialogParent->myParametersValues->getParameterRows().back()) {
360 myParameterDialogParent->myParametersValues->clearParameters();
368 std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
369 std::vector<std::string> emptyKeyValues;
371 for (
const auto& parameterRow : myParameterDialogParent->myParametersValues->getParameterRows()) {
373 if (!parameterRow->keyField->getText().empty()) {
374 nonEmptyKeyValues.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
375 }
else if (!parameterRow->valueField->getText().empty()) {
376 emptyKeyValues.push_back(parameterRow->valueField->getText().text());
380 std::sort(nonEmptyKeyValues.begin(), nonEmptyKeyValues.end());
382 std::sort(emptyKeyValues.begin(), emptyKeyValues.end());
384 for (
const auto& emptyKeyValue : emptyKeyValues) {
385 nonEmptyKeyValues.push_back(std::make_pair(
"", emptyKeyValue));
388 myParameterDialogParent->myParametersValues->setParameters(nonEmptyKeyValues);
396 FXDialogBox* ParameterHelpDialog =
new FXDialogBox(
this,
" Parameters Help",
GUIDesignDialogBox);
399 std::ostringstream help;
401 <<
TL(
"- Parameters are defined by a Key and a Value.\n")
402 <<
TL(
"- In Netedit can be defined using format key1=parameter1|key2=parameter2|...\n")
403 <<
TL(
" - Duplicated and empty Keys aren't valid.\n")
404 <<
TL(
" - Whitespace and certain characters aren't allowed (@$%^&/|\\....)\n");
418 ParameterHelpDialog->create();
420 ParameterHelpDialog->show(PLACEMENT_CURSOR);
424 getApp()->runModalFor(ParameterHelpDialog);
433 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));
497 myGenericDataAttributes(nullptr),
498 myParametersEditor(parametersEditor),
499 VTypeAttributeRow(nullptr),
500 myAttributeCarrier(nullptr),
521 myGenericDataAttributes(nullptr),
522 myParametersEditor(nullptr),
523 VTypeAttributeRow(VTypeAttributeRow),
524 myAttributeCarrier(nullptr),
535 myGenericDataAttributes(nullptr),
536 myParametersEditor(nullptr),
537 VTypeAttributeRow(nullptr),
538 myAttributeCarrier(attributeCarrier),
549 myGenericDataAttributes(nullptr),
550 myParametersEditor(nullptr),
551 VTypeAttributeRow(nullptr),
552 myAttributeCarrier(nullptr),
557 std::vector<std::pair<std::string, std::string> > parametersStr;
560 parametersStr.push_back(std::make_pair(parameter.first, parameter.second));
573 std::vector<std::pair<std::string, std::string> > parameters;
578 if (parameterRow->keyField->getText().empty()) {
580 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
582 FXMessageBox::warning(getApp(), MBOX_OK,
"Empty Parameter key",
"%s",
"Parameters with empty keys aren't allowed");
584 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
588 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
590 FXMessageBox::warning(getApp(), MBOX_OK,
"Invalid Parameter key",
"%s",
"There are keys with invalid characters");
592 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
596 parameters.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
600 std::sort(parameters.begin(), parameters.end());
602 for (
auto i = parameters.begin(); i != parameters.end(); i++) {
603 if (((i + 1) != parameters.end()) && (i->first) == (i + 1)->first) {
605 WRITE_DEBUG(
"Opening FXMessageBox of type 'warning'");
607 FXMessageBox::warning(getApp(), MBOX_OK,
"Duplicated Parameters",
"%s",
"Parameters with the same Key aren't allowed");
609 WRITE_DEBUG(
"Closed FXMessageBox of type 'warning' with 'OK'");
643 for (
const auto& parameter : parameters) {
648 getApp()->stopModal(
this, TRUE);
656 getApp()->stopModal(
this, FALSE);
681 std::vector<std::pair<std::string, std::string> > parametersStr;
684 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 GUIDesignTextFieldNCol
Num of column of text field.
#define GUIDesignButtonOK
#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 GUIDesignDialogBoxExplicitStretchable(width, height)
design for dialog box with specific width and height that can be stretched (But not shrunk)
#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_NOTHING
invalid tag, must be the last one
@ 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
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 viewNet
GNEInspectorFrame * getInspectorFrameParent() const
get inspector frame parent
GNETypeFrame * getTypeFrameParent() const
get type 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
FXButton * myKeepOldButton
accept button
GNEVehicleTypeDialog::VTypeAttributes::VTypeAttributeRow * VTypeAttributeRow
pointer to VTypeAttributeRow
FXButton * myCancelButton
cancel button
~GNESingleParametersDialog()
destructor
void constructor(const std::string &name)
auxiliar constructor
ParametersOperations * myParametersOperations
pointer to parameters operations
GNEFrameAttributeModules::ParametersEditor * myParametersEditor
pointer to ParametersEditor
GNEAttributeCarrier * myAttributeCarrier
pointer to GNEAttributeCarrier
NBLoadedSUMOTLDef * myTLDef
pointer to TLDef
GNESingleParametersDialog(GNEFrameAttributeModules::GenericDataAttributes *genericDataAttributes)
Constructor for generic data attributes.
GNEFrameAttributeModules::GenericDataAttributes * myGenericDataAttributes
FOX need this.
long onCmdAccept(FXObject *, FXSelector, void *)
GNEDemandElement * getCurrentType() const
get current Vehicle Type
TypeSelector * getTypeSelector() const
get vehicle type selector
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
std::vector< std::pair< std::string, std::string > > getParametersVectorStr() const
get parameters as vector of strings
void setParameters(const std::vector< std::pair< std::string, std::string > > ¶meters)
set parameters
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.
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.
void clearParameter()
Clears the parameter map.
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
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.