Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEAttributesEditorRow.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Row used for edit attributes in GNEAttributesEditor
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
30
32
33// ===========================================================================
34// FOX callback mapping
35// ===========================================================================
36
47
48// Object implementation
49FXIMPLEMENT(GNEAttributesEditorRow, FXHorizontalFrame, GNEAttributeRowMap, ARRAYNUMBER(GNEAttributeRowMap))
50
51// ===========================================================================
52// defines
53// ===========================================================================
54
55#define TEXTCOLOR_BLACK FXRGB(0, 0, 0)
56#define TEXTCOLOR_BLUE FXRGB(0, 0, 255)
57#define TEXTCOLOR_RED FXRGB(255, 0, 0)
58#define TEXTCOLOR_BACKGROUND_RED FXRGBA(255, 213, 213, 255)
59#define TEXTCOLOR_BACKGROUND_WHITE FXRGB(255, 255, 255)
60
61// ===========================================================================
62// method definitions
63// ===========================================================================
64
66 FXHorizontalFrame(attributeTable->getCollapsableFrame(), GUIDesignAuxiliarHorizontalFrame),
67 myAttributeTable(attributeTable) {
68 // get static tooltip menu
69 const auto tooltipMenu = attributeTable->getFrameParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu();
70 // Create left label
71 myAttributeLabel = new MFXLabelTooltip(this, tooltipMenu, "Label", nullptr, GUIDesignLabelThickedFixed(100));
72 myAttributeLabel->hide();
73 // create lef boolean checkBox for enable/disable attributes
74 myAttributeToggleEnableCheckButton = new FXCheckButton(this, "Enable/Disable attribute checkBox", this,
77 // create left button for reparent
78 myAttributeReparentButton = new MFXButtonTooltip(this, tooltipMenu, "Reparent", nullptr, this,
80 myAttributeReparentButton->setHelpText(TL("Change parent of this element"));
82 // create left button for inspect parent
83 myAttributeInspectParentButton = new MFXButtonTooltip(this, tooltipMenu, "Inspect parent button", nullptr, this,
86 // create lef button for edit allow/disallow vClasses
87 myAttributeVClassButton = new MFXButtonTooltip(this, tooltipMenu, "Edit vClass button", nullptr, this,
90 // set tip text for edit vClasses button
91 myAttributeVClassButton->setTipText(TL("Open dialog for editing vClasses"));
92 myAttributeVClassButton->setHelpText(TL("Open dialog for editing vClasses"));
93 // create lef attribute for edit color
94 myAttributeColorButton = new MFXButtonTooltip(this, tooltipMenu, "color button", GUIIconSubSys::getIcon(GUIIcon::COLORWHEEL), this,
97 // set tip text for color button
98 myAttributeColorButton->setTipText(TL("Open dialog for editing color"));
99 myAttributeColorButton->setHelpText(TL("Open dialog for editing color"));
100 // create right text field for string attributes
101 myValueTextField = new MFXTextFieldTooltip(this, tooltipMenu, GUIDesignTextFieldNCol, this,
103 myValueTextField->hide();
104 // create right combo box for discrete attributes
107 myValueComboBox->hide();
108 // Create right check button
109 myValueCheckButton = new FXCheckButton(this, "check button", this, MID_GNE_ATTRIBUTESEDITORROW_SETATTRIBUTE, GUIDesignCheckButton);
110 myValueCheckButton->hide();
111 // create right move lane up button
114 myValueLaneUpButton->hide();
115 // set tip texts
116 myValueLaneUpButton->setTipText(TL("Move element up one lane"));
117 myValueLaneUpButton->setHelpText(TL("Move element up one lane"));
118 // create right move lane down button
121 myValueLaneDownButton->hide();
122 // set tip texts
123 myValueLaneDownButton->setTipText(TL("Move element down one lane"));
124 myValueLaneDownButton->setHelpText(TL("Move element down one lane"));
125}
126
127
128bool
129GNEAttributesEditorRow::showAttributeRow(const GNEAttributeProperties& attrProperty, const bool forceDisable) {
130 if (myAttributeTable->myEditedACs.empty()) {
131 return false;
132 }
133 myAttribute = attrProperty.getAttr();
134 const auto& tagProperty = attrProperty.getTagPropertyParent();
135 const auto firstEditedAC = myAttributeTable->myEditedACs.front();
136 // check if we're editing multiple ACs
137 const auto multipleEditedACs = (myAttributeTable->myEditedACs.size() > 1);
138 // declare flag for show attribute enabled
139 const bool attributeEnabled = attrProperty.isAlwaysEnabled() ? true : firstEditedAC->isAttributeEnabled(myAttribute);
140 // check if this attribute is computed
141 const bool computedAttribute = multipleEditedACs ? false : firstEditedAC->isAttributeComputed(myAttribute);
142 // get string value depending if attribute is enabled
143 const std::string value = getAttributeValue(attributeEnabled);
144 // get parent if we're editing single vTypes
145 GNEAttributeCarrier* ACParent = nullptr;
146 if (!multipleEditedACs && attrProperty.isVType()) {
148 // parent can be either type or distribution
150 ACParent = ACs->retrieveDemandElement(SUMO_TAG_VTYPE, firstEditedAC->getAttribute(SUMO_ATTR_TYPE), false);
151 }
152 if (ACParent == nullptr) {
153 ACParent = ACs->retrieveDemandElement(SUMO_TAG_VTYPE_DISTRIBUTION, firstEditedAC->getAttribute(SUMO_ATTR_TYPE), false);
154 }
155 }
156 // hide editing for unique attributes in case of multi-selection
157 if (multipleEditedACs && attrProperty.isUnique()) {
158 return hideAttributeRow();
159 }
160 // front element has their own button, and doesn't use the UndoList
162 return hideAttributeRow();
163 }
164 // if we have a disabled flow attribute, don't show row
165 if (attrProperty.isFlow() && !attributeEnabled) {
166 return hideAttributeRow();
167 }
168 // expected and joins depend of triggered
169 if (tagProperty.isVehicleStop() && !attributeEnabled) {
171 return hideAttributeRow();
173 return hideAttributeRow();
174 } else if (myAttribute == SUMO_ATTR_JOIN) {
175 return hideAttributeRow();
176 }
177 }
178 // don't show stop offset exception if stopOffset is zero
180 (GNEAttributeCarrier::parse<double>(firstEditedAC->getAttribute(GNE_ATTR_STOPOFFSET)) == 0)) {
181 return hideAttributeRow();
182 }
183 // show elements depending of attribute properties
184 if (attrProperty.isActivatable()) {
185 showAttributeToggleEnable(attrProperty, firstEditedAC->isAttributeEnabled(myAttribute));
186 } else if (myAttribute == GNE_ATTR_PARENT) {
187 showAttributeReparent(attributeEnabled);
188 } else if ((myAttribute == SUMO_ATTR_TYPE) && tagProperty.hasTypeParent()) {
189 showAttributeInspectParent(attrProperty, attributeEnabled);
190 } else if (attrProperty.isVClass() && (myAttribute != SUMO_ATTR_DISALLOW)) {
191 showAttributeVClass(attrProperty, attributeEnabled);
192 } else if (myAttribute == SUMO_ATTR_COLOR) {
193 showAttributeColor(attrProperty, attributeEnabled);
194 } else {
195 showAttributeLabel(attrProperty);
196 }
197 // continue depending of type of attribute
198 if (attrProperty.isBool()) {
199 showValueCheckButton(value, attributeEnabled, computedAttribute);
200 } else if (!attrProperty.isVClass() && (attrProperty.isDiscrete() || attrProperty.isVType())) {
201 showValueComboBox(attrProperty, value, attributeEnabled, computedAttribute);
202 } else {
203 showValueString(value, attributeEnabled, computedAttribute);
204 }
205 // check if show move lane buttons
206 if (!multipleEditedACs && !tagProperty.isNetworkElement() && (myAttribute == SUMO_ATTR_LANE)) {
207 showMoveLaneButtons(value);
208 myValueLaneUpButton->show();
209 myValueLaneDownButton->show();
210 } else {
211 myValueLaneUpButton->hide();
212 myValueLaneDownButton->hide();
213 }
214 // enable depending of supermode
215 enableElements(attrProperty, forceDisable);
216 // Show row
217 show();
218 return true;
219}
220
221
222bool
224 hide();
225 return false;
226}
227
228
229bool
231 return shown();
232}
233
234
235long
236GNEAttributesEditorRow::onCmdOpenColorDialog(FXObject*, FXSelector, void*) {
237 const auto& attrProperty = myAttributeTable->myEditedACs.front()->getTagProperty().getAttributeProperties(myAttribute);
238 // create FXColorDialog
239 FXColorDialog colordialog(this, TL("Color Dialog"));
240 colordialog.setTarget(this);
241 colordialog.setIcon(GUIIconSubSys::getIcon(GUIIcon::COLORWHEEL));
242 // If previous attribute wasn't correct, set black as default color
243 if (GNEAttributeCarrier::canParse<RGBColor>(myValueTextField->getText().text())) {
244 colordialog.setRGBA(MFXUtils::getFXColor(GNEAttributeCarrier::parse<RGBColor>(myValueTextField->getText().text())));
245 } else if (!attrProperty.getDefaultValue().empty()) {
246 colordialog.setRGBA(MFXUtils::getFXColor(GNEAttributeCarrier::parse<RGBColor>(attrProperty.getDefaultValue())));
247 } else {
248 colordialog.setRGBA(MFXUtils::getFXColor(RGBColor::BLACK));
249 }
250 // execute dialog to get a new color in the text field
251 if (colordialog.execute()) {
252 myValueTextField->setText(toString(MFXUtils::getRGBColor(colordialog.getRGBA())).c_str(), TRUE);
253 }
254 return 1;
255}
256
257
258long
259GNEAttributesEditorRow::onCmdOpenAllowDialog(FXObject*, FXSelector, void*) {
260 // declare values to be modified
261 std::string allowedVehicles = myValueTextField->getText().text();
262 // declare accept changes
263 bool acceptChanges = false;
264 // open GNEAllowVClassesDialog (also used to modify SUMO_ATTR_CHANGE_LEFT etc)
265 GNEAllowVClassesDialog(myAttributeTable->getFrameParent()->getViewNet(), myAttribute, &allowedVehicles, &acceptChanges).execute();
266 // continue depending of acceptChanges
267 if (acceptChanges) {
268 myValueTextField->setText(allowedVehicles.c_str(), TRUE);
269 }
270 return 1;
271}
272
273
274long
275GNEAttributesEditorRow::onCmdReparent(FXObject*, FXSelector, void*) {
277 return 1;
278}
279
280
281long
282GNEAttributesEditorRow::onCmdInspectParent(FXObject*, FXSelector, void*) {
284 return 1;
285}
286
287
288long
289GNEAttributesEditorRow::onCmdMoveLaneUp(FXObject*, FXSelector, void*) {
291 return 1;
292}
293
294
295long
296GNEAttributesEditorRow::onCmdMoveLaneDown(FXObject*, FXSelector, void*) {
298 return 1;
299}
300
301
302long
303GNEAttributesEditorRow::onCmdSetAttribute(FXObject* obj, FXSelector, void*) {
304 if (myAttributeTable->myEditedACs.empty()) {
305 return 0;
306 }
307 const auto& editedAC = myAttributeTable->myEditedACs.front();
308 const auto& attrProperties = editedAC->getTagProperty().getAttributeProperties(myAttribute);
309 // continue depending of clicked object
310 if (obj == myValueCheckButton) {
311 // Set true o false depending of the checkBox
312 if (myValueCheckButton->getCheck()) {
313 myValueCheckButton->setText("true");
314 } else {
315 myValueCheckButton->setText("false");
316 }
318 } else if (obj == myValueComboBox) {
319 const std::string newValue = myValueComboBox->getText().text();
320 // check if the new comboBox value is valid
321 if (editedAC->isValid(myAttribute, newValue)) {
324 myValueTextField->killFocus();
326 } else {
327 // edit colors
329 if (newValue.empty()) {
331 }
332 // Write Warning in console if we're in testing mode
333 WRITE_DEBUG(TLF("ComboBox value '%' for attribute % of % isn't valid", newValue, attrProperties.getAttrStr(), attrProperties.getTagPropertyParent().getTagStr()));
334 }
335 } else if (obj == myValueTextField) {
336 // check if we're merging junction
337 //if (!mergeJunction(myACAttr.getAttr(), newVal)) {
338 // if its valid for the first AC than its valid for all (of the same type)
339
340
341 // first check if set default value
342 if (myValueTextField->getText().empty() && attrProperties.hasDefaultValue() && !attrProperties.isVClass()) {
343 // update text field without notify
344 myValueTextField->setText(attrProperties.getDefaultValue().c_str(), FALSE);
345 }
346 // if we're editing an angle, check if filter between [0,360]
347 if ((myAttribute == SUMO_ATTR_ANGLE) && GNEAttributeCarrier::canParse<double>(myValueTextField->getText().text())) {
348 // filter anglea and update text field without notify
349 const double angle = fmod(GNEAttributeCarrier::parse<double>(myValueTextField->getText().text()), 360);
350 myValueTextField->setText(toString(angle).c_str(), FALSE);
351 }
352 // if we're editing a position or a shape, strip whitespace after comma
354 std::string shape(myValueTextField->getText().text());
355 while (shape.find(", ") != std::string::npos) {
356 shape = StringUtils::replace(shape, ", ", ",");
357 }
358 myValueTextField->setText(toString(shape).c_str(), FALSE);
359 }
360 // if we're editing a int, strip decimal value
361 if (attrProperties.isInt() && GNEAttributeCarrier::canParse<double>(myValueTextField->getText().text())) {
362 double doubleValue = GNEAttributeCarrier::parse<double>(myValueTextField->getText().text());
363 if ((doubleValue - (int)doubleValue) == 0) {
364 myValueTextField->setText(toString((int)doubleValue).c_str(), FALSE);
365 }
366
367 }
368 // after apply all filters, obtain value
369 const std::string newValue = myValueTextField->getText().text();
370 // check if the new textField value is valid
371 if (editedAC->isValid(myAttribute, newValue)) {
372 myValueTextField->setTextColor(TEXTCOLOR_BLACK);
374 myValueTextField->killFocus();
376 } else {
377 // edit colors
378 myValueTextField->setTextColor(TEXTCOLOR_RED);
379 if (newValue.empty()) {
381 }
382 // Write Warning in console if we're in testing mode
383 WRITE_DEBUG(TLF("TextField value '%' for attribute % of % isn't valid", newValue, attrProperties.getAttrStr(), attrProperties.getTagPropertyParent().getTagStr()));
384 }
385 }
386 return 1;
387}
388
389
390long
395
396
398 myAttributeTable(nullptr) {
399}
400
401
402const std::string
404 if (enabled) {
405 // Declare a set of occurring values and insert attribute's values of item (note: We use a set to avoid repeated values)
406 std::set<std::string> values;
407 // iterate over edited attributes and insert every value in set
408 for (const auto& editedAC : myAttributeTable->myEditedACs) {
409 if (editedAC->hasAttribute(myAttribute)) {
410 values.insert(editedAC->getAttribute(myAttribute));
411 }
412 }
413 // merge all values in a single string
414 std::ostringstream oss;
415 for (auto it = values.begin(); it != values.end(); it++) {
416 if (it != values.begin()) {
417 oss << " ";
418 }
419 oss << *it;
420 }
421 // obtain value to be shown in row
422 return oss.str();
423 } else {
424 return myAttributeTable->myEditedACs.front()->getAlternativeValueForDisabledAttributes(myAttribute);
425 }
426}
427
428
429void
431 myAttributeToggleEnableCheckButton->setText(attrProperty.getAttrStr().c_str());
432 myAttributeToggleEnableCheckButton->setCheck(value);
435 // hide other elements
436 myAttributeLabel->hide();
441}
442
443
444void
446 if (enabled) {
448 } else {
449 myAttributeReparentButton->disable();
450 }
452 // hide other elements
454 myAttributeLabel->hide();
458}
459
460
461void
463 // set icon and text
465 myAttributeInspectParentButton->setText(attrProperty.getAttrStr().c_str());
466 if (enabled) {
468 } else {
470 }
472 // hide other elements
474 myAttributeLabel->hide();
478}
479
480
481void
483 const bool enabled) {
484 // set icon and text
485 myAttributeVClassButton->setText(attrProperty.getAttrStr().c_str());
486 if (enabled) {
487 myAttributeVClassButton->enable();
488 } else {
489 myAttributeVClassButton->disable();
490 }
492 // hide other elements
493 myAttributeLabel->hide();
498}
499
500
501void
503 const bool enabled) {
504 myAttributeColorButton->setText(attrProperty.getAttrStr().c_str());
506 if (enabled) {
507 myAttributeColorButton->enable();
508 } else {
509 myAttributeColorButton->disable();
510 }
511 // hide other elements
512 myAttributeLabel->hide();
517}
518
519
520void
522 myAttributeLabel->setText(attrProperty.getAttrStr().c_str());
523 myAttributeLabel->show();
524 // hide other elements
530}
531
532
533void
535 const bool enabled, const bool computed) {
536 // first we need to check if all boolean values are equal
537 bool allValuesEqual = true;
538 // declare boolean vector
539 std::vector<bool> booleanVector;
540 // check if value can be parsed to a boolean vector
541 if (GNEAttributeCarrier::canParse<std::vector<bool> >(value)) {
542 booleanVector = GNEAttributeCarrier::parse<std::vector<bool> >(value);
543 }
544 // iterate over booleans comparing all element with the first
545 for (const auto& booleanValue : booleanVector) {
546 if (booleanValue != booleanVector.front()) {
547 allValuesEqual = false;
548 }
549 }
550 // use checkbox or textfield depending if all booleans are equal
551 if (allValuesEqual) {
552 if (enabled) {
553 myValueCheckButton->enable();
554 } else {
555 myValueCheckButton->disable();
556 }
557 // set check button
558 if ((booleanVector.size() > 0) && booleanVector.front()) {
559 myValueCheckButton->setCheck(true);
560 myValueCheckButton->setText("true");
561 } else {
562 myValueCheckButton->setCheck(false);
563 myValueCheckButton->setText("false");
564 }
565 // show check button
566 myValueCheckButton->show();
567 // hide other value elements
568 myValueTextField->hide();
569 myValueComboBox->hide();
570 myValueLaneUpButton->hide();
571 myValueLaneDownButton->hide();
572 } else {
573 // show value as string
574 showValueString(value, enabled, computed);
575 }
576}
577
578
579void
580GNEAttributesEditorRow::showValueComboBox(const GNEAttributeProperties& attrProperty, const std::string& value,
581 const bool enabled, const bool computed) {
582 // first we need to check if all boolean values are equal
583 bool allValuesEqual = true;
584 // declare boolean vector
585 std::vector<std::string> stringVector;
586 // check if value can be parsed to a boolean vector
587 if (GNEAttributeCarrier::canParse<std::vector<std::string> >(value)) {
588 stringVector = GNEAttributeCarrier::parse<std::vector<std::string> >(value);
589 }
590 // iterate over string comparing all element with the first
591 for (const auto& stringValue : stringVector) {
592 if (stringValue != stringVector.front()) {
593 allValuesEqual = false;
594 }
595 }
596 // use checkbox or textfield depending if all booleans are equal
597 if (allValuesEqual) {
598 // clear and enable comboBox
602 if (enabled) {
604 } else {
606 }
607 // fill depeding of ACAttr
608 if (attrProperty.getAttr() == SUMO_ATTR_VCLASS) {
609 // add all vClasses with their icons
610 for (const auto& vClassStr : SumoVehicleClassStrings.getStrings()) {
612 }
613 } else if (attrProperty.isVType()) {
614 // get ACs
616 // fill comboBox with all vTypes and vType distributions sorted by ID
617 std::map<std::string, GNEDemandElement*> sortedTypes;
618 for (const auto& type : ACs->getDemandElements().at(SUMO_TAG_VTYPE)) {
619 sortedTypes[type.second->getID()] = type.second;
620 }
621 for (const auto& sortedType : sortedTypes) {
622 myValueComboBox->appendIconItem(sortedType.first.c_str(), sortedType.second->getACIcon());
623 }
624 sortedTypes.clear();
625 for (const auto& typeDistribution : ACs->getDemandElements().at(SUMO_TAG_VTYPE_DISTRIBUTION)) {
626 sortedTypes[typeDistribution.second->getID()] = typeDistribution.second;
627 }
628 for (const auto& sortedType : sortedTypes) {
629 myValueComboBox->appendIconItem(sortedType.first.c_str(), sortedType.second->getACIcon());
630 }
631 } else if (attrProperty.getAttr() == SUMO_ATTR_ICON) {
632 // add all POIIcons with their icons
633 for (const auto& POIIcon : SUMOXMLDefinitions::POIIcons.getValues()) {
635 }
636 } else if ((attrProperty.getAttr() == SUMO_ATTR_RIGHT_OF_WAY) && (myAttributeTable->myEditedACs.size() == 1) &&
637 (attrProperty.getTagPropertyParent().getTag() == SUMO_TAG_JUNCTION)) {
638 // special case for junction types
639 if (myAttributeTable->myEditedACs.front()->getAttribute(SUMO_ATTR_TYPE) == "priority") {
642 } else if (myAttributeTable->myEditedACs.front()->getAttribute(SUMO_ATTR_TYPE) == "traffic_light") {
646 } else {
648 }
649 } else {
650 // fill comboBox with discrete values
651 for (const auto& discreteValue : attrProperty.getDiscreteValues()) {
652 myValueComboBox->appendIconItem(discreteValue.c_str(), nullptr);
653 }
654 }
655 // set current value (or disable)
656 const auto index = myValueComboBox->findItem(value.c_str());
657 if (index < 0) {
658 if (myValueComboBox->getNumItems() > 0) {
660 } else {
662 }
663 } else {
665 }
666 // show comboBox button
667 myValueComboBox->show();
668 // hide other value elements
669 myValueTextField->hide();
670 myValueCheckButton->hide();
671 myValueLaneUpButton->hide();
672 myValueLaneDownButton->hide();
673 } else {
674 // show value as string
675 showValueString(value, enabled, computed);
676 }
677}
678
679
680void
681GNEAttributesEditorRow::showValueString(const std::string& value, const bool enabled, const bool computed) {
682 // clear and enable comboBox
683 myValueTextField->setText(value.c_str());
684 if (computed) {
685 myValueTextField->setTextColor(TEXTCOLOR_BLUE);
686 } else {
687 myValueTextField->setTextColor(TEXTCOLOR_BLACK);
688 }
689 if (enabled) {
690 myValueTextField->enable();
691 } else {
692 myValueTextField->disable();
693 }
694 // show list of values
695 myValueTextField->show();
696 // hide other value elements
697 myValueCheckButton->hide();
698 myValueComboBox->hide();
699}
700
701
702void
704 // retrieve lane
705 const auto lane = myAttributeTable->myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveLane(laneID, false);
706 // check lane
707 if (lane) {
708 // check if disable move up
709 if ((lane->getIndex() + 1) >= (int)lane->getParentEdge()->getLanes().size()) {
710 myValueLaneUpButton->disable();
711 } else {
712 myValueLaneUpButton->enable();
713 }
714 // check if disable move down
715 if ((lane->getIndex() - 1) < 0) {
716 myValueLaneDownButton->disable();
717 } else {
718 myValueLaneDownButton->enable();
719 }
720 } else {
721 // if lane doesn't exist, disable both
722 myValueLaneUpButton->disable();
723 myValueLaneDownButton->disable();
724 }
725}
726
727
728void
729GNEAttributesEditorRow::enableElements(const GNEAttributeProperties& attrProperty, const bool forceDisable) {
730 const auto& editModes = myAttributeTable->myFrameParent->getViewNet()->getEditModes();
731 const auto& tagProperty = attrProperty.getTagPropertyParent();
732 // by default we assume that elements are disabled
733 bool enableElements = false;
734 if (forceDisable) {
735 enableElements = false;
736 } else if (editModes.isCurrentSupermodeNetwork() && (tagProperty.isNetworkElement() || tagProperty.isAdditionalElement())) {
737 enableElements = true;
738 } else if (editModes.isCurrentSupermodeDemand() && tagProperty.isDemandElement()) {
739 enableElements = true;
740 } else if (editModes.isCurrentSupermodeData() && (tagProperty.isDataElement() || tagProperty.isMeanData())) {
741 enableElements = true;
742 }
743 if (!enableElements) {
745 myAttributeReparentButton->disable();
747 myAttributeVClassButton->disable();
748 myAttributeColorButton->disable();
749 myValueTextField->disable();
751 myValueCheckButton->disable();
752 myValueLaneUpButton->disable();
753 myValueLaneDownButton->disable();
754 }
755}
756
757/*
758bool
759GNEAttributesEditorRow::mergeJunction(SumoXMLAttr attr, const std::string& newVal) const {
760 const auto viewNet = myAttributesEditorParent->getFrameParent()->getViewNet();
761 const auto& inspectedElements = viewNet->getInspectedElements();
762 // check if we're editing junction position
763 if (inspectedElements.isInspectingSingleElement() && (inspectedElements.getFirstAC()->getTagProperty().getTag() == SUMO_TAG_JUNCTION) && (attr == SUMO_ATTR_POSITION)) {
764 // retrieve original junction
765 GNEJunction* movedJunction = viewNet->getNet()->getAttributeCarriers()->retrieveJunction(inspectedElements.getFirstAC()->getID());
766 // parse position
767 const Position newPosition = GNEAttributeCarrier::parse<Position>(newVal);
768 // iterate over network junction
769 for (const auto& targetjunction : viewNet->getNet()->getAttributeCarriers()->getJunctions()) {
770 // check distance position
771 if ((targetjunction.second->getPositionInView().distanceTo2D(newPosition) < POSITION_EPS) &&
772 viewNet->askMergeJunctions(movedJunction, targetjunction.second)) {
773 viewNet->getNet()->mergeJunctions(movedJunction, targetjunction.second, viewNet->getUndoList());
774 return true;
775 }
776 }
777 }
778 // nothing to merge
779 return false;
780}
781*/
782
783
784/****************************************************************************/
#define TEXTCOLOR_BLUE
#define TEXTCOLOR_RED
#define TEXTCOLOR_BLACK
FXDEFMAP(GNEAttributesEditorRow) GNEAttributeRowMap[]
#define TEXTCOLOR_BACKGROUND_WHITE
#define TEXTCOLOR_BACKGROUND_RED
@ MID_GNE_ATTRIBUTESEDITORROW_OPENALLOWDIALLOG
open allow dialog in attributes editor row
@ MID_GNE_ATTRIBUTESEDITORROW_MOVELANEUP
move lane up
@ MID_GNE_ATTRIBUTESEDITORROW_SETATTRIBUTE
set attribute (string, bool, etc.) in attributes editor row
@ MID_GNE_ATTRIBUTESEDITORROW_REPARENT
reparent
@ MID_GNE_ATTRIBUTESEDITORROW_TOGGLEENABLEATTRIBUTE
toogle enable attribute in attributes editor row
@ MID_GNE_ATTRIBUTESEDITORROW_OPENCOLORDIALOG
open color dialog in attributes editor row
@ MID_GNE_ATTRIBUTESEDITORROW_MOVELANEDOWN
move lane down
@ MID_GNE_ATTRIBUTESEDITORROW_INSPECTPARENT
inspect parent
#define GUIDesignButtonAttribute
button extended over over column with thick and raise frame
Definition GUIDesigns.h:88
#define GUIDesignButtonIcon
button only with icon
Definition GUIDesigns.h:91
#define GUIDesignComboBoxAttribute
Combo box static (cannot be edited) extended over the matrix column.
Definition GUIDesigns.h:302
#define GUIDesignComboBoxNCol
number of column of every combo box
Definition GUIDesigns.h:311
#define GUIDesignTextField
Definition GUIDesigns.h:59
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:399
#define GUIDesignTextFieldNCol
Num of column of text field.
Definition GUIDesigns.h:74
#define GUIDesignComboBoxVisibleItems
Definition GUIDesigns.h:49
#define GUIDesignCheckButton
checkButton placed in left position
Definition GUIDesigns.h:192
#define GUIDesignCheckButtonAttribute
checkButton without thick extended over the frame used for attributes
Definition GUIDesigns.h:201
#define GUIDesignLabelThickedFixed(width)
label thicked, icon before text, text centered and custom width
Definition GUIDesigns.h:252
#define WRITE_DEBUG(msg)
Definition MsgHandler.h:306
#define TL(string)
Definition MsgHandler.h:315
#define TLF(string,...)
Definition MsgHandler.h:317
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
POIIcon
POI icons.
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_ICON
icon
@ SUMO_ATTR_LANE
@ GNE_ATTR_STOPOFFSET
stop offset (virtual, used by edge and lanes)
@ GNE_ATTR_PARENT
parent of an additional element
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_EXPECTED
@ GNE_ATTR_STOPOEXCEPTION
stop exceptions (virtual, used by edge and lanes)
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_ANGLE
@ SUMO_ATTR_JOIN
@ SUMO_ATTR_VCLASS
@ GNE_ATTR_FRONTELEMENT
@ SUMO_ATTR_EXPECTED_CONTAINERS
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_RIGHT_OF_WAY
How to compute right of way.
@ SUMO_ATTR_POSITION
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
Dialog for edit rerouters.
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
bool isVClass() const
return true if attribute is a VehicleClass
bool isBool() const
return true if attribute is boolean
const std::string & getAttrStr() const
get XML Attribute
bool isDiscrete() const
return true if attribute is discrete
bool isVType() const
return true if attribute is a VType or vTypeDistribution
bool isUnique() const
return true if attribute is unique
bool isFlow() const
return true if attribute is part of a flow definition
bool isActivatable() const
return true if attribute is activatable
const std::vector< std::string > & getDiscreteValues() const
get discrete values
bool isAlwaysEnabled() const
return true if attribute is always enabled
SumoXMLAttr getAttr() const
get XML Attribute
const GNETagProperties & getTagPropertyParent() const
get reference to tagProperty parent
GNEFrame * getFrameParent() const
pointer to GNEFrame parent
std::vector< GNEAttributeCarrier * > myEditedACs
current edited ACs
GNEFrame * myFrameParent
pointer to GNEFrame parent
void toggleEnableAttribute(SumoXMLAttr attr, const bool value)
set attribute in the current ACs (Callend from row)
void moveLaneDown()
move lane down
void inspectParent()
inspect parent (Callend from row)
void enableReparent()
void enable reparent
void moveLaneUp()
move lane up
void setAttribute(SumoXMLAttr attr, const std::string &value)
set attribute in the current ACs (Callend from row)
SumoXMLAttr myAttribute
edited attribute
bool isAttributeRowShown() const
check if current attribute row is shown
bool showAttributeRow(const GNEAttributeProperties &attrProperty, const bool forceDisable)
return true if attribute row was successfully show
MFXButtonTooltip * myValueLaneUpButton
Button for move lane up.
FXCheckButton * myAttributeToggleEnableCheckButton
pointer to attribute menu check
void enableElements(const GNEAttributeProperties &attrProperty, const bool forceDisable)
check if enable or disable all elements depending of current supermode or forceDisable
long onCmdInspectParent(FXObject *, FXSelector, void *)
called when user press "inspect parent"
long onCmdOpenAllowDialog(FXObject *, FXSelector, void *)
called when user press "open allow" dialog
long onCmdOpenColorDialog(FXObject *, FXSelector, void *)
called when user press "edit color" dialog
MFXButtonTooltip * myValueLaneDownButton
Button for move lane down.
const std::string getAttributeValue(const bool enabled) const
get value from edited ACs
void showAttributeLabel(const GNEAttributeProperties &attrProperty)
show attribute label
MFXLabelTooltip * myAttributeLabel
pointer to attribute label
MFXComboBoxIcon * myValueComboBox
pointer to combo box for select choices
bool hideAttributeRow()
hide attribute row (always return false)
void showValueComboBox(const GNEAttributeProperties &attrProperty, const std::string &value, const bool enabled, const bool computed)
show value for combo Box
long onCmdToggleEnableAttribute(FXObject *, FXSelector, void *)
called when user press the checkBox for toogle enable/disable attribute
GNEAttributesEditorRow()
default constructor (needed for FOX)
long onCmdMoveLaneDown(FXObject *, FXSelector, void *)
called when user press "move lane down"
long onCmdMoveLaneUp(FXObject *, FXSelector, void *)
called when user press "move lane up"
void showMoveLaneButtons(const std::string &laneID)
show move lane buttons
void showAttributeToggleEnable(const GNEAttributeProperties &attrProperty, const bool value)
show attribute toogle enable
GNEAttributesEditor * myAttributeTable
check junction merging bool mergeJunction(SumoXMLAttr attr, const std::string& newVal) const;
void showAttributeInspectParent(const GNEAttributeProperties &attrProperty, const bool enabled)
show attribute parent
void showAttributeVClass(const GNEAttributeProperties &attrProperty, const bool enabled)
show attribute vClass
FXCheckButton * myValueCheckButton
pointer to menu check
MFXButtonTooltip * myAttributeColorButton
pointer to attribute color button
void showValueCheckButton(const std::string &value, const bool enabled, const bool computed)
show value for check button
MFXButtonTooltip * myAttributeVClassButton
pointer to attribute vClass button
long onCmdSetAttribute(FXObject *obj, FXSelector, void *)
set new string/bool attribute
void showAttributeColor(const GNEAttributeProperties &attrProperty, const bool enabled)
show attribute color
MFXButtonTooltip * myAttributeReparentButton
pointer to attribute reparent button
void showAttributeReparent(const bool enabled)
show attribute reparent
MFXButtonTooltip * myAttributeInspectParentButton
pointer to attribute inspect parent button
MFXTextFieldTooltip * myValueTextField
pointer to text field for modify values
void showValueString(const std::string &value, const bool enabled, const bool computed)
show value for strings
long onCmdReparent(FXObject *, FXSelector, void *)
called when user press reparent button
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:150
GNELane * retrieveLane(const std::string &id, bool hardFail=true, bool checkVolatileChange=false) const
get lane by id
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:127
GUIIcon getGUIIcon() const
get GUI icon associated to this Tag
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
GNENet * getNet() const
get the net object
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
GNEViewParent * getViewParent() const
get the net object
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
MFXStaticToolTip * getStaticTooltipMenu() const
get static toolTip for menus
ComboBox with icon.
long setCurrentItem(const FXint index, FXbool notify=FALSE)
Set the current item (index is zero-based)
FXint findItem(const FXString &text) const
find item
FXint getNumItems() const
Return the number of items in the list.
void setBackColor(FXColor clr)
Set window background color.
FXString getText() const
Get the text.
void setTextColor(FXColor clr)
Change text color.
void clearItems()
Remove all items from the list.
void disable()
Disable combo box.
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon item in the last position
void enable()
Enable combo box.
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition MFXUtils.cpp:112
static RGBColor getRGBColor(FXColor col)
converts FXColor to RGBColor
Definition MFXUtils.cpp:106
static FXIcon * getPOIIcon(POIIcon iconType)
returns icon associated to the given POI image
Definition POIIcons.cpp:30
static const RGBColor BLACK
Definition RGBColor.h:193
static StringBijection< POIIcon > POIIcons
POI icon values.
static StringBijection< RightOfWay > RightOfWayValues
righ of way algorithms
std::vector< T > getValues() const
static std::string replace(std::string str, const std::string &what, const std::string &by)
Replaces all occurrences of the second string by the third string within the first string.
static FXIcon * getVClassIcon(const SUMOVehicleClass vc)
returns icon associated to the given vClass