70 myFrameParent(frameParent) {
83 refreshGenericDataAttributes();
98 myTextFieldParameters->setText(getParametersStr().c_str());
99 myTextFieldParameters->setTextColor(FXRGB(0, 0, 0));
100 myTextFieldParameters->killFocus();
114 for (
const auto& parameter : myParameters) {
115 result += parameter.first +
"=" + parameter.second +
"|";
118 if (!result.empty()) {
125std::vector<std::pair<std::string, std::string> >
127 std::vector<std::pair<std::string, std::string> > result;
129 for (
const auto& parameter : myParameters) {
130 result.push_back(std::make_pair(parameter.first, parameter.second));
141 for (
const auto& parameter : parameters) {
142 result += parameter.first +
"=" + parameter.second +
"|";
145 if (!result.empty()) {
149 myTextFieldParameters->setText(result.c_str(), TRUE);
155 return myFrameParent;
161 if (myTextFieldParameters->getText().empty()) {
163 }
else if (myTextFieldParameters->getTextColor() == FXRGB(255, 0, 0)) {
179 refreshGenericDataAttributes();
191 myParameters.clear();
195 myTextFieldParameters->setTextColor(FXRGB(0, 0, 0));
196 myTextFieldParameters->killFocus();
198 std::vector<std::string> parameters =
StringTokenizer(myTextFieldParameters->getText().text(),
"|",
true).
getVector();
200 for (
const auto& parameter : parameters) {
204 myParameters[keyParam.front()] = keyParam.back();
207 myTextFieldParameters->setText(getParametersStr().c_str(), FALSE);
209 myTextFieldParameters->setTextColor(FXRGB(255, 0, 0));
220 myInspectorFrameParent(inspectorFrameParent) {
229 myTypeFrameParent(typeFrameParent) {
241 return myInspectorFrameParent ? myInspectorFrameParent->getViewNet() : myTypeFrameParent->getViewNet();
247 if (myInspectorFrameParent) {
249 if (inspectedElements.getFirstAC() && inspectedElements.getFirstAC()->getTagProperty().hasParameters()) {
251 refreshParametersEditor();
255 hideParametersEditor();
257 }
else if (myTypeFrameParent) {
258 if (myTypeFrameParent->getTypeSelector()->getCurrentType() !=
nullptr) {
260 refreshParametersEditor();
264 hideParametersEditor();
267 hideParametersEditor();
281 if (myInspectorFrameParent) {
282 const auto& inspectedElements = myInspectorFrameParent->getViewNet()->getInspectedElements();
284 if (inspectedElements.getFirstAC() && inspectedElements.getFirstAC()->getTagProperty().hasParameters()) {
286 if (inspectedElements.isInspectingSingleElement()) {
288 myTextFieldParameters->setText(inspectedElements.getFirstAC()->getAttribute(
GNE_ATTR_PARAMETERS).c_str());
291 std::string parameters = inspectedElements.getFirstAC()->getAttribute(
GNE_ATTR_PARAMETERS);
292 for (
const auto& AC : inspectedElements.getACs()) {
294 parameters =
"different parameters";
298 myTextFieldParameters->setText(parameters.c_str());
301 myTextFieldParameters->setTextColor(FXRGB(0, 0, 0));
304 myTextFieldParameters->enable();
305 myButtonEditParameters->enable();
307 myTextFieldParameters->disable();
308 myButtonEditParameters->disable();
311 }
else if (myTypeFrameParent) {
313 GNEDemandElement* type = myTypeFrameParent->getTypeSelector()->getCurrentType();
319 myTextFieldParameters->setTextColor(FXRGB(0, 0, 0));
322 myTextFieldParameters->enable();
323 myButtonEditParameters->enable();
325 myTextFieldParameters->disable();
326 myButtonEditParameters->disable();
335 return myInspectorFrameParent;
341 return myTypeFrameParent;
347 if (myInspectorFrameParent) {
350 if (inspectedElements.getFirstAC() && inspectedElements.getFirstAC()->getTagProperty().hasParameters()) {
351 if (inspectedElements.isInspectingMultipleElements()) {
361 refreshParametersEditor();
375 refreshParametersEditor();
382 }
else if (myTypeFrameParent) {
384 GNEDemandElement* type = myTypeFrameParent->getTypeSelector()->getCurrentType();
393 refreshParametersEditor();
406 if (myInspectorFrameParent) {
407 const auto& inspectedElements = myInspectorFrameParent->getViewNet()->getInspectedElements();
409 if (inspectedElements.getFirstAC() && inspectedElements.getFirstAC()->getTagProperty().hasParameters()) {
411 if (inspectedElements.getFirstAC()->isValid(
GNE_ATTR_PARAMETERS, myTextFieldParameters->getText().text())) {
413 myTextFieldParameters->setTextColor(FXRGB(0, 0, 0));
414 myTextFieldParameters->killFocus();
416 if (inspectedElements.isInspectingSingleElement()) {
418 myInspectorFrameParent->getViewNet()->getUndoList()->begin(inspectedElements.getFirstAC(),
"change parameters");
420 inspectedElements.getFirstAC()->setACParameters(myTextFieldParameters->getText().text(), myInspectorFrameParent->getViewNet()->getUndoList());
422 myInspectorFrameParent->getViewNet()->getUndoList()->end();
423 }
else if (inspectedElements.isInspectingMultipleElements()) {
425 myInspectorFrameParent->getViewNet()->getUndoList()->begin(inspectedElements.getFirstAC(),
"change multiple parameters");
427 for (
const auto& inspectedAC : inspectedElements.getACs()) {
428 inspectedAC->setACParameters(myTextFieldParameters->getText().text(), myInspectorFrameParent->getViewNet()->getUndoList());
431 myInspectorFrameParent->getViewNet()->getUndoList()->end();
436 myTextFieldParameters->setTextColor(FXRGB(255, 0, 0));
439 }
else if (myTypeFrameParent) {
441 GNEDemandElement* type = myTypeFrameParent->getTypeSelector()->getCurrentType();
447 myTextFieldParameters->setTextColor(FXRGB(0, 0, 0));
448 myTextFieldParameters->killFocus();
450 myTypeFrameParent->getViewNet()->getUndoList()->begin(type,
"change parameters");
452 type->
setACParameters(myTextFieldParameters->getText().text(), myTypeFrameParent->getViewNet()->getUndoList());
454 myTypeFrameParent->getViewNet()->getUndoList()->end();
456 myTextFieldParameters->setTextColor(FXRGB(255, 0, 0));
FXDEFMAP(GNEFrameAttributeModules::GenericDataAttributes) GenericDataAttributesMap[]
@ MID_GNE_SET_ATTRIBUTE
attribute edited
@ MID_GNE_OPEN_PARAMETERS_DIALOG
open parameters dialog
#define GUIDesignTextField
#define GUIDesignTextFieldNCol
Num of column of text field.
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
void setACParameters(const std::string ¶meters, GNEUndoList *undoList)
set parameters (string)
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
const GNETagProperties & getTagPropertyParent() const
get reference to tagProperty parent
virtual std::string getAttribute(SumoXMLAttr key) const =0
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
~GenericDataAttributes()
destructor
long onCmdSetParameters(FXObject *, FXSelector, void *)
Called when user udpate the parameter text field.
bool areAttributesValid() const
check if current attributes are valid
const Parameterised::Map & getParametersMap() const
get parameters as map
void refreshGenericDataAttributes()
refresh netedit attributes
void showGenericDataAttributes()
show netedit attributes EditorCreator
long onCmdEditParameters(FXObject *, FXSelector, void *)
GNEFrame * getFrameParent() const
pointer to frame parent
std::vector< std::pair< std::string, std::string > > getParameters() const
get parameters as vector of strings
std::string getParametersStr() const
get parameters as string
void hideGenericDataAttributes()
hide netedit attributes EditorCreator
void setParameters(const std::vector< std::pair< std::string, std::string > > ¶meters)
set parameters
GNEViewNet * getViewNet() const
@get viewNet
~ParametersEditor()
destructor
void refreshParametersEditor()
refresh netedit attributes
long onCmdSetParameters(FXObject *, FXSelector, void *)
Called when user udpate the parameter text field.
long onCmdEditParameters(FXObject *, FXSelector, void *)
ParametersEditor(GNEInspectorFrame *inspectorFrameParent)
FOX-declaration.
void hideParametersEditor()
hide netedit attributes EditorInspector
GNEInspectorFrame * getInspectorFrameParent() const
get inspector frame parent
FXButton * myButtonEditParameters
button for edit parameters using specific dialog
FXTextField * myTextFieldParameters
text field for write parameters
GNETypeFrame * getTypeFrameParent() const
get type frame parent
void showParametersEditor()
show netedit attributes EditorInspector
static bool isSupermodeValid(const GNEViewNet *viewNet, const GNEAttributeCarrier *AC)
return true if AC can be edited in the current supermode
GNEViewNet * getViewNet() const
get view net
Dialog for edit parameters.
Dialog for edit parameters.
bool isMeanData() const
return true if tag correspond to a mean data element
bool isNetworkElement() const
element sets
bool isDataElement() const
return true if tag correspond to a data element
bool isDemandElement() const
return true if tag correspond to a demand element
bool isAdditionalElement() const
return true if tag correspond to an additional element (note: this include TAZ, shapes and wires)
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
GNEViewNetHelper::InspectedElements & getInspectedElements()
get inspected elements
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
MFXGroupBoxModule (based on FXGroupBox)
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toggled)
static bool areAttributesValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to an attributes map "key1=value1|key2=value2|....
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
std::map< std::string, std::string > Map
parameters map
std::vector< std::string > getVector()
return vector of strings
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
bool isCurrentSupermodeData() const
@check if current supermode is Data
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network