82 FXScrollWindow* scrollWindow =
new FXScrollWindow(
this, LAYOUT_FILL);
96 for (
const auto& newParameter : newParameters) {
107 for (
const auto& newParameter : newParameters) {
116 myParameterRows.back()->enableRow(newParameter.first, newParameter.second);
139const std::vector<GNEParametersDialog::ParametersValues::ParameterRow*>
149 if (row->keyField->getText().text() == key) {
163 return FXGroupBox::onPaint(o, f, p);
215 if (verticalFrameParent->id()) {
244 keyField->setText(parameter.c_str());
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();
336 TL(
"Save Parameter Template file"),
380 std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
381 std::vector<std::string> emptyKeyValues;
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));
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);
448 if (key.size() == 0) {
451 WRITE_WARNINGF(
TL(
"Key '%' of Parameter contains invalid characters"), key);
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)
const std::string invalid_return< std::string >::value
@ 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.
GNEDialog(GNEApplicationWindow *applicationWindow, const std::string &name, GUIIcon titleIcon, DialogType type, Buttons buttons, OpenType openType, ResizeMode resizeMode)
basic constructor
virtual long onCmdCancel(FXObject *, FXSelector, void *)
called when cancel or no button is pressed (can be reimplemented in children)
~GNEParameterHandler()
Destructor.
ParametersOperations * myParametersOperationsParent
pointer to ParametersOperations parent
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
GNEParametersDialog * myParameterDialogParent
pointer to Shape Frame Parent
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.
FXButton * button
Button for add or remove row.
~ParameterRow()
destructor
FXHorizontalFrame * horizontalFrame
frame in which elements of ParameterRow are placed
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
FXVerticalFrame * myVerticalFrameRow
vertical frame in which rows are placed
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
FXLabel * myKeyLabel
label for key (its neccesary because has to be resized in every onPaint() iteration)
ParametersValues(FXHorizontalFrame *frame, const std::string &name)
constructor
std::vector< ParameterRow * > myParameterRows
vector with the ParameterRows
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.
SUMOSAXHandler(const std::string &file="", const std::string &expectedRoot="")
Constructor.
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.