Skip to content

Commit

Permalink
Restored full functionality of Flow editor. Refs #15776
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Nov 29, 2024
1 parent 9207a86 commit 984d199
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 70 deletions.
20 changes: 14 additions & 6 deletions src/netedit/elements/demand/GNEDemandElementFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ GNEDemandElementFlow::isFlowAttributeEnabled(SumoXMLAttr key) const {
return (parametersSet & VEHPARS_POISSON_SET) != 0;
case SUMO_ATTR_PROB:
return (parametersSet & VEHPARS_PROB_SET) != 0;
case GNE_ATTR_FLOW_SPACING:
return !isFlowAttributeEnabled(SUMO_ATTR_END) || !isFlowAttributeEnabled(SUMO_ATTR_NUMBER);
default:
return true;
}
Expand Down Expand Up @@ -365,12 +367,18 @@ GNEDemandElementFlow::setFlowAttribute(const GNEDemandElement* flowElement, Sumo
toggleFlowAttribute(SUMO_ATTR_PERIOD, false);
toggleFlowAttribute(GNE_ATTR_POISSON, false);
toggleFlowAttribute(SUMO_ATTR_PROB, false);
} else if (value == toString(SUMO_ATTR_END)) {
toggleFlowAttribute(SUMO_ATTR_END, true);
toggleFlowAttribute(SUMO_ATTR_NUMBER, false);
} else if (value == toString(SUMO_ATTR_NUMBER)) {
toggleFlowAttribute(SUMO_ATTR_END, false);
toggleFlowAttribute(SUMO_ATTR_NUMBER, true);
} else {
// if previously end-number was enabled, enable perHour
if (isFlowAttributeEnabled(SUMO_ATTR_END) && isFlowAttributeEnabled(SUMO_ATTR_NUMBER)) {
toggleFlowAttribute(SUMO_ATTR_VEHSPERHOUR, true);
}
if (value == toString(SUMO_ATTR_END)) {
toggleFlowAttribute(SUMO_ATTR_END, true);
toggleFlowAttribute(SUMO_ATTR_NUMBER, false);
} else if (value == toString(SUMO_ATTR_NUMBER)) {
toggleFlowAttribute(SUMO_ATTR_END, false);
toggleFlowAttribute(SUMO_ATTR_NUMBER, true);
}
}
break;
case GNE_ATTR_FLOW_SPACING:
Expand Down
111 changes: 48 additions & 63 deletions src/netedit/frames/GNEAttributesEditorRow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ GNEAttributesEditorRow::showAttributeRow(const GNEAttributeProperties& attrPrope
attributeEnabled = false;
}
}
// extra check for geo shape
if ((myAttribute == SUMO_ATTR_GEOSHAPE) && (firstEditedAC->getAttribute(SUMO_ATTR_GEO) == GNEAttributeCarrier::False)) {
attributeEnabled = false;
}
// check if this attribute is computed
const bool computedAttribute = multipleEditedACs ? false : firstEditedAC->isAttributeComputed(myAttribute);
// get string value depending if attribute is enabled
Expand All @@ -169,37 +173,42 @@ GNEAttributesEditorRow::showAttributeRow(const GNEAttributeProperties& attrPrope
ACParent = ACs->retrieveDemandElement(SUMO_TAG_VTYPE_DISTRIBUTION, firstEditedAC->getAttribute(SUMO_ATTR_TYPE), false);
}
}
// show elements depending of attribute properties
if (attrProperty.isActivatable()) {
showAttributeCheckButton(attrProperty, attributeEnabled);
} else if ((myAttribute == SUMO_ATTR_TYPE) && (tagProperty.isVehicle() || tagProperty.isPerson() || tagProperty.isContainer())) {
showAttributeParent(attrProperty, attributeEnabled);
} else if (myAttribute == SUMO_ATTR_ALLOW) {
showAttributeVClass(attrProperty, attributeEnabled);
} else if (myAttribute == SUMO_ATTR_COLOR) {
showAttributeColor(attrProperty, attributeEnabled);
} else {
showAttributeLabel(attrProperty);
}
// continue depending of type of attribute
if (attrProperty.isBool()) {
showValueCheckButton(attrProperty, value, attributeEnabled, computedAttribute);
} else if (attrProperty.isDiscrete() || attrProperty.isVType()) {
showValueComboBox(attrProperty, value, attributeEnabled, computedAttribute);
} else {
showValueString(attrProperty, value, attributeEnabled, computedAttribute);
}
// check if show move lane buttons
if (!multipleEditedACs && !tagProperty.isNetworkElement() && (myAttribute == SUMO_ATTR_LANE)) {
showMoveLaneButtons(value);
myValueLaneUpButton->show();
myValueLaneDownButton->show();
// if we have a disabled flow attribute, don't show row
if (attrProperty.isFlow() && !attributeEnabled) {
hideAttributeRow();
} else {
myValueLaneUpButton->hide();
myValueLaneDownButton->hide();
// show elements depending of attribute properties
if (attrProperty.isActivatable()) {
showAttributeCheckButton(attrProperty, firstEditedAC->isAttributeEnabled(myAttribute), attributeEnabled);
} else if ((myAttribute == SUMO_ATTR_TYPE) && (tagProperty.isVehicle() || tagProperty.isPerson() || tagProperty.isContainer())) {
showAttributeParent(attrProperty, attributeEnabled);
} else if (myAttribute == SUMO_ATTR_ALLOW) {
showAttributeVClass(attrProperty, attributeEnabled);
} else if (myAttribute == SUMO_ATTR_COLOR) {
showAttributeColor(attrProperty, attributeEnabled);
} else {
showAttributeLabel(attrProperty);
}
// continue depending of type of attribute
if (attrProperty.isBool()) {
showValueCheckButton(attrProperty, value, attributeEnabled, computedAttribute);
} else if (attrProperty.isDiscrete() || attrProperty.isVType()) {
showValueComboBox(attrProperty, value, attributeEnabled, computedAttribute);
} else {
showValueString(attrProperty, value, attributeEnabled, computedAttribute);
}
// check if show move lane buttons
if (!multipleEditedACs && !tagProperty.isNetworkElement() && (myAttribute == SUMO_ATTR_LANE)) {
showMoveLaneButtons(value);
myValueLaneUpButton->show();
myValueLaneDownButton->show();
} else {
myValueLaneUpButton->hide();
myValueLaneDownButton->hide();
}
// Show GNEAttributesEditorRow
show();
}
// Show GNEAttributesEditorRow
show();
}
}

