Path: blob/main/src/netedit/elements/moving/GNEMoveElementPlanParent.cpp
185790 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 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 GNEMoveElementPlanParent.cpp14/// @author Pablo Alvarez Lopez15/// @date Oct 202516///17// Class used for elements that can be moved over a edge with two positions18/****************************************************************************/19#include <config.h>2021#include <foreign/fontstash/fontstash.h>22#include <netedit/changes/GNEChange_Attribute.h>23#include <netedit/changes/GNEChange_Connection.h>24#include <netedit/elements/demand/GNEDemandElement.h>25#include <netedit/elements/GNEAttributeCarrier.h>26#include <netedit/elements/moving/GNEMoveElement.h>27#include <netedit/elements/network/GNEConnection.h>28#include <netedit/frames/common/GNEMoveFrame.h>29#include <netedit/GNENet.h>30#include <netedit/GNETagProperties.h>31#include <netedit/GNEUndoList.h>32#include <netedit/GNEViewNet.h>33#include <netedit/GNEViewParent.h>34#include <utils/gui/div/GLHelper.h>35#include <utils/gui/div/GUIGlobalViewObjectsHandler.h>36#include <utils/gui/globjects/GLIncludes.h>37#include <utils/gui/globjects/GUIGlObject.h>38#include <utils/options/OptionsCont.h>39#include <utils/xml/NamespaceIDs.h>4041#include "GNEMoveElementPlanParent.h"4243// ===========================================================================44// member method definitions45// ===========================================================================4647GNEMoveElementPlanParent::GNEMoveElementPlanParent(GNEDemandElement* planParent,48double& departPos, DepartPosDefinition& departPosProcedure) :49GNEMoveElement(planParent),50myPlanParent(planParent),51myDepartPos(departPos),52myDepartPosProcedure(departPosProcedure) {53}545556GNEMoveElementPlanParent::~GNEMoveElementPlanParent() {}575859GNEMoveOperation*60GNEMoveElementPlanParent::getMoveOperation() {61const auto firstContainerPlan = myPlanParent->getChildDemandElements().front();62// check first person plan63if (firstContainerPlan->getTagProperty()->isPlanStopPerson()) {64return nullptr;65} else if (firstContainerPlan->getParentEdges().size() > 0) {66// get lane67const GNELane* lane = firstContainerPlan->getParentEdges().front()->getLaneByAllowedVClass(myPlanParent->getVClass());68// declare departPos69double posOverLane = 0;70if (GNEAttributeCarrier::canParse<double>(myPlanParent->getAttribute(SUMO_ATTR_DEPARTPOS))) {71posOverLane = GNEAttributeCarrier::parse<double>(myPlanParent->getAttribute(SUMO_ATTR_DEPARTPOS));72}73// return move operation74return new GNEMoveOperation(this, lane, posOverLane, false);75} else {76return nullptr;77}78}798081std::string82GNEMoveElementPlanParent::getMovingAttribute(SumoXMLAttr key) const {83return myMovedElement->getCommonAttribute(key);84}858687double88GNEMoveElementPlanParent::getMovingAttributeDouble(SumoXMLAttr key) const {89return myMovedElement->getCommonAttributeDouble(key);90}919293Position94GNEMoveElementPlanParent::getMovingAttributePosition(SumoXMLAttr key) const {95return myMovedElement->getCommonAttributePosition(key);96}979899PositionVector100GNEMoveElementPlanParent::getMovingAttributePositionVector(SumoXMLAttr key) const {101return myMovedElement->getCommonAttributePositionVector(key);102}103104105void106GNEMoveElementPlanParent::setMovingAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {107myMovedElement->setCommonAttribute(key, value, undoList);108}109110111bool112GNEMoveElementPlanParent::isMovingAttributeValid(SumoXMLAttr key, const std::string& value) const {113return myMovedElement->isCommonAttributeValid(key, value);114}115116117void118GNEMoveElementPlanParent::setMovingAttribute(SumoXMLAttr key, const std::string& value) {119myMovedElement->setCommonAttribute(key, value);120}121122123void124GNEMoveElementPlanParent::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {125// nothing to do here126}127128129void130GNEMoveElementPlanParent::setMoveShape(const GNEMoveResult& moveResult) {131// change departPos132myDepartPosProcedure = DepartPosDefinition::GIVEN;133myDepartPos = moveResult.newFirstPos;134// update geometry135myPlanParent->updateGeometry();136}137138139void140GNEMoveElementPlanParent::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) {141undoList->begin(myPlanParent, TLF("departPos of %", myPlanParent->getTagStr()));142// now set departPos143myPlanParent->setAttribute(SUMO_ATTR_DEPARTPOS, toString(moveResult.newFirstPos), undoList);144undoList->end();145}146147/****************************************************************************/148149150