/****************************************************************************/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 GNELane.h14/// @author Jakob Erdmann15/// @date Feb 201116///17// A class for visualizing Lane geometry (adapted from GUILaneWrapper)18/****************************************************************************/19#pragma once20#include <config.h>2122#include <netedit/elements/GNECandidateElement.h>23#include <netedit/elements/moving/GNEMoveResult.h>24#include <netedit/GNELane2laneConnection.h>2526#include "GNENetworkElement.h"2728// ===========================================================================29// class declarations30// ===========================================================================3132class GNEConnection;33class GNEEdge;34class GNEMoveElementLane;35class GNEMoveOperation;36class GNENet;37class GNETLSEditorFrame;38class GUIGLObjectPopupMenu;39class PositionVector;4041// ===========================================================================42// class definitions43// ===========================================================================4445class GNELane : public GNENetworkElement, public GNECandidateElement, public FXDelegator {46/// @brief FOX-declaration47FXDECLARE_OVERRIDE(GNELane)4849public:50/// @brief class for lane drawing constants51class DrawingConstants {5253public:54/// @brief parameter constructor55DrawingConstants(const GNELane* lane);5657/// @brief update lane drawing constants58void update(const GUIVisualizationSettings& s);5960/// @brief get exaggeration61double getExaggeration() const;6263/// @brief get lane drawing width64double getDrawingWidth() const;6566/// @brief get internal lane drawing width67double getInternalDrawingWidth() const;6869/// @brief get lane offset70double getOffset() const;7172/// @brief get detail73GUIVisualizationSettings::Detail getDetail() const;7475/// @brief draw as railway76bool drawAsRailway() const;7778/// @brief draw superposed79bool drawSuperposed() const;8081protected:82/// @brief lane83const GNELane* myLane;8485/// @brief exaggeration86double myExaggeration = 0;8788/// @brief lane drawing width89double myDrawingWidth = 0;9091/// @brief internal lane drawing width (used for drawing selected lanes)92double myInternalDrawingWidth = 0;9394/// @brief lane offset95double myOffset = 0;9697/// @brief detail level98GUIVisualizationSettings::Detail myDetail = GUIVisualizationSettings::Detail::Level4;99100/// @brief draw as railway101bool myDrawAsRailway = false;102103/// @brief draw supersposed (reduced width so that the lane markings below are visible)104bool myDrawSuperposed = false;105106private:107/// @brief invalidate default constructor108DrawingConstants() = delete;109110/// @brief Invalidated copy constructor.111DrawingConstants(const DrawingConstants&) = delete;112113/// @brief Invalidated assignment operator.114DrawingConstants& operator=(const DrawingConstants&) = delete;115};116117/**@brief Constructor118* @param[in] idStorage The storage of gl-ids to get the one for this lane representation from119* @param[in] the edge this lane belongs to120* @param[in] the index of this lane121*/122GNELane(GNEEdge* edge, const int index);123124/// @brief Destructor125~GNELane();126127/// @brief methods to retrieve the elements linked to this lane128/// @{129130/// @brief get GNEMoveElement associated with this lane131GNEMoveElement* getMoveElement() const override;132133/// @brief get parameters associated with this lane134Parameterised* getParameters() override;135136/// @brief get parameters associated with this lane137const Parameterised* getParameters() const override;138139/// @}140141/// @brief get parent edge142GNEEdge* getParentEdge() const;143144/// @brief check if current lane allow pedestrians145bool allowPedestrians() const;146147/// @name Functions related with geometry of element148/// @{149150/// @brief get lane geometry151const GUIGeometry& getLaneGeometry() const;152153/// @brief get elements shape154const PositionVector& getLaneShape() const;155156/// @brief get rotations of the single shape parts157const std::vector<double>& getShapeRotations() const;158159/// @brief get lengths of the single shape parts160const std::vector<double>& getShapeLengths() const;161162/// @brief get lane drawing constants (previously calculated in drawGL())163const DrawingConstants* getDrawingConstants() const;164165/// @brief update pre-computed geometry information166void updateGeometry() override;167168/// @brief Returns position of hierarchical element in view169Position getPositionInView() const;170171/// @}172173/// @name Function related with contour drawing174/// @{175176/// @brief check if draw from contour (green)177bool checkDrawFromContour() const override;178179/// @brief check if draw from contour (magenta)180bool checkDrawToContour() const override;181182/// @brief check if draw related contour (cyan)183bool checkDrawRelatedContour() const override;184185/// @brief check if draw over contour (orange)186bool checkDrawOverContour() const override;187188/// @brief check if draw delete contour (pink/white)189bool checkDrawDeleteContour() const override;190191/// @brief check if draw delete contour small (pink/white)192bool checkDrawDeleteContourSmall() const override;193194/// @brief check if draw select contour (blue)195bool checkDrawSelectContour() const override;196197/// @brief check if draw move contour (red)198bool checkDrawMoveContour() const override;199200/// @}201202/// @brief returns a vector with the incoming GNEConnections of this lane203std::vector<GNEConnection*> getGNEIncomingConnections();204205/// @brief returns a vector with the outgoing GNEConnections of this lane206std::vector<GNEConnection*> getGNEOutcomingConnections();207208/// @brief update IDs of incoming connections of this lane209void updateConnectionIDs();210211/// @brief get length geometry factor212double getLengthGeometryFactor() const;213214/// @name inherited from GUIGlObject215/// @{216// @brief Returns the name of the parent object (if any)217// @return This object's parent id218std::string getParentName() const override;219220/**@brief Returns an own popup-menu221*222* @param[in] app The application needed to build the popup-menu223* @param[in] parent The parent window needed to build the popup-menu224* @return The built popup-menu225* @see GUIGlObject::getPopUpMenu226*/227GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;228229/// @brief multiplexes message to two targets230long onDefault(FXObject*, FXSelector, void*) override;231232/// @brief return exaggeration associated with this GLObject233double getExaggeration(const GUIVisualizationSettings& s) const override;234235/// @brief Returns the boundary to which the view shall be centered in order to show the object236Boundary getCenteringBoundary() const override;237238/// @brief update centering boundary (implies change in RTREE)239void updateCenteringBoundary(const bool updateGrid);240241/**@brief Draws the object242* @param[in] s The settings for the current view (may influence drawing)243* @see GUIGlObject::drawGL244*/245void drawGL(const GUIVisualizationSettings& s) const override;246247/// @brief delete element248void deleteGLObject() override;249250/// @brief update GLObject (geometry, ID, etc.)251void updateGLObject() override;252/// @}253254/// @brief returns the index of the lane255int getIndex() const;256257/// @brief returns the current speed of lane258double getSpeed() const;259260/* @brief method for setting the index of the lane261* @param[in] index The new index of lane262*/263void setIndex(int index);264265/** @brief returns the parameteric length of the lane266* @note is the same as their Edge parent, and cannot be never nullptr267*/268double getLaneParametricLength() const;269270/// @brief returns the length of the lane's shape271double getLaneShapeLength() const;272273/// @brief check if this lane is restricted274bool isRestricted(SUMOVehicleClass vclass) const;275276/// @brief get Lane2laneConnection struct277const GNELane2laneConnection& getLane2laneConnections() const;278279/// @name inherited from GNEAttributeCarrier280/// @{281/* @brief method for getting the Attribute of an XML key282* @param[in] key The attribute key283* @return string with the value associated to key284*/285std::string getAttribute(SumoXMLAttr key) const override;286std::string getAttributeForSelection(SumoXMLAttr key) const override;287288/* @brief method for getting the Attribute of an XML key in double format289* @param[in] key The attribute key290* @return double with the value associated to key291*/292double getAttributeDouble(SumoXMLAttr key) const override;293294/* @brief method for getting the Attribute of an XML key in position format295* @param[in] key The attribute key296* @return position with the value associated to key297*/298Position getAttributePosition(SumoXMLAttr key) const override;299300/* @brief method for getting the Attribute of an XML key in Position format301* @param[in] key The attribute key302* @return position with the value associated to key303*/304PositionVector getAttributePositionVector(SumoXMLAttr key) const override;305306/* @brief method for setting the attribute and letting the object perform additional changes307* @param[in] key The attribute key308* @param[in] value The new value309* @param[in] undoList The undoList on which to register changes310*/311void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;312313/* @brief method for checking if the key and their correspond attribute are valids314* @param[in] key The attribute key315* @param[in] value The value associated to key key316* @return true if the value is valid, false in other case317*/318bool isValid(SumoXMLAttr key, const std::string& value) override;319320/* @brief method for check if the value for certain attribute is set321* @param[in] key The attribute key322*/323bool isAttributeEnabled(SumoXMLAttr key) const override;324325/* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)326* @param[in] key The attribute key327*/328bool isAttributeComputed(SumoXMLAttr key) const override;329330/// @}331332/* @brief method for setting the special color of the lane333* @param[in] color Pointer to new special color334*/335void setSpecialColor(const RGBColor* Color2, double colorValue = std::numeric_limits<double>::max());336337/// @brief return value for lane coloring according to the given scheme338double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;339340/// @brief draw overlapped routes341void drawOverlappedRoutes(const int numRoutes) const;342343/// @brief draw laneStopOffset344void drawLaneStopOffset(const GUIVisualizationSettings& s) const;345346protected:347/// @brief FOX needs this348GNELane();349350private:351/// @brief move element lane352GNEMoveElementLane* myMoveElementLane = nullptr;353354/// @brief The index of this lane355int myIndex;356357/// @brief lane geometry358GUIGeometry myLaneGeometry;359360/// @brief LaneDrawingConstants361DrawingConstants* myDrawingConstants;362363/// @name computed only once (for performance) in updateGeometry()364/// @{365366/// @brief Position of textures of restricted lanes367std::vector<Position> myLaneRestrictedTexturePositions;368369/// @brief Rotations of textures of restricted lanes370std::vector<double> myLaneRestrictedTextureRotations;371/// @}372373/// @brief optional special color374const RGBColor* mySpecialColor;375376/// @brief optional value that corresponds to which the special color corresponds377double mySpecialColorValue;378379/// @brief The color of the shape parts (cached)380mutable std::vector<RGBColor> myShapeColors;381382/// @brief lane2lane connections383GNELane2laneConnection myLane2laneConnections;384385/// @brief set attribute after validation386void setAttribute(SumoXMLAttr key, const std::string& value) override;387388/// @brief draw lane389void drawLane(const GUIVisualizationSettings& s, const double layer) const;390391/// @brief draw selected lane392void drawSelectedLane(const GUIVisualizationSettings& s) const;393394/// @brief draw shape edited395void drawShapeEdited(const GUIVisualizationSettings& s) const;396397/// @brief draw children398void drawChildren(const GUIVisualizationSettings& s) const;399400/// @brief draw lane markings401void drawMarkingsAndBoundings(const GUIVisualizationSettings& s) const;402403/// @brief draw link Number404void drawLinkNo(const GUIVisualizationSettings& s) const;405406/// @brief draw TLS link Number407void drawTLSLinkNo(const GUIVisualizationSettings& s) const;408409/// @brief draw lane arrows410void drawArrows(const GUIVisualizationSettings& s) const;411412/// @brief draw lane to lane connections413void drawLane2LaneConnections() const;414415/// @brief calculate contour416void calculateLaneContour(const GUIVisualizationSettings& s, const double layer) const;417418/// @brief sets the color according to the current scheme index and some lane function419bool setFunctionalColor(int activeScheme, RGBColor& col) const;420421/// @brief sets multiple colors according to the current scheme index and some lane function422bool setMultiColor(const GUIVisualizationSettings& s, const GUIColorer& c, RGBColor& col) const;423424/// @brief whether to draw this lane as a waterways425bool drawAsWaterway(const GUIVisualizationSettings& s) const;426427/// @brief direction indicators for lanes428void drawDirectionIndicators(const GUIVisualizationSettings& s) const;429430/// @brief draw lane as railway431void drawLaneAsRailway() const;432433/// @brief draw lane textures434void drawTextures(const GUIVisualizationSettings& s) const;435436/// @brief draw start and end geometry points437void drawStartEndGeometryPoints(const GUIVisualizationSettings& s) const;438439/// @brief set color according to edit mode and visualisation settings440RGBColor setLaneColor(const GUIVisualizationSettings& s) const;441442/// @brief build edge operations contextual menu443void buildEdgeOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMenu* ret);444445/// @brief build lane operations contextual menu446void buildLaneOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMenu* ret);447448/// @brief build template oerations contextual menu449void buildTemplateOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMenu* ret);450451/// @brief build rechable operations contextual menu452void buildRechableOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMenu* ret);453454/// @brief Invalidated copy constructor.455GNELane(const GNELane&) = delete;456457/// @brief Invalidated assignment operator.458GNELane& operator=(const GNELane&) = delete;459};460461462