Path: blob/main/src/netedit/elements/additional/GNERerouter.h
169684 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 GNERerouter.h14/// @author Pablo Alvarez Lopez15/// @date Nov 201516///17//18/****************************************************************************/19#pragma once20#include <config.h>2122#include "GNEAdditional.h"2324// ===========================================================================25// class declarations26// ===========================================================================2728class GNEEdge;2930// ===========================================================================31// class definitions32// ===========================================================================3334class GNERerouter : public GNEAdditional, public Parameterised {3536public:37/// @brief default Constructor38GNERerouter(GNENet* net);3940/**@brief Constructor41* @param[in] id The storage of gl-ids to get the one for this lane representation from42* @param[in] net pointer to GNENet of this additional element belongs43* @param[in] filename file in which this element is stored44* @param[in] pos position (center) of the rerouter in the map45* @param[in] name Rerouter name46* @param[in] probability The probability for vehicle rerouting47* @param[in] off Whether the router should be inactive initially48* @param[in] parameters generic parameters49*/50GNERerouter(const std::string& id, GNENet* net, const std::string& filename, const Position& pos, const std::string& name,51double probability, bool off, bool optional, SUMOTime timeThreshold, const std::vector<std::string>& vTypes,52const Parameterised::Map& parameters);5354/// @brief Destructor55~GNERerouter();5657/**@brief get move operation58* @note returned GNEMoveOperation can be nullptr59*/60GNEMoveOperation* getMoveOperation();6162/// @brief open GNERerouterDialog63void openAdditionalDialog();6465/// @name members and functions relative to write additionals into XML66/// @{6768/**@brief write additional element into a xml file69* @param[in] device device in which write parameters of additional element70*/71void writeAdditional(OutputDevice& device) const;7273/// @brief check if current additional is valid to be written into XML (must be reimplemented in all detector children)74bool isAdditionalValid() const;7576/// @brief return a string with the current additional problem (must be reimplemented in all detector children)77std::string getAdditionalProblem() const;7879/// @brief fix additional problem (must be reimplemented in all detector children)80void fixAdditionalProblem();8182/// @}8384/// @name Function related with contour drawing85/// @{8687/// @brief check if draw move contour (red)88bool checkDrawMoveContour() const;8990/// @}9192/// @name Functions related with geometry of element93/// @{9495/// @brief update pre-computed geometry information96void updateGeometry();9798/// @brief Returns position of additional in view99Position getPositionInView() const;100101/// @brief update centering boundary (implies change in RTREE)102void updateCenteringBoundary(const bool updateGrid);103104/// @brief split geometry105void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);106107/// @}108109/// @name inherited from GUIGlObject110/// @{111112/// @brief Returns the name of the parent object113/// @return This object's parent id114std::string getParentName() const;115116/**@brief Draws the object117* @param[in] s The settings for the current view (may influence drawing)118* @see GUIGlObject::drawGL119*/120void drawGL(const GUIVisualizationSettings& s) const;121122/// @}123124/// @name inherited from GNEAttributeCarrier125/// @{126127/* @brief method for getting the Attribute of an XML key128* @param[in] key The attribute key129* @return string with the value associated to key130*/131std::string getAttribute(SumoXMLAttr key) const;132133/* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)134* @param[in] key The attribute key135* @return double with the value associated to key136*/137double getAttributeDouble(SumoXMLAttr key) const;138139/// @brief get parameters map140const Parameterised::Map& getACParametersMap() const;141142/* @brief method for setting the attribute and letting the object perform additional changes143* @param[in] key The attribute key144* @param[in] value The new value145* @param[in] undoList The undoList on which to register changes146*/147void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);148149/* @brief method for checking if the key and their correspond attribute are valids150* @param[in] key The attribute key151* @param[in] value The value associated to key key152* @return true if the value is valid, false in other case153*/154bool isValid(SumoXMLAttr key, const std::string& value);155156/// @brief get PopPup ID (Used in AC Hierarchy)157std::string getPopUpID() const;158159/// @brief get Hierarchy Name (Used in AC Hierarchy)160std::string getHierarchyName() const;161162/// @}163164protected:165/// @brief position of rerouter in view166Position myPosition;167168/// @brief probability of rerouter169double myProbability;170171/// @brief attribute to enable or disable inactive initially172bool myOff;173174/// @brief attribute to enable or disable request trigger175bool myOptional;176177/// @brief attribute to configure activation time threshold178SUMOTime myTimeThreshold;179180/// @brief optional vehicle types for restricting the rerouter181std::vector<std::string> myVTypes;182183private:184/// @brief set attribute after validation185void setAttribute(SumoXMLAttr key, const std::string& value);186187/// @brief set move shape188void setMoveShape(const GNEMoveResult& moveResult);189190/// @brief commit move shape191void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);192193/// @brief rebuild Rerouter Symbols194void rebuildRerouterSymbols(const std::string& value, GNEUndoList* undoList);195196/// @brief Invalidated copy constructor.197GNERerouter(const GNERerouter&) = delete;198199/// @brief Invalidated assignment operator.200GNERerouter& operator=(const GNERerouter&) = delete;201};202203204