107 myAttributesCreatorParent(AttributesCreatorParent),
108 myAttrProperties(attrProperties) {
111 myAttributeLabel->hide();
113 myAttributeRadioButton->hide();
115 myAttributeCheckButton->hide();
117 myAttributeColorButton->hide();
120 myValueTextFieldInt->hide();
122 myValueTextFieldReal->hide();
124 myValueTextFieldStrings->hide();
126 myValueCheckButton->hide();
128 if ((attrProperties.getTagPropertyParent().isStop() || attrProperties.getTagPropertyParent().isPersonStop()) && (attrProperties.getAttr() ==
SUMO_ATTR_UNTIL)) {
129 myAttributeCheckButton->setCheck(FALSE);
131 myAttributeCheckButton->setCheck(TRUE);
134 if (getParent()->
id()) {
136 FXHorizontalFrame::create();
140 if (myAttrProperties.isColor()) {
141 myAttributeColorButton->setTextColor(FXRGB(0, 0, 0));
142 myAttributeColorButton->setText(myAttrProperties.getAttrStr().c_str());
143 myAttributeColorButton->show();
144 }
else if (myAttrProperties.isEnablitable()) {
145 myAttributeRadioButton->setTextColor(FXRGB(0, 0, 0));
146 myAttributeRadioButton->setText(myAttrProperties.getAttrStr().c_str());
147 myAttributeRadioButton->show();
148 }
else if (myAttrProperties.isOptional()) {
149 myAttributeCheckButton->setText(myAttrProperties.getAttrStr().c_str());
150 myAttributeCheckButton->show();
152 myAttributeLabel->setText(myAttrProperties.getAttrStr().c_str());
153 myAttributeLabel->show();
155 if (myAttrProperties.isInt()) {
156 myValueTextFieldInt->setTextColor(FXRGB(0, 0, 0));
157 myValueTextFieldInt->setText(attrProperties.getDefaultValue().c_str());
158 myValueTextFieldInt->show();
160 if (myAttributeRadioButton->shown() && (myAttributeRadioButton->getCheck() == FALSE)) {
161 myValueTextFieldInt->disable();
164 if (myAttributeCheckButton->shown() && (myAttributeCheckButton->getCheck() == FALSE)) {
165 myValueTextFieldInt->disable();
167 }
else if (myAttrProperties.isFloat() || myAttrProperties.isSUMOTime()) {
168 myValueTextFieldReal->setTextColor(FXRGB(0, 0, 0));
169 myValueTextFieldReal->setText(attrProperties.getDefaultValue().c_str());
170 myValueTextFieldReal->show();
172 if (myAttributeRadioButton->shown() && (myAttributeRadioButton->getCheck() == FALSE)) {
173 myValueTextFieldReal->disable();
176 if (myAttributeCheckButton->shown() && (myAttributeCheckButton->getCheck() == FALSE)) {
177 myValueTextFieldReal->disable();
179 }
else if (myAttrProperties.isBool()) {
180 if (GNEAttributeCarrier::parse<bool>(attrProperties.getDefaultValue())) {
181 myValueCheckButton->setCheck(
true);
182 myValueCheckButton->setText(
"true");
184 myValueCheckButton->setCheck(
false);
185 myValueCheckButton->setText(
"false");
187 myValueCheckButton->show();
189 if (myAttributeRadioButton->shown() && (myAttributeRadioButton->getCheck() == FALSE)) {
190 myValueCheckButton->disable();
193 if (myAttributeCheckButton->shown() && (myAttributeCheckButton->getCheck() == FALSE)) {
194 myValueCheckButton->disable();
197 myValueTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
198 myValueTextFieldStrings->setText(attrProperties.getDefaultValue().c_str());
199 myValueTextFieldStrings->show();
201 if (myAttributeRadioButton->shown() && (myAttributeRadioButton->getCheck() == FALSE)) {
202 myValueTextFieldStrings->disable();
205 if (myAttributeCheckButton->shown() && (myAttributeCheckButton->getCheck() == FALSE)) {
206 myValueTextFieldStrings->disable();
218 if (getParent()->
id()) {
219 FXHorizontalFrame::destroy();
226 return myAttrProperties;
232 if (myAttrProperties.isBool()) {
233 return (myValueCheckButton->getCheck() == 1) ?
"1" :
"0";
234 }
else if (myAttrProperties.isInt()) {
235 return myValueTextFieldInt->getText().text();
236 }
else if (myAttrProperties.isFloat() || myAttrProperties.isSUMOTime()) {
237 return myValueTextFieldReal->getText().text();
239 return myValueTextFieldStrings->getText().text();
247 return myAttributeRadioButton->getCheck() == TRUE;
258 myAttributeRadioButton->setCheck(value);
261 if (myAttrProperties.isBool()) {
262 myValueCheckButton->enable();
263 }
else if (myAttrProperties.isInt()) {
264 myValueTextFieldInt->enable();
265 }
else if (myAttrProperties.isFloat() || myAttrProperties.isSUMOTime()) {
266 myValueTextFieldReal->enable();
268 myValueTextFieldStrings->enable();
271 if (myAttrProperties.isBool()) {
272 myValueCheckButton->disable();
273 }
else if (myAttrProperties.isInt()) {
274 myValueTextFieldInt->disable();
275 }
else if (myAttrProperties.isFloat() || myAttrProperties.isSUMOTime()) {
276 myValueTextFieldReal->disable();
278 myValueTextFieldStrings->disable();
288 return myAttributeCheckButton->getCheck() == TRUE;
299 myAttributeCheckButton->setCheck(value);
302 if (myAttrProperties.isBool()) {
303 myValueCheckButton->enable();
304 }
else if (myAttrProperties.isInt()) {
305 myValueTextFieldInt->enable();
306 }
else if (myAttrProperties.isFloat() || myAttrProperties.isSUMOTime()) {
307 myValueTextFieldReal->enable();
309 myValueTextFieldStrings->enable();
312 if (myAttrProperties.isBool()) {
313 myValueCheckButton->disable();
314 }
else if (myAttrProperties.isInt()) {
315 myValueTextFieldInt->disable();
316 }
else if (myAttrProperties.isFloat() || myAttrProperties.isSUMOTime()) {
317 myValueTextFieldReal->disable();
319 myValueTextFieldStrings->disable();
328 if (myAttrProperties.isBool()) {
329 return myValueCheckButton->enable();
330 }
else if (myAttrProperties.isInt()) {
331 return myValueTextFieldInt->enable();
332 }
else if (myAttrProperties.isFloat() || myAttrProperties.isSUMOTime()) {
333 return myValueTextFieldReal->enable();
335 return myValueTextFieldStrings->enable();
342 if (myAttrProperties.isBool()) {
343 return myValueCheckButton->disable();
344 }
else if (myAttrProperties.isInt()) {
345 return myValueTextFieldInt->disable();
346 }
else if (myAttrProperties.isFloat() || myAttrProperties.isSUMOTime()) {
347 return myValueTextFieldReal->disable();
349 return myValueTextFieldStrings->disable();
358 }
else if (myAttrProperties.isBool()) {
359 return myValueCheckButton->isEnabled();
360 }
else if (myAttrProperties.isInt()) {
361 return myValueTextFieldInt->isEnabled();
362 }
else if (myAttrProperties.isFloat() || myAttrProperties.isSUMOTime()) {
363 return myValueTextFieldReal->isEnabled();
365 return myValueTextFieldStrings->isEnabled();
372 return myInvalidValue;
378 return myAttributesCreatorParent;
387 if (obj == myValueCheckButton) {
388 if (myValueCheckButton->getCheck()) {
389 myValueCheckButton->setText(
"true");
391 myValueCheckButton->setText(
"false");
394 myAttributesCreatorParent->updateDisjointAttributes(
nullptr);
395 }
else if (myAttrProperties.isComplex()) {
397 myInvalidValue = checkComplexAttribute(myValueTextFieldStrings->getText().text());
398 }
else if (myAttrProperties.isInt()) {
399 if (GNEAttributeCarrier::canParse<int>(myValueTextFieldInt->getText().text())) {
401 int intValue = GNEAttributeCarrier::parse<int>(myValueTextFieldInt->getText().text());
403 if (myAttrProperties.isPositive() && (intValue < 0)) {
404 myInvalidValue =
"'" + myAttrProperties.getAttrStr() +
"' cannot be negative";
407 myInvalidValue =
"'" + myAttrProperties.getAttrStr() +
"' doesn't have a valid 'int' format";
409 }
else if (myAttrProperties.isSUMOTime()) {
411 if (!GNEAttributeCarrier::canParse<SUMOTime>(myValueTextFieldReal->getText().text())) {
412 myInvalidValue =
"'" + myAttrProperties.getAttrStr() +
"' doesn't have a valid SUMOTime format";
414 }
else if (myAttrProperties.isFloat()) {
415 if (GNEAttributeCarrier::canParse<double>(myValueTextFieldReal->getText().text())) {
417 double doubleValue = GNEAttributeCarrier::parse<double>(myValueTextFieldReal->getText().text());
419 if (myAttrProperties.isPositive() && (doubleValue < 0)) {
420 myInvalidValue =
"'" + myAttrProperties.getAttrStr() +
"' cannot be negative";
422 }
else if (myAttrProperties.isProbability() && ((doubleValue < 0) || doubleValue > 1)) {
423 myInvalidValue =
"'" + myAttrProperties.getAttrStr() +
"' takes only values between 0 and 1";
424 }
else if (myAttrProperties.hasAttrRange() && ((doubleValue < myAttrProperties.getMinimumRange()) || doubleValue > myAttrProperties.getMaximumRange())) {
425 myInvalidValue =
"'" + myAttrProperties.getAttrStr() +
"' takes only values between " +
toString(myAttrProperties.getMinimumRange()) +
" and " +
toString(myAttrProperties.getMaximumRange());
426 }
else if ((myAttributesCreatorParent->getCurrentTagProperties().getTag() ==
SUMO_TAG_E2DETECTOR) && (myAttrProperties.getAttr() ==
SUMO_ATTR_LENGTH) && (doubleValue == 0)) {
427 myInvalidValue =
"E2 length cannot be 0";
430 myInvalidValue =
"'" + myAttrProperties.getAttrStr() +
"' doesn't have a valid 'float' format";
432 }
else if (myAttrProperties.isColor()) {
434 if (GNEAttributeCarrier::canParse<RGBColor>(myValueTextFieldStrings->getText().text()) ==
false) {
435 myInvalidValue =
"'" + myAttrProperties.getAttrStr() +
"' doesn't have a valid 'RBGColor' format";
437 }
else if (myAttrProperties.isFilename()) {
438 std::string file = myValueTextFieldStrings->getText().text();
441 myInvalidValue =
"input contains invalid characters for a filename";
446 myInvalidValue =
"doesn't exist image '" + file +
"'";
451 std::string name = myValueTextFieldStrings->getText().text();
454 myInvalidValue =
"input contains invalid characters";
457 std::string name = myValueTextFieldStrings->getText().text();
460 myInvalidValue =
"list of IDs contains invalid characters";
464 std::string index = myValueTextFieldStrings->getText().text();
465 if ((index !=
"fit") && (index !=
"end") && !GNEAttributeCarrier::canParse<int>(index)) {
466 myInvalidValue =
"index isn't either 'fit' or 'end' or a valid positive int";
467 }
else if (GNEAttributeCarrier::canParse<int>(index) && (GNEAttributeCarrier::parse<int>(index) < 0)) {
468 myInvalidValue =
"index cannot be negative";
472 std::vector<std::string> vehicleIDs = GNEAttributeCarrier::parse<std::vector<std::string> >(myValueTextFieldStrings->getText().text());
474 for (
const auto &i : vehicleIDs) {
476 myInvalidValue =
"invalid id used in " + myAttrProperties.getAttrStr();
480 if (myValueTextFieldStrings->getText().text() !=
"waiting") {
481 myInvalidValue =
"invalid " + myAttrProperties.getAttrStr();
485 myInvalidValue =
"invalid id used in " + myAttrProperties.getAttrStr();
489 if (myInvalidValue.size() == 0) {
490 myValueTextFieldInt->setTextColor(FXRGB(0, 0, 0));
491 myValueTextFieldInt->killFocus();
492 myValueTextFieldReal->setTextColor(FXRGB(0, 0, 0));
493 myValueTextFieldReal->killFocus();
494 myValueTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
495 myValueTextFieldStrings->killFocus();
498 myValueTextFieldInt->setTextColor(FXRGB(255, 0, 0));
499 myValueTextFieldReal->setTextColor(FXRGB(255, 0, 0));
500 myValueTextFieldStrings->setTextColor(FXRGB(255, 0, 0));
510 if (myAttributeCheckButton->getCheck()) {
512 myValueCheckButton->enable();
513 myValueTextFieldInt->enable();
514 myValueTextFieldReal->enable();
515 myValueTextFieldStrings->enable();
518 myValueCheckButton->disable();
519 myValueTextFieldInt->disable();
520 myValueTextFieldReal->disable();
521 myValueTextFieldStrings->disable();
530 FXColorDialog colordialog(
this, tr(
"Color Dialog"));
531 colordialog.setTarget(
this);
533 if (GNEAttributeCarrier::canParse<RGBColor>(myValueTextFieldStrings->getText().text())) {
539 if (colordialog.execute()) {
541 onCmdSetAttribute(
nullptr, 0,
nullptr);
549 WRITE_DEBUG(
"Selected radio button for attribute '" + myAttrProperties.getAttrStr() +
"'");
551 myAttributesCreatorParent->updateDisjointAttributes(
this);
559 std::string errorMessage;
574 switch (myAttrProperties.getAttr()) {
619 myFrameParent(frameParent) {
633 myTagProperties = tagProperties;
635 for (
int i = 0; i < (int)myAttributesCreatorRows.size(); i++) {
637 if (myAttributesCreatorRows.at(i) !=
nullptr) {
638 myAttributesCreatorRows.at(i)->destroy();
639 delete myAttributesCreatorRows.at(i);
640 myAttributesCreatorRows.at(i) =
nullptr;
644 for (
const auto& i : myTagProperties) {
651 updateDisjointAttributes(
nullptr);
653 myHelpButton->reparent(
this);
667 std::map<SumoXMLAttr, std::string>
669 std::map<SumoXMLAttr, std::string> values;
671 for (
int i = 0; i < (int)myAttributesCreatorRows.size(); i++) {
672 if (myAttributesCreatorRows.at(i) && myAttributesCreatorRows.at(i)->getAttrProperties().getAttr() !=
SUMO_ATTR_NOTHING) {
674 bool rowEnabled = myAttributesCreatorRows.at(i)->isAttributesCreatorRowEnabled();
676 bool hasDefaultStaticValue = !myAttributesCreatorRows.at(i)->getAttrProperties().hasStaticDefaultValue() || (myAttributesCreatorRows.at(i)->getAttrProperties().getDefaultValue() != myAttributesCreatorRows.at(i)->getValue());
678 bool isEnablitableAttribute = myAttributesCreatorRows.at(i)->getAttrProperties().isEnablitable();
680 bool isOptionalAttribute = myAttributesCreatorRows.at(i)->getAttrProperties().isOptional() && myAttributesCreatorRows.at(i)->getAttributeCheckButtonCheck();
682 if (rowEnabled && (includeAll || hasDefaultStaticValue || isEnablitableAttribute || isOptionalAttribute)) {
683 values[myAttributesCreatorRows.at(i)->getAttrProperties().getAttr()] = myAttributesCreatorRows.at(i)->getValue();
693 return myTagProperties;
699 std::string errorMessage;
701 for (
const auto& i : myTagProperties) {
702 if (errorMessage.empty() && myAttributesCreatorRows.at(i.getPositionListed())) {
704 std::string attributeValue = myAttributesCreatorRows.at(i.getPositionListed())->isAttributeValid();
705 if (attributeValue.size() != 0) {
706 errorMessage = attributeValue;
711 if (extra.size() == 0) {
712 errorMessage =
"Invalid input parameter of " + myTagProperties.getTagStr() +
": " + errorMessage;
714 errorMessage =
"Invalid input parameter of " + myTagProperties.getTagStr() +
": " + extra;
718 myFrameParent->myViewNet->setStatusBarText(errorMessage);
727 for (
auto i : myTagProperties) {
729 if (myAttributesCreatorRows.at(i.getPositionListed()) && myAttributesCreatorRows.at(i.getPositionListed())->isAttributeValid().size() != 0) {
747 if (row ==
nullptr) {
811 }
else if (myTagProperties.isStop() || myTagProperties.isPersonStop()) {
813 if (myAttributesCreatorRows[myTagProperties.getAttributeProperties(
SUMO_ATTR_TRIGGERED).getPositionListed()]->getValue() ==
"1") {
814 myAttributesCreatorRows[myTagProperties.getAttributeProperties(
SUMO_ATTR_EXPECTED).getPositionListed()]->enableAttributesCreatorRow();
816 myAttributesCreatorRows[myTagProperties.getAttributeProperties(
SUMO_ATTR_EXPECTED).getPositionListed()]->disableAttributesCreatorRow();
820 myAttributesCreatorRows[myTagProperties.getAttributeProperties(
SUMO_ATTR_EXPECTED_CONTAINERS).getPositionListed()]->enableAttributesCreatorRow();
822 myAttributesCreatorRows[myTagProperties.getAttributeProperties(
SUMO_ATTR_EXPECTED_CONTAINERS).getPositionListed()]->disableAttributesCreatorRow();
831 myFrameParent->openHelpAttributesDialog(myTagProperties);
841 myAttributesEditorParent(attributeEditorParent),
875 if (getParent()->
id()) {
877 FXHorizontalFrame::create();
919 if (attributeEnabled) {
932 bool allBooleanValuesEqual =
true;
934 std::vector<bool> booleanVector;
937 booleanVector = GNEAttributeCarrier::parse<std::vector<bool> >(value);
940 for (
const auto& i : booleanVector) {
941 if (i != booleanVector.front()) {
942 allBooleanValuesEqual =
false;
946 if (allBooleanValuesEqual) {
948 if ((booleanVector.size() > 0) && booleanVector.front()) {
1053 if (getParent()->
id()) {
1054 FXHorizontalFrame::destroy();
1062 myValueTextFieldInt->enable();
1063 myValueTextFieldReal->enable();
1064 myValueTextFieldStrings->enable();
1065 myValueComboBoxChoices->enable();
1066 myValueCheckButton->enable();
1067 myAttributeButtonCombinableChoices->enable();
1068 myAttributeColorButton->enable();
1069 myAttributeRadioButton->enable();
1070 myAttributeCheckButton->enable();
1072 if (myAttributeRadioButton->shown()) {
1073 myAttributeRadioButton->setCheck(disjointAttributeEnabled);
1076 if (myAttributeCheckButton->shown()) {
1077 myAttributeCheckButton->setCheck( FALSE);
1079 if (myValueTextFieldInt->shown()) {
1081 if (myValueTextFieldInt->getTextColor() == FXRGB(0, 0, 0) || forceRefresh) {
1082 myValueTextFieldInt->setText(value.c_str());
1083 myValueTextFieldInt->setTextColor(FXRGB(0, 0, 0));
1086 if (myACAttr.isNonEditable() || !disjointAttributeEnabled) {
1087 myValueTextFieldInt->disable();
1089 }
else if (myValueTextFieldReal->shown()) {
1091 if (myValueTextFieldReal->getTextColor() == FXRGB(0, 0, 0) || forceRefresh) {
1092 myValueTextFieldReal->setText(value.c_str());
1093 myValueTextFieldReal->setTextColor(FXRGB(0, 0, 0));
1096 if (myACAttr.isNonEditable() || !disjointAttributeEnabled) {
1097 myValueTextFieldReal->disable();
1099 }
else if (myValueTextFieldStrings->shown()) {
1101 if (myValueTextFieldStrings->getTextColor() == FXRGB(0, 0, 0) || forceRefresh) {
1102 myValueTextFieldStrings->setText(value.c_str());
1103 myValueTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
1106 if (myACAttr.isNonEditable() || !disjointAttributeEnabled) {
1107 myValueTextFieldStrings->disable();
1109 }
else if (myValueComboBoxChoices->shown()) {
1111 myValueComboBoxChoices->clearItems();
1112 for (
const auto& it : myACAttr.getDiscreteValues()) {
1113 myValueComboBoxChoices->appendItem(it.c_str());
1116 myValueComboBoxChoices->setNumVisible((
int)myACAttr.getDiscreteValues().size());
1117 myValueComboBoxChoices->setCurrentItem(myValueComboBoxChoices->findItem(value.c_str()));
1118 myValueComboBoxChoices->setTextColor(FXRGB(0, 0, 0));
1119 myValueComboBoxChoices->show();
1121 if (myACAttr.isNonEditable() || !disjointAttributeEnabled) {
1122 myValueComboBoxChoices->disable();
1124 }
else if (myValueCheckButton->shown()) {
1125 if (GNEAttributeCarrier::canParse<bool>(value)) {
1126 myValueCheckButton->setCheck(GNEAttributeCarrier::parse<bool>(value));
1128 myValueCheckButton->setCheck(
false);
1131 if (myACAttr.isNonEditable() || !disjointAttributeEnabled) {
1132 myValueCheckButton->disable();
1137 if (((myAttributesEditorParent->getFrameParent()->myViewNet->getEditModes().currentSupermode ==
GNE_SUPERMODE_NETWORK) && myACAttr.getTagPropertyParent().isDemandElement()) ||
1138 ((myAttributesEditorParent->getFrameParent()->myViewNet->getEditModes().currentSupermode ==
GNE_SUPERMODE_DEMAND) && !myACAttr.getTagPropertyParent().isDemandElement())) {
1139 myAttributeColorButton->disable();
1140 myAttributeRadioButton->disable();
1141 myAttributeCheckButton->disable();
1142 myValueTextFieldInt->disable();
1143 myValueTextFieldReal->disable();
1144 myValueTextFieldStrings->disable();
1145 myValueComboBoxChoices->disable();
1146 myValueCheckButton->disable();
1147 myAttributeButtonCombinableChoices->disable();
1151 myValueTextFieldStrings->disable();
1156 myValueTextFieldStrings->disable();
1159 if ((myACAttr.getTagPropertyParent().isStop() || myACAttr.getTagPropertyParent().isPersonStop()) &&
1162 myValueTextFieldStrings->disable();
1170 return ((myValueTextFieldInt->getTextColor() == FXRGB(0, 0, 0)) && (myValueTextFieldReal->getTextColor() == FXRGB(0, 0, 0)) &&
1171 (myValueTextFieldStrings->getTextColor() == FXRGB(0, 0, 0)) && (myValueComboBoxChoices->getTextColor() == FXRGB(0, 0, 0)));
1177 if (obj == myAttributeColorButton) {
1179 FXColorDialog colordialog(
this, tr(
"Color Dialog"));
1180 colordialog.setTarget(
this);
1182 if (GNEAttributeCarrier::canParse<RGBColor>(myValueTextFieldStrings->getText().text())) {
1184 }
else if (!myACAttr.getDefaultValue().empty()) {
1190 if (colordialog.execute()) {
1192 myValueTextFieldStrings->setText(newValue.c_str());
1193 if (myAttributesEditorParent->getEditedACs().front()->isValid(myACAttr.getAttr(), newValue)) {
1195 if (myAttributesEditorParent->getEditedACs().size() > 1) {
1196 myAttributesEditorParent->getFrameParent()->myViewNet->getUndoList()->p_begin(
"Change multiple attributes");
1199 for (
const auto& it_ac : myAttributesEditorParent->getEditedACs()) {
1200 it_ac->setAttribute(myACAttr.getAttr(), newValue, myAttributesEditorParent->getFrameParent()->myViewNet->getUndoList());
1203 myValueTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
1204 myValueTextFieldStrings->killFocus();
1208 }
else if (obj == myAttributeButtonCombinableChoices) {
1210 if (myAttributesEditorParent->getEditedACs().size() > 1) {
1211 myAttributesEditorParent->getFrameParent()->myViewNet->getUndoList()->p_begin(
"Change multiple attributes");
1214 GNEDialog_AllowDisallow(myAttributesEditorParent->getFrameParent()->myViewNet, myAttributesEditorParent->getEditedACs().front()).execute();
1215 std::string allowed = myAttributesEditorParent->getEditedACs().front()->getAttribute(
SUMO_ATTR_ALLOW);
1217 for (
const auto& it_ac : myAttributesEditorParent->getEditedACs()) {
1218 it_ac->setAttribute(
SUMO_ATTR_ALLOW, allowed, myAttributesEditorParent->getFrameParent()->myViewNet->getUndoList());
1221 if (myAttributesEditorParent->getEditedACs().size() > 1) {
1222 myAttributesEditorParent->getFrameParent()->myViewNet->getUndoList()->p_end();
1225 myAttributesEditorParent->getFrameParent()->attributeUpdated();
1228 throw ProcessError(
"Invalid call to onCmdOpenAttributeDialog");
1238 if (myACAttr.isBool()) {
1240 if (myValueCheckButton->shown()) {
1242 if (myValueCheckButton->getCheck()) {
1243 myValueCheckButton->setText(
"true");
1246 myValueCheckButton->setText(
"false");
1251 newVal = myValueTextFieldStrings->getText().text();
1253 }
else if (myACAttr.isDiscrete()) {
1255 if ((myACAttr.getDiscreteValues().size() > 0) &&
1256 myACAttr.isCombinable()) {
1258 newVal = myValueTextFieldStrings->getText().text();
1259 }
else if (!myMultiple) {
1261 newVal = myValueComboBoxChoices->getText().text();
1264 newVal = myValueTextFieldStrings->getText().text();
1266 }
else if (myACAttr.isFloat() || myACAttr.isSUMOTime()) {
1268 if (myValueTextFieldReal->getText().empty() && myACAttr.hasStaticDefaultValue()) {
1269 newVal = myACAttr.getDefaultValue();
1270 myValueTextFieldReal->setText(newVal.c_str());
1273 newVal = myValueTextFieldReal->getText().text();
1275 }
else if (myACAttr.isInt()) {
1277 if (myValueTextFieldInt->getText().empty() && myACAttr.hasStaticDefaultValue()) {
1278 newVal = myACAttr.getDefaultValue();
1279 myValueTextFieldInt->setText(newVal.c_str());
1282 newVal = myValueTextFieldInt->getText().text();
1286 if (myValueTextFieldStrings->getText().empty() && myACAttr.hasStaticDefaultValue()) {
1287 newVal = myACAttr.getDefaultValue();
1288 myValueTextFieldStrings->setText(newVal.c_str());
1291 newVal = myValueTextFieldStrings->getText().text();
1297 newVal = stripWhitespaceAfterComma(newVal);
1301 if (myAttributesEditorParent->getEditedACs().front()->isValid(myACAttr.getAttr(), newVal)) {
1303 if (myAttributesEditorParent->getEditedACs().size() > 1) {
1304 myAttributesEditorParent->getFrameParent()->myViewNet->getUndoList()->p_begin(
"Change multiple attributes");
1307 myAttributesEditorParent->getFrameParent()->myViewNet->getUndoList()->p_begin(
"change " + myACAttr.getTagPropertyParent().getTagStr() +
" attribute");
1310 for (
const auto& it_ac : myAttributesEditorParent->getEditedACs()) {
1311 it_ac->setAttribute(myACAttr.getAttr(), newVal, myAttributesEditorParent->getFrameParent()->myViewNet->getUndoList());
1314 if (myAttributesEditorParent->getEditedACs().size() > 1) {
1315 myAttributesEditorParent->getFrameParent()->myViewNet->getUndoList()->p_end();
1317 myAttributesEditorParent->getFrameParent()->myViewNet->getUndoList()->p_end();
1320 if (myACAttr.isCombinable()) {
1321 myValueTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
1322 myValueTextFieldStrings->killFocus();
1324 myAttributesEditorParent->refreshAttributeEditor(
false,
false);
1325 }
else if (myACAttr.isDiscrete()) {
1326 myValueComboBoxChoices->setTextColor(FXRGB(0, 0, 0));
1327 myValueComboBoxChoices->killFocus();
1328 }
else if (myACAttr.isFloat() || myACAttr.isSUMOTime()) {
1329 myValueTextFieldReal->setTextColor(FXRGB(0, 0, 0));
1330 myValueTextFieldReal->killFocus();
1331 }
else if (myACAttr.isInt() && myValueTextFieldStrings !=
nullptr) {
1332 myValueTextFieldInt->setTextColor(FXRGB(0, 0, 0));
1333 myValueTextFieldInt->killFocus();
1334 }
else if (myValueTextFieldStrings !=
nullptr) {
1335 myValueTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
1336 myValueTextFieldStrings->killFocus();
1339 myAttributesEditorParent->getFrameParent()->attributeUpdated();
1342 if (myACAttr.isCombinable()) {
1343 myValueTextFieldStrings->setTextColor(FXRGB(255, 0, 0));
1344 myValueTextFieldStrings->killFocus();
1345 }
else if (myACAttr.isDiscrete()) {
1346 myValueComboBoxChoices->setTextColor(FXRGB(255, 0, 0));
1347 myValueComboBoxChoices->killFocus();
1348 }
else if (myACAttr.isFloat() || myACAttr.isSUMOTime()) {
1349 myValueTextFieldReal->setTextColor(FXRGB(255, 0, 0));
1350 }
else if (myACAttr.isInt() && myValueTextFieldStrings !=
nullptr) {
1351 myValueTextFieldInt->setTextColor(FXRGB(255, 0, 0));
1352 }
else if (myValueTextFieldStrings !=
nullptr) {
1353 myValueTextFieldStrings->setTextColor(FXRGB(255, 0, 0));
1356 WRITE_DEBUG(
"Value '" + newVal +
"' for attribute " + myACAttr.getAttrStr() +
" of " + myACAttr.getTagPropertyParent().getTagStr() +
" isn't valid");
1364 if (myAttributeCheckButton->getCheck()) {
1366 myValueCheckButton->enable();
1367 myValueTextFieldInt->enable();
1368 myValueTextFieldReal->enable();
1369 myValueTextFieldStrings->enable();
1372 myValueCheckButton->disable();
1373 myValueTextFieldInt->disable();
1374 myValueTextFieldReal->disable();
1375 myValueTextFieldStrings->disable();
1384 GNEUndoList* undoList = myAttributesEditorParent->getFrameParent()->myViewNet->getUndoList();
1386 WRITE_DEBUG(
"Selected radio button for attribute '" + myACAttr.getAttrStr() +
"'");
1388 undoList->
p_begin(
"enable attribute '" + myACAttr.getAttrStr() +
"'");
1390 myAttributesEditorParent->getEditedACs().front()->enableAttribute(myACAttr.getAttr(), undoList);
1394 myAttributesEditorParent->refreshAttributeEditor(
false,
false);
1406 std::string result(stringValue);
1407 while (result.find(
", ") != std::string::npos) {
1419 myFrameParent(FrameParent),
1420 myIncludeExtended(true) {
1431 myIncludeExtended = includeExtended;
1433 for (
int i = 0; i < (int)myAttributesEditorRows.size(); i++) {
1435 if (myAttributesEditorRows.at(i) !=
nullptr) {
1436 myAttributesEditorRows.at(i)->destroy();
1437 delete myAttributesEditorRows.at(i);
1438 myAttributesEditorRows.at(i) =
nullptr;
1441 if (myEditedACs.size() > 0) {
1443 for (
const auto& i : myEditedACs.front()->getTagProperty()) {
1445 if ((myEditedACs.size() > 1) && i.isUnique()) {
1449 if (i.isExtended() && !includeExtended) {
1453 std::set<std::string> occuringValues;
1454 for (
const auto& it_ac : myEditedACs) {
1455 occuringValues.insert(it_ac->getAttribute(i.getAttr()));
1458 std::ostringstream oss;
1459 for (
auto it_val = occuringValues.begin(); it_val != occuringValues.end(); it_val++) {
1460 if (it_val != occuringValues.begin()) {
1465 std::string value = oss.str();
1471 for (
const auto& it_ac : myEditedACs) {
1481 bool attributeEnabled = i.isEnablitable() ? myEditedACs.front()->isAttributeEnabled(i.getAttr()) :
true;
1483 myAttributesEditorRows[i.getPositionListed()] =
new AttributesEditorRow(
this, i, value, attributeEnabled);
1487 myHelpButton->reparent(
this);
1494 myEditedACs.clear();
1502 if (myEditedACs.size() > 0) {
1504 for (
const auto& i : myEditedACs.front()->getTagProperty()) {
1506 if ((myEditedACs.size() > 1) && i.isUnique()) {
1510 std::set<std::string> occuringValues;
1511 for (
const auto& it_ac : myEditedACs) {
1512 occuringValues.insert(it_ac->getAttribute(i.getAttr()));
1515 std::ostringstream oss;
1516 for (
auto it_val = occuringValues.begin(); it_val != occuringValues.end(); it_val++) {
1517 if (it_val != occuringValues.begin()) {
1523 bool attributeEnabled = i.isEnablitable() ? myEditedACs.front()->isAttributeEnabled(i.getAttr()) :
true;
1526 myAttributesEditorRows[i.getPositionListed()]->refreshAttributesEditorRow(oss.str(),
true, attributeEnabled);
1529 myAttributesEditorRows[i.getPositionListed()]->refreshAttributesEditorRow(oss.str(),
true, attributeEnabled);
1532 myAttributesEditorRows[i.getPositionListed()]->refreshAttributesEditorRow(oss.str(),
false, attributeEnabled);
1541 return myFrameParent;
1545 const std::vector<GNEAttributeCarrier*>&
1554 if (myEditedACs.size() > 0) {
1556 auto i = std::find(myEditedACs.begin(), myEditedACs.end(), AC);
1558 if (i != myEditedACs.end()) {
1560 myEditedACs.erase(i);
1562 WRITE_DEBUG(
"Removed inspected element from Inspected ACs. " +
toString(myEditedACs.size()) +
" ACs remains.");
1564 showAttributeEditorModul(myEditedACs, myIncludeExtended);
1573 if (myEditedACs.size() > 0) {
1575 myFrameParent->openHelpAttributesDialog(myEditedACs.front()->getTagProperty());
1586 myFrameParent(frameParent) {
1610 myFrameParent->attributesEditorExtendedDialogOpened();
1620 myFrameParent(inspectorFrameParent),
1622 myGenericParameters(nullptr) {
1632 delete myGenericParameters;
1638 if (AC !=
nullptr) {
1646 refreshGenericParametersEditor();
1655 if (ACs.size() > 0) {
1659 bool differentsGenericParameters =
false;
1660 std::string genericParameter = myACs.front()->getAttribute(
GNE_ATTR_GENERIC);
1661 for (
auto i : myACs) {
1663 differentsGenericParameters =
true;
1667 if (differentsGenericParameters) {
1668 myGenericParameters->clear();
1670 *myGenericParameters = myACs.front()->getGenericParameters();
1673 refreshGenericParametersEditor();
1692 myTextFieldGenericParameter->setText(myAC->getAttribute(
GNE_ATTR_GENERIC).c_str());
1693 myTextFieldGenericParameter->setTextColor(FXRGB(0, 0, 0));
1695 if (((myFrameParent->myViewNet->getEditModes().currentSupermode ==
GNE_SUPERMODE_NETWORK) && myAC->getTagProperty().isDemandElement()) ||
1696 ((myFrameParent->myViewNet->getEditModes().currentSupermode ==
GNE_SUPERMODE_DEMAND) && !myAC->getTagProperty().isDemandElement())) {
1697 myTextFieldGenericParameter->disable();
1698 myEditGenericParameterButton->disable();
1700 myTextFieldGenericParameter->enable();
1701 myEditGenericParameterButton->enable();
1703 }
else if (myACs.size() > 0) {
1705 std::string genericParameter = myACs.front()->getAttribute(
GNE_ATTR_GENERIC);
1706 for (
auto i : myACs) {
1708 genericParameter =
"different generic attributes";
1711 myTextFieldGenericParameter->setText(genericParameter.c_str());
1712 myTextFieldGenericParameter->setTextColor(FXRGB(0, 0, 0));
1714 if (((myFrameParent->myViewNet->getEditModes().currentSupermode ==
GNE_SUPERMODE_NETWORK) && myACs.front()->getTagProperty().isDemandElement()) ||
1715 ((myFrameParent->myViewNet->getEditModes().currentSupermode ==
GNE_SUPERMODE_DEMAND) && !myACs.front()->getTagProperty().isDemandElement())) {
1716 myTextFieldGenericParameter->disable();
1717 myEditGenericParameterButton->disable();
1719 myTextFieldGenericParameter->enable();
1720 myEditGenericParameterButton->enable();
1730 for (
auto i = myGenericParameters->begin(); i != myGenericParameters->end(); i++) {
1731 result += i->first +
"=" + i->second +
"|";
1734 if (!result.empty()) {
1751 myAC->setAttribute(
GNE_ATTR_GENERIC, getGenericParametersStr(), myFrameParent->myViewNet->getUndoList());
1752 }
else if (myACs.size() > 0) {
1753 myFrameParent->myViewNet->getUndoList()->p_begin(
"Change multiple generic attributes");
1754 for (
auto i : myACs) {
1755 i->setAttribute(
GNE_ATTR_GENERIC, getGenericParametersStr(), myFrameParent->myViewNet->getUndoList());
1757 myFrameParent->myViewNet->getUndoList()->p_end();
1759 myFrameParent->attributeUpdated();
1762 refreshGenericParametersEditor();
1774 std::vector<std::string> parsedValues;
1775 StringTokenizer st(myTextFieldGenericParameter->getText().text(),
"|",
true);
1776 while (st.hasNext()) {
1777 parsedValues.push_back(st.next());
1780 for (
auto i : parsedValues) {
1782 WRITE_WARNING(
"Invalid format of Generic Parameter (" + i +
")");
1783 myTextFieldGenericParameter->setTextColor(FXRGB(255, 0, 0));
1788 std::sort(parsedValues.begin(), parsedValues.end());
1789 for (
auto i = parsedValues.begin(); i != parsedValues.end(); i++) {
1790 if (((i + 1) != parsedValues.end())) {
1791 std::vector<std::string> firstKey, secondKey;
1796 firstKey.push_back(stKey1.
next());
1799 secondKey.push_back(stKey2.
next());
1802 if ((firstKey.size() != 2) || (secondKey.size() != 2) || (firstKey.front() == secondKey.front())) {
1803 WRITE_WARNING(
"Generic Parameters wit the same key aren't allowed (" + (*i) +
"," + * (i + 1) +
")");
1804 myTextFieldGenericParameter->setTextColor(FXRGB(255, 0, 0));
1810 myTextFieldGenericParameter->setTextColor(FXRGB(0, 0, 0));
1811 myTextFieldGenericParameter->killFocus();
1813 myGenericParameters->clear();
1814 for (
auto i : parsedValues) {
1815 std::vector<std::string> parsedParameters;
1818 parsedParameters.push_back(stParam.
next());
1822 myGenericParameters->push_back(std::make_pair(parsedParameters.front(), parsedParameters.back()));
1827 myAC->setAttribute(
GNE_ATTR_GENERIC, getGenericParametersStr(), myFrameParent->myViewNet->getUndoList());
1828 }
else if (myACs.size() > 0) {
1829 myFrameParent->myViewNet->getUndoList()->p_begin(
"Change multiple generic attributes");
1830 for (
auto i : myACs) {
1831 i->setAttribute(
GNE_ATTR_GENERIC, getGenericParametersStr(), myFrameParent->myViewNet->getUndoList());
1833 myFrameParent->myViewNet->getUndoList()->p_end();
1835 myFrameParent->attributeUpdated();
1846 myFrameParent(frameParent),
1847 myDeleteLastCreatedPoint(false) {
1854 std::ostringstream information;
1856 <<
"- 'Start drawing' or ENTER\n"
1857 <<
" draws shape boundary.\n"
1858 <<
"- 'Stop drawing' or ENTER\n"
1859 <<
" creates shape.\n"
1860 <<
"- 'Shift + Click'\n"
1861 <<
" removes last created point.\n"
1862 <<
"- 'Abort drawing' or ESC\n"
1863 <<
" removes drawed shape.";
1895 myStartDrawingButton->disable();
1896 myStopDrawingButton->enable();
1897 myAbortDrawingButton->enable();
1905 if (myFrameParent->shapeDrawed()) {
1907 myTemporalShapeShape.clear();
1908 myFrameParent->myViewNet->update();
1910 myStartDrawingButton->enable();
1911 myStopDrawingButton->disable();
1912 myAbortDrawingButton->disable();
1923 myTemporalShapeShape.clear();
1924 myFrameParent->myViewNet->update();
1926 myStartDrawingButton->enable();
1927 myStopDrawingButton->disable();
1928 myAbortDrawingButton->disable();
1934 if (myStopDrawingButton->isEnabled()) {
1935 myTemporalShapeShape.push_back(P);
1937 throw ProcessError(
"A new point cannot be added if drawing wasn't started");
1950 return myTemporalShapeShape;
1956 return myStopDrawingButton->isEnabled();
1962 myDeleteLastCreatedPoint = value;
1968 return myDeleteLastCreatedPoint;
1998 myFrameParent(frameParent),
1999 myCurrentLengthValid(true),
2000 myActualAdditionalReferencePoint(GNE_ADDITIONALREFERENCEPOINT_LEFT) {
2038 bool showFrame =
false;
2041 myLengthLabel->show();
2042 myLengthTextField->show();
2043 myReferencePointMatchBox->show();
2046 myLengthLabel->hide();
2047 myLengthTextField->hide();
2048 myReferencePointMatchBox->hide();
2052 myBlockMovementLabel->show();
2053 myBlockMovementCheckButton->show();
2056 myBlockMovementLabel->hide();
2057 myBlockMovementCheckButton->hide();
2061 myBlockShapeLabel->show();
2062 myBlockShapeCheckButton->show();
2065 myBlockShapeLabel->hide();
2066 myBlockShapeCheckButton->hide();
2070 myClosePolygonLabel->show();
2071 myCloseShapeCheckButton->show();
2074 myClosePolygonLabel->hide();
2075 myCloseShapeCheckButton->hide();
2095 if (myReferencePointMatchBox->shown()) {
2097 if (lane ==
nullptr) {
2099 }
else if (myCurrentLengthValid) {
2103 if (myActualAdditionalReferencePoint == GNE_ADDITIONALREFERENCEPOINT_INVALID) {
2104 std::string errorMessage =
"Current selected reference point isn't valid";
2105 myFrameParent->myViewNet->setStatusBarText(errorMessage);
2111 double lenght = GNEAttributeCarrier::parse<double>(myLengthTextField->getText().text());
2121 if (myBlockMovementCheckButton->shown()) {
2122 if (myBlockMovementCheckButton->getCheck() == 1) {
2129 if (myBlockShapeCheckButton->shown()) {
2130 if (myBlockShapeCheckButton->getCheck() == 1) {
2137 if (myCloseShapeCheckButton->shown()) {
2138 if (myCloseShapeCheckButton->getCheck() == 1) {
2151 if (obj == myBlockMovementCheckButton) {
2152 if (myBlockMovementCheckButton->getCheck()) {
2153 myBlockMovementCheckButton->setText(
"true");
2155 myBlockMovementCheckButton->setText(
"false");
2157 }
else if (obj == myBlockShapeCheckButton) {
2158 if (myBlockShapeCheckButton->getCheck()) {
2159 myBlockShapeCheckButton->setText(
"true");
2161 myBlockShapeCheckButton->setText(
"false");
2163 }
else if (obj == myCloseShapeCheckButton) {
2164 if (myCloseShapeCheckButton->getCheck()) {
2165 myCloseShapeCheckButton->setText(
"true");
2167 myCloseShapeCheckButton->setText(
"false");
2169 }
else if (obj == myLengthTextField) {
2171 if (GNEAttributeCarrier::canParse<double>(myLengthTextField->getText().text()) &&
2172 GNEAttributeCarrier::parse<double>(myLengthTextField->getText().text()) > 0) {
2173 myLengthTextField->setTextColor(FXRGB(0, 0, 0));
2174 myLengthTextField->killFocus();
2175 myCurrentLengthValid =
true;
2177 myLengthTextField->setTextColor(FXRGB(255, 0, 0));
2178 myCurrentLengthValid =
false;
2182 }
else if (obj == myReferencePointMatchBox) {
2184 if (myReferencePointMatchBox->getText() ==
"reference left") {
2185 myReferencePointMatchBox->setTextColor(FXRGB(0, 0, 0));
2186 myActualAdditionalReferencePoint = GNE_ADDITIONALREFERENCEPOINT_LEFT;
2187 myLengthTextField->enable();
2188 }
else if (myReferencePointMatchBox->getText() ==
"reference right") {
2189 myReferencePointMatchBox->setTextColor(FXRGB(0, 0, 0));
2190 myActualAdditionalReferencePoint = GNE_ADDITIONALREFERENCEPOINT_RIGHT;
2191 myLengthTextField->enable();
2192 }
else if (myReferencePointMatchBox->getText() ==
"reference center") {
2193 myLengthTextField->enable();
2194 myReferencePointMatchBox->setTextColor(FXRGB(0, 0, 0));
2195 myActualAdditionalReferencePoint = GNE_ADDITIONALREFERENCEPOINT_CENTER;
2196 myLengthTextField->enable();
2198 myReferencePointMatchBox->setTextColor(FXRGB(255, 0, 0));
2199 myActualAdditionalReferencePoint = GNE_ADDITIONALREFERENCEPOINT_INVALID;
2200 myLengthTextField->disable();
2211 FXDialogBox* additionalNeteditAttributesHelpDialog =
new FXDialogBox(
this,
"Netedit Parameters Help",
GUIDesignDialogBox);
2214 std::ostringstream help;
2216 <<
"- Referece point: Mark the initial position of the additional element.\n"
2217 <<
" Example: If you want to create a busStop with a length of 30 in the point 100 of the lane:\n"
2218 <<
" - Reference Left will create it with startPos = 70 and endPos = 100.\n"
2219 <<
" - Reference Right will create it with startPos = 100 and endPos = 130.\n"
2220 <<
" - Reference Center will create it with startPos = 85 and endPos = 115.\n"
2222 <<
"- Block movement: if is enabled, the created additional element will be blocked. i.e. cannot be moved with\n"
2223 <<
" the mouse. This option can be modified inspecting element.";
2235 WRITE_DEBUG(
"Opening NeteditAttributes help dialog");
2237 additionalNeteditAttributesHelpDialog->create();
2239 additionalNeteditAttributesHelpDialog->show(PLACEMENT_CURSOR);
2241 getApp()->refresh();
2243 getApp()->runModalFor(additionalNeteditAttributesHelpDialog);
2245 WRITE_DEBUG(
"Closing NeteditAttributes help dialog");
2264 switch (myActualAdditionalReferencePoint) {
2265 case GNE_ADDITIONALREFERENCEPOINT_LEFT:
2266 return positionOfTheMouseOverLane;
2267 case GNE_ADDITIONALREFERENCEPOINT_RIGHT:
2268 return positionOfTheMouseOverLane - lengthOfAdditional;
2269 case GNE_ADDITIONALREFERENCEPOINT_CENTER:
2270 return positionOfTheMouseOverLane - lengthOfAdditional / 2;
2279 switch (myActualAdditionalReferencePoint) {
2280 case GNE_ADDITIONALREFERENCEPOINT_LEFT:
2281 return positionOfTheMouseOverLane + lengthOfAdditional;
2282 case GNE_ADDITIONALREFERENCEPOINT_RIGHT:
2283 return positionOfTheMouseOverLane;
2284 case GNE_ADDITIONALREFERENCEPOINT_CENTER:
2285 return positionOfTheMouseOverLane + lengthOfAdditional / 2;