82 FXScrollWindow* scrollWindow =
new FXScrollWindow(
this, LAYOUT_FILL);
96 for (
const auto& newParameter : newParameters) {
97 addParameter(newParameter);
107 for (
const auto& newParameter : newParameters) {
108 addParameter(newParameter);
116 myParameterRows.back()->enableRow(newParameter.first, newParameter.second);
118 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
120 myParameterRows.back()->toggleAddButton();
127 for (
const auto& parameterRow : myParameterRows) {
131 myParameterRows.clear();
133 myParameterRows.push_back(
new ParameterRow(
this, myVerticalFrameRow));
135 myParameterRows.back()->toggleAddButton();
139const std::vector<GNEParametersDialog::ParametersValues::ParameterRow*>
141 return myParameterRows;
148 for (
const auto& row : myParameterRows) {
149 if (row->keyField->getText().text() == key) {
160 if (myParameterRows.size() > 0) {
161 myKeyLabel->setWidth(myParameterRows.front()->keyField->getWidth());
163 return FXGroupBox::onPaint(o, f, p);
170 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
171 if (myParameterRows.at(i)->keyField == obj) {
177 myParameterRows.at(i)->keyField->killFocus();
188 if (myParameterRows.back()->button == obj) {
190 addParameter(std::make_pair(
"",
""));
194 for (
int i = 0; i < (int)myParameterRows.size(); i++) {
195 if (myParameterRows.at(i)->button == obj) {
197 delete myParameterRows.at(i);
199 myParameterRows.erase(myParameterRows.begin() + i);
215 if (verticalFrameParent->id()) {
216 horizontalFrame->create();
225 delete horizontalFrame;
232 keyField->setText(
"");
234 valueField->setText(
"");
235 valueField->disable();
244 keyField->setText(parameter.c_str());
252 valueField->setText(value.c_str());
253 valueField->enable();
263 keyField->setText(
"");
265 valueField->setText(
"");
266 valueField->disable();
282 keyField->setText(other.
keyField->getText());
283 valueField->setText(other.
valueField->getText());
292 myParameterDialogParent(ParameterDialogParent) {
308 FXFileDialog opendialog(
this,
TL(
"Open Parameter Template"));
310 opendialog.setSelectMode(SELECTFILE_EXISTING);
315 if (opendialog.execute()) {
317 std::string file = opendialog.getFilename().text();
319 const int numberOfParametersbeforeLoad = (int)myParameterDialogParent->myParametersValues->getParameterRows().size();
326 WRITE_MESSAGEF(
TL(
"Loaded % Parameters."),
toString((
int)myParameterDialogParent->myParametersValues->getParameterRows().size() - numberOfParametersbeforeLoad));
336 TL(
"Save Parameter Template file"),
349 for (
const auto& row : myParameterDialogParent->myParametersValues->getParameterRows()) {
351 if (row != myParameterDialogParent->myParametersValues->getParameterRows().back()) {
372 myParameterDialogParent->myParametersValues->clearParameters();
380 std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
381 std::vector<std::string> emptyKeyValues;
383 for (
const auto& parameterRow : myParameterDialogParent->myParametersValues->getParameterRows()) {
385 if (!parameterRow->keyField->getText().empty()) {
386 nonEmptyKeyValues.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
387 }
else if (!parameterRow->valueField->getText().empty()) {
388 emptyKeyValues.push_back(parameterRow->valueField->getText().text());
392 std::sort(nonEmptyKeyValues.begin(), nonEmptyKeyValues.end());
394 std::sort(emptyKeyValues.begin(), emptyKeyValues.end());
396 for (
const auto& emptyKeyValue : emptyKeyValues) {
397 nonEmptyKeyValues.push_back(std::make_pair(
"", emptyKeyValue));
400 myParameterDialogParent->myParametersValues->setParameters(nonEmptyKeyValues);
408 std::ostringstream help;
410 <<
TL(
"- Parameters are defined by a Key and a Value.") <<
"\n"
411 <<
TL(
"- In Netedit can be defined using format key1=parameter1|key2=parameter2|...") <<
"\n"
412 <<
TL(
"- Duplicated and empty Keys aren't valid.") <<
"\n"
413 <<
TL(
"- Whitespace and certain characters aren't allowed (@$%^&/|\\....)");
416 TL(
"Parameters Help"), help);
423 myParametersOperationsParent(ParametersOperationsParent) {
448 if (key.size() == 0) {
451 WRITE_WARNINGF(
TL(
"Key '%' of Parameter contains invalid characters"), key);
453 }
else if (myParametersOperationsParent->myParameterDialogParent->myParametersValues->keyExist(key)) {
457 myParametersOperationsParent->myParameterDialogParent->myParametersValues->addParameter(std::make_pair(key, value));
496std::vector<std::pair<std::string, std::string> >
498 std::vector<std::pair<std::string, std::string> > parameters;
503 parameters.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
513 std::vector<std::pair<std::string, std::string> > editedParameters =
getEditedParameters();
515 for (
const auto& editedParameter : editedParameters) {
516 if (editedParameter.first.empty()) {
527 std::sort(editedParameters.begin(), editedParameters.end());
529 for (
auto i = editedParameters.begin(); (i + 1) != editedParameters.end(); i++) {
530 if ((i->first) == (i + 1)->first) {
FXDEFMAP(GNEParametersDialog) GNEParametersDialogMap[]
@ 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 GUIDesignTextColorRed
red color (for invalid text)
#define GUIDesignButtonIcon
button only with icon
#define GUIDesignTextField
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
#define GUIDesignTextFieldNCol
Num of column of text field.
#define GUIDesignLabelThick(justify)
label extended over frame with thick and with text justify to left
#define GUIDesignTextColorBlack
black color (for correct text)
#define GUIDesignGroupBoxFrameFill
Group box design extended over frame (X and Y)
#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
FXString gCurrentFolder
The folder used as last.
GUIIcon
An enumeration of icons used by the gui applications.
#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)
The main window of Netedit.
FXVerticalFrame * myContentFrame
content frame
GNEApplicationWindow * myApplicationWindow
FOX needs this.
void openDialog(FXWindow *focusableElement=nullptr)
open dialog
long closeDialogAccepting()
close dialog accepting the changes
OpenType
Open dialog type.
virtual long onCmdCancel(FXObject *, FXSelector, void *)
called when cancel or no button is pressed (can be reimplemented in children)
~GNEParameterHandler()
Destructor.
GNEParameterHandler(ParametersOperations *ParametersOperationsParent, const std::string &file)
Constructor.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
~ParametersOperations()
destructor
long onCmdSortParameters(FXObject *, FXSelector, void *)
event when user press sort parameters button
ParametersOperations(FXHorizontalFrame *frame, GNEParametersDialog *ParameterDialogParent)
FOX-declaration.
long onCmdHelpParameter(FXObject *, FXSelector, void *)
event when user press help parameters button
FXButton * myHelpButton
help button
long onCmdClearParameters(FXObject *, FXSelector, void *)
event when user press clear parameters button
long onCmdSaveParameters(FXObject *, FXSelector, void *)
event when user press save parameters button
FXButton * myClearButton
clear button
FXButton * myLoadButton
load button
FXButton * mySortButton
sort button
long onCmdLoadParameters(FXObject *, FXSelector, void *)
FXButton * mySaveButton
save button
ParameterRow(ParametersValues *ParametersValues, FXVerticalFrame *verticalFrameParent)
constructor
void toggleAddButton()
toggle add button
void copyValues(const ParameterRow &other)
copy values of other parameter Row
FXTextField * keyField
TextField for parameter.
~ParameterRow()
destructor
void disableRow()
disable row
bool isButtonInAddMode() const
check if remove button is in mode "add"
void enableRow(const std::string ¶meter, const std::string &value) const
enable row
FXTextField * valueField
TextField for value.
bool keyExist(const std::string &key) const
check if given key exist already
long onCmdSetAttribute(FXObject *, FXSelector, void *)
event when user change an attribute
void clearParameters()
clear all parameters
const std::vector< ParameterRow * > getParameterRows() const
get vector with the ParameterRows
void setParameters(const Parameterised::Map &newParameters)
set parameters map
void addParameter(std::pair< std::string, std::string > newParameter)
add a single parameter
long onPaint(FXObject *o, FXSelector f, void *p)
~ParametersValues()
destructor
long onCmdButtonPress(FXObject *, FXSelector, void *)
event when user press a remove (or add) button
ParametersOperations * myParametersOperations
pointer to parameters operations
long onCmdReset(FXObject *, FXSelector, void *)
event after press reset button
long onCmdAccept(FXObject *, FXSelector, void *)
event after press accept button
const Parameterised::Map myOriginalParameters
FOX need this.
GNEParametersDialog(GNEApplicationWindow *applicationWindow, const Parameterised::Map ¶meters)
constructor
std::vector< std::pair< std::string, std::string > > getEditedParameters() const
get edited parameters
ParametersValues * myParametersValues
pointer to parameters values
void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)
run internal test
~GNEParametersDialog()
destructor
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 modal dialogs that can not be edited using tab
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extensions, FXIcon *icon, FXString ¤tFolder)
Returns the file name to write.
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
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.