Path: blob/main/src/netedit/elements/network/GNENetworkElement.h
185850 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 GNENetworkElement.h14/// @author Pablo Alvarez Lopez15/// @date Jun 201616///17// A abstract class for network elements18/****************************************************************************/19#pragma once20#include <config.h>2122#include <netedit/elements/GNEAttributeCarrier.h>23#include <netedit/elements/GNEContour.h>24#include <netedit/elements/GNEHierarchicalElement.h>25#include <utils/gui/globjects/GUIGlObject.h>2627// ===========================================================================28// class declaration29// ===========================================================================3031class GNEMoveOperation;3233// ===========================================================================34// class definitions35// ===========================================================================3637class GNENetworkElement : public GNEAttributeCarrier, public GUIGlObject, public GNEHierarchicalElement {3839public:40/**@brief Constructor for templates41* @param[in] tag SUMO Tag assigned to this type of object42* @param[in] net GNENet in which this AttributeCarrier is stored43*/44GNENetworkElement(GNENet* net, SumoXMLTag tag);4546/**@brief Constructor.47* @param[in] net The net to inform about gui updates48* @param[in] id of the element49* @param[in] tag sumo xml tag of the element50*/51GNENetworkElement(GNENet* net, const std::string& id, SumoXMLTag tag);5253/// @brief Destructor54virtual ~GNENetworkElement();5556/// @brief methods to retrieve the elements linked to this network element57/// @{5859/// @brief get GNEHierarchicalElement associated with this AttributeCarrier60GNEHierarchicalElement* getHierarchicalElement() override;6162/// @brief get GUIGlObject associated with this AttributeCarrier63GUIGlObject* getGUIGlObject() override;6465/// @brief get GUIGlObject associated with this AttributeCarrier (constant)66const GUIGlObject* getGUIGlObject() const override;6768/// @}6970/// @brief get reference to fileBucket in which save this AC71FileBucket* getFileBucket() const override;7273/// @brief check if current network element is valid to be written into XML (by default true, can be reimplemented in children)74virtual bool isNetworkElementValid() const;7576/// @brief return a string with the current network element problem (by default empty, can be reimplemented in children)77virtual std::string getNetworkElementProblem() const;7879/// @name inherited from GUIGlObject80/// @{8182/**@brief Returns an own parameter window83*84* @param[in] app The application needed to build the parameter window85* @param[in] parent The parent window needed to build the parameter window86* @return The built parameter window87* @see GUIGlObject::getParameterWindow88*/89GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;9091/// @brief check if element is locked92bool isGLObjectLocked() const override;9394/// @brief mark element as front element95void markAsFrontElement() override;9697/// @brief select element98void selectGLObject() override;99100/// @brief Returns the name of the object (default "")101virtual const std::string getOptionalName() const override;102103/// @}104105/// @name inherited from GNEAttributeCarrier106/// @{107108/// @brief get PopPup ID (Used in AC Hierarchy)109std::string getPopUpID() const override;110111/// @brief get Hierarchy Name (Used in AC Hierarchy)112std::string getHierarchyName() const override;113114/// @}115116/// @name functions related with shape editing117/// @{118119/// @brief set shape edited120void setShapeEdited(const bool value);121122/// @brief check if shape is being edited123bool isShapeEdited() const;124125/// @brief get index geometry point under cursor of shape edited126int getGeometryPointUnderCursorShapeEdited() const;127128/// @brief simplify shape edited129void simplifyShapeEdited(GNEUndoList* undoList);130131/// @brief straighten shape edited132void straigthenShapeEdited(GNEUndoList* undoList);133134/// @brief close shape edited135void closeShapeEdited(GNEUndoList* undoList);136137/// @brief open shape edited138void openShapeEdited(GNEUndoList* undoList);139140/// @brief set first geometry point shape edited141void setFirstGeometryPointShapeEdited(const int index, GNEUndoList* undoList);142143/// @brief delete geometry point shape edited144void deleteGeometryPointShapeEdited(const int index, GNEUndoList* undoList);145146/// @brief reset shape edited147void resetShapeEdited(GNEUndoList* undoList);148149/// @}150151/// @brief set network element id152void setNetworkElementID(const std::string& newID);153154protected:155/// @brief flag to check if element shape is being edited156bool myShapeEdited;157158/// @brief network element contour159GNEContour myNetworkElementContour;160161// @brief check if we're drawing using a boundary but element was already selected162bool checkDrawingBoundarySelection() const;163164/// @brief get shape edited popup menu165GUIGLObjectPopupMenu* getShapeEditedPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, const PositionVector& shape);166167/**@brief return index of a vertex of shape, or of a new vertex if position is over an shape's edge168* @param pos position of new/existent vertex169* @return index of position vector170*/171int getVertexIndex(const PositionVector& shape, const Position& pos);172173private:174/// @brief Invalidated copy constructor.175GNENetworkElement(const GNENetworkElement&) = delete;176177/// @brief Invalidated assignment operator.178GNENetworkElement& operator=(const GNENetworkElement&) = delete;179};180181182