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) {
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());
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);
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"),
338 for (
const auto& row : myParameterDialogParent->myParametersValues->getParameterRows()) {
340 if (row != myParameterDialogParent->myParametersValues->getParameterRows().back()) {
361 myParameterDialogParent->myParametersValues->clearParameters();
369 std::vector<std::pair<std::string, std::string> > nonEmptyKeyValues;
370 std::vector<std::string> emptyKeyValues;
372 for (
const auto& parameterRow : myParameterDialogParent->myParametersValues->getParameterRows()) {
374 if (!parameterRow->keyField->getText().empty()) {
375 nonEmptyKeyValues.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
376 }
else if (!parameterRow->valueField->getText().empty()) {
377 emptyKeyValues.push_back(parameterRow->valueField->getText().text());
381 std::sort(nonEmptyKeyValues.begin(), nonEmptyKeyValues.end());
383 std::sort(emptyKeyValues.begin(), emptyKeyValues.end());
385 for (
const auto& emptyKeyValue : emptyKeyValues) {
386 nonEmptyKeyValues.push_back(std::make_pair(
"", emptyKeyValue));
389 myParameterDialogParent->myParametersValues->setParameters(nonEmptyKeyValues);
397 std::ostringstream help;
399 <<
TL(
"- Parameters are defined by a Key and a Value.") <<
"\n"
400 <<
TL(
"- In Netedit can be defined using format key1=parameter1|key2=parameter2|...") <<
"\n"
401 <<
TL(
" - Duplicated and empty Keys aren't valid.") <<
"\n"
402 <<
TL(
" - Whitespace and certain characters aren't allowed (@$%^&/|\\....)");
404 GNEHelpBasicDialog(myParameterDialogParent->myAttributesEditor->getFrameParent()->getViewNet()->getViewParent()->getGNEAppWindows(),
405 TL(
"Parameters Help"), help);
412 myParametersOperationsParent(ParametersOperationsParent) {
437 if (key.size() == 0) {
440 WRITE_WARNINGF(
TL(
"Key '%' of Parameter contains invalid characters"), key);
442 }
else if (myParametersOperationsParent->myParameterDialogParent->myParametersValues->keyExist(key)) {
446 myParametersOperationsParent->myParameterDialogParent->myParametersValues->addParameter(std::make_pair(key, value));
461 GNEDialog(attributesEditor->getFrameParent()->getViewNet()->getViewParent()->getGNEAppWindows(),
483 VTypeAttributeRow(VTypeAttributeRow) {
498 GNEDialog(attributeCarrier->getNet()->getViewNet()->getViewParent()->getGNEAppWindows(),
501 myAttributeCarrier(attributeCarrier) {
528 std::vector<std::pair<std::string, std::string> > parametersStr;
531 parametersStr.push_back(std::make_pair(parameter.first, parameter.second));
552 std::vector<std::pair<std::string, std::string> > parameters;
557 if (parameterRow->keyField->getText().empty()) {
567 parameters.push_back(std::make_pair(parameterRow->keyField->getText().text(), parameterRow->valueField->getText().text()));
571 std::sort(parameters.begin(), parameters.end());
573 for (
auto i = parameters.begin(); i != parameters.end(); i++) {
574 if (((i + 1) != parameters.end()) && (i->first) == (i + 1)->first) {
597 for (
const auto& parameter : parameters) {
617 std::vector<std::pair<std::string, std::string> > parametersStr;
620 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 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.
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
FXVerticalFrame * myContentFrame
content frame
GNEApplicationWindow * myApplicationWindow
FOX needs this.
long closeDialogAccepting()
close dialog accepting the changes
OpenType
Open dialog type.
void openDialog()
open dialog
virtual long onCmdCancel(FXObject *, FXSelector, void *)
called when cancel or no button is pressed (can be reimplemented in children)
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
void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)
run internal test
ParametersValues * myParametersValues
pointer to parameters values
long onCmdReset(FXObject *, FXSelector, void *)
event after press reset button
GNEVehicleTypeDialog::VTypeAttributes::VTypeAttributeRow * VTypeAttributeRow
pointer to VTypeAttributeRow
GNESingleParametersDialog(GNEAttributesEditorType *attributesEditor)
Constructor for attributes editor.
~GNESingleParametersDialog()
destructor
ParametersOperations * myParametersOperations
pointer to parameters operations
GNEAttributeCarrier * myAttributeCarrier
pointer to GNEAttributeCarrier
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 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.
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.