/****************************************************************************/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 GNEPerson.h14/// @author Pablo Alvarez Lopez15/// @date May 201916///17// Representation of persons in netedit18/****************************************************************************/19#pragma once20#include <config.h>21#include <netedit/elements/GNEContour.h>22#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>2324#include "GNEDemandElement.h"25#include "GNEDemandElementFlow.h"2627// ===========================================================================28// class declaration29// ===========================================================================3031class GNEMoveElementPlanParent;3233// ===========================================================================34// class definitions35// ===========================================================================3637class GNEPerson : public GNEDemandElement, public GNEDemandElementFlow {3839public:40/// @brief class used in GUIGLObjectPopupMenu for person transformations41class GNEPersonPopupMenu : public GUIGLObjectPopupMenu {42FXDECLARE(GNEPersonPopupMenu)4344public:45/** @brief Constructor46* @param[in] person GNEPerson to be transformed47* @param[in] app The main window for instantiation of other windows48* @param[in] parent The parent view for changing it49*/50GNEPersonPopupMenu(GNEPerson* person, GUIMainWindow& app, GUISUMOAbstractView& parent);5152/// @brief Destructor53~GNEPersonPopupMenu();5455/// @brief Called to transform the current person to another person type56long onCmdTransform(FXObject* obj, FXSelector, void*);5758protected:59FOX_CONSTRUCTOR(GNEPersonPopupMenu)6061private:62/// @brief current person63GNEPerson* myPerson;6465/// @brief menu command for transform to person66FXMenuCommand* myTransformToPerson;6768/// @brief menu command for transform to personFlow69FXMenuCommand* myTransformToPersonFlow;70};7172/// @brief class used in GUIGLObjectPopupMenu for single person transformations73class GNESelectedPersonsPopupMenu : public GUIGLObjectPopupMenu {74FXDECLARE(GNESelectedPersonsPopupMenu)7576public:77/** @brief Constructor78* @param[in] person clicked GNEPerson79* @param[in] selectedPerson vector with selected GNEPerson80* @param[in] app The main window for instantiation of other windows81* @param[in] parent The parent view for changing it82*/83GNESelectedPersonsPopupMenu(GNEPerson* person, const std::vector<GNEPerson*>& selectedPerson, GUIMainWindow& app, GUISUMOAbstractView& parent);8485/// @brief Destructor86~GNESelectedPersonsPopupMenu();8788/// @brief Called to transform the current person to another person type89long onCmdTransform(FXObject* obj, FXSelector, void*);9091protected:92FOX_CONSTRUCTOR(GNESelectedPersonsPopupMenu)9394private:95/// @brief tag of clicked person96SumoXMLTag myPersonTag;9798/// @brief current selected persons99std::vector<GNEPerson*> mySelectedPersons;100101/// @brief menu command for transform to person102FXMenuCommand* myTransformToPerson;103104/// @brief menu command for transform to personFlow105FXMenuCommand* myTransformToPersonFlow;106};107108/// @brief default constructor109GNEPerson(SumoXMLTag tag, GNENet* net);110111/// @brief constructor for persons112GNEPerson(SumoXMLTag tag, GNENet* net, FileBucket* fileBucket, GNEDemandElement* pType,113const SUMOVehicleParameter& personparameters);114115/// @brief destructor116~GNEPerson();117118/// @brief methods to retrieve the elements linked to this person119/// @{120121/// @brief get GNEMoveElement associated with this person122GNEMoveElement* getMoveElement() const override;123124/// @brief get parameters associated with this person125Parameterised* getParameters() override;126127/// @brief get parameters associated with this person (constant)128const Parameterised* getParameters() const override;129130/// @}131132/**@brief write demand element element into a xml file133* @param[in] device device in which write parameters of demand element element134*/135void writeDemandElement(OutputDevice& device) const override;136137/// @brief check if current demand element is valid to be written into XML (by default true, can be reimplemented in children)138Problem isDemandElementValid() const override;139140/// @brief return a string with the current demand element problem (by default empty, can be reimplemented in children)141std::string getDemandElementProblem() const override;142143/// @brief fix demand element problem (by default throw an exception, has to be reimplemented in children)144void fixDemandElementProblem() override;145146/// @name members and functions relative to elements common to all demand elements147/// @{148/// @brief obtain VClass related with this demand element149SUMOVehicleClass getVClass() const override;150151/// @brief get color152const RGBColor& getColor() const override;153154/// @}155156/// @name Functions related with geometry of element157/// @{158/// @brief update pre-computed geometry information159void updateGeometry() override;160161/// @brief Returns position of demand element in view162Position getPositionInView() const override;163/// @}164165/// @name inherited from GUIGlObject166/// @{167/**@brief Returns an own popup-menu168*169* @param[in] app The application needed to build the popup-menu170* @param[in] parent The parent window needed to build the popup-menu171* @return The built popup-menu172* @see GUIGlObject::getPopUpMenu173*/174GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;175176/**@brief Returns the name of the parent object177* @return This object's parent id178*/179std::string getParentName() const override;180181/// @brief return exaggeration associated with this GLObject182double getExaggeration(const GUIVisualizationSettings& s) const override;183184/**@brief Returns the boundary to which the view shall be centered in order to show the object185* @return The boundary the object is within186*/187Boundary getCenteringBoundary() const override;188189/// @brief split geometry190void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) override;191192/**@brief Draws the object193* @param[in] s The settings for the current view (may influence drawing)194* @see GUIGlObject::drawGL195*/196void drawGL(const GUIVisualizationSettings& s) const override;197198/// @}199200/// @name inherited from GNEPathElement201/// @{202203/// @brief compute pathElement204void computePathElement() override;205206/**@brief Draws partial object over lane207* @param[in] s The settings for the current view (may influence drawing)208* @param[in] segment lane segment209* @param[in] offsetFront front offset210*/211void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;212213/**@brief Draws partial object over junction214* @param[in] s The settings for the current view (may influence drawing)215* @param[in] segment junction segment216* @param[in] offsetFront front offset217*/218void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const override;219220/// @brief get first path lane221GNELane* getFirstPathLane() const override;222223/// @brief get last path lane224GNELane* getLastPathLane() const override;225/// @}226227/// @brief inherited from GNEAttributeCarrier228/// @{229/* @brief method for getting the Attribute of an XML key230* @param[in] key The attribute key231* @return string with the value associated to key232*/233std::string getAttribute(SumoXMLAttr key) const override;234235/* @brief method for getting the Attribute of an XML key in double format236* @param[in] key The attribute key237* @return double with the value associated to key238*/239double getAttributeDouble(SumoXMLAttr key) const override;240241/* @brief method for getting the Attribute of an XML key in position format242* @param[in] key The attribute key243* @return position with the value associated to key244*/245Position getAttributePosition(SumoXMLAttr key) const override;246247/* @brief method for setting the attribute and letting the object perform demand element changes248* @param[in] key The attribute key249* @param[in] value The new value250* @param[in] undoList The undoList on which to register changes251* @param[in] net optionally the GNENet to inform about gui updates252*/253void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;254255/* @brief method for setting the attribute and letting the object perform demand element changes256* @param[in] key The attribute key257* @param[in] value The new value258* @param[in] undoList The undoList on which to register changes259*/260bool isValid(SumoXMLAttr key, const std::string& value) override;261262/* @brief method for enable attribute263* @param[in] key The attribute key264* @param[in] undoList The undoList on which to register changes265* @note certain attributes can be only enabled, and can produce the disabling of other attributes266*/267void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList) override;268269/* @brief method for disable attribute270* @param[in] key The attribute key271* @param[in] undoList The undoList on which to register changes272* @note certain attributes can be only enabled, and can produce the disabling of other attributes273*/274void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList) override;275276/* @brief method for check if the value for certain attribute is set277* @param[in] key The attribute key278*/279bool isAttributeEnabled(SumoXMLAttr key) const override;280281/// @brief get PopPup ID (Used in AC Hierarchy)282std::string getPopUpID() const override;283284/// @brief get Hierarchy Name (Used in AC Hierarchy)285std::string getHierarchyName() const override;286/// @}287288protected:289/// @brief move element plan parent290GNEMoveElementPlanParent* myMoveElementPlanParent = nullptr;291292/// @brief variable used for contours293GNEContour myPersonContour;294295/// @brief get drawing color296RGBColor getDrawingColor(const GUIVisualizationSettings& s) const;297298private:299// @brief struct used for calculating person plan geometry segments300struct personPlanSegment {301/// @brief parameter constructor302personPlanSegment(GNEDemandElement* _personPlan);303304/// @brief person plan305const GNEDemandElement* personPlan;306307/// @brief edge308GNEEdge* edge;309310/// @brief busStops placed in this segment311std::vector<GNEAdditional*> busStops;312313/// @brief stops placed in this segment314std::vector<GNEDemandElement*> stops;315316/// @brief arrival position317double arrivalPos;318319private:320/// @brief constructor321personPlanSegment();322};323324/// @brief method for setting the attribute and nothing else325void setAttribute(SumoXMLAttr key, const std::string& value) override;326327/// @brief method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)328void toggleAttribute(SumoXMLAttr key, const bool value) override;329330/// @brief Invalidated copy constructor.331GNEPerson(const GNEPerson&) = delete;332333/// @brief Invalidated assignment operator334GNEPerson& operator=(const GNEPerson&) = delete;335};336337338