83 FXScrollWindow* scrollWindow =
new FXScrollWindow(
this, LAYOUT_FILL);
97 for (
const auto& newParameter : newParameters) {
98 addParameter(newParameter);
106 myParameterRows.back()->enableRow(newParameter.first, newParameter.second);
108 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
110 myParameterRows.back()->toggleAddButton();
117 for (
const auto& parameterRow : myParameterRows) {
121 myParameterRows.clear();
123 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
125 myParameterRows.back()->toggleAddButton();
129const std::vector<GNESingleParametersDialog::ParametersValues::ParameterRow*>
131 return myParameterRows;
138 for (
const auto& row : myParameterRows) {
139 if (row->keyField->getText().text() == key) {
150 if (myParameterRows.size() > 0) {
151 myKeyLabel->setWidth(myParameterRows.front()->keyField->getWidth());
153 return FXGroupBox::onPaint(o, f, p);
160 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
161 if (myParameterRows.at(i)->keyField == obj) {
164 myParameterRows.at(i)->keyField->setTextColor(FXRGB(0, 0, 0));
166 myParameterRows.at(i)->keyField->setTextColor(FXRGB(255, 0, 0));
167 myParameterRows.at(i)->keyField->killFocus();
178 if (myParameterRows.back()->button == obj) {
180 addParameter(std::make_pair(
"",
""));
184 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
185 if (myParameterRows.at(i)->button == obj) {
187 delete myParameterRows.at(i);
189 myParameterRows.erase(myParameterRows.begin() + i);
205 if (verticalFrameParent->id()) {
206 horizontalFrame->create();
215 delete horizontalFrame;
222 keyField->setText(
"");
224 valueField->setText(
"");
225 valueField->disable();
234 keyField->setText(parameter.c_str());
236 keyField->setTextColor(FXRGB(0, 0, 0));
238 keyField->setTextColor(FXRGB(255, 0, 0));
242 valueField->setText(value.c_str());
243 valueField->enable();
253 keyField->setText(
"");
255 valueField->setText(
"");
256 valueField->disable();
272 keyField->setText(other.
keyField->getText());
273 valueField->setText(other.
valueField->getText());
282 myParameterDialogParent(ParameterDialogParent) {
298 FXFileDialog opendialog(
this,
TL(
"Open Parameter Template"));
300 opendialog.setSelectMode(SELECTFILE_EXISTING);
305 if (opendialog.execute()) {
307 std::string file = opendialog.getFilename().text();
309 const int numberOfParametersbeforeLoad = (int)myParameterDialogParent->myParametersValues->getParameterRows().size();
316 WRITE_MESSAGEF(
TL(
"Loaded % Parameters."),
toString((
int)myParameterDialogParent->myParametersValues->getParameterRows().size() - numberOfParametersbeforeLoad));
326 TL(
"Save Parameter Template file"),
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);
401 std::ostringstream help;
403 <<
TL(
"- Parameters are defined by a Key and a Value.\n")
404 <<
TL(
"- In Netedit can be defined using format key1=parameter1|key2=parameter2|...\n")
405 <<
TL(
" - Duplicated and empty Keys aren't valid.\n")
406 <<
TL(
" - Whitespace and certain characters aren't allowed (@$%^&/|\\....)\n");
418 ParameterHelpDialog->create();
420 ParameterHelpDialog->show(PLACEMENT_CURSOR);
424 getApp()->runModalFor(ParameterHelpDialog);
431 myParametersOperationsParent(ParametersOperationsParent) {
456 if (key.size() == 0) {
459 WRITE_WARNINGF(
TL(
"Key '%' of Parameter contains invalid characters"), key);
461 }
else if (myParametersOperationsParent->myParameterDialogParent->myParametersValues->keyExist(key)) {
465 myParametersOperationsParent->myParameterDialogParent->myParametersValues->addParameter(std::make_pair(key, value));
491 VTypeAttributeRow(VTypeAttributeRow) {
501 myAttributeCarrier(attributeCarrier) {
515 std::vector<std::pair<std::string, std::string> > parametersStr;
518 parametersStr.push_back(std::make_pair(parameter.first, parameter.second));
537 std::vector<std::pair<std::string, std::string> > parameters;
542 if (parameterRow->keyField->getText().empty()) {
544 FXMessageBox::warning(getApp(), MBOX_OK,
"Empty Parameter key",
"%s",
"Parameters with empty keys aren't allowed");
548 FXMessageBox::warning(getApp(), MBOX_OK,
"Invalid Parameter key",
"%s",
"There are keys with invalid characters");
552 parameters.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
556 std::sort(parameters.begin(), parameters.end());
558 for (
auto i = parameters.begin(); i != parameters.end(); i++) {
559 if (((i + 1) != parameters.end()) && (i->first) == (i + 1)->first) {
561 FXMessageBox::warning(getApp(), MBOX_OK,
"Duplicated Parameters",
"%s",
"Parameters with the same Key aren't allowed");
582 for (
const auto& parameter : parameters) {
587 getApp()->stopModal(
this, TRUE);
595 getApp()->stopModal(
this, FALSE);
611 std::vector<std::pair<std::string, std::string> > parametersStr;
614 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
GNEFrame * getFrameParent() const
pointer to GNEFrame parent
const std::vector< GNEAttributeCarrier * > & getEditedAttributeCarriers() const
get edited attribute carriers
GNEViewNet * getViewNet() const
get view net
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(GNEAttributesEditorType *attributesEditor)
Constructor for attributes editor.
~GNESingleParametersDialog()
destructor
void constructor(const std::string &name)
auxiliar constructor
ParametersOperations * myParametersOperations
pointer to parameters operations
GNEAttributeCarrier * myAttributeCarrier
pointer to GNEAttributeCarrier
void runInternalTest(const InternalTestStep::DialogTest *modalArguments)
run internal test
NBLoadedSUMOTLDef * myTLDef
pointer to TLDef
GNEAttributesEditorType * myAttributesEditor
FOX need this.
long onCmdAccept(FXObject *, FXSelector, void *)
event after press accept button
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
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
dialog arguments (used for certain functions that opens modal dialogs)
MFXDialogBox()
FOX needs this.
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extensions, 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 StringBijection< XMLFileExtension > XMLFileExtensions
XML file Extensions.
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.