Skip to content

Commit

Permalink
Fixed error selecting plans. Refs eclipse-sumo#457
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez authored and yct72 committed Dec 6, 2023
1 parent 3407914 commit 66d1ef2
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 150 deletions.
8 changes: 4 additions & 4 deletions src/netedit/elements/demand/GNEStopPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ GNEStopPlan::drawGL(const GUIVisualizationSettings& s) const {
(getTagProperty().isPlanStopContainer() && checkDrawContainerPlan())) {
// check if draw stopPerson over busStop oder over lane
if (getParentAdditionals().size() > 0) {
drawStopPersonOverStoppingPlace(s, exaggeration);
drawStopOverStoppingPlace(s, exaggeration);
} else {
drawStopPersonOverEdge(s, exaggeration);
drawStopOverEdge(s, exaggeration);
}
// check if draw plan parent
if (getParentDemandElements().at(0)->getPreviousChildDemandElement(this) == nullptr) {
Expand Down Expand Up @@ -392,7 +392,7 @@ GNEStopPlan::getACParametersMap() const {
// ===========================================================================

void
GNEStopPlan::drawStopPersonOverEdge(const GUIVisualizationSettings& s, const double exaggeration) const {
GNEStopPlan::drawStopOverEdge(const GUIVisualizationSettings& s, const double exaggeration) const {
// declare stop color
const RGBColor stopColor = drawUsingSelectColor() ? s.colorSettings.selectedPersonPlanColor : s.colorSettings.stopColor;
// avoid draw invisible elements
Expand Down Expand Up @@ -460,7 +460,7 @@ GNEStopPlan::drawStopPersonOverEdge(const GUIVisualizationSettings& s, const dou


void
GNEStopPlan::drawStopPersonOverStoppingPlace(const GUIVisualizationSettings& s, const double exaggeration) const {
GNEStopPlan::drawStopOverStoppingPlace(const GUIVisualizationSettings& s, const double exaggeration) const {
// declare stop color
const RGBColor stopColor = drawUsingSelectColor() ? s.colorSettings.selectedPersonPlanColor : s.colorSettings.stopColor;
// avoid draw invisible elements
Expand Down
8 changes: 4 additions & 4 deletions src/netedit/elements/demand/GNEStopPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ class GNEStopPlan : public GNEDemandElement, public Parameterised, public GNEDem
/// @brief parameter set
int myParametersSet = 0;

/// @brief draw stopPerson over lane
void drawStopPersonOverEdge(const GUIVisualizationSettings& s, const double exaggeration) const;
/// @brief draw stop plan over lane
void drawStopOverEdge(const GUIVisualizationSettings& s, const double exaggeration) const;

/// @brief draw stopPerson over stoppingPlace
void drawStopPersonOverStoppingPlace(const GUIVisualizationSettings& s, const double exaggeration) const;
/// @brief draw stop plan over stoppingPlace
void drawStopOverStoppingPlace(const GUIVisualizationSettings& s, const double exaggeration) const;

private:
/// @brief method for setting the attribute and nothing else
Expand Down
218 changes: 76 additions & 142 deletions src/netedit/frames/common/GNESelectorFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,29 +802,18 @@ GNESelectorFrame::SelectionOperation::processDemandElementSelection(const bool o
return true;
}
// invert person trip
if (ignoreLocking || !locks.isObjectLocked(GLO_PERSONTRIP, false)) {
for (const auto& person : demandElements.at(SUMO_TAG_PERSON)) {
for (const auto& personPlan : person->getChildDemandElements()) {
if (onlyCount) {
return true;
} else if (personPlan->getTagProperty().isPersonTrip()) {
if (onlyUnselect || personPlan->isAttributeCarrierSelected()) {
personPlan->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
personPlan->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
}
}
}
}
for (const auto& personFlow : demandElements.at(SUMO_TAG_PERSONFLOW)) {
for (const auto& personPlan : personFlow->getChildDemandElements()) {
if (onlyCount) {
return true;
} else if (personPlan->getTagProperty().isPersonTrip()) {
if (onlyUnselect || personPlan->isAttributeCarrierSelected()) {
personPlan->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
personPlan->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
if (ignoreLocking || !locks.isObjectLocked(GLO_PERSON, false)) {
for (const auto& personTag : NamespaceIDs::persons) {
for (const auto& person : demandElements.at(personTag)) {
for (const auto& personPlan : person->getChildDemandElements()) {
if (personPlan->getTagProperty().isPersonTrip()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || personPlan->isAttributeCarrierSelected()) {
personPlan->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
personPlan->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
}
}
}
}
Expand All @@ -834,29 +823,18 @@ GNESelectorFrame::SelectionOperation::processDemandElementSelection(const bool o
return true;
}
// invert ride
if (ignoreLocking || !locks.isObjectLocked(GLO_PERSONTRIP, false)) {
for (const auto& person : demandElements.at(SUMO_TAG_PERSON)) {
for (const auto& personPlan : person->getChildDemandElements()) {
if (personPlan->getTagProperty().isPlanRide()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || personPlan->isAttributeCarrierSelected()) {
personPlan->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
personPlan->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
}
}
}
}
for (const auto& personFlow : demandElements.at(SUMO_TAG_PERSONFLOW)) {
for (const auto& personPlan : personFlow->getChildDemandElements()) {
if (personPlan->getTagProperty().isPlanRide()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || personPlan->isAttributeCarrierSelected()) {
personPlan->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
personPlan->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
if (ignoreLocking || !locks.isObjectLocked(GLO_PERSON, false)) {
for (const auto& personTag : NamespaceIDs::persons) {
for (const auto& person : demandElements.at(personTag)) {
for (const auto& personPlan : person->getChildDemandElements()) {
if (personPlan->getTagProperty().isPlanRide()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || personPlan->isAttributeCarrierSelected()) {
personPlan->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
personPlan->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
}
}
}
}
Expand All @@ -866,29 +844,18 @@ GNESelectorFrame::SelectionOperation::processDemandElementSelection(const bool o
return true;
}
// invert walks
if (ignoreLocking || !locks.isObjectLocked(GLO_PERSONTRIP, false)) {
for (const auto& person : demandElements.at(SUMO_TAG_PERSON)) {
for (const auto& personPlan : person->getChildDemandElements()) {
if (personPlan->getTagProperty().isPlanWalk()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || personPlan->isAttributeCarrierSelected()) {
personPlan->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
personPlan->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
}
}
}
}
for (const auto& personFlow : demandElements.at(SUMO_TAG_PERSONFLOW)) {
for (const auto& personPlan : personFlow->getChildDemandElements()) {
if (personPlan->getTagProperty().isPlanWalk()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || personPlan->isAttributeCarrierSelected()) {
personPlan->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
personPlan->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
if (ignoreLocking || !locks.isObjectLocked(GLO_PERSON, false)) {
for (const auto& personTag : NamespaceIDs::persons) {
for (const auto& person : demandElements.at(personTag)) {
for (const auto& personPlan : person->getChildDemandElements()) {
if (personPlan->getTagProperty().isPlanWalk()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || personPlan->isAttributeCarrierSelected()) {
personPlan->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
personPlan->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
}
}
}
}
Expand All @@ -899,30 +866,6 @@ GNESelectorFrame::SelectionOperation::processDemandElementSelection(const bool o
}
// invert containers
if (ignoreLocking || !locks.isObjectLocked(GLO_CONTAINER, false)) {
for (const auto& container : demandElements.at(SUMO_TAG_CONTAINER)) {
if (onlyCount) {
return true;
} else if (onlyUnselect || container->isAttributeCarrierSelected()) {
container->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
container->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
}
}
for (const auto& containerFlow : demandElements.at(SUMO_TAG_CONTAINERFLOW)) {
if (onlyCount) {
return true;
} else if (onlyUnselect || containerFlow->isAttributeCarrierSelected()) {
containerFlow->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
containerFlow->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
}
}
} else if (onlyCount) {
ignoreLocking = askContinueIfLock();
return true;
}
// invert container
if (ignoreLocking || !locks.isObjectLocked(GLO_TRANSPORT, false)) {
for (const auto& containerTag : NamespaceIDs::containers) {
for (const auto& container : demandElements.at(containerTag)) {
if (onlyCount) {
Expand All @@ -938,30 +881,40 @@ GNESelectorFrame::SelectionOperation::processDemandElementSelection(const bool o
ignoreLocking = askContinueIfLock();
return true;
}
// invert ride
if (ignoreLocking || !locks.isObjectLocked(GLO_TRANSHIP, false)) {
for (const auto& container : demandElements.at(SUMO_TAG_CONTAINER)) {
for (const auto& containerPlan : container->getChildDemandElements()) {
if (containerPlan->getTagProperty().isPlanTranship()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || containerPlan->isAttributeCarrierSelected()) {
containerPlan->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
containerPlan->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
// invert transport
if (ignoreLocking || !locks.isObjectLocked(GLO_CONTAINER, false)) {
for (const auto& containerTag : NamespaceIDs::containers) {
for (const auto& container : demandElements.at(containerTag)) {
for (const auto& containerPlan : container->getChildDemandElements()) {
if (containerPlan->getTagProperty().isPlanTransport()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || containerPlan->isAttributeCarrierSelected()) {
containerPlan->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
containerPlan->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
}
}
}
}
}
for (const auto& containerFlow : demandElements.at(SUMO_TAG_CONTAINERFLOW)) {
for (const auto& containerPlan : containerFlow->getChildDemandElements()) {
if (containerPlan->getTagProperty().isPlanTranship()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || containerPlan->isAttributeCarrierSelected()) {
containerPlan->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
containerPlan->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
} else if (onlyCount) {
ignoreLocking = askContinueIfLock();
return true;
}
// invert tranships
if (ignoreLocking || !locks.isObjectLocked(GLO_CONTAINER, false)) {
for (const auto& containerTag : NamespaceIDs::containers) {
for (const auto& container : demandElements.at(containerTag)) {
for (const auto& containerPlan : container->getChildDemandElements()) {
if (containerPlan->getTagProperty().isPlanTranship()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || containerPlan->isAttributeCarrierSelected()) {
containerPlan->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
containerPlan->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
}
}
}
}
Expand All @@ -970,38 +923,19 @@ GNESelectorFrame::SelectionOperation::processDemandElementSelection(const bool o
ignoreLocking = askContinueIfLock();
return true;
}
// invert stops
// invert stops and waypoints
if (ignoreLocking || !locks.isObjectLocked(GLO_STOP, false)) {
for (const auto& demandElementTag : demandElements) {
for (const auto& demandElement : demandElementTag.second) {
// avoid vTypes
if (!demandElement->getTagProperty().isType()) {
// iterate over every child
for (const auto& stop : demandElement->getChildDemandElements()) {
if (stop->getTagProperty().isVehicleStop() || stop->getTagProperty().isPlanStopPerson() || stop->getTagProperty().isPlanStopContainer()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || stop->isAttributeCarrierSelected()) {
stop->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
stop->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
}
} else {
// special case for embedded routes
for (const auto& stopEmbeddedRoute : stop->getChildDemandElements()) {
if (stopEmbeddedRoute->getTagProperty().isVehicleStop() ||
stopEmbeddedRoute->getTagProperty().isPlanStopPerson() ||
stopEmbeddedRoute->getTagProperty().isPlanStopContainer()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || stopEmbeddedRoute->isAttributeCarrierSelected()) {
stopEmbeddedRoute->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
stopEmbeddedRoute->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
}
}
}
}
if (demandElement->getTagProperty().isVehicleStop() ||
demandElement->getTagProperty().isVehicleWaypoint() ||
demandElement->getTagProperty().isPlanStop()) {
if (onlyCount) {
return true;
} else if (onlyUnselect || demandElement->isAttributeCarrierSelected()) {
demandElement->setAttribute(GNE_ATTR_SELECTED, "false", undoList);
} else {
demandElement->setAttribute(GNE_ATTR_SELECTED, "true", undoList);
}
}
}
Expand Down

0 comments on commit 66d1ef2

Please sign in to comment.