/****************************************************************************/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 GUIEdge.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Sascha Krieg17/// @author Michael Behrisch18/// @date Sept 200219///20// A road/street connecting two junctions (gui-version)21/****************************************************************************/22#pragma once23#include <config.h>2425#include <vector>26#include <string>27#include <utils/foxtools/fxheader.h>28#include <microsim/MSEdge.h>29#include <utils/gui/globjects/GUIGlObject.h>30#include <utils/gui/settings/GUIPropertySchemeStorage.h>313233// ===========================================================================34// class declarations35// ===========================================================================36class MESegment;37class MSBaseVehicle;38class GUILane;394041// ===========================================================================42// class definitions43// ===========================================================================44/**45* @class GUIEdge46* @brief A road/street connecting two junctions (gui-version)47*48* @see MSEdge49*/50class GUIEdge : public MSEdge, public GUIGlObject {51public:52/** @brief Constructor.53* @param[in] id The id of the edge54* @param[in] numericalID The numerical id (index) of the edge55* @see MSEdge56*/57GUIEdge(const std::string& id, int numericalID,58const SumoXMLEdgeFunc function,59const std::string& streetName, const std::string& edgeType, int priority,60double distance);616263/// @brief Destructor.64~GUIEdge();6566/// Has to be called after all edges were built and all connections were set67virtual void closeBuilding() override;6869/* @brief Returns the gl-ids of all known edges70* @param[in] includeInternal Whether to include ids of internal edges71*/72static std::vector<GUIGlID> getIDs(bool includeInternal);7374/* @brief Returns the combined length of all edges75* @param[in] includeInternal Whether to include lengths of internal edges76* @param[in] eachLane Whether to count each lane separately77*/78static double getTotalLength(bool includeInternal, bool eachLane);7980/// Returns the street's geometry81Boundary getBoundary() const;8283/// returns the enumerated lane (!!! why not private with a friend?)84MSLane& getLane(int laneNo);8586/** returns the position on the line given by the coordinates where "prev"87is the length of the line and "wanted" the distance from the begin88!!! should be within another class */89static std::pair<double, double> getLaneOffsets(double x1, double y1,90double x2, double y2, double prev, double wanted);919293/// @name inherited from GUIGlObject94//@{9596/** @brief Returns an own popup-menu97*98* @param[in] app The application needed to build the popup-menu99* @param[in] parent The parent window needed to build the popup-menu100* @return The built popup-menu101* @see GUIGlObject::getPopUpMenu102*/103virtual GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;104105106/** @brief Returns an own parameter window107*108* @param[in] app The application needed to build the parameter window109* @param[in] parent The parent window needed to build the parameter window110* @return The built parameter window111* @see GUIGlObject::getParameterWindow112*/113virtual GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;114115/** @brief Returns an own type parameter window116*117* @param[in] app The application needed to build the parameter window118* @param[in] parent The parent window needed to build the parameter window119* @return The built parameter window120*/121GUIParameterTableWindow* getTypeParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;122123/** @brief Returns the boundary to which the view shall be centered in order to show the object124*125* @return The boundary the object is within126* @see GUIGlObject::getCenteringBoundary127*/128Boundary getCenteringBoundary() const override;129130/// @brief Returns the street name131const std::string getOptionalName() const override;132133/** @brief Draws the object134* @param[in] s The settings for the current view (may influence drawing)135* @see GUIGlObject::drawGL136*/137void drawGL(const GUIVisualizationSettings& s) const override;138//@}139140double getClickPriority() const override;141142void addTransportable(MSTransportable* t) const override {143FXMutexLock locker(myLock);144MSEdge::addTransportable(t);145}146147void removeTransportable(MSTransportable* t) const override {148FXMutexLock locker(myLock);149MSEdge::removeTransportable(t);150}151152/// @name Access to persons153/// @{154155/** @brief Returns this edge's persons set; locks it for microsimulation156* @brief Avoids the creation of new vector as in getSortedPersons157*158* @return159* Please note that it is necessary to release the person container160* afterwards using "releasePersons".161* @return This edge's persons.162*/163const std::set<MSTransportable*, ComparatorNumericalIdLess>& getPersonsSecure() const {164myLock.lock();165return myPersons;166}167168/** @brief Allows to use the container for microsimulation again169*170* Unlocks "myLock" preventing usage by microsimulation.171*/172void releasePersons() const {173myLock.unlock();174}175/// @}176177double getAllowedSpeed() const;178/// @brief return meanSpead divided by allowedSpeed179double getRelativeSpeed() const;180181/// @brief sets the color according to the currente settings182void setColor(const GUIVisualizationSettings& s) const;183184/// @brief sets the color according to the current scheme index and some edge function185bool setFunctionalColor(const GUIColorer& c) const;186187/// @brief sets multiple colors according to the current scheme index and edge function188bool setMultiColor(const GUIColorer& c) const;189190/// @brief gets the color value according to the current scheme index191double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;192193/// @brief gets the scaling value according to the current scheme index194double getScaleValue(const GUIVisualizationSettings& s, int activeScheme) const;195196/// @brief returns the segment closest to the given position197MESegment* getSegmentAtPosition(const Position& pos);198199void drawMesoVehicles(const GUIVisualizationSettings& s) const;200201/// @brief grant exclusive access to the mesoscopic state202void lock() const override {203myLock.lock();204}205206/// @brief release exclusive access to the mesoscopic state207void unlock() const override {208myLock.unlock();209}210211/// @brief close this edge for traffic212void closeTraffic(const GUILane* lane);213214/// @brief add a rerouter215void addRerouter();216217/// @brief return segment colors (meso)218const std::vector<RGBColor>& getSegmentColors() const {219return mySegmentColors;220}221222RGBColor getMesoColor() const {223return myMesoColor;224}225226bool showDeadEnd() const {227return myShowDeadEnd;228}229230/// @brief whether this lane is selected in the GUI231bool isSelected() const override;232233/// The color of the segments (cached)234mutable std::vector<RGBColor> mySegmentColors;235236/// @brief whether to highlight this edge as a dead-end edge237bool myShowDeadEnd;238239/// @brief get number of vehicles waiting for departure on this edge240double getPendingEmits() const;241242private:243/// @brief invalidated copy constructor244GUIEdge(const GUIEdge& s);245246/// @brief invalidated assignment operator247GUIEdge& operator=(const GUIEdge& s);248249250private:251/// The mutex used to avoid concurrent updates of myPersons/ myContainers252mutable FXMutex myLock;253254mutable RGBColor myMesoColor;255256};257258259