Expand Down Expand Up @@ -409,9 +418,14 @@ GNEAttributesEditorRow::getAttributeValue(const GNEAttributeProperties& attrProp


void
GNEAttributesEditorRow::showAttributeCheckButton(const GNEAttributeProperties& attrProperty, const bool enabled) {
GNEAttributesEditorRow::showAttributeCheckButton(const GNEAttributeProperties& attrProperty, const bool value, const bool enabled) {
myAttributeCheckButton->setText(attrProperty.getAttrStr().c_str());
myAttributeCheckButton->setCheck(enabled);
myAttributeCheckButton->setCheck(value);
if (enabled) {
myAttributeParentButton->enable();
} else {
myAttributeParentButton->disable();
}
myAttributeCheckButton->show();
// hide other elements
myAttributeLabel->hide();
Expand Down Expand Up @@ -499,7 +513,7 @@ GNEAttributesEditorRow::showAttributeLabel(const GNEAttributeProperties& attrPro

void
GNEAttributesEditorRow::showValueCheckButton(const GNEAttributeProperties& attrProperty, const std::string& value,
const bool computed, const bool enabled) {
const bool enabled, const bool computed) {
// first we need to check if all boolean values are equal
bool allValuesEqual = true;
// declare boolean vector
Expand Down Expand Up @@ -547,7 +561,7 @@ GNEAttributesEditorRow::showValueCheckButton(const GNEAttributeProperties& attrP

void
GNEAttributesEditorRow::showValueComboBox(const GNEAttributeProperties& attrProperty, const std::string& value,
const bool computed, const bool enabled) {
const bool enabled, const bool computed) {
// first we need to check if all boolean values are equal
bool allValuesEqual = true;
// declare boolean vector
Expand Down Expand Up @@ -712,36 +726,7 @@ GNEAttributesEditorRow::enableDependingOfSupermode(const GNEAttributeProperties&
} else if (editModes.isCurrentSupermodeData() && (tagProperty.isDataElement() || tagProperty.isMeanData())) {
enableElements = true;
}
if (enableElements) {
// only enable elements showns
if (myAttributeCheckButton->shown()) {
myAttributeCheckButton->enable();
}
if (myAttributeParentButton->shown()) {
myAttributeParentButton->enable();
}
if (myAttributeVClassButton->shown()) {
myAttributeVClassButton->enable();
}
if (myAttributeColorButton->shown()) {
myAttributeColorButton->enable();
}
if (myValueTextField->shown()) {
myValueTextField->enable();
}
if (myValueComboBox->shown()) {
myValueComboBox->enable();
}
if (myValueCheckButton->shown()) {
myValueCheckButton->enable();
}
if (myValueLaneUpButton->shown()) {
myValueLaneUpButton->enable();
}
if (myValueLaneDownButton->shown()) {
myValueLaneDownButton->enable();
}
} else {
if (!enableElements) {
myAttributeCheckButton->disable();
myAttributeParentButton->disable();
myAttributeVClassButton->disable();
Expand Down
2 changes: 1 addition & 1 deletion src/netedit/frames/GNEAttributesEditorRow.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class GNEAttributesEditorRow : protected FXHorizontalFrame {
const std::string getAttributeValue(const GNEAttributeProperties& attrProperty) const;

/// @brief show attribute checkButton
void showAttributeCheckButton(const GNEAttributeProperties& attrProperty, const bool enabled);
void showAttributeCheckButton(const GNEAttributeProperties& attrProperty, const bool value, const bool enabled);

/// @brief show attribute parent
void showAttributeParent(const GNEAttributeProperties& attrProperty, const bool enabled);
Expand Down

0 comments on commit 984d199

Please sign in to comment.