Path: blob/main/src/netedit/elements/moving/GNEMoveElement.h
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 GNEMoveElement.h14/// @author Pablo Alvarez Lopez15/// @date Mar 202016///17// Class used for elements that can be moved18/****************************************************************************/19#pragma once20#include <config.h>2122#include <utils/xml/SUMOXMLDefinitions.h>2324#include "GNEMoveOffset.h"25#include "GNEMoveResult.h"2627// ===========================================================================28// class declaration29// ===========================================================================3031class GNEAttributeCarrier;32class GNEUndoList;33class GNEViewNet;34class GUIGlObject;35class Parameterised;3637// ===========================================================================38// class definitions39// ===========================================================================4041class GNEMoveElement {4243public:44/// @brief constructor45GNEMoveElement(GNEAttributeCarrier* movedElement);4647//// @brief empty destructor48virtual ~GNEMoveElement();4950/**@brief get move operation51* @note returned GNEMoveOperation can be nullptr52*/53virtual GNEMoveOperation* getMoveOperation() = 0;5455/// @name functions related with moving attributes56/// @{5758/// @brief get moving attribute59virtual std::string getMovingAttribute(SumoXMLAttr key) const = 0;6061/// @brief get moving attribute double62virtual double getMovingAttributeDouble(SumoXMLAttr key) const = 0;6364/// @brief get moving attribute position65virtual Position getMovingAttributePosition(SumoXMLAttr key) const = 0;6667/// @brief get moving attribute positionVector68virtual PositionVector getMovingAttributePositionVector(SumoXMLAttr key) const = 0;6970/// @brief set moving attribute (using undo-list)71virtual void setMovingAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;7273/// @brief check if the given moving attribute is valid74virtual bool isMovingAttributeValid(SumoXMLAttr key, const std::string& value) const = 0;7576/// @brief set moving attribute77virtual void setMovingAttribute(SumoXMLAttr key, const std::string& value) = 0;7879/// @}8081/// @brief remove geometry point in the clicked position82virtual void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) = 0;8384/// @brief move element the for given offset (note: offset can be X-Y-0, 0-0-Z or X-Y-Z)85static void moveElement(const GNEViewNet* viewNet, GNEMoveOperation* moveOperation, const GNEMoveOffset& offset);8687/// @brief commit move element for the given offset88static void commitMove(const GNEViewNet* viewNet, GNEMoveOperation* moveOperation, const GNEMoveOffset& offset, GNEUndoList* undoList);8990/// @brief move element lateral offset91double myMovingLateralOffset = 0;9293protected:94/// @brief pointer to element95GNEAttributeCarrier* myMovedElement = nullptr;9697/// @brief calculate move shape operation98GNEMoveOperation* getEditShapeOperation(const GUIGlObject* obj, const PositionVector originalShape, const bool maintainShapeClosed);99100private:101/// @brief set move shape102virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;103104/// @brief commit move shape105virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;106107/// @brief calculate lane offset (used in calculateLanePosition)108static double calculateLaneOffset(const GNEViewNet* viewNet, const GNELane* lane, const double firstPosition,109const double lastPosition, const GNEMoveOffset& offset);110111/// @brief calculate lane position over one lane with only one position (accesss, E1, star/end positions, etc.)112static void calculateLanePosition(double& starPos, const GNEViewNet* viewNet, const GNELane* lane,113const double posOverLane, const GNEMoveOffset& offset);114115/// @brief calculate lane position over one lane with two positions (stoppingPlaces, E2 single lanes)116static void calculateLanePositions(double& starPos, double& endPos, const GNEViewNet* viewNet, const GNELane* lane,117const double firstPosOverLane, const double lastPosOverLane, const GNEMoveOffset& offset);118119/// @brief calculate lane position over two lane with two positions (E2 Multilanes)120static void calculateLanePositions(double& starPos, double& endPos, const GNEViewNet* viewNet, const GNELane* firstLane,121const double firstPosOverLane, const GNELane* lastLane, const double lastPosOverLane,122const bool firstLaneClicked, const GNEMoveOffset& offset);123124/// @brief calculate new lane change125static void calculateNewLaneChange(const GNEViewNet* viewNet, const GNELane* originalLane, const GNELane*& newLane, double& laneOffset);126127/// @brief calculate width/height shape128static PositionVector calculateExtrapolatedVector(const GNEMoveOperation* moveOperation, const GNEMoveResult& moveResult);129130/// @brief invalidate default constructor131GNEMoveElement() = delete;132133/// @brief Invalidated copy constructor.134GNEMoveElement(const GNEMoveElement&) = delete;135136/// @brief Invalidated assignment operator.137GNEMoveElement& operator=(const GNEMoveElement&) = delete;138};139140141