Path: blob/main/src/netedit/elements/network/GNEConnection.h
185790 views
/****************************************************************************/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 GNEConnection.h14/// @author Pablo Alvarez Lopez15/// @date Jun 201616///17// A class for represent connections between Lanes18/****************************************************************************/19#pragma once20#include <config.h>2122#include <netbuild/NBEdge.h>23#include <utils/gui/div/GUIGeometry.h>2425#include "GNENetworkElement.h"2627// ===========================================================================28// class declarations29// ===========================================================================3031class GNEEdge;32class GNEMoveElementConnection;3334// ===========================================================================35// class definitions36// ===========================================================================3738class GNEConnection : public GNENetworkElement {3940/// @brief friend classses41friend class GNEMoveElementConnection;4243public:44/** Constructor45* @param[in] from The edge the vehicles leave46* @param[in] connection NBEdge::Connection in which the rest of parameters are defined47* @param[in] uncontrolled if set to true, This connection will not be TLS-controlled despite its node being controlled.48**/49GNEConnection(GNELane* from, GNELane* to);5051/// @brief Destructor52~GNEConnection();5354/// @brief methods to retrieve the elements linked to this connection55/// @{5657/// @brief get GNEMoveElement associated with this connection58GNEMoveElement* getMoveElement() const override;5960/// @brief get parameters associated with this connection61Parameterised* getParameters() override;6263/// @brief get parameters associated with this connection (constant)64const Parameterised* getParameters() const override;6566/// @}6768/// @name Functions related with geometry of element69/// @{7071/// @brief get connection shape72const PositionVector& getConnectionShape() const;7374/// @brief update pre-computed geometry information75void updateGeometry() override;7677/// @brief Returns position of hierarchical element in view78Position getPositionInView() const;7980/// @}8182/// @name Function related with contour drawing83/// @{8485/// @brief check if draw from contour (green)86bool checkDrawFromContour() const override;8788/// @brief check if draw from contour (magenta)89bool checkDrawToContour() const override;9091/// @brief check if draw related contour (cyan)92bool checkDrawRelatedContour() const override;9394/// @brief check if draw over contour (orange)95bool checkDrawOverContour() const override;9697/// @brief check if draw delete contour (pink/white)98bool checkDrawDeleteContour() const override;99100/// @brief check if draw delete contour small (pink/white)101bool checkDrawDeleteContourSmall() const override;102103/// @brief check if draw select contour (blue)104bool checkDrawSelectContour() const override;105106/// @brief check if draw move contour (red)107bool checkDrawMoveContour() const override;108109/// @}110111/// @brief get the name of the edge the vehicles leave112GNEEdge* getEdgeFrom() const;113114/// @brief get the name of the edge the vehicles may reach when leaving "from"115GNEEdge* getEdgeTo() const;116117/// @briefthe get lane of the incoming lane118GNELane* getLaneFrom() const;119120/// @briefthe get lane of the outgoing lane121GNELane* getLaneTo() const;122123/// @briefthe get lane index of the incoming lane124int getFromLaneIndex() const;125126/// @briefthe get lane index of the outgoing lane127int getToLaneIndex() const;128129/// @brief get Edge::Connection130NBEdge::Connection& getNBEdgeConnection() const;131132/// @brief get NBConnection133NBConnection getNBConnection() const;134135/// @brief get LinkState136LinkState getLinkState() const;137138/// @brief check that connection's Geometry has to be updated139void markConnectionGeometryDeprecated();140141/// @brief update internal ID of Connection142void updateConnectionID();143144/// @brief recompute cached myLinkState145void updateLinkState();146147/// @brief smoothShape148void smootShape();149150/// @name inherited from GUIGlObject151/// @{152/**@brief Returns an own popup-menu153*154* @param[in] app The application needed to build the popup-menu155* @param[in] parent The parent window needed to build the popup-menu156* @return The built popup-menu157* @see GUIGlObject::getPopUpMenu158*/159GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;160161/// @brief return exaggeration associated with this GLObject162double getExaggeration(const GUIVisualizationSettings& s) const override;163164/// @brief Returns the boundary to which the view shall be centered in order to show the object165Boundary getCenteringBoundary() const override;166167/// @brief update centering boundary (implies change in RTREE)168void updateCenteringBoundary(const bool updateGrid);169170/**@brief Draws the object171* @param[in] s The settings for the current view (may influence drawing)172* @see GUIGlObject::drawGL173*/174void drawGL(const GUIVisualizationSettings& s) const override;175176/// @brief delete element177void deleteGLObject() override;178179/// @brief update GLObject (geometry, ID, etc.)180void updateGLObject() override;181182/// @}183184/* @brief method for setting the special color of the connection185* @param[in] color Pointer to new special color186*/187void setSpecialColor(const RGBColor* Color2);188189/// @name inherited from GNEAttributeCarrier190/// @{191/* @brief method for getting the Attribute of an XML key192* @param[in] key The attribute key193* @return string with the value associated to key194*/195std::string getAttribute(SumoXMLAttr key) const override;196197/* @brief method for getting the Attribute of an XML key in double format198* @param[in] key The attribute key199* @return double with the value associated to key200*/201double getAttributeDouble(SumoXMLAttr key) const override;202203/* @brief method for getting the Attribute of an XML key in position format204* @param[in] key The attribute key205* @return position with the value associated to key206*/207Position getAttributePosition(SumoXMLAttr key) const override;208209/* @brief method for getting the Attribute of an XML key in positionVector format210* @param[in] key The attribute key211* @return positionVector with the value associated to key212*/213PositionVector getAttributePositionVector(SumoXMLAttr key) const override;214215/* @brief method for setting the attribute and letting the object perform additional changes216* @param[in] key The attribute key217* @param[in] value The new value218* @param[in] undoList The undoList on which to register changes219*/220void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;221222/* @brief method for checking if the key and their conrrespond attribute are valids223* @param[in] key The attribute key224* @param[in] value The value associated to key key225* @return true if the value is valid, false in other case226*/227bool isValid(SumoXMLAttr key, const std::string& value) override;228229/* @brief method for check if the value for certain attribute is set230* @param[in] key The attribute key231*/232bool isAttributeEnabled(SumoXMLAttr key) const override;233234/* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)235* @param[in] key The attribute key236*/237bool isAttributeComputed(SumoXMLAttr key) const override;238239/// @}240241protected:242/// @brief move element connection243GNEMoveElementConnection* myMoveElementConnection = nullptr;244245/// @brief Linkstate. @note cached because after 'undo' the connection needs to be drawn while the node logic (NBRequest) has not been recomputed246LinkState myLinkState;247248/// @brief optional special color249const RGBColor* mySpecialColor;250251/// @brief connection geometry252GUIGeometry myConnectionGeometry;253254/// @brief junction maker geometry255GUIGeometry myInternalJunctionMarkerGeometry;256257/// @brief flag to indicate that connection's shape has to be updated258bool myShapeDeprecated;259260private:261/// @brief set attribute after validation262void setAttribute(SumoXMLAttr key, const std::string& value) override;263264/// @brief manage change of tlLinkindices265void changeTLIndex(SumoXMLAttr key, int tlIndex, int tlIndex2, GNEUndoList* undoList);266267/// @brief check if the edgeConnection vinculated with this connection exists268bool existNBEdgeConnection() const;269270/// @brief check if draw connection271bool checkDrawConnection() const;272273/// @brief get connection color274RGBColor getConnectionColor(const GUIVisualizationSettings& s) const;275276/// @brief draw connection277void drawConnection(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,278const GUIGeometry& superposedGeometry, const double exaggeration) const;279280/// @brief draw arrows over connections281void drawConnectionArrows(const GUIVisualizationSettings& s, const GUIGeometry& superposedGeometry,282const RGBColor& color) const;283284/// @brief draw edge value285void drawEdgeValues(const GUIVisualizationSettings& s, const PositionVector& shape) const;286287/// @brief calculate connection contour288void calculateConnectionContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,289const PositionVector& shape, const double exaggeration) const;290291/// @brief Invalidated copy constructor.292GNEConnection(const GNEConnection&) = delete;293294/// @brief Invalidated assignment operator.295GNEConnection& operator=(const GNEConnection&) = delete;296};297298299