Path: blob/main/src/netedit/elements/network/GNECrossing.h
185790 views
/****************************************************************************/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 GNECrossing.h14/// @author Jakob Erdmann15/// @date June 201116///17// A class for visualizing Inner Lanes (used when editing traffic lights)18/****************************************************************************/19#pragma once20#include <config.h>21#include "GNENetworkElement.h"22#include <netbuild/NBNode.h>2324// ===========================================================================25// class declarations26// ===========================================================================2728class GNEEdge;29class GNEJunction;30class GNEMoveElementCrossing;31class GUIGLObjectPopupMenu;32class PositionVector;3334// ===========================================================================35// class definitions36// ===========================================================================373839class GNECrossing : public GNENetworkElement {4041public:42/// @brief default constructor43GNECrossing(GNENet* net);4445/**@brief Constructor46* @param[in] junction GNEJunction in which this crossing is placed47* @param[in] crossing Node::Crossing48*/49GNECrossing(GNEJunction* junction, std::vector<NBEdge*> edges);5051/// @brief Destructor52~GNECrossing();5354/// @brief methods to retrieve the elements linked to this crossing55/// @{5657/// @brief get GNEMoveElement associated with this crossing58GNEMoveElement* getMoveElement() const override;5960/// @brief get parameters associated with this crossing61Parameterised* getParameters() override;6263/// @brief get parameters associated with this crossing (constant)64const Parameterised* getParameters() const override;6566/// @}6768/// @brief check if current network element is valid to be written into XML69bool isNetworkElementValid() const override;7071/// @brief return a string with the current network element problem72std::string getNetworkElementProblem() const override;7374/// @name Functions related with geometry of element75/// @{7677/// @brief get Crossing shape78const PositionVector& getCrossingShape() const;7980/// @brief update pre-computed geometry information81void updateGeometry() override;8283/// @brief Returns position of hierarchical element in view84Position getPositionInView() const;8586/// @}8788/// @name Function related with contour drawing89/// @{9091/// @brief check if draw from contour (green)92bool checkDrawFromContour() const override;9394/// @brief check if draw from contour (magenta)95bool checkDrawToContour() const override;9697/// @brief check if draw related contour (cyan)98bool checkDrawRelatedContour() const override;99100/// @brief check if draw over contour (orange)101bool checkDrawOverContour() const override;102103/// @brief check if draw delete contour (pink/white)104bool checkDrawDeleteContour() const override;105106/// @brief check if draw delete contour small (pink/white)107bool checkDrawDeleteContourSmall() const override;108109/// @brief check if draw select contour (blue)110bool checkDrawSelectContour() const override;111112/// @brief check if draw move contour (red)113bool checkDrawMoveContour() const override;114115/// @}116117/// @brief get crossingEdges118const std::vector<NBEdge*>& getCrossingEdges() const;119120///@brief get referente to NBode::Crossing121NBNode::Crossing* getNBCrossing() const;122123/// @name inherited from GUIGlObject124/// @{125/**@brief Returns an own popup-menu126*127* @param[in] app The application needed to build the popup-menu128* @param[in] parent The parent window needed to build the popup-menu129* @return The built popup-menu130* @see GUIGlObject::getPopUpMenu131*/132GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;133134/// @brief Returns the boundary to which the view shall be centered in order to show the object135Boundary getCenteringBoundary() const override;136137/// @brief update centering boundary (implies change in RTREE)138void updateCenteringBoundary(const bool updateGrid);139140/**@brief Draws the object141* @param[in] s The settings for the current view (may influence drawing)142* @see GUIGlObject::drawGL143*/144void drawGL(const GUIVisualizationSettings& s) const override;145146/// @brief delete element147void deleteGLObject() override;148149/// @brief update GLObject (geometry, ID, etc.)150void updateGLObject() override;151152/// @}153154/// @name inherited from GNEAttributeCarrier155/// @{156/* @brief method for getting the Attribute of an XML key157* @param[in] key The attribute key158* @return string with the value associated to key159*/160std::string getAttribute(SumoXMLAttr key) const override;161162/* @brief method for getting the Attribute of an XML key in double format163* @param[in] key The attribute key164* @return double with the value associated to key165*/166double getAttributeDouble(SumoXMLAttr key) const override;167168/* @brief method for getting the Attribute of an XML key in position format169* @param[in] key The attribute key170* @return position with the value associated to key171*/172Position getAttributePosition(SumoXMLAttr key) const override;173174/* @brief method for getting the Attribute of an XML key in Position format175* @param[in] key The attribute key176* @return position with the value associated to key177*/178PositionVector getAttributePositionVector(SumoXMLAttr key) const override;179180/* @brief method for setting the attribute and letting the object perform additional changes181* @param[in] key The attribute key182* @param[in] value The new value183* @param[in] undoList The undoList on which to register changes184*/185void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;186187/* @brief method for checking if the key and their correspond attribute are valids188* @param[in] key The attribute key189* @param[in] value The value associated to key key190* @return true if the value is valid, false in other case191*/192bool isValid(SumoXMLAttr key, const std::string& value) override;193194/* @brief method for check if the value for certain attribute is set195* @param[in] key The attribute key196*/197bool isAttributeEnabled(SumoXMLAttr key) const override;198199/// @}200201/// @brief return true if a edge belongs to crossing's edges202bool checkEdgeBelong(GNEEdge* edges) const;203204/// @brief return true if a edge of a vector of edges belongs to crossing's edges205bool checkEdgeBelong(const std::vector<GNEEdge*>& edges) const;206207protected:208/// @brief move element crossing209GNEMoveElementCrossing* myMoveElementCrossing = nullptr;210211/// @brief Crossing Edges (It works as ID because a junction can only ONE Crossing with the same edges)212std::vector<NBEdge*> myCrossingEdges;213214/// @brief crossing geometry215GUIGeometry myCrossingGeometry;216217/// @brief template NBCrossing218NBNode::Crossing* myTemplateNBCrossing;219220private:221/// @brief check if draw crossing222bool checkDrawCrossing(const GUIVisualizationSettings& s) const;223224/// @brief draw crossing225void drawCrossing(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,226const NBNode::Crossing* crossing, const double width, const double exaggeration) const;227228/// @brief get crossing color229RGBColor getCrossingColor(const GUIVisualizationSettings& s, const NBNode::Crossing* crossing) const;230231/// @brief draw crossing with hight detail232void drawCrossingDetailed(const double width, const double exaggeration) const;233234/// @brief calculate contour235void calculateCrossingContour(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,236const double width, const double exaggeration) const;237238/// @brief method for setting the attribute and nothing else (used in GNEChange_Attribute)239void setAttribute(SumoXMLAttr key, const std::string& value) override;240241/// @brief draw TLS Link Number242void drawTLSLinkNo(const GUIVisualizationSettings& s, const NBNode::Crossing* crossing) const;243244/// @brief Invalidated copy constructor.245GNECrossing(const GNECrossing&) = delete;246247/// @brief Invalidated assignment operator.248GNECrossing& operator=(const GNECrossing&) = delete;249};250251252