Path: blob/main/src/netedit/elements/additional/GNEAdditional.h
193904 views
/****************************************************************************/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 GNEAdditional.h14/// @author Pablo Alvarez Lopez15/// @date Jan 201616///17// A abstract class for representation of additional elements18/****************************************************************************/19#pragma once20#include <config.h>2122#include <netedit/elements/GNEAttributeCarrier.h>23#include <netedit/elements/GNEContour.h>24#include <netedit/elements/GNEHierarchicalElement.h>25#include <netedit/elements/GNEPathElement.h>26#include <netedit/elements/moving/GNEMoveElement.h>27#include <utils/gui/div/GUIGeometry.h>28#include <utils/gui/globjects/GUIGlObject.h>2930// ===========================================================================31// class declarations32// ===========================================================================3334class GNENetworkElement;35class GUIGLObjectPopupMenu;3637// ===========================================================================38// class definitions39// ===========================================================================4041class GNEAdditional : public GNEAttributeCarrier, public GNEHierarchicalElement, public GUIGlObject, public GNEPathElement {4243public:44/// @brief declare friend class45friend class GNEAdditionalListed;46friend class GNEAdditionalSquared;4748/**@brief Constructor for templates49* @param[in] tag SUMO Tag assigned to this type of object50* @param[in] net GNENet in which this AttributeCarrier is stored51*/52GNEAdditional(GNENet* net, SumoXMLTag tag);5354/**@brief Constructor55* @param[in] id Gl-id of the additional element (Must be unique)56* @param[in] tag SUMO Tag assigned to this type of object57* @param[in] net GNENet in which this AttributeCarrier is stored58* @param[in] fileBucket bucket in which this AttributeCarrier is stored59* @param[in] name Additional name60*/61GNEAdditional(const std::string& id, GNENet* net, SumoXMLTag tag, FileBucket* fileBucket, const std::string& name);6263/**@brief Constructor for additional with parents64* @param[in] additionalParent pointer to additional parent65* @param[in] tag Type of xml tag that define the additional element (SUMO_TAG_BUS_STOP, SUMO_TAG_REROUTER, etc...)66* @param[in] name Additional name67*/68GNEAdditional(GNEAdditional* additionalParent, SumoXMLTag tag, const std::string& name);6970/// @brief Destructor71~GNEAdditional();7273/// @brief methods to retrieve the elements linked to this additional74/// @{7576/// @brief get GNEHierarchicalElement associated with this additional77GNEHierarchicalElement* getHierarchicalElement() override;7879/// @brief get GUIGlObject associated with this additional80GUIGlObject* getGUIGlObject() override;8182/// @brief get GUIGlObject associated with this additional (constant)83const GUIGlObject* getGUIGlObject() const override;8485/// @}8687/// @brief get reference to fileBucket in which save this AC88FileBucket* getFileBucket() const override;8990/// @brief Returns the name of the object (default "")91virtual const std::string getOptionalName() const override;9293/// @brief obtain additional geometry94const GUIGeometry& getAdditionalGeometry() const;9596/// @brief set special color97void setSpecialColor(const RGBColor* color);9899/// @brief reset additional contour100void resetAdditionalContour();101102/// @name members and functions relative to write additionals into XML103/// @{104105/**@brief write additional element into a xml file106* @param[in] device device in which write parameters of additional element107*/108virtual void writeAdditional(OutputDevice& device) const = 0;109110/// @brief check if current additional is valid to be written into XML (by default true, can be reimplemented in children)111virtual bool isAdditionalValid() const = 0;112113/// @brief return a string with the current additional problem (by default empty, can be reimplemented in children)114virtual std::string getAdditionalProblem() const = 0;115116/// @brief fix additional problem (by default throw an exception, has to be reimplemented in children)117virtual void fixAdditionalProblem() = 0;118119/// @}120121/// @name functions related with geometry122/// @{123124/**@brief open Additional Dialog125* @note: if additional needs an additional dialog, this function has to be implemented in childrens (see GNERerouter and GNEVariableSpeedSign)126* @throw invalid argument if additional doesn't have an additional Dialog127*/128virtual void openAdditionalDialog(FXWindow* restoringFocusWindow);129130/// @brief Returns position of additional in view131virtual Position getPositionInView() const = 0;132133/// @brief return exaggeration associated with this GLObject134double getExaggeration(const GUIVisualizationSettings& s) const override;135136/// @brief Returns the boundary to which the view shall be centered in order to show the object137Boundary getCenteringBoundary() const override;138139/// @brief update centering boundary (implies change in RTREE)140virtual void updateCenteringBoundary(const bool updateGrid) = 0;141142/// @brief split geometry143virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;144145/// @}146147/// @name Function related with contour drawing148/// @{149150/// @brief check if draw from contour (green)151bool checkDrawFromContour() const override;152153/// @brief check if draw from contour (magenta)154bool checkDrawToContour() const override;155156/// @brief check if draw related contour (cyan)157bool checkDrawRelatedContour() const override;158159/// @brief check if draw over contour (orange)160bool checkDrawOverContour() const override;161162/// @brief check if draw delete contour (pink/white)163bool checkDrawDeleteContour() const override;164165/// @brief check if draw delete contour small (pink/white)166bool checkDrawDeleteContourSmall() const override;167168/// @brief check if draw select contour (blue)169bool checkDrawSelectContour() const override;170171/// @}172173/// @name inherited from GUIGlObject174/// @{175176/**@brief Returns an own popup-menu177*178* @param[in] app The application needed to build the popup-menu179* @param[in] parent The parent window needed to build the popup-menu180* @return The built popup-menu181* @see GUIGlObject::getPopUpMenu182*/183virtual GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;184185/**@brief Returns an own parameter window186*187* @param[in] app The application needed to build the parameter window188* @param[in] parent The parent window needed to build the parameter window189* @return The built parameter window190* @see GUIGlObject::getParameterWindow191*/192GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;193194/// @brief Returns the additional name195const std::string& getOptionalAdditionalName() const;196197/// @brief check if element is locked198bool isGLObjectLocked() const override;199200/// @brief mark element as front element201void markAsFrontElement() override;202203/// @brief delete element204void deleteGLObject() override;205206/// @brief select element207void selectGLObject() override;208209/// @brief update GLObject (geometry, ID, etc.)210void updateGLObject() override;211212/// @}213214/// @name inherited from GNEPathElement215/// @{216217/// @brief compute pathElement218virtual void computePathElement() override;219220/// @brief check if path element is selected221bool isPathElementSelected() const override;222223/**@brief Draws partial object over lane224* @param[in] s The settings for the current view (may influence drawing)225* @param[in] segment lane segment226* @param[in] offsetFront front offset227*/228virtual void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;229230/**@brief Draws partial object over junction231* @param[in] s The settings for the current view (may influence drawing)232* @param[in] segment junction segment233* @param[in] offsetFront front offset234*/235virtual void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;236237/// @brief get first path lane238GNELane* getFirstPathLane() const override;239240/// @brief get last path lane241GNELane* getLastPathLane() const override;242243/// @}244245/// @brief draw parent and child lines246void drawParentChildLines(const GUIVisualizationSettings& s, const RGBColor& color, const bool onlySymbols = false) const;247248/// @brief draw up geometry point249void drawUpGeometryPoint(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const Position& pos,250const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;251252/// @brief draw down geometry point253void drawDownGeometryPoint(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const Position& pos,254const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;255256/// @brief draw left geometry point257void drawLeftGeometryPoint(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const Position& pos,258const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;259260/// @brief draw right geometry point261void drawRightGeometryPoint(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d, const Position& pos,262const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;263264/// @brief check if the given lanes are consecutive265static bool areLaneConsecutives(const std::vector<GNELane*>& lanes);266267/// @brief check if the given lanes are connected268static bool areLaneConnected(const std::vector<GNELane*>& lanes);269270protected:271/// @brief Additional Boundary (used only by additionals placed over grid)272Boundary myAdditionalBoundary;273274/// @brief geometry to be precomputed in updateGeometry(...)275GUIGeometry myAdditionalGeometry;276277/// @brief variable used for draw additional contours278GNEContour myAdditionalContour;279280/// @brief name of additional281std::string myAdditionalName;282283/// @brief pointer to special color (used for drawing Additional with a certain color, mainly used for selections)284const RGBColor* mySpecialColor = nullptr;285286/// @brief write common additional attributes287void writeAdditionalAttributes(OutputDevice& device) const;288289/// @name Functions relative to change values in setAttribute(...)290/// @{291292/// @brief check if a new additional ID is valid293bool isValidAdditionalID(const std::string& value) const;294295/// @brief check if a new additional ID is valid296bool isValidAdditionalID(const std::vector<SumoXMLTag>& tags, const std::string& value) const;297298/// @brief check if a new detector ID is valid299bool isValidDetectorID(const std::string& value) const;300301/// @brief check if a new detector ID is valid302bool isValidDetectorID(const std::vector<SumoXMLTag>& tags, const std::string& value) const;303304/// @brief set additional ID305void setAdditionalID(const std::string& newID);306307/// @}308309/// @brief draw additional ID310void drawAdditionalID(const GUIVisualizationSettings& s) const;311312/// @brief draw additional name313void drawAdditionalName(const GUIVisualizationSettings& s) const;314315/// @brief replace additional parent edges316void replaceAdditionalParentEdges(const std::string& value);317318/// @brief replace additional parent lanes319void replaceAdditionalParentLanes(const std::string& value);320321/// @brief replace additional child edges322void replaceAdditionalChildEdges(const std::string& value);323324/// @brief replace additional child lanes325void replaceAdditionalChildLanes(const std::string& value);326327/// @brief replace additional parent328void replaceAdditionalParent(SumoXMLTag tag, const std::string& value, const int parentIndex);329330/// @brief replace demand element parent331void replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex);332333/// @brief shift lane index334void shiftLaneIndex();335336/// @brief calculate perpendicular line between lane parents337void calculatePerpendicularLine(const double endLaneposition);338339/// @brief draw demand element children340void drawDemandElementChildren(const GUIVisualizationSettings& s) const;341342/// @name JuPedSim values343/// @{344345/// @brief get JuPedSim type346static std::string getJuPedSimType(SumoXMLTag tag);347348/// @brief get JuPedSim color349static RGBColor getJuPedSimColor(SumoXMLTag tag);350351/// @brief get JuPedSim fill352static bool getJuPedSimFill(SumoXMLTag tag);353354/// @brief get JuPedSim color355static double getJuPedSimLayer(SumoXMLTag tag);356357/// @}358359/// @name calculate contours360/// @{361362/// @brief calculate contour for polygons363void calculateContourPolygons(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,364const double layer, const double exaggeration, const bool filledShape) const;365366/// @}367368private:369/**@brief check restriction with the number of children370* @throw ProcessError if is called without be reimplemented in child class371*/372virtual bool checkChildAdditionalRestriction() const;373374/// @brief draw geometry point375void drawSemiCircleGeometryPoint(const GUIVisualizationSettings& s, const GUIVisualizationSettings::Detail d,376const Position& pos, const double rot, const RGBColor& baseColor,377const double fromAngle, const double toAngle, const bool ignoreShift) const;378379/// @brief Invalidated copy constructor.380GNEAdditional(const GNEAdditional&) = delete;381382/// @brief Invalidated assignment operator.383GNEAdditional& operator=(const GNEAdditional&) = delete;384};385386387