Path: blob/main/src/netedit/elements/additional/GNEClosingLaneReroute.cpp
193689 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GNEClosingLaneReroute.cpp14/// @author Pablo Alvarez Lopez15/// @date Jan 201716///17//18/****************************************************************************/19#include <config.h>2021#include <netedit/changes/GNEChange_Attribute.h>22#include <netedit/GNENet.h>2324#include "GNEClosingLaneReroute.h"2526// ===========================================================================27// member method definitions28// ===========================================================================2930GNEClosingLaneReroute::GNEClosingLaneReroute(GNENet* net) :31GNEAdditional(net, SUMO_TAG_CLOSING_LANE_REROUTE),32GNEAdditionalListed(this),33myClosedLane(nullptr),34myPermissions(0) {35}363738GNEClosingLaneReroute::GNEClosingLaneReroute(GNEAdditional* rerouterIntervalParent, GNELane* closedLane, SVCPermissions permissions) :39GNEAdditional(rerouterIntervalParent, SUMO_TAG_CLOSING_LANE_REROUTE, ""),40GNEAdditionalListed(this),41myClosedLane(closedLane),42myPermissions(permissions) {43// set parents44setParent<GNEAdditional*>(rerouterIntervalParent);45setParent<GNELane*>(closedLane);46// update boundary of rerouter parent47rerouterIntervalParent->getParentAdditionals().front()->updateCenteringBoundary(true);48}495051GNEClosingLaneReroute::~GNEClosingLaneReroute() {}525354GNEMoveElement*55GNEClosingLaneReroute::getMoveElement() const {56return nullptr;57}585960Parameterised*61GNEClosingLaneReroute::getParameters() {62return nullptr;63}646566const Parameterised*67GNEClosingLaneReroute::getParameters() const {68return nullptr;69}707172void73GNEClosingLaneReroute::writeAdditional(OutputDevice& device) const {74device.openTag(SUMO_TAG_CLOSING_LANE_REROUTE);75// write common additional attributes76writeAdditionalAttributes(device);77// write specific attributes78device.writeAttr(SUMO_ATTR_ID, getAttribute(SUMO_ATTR_LANE));79if (getAttribute(SUMO_ATTR_ALLOW) != getVehicleClassNames(SVCAll)) {80if (!getAttribute(SUMO_ATTR_ALLOW).empty()) {81device.writeAttr(SUMO_ATTR_ALLOW, getAttribute(SUMO_ATTR_ALLOW));82} else {83device.writeAttr(SUMO_ATTR_DISALLOW, getAttribute(SUMO_ATTR_DISALLOW));84}85}86device.closeTag();87}888990bool91GNEClosingLaneReroute::isAdditionalValid() const {92return true;93}949596std::string97GNEClosingLaneReroute::getAdditionalProblem() const {98return "";99}100101102void103GNEClosingLaneReroute::fixAdditionalProblem() {104// nothing to fix105}106107108bool109GNEClosingLaneReroute::checkDrawMoveContour() const {110return false;111}112113114void115GNEClosingLaneReroute::updateGeometry() {116updateGeometryListedAdditional();117}118119120Position121GNEClosingLaneReroute::getPositionInView() const {122return getListedPositionInView();123}124125126void127GNEClosingLaneReroute::updateCenteringBoundary(const bool /*updateGrid*/) {128// nothing to update129}130131132void133GNEClosingLaneReroute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {134// geometry of this element cannot be splitted135}136137138std::string139GNEClosingLaneReroute::getParentName() const {140return getParentAdditionals().at(0)->getID();141}142143144void145GNEClosingLaneReroute::drawGL(const GUIVisualizationSettings& s) const {146// draw closing reroute as listed attribute147drawListedAdditional(s, RGBColor::RED, RGBColor::YELLOW, GUITexture::REROUTER_CLOSINGLANEREROUTE,148getAttribute(SUMO_ATTR_LANE));149}150151152std::string153GNEClosingLaneReroute::getAttribute(SumoXMLAttr key) const {154switch (key) {155case SUMO_ATTR_ID:156return getMicrosimID();157case SUMO_ATTR_LANE:158return myClosedLane->getID();159case SUMO_ATTR_ALLOW:160return getVehicleClassNames(myPermissions);161case SUMO_ATTR_DISALLOW:162return getVehicleClassNames(invertPermissions(myPermissions));163case GNE_ATTR_PARENT:164return getParentAdditionals().at(0)->getID();165case GNE_ATTR_SHIFTLANEINDEX:166return "";167default:168return getCommonAttribute(key);169}170}171172173double174GNEClosingLaneReroute::getAttributeDouble(SumoXMLAttr key) const {175return getCommonAttributeDouble(key);176}177178179Position GNEClosingLaneReroute::getAttributePosition(SumoXMLAttr key) const {180return getCommonAttributePosition(key);181}182183184PositionVector185GNEClosingLaneReroute::getAttributePositionVector(SumoXMLAttr key) const {186return getCommonAttributePositionVector(key);187}188189190void191GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {192switch (key) {193case SUMO_ATTR_ID:194case SUMO_ATTR_LANE:195case SUMO_ATTR_ALLOW:196case SUMO_ATTR_DISALLOW:197case GNE_ATTR_SHIFTLANEINDEX:198GNEChange_Attribute::changeAttribute(this, key, value, undoList);199break;200default:201setCommonAttribute(key, value, undoList);202break;203}204}205206207bool208GNEClosingLaneReroute::isValid(SumoXMLAttr key, const std::string& value) {209switch (key) {210case SUMO_ATTR_ID:211return isValidAdditionalID(value);212case SUMO_ATTR_LANE:213return (myNet->getAttributeCarriers()->retrieveLane(value, false) != nullptr);214case SUMO_ATTR_ALLOW:215case SUMO_ATTR_DISALLOW:216return canParseVehicleClasses(value);217default:218return isCommonAttributeValid(key, value);219}220}221222223std::string224GNEClosingLaneReroute::getPopUpID() const {225return getTagStr();226}227228229std::string230GNEClosingLaneReroute::getHierarchyName() const {231return getTagStr() + ": " + myClosedLane->getID();232}233234// ===========================================================================235// private236// ===========================================================================237238void239GNEClosingLaneReroute::setAttribute(SumoXMLAttr key, const std::string& value) {240switch (key) {241case SUMO_ATTR_ID:242// update microsimID243setAdditionalID(value);244break;245case SUMO_ATTR_LANE:246myClosedLane = myNet->getAttributeCarriers()->retrieveLane(value);247break;248case SUMO_ATTR_ALLOW:249myPermissions = parseVehicleClasses(value);250break;251case SUMO_ATTR_DISALLOW:252myPermissions = invertPermissions(parseVehicleClasses(value));253break;254case GNE_ATTR_SHIFTLANEINDEX:255shiftLaneIndex();256break;257default:258setCommonAttribute(key, value);259break;260}261}262263/****************************************************************************/264265266