Path: blob/main/src/netedit/elements/demand/GNEContainer.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 GNEContainer.h14/// @author Pablo Alvarez Lopez15/// @date Jun 202116///17// Representation of containers in netedit18/****************************************************************************/19#pragma once20#include <config.h>2122#include <netedit/elements/GNEContour.h>23#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>2425#include "GNEDemandElement.h"26#include "GNEDemandElementFlow.h"2728// ===========================================================================29// class declaration30// ===========================================================================3132class GNEMoveElementPlanParent;3334// ===========================================================================35// class definitions36// ===========================================================================3738class GNEContainer : public GNEDemandElement, public GNEDemandElementFlow {3940public:41/// @brief class used in GUIGLObjectPopupMenu for container transformations42class GNEContainerPopupMenu : public GUIGLObjectPopupMenu {43FXDECLARE(GNEContainerPopupMenu)4445public:46/** @brief Constructor47* @param[in] container GNEContainer to be transformed48* @param[in] app The main window for instantiation of other windows49* @param[in] parent The parent view for changing it50*/51GNEContainerPopupMenu(GNEContainer* container, GUIMainWindow& app, GUISUMOAbstractView& parent);5253/// @brief Destructor54~GNEContainerPopupMenu();5556/// @brief Called to transform the current container to another container type57long onCmdTransform(FXObject* obj, FXSelector, void*);5859protected:60FOX_CONSTRUCTOR(GNEContainerPopupMenu)6162private:63/// @brief current container64GNEContainer* myContainer;6566/// @brief menu command for transform to container67FXMenuCommand* myTransformToContainer;6869/// @brief menu command for transform to containerFlow70FXMenuCommand* myTransformToContainerFlow;71};7273/// @brief class used in GUIGLObjectPopupMenu for single container transformations74class GNESelectedContainersPopupMenu : public GUIGLObjectPopupMenu {75FXDECLARE(GNESelectedContainersPopupMenu)7677public:78/** @brief Constructor79* @param[in] container clicked GNEContainer80* @param[in] selectedContainer vector with selected GNEContainer81* @param[in] app The main window for instantiation of other windows82* @param[in] parent The parent view for changing it83*/84GNESelectedContainersPopupMenu(GNEContainer* container, const std::vector<GNEContainer*>& selectedContainer, GUIMainWindow& app, GUISUMOAbstractView& parent);8586/// @brief Destructor87~GNESelectedContainersPopupMenu();8889/// @brief Called to transform the current container to another container type90long onCmdTransform(FXObject* obj, FXSelector, void*);9192protected:93FOX_CONSTRUCTOR(GNESelectedContainersPopupMenu)9495private:96/// @brief tag of clicked container97SumoXMLTag myContainerTag;9899/// @brief current selected containers100std::vector<GNEContainer*> mySelectedContainers;101102/// @brief menu command for transform to container103FXMenuCommand* myTransformToContainer;104105/// @brief menu command for transform to containerFlow106FXMenuCommand* myTransformToContainerFlow;107};108109/// @brief default constructor110GNEContainer(SumoXMLTag tag, GNENet* net);111112/// @brief constructor for containers113GNEContainer(SumoXMLTag tag, GNENet* net, FileBucket* fileBucket, GNEDemandElement* pType,114const SUMOVehicleParameter& containerparameters);115116/// @brief destructor117~GNEContainer();118119/// @brief methods to retrieve the elements linked to this container120/// @{121122/// @brief get GNEMoveElement associated with this container123GNEMoveElement* getMoveElement() const override;124125/// @brief get parameters associated with this container126Parameterised* getParameters() override;127128/// @brief get parameters associated with this container (constant)129const Parameterised* getParameters() const override;130131/// @}132133/**@brief write demand element element into a xml file134* @param[in] device device in which write parameters of demand element element135*/136void writeDemandElement(OutputDevice& device) const override;137138/// @brief check if current demand element is valid to be written into XML (by default true, can be reimplemented in children)139Problem isDemandElementValid() const override;140141/// @brief return a string with the current demand element problem (by default empty, can be reimplemented in children)142std::string getDemandElementProblem() const override;143144/// @brief fix demand element problem (by default throw an exception, has to be reimplemented in children)145void fixDemandElementProblem() override;146147/// @name members and functions relative to elements common to all demand elements148/// @{149/// @brief obtain VClass related with this demand element150SUMOVehicleClass getVClass() const override;151152/// @brief get color153const RGBColor& getColor() const override;154155/// @}156157/// @name Functions related with geometry of element158/// @{159/// @brief update pre-computed geometry information160void updateGeometry() override;161162/// @brief Returns position of demand element in view163Position getPositionInView() const override;164/// @}165166/// @name inherited from GUIGlObject167/// @{168/**@brief Returns an own popup-menu169*170* @param[in] app The application needed to build the popup-menu171* @param[in] parent The parent window needed to build the popup-menu172* @return The built popup-menu173* @see GUIGlObject::getPopUpMenu174*/175GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;176177/**@brief Returns the name of the parent object178* @return This object's parent id179*/180std::string getParentName() const override;181182/// @brief return exaggeration associated with this GLObject183double getExaggeration(const GUIVisualizationSettings& s) const override;184185/**@brief Returns the boundary to which the view shall be centered in order to show the object186* @return The boundary the object is within187*/188Boundary getCenteringBoundary() const override;189190/// @brief split geometry191void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) override;192193/**@brief Draws the object194* @param[in] s The settings for the current view (may influence drawing)195* @see GUIGlObject::drawGL196*/197void drawGL(const GUIVisualizationSettings& s) const override;198199/// @}200201/// @name inherited from GNEPathElement202/// @{203204/// @brief compute pathElement205void computePathElement() override;206207/**@brief Draws partial object over lane208* @param[in] s The settings for the current view (may influence drawing)209* @param[in] segment lane segment210* @param[in] offsetFront front offset211*/212void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;213214/**@brief Draws partial object over junction215* @param[in] s The settings for the current view (may influence drawing)216* @param[in] segment junction segment217* @param[in] offsetFront front offset218*/219void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;220221/// @brief get first path lane222GNELane* getFirstPathLane() const override;223224/// @brief get last path lane225GNELane* getLastPathLane() const override;226/// @}227228/// @brief inherited from GNEAttributeCarrier229/// @{230/* @brief method for getting the Attribute of an XML key231* @param[in] key The attribute key232* @return string with the value associated to key233*/234std::string getAttribute(SumoXMLAttr key) const override;235236/* @brief method for getting the Attribute of an XML key in double format237* @param[in] key The attribute key238* @return double with the value associated to key239*/240double getAttributeDouble(SumoXMLAttr key) const override;241242/* @brief method for getting the Attribute of an XML key in position format243* @param[in] key The attribute key244* @return position with the value associated to key245*/246Position getAttributePosition(SumoXMLAttr key) const override;247248/* @brief method for setting the attribute and letting the object perform demand element changes249* @param[in] key The attribute key250* @param[in] value The new value251* @param[in] undoList The undoList on which to register changes252* @param[in] net optionally the GNENet to inform about gui updates253*/254void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;255256/* @brief method for setting the attribute and letting the object perform demand element changes257* @param[in] key The attribute key258* @param[in] value The new value259* @param[in] undoList The undoList on which to register changes260*/261bool isValid(SumoXMLAttr key, const std::string& value) override;262263/* @brief method for enable attribute264* @param[in] key The attribute key265* @param[in] undoList The undoList on which to register changes266* @note certain attributes can be only enabled, and can produce the disabling of other attributes267*/268void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList) override;269270/* @brief method for disable attribute271* @param[in] key The attribute key272* @param[in] undoList The undoList on which to register changes273* @note certain attributes can be only enabled, and can produce the disabling of other attributes274*/275void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList) override;276277/* @brief method for check if the value for certain attribute is set278* @param[in] key The attribute key279*/280bool isAttributeEnabled(SumoXMLAttr key) const override;281282/// @brief get PopPup ID (Used in AC Hierarchy)283std::string getPopUpID() const override;284285/// @brief get Hierarchy Name (Used in AC Hierarchy)286std::string getHierarchyName() const override;287/// @}288289protected:290/// @brief move element plan parent291GNEMoveElementPlanParent* myMoveElementPlanParent = nullptr;292293/// @brief variable used for contours294GNEContour myContainerContour;295296/// @brief get drawing color297RGBColor getDrawingColor(const GUIVisualizationSettings& s) const;298299/// @brief draw container as poly300void drawAction_drawAsPoly() const;301302/// @brief draw container as image303void drawAction_drawAsImage(const GUIVisualizationSettings& s) const;304305private:306// @brief struct used for calculating container plan geometry segments307struct containerPlanSegment {308/// @brief parameter constructor309containerPlanSegment(GNEDemandElement* _containerPlan);310311/// @brief container plan312const GNEDemandElement* containerPlan;313314/// @brief edge315GNEEdge* edge;316317/// @brief busStops placed in this segment318std::vector<GNEAdditional*> busStops;319320/// @brief stops placed in this segment321std::vector<GNEDemandElement*> stops;322323/// @brief arrival position324double arrivalPos;325326private:327/// @brief constructor328containerPlanSegment();329};330331/// @brief method for setting the attribute and nothing else332void setAttribute(SumoXMLAttr key, const std::string& value) override;333334/// @brief method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)335void toggleAttribute(SumoXMLAttr key, const bool value) override;336337/// @brief Invalidated copy constructor.338GNEContainer(const GNEContainer&) = delete;339340/// @brief Invalidated assignment operator341GNEContainer& operator=(const GNEContainer&) = delete;342};343344345