diff --git a/src/netedit/elements/demand/GNEContainer.h b/src/netedit/elements/demand/GNEContainer.h index b9227eb48d1..63aeda8a4b9 100644 --- a/src/netedit/elements/demand/GNEContainer.h +++ b/src/netedit/elements/demand/GNEContainer.h @@ -27,9 +27,7 @@ // =========================================================================== // class definitions // =========================================================================== -/** - * @class GNEContainer - */ + class GNEContainer : public GNEDemandElement, public GNEDemandElementFlow { public: diff --git a/src/netedit/elements/demand/GNEDemandElement.cpp b/src/netedit/elements/demand/GNEDemandElement.cpp index 31437d6ce6d..b231ad9a81c 100644 --- a/src/netedit/elements/demand/GNEDemandElement.cpp +++ b/src/netedit/elements/demand/GNEDemandElement.cpp @@ -34,11 +34,6 @@ #include "GNERouteHandler.h" -// =========================================================================== -// static definitions -// =========================================================================== -const double GNEDemandElement::myPersonPlanArrivalPositionDiameter = SUMO_const_halfLaneWidth; - // =========================================================================== // member method definitions // =========================================================================== @@ -504,469 +499,6 @@ GNEDemandElement::getInvalidStops() const { } -bool -GNEDemandElement::drawPersonPlan() const { - // check conditions - if (myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() && - myNet->getViewNet()->getNetworkViewOptions().showDemandElements() && - myNet->getViewNet()->getDemandViewOptions().showAllPersonPlans()) { - // show all person plans in network mode - return true; - } else if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() && - myNet->getViewNet()->getDemandViewOptions().showAllPersonPlans()) { - // show all person plans - return true; - } else if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() && isAttributeCarrierSelected()) { - // show selected - return true; - } else if (myNet->getViewNet()->isAttributeCarrierInspected(getParentDemandElements().front())) { - // person parent is inspected - return true; - } else if (myNet->getViewNet()->getDemandViewOptions().getLockedPerson() == getParentDemandElements().front()) { - // person parent is locked - return true; - } else if (myNet->getViewNet()->getInspectedAttributeCarriers().empty()) { - // nothing is inspected - return false; - } else { - // get inspected AC - const GNEAttributeCarrier* AC = myNet->getViewNet()->getInspectedAttributeCarriers().front(); - // check condition - if (AC->getTagProperty().isPersonPlan() && AC->getAttribute(GNE_ATTR_PARENT) == getAttribute(GNE_ATTR_PARENT)) { - // common person parent - return true; - } else { - // all conditions are false - return false; - } - } -} - - -bool -GNEDemandElement::drawContainerPlan() const { - // check conditions - if (myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() && - myNet->getViewNet()->getNetworkViewOptions().showDemandElements() && - myNet->getViewNet()->getDemandViewOptions().showAllContainerPlans()) { - // show all container plans in network mode - return true; - } else if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() && - myNet->getViewNet()->getDemandViewOptions().showAllContainerPlans()) { - // show all container plans - return true; - } else if (myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() && isAttributeCarrierSelected()) { - // show selected - return true; - } else if (myNet->getViewNet()->isAttributeCarrierInspected(getParentDemandElements().front())) { - // container parent is inspected - return true; - } else if (myNet->getViewNet()->getDemandViewOptions().getLockedContainer() == getParentDemandElements().front()) { - // container parent is locked - return true; - } else if (myNet->getViewNet()->getInspectedAttributeCarriers().empty()) { - // nothing is inspected - return false; - } else { - // get inspected AC - const GNEAttributeCarrier* AC = myNet->getViewNet()->getInspectedAttributeCarriers().front(); - // check condition - if (AC->getTagProperty().isContainerPlan() && AC->getAttribute(GNE_ATTR_PARENT) == getAttribute(GNE_ATTR_PARENT)) { - // common container parent - return true; - } else { - // all conditions are false - return false; - } - } -} - - -void -GNEDemandElement::drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, - const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const { - // get inspected and front flags - const bool dottedElement = myNet->getViewNet()->isAttributeCarrierInspected(this) || (myNet->getViewNet()->getFrontAttributeCarrier() == this); - // get person parent - const GNEDemandElement* personParent = getParentDemandElements().front(); - // check if draw person plan element can be drawn - if ((personPlanColor.alpha() != 0) && drawPlan && myNet->getPathManager()->getPathDraw()->drawPathGeometry(dottedElement, lane, myTagProperty.getTag())) { - // get inspected attribute carriers - const auto& inspectedACs = myNet->getViewNet()->getInspectedAttributeCarriers(); - // get inspected person plan - const GNEAttributeCarrier* personPlanInspected = (inspectedACs.size() > 0) ? inspectedACs.front() : nullptr; - // flag to check if width must be duplicated - const bool duplicateWidth = (personPlanInspected == this) || (personPlanInspected == personParent); - // calculate path width - const double pathWidth = s.addSize.getExaggeration(s, lane) * personPlanWidth * (duplicateWidth ? 2 : 1); - // declare path geometry - GUIGeometry personPlanGeometry; - // update pathGeometry depending of first and last segment - if (segment->isFirstSegment() && segment->isLastSegment()) { - personPlanGeometry.updateGeometry(lane->getLaneGeometry().getShape(), - getPathElementDepartValue(), getPathElementArrivalValue(), // extrem positions - getPathElementDepartPos(), getPathElementArrivalPos()); // extra positions - } else if (segment->isFirstSegment()) { - personPlanGeometry.updateGeometry(lane->getLaneGeometry().getShape(), - getPathElementDepartValue(), -1, // extrem positions - getPathElementDepartPos(), Position::INVALID); // extra positions - } else if (segment->isLastSegment()) { - personPlanGeometry.updateGeometry(lane->getLaneGeometry().getShape(), - -1, getPathElementArrivalValue(), // extrem positions - Position::INVALID, getPathElementArrivalPos()); // extra positions - } else { - personPlanGeometry = lane->getLaneGeometry(); - } - // get color - const RGBColor& pathColor = drawUsingSelectColor() ? s.colorSettings.selectedPersonPlanColor : personPlanColor; - // Start drawing adding an gl identificator - GLHelper::pushName(getGlID()); - // Add a draw matrix - GLHelper::pushMatrix(); - // Start with the drawing of the area traslating matrix to origin - myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, getType(), offsetFront); - // Set color - GLHelper::setColor(pathColor); - // draw geometry - GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), personPlanGeometry, pathWidth); - // Pop last matrix - GLHelper::popMatrix(); - // Draw name if isn't being drawn for selecting - if (!s.drawForRectangleSelection) { - drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); - } - // check if this is the last segment - if (segment->isLastSegment()) { - // calculate circle width - const double circleRadius = (duplicateWidth ? myPersonPlanArrivalPositionDiameter : (myPersonPlanArrivalPositionDiameter / 2.0)); - const double circleWidth = circleRadius * MIN2((double)0.5, s.laneWidthExaggeration); - const double circleWidthSquared = circleWidth * circleWidth; - // get geometryEndPos - const Position geometryEndPos = getPathElementArrivalPos(); - // check if endPos can be drawn - if (!s.drawForRectangleSelection || (myNet->getViewNet()->getPositionInformation().distanceSquaredTo2D(geometryEndPos) <= (circleWidthSquared + 2))) { - // push draw matrix - GLHelper::pushMatrix(); - // Start with the drawing of the area traslating matrix to origin - myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, getType()); - // translate to pos and move to upper using GLO_PERSONTRIP (to avoid overlapping) - glTranslated(geometryEndPos.x(), geometryEndPos.y(), 0); - // Set person plan color - GLHelper::setColor(pathColor); - // resolution of drawn circle depending of the zoom (To improve smothness) - GLHelper::drawFilledCircle(circleWidth, s.getCircleResolution()); - // pop draw matrix - GLHelper::popMatrix(); - } - } - // check if we have to draw an red arrow or line - if (segment->getNextSegment() && segment->getNextSegment()->getLane()) { - // get firstPosition (last position of current lane shape) - const Position from = lane->getLaneShape().back(); - // get lastPosition (first position of next lane shape) - const Position to = segment->getNextSegment()->getLane()->getLaneShape().front(); - // push draw matrix - GLHelper::pushMatrix(); - // Start with the drawing of the area traslating matrix to origin - myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, getType()); - // draw child line - GUIGeometry::drawChildLine(s, from, to, RGBColor::RED, dottedElement || isAttributeCarrierSelected(), .05); - // pop draw matrix - GLHelper::popMatrix(); - } - // check if we have to draw an red arrow or line - if (segment->getPreviousSegment() && segment->getPreviousSegment()->getLane()) { - // get firstPosition (last position of current lane shape) - const Position from = lane->getLaneShape().front(); - // get lastPosition (first position of next lane shape) - const Position to = segment->getPreviousSegment()->getLane()->getLaneShape().back(); - // push draw matrix - GLHelper::pushMatrix(); - // Start with the drawing of the area traslating matrix to origin - myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, getType()); - // draw child line - GUIGeometry::drawChildLine(s, from, to, RGBColor::RED, dottedElement || isAttributeCarrierSelected(), .05); - // pop draw matrix - GLHelper::popMatrix(); - } - // Pop name - GLHelper::popName(); - // declare trim geometry to draw - const auto shape = (segment->isFirstSegment() || segment->isLastSegment()) ? personPlanGeometry.getShape() : lane->getLaneShape(); - // check if mouse is over element - mouseWithinGeometry(shape, pathWidth); - // check if shape dotted contour has to be drawn - if (dottedElement) { - // inspect contour - if (myNet->getViewNet()->isAttributeCarrierInspected(this)) { - GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::INSPECT, shape, pathWidth, 1, segment->isFirstSegment(), segment->isLastSegment()); - } - // front element contour - if (myNet->getViewNet()->getFrontAttributeCarrier() == this) { - GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::FRONT, shape, pathWidth, 1, segment->isFirstSegment(), segment->isLastSegment()); - } - // delete contour - if (myNet->getViewNet()->drawDeleteContour(this, this)) { - GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::REMOVE, shape, pathWidth, 1, segment->isFirstSegment(), segment->isLastSegment()); - } - // select contour - if (myNet->getViewNet()->drawSelectContour(this, this)) { - GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::SELECT, shape, pathWidth, 1, segment->isFirstSegment(), segment->isLastSegment()); - } - } - } - // draw person parent if this is the edge first edge and this is the first plan - if (getParentJunctions().empty() && (getFirstPathLane()->getParentEdge() == lane->getParentEdge()) && - (personParent->getChildDemandElements().front() == this)) { - personParent->drawGL(s); - } -} - - -void -GNEDemandElement::drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* /*segment*/, - const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const { - // get inspected and front flags - const bool dottedElement = myNet->getViewNet()->isAttributeCarrierInspected(this) || (myNet->getViewNet()->getFrontAttributeCarrier() == this); - // check if draw person plan elements can be drawn - if ((personPlanColor.alpha() != 0) && drawPlan && myNet->getPathManager()->getPathDraw()->drawPathGeometry(false, fromLane, toLane, myTagProperty.getTag())) { - // get inspected attribute carriers - const auto& inspectedACs = myNet->getViewNet()->getInspectedAttributeCarriers(); - // get person parent - const GNEDemandElement* personParent = getParentDemandElements().front(); - // get inspected person plan - const GNEAttributeCarrier* personPlanInspected = (inspectedACs.size() > 0) ? inspectedACs.front() : nullptr; - // flag to check if width must be duplicated - const bool duplicateWidth = (personPlanInspected == this) || (personPlanInspected == personParent); - // calculate path width - const double pathWidth = s.addSize.getExaggeration(s, fromLane) * personPlanWidth * (duplicateWidth ? 2 : 1); - // get color - const RGBColor& color = drawUsingSelectColor() ? s.colorSettings.selectedPersonPlanColor : personPlanColor; - // Start drawing adding an gl identificator - GLHelper::pushName(getGlID()); - // push a draw matrix - GLHelper::pushMatrix(); - // Start with the drawing of the area traslating matrix to origin - myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, getType(), offsetFront); - // check if draw lane2lane connection or a red line - if (fromLane && fromLane->getLane2laneConnections().exist(toLane)) { - // obtain lane2lane geometry - const GUIGeometry& lane2laneGeometry = fromLane->getLane2laneConnections().getLane2laneGeometry(toLane); - // Set person plan color - GLHelper::setColor(color); - // draw lane2lane - GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), lane2laneGeometry, pathWidth); - } else { - // Set invalid person plan color - GLHelper::setColor(RGBColor::RED); - // draw line between end of first shape and first position of second shape - GLHelper::drawBoxLines({fromLane->getLaneShape().back(), toLane->getLaneShape().front()}, (0.5 * pathWidth)); - } - // Pop last matrix - GLHelper::popMatrix(); - // Pop name - GLHelper::popName(); - // draw lock icon - GNEViewNetHelper::LockIcon::drawLockIcon(this, getType(), getPositionInView(), 0.5); - // check if shape dotted contour has to be drawn - if (fromLane->getLane2laneConnections().exist(toLane) && dottedElement) { - // check if mouse is over element - mouseWithinGeometry(fromLane->getLane2laneConnections().getLane2laneGeometry(toLane).getShape(), pathWidth); - // inspect contour - if (myNet->getViewNet()->isAttributeCarrierInspected(this)) { - GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::INSPECT, fromLane->getLane2laneConnections().getLane2laneGeometry(toLane).getShape(), - pathWidth, 1, false, false); - } - // front contour - if (myNet->getViewNet()->getFrontAttributeCarrier() == this) { - GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::FRONT, fromLane->getLane2laneConnections().getLane2laneGeometry(toLane).getShape(), - pathWidth, 1, false, false); - } - // delete contour - if (myNet->getViewNet()->drawDeleteContour(this, this)) { - GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::REMOVE, fromLane->getLane2laneConnections().getLane2laneGeometry(toLane).getShape(), - pathWidth, 1, false, false); - } - // select contour - if (myNet->getViewNet()->drawSelectContour(this, this)) { - GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::SELECT, fromLane->getLane2laneConnections().getLane2laneGeometry(toLane).getShape(), - pathWidth, 1, false, false); - } - } - } -} - - -GNEDemandElement::Problem -GNEDemandElement::isPersonPlanValid() const { - // get previous child - const auto previousChild = getParentDemandElements().at(0)->getPreviousChildDemandElement(this); - if (previousChild) { - // get previous edge - GNEEdge* previousEdge = nullptr; - if (previousChild->getParentLanes().size() == 1) { - previousEdge = previousChild->getParentLanes().front()->getParentEdge(); - } else if (previousChild->getParentAdditionals().size() == 1) { - previousEdge = previousChild->getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); - } else if (previousChild->getParentEdges().size() > 0) { - previousEdge = previousChild->getParentEdges().back(); - } else if (previousChild->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { - previousEdge = previousChild->getParentDemandElements().at(1)->getParentEdges().back(); - } - // get first edge - GNEEdge* firstEdge = nullptr; - // check edge - if (getParentLanes().size() == 1) { - firstEdge = getParentLanes().front()->getParentEdge(); - } else if (getParentEdges().size() > 0) { - firstEdge = getParentEdges().front(); - } else if (getParentAdditionals().size() == 1) { - firstEdge = getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); - } else if (getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { - firstEdge = getParentDemandElements().at(1)->getParentEdges().front(); - } - // check junctions - if ((previousChild->getParentJunctions().size() > 0) && (getParentJunctions().size() > 0)) { - if (previousChild->getParentJunctions().back() != getParentJunctions().front()) { - return Problem::DISCONNECTED_PLAN; - } - } else if (previousEdge && (getParentJunctions().size() > 0)) { - if (previousEdge->getToJunction() != getParentJunctions().front()) { - return Problem::DISCONNECTED_PLAN; - } - } else if (previousEdge != firstEdge) { - return Problem::DISCONNECTED_PLAN; - } - } - // get next child - const auto nextChild = getParentDemandElements().at(0)->getNextChildDemandElement(this); - if (nextChild) { - // get previous edge - GNEEdge* nextEdge = nullptr; - if (nextChild->getParentLanes().size() == 1) { - nextEdge = nextChild->getParentLanes().front()->getParentEdge(); - } else if (nextChild->getParentEdges().size() > 0) { - nextEdge = nextChild->getParentEdges().front(); - } else if (nextChild->getParentAdditionals().size() == 1) { - nextEdge = nextChild->getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); - } else if (nextChild->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { - nextEdge = nextChild->getParentDemandElements().at(1)->getParentEdges().front(); - } - // get last edge - GNEEdge* lastEdge = nullptr; - // check edge - if (getParentLanes().size() == 1) { - lastEdge = getParentLanes().front()->getParentEdge(); - } else if (getParentAdditionals().size() == 1) { - lastEdge = getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); - } else if (getParentEdges().size() > 0) { - lastEdge = getParentEdges().back(); - } else if (getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { - lastEdge = getParentDemandElements().at(1)->getParentEdges().back(); - } - // compare both edges - if ((nextChild->getParentJunctions().size() > 0) && (getParentJunctions().size() > 0)) { - if (nextChild->getParentJunctions().front() != getParentJunctions().back()) { - return Problem::DISCONNECTED_PLAN; - } - } else if (nextEdge && (getParentJunctions().size() > 0)) { - if (nextEdge->getFromJunction() != getParentJunctions().back()) { - return Problem::DISCONNECTED_PLAN; - } - } else if (lastEdge && (nextChild->getParentJunctions().size() > 0)) { - if (lastEdge->getToJunction() != nextChild->getParentJunctions().front()) { - return Problem::DISCONNECTED_PLAN; - } - } else if (nextEdge != lastEdge) { - return Problem::DISCONNECTED_PLAN; - } - } - // all ok, then return true - return Problem::OK; -} - - -std::string -GNEDemandElement::getPersonPlanProblem() const { - // get previous child - const auto previousChild = getParentDemandElements().at(0)->getPreviousChildDemandElement(this); - if (previousChild) { - // get previous edge - GNEEdge* previousEdge = nullptr; - if (previousChild->getParentLanes().size() == 1) { - previousEdge = previousChild->getParentLanes().front()->getParentEdge(); - } else if (previousChild->getParentAdditionals().size() == 1) { - previousEdge = previousChild->getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); - } else if (previousChild->getParentEdges().size() > 0) { - previousEdge = previousChild->getParentEdges().back(); - } else if (previousChild->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { - previousEdge = previousChild->getParentDemandElements().at(1)->getParentEdges().back(); - } - // get first edge - GNEEdge* firstEdge = nullptr; - // check edge - if (getParentLanes().size() == 1) { - firstEdge = getParentLanes().front()->getParentEdge(); - } else if (getParentEdges().size() > 0) { - firstEdge = getParentEdges().front(); - } else if (getParentAdditionals().size() == 1) { - firstEdge = getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); - } else if (getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { - firstEdge = getParentDemandElements().at(1)->getParentEdges().front(); - } - // compare elements - if ((previousChild->getParentJunctions().size() > 0) && (getParentJunctions().size() > 0)) { - return ("Junction '" + previousChild->getParentJunctions().back()->getID() + - "' is not consecutive with junction '" + getParentJunctions().front()->getID() + "'"); - } else if (previousEdge && (getParentJunctions().size() > 0)) { - return ("edge '" + previousEdge->getID() + "' is not consecutive with junction '" + getParentJunctions().front()->getID() + "'"); - } else if (previousEdge && firstEdge && (previousEdge != firstEdge)) { - return "Edge '" + previousEdge->getID() + "' is not consecutive with edge '" + firstEdge->getID() + "'"; - } - } - // get next child - const auto nextChild = getParentDemandElements().at(0)->getNextChildDemandElement(this); - if (nextChild) { - // get previous edge - GNEEdge* nextEdge = nullptr; - if (nextChild->getParentLanes().size() == 1) { - nextEdge = nextChild->getParentLanes().front()->getParentEdge(); - } else if (nextChild->getParentAdditionals().size() == 1) { - nextEdge = nextChild->getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); - } else if (nextChild->getParentEdges().size() > 0) { - nextEdge = nextChild->getParentEdges().front(); - } else if (nextChild->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { - nextEdge = nextChild->getParentDemandElements().at(1)->getParentEdges().front(); - } - // get last edge - GNEEdge* lastEdge = nullptr; - // check edge - if (getParentLanes().size() == 1) { - lastEdge = getParentLanes().front()->getParentEdge(); - } else if (getParentAdditionals().size() == 1) { - lastEdge = getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); - } else if (getParentEdges().size() > 0) { - lastEdge = getParentEdges().back(); - } else if (getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { - lastEdge = getParentDemandElements().at(1)->getParentEdges().back(); - } - // compare elements - if ((nextChild->getParentJunctions().size() > 0) && (getParentJunctions().size() > 0)) { - return ("Junction '" + nextChild->getParentJunctions().front()->getID() + - "' is not consecutive with junction '" + getParentJunctions().back()->getID() + "'"); - } else if (nextEdge && (getParentJunctions().size() > 0)) { - return ("edge '" + nextEdge->getID() + "' is not consecutive with junction '" + getParentJunctions().back()->getID() + "'"); - } else if (lastEdge && (nextChild->getParentJunctions().size() > 0)) { - return ("edge '" + lastEdge->getID() + "' is not consecutive with junction '" + nextChild->getParentJunctions().back()->getID() + "'"); - } else if (nextEdge && lastEdge && (nextEdge != lastEdge)) { - return "Edge '" + lastEdge->getID() + "' is not consecutive with edge '" + nextEdge->getID() + "'"; - } - } - // undefined problem - return "undefined problem"; -} - - void GNEDemandElement::drawJunctionLine(const GNEDemandElement* element) const { // get two points diff --git a/src/netedit/elements/demand/GNEDemandElement.h b/src/netedit/elements/demand/GNEDemandElement.h index 8fc46401581..05bab8637e0 100644 --- a/src/netedit/elements/demand/GNEDemandElement.h +++ b/src/netedit/elements/demand/GNEDemandElement.h @@ -48,16 +48,13 @@ class GNEJunction; // class definitions // =========================================================================== -/** - * @class GNEDemandElement - * @brief An Element which don't belong to GNENet but has influence in the simulation - */ class GNEDemandElement : public GNEPathManager::PathElement, public GNEHierarchicalElement, public GNEMoveElement, public GNEDemandElementDistribution { public: /// @brief friend declaration (needed for vTypes) friend class GNERouteHandler; friend class GNEDemandElementFlow; + friend class GNEDemandElementPlan; /// @brief enum class for demandElement problems enum class Problem { @@ -352,33 +349,6 @@ class GNEDemandElement : public GNEPathManager::PathElement, public GNEHierarchi /// @brief get route parent (always the second parent demand element) GNEDemandElement* getRouteParent() const; - /// @name Only for person plans - /// @{ - /// @brief check if person plan can be drawn - bool drawPersonPlan() const; - - /// @brief check if container plan can be drawn - bool drawContainerPlan() const; - - /// @brief draw person plan partial lane - void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront, - const double personPlanWidth, const RGBColor& personPlanColor) const; - - /// @brief draw person plan partial junction - void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, - const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const; - - /// @brief check if person plan is valid - Problem isPersonPlanValid() const; - - /// @brief get person plan problem - std::string getPersonPlanProblem() const; - - /// @brief person plans arrival position radius - static const double myPersonPlanArrivalPositionDiameter; - - /// @} - /// @brief draw line between junctions void drawJunctionLine(const GNEDemandElement* element) const; diff --git a/src/netedit/elements/demand/GNEDemandElementDistribution.h b/src/netedit/elements/demand/GNEDemandElementDistribution.h index 827df047c5b..18db0d31f17 100644 --- a/src/netedit/elements/demand/GNEDemandElementDistribution.h +++ b/src/netedit/elements/demand/GNEDemandElementDistribution.h @@ -32,10 +32,6 @@ class GNEUndoList; // class definitions // =========================================================================== -/** - * @class GNEDemandElementDistribution - * @brief Module used for represent attribute distributions - */ class GNEDemandElementDistribution { /// @brief friend declaration diff --git a/src/netedit/elements/demand/GNEDemandElementPlan.cpp b/src/netedit/elements/demand/GNEDemandElementPlan.cpp new file mode 100644 index 00000000000..eafefa48e75 --- /dev/null +++ b/src/netedit/elements/demand/GNEDemandElementPlan.cpp @@ -0,0 +1,526 @@ +/****************************************************************************/ +// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo +// Copyright (C) 2001-2023 German Aerospace Center (DLR) and others. +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0/ +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License 2.0 are satisfied: GNU General Public License, version 2 +// or later which is available at +// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later +/****************************************************************************/ +/// @file GNEDemandElementPlan.cpp +/// @author Pablo Alvarez Lopez +/// @date Sep 2023 +/// +// An auxiliar, asbtract class for plan elements +/****************************************************************************/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "GNEDemandElementPlan.h" +#include "GNEDemandElement.h" + +// =========================================================================== +// static definitions +// =========================================================================== +const double GNEDemandElementPlan::myPersonPlanArrivalPositionDiameter = SUMO_const_halfLaneWidth; + +// =========================================================================== +// GNEDemandElement method definitions +// =========================================================================== + + +GNEDemandElementPlan::GNEDemandElementPlan(const GNEDemandElement* planElement) : + myPlanElement(planElement) { +} + + +bool +GNEDemandElementPlan::drawPersonPlan() const { + // get view net + auto viewNet = myPlanElement->getNet()->getViewNet(); + // check conditions + if (viewNet->getEditModes().isCurrentSupermodeNetwork() && + viewNet->getNetworkViewOptions().showDemandElements() && + viewNet->getDemandViewOptions().showAllPersonPlans()) { + // show all person plans in network mode + return true; + } else if (viewNet->getEditModes().isCurrentSupermodeDemand() && + viewNet->getDemandViewOptions().showAllPersonPlans()) { + // show all person plans + return true; + } else if (viewNet->getEditModes().isCurrentSupermodeDemand() && myPlanElement->isAttributeCarrierSelected()) { + // show selected + return true; + } else if (viewNet->isAttributeCarrierInspected(myPlanElement->getParentDemandElements().front())) { + // person parent is inspected + return true; + } else if (viewNet->getDemandViewOptions().getLockedPerson() == myPlanElement->getParentDemandElements().front()) { + // person parent is locked + return true; + } else if (viewNet->getInspectedAttributeCarriers().empty()) { + // nothing is inspected + return false; + } else { + // get inspected AC + const GNEAttributeCarrier* AC = viewNet->getInspectedAttributeCarriers().front(); + // check condition + if (AC->getTagProperty().isPersonPlan() && AC->getAttribute(GNE_ATTR_PARENT) == myPlanElement->getAttribute(GNE_ATTR_PARENT)) { + // common person parent + return true; + } else { + // all conditions are false + return false; + } + } +} + + +bool +GNEDemandElementPlan::drawContainerPlan() const { + // get view net + auto viewNet = myPlanElement->getNet()->getViewNet(); + // check conditions + if (viewNet->getEditModes().isCurrentSupermodeNetwork() && + viewNet->getNetworkViewOptions().showDemandElements() && + viewNet->getDemandViewOptions().showAllContainerPlans()) { + // show all container plans in network mode + return true; + } else if (viewNet->getEditModes().isCurrentSupermodeDemand() && + viewNet->getDemandViewOptions().showAllContainerPlans()) { + // show all container plans + return true; + } else if (viewNet->getEditModes().isCurrentSupermodeDemand() && myPlanElement->isAttributeCarrierSelected()) { + // show selected + return true; + } else if (viewNet->isAttributeCarrierInspected(myPlanElement->getParentDemandElements().front())) { + // container parent is inspected + return true; + } else if (viewNet->getDemandViewOptions().getLockedContainer() == myPlanElement->getParentDemandElements().front()) { + // container parent is locked + return true; + } else if (viewNet->getInspectedAttributeCarriers().empty()) { + // nothing is inspected + return false; + } else { + // get inspected AC + const GNEAttributeCarrier* AC = viewNet->getInspectedAttributeCarriers().front(); + // check condition + if (AC->getTagProperty().isContainerPlan() && AC->getAttribute(GNE_ATTR_PARENT) == myPlanElement->getAttribute(GNE_ATTR_PARENT)) { + // common container parent + return true; + } else { + // all conditions are false + return false; + } + } +} + + +void +GNEDemandElementPlan::drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, + const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const { + // get view net + auto viewNet = myPlanElement->getNet()->getViewNet(); + // get inspected and front flags + const bool dottedElement = viewNet->isAttributeCarrierInspected(myPlanElement) || (viewNet->getFrontAttributeCarrier() == myPlanElement); + // get person parent + const GNEDemandElement* personParent = myPlanElement->getParentDemandElements().front(); + // check if draw person plan element can be drawn + if ((personPlanColor.alpha() != 0) && drawPlan && myPlanElement->getNet()->getPathManager()->getPathDraw()->drawPathGeometry(dottedElement, lane, myPlanElement->getTagProperty().getTag())) { + // get inspected attribute carriers + const auto& inspectedACs = viewNet->getInspectedAttributeCarriers(); + // get inspected person plan + const GNEAttributeCarrier* personPlanInspected = (inspectedACs.size() > 0) ? inspectedACs.front() : nullptr; + // flag to check if width must be duplicated + const bool duplicateWidth = (personPlanInspected == myPlanElement) || (personPlanInspected == personParent); + // calculate path width + const double pathWidth = s.addSize.getExaggeration(s, lane) * personPlanWidth * (duplicateWidth ? 2 : 1); + // declare path geometry + GUIGeometry personPlanGeometry; + // update pathGeometry depending of first and last segment + if (segment->isFirstSegment() && segment->isLastSegment()) { + personPlanGeometry.updateGeometry(lane->getLaneGeometry().getShape(), + myPlanElement->getPathElementDepartValue(), myPlanElement->getPathElementArrivalValue(), // extrem positions + myPlanElement->getPathElementDepartPos(), myPlanElement->getPathElementArrivalPos()); // extra positions + } else if (segment->isFirstSegment()) { + personPlanGeometry.updateGeometry(lane->getLaneGeometry().getShape(), + myPlanElement->getPathElementDepartValue(), -1, // extrem positions + myPlanElement->getPathElementDepartPos(), Position::INVALID); // extra positions + } else if (segment->isLastSegment()) { + personPlanGeometry.updateGeometry(lane->getLaneGeometry().getShape(), + -1, myPlanElement->getPathElementArrivalValue(), // extrem positions + Position::INVALID, myPlanElement->getPathElementArrivalPos()); // extra positions + } else { + personPlanGeometry = lane->getLaneGeometry(); + } + // get color + const RGBColor& pathColor = myPlanElement->drawUsingSelectColor() ? s.colorSettings.selectedPersonPlanColor : personPlanColor; + // Start drawing adding an gl identificator + GLHelper::pushName(myPlanElement->getGlID()); + // Add a draw matrix + GLHelper::pushMatrix(); + // Start with the drawing of the area traslating matrix to origin + viewNet->drawTranslateFrontAttributeCarrier(myPlanElement, myPlanElement->getType(), offsetFront); + // Set color + GLHelper::setColor(pathColor); + // draw geometry + GUIGeometry::drawGeometry(s, viewNet->getPositionInformation(), personPlanGeometry, pathWidth); + // Pop last matrix + GLHelper::popMatrix(); + // Draw name if isn't being drawn for selecting + if (!s.drawForRectangleSelection) { + myPlanElement->drawName(myPlanElement->getCenteringBoundary().getCenter(), s.scale, s.addName); + } + // check if myPlanElement is the last segment + if (segment->isLastSegment()) { + // calculate circle width + const double circleRadius = (duplicateWidth ? myPersonPlanArrivalPositionDiameter : (myPersonPlanArrivalPositionDiameter / 2.0)); + const double circleWidth = circleRadius * MIN2((double)0.5, s.laneWidthExaggeration); + const double circleWidthSquared = circleWidth * circleWidth; + // get geometryEndPos + const Position geometryEndPos = myPlanElement->getPathElementArrivalPos(); + // check if endPos can be drawn + if (!s.drawForRectangleSelection || (viewNet->getPositionInformation().distanceSquaredTo2D(geometryEndPos) <= (circleWidthSquared + 2))) { + // push draw matrix + GLHelper::pushMatrix(); + // Start with the drawing of the area traslating matrix to origin + viewNet->drawTranslateFrontAttributeCarrier(myPlanElement, myPlanElement->getType()); + // translate to pos and move to upper using GLO_PERSONTRIP (to avoid overlapping) + glTranslated(geometryEndPos.x(), geometryEndPos.y(), 0); + // Set person plan color + GLHelper::setColor(pathColor); + // resolution of drawn circle depending of the zoom (To improve smothness) + GLHelper::drawFilledCircle(circleWidth, s.getCircleResolution()); + // pop draw matrix + GLHelper::popMatrix(); + } + } + // check if we have to draw an red arrow or line + if (segment->getNextSegment() && segment->getNextSegment()->getLane()) { + // get firstPosition (last position of current lane shape) + const Position from = lane->getLaneShape().back(); + // get lastPosition (first position of next lane shape) + const Position to = segment->getNextSegment()->getLane()->getLaneShape().front(); + // push draw matrix + GLHelper::pushMatrix(); + // Start with the drawing of the area traslating matrix to origin + viewNet->drawTranslateFrontAttributeCarrier(myPlanElement, myPlanElement->getType()); + // draw child line + GUIGeometry::drawChildLine(s, from, to, RGBColor::RED, dottedElement || myPlanElement->isAttributeCarrierSelected(), .05); + // pop draw matrix + GLHelper::popMatrix(); + } + // check if we have to draw an red arrow or line + if (segment->getPreviousSegment() && segment->getPreviousSegment()->getLane()) { + // get firstPosition (last position of current lane shape) + const Position from = lane->getLaneShape().front(); + // get lastPosition (first position of next lane shape) + const Position to = segment->getPreviousSegment()->getLane()->getLaneShape().back(); + // push draw matrix + GLHelper::pushMatrix(); + // Start with the drawing of the area traslating matrix to origin + viewNet->drawTranslateFrontAttributeCarrier(myPlanElement, myPlanElement->getType()); + // draw child line + GUIGeometry::drawChildLine(s, from, to, RGBColor::RED, dottedElement || myPlanElement->isAttributeCarrierSelected(), .05); + // pop draw matrix + GLHelper::popMatrix(); + } + // Pop name + GLHelper::popName(); + // declare trim geometry to draw + const auto shape = (segment->isFirstSegment() || segment->isLastSegment()) ? personPlanGeometry.getShape() : lane->getLaneShape(); + // check if mouse is over element + myPlanElement->mouseWithinGeometry(shape, pathWidth); + // check if shape dotted contour has to be drawn + if (dottedElement) { + // inspect contour + if (viewNet->isAttributeCarrierInspected(myPlanElement)) { + GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::INSPECT, shape, pathWidth, 1, segment->isFirstSegment(), segment->isLastSegment()); + } + // front element contour + if (viewNet->getFrontAttributeCarrier() == myPlanElement) { + GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::FRONT, shape, pathWidth, 1, segment->isFirstSegment(), segment->isLastSegment()); + } + // delete contour + if (viewNet->drawDeleteContour(myPlanElement, myPlanElement)) { + GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::REMOVE, shape, pathWidth, 1, segment->isFirstSegment(), segment->isLastSegment()); + } + // select contour + if (viewNet->drawSelectContour(myPlanElement, myPlanElement)) { + GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::SELECT, shape, pathWidth, 1, segment->isFirstSegment(), segment->isLastSegment()); + } + } + } + // draw person parent if myPlanElement is the edge first edge and myPlanElement is the first plan + if (myPlanElement->getParentJunctions().empty() && (myPlanElement->getFirstPathLane()->getParentEdge() == lane->getParentEdge()) && + (personParent->getChildDemandElements().front() == myPlanElement)) { + personParent->drawGL(s); + } +} + + +void +GNEDemandElementPlan::drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* /*segment*/, + const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const { + // get view net + auto viewNet = myPlanElement->getNet()->getViewNet(); + // get inspected and front flags + const bool dottedElement = viewNet->isAttributeCarrierInspected(myPlanElement) || (viewNet->getFrontAttributeCarrier() == myPlanElement); + // check if draw person plan elements can be drawn + if ((personPlanColor.alpha() != 0) && drawPlan && myPlanElement->getNet()->getPathManager()->getPathDraw()->drawPathGeometry(false, fromLane, toLane, myPlanElement->getTagProperty().getTag())) { + // get inspected attribute carriers + const auto& inspectedACs = viewNet->getInspectedAttributeCarriers(); + // get person parent + const GNEDemandElement* personParent = myPlanElement->getParentDemandElements().front(); + // get inspected person plan + const GNEAttributeCarrier* personPlanInspected = (inspectedACs.size() > 0) ? inspectedACs.front() : nullptr; + // flag to check if width must be duplicated + const bool duplicateWidth = (personPlanInspected == myPlanElement) || (personPlanInspected == personParent); + // calculate path width + const double pathWidth = s.addSize.getExaggeration(s, fromLane) * personPlanWidth * (duplicateWidth ? 2 : 1); + // get color + const RGBColor& color = myPlanElement->drawUsingSelectColor() ? s.colorSettings.selectedPersonPlanColor : personPlanColor; + // Start drawing adding an gl identificator + GLHelper::pushName(myPlanElement->getGlID()); + // push a draw matrix + GLHelper::pushMatrix(); + // Start with the drawing of the area traslating matrix to origin + viewNet->drawTranslateFrontAttributeCarrier(myPlanElement, myPlanElement->getType(), offsetFront); + // check if draw lane2lane connection or a red line + if (fromLane && fromLane->getLane2laneConnections().exist(toLane)) { + // obtain lane2lane geometry + const GUIGeometry& lane2laneGeometry = fromLane->getLane2laneConnections().getLane2laneGeometry(toLane); + // Set person plan color + GLHelper::setColor(color); + // draw lane2lane + GUIGeometry::drawGeometry(s, viewNet->getPositionInformation(), lane2laneGeometry, pathWidth); + } else { + // Set invalid person plan color + GLHelper::setColor(RGBColor::RED); + // draw line between end of first shape and first position of second shape + GLHelper::drawBoxLines({fromLane->getLaneShape().back(), toLane->getLaneShape().front()}, (0.5 * pathWidth)); + } + // Pop last matrix + GLHelper::popMatrix(); + // Pop name + GLHelper::popName(); + // draw lock icon + GNEViewNetHelper::LockIcon::drawLockIcon(myPlanElement, myPlanElement->getType(), myPlanElement->getPositionInView(), 0.5); + // check if shape dotted contour has to be drawn + if (fromLane->getLane2laneConnections().exist(toLane) && dottedElement) { + // check if mouse is over element + myPlanElement->mouseWithinGeometry(fromLane->getLane2laneConnections().getLane2laneGeometry(toLane).getShape(), pathWidth); + // inspect contour + if (viewNet->isAttributeCarrierInspected(myPlanElement)) { + GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::INSPECT, fromLane->getLane2laneConnections().getLane2laneGeometry(toLane).getShape(), + pathWidth, 1, false, false); + } + // front contour + if (viewNet->getFrontAttributeCarrier() == myPlanElement) { + GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::FRONT, fromLane->getLane2laneConnections().getLane2laneGeometry(toLane).getShape(), + pathWidth, 1, false, false); + } + // delete contour + if (viewNet->drawDeleteContour(myPlanElement, myPlanElement)) { + GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::REMOVE, fromLane->getLane2laneConnections().getLane2laneGeometry(toLane).getShape(), + pathWidth, 1, false, false); + } + // select contour + if (viewNet->drawSelectContour(myPlanElement, myPlanElement)) { + GUIDottedGeometry::drawDottedContourShape(s, GUIDottedGeometry::DottedContourType::SELECT, fromLane->getLane2laneConnections().getLane2laneGeometry(toLane).getShape(), + pathWidth, 1, false, false); + } + } + } +} + + +GNEDemandElement::Problem +GNEDemandElementPlan::isPersonPlanValid() const { + // get previous child + const auto previousChild = myPlanElement->getParentDemandElements().at(0)->getPreviousChildDemandElement(myPlanElement); + if (previousChild) { + // get previous edge + GNEEdge* previousEdge = nullptr; + if (previousChild->getParentLanes().size() == 1) { + previousEdge = previousChild->getParentLanes().front()->getParentEdge(); + } else if (previousChild->getParentAdditionals().size() == 1) { + previousEdge = previousChild->getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); + } else if (previousChild->getParentEdges().size() > 0) { + previousEdge = previousChild->getParentEdges().back(); + } else if (previousChild->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { + previousEdge = previousChild->getParentDemandElements().at(1)->getParentEdges().back(); + } + // get first edge + GNEEdge* firstEdge = nullptr; + // check edge + if (myPlanElement->getParentLanes().size() == 1) { + firstEdge = myPlanElement->getParentLanes().front()->getParentEdge(); + } else if (myPlanElement->getParentEdges().size() > 0) { + firstEdge = myPlanElement->getParentEdges().front(); + } else if (myPlanElement->getParentAdditionals().size() == 1) { + firstEdge = myPlanElement->getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); + } else if (myPlanElement->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { + firstEdge = myPlanElement->getParentDemandElements().at(1)->getParentEdges().front(); + } + // check junctions + if ((previousChild->getParentJunctions().size() > 0) && (myPlanElement->getParentJunctions().size() > 0)) { + if (previousChild->getParentJunctions().back() != myPlanElement->getParentJunctions().front()) { + return GNEDemandElement::Problem::DISCONNECTED_PLAN; + } + } else if (previousEdge && (myPlanElement->getParentJunctions().size() > 0)) { + if (previousEdge->getToJunction() != myPlanElement->getParentJunctions().front()) { + return GNEDemandElement::Problem::DISCONNECTED_PLAN; + } + } else if (previousEdge != firstEdge) { + return GNEDemandElement::Problem::DISCONNECTED_PLAN; + } + } + // get next child + const auto nextChild = myPlanElement->getParentDemandElements().at(0)->getNextChildDemandElement(myPlanElement); + if (nextChild) { + // get previous edge + GNEEdge* nextEdge = nullptr; + if (nextChild->getParentLanes().size() == 1) { + nextEdge = nextChild->getParentLanes().front()->getParentEdge(); + } else if (nextChild->getParentEdges().size() > 0) { + nextEdge = nextChild->getParentEdges().front(); + } else if (nextChild->getParentAdditionals().size() == 1) { + nextEdge = nextChild->getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); + } else if (nextChild->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { + nextEdge = nextChild->getParentDemandElements().at(1)->getParentEdges().front(); + } + // get last edge + GNEEdge* lastEdge = nullptr; + // check edge + if (myPlanElement->getParentLanes().size() == 1) { + lastEdge = myPlanElement->getParentLanes().front()->getParentEdge(); + } else if (myPlanElement->getParentAdditionals().size() == 1) { + lastEdge = myPlanElement->getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); + } else if (myPlanElement->getParentEdges().size() > 0) { + lastEdge = myPlanElement->getParentEdges().back(); + } else if (myPlanElement->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { + lastEdge = myPlanElement->getParentDemandElements().at(1)->getParentEdges().back(); + } + // compare both edges + if ((nextChild->getParentJunctions().size() > 0) && (myPlanElement->getParentJunctions().size() > 0)) { + if (nextChild->getParentJunctions().front() != myPlanElement->getParentJunctions().back()) { + return GNEDemandElement::Problem::DISCONNECTED_PLAN; + } + } else if (nextEdge && (myPlanElement->getParentJunctions().size() > 0)) { + if (nextEdge->getFromJunction() != myPlanElement->getParentJunctions().back()) { + return GNEDemandElement::Problem::DISCONNECTED_PLAN; + } + } else if (lastEdge && (nextChild->getParentJunctions().size() > 0)) { + if (lastEdge->getToJunction() != nextChild->getParentJunctions().front()) { + return GNEDemandElement::Problem::DISCONNECTED_PLAN; + } + } else if (nextEdge != lastEdge) { + return GNEDemandElement::Problem::DISCONNECTED_PLAN; + } + } + // all ok, then return true + return GNEDemandElement::Problem::OK; +} + + +std::string +GNEDemandElementPlan::getPersonPlanProblem() const { + // get previous child + const auto previousChild = myPlanElement->getParentDemandElements().at(0)->getPreviousChildDemandElement(myPlanElement); + if (previousChild) { + // get previous edge + GNEEdge* previousEdge = nullptr; + if (previousChild->getParentLanes().size() == 1) { + previousEdge = previousChild->getParentLanes().front()->getParentEdge(); + } else if (previousChild->getParentAdditionals().size() == 1) { + previousEdge = previousChild->getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); + } else if (previousChild->getParentEdges().size() > 0) { + previousEdge = previousChild->getParentEdges().back(); + } else if (previousChild->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { + previousEdge = previousChild->getParentDemandElements().at(1)->getParentEdges().back(); + } + // get first edge + GNEEdge* firstEdge = nullptr; + // check edge + if (myPlanElement->getParentLanes().size() == 1) { + firstEdge = myPlanElement->getParentLanes().front()->getParentEdge(); + } else if (myPlanElement->getParentEdges().size() > 0) { + firstEdge = myPlanElement->getParentEdges().front(); + } else if (myPlanElement->getParentAdditionals().size() == 1) { + firstEdge = myPlanElement->getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); + } else if (myPlanElement->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { + firstEdge = myPlanElement->getParentDemandElements().at(1)->getParentEdges().front(); + } + // compare elements + if ((previousChild->getParentJunctions().size() > 0) && (myPlanElement->getParentJunctions().size() > 0)) { + return ("Junction '" + previousChild->getParentJunctions().back()->getID() + + "' is not consecutive with junction '" + myPlanElement->getParentJunctions().front()->getID() + "'"); + } else if (previousEdge && (myPlanElement->getParentJunctions().size() > 0)) { + return ("edge '" + previousEdge->getID() + "' is not consecutive with junction '" + myPlanElement->getParentJunctions().front()->getID() + "'"); + } else if (previousEdge && firstEdge && (previousEdge != firstEdge)) { + return "Edge '" + previousEdge->getID() + "' is not consecutive with edge '" + firstEdge->getID() + "'"; + } + } + // get next child + const auto nextChild = myPlanElement->getParentDemandElements().at(0)->getNextChildDemandElement(myPlanElement); + if (nextChild) { + // get previous edge + GNEEdge* nextEdge = nullptr; + if (nextChild->getParentLanes().size() == 1) { + nextEdge = nextChild->getParentLanes().front()->getParentEdge(); + } else if (nextChild->getParentAdditionals().size() == 1) { + nextEdge = nextChild->getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); + } else if (nextChild->getParentEdges().size() > 0) { + nextEdge = nextChild->getParentEdges().front(); + } else if (nextChild->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { + nextEdge = nextChild->getParentDemandElements().at(1)->getParentEdges().front(); + } + // get last edge + GNEEdge* lastEdge = nullptr; + // check edge + if (myPlanElement->getParentLanes().size() == 1) { + lastEdge = myPlanElement->getParentLanes().front()->getParentEdge(); + } else if (myPlanElement->getParentAdditionals().size() == 1) { + lastEdge = myPlanElement->getParentAdditionals().front()->getParentLanes().front()->getParentEdge(); + } else if (myPlanElement->getParentEdges().size() > 0) { + lastEdge = myPlanElement->getParentEdges().back(); + } else if (myPlanElement->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) { + lastEdge = myPlanElement->getParentDemandElements().at(1)->getParentEdges().back(); + } + // compare elements + if ((nextChild->getParentJunctions().size() > 0) && (myPlanElement->getParentJunctions().size() > 0)) { + return ("Junction '" + nextChild->getParentJunctions().front()->getID() + + "' is not consecutive with junction '" + myPlanElement->getParentJunctions().back()->getID() + "'"); + } else if (nextEdge && (myPlanElement->getParentJunctions().size() > 0)) { + return ("edge '" + nextEdge->getID() + "' is not consecutive with junction '" + myPlanElement->getParentJunctions().back()->getID() + "'"); + } else if (lastEdge && (nextChild->getParentJunctions().size() > 0)) { + return ("edge '" + lastEdge->getID() + "' is not consecutive with junction '" + nextChild->getParentJunctions().back()->getID() + "'"); + } else if (nextEdge && lastEdge && (nextEdge != lastEdge)) { + return "Edge '" + lastEdge->getID() + "' is not consecutive with edge '" + nextEdge->getID() + "'"; + } + } + // undefined problem + return "undefined problem"; +} + +/****************************************************************************/ diff --git a/src/netedit/elements/demand/GNEDemandElementPlan.h b/src/netedit/elements/demand/GNEDemandElementPlan.h new file mode 100644 index 00000000000..69dc9564ae6 --- /dev/null +++ b/src/netedit/elements/demand/GNEDemandElementPlan.h @@ -0,0 +1,77 @@ +/****************************************************************************/ +// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo +// Copyright (C) 2001-2023 German Aerospace Center (DLR) and others. +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0/ +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License 2.0 are satisfied: GNU General Public License, version 2 +// or later which is available at +// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later +/****************************************************************************/ +/// @file GNEDemandElementPlan.h +/// @author Pablo Alvarez Lopez +/// @date Sep 2023 +/// +// An auxiliar, asbtract class for plan elements +/****************************************************************************/ +#pragma once +#include + +#include +#include +#include + +// =========================================================================== +// class declaration +// =========================================================================== + +class SUMOVehicleParameter; +class GNEDemandElement; + +// =========================================================================== +// class definitions +// =========================================================================== + +class GNEDemandElementPlan { + +protected: + /// @brief constructor + GNEDemandElementPlan(const GNEDemandElement* planElement); + + /// @brief check if person plan can be drawn + bool drawPersonPlan() const; + + /// @brief check if container plan can be drawn + bool drawContainerPlan() const; + + /// @brief draw person plan partial lane + void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront, + const double personPlanWidth, const RGBColor& personPlanColor) const; + + /// @brief draw person plan partial junction + void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, + const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const; + + /// @brief check if person plan is valid + GNEDemandElement::Problem isPersonPlanValid() const; + + /// @brief get person plan problem + std::string getPersonPlanProblem() const; + +protected: + /// @brief person plans arrival position radius + static const double myPersonPlanArrivalPositionDiameter; + +private: + /// @brief pointer to plan element + const GNEDemandElement* myPlanElement; + + /// @brief Invalidated copy constructor. + GNEDemandElementPlan(const GNEDemandElementPlan&) = delete; + + /// @brief Invalidated assignment operator. + GNEDemandElementPlan& operator=(const GNEDemandElementPlan&) = delete; +}; diff --git a/src/netedit/elements/demand/GNEPerson.h b/src/netedit/elements/demand/GNEPerson.h index 883e9a8cb9d..2b968d960a5 100644 --- a/src/netedit/elements/demand/GNEPerson.h +++ b/src/netedit/elements/demand/GNEPerson.h @@ -27,9 +27,7 @@ // =========================================================================== // class definitions // =========================================================================== -/** - * @class GNEPerson - */ + class GNEPerson : public GNEDemandElement, public GNEDemandElementFlow { public: diff --git a/src/netedit/elements/demand/GNEPersonTrip.cpp b/src/netedit/elements/demand/GNEPersonTrip.cpp index deb5d669e71..549befec291 100644 --- a/src/netedit/elements/demand/GNEPersonTrip.cpp +++ b/src/netedit/elements/demand/GNEPersonTrip.cpp @@ -38,6 +38,7 @@ GNEPersonTrip::GNEPersonTrip(SumoXMLTag tag, GNENet* net) : GNEDemandElement("", net, GLO_PERSONTRIP, tag, GUIIconSubSys::getIcon(GUIIcon::PERSONTRIP_FROMTO), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}), + GNEDemandElementPlan(this), myArrivalPosition(0) { // reset default values resetDefaultValues(); @@ -49,6 +50,7 @@ GNEPersonTrip::GNEPersonTrip(GNENet* net, GNEDemandElement* personParent, GNEEdg const std::vector& lines) : GNEDemandElement(personParent, net, GLO_PERSONTRIP, GNE_TAG_PERSONTRIP_EDGE, GUIIconSubSys::getIcon(GUIIcon::PERSONTRIP_FROMTO), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {personParent}, {}), + GNEDemandElementPlan(this), myArrivalPosition(arrivalPosition), myVTypes(types), myModes(modes), @@ -62,6 +64,7 @@ GNEPersonTrip::GNEPersonTrip(bool isTrain, GNENet* net, GNEDemandElement* person GNEDemandElement(personParent, net, GLO_PERSONTRIP, isTrain ? GNE_TAG_PERSONTRIP_TRAINSTOP : GNE_TAG_PERSONTRIP_BUSSTOP, GUIIconSubSys::getIcon(isTrain ? GUIIcon::PERSONTRIP_TRAINSTOP : GUIIcon::PERSONTRIP_BUSSTOP), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge}, {}, {toStoppingPlace}, {personParent}, {}), + GNEDemandElementPlan(this), myArrivalPosition(arrivalPosition), myVTypes(types), myModes(modes), @@ -74,6 +77,7 @@ GNEPersonTrip::GNEPersonTrip(GNENet* net, GNEDemandElement* personParent, GNEJun const std::vector& lines) : GNEDemandElement(personParent, net, GLO_PERSONTRIP, GNE_TAG_PERSONTRIP_JUNCTIONS, GUIIconSubSys::getIcon(GUIIcon::PERSONTRIP_JUNCTIONS), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {fromJunction, toJunction}, {}, {}, {}, {personParent}, {}), + GNEDemandElementPlan(this), myArrivalPosition(arrivalPosition), myVTypes(types), myModes(modes), @@ -86,6 +90,7 @@ GNEPersonTrip::GNEPersonTrip(GNENet* net, GNEDemandElement* personParent, GNEAdd const std::vector& lines) : GNEDemandElement(personParent, net, GLO_PERSONTRIP, GNE_TAG_PERSONTRIP_TAZS, GUIIconSubSys::getIcon(GUIIcon::PERSONTRIP_JUNCTIONS), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {fromTAZ, toTAZ}, {personParent}, {}), + GNEDemandElementPlan(this), myArrivalPosition(arrivalPosition), myVTypes(types), myModes(modes), diff --git a/src/netedit/elements/demand/GNEPersonTrip.h b/src/netedit/elements/demand/GNEPersonTrip.h index db526fa5f18..26b3fb1e38f 100644 --- a/src/netedit/elements/demand/GNEPersonTrip.h +++ b/src/netedit/elements/demand/GNEPersonTrip.h @@ -19,21 +19,25 @@ /****************************************************************************/ #pragma once #include -#include "GNEDemandElement.h" #include +#include "GNEDemandElement.h" +#include "GNEDemandElementPlan.h" + // =========================================================================== // class declarations // =========================================================================== + class GNEEdge; class GNEConnection; class GNEVehicle; - // =========================================================================== // class definitions -// =========================================================================== -class GNEPersonTrip : public GNEDemandElement, public Parameterised { +// ==================================================================== + +class GNEPersonTrip : public GNEDemandElement, public Parameterised, public GNEDemandElementPlan { + public: /// @brief default constructor GNEPersonTrip(SumoXMLTag tag, GNENet* net); diff --git a/src/netedit/elements/demand/GNERide.cpp b/src/netedit/elements/demand/GNERide.cpp index bc368f5c4d9..d7a006f8296 100644 --- a/src/netedit/elements/demand/GNERide.cpp +++ b/src/netedit/elements/demand/GNERide.cpp @@ -36,7 +36,8 @@ GNERide::GNERide(SumoXMLTag tag, GNENet* net) : GNEDemandElement("", net, GLO_RIDE, tag, GUIIconSubSys::getIcon(GUIIcon::RIDE_FROMTO), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}), -myArrivalPosition(0) { + GNEDemandElementPlan(this), + myArrivalPosition(0) { // reset default values resetDefaultValues(); } @@ -46,8 +47,9 @@ GNERide::GNERide(GNENet* net, GNEDemandElement* personParent, GNEEdge* fromEdge, double arrivalPosition, const std::vector& lines) : GNEDemandElement(personParent, net, GLO_RIDE, GNE_TAG_RIDE_EDGE, GUIIconSubSys::getIcon(GUIIcon::RIDE_FROMTO), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {personParent}, {}), -myArrivalPosition(arrivalPosition), -myLines(lines) { + GNEDemandElementPlan(this), + myArrivalPosition(arrivalPosition), + myLines(lines) { } @@ -56,8 +58,9 @@ GNERide::GNERide(bool isTrain, GNENet* net, GNEDemandElement* personParent, GNEE GNEDemandElement(personParent, net, GLO_RIDE, isTrain ? GNE_TAG_RIDE_TRAINSTOP : GNE_TAG_RIDE_BUSSTOP, GUIIconSubSys::getIcon(isTrain ? GUIIcon::RIDE_TRAINSTOP : GUIIcon::RIDE_BUSSTOP), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge}, {}, {toBusStop}, {personParent}, {}), -myArrivalPosition(arrivalPosition), -myLines(lines) { + GNEDemandElementPlan(this), + myArrivalPosition(arrivalPosition), + myLines(lines) { } diff --git a/src/netedit/elements/demand/GNERide.h b/src/netedit/elements/demand/GNERide.h index b0df8c58517..32640fa3582 100644 --- a/src/netedit/elements/demand/GNERide.h +++ b/src/netedit/elements/demand/GNERide.h @@ -19,12 +19,15 @@ /****************************************************************************/ #pragma once #include -#include "GNEDemandElement.h" #include +#include "GNEDemandElement.h" +#include "GNEDemandElementPlan.h" + // =========================================================================== // class declarations // =========================================================================== + class GNEEdge; class GNEConnection; class GNEVehicle; @@ -33,7 +36,7 @@ class GNEVehicle; // class definitions // =========================================================================== -class GNERide : public GNEDemandElement, public Parameterised { +class GNERide : public GNEDemandElement, public Parameterised, public GNEDemandElementPlan { public: /// @brief default constructor diff --git a/src/netedit/elements/demand/GNERoute.h b/src/netedit/elements/demand/GNERoute.h index 9b641b8ac8e..ee81476d729 100644 --- a/src/netedit/elements/demand/GNERoute.h +++ b/src/netedit/elements/demand/GNERoute.h @@ -28,6 +28,7 @@ // =========================================================================== // class declarations // =========================================================================== + class GNEEdge; class GNEConnection; class GNEVehicle; diff --git a/src/netedit/elements/demand/GNEStop.cpp b/src/netedit/elements/demand/GNEStop.cpp index 6a7c36537c6..1659a6b2de7 100644 --- a/src/netedit/elements/demand/GNEStop.cpp +++ b/src/netedit/elements/demand/GNEStop.cpp @@ -42,7 +42,8 @@ GNEStop::GNEStop(SumoXMLTag tag, GNENet* net) : GNEDemandElement("", net, GLO_STOP, tag, GUIIconSubSys::getIcon(GUIIcon::STOP), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}), -myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) { + GNEDemandElementPlan(this), + myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) { // reset default values resetDefaultValues(); // enable parking for stops in parkin)gAreas @@ -65,8 +66,9 @@ myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) { GNEStop::GNEStop(SumoXMLTag tag, GNENet* net, GNEDemandElement* stopParent, GNEAdditional* stoppingPlace, const SUMOVehicleParameter::Stop& stopParameter) : GNEDemandElement(stopParent, net, GLO_STOP, tag, GUIIconSubSys::getIcon(GUIIcon::STOP), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {stoppingPlace}, {stopParent}, {}), -SUMOVehicleParameter::Stop(stopParameter), -myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) { + SUMOVehicleParameter::Stop(stopParameter), + GNEDemandElementPlan(this), + myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) { // enable parking for stops in parkingAreas if ((tag == GNE_TAG_STOP_PARKINGAREA) || (tag == GNE_TAG_WAYPOINT_PARKINGAREA)) { parametersSet |= STOP_PARKING_SET; @@ -91,8 +93,9 @@ myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) { GNEStop::GNEStop(SumoXMLTag tag, GNENet* net, GNEDemandElement* stopParent, GNELane* lane, const SUMOVehicleParameter::Stop& stopParameter) : GNEDemandElement(stopParent, net, GLO_STOP, tag, GUIIconSubSys::getIcon(GUIIcon::STOP), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {lane}, {}, {stopParent}, {}), -SUMOVehicleParameter::Stop(stopParameter), -myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) { + SUMOVehicleParameter::Stop(stopParameter), + GNEDemandElementPlan(this), + myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) { // set parking if (parametersSet & STOP_PARKING_SET) { parking = ParkingType::OFFROAD; @@ -113,8 +116,9 @@ myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) { GNEStop::GNEStop(SumoXMLTag tag, GNENet* net, GNEDemandElement* stopParent, GNEEdge* edge, const SUMOVehicleParameter::Stop& stopParameter) : GNEDemandElement(stopParent, net, GLO_STOP, tag, GUIIconSubSys::getIcon(GUIIcon::STOP), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {edge}, {}, {}, {stopParent}, {}), -SUMOVehicleParameter::Stop(stopParameter), -myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) { + SUMOVehicleParameter::Stop(stopParameter), + GNEDemandElementPlan(this), + myCreationIndex(myNet->getAttributeCarriers()->getStopIndex()) { // enable parking for stops in parkingAreas if ((tag == GNE_TAG_STOP_PARKINGAREA) || (tag == GNE_TAG_WAYPOINT_PARKINGAREA)) { parametersSet |= STOP_PARKING_SET; diff --git a/src/netedit/elements/demand/GNEStop.h b/src/netedit/elements/demand/GNEStop.h index 7a21dd14b31..ada2cebcd6d 100644 --- a/src/netedit/elements/demand/GNEStop.h +++ b/src/netedit/elements/demand/GNEStop.h @@ -21,14 +21,13 @@ #include #include "GNEDemandElement.h" +#include "GNEDemandElementPlan.h" // =========================================================================== // class definitions // =========================================================================== -/** - * @class GNEStop - */ -class GNEStop : public GNEDemandElement, public SUMOVehicleParameter::Stop { + +class GNEStop : public GNEDemandElement, public SUMOVehicleParameter::Stop, public GNEDemandElementPlan { public: /// @brief default constructor diff --git a/src/netedit/elements/demand/GNETranship.cpp b/src/netedit/elements/demand/GNETranship.cpp index 2fbb31dce38..6c19e68b451 100644 --- a/src/netedit/elements/demand/GNETranship.cpp +++ b/src/netedit/elements/demand/GNETranship.cpp @@ -37,9 +37,10 @@ GNETranship::GNETranship(SumoXMLTag tag, GNENet* net) : GNEDemandElement("", net, GLO_TRANSHIP, tag, GUIIconSubSys::getIcon(GUIIcon::TRANSHIP_FROMTO), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}), - mySpeed(0), - myDepartPosition(0), -myArrivalPosition(-1) { + GNEDemandElementPlan(this), + mySpeed(0), + myDepartPosition(0), + myArrivalPosition(-1) { // reset default values resetDefaultValues(); } @@ -48,11 +49,11 @@ myArrivalPosition(-1) { GNETranship::GNETranship(GNENet* net, GNEDemandElement* containerParent, GNEEdge* fromEdge, GNEEdge* toEdge, const double speed, const double departPosition, const double arrivalPosition) : GNEDemandElement(containerParent, net, GLO_TRANSHIP, GNE_TAG_TRANSHIP_EDGE, GUIIconSubSys::getIcon(GUIIcon::TRANSHIP_FROMTO), - GNEPathManager::PathElement::Options::DEMAND_ELEMENT, -{}, {fromEdge, toEdge}, {}, {}, {containerParent}, {}), -mySpeed(speed), -myDepartPosition(departPosition), -myArrivalPosition(arrivalPosition) { + GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {containerParent}, {}), + GNEDemandElementPlan(this), + mySpeed(speed), + myDepartPosition(departPosition), + myArrivalPosition(arrivalPosition) { } @@ -60,9 +61,10 @@ GNETranship::GNETranship(GNENet* net, GNEDemandElement* containerParent, GNEEdge const double speed, const double departPosition, const double arrivalPosition) : GNEDemandElement(containerParent, net, GLO_TRANSHIP, GNE_TAG_TRANSHIP_CONTAINERSTOP, GUIIconSubSys::getIcon(GUIIcon::TRANSPORT_CONTAINERSTOP), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge}, {}, {toContainerStop}, {containerParent}, {}), -mySpeed(speed), -myDepartPosition(departPosition), -myArrivalPosition(arrivalPosition) { + GNEDemandElementPlan(this), + mySpeed(speed), + myDepartPosition(departPosition), + myArrivalPosition(arrivalPosition) { } @@ -70,9 +72,10 @@ GNETranship::GNETranship(GNENet* net, GNEDemandElement* containerParent, std::ve const double speed, const double departPosition, const double arrivalPosition) : GNEDemandElement(containerParent, net, GLO_TRANSHIP, GNE_TAG_TRANSHIP_EDGES, GUIIconSubSys::getIcon(GUIIcon::TRANSHIP_EDGES), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {edges}, {}, {}, {containerParent}, {}), -mySpeed(speed), -myDepartPosition(departPosition), -myArrivalPosition(arrivalPosition) { + GNEDemandElementPlan(this), + mySpeed(speed), + myDepartPosition(departPosition), + myArrivalPosition(arrivalPosition) { } diff --git a/src/netedit/elements/demand/GNETranship.h b/src/netedit/elements/demand/GNETranship.h index 494912279a3..f6977283f91 100644 --- a/src/netedit/elements/demand/GNETranship.h +++ b/src/netedit/elements/demand/GNETranship.h @@ -22,20 +22,21 @@ #include #include "GNEDemandElement.h" +#include "GNEDemandElementPlan.h" // =========================================================================== // class declarations // =========================================================================== + class GNEEdge; class GNEConnection; class GNEVehicle; - // =========================================================================== // class definitions // =========================================================================== -class GNETranship : public GNEDemandElement, public Parameterised { +class GNETranship : public GNEDemandElement, public Parameterised, public GNEDemandElementPlan { public: /// @brief default constructor diff --git a/src/netedit/elements/demand/GNETransport.cpp b/src/netedit/elements/demand/GNETransport.cpp index 5aa86d85675..28b7ef84a44 100644 --- a/src/netedit/elements/demand/GNETransport.cpp +++ b/src/netedit/elements/demand/GNETransport.cpp @@ -37,7 +37,8 @@ GNETransport::GNETransport(SumoXMLTag tag, GNENet* net) : GNEDemandElement("", net, GLO_TRANSPORT, tag, GUIIconSubSys::getIcon(GUIIcon::TRANSHIP_FROMTO), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}), -myArrivalPosition(0) { + GNEDemandElementPlan(this), + myArrivalPosition(0) { // reset default values resetDefaultValues(); } @@ -46,16 +47,18 @@ myArrivalPosition(0) { GNETransport::GNETransport(GNENet* net, GNEDemandElement* containerParent, GNEEdge* fromEdge, GNEEdge* toEdge, const std::vector& lines, const double arrivalPosition) : GNEDemandElement(containerParent, net, GLO_TRANSPORT, GNE_TAG_TRANSPORT_EDGE, GUIIconSubSys::getIcon(GUIIcon::TRANSHIP_FROMTO), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {containerParent}, {}), -myLines(lines), -myArrivalPosition(arrivalPosition) { + GNEDemandElementPlan(this), + myLines(lines), + myArrivalPosition(arrivalPosition) { } GNETransport::GNETransport(GNENet* net, GNEDemandElement* containerParent, GNEEdge* fromEdge, GNEAdditional* toContainerStop, const std::vector& lines, const double arrivalPosition) : GNEDemandElement(containerParent, net, GLO_TRANSPORT, GNE_TAG_TRANSPORT_CONTAINERSTOP, GUIIconSubSys::getIcon(GUIIcon::TRANSPORT_CONTAINERSTOP), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge}, {}, {toContainerStop}, {containerParent}, {}), -myLines(lines), -myArrivalPosition(arrivalPosition) { + GNEDemandElementPlan(this), + myLines(lines), + myArrivalPosition(arrivalPosition) { } diff --git a/src/netedit/elements/demand/GNETransport.h b/src/netedit/elements/demand/GNETransport.h index b988bc3093e..19862cdcc7e 100644 --- a/src/netedit/elements/demand/GNETransport.h +++ b/src/netedit/elements/demand/GNETransport.h @@ -19,21 +19,25 @@ /****************************************************************************/ #pragma once #include -#include "GNEDemandElement.h" #include +#include "GNEDemandElement.h" +#include "GNEDemandElementPlan.h" + // =========================================================================== // class declarations // =========================================================================== + class GNEEdge; class GNEConnection; class GNEVehicle; - // =========================================================================== // class definitions // =========================================================================== -class GNETransport : public GNEDemandElement, public Parameterised { + +class GNETransport : public GNEDemandElement, public Parameterised, public GNEDemandElementPlan { + public: /// @brief default constructor GNETransport(SumoXMLTag tag, GNENet* net); diff --git a/src/netedit/elements/demand/GNEVehicle.h b/src/netedit/elements/demand/GNEVehicle.h index 1553f8c3eef..4f475fcaeca 100644 --- a/src/netedit/elements/demand/GNEVehicle.h +++ b/src/netedit/elements/demand/GNEVehicle.h @@ -27,9 +27,7 @@ // =========================================================================== // class definitions // =========================================================================== -/** - * @class GNEVehicle - */ + class GNEVehicle : public GNEDemandElement, public GNEDemandElementFlow { public: diff --git a/src/netedit/elements/demand/GNEWalk.cpp b/src/netedit/elements/demand/GNEWalk.cpp index c1bc418afe2..2b16327ee69 100644 --- a/src/netedit/elements/demand/GNEWalk.cpp +++ b/src/netedit/elements/demand/GNEWalk.cpp @@ -38,6 +38,7 @@ GNEWalk::GNEWalk(SumoXMLTag tag, GNENet* net) : GNEDemandElement("", net, GLO_WALK, tag, GUIIconSubSys::getIcon(GUIIcon::WALK_FROMTO), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}), + GNEDemandElementPlan(this), myArrivalPosition(0) { // reset default values resetDefaultValues(); @@ -47,6 +48,7 @@ GNEWalk::GNEWalk(SumoXMLTag tag, GNENet* net) : GNEWalk::GNEWalk(GNENet* net, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEEdge* toEdge, double arrivalPosition) : GNEDemandElement(personParent, net, GLO_WALK, GNE_TAG_WALK_EDGE, GUIIconSubSys::getIcon(GUIIcon::WALK_FROMTO), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {personParent}, {}), + GNEDemandElementPlan(this), myArrivalPosition(arrivalPosition) { } @@ -54,6 +56,7 @@ GNEWalk::GNEWalk(GNENet* net, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEWalk::GNEWalk(const bool isTrain, GNENet* net, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEAdditional* toAdditional, double arrivalPosition) : GNEDemandElement(personParent, net, GLO_WALK, isTrain ? GNE_TAG_WALK_TRAINSTOP : GNE_TAG_WALK_BUSSTOP, GUIIconSubSys::getIcon(isTrain ? GUIIcon::WALK_TRAINSTOP : GUIIcon::WALK_BUSSTOP), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge}, {}, {toAdditional}, {personParent}, {}), + GNEDemandElementPlan(this), myArrivalPosition(arrivalPosition) { } @@ -61,6 +64,7 @@ GNEWalk::GNEWalk(const bool isTrain, GNENet* net, GNEDemandElement* personParent GNEWalk::GNEWalk(GNENet* net, GNEDemandElement* personParent, std::vector edges, double arrivalPosition) : GNEDemandElement(personParent, net, GLO_WALK, GNE_TAG_WALK_EDGES, GUIIconSubSys::getIcon(GUIIcon::WALK_EDGES), GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {edges}, {}, {}, {personParent}, {}), + GNEDemandElementPlan(this), myArrivalPosition(arrivalPosition) { } @@ -68,15 +72,15 @@ GNEWalk::GNEWalk(GNENet* net, GNEDemandElement* personParent, std::vector -#include "GNEDemandElement.h" #include +#include "GNEDemandElement.h" +#include "GNEDemandElementPlan.h" // =========================================================================== // class declarations // =========================================================================== + class GNEEdge; class GNEConnection; class GNEVehicle; - // =========================================================================== // class definitions // =========================================================================== -class GNEWalk : public GNEDemandElement, public Parameterised { + +class GNEWalk : public GNEDemandElement, public Parameterised, public GNEDemandElementPlan { + public: /// @brief default constructor GNEWalk(SumoXMLTag tag, GNENet* net);