/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2016-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 GNERoute.h14/// @author Pablo Alvarez Lopez15/// @date Jan 201916///17// A class for visualizing routes in Netedit18/****************************************************************************/19#pragma once20#include <config.h>21#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>2223#include "GNEDemandElement.h"2425// ===========================================================================26// class declarations27// ===========================================================================2829class GNEEdge;30class GNEVehicle;3132// ===========================================================================33// class definitions34// ===========================================================================3536class GNERoute : public GNEDemandElement, public Parameterised {3738public:3940/// @brief class used in GUIGLObjectPopupMenu for routes41class GNERoutePopupMenu : public GUIGLObjectPopupMenu {42FXDECLARE(GNERoutePopupMenu)4344public:45/** @brief Constructor46* @param[in] app The main window for instantiation of other windows47* @param[in] parent The parent view for changing it48* @param[in] o The object of interest49* @param[in, out] additionalVisualizations Information which additional visualisations are enabled (per view)50*/51GNERoutePopupMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, GUIGlObject* o);5253/// @brief Destructor54~GNERoutePopupMenu();5556/// @brief Called to modify edge distance values along the route57long onCmdApplyDistance(FXObject*, FXSelector, void*);5859protected:60/// @brief default constructor needed by FOX61GNERoutePopupMenu() {}62};6364/// @brief default constructor65GNERoute(SumoXMLTag tag, GNENet* net);6667/// @brief calibrator constructor (used in calibrators)68GNERoute(GNEAdditional* calibrator);6970/// @brief copy constructor (used in copy vehicles)71GNERoute(const std::string& id, const GNEDemandElement* originalRoute);7273/// @brief copy constructor (used in copy embedded vehicles)74GNERoute(GNEVehicle* vehicleParent, const GNEDemandElement* originalRoute);7576/**@brief parameter constructor for routes77* @param[in] id route ID78* @param[in] net net in which this Route is placed79* @param[in] fileBucket file in which this element is stored80* @param[in] vClass vehicle class81* @param[in] edges route edges82* @param[in] color route color83* @param[in] repeat the number of times that the edges of this route shall be repeated84* @param[in] cycleType the times will be shifted forward by 'cycleTime' on each repeat85* @param[in] probability default probability for vType distributions86* @param[in] parameters generic parameters87*/88GNERoute(const std::string& id, GNENet* net, FileBucket* fileBucket, SUMOVehicleClass vClass, const std::vector<GNEEdge*>& edges,89const RGBColor& color, const int repeat, const SUMOTime cycleTime, const double probability, const Parameterised::Map& parameters);9091/**@brief parameter constructor for embedded routes92* @param[in] vehicleParent vehicle parent of this embedded route93* @param[in] edges route edges94* @param[in] color route color95* @param[in] repeat the number of times that the edges of this route shall be repeated96* @param[in] cycleType the times will be shifted forward by 'cycleTime' on each repeat97* @param[in] parameters generic parameters98*/99GNERoute(GNEDemandElement* vehicleParent, const std::vector<GNEEdge*>& edges, const RGBColor& color,100const int repeat, const SUMOTime cycleTime, const Parameterised::Map& parameters);101102/// @brief destructor103~GNERoute();104105/// @brief methods to retrieve the elements linked to this route106/// @{107108/// @brief get GNEMoveElement associated with this route109GNEMoveElement* getMoveElement() const override;110111/// @brief get parameters associated with this route112Parameterised* getParameters() override;113114/// @brief get parameters associated with this route (constant)115const Parameterised* getParameters() const override;116117/// @}118119/**@brief write demand element element into a xml file120* @param[in] device device in which write parameters of demand element element121*/122void writeDemandElement(OutputDevice& device) const override;123124/// @brief check if current demand element is valid to be written into XML (by default true, can be reimplemented in children)125Problem isDemandElementValid() const override;126127/// @brief return a string with the current demand element problem (by default empty, can be reimplemented in children)128std::string getDemandElementProblem() const override;129130/// @brief fix demand element problem (by default throw an exception, has to be reimplemented in children)131void fixDemandElementProblem() override;132133/// @name members and functions relative to elements common to all demand elements134/// @{135/// @brief obtain VClass related with this demand element136SUMOVehicleClass getVClass() const override;137138/// @brief get color139const RGBColor& getColor() const override;140141/// @}142143/// @name Functions related with geometry of element144/// @{145/// @brief update pre-computed geometry information146void updateGeometry() override;147148/// @brief Returns position of additional in view149Position getPositionInView() const override;150/// @}151152/// @name inherited from GUIGlObject153/// @{154155/**@brief Returns an own popup-menu156*157* @param[in] app The application needed to build the popup-menu158* @param[in] parent The parent window needed to build the popup-menu159* @return The built popup-menu160* @see GUIGlObject::getPopUpMenu161*/162GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;163164/**@brief Returns the name of the parent object165* @return This object's parent id166*/167std::string getParentName() const override;168169/// @brief return exaggeration associated with this GLObject170double getExaggeration(const GUIVisualizationSettings& s) const override;171172/**@brief Returns the boundary to which the view shall be centered in order to show the object173* @return The boundary the object is within174*/175Boundary getCenteringBoundary() const override;176177/// @brief split geometry178void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) override;179180/**@brief Draws the object181* @param[in] s The settings for the current view (may influence drawing)182* @see GUIGlObject::drawGL183*/184void drawGL(const GUIVisualizationSettings& s) const override;185186/// @}187188/// @name inherited from GNEPathElement189/// @{190191/// @brief compute pathElement192void computePathElement() override;193194/**@brief Draws partial object over lane195* @param[in] s The settings for the current view (may influence drawing)196* @param[in] segment lane segment197* @param[in] offsetFront front offset198*/199void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;200201/**@brief Draws partial object over junction202* @param[in] s The settings for the current view (may influence drawing)203* @param[in] segment junction segment204* @param[in] offsetFront front offset205*/206void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;207208/// @brief get first path lane209GNELane* getFirstPathLane() const override;210211/// @brief get last path lane212GNELane* getLastPathLane() const override;213/// @}214215/// @brief inherited from GNEAttributeCarrier216/// @{217/* @brief method for getting the Attribute of an XML key218* @param[in] key The attribute key219* @return string with the value associated to key220*/221std::string getAttribute(SumoXMLAttr key) const override;222223/* @brief method for getting the Attribute of an XML key in double format224* @param[in] key The attribute key225* @return double with the value associated to key226*/227double getAttributeDouble(SumoXMLAttr key) const override;228229/* @brief method for getting the Attribute of an XML key in position format230* @param[in] key The attribute key231* @return position with the value associated to key232*/233Position getAttributePosition(SumoXMLAttr key) const override;234235/* @brief method for setting the attribute and letting the object perform additional changes236* @param[in] key The attribute key237* @param[in] value The new value238* @param[in] undoList The undoList on which to register changes239* @param[in] net optionally the GNENet to inform about gui updates240*/241void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;242243/* @brief method for setting the attribute and letting the object perform additional changes244* @param[in] key The attribute key245* @param[in] value The new value246* @param[in] undoList The undoList on which to register changes247*/248bool isValid(SumoXMLAttr key, const std::string& value) override;249250/// @brief get PopPup ID (Used in AC Hierarchy)251std::string getPopUpID() const override;252253/// @brief get Hierarchy Name (Used in AC Hierarchy)254std::string getHierarchyName() const override;255256/// @}257258/** @brief check if a route is valid259* @param[in] edges vector with the route's edges260* @return an empty string if route is valid, or a string with the problem261*/262static std::string isRouteValid(const std::vector<GNEEdge*>& edges);263264/// @brief create a copy of the given route265static GNEDemandElement* copyRoute(const GNERoute* originalRoute);266267protected:268/// @brief route color269RGBColor myColor = RGBColor::INVISIBLE;270271/// @brief repeat272int myRepeat = 0;273274/// @brief cycleTime275SUMOTime myCycleTime = 0;276277/// @brief probability278double myProbability = DEFAULT_VEH_PROB;279280/// @brief SUMOVehicleClass (Only used for drawing)281SUMOVehicleClass myVClass = SVC_PASSENGER;282283private:284/// @brief draw route partial lane285void drawRoutePartialLane(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,286const GNESegment* segment, const double offsetFront,287const GUIGeometry& geometry, const double exaggeration) const;288289/// @brief draw route partial junction290void drawRoutePartialJunction(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,291const double offsetFront, const GUIGeometry& geometry, const double exaggeration) const;292293/// @brief method for setting the attribute and nothing else294void setAttribute(SumoXMLAttr key, const std::string& value) override;295296/// @brief check if we're creating a vehicle or flow over route297bool checkCreatingVehicleOverRoute() const;298299/// @brief Invalidated copy constructor.300GNERoute(GNERoute*) = delete;301302/// @brief Invalidated assignment operator.303GNERoute& operator=(GNERoute*) = delete;304};305306307