/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 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,60const std::string& routingType, int priority,61double distance);626364/// @brief Destructor.65~GUIEdge();6667/// Has to be called after all edges were built and all connections were set68virtual void closeBuilding() override;6970/* @brief Returns the gl-ids of all known edges71* @param[in] includeInternal Whether to include ids of internal edges72*/73static std::vector<GUIGlID> getIDs(bool includeInternal);7475/* @brief Returns the combined length of all edges76* @param[in] includeInternal Whether to include lengths of internal edges77* @param[in] eachLane Whether to count each lane separately78*/79static double getTotalLength(bool includeInternal, bool eachLane);8081/// Returns the street's geometry82Boundary getBoundary() const;8384/// returns the enumerated lane (!!! why not private with a friend?)85MSLane& getLane(int laneNo);8687/** returns the position on the line given by the coordinates where "prev"88is the length of the line and "wanted" the distance from the begin89!!! should be within another class */90static std::pair<double, double> getLaneOffsets(double x1, double y1,91double x2, double y2, double prev, double wanted);929394/// @name inherited from GUIGlObject95//@{9697/** @brief Returns an own popup-menu98*99* @param[in] app The application needed to build the popup-menu100* @param[in] parent The parent window needed to build the popup-menu101* @return The built popup-menu102* @see GUIGlObject::getPopUpMenu103*/104virtual GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;105106107/** @brief Returns an own parameter window108*109* @param[in] app The application needed to build the parameter window110* @param[in] parent The parent window needed to build the parameter window111* @return The built parameter window112* @see GUIGlObject::getParameterWindow113*/114virtual GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;115116/** @brief Returns an own type parameter window117*118* @param[in] app The application needed to build the parameter window119* @param[in] parent The parent window needed to build the parameter window120* @return The built parameter window121*/122GUIParameterTableWindow* getTypeParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;123124/** @brief Returns the boundary to which the view shall be centered in order to show the object125*126* @return The boundary the object is within127* @see GUIGlObject::getCenteringBoundary128*/129Boundary getCenteringBoundary() const override;130131/// @brief Returns the street name132const std::string getOptionalName() const override;133134/** @brief Draws the object135* @param[in] s The settings for the current view (may influence drawing)136* @see GUIGlObject::drawGL137*/138void drawGL(const GUIVisualizationSettings& s) const override;139//@}140141double getClickPriority() const override;142143void addTransportable(MSTransportable* t) const override {144FXMutexLock locker(myLock);145MSEdge::addTransportable(t);146}147148void removeTransportable(MSTransportable* t) const override {149FXMutexLock locker(myLock);150MSEdge::removeTransportable(t);151}152153/// @name Access to persons154/// @{155156/** @brief Returns this edge's persons set; locks it for microsimulation157* @brief Avoids the creation of new vector as in getSortedPersons158*159* @return160* Please note that it is necessary to release the person container161* afterwards using "releasePersons".162* @return This edge's persons.163*/164const std::set<MSTransportable*, ComparatorNumericalIdLess>& getPersonsSecure() const {165myLock.lock();166return myPersons;167}168169/** @brief Allows to use the container for microsimulation again170*171* Unlocks "myLock" preventing usage by microsimulation.172*/173void releasePersons() const {174myLock.unlock();175}176/// @}177178double getAllowedSpeed() const;179/// @brief return meanSpead divided by allowedSpeed180double getRelativeSpeed() const;181182/// @brief sets the color according to the currente settings183void setColor(const GUIVisualizationSettings& s) const;184185/// @brief sets the color according to the current scheme index and some edge function186bool setFunctionalColor(const GUIColorer& c) const;187188/// @brief sets multiple colors according to the current scheme index and edge function189bool setMultiColor(const GUIColorer& c) const;190191/// @brief gets the color value according to the current scheme index192double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;193194/// @brief gets the scaling value according to the current scheme index195double getScaleValue(const GUIVisualizationSettings& s, int activeScheme) const;196197/// @brief returns the segment closest to the given position198MESegment* getSegmentAtPosition(const Position& pos);199200void drawMesoVehicles(const GUIVisualizationSettings& s) const;201202/// @brief grant exclusive access to the mesoscopic state203void lock() const override {204myLock.lock();205}206207/// @brief release exclusive access to the mesoscopic state208void unlock() const override {209myLock.unlock();210}211212/// @brief close this edge for traffic213void closeTraffic(const GUILane* lane);214215/// @brief add a rerouter216void addRerouter();217218/// @brief return segment colors (meso)219const std::vector<RGBColor>& getSegmentColors() const {220return mySegmentColors;221}222223RGBColor getMesoColor() const {224return myMesoColor;225}226227bool showDeadEnd() const {228return myShowDeadEnd;229}230231/// @brief whether this lane is selected in the GUI232bool isSelected() const override;233234/// The color of the segments (cached)235mutable std::vector<RGBColor> mySegmentColors;236237/// @brief whether to highlight this edge as a dead-end edge238bool myShowDeadEnd;239240/// @brief get number of vehicles waiting for departure on this edge241double getPendingEmits() const;242243private:244/// @brief invalidated copy constructor245GUIEdge(const GUIEdge& s);246247/// @brief invalidated assignment operator248GUIEdge& operator=(const GUIEdge& s);249250251private:252/// The mutex used to avoid concurrent updates of myPersons/ myContainers253mutable FXMutex myLock;254255mutable RGBColor myMesoColor;256257};258259260