/****************************************************************************/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 GUIPerson.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Sascha Krieg17/// @author Michael Behrisch18/// @date Sept 200219///20// A MSVehicle extended by some values for usage within the gui21/****************************************************************************/22#pragma once23#include <config.h>2425#include <vector>26#include <set>27#include <string>28#include <utils/foxtools/fxheader.h>29#include <utils/gui/globjects/GUIGlObject.h>30#include <utils/common/RGBColor.h>31#include <microsim/transportables/MSPerson.h>32#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>33#include <utils/gui/settings/GUIPropertySchemeStorage.h>34#include "GUIBaseVehicle.h"353637// ===========================================================================38// class declarations39// ===========================================================================40class GUISUMOAbstractView;41class GUIGLObjectPopupMenu;42class MSDevice_Vehroutes;434445// ===========================================================================46// class definitions47// ===========================================================================48/**49* @class GUIPerson50*/51class GUIPerson : public MSPerson, public GUIGlObject {5253public:54/// @brief Constructor55GUIPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan, const double speedFactor);5657/// @brief destructor58~GUIPerson();5960/// @name inherited from GUIGlObject61/// @{62/** @brief Returns an own popup-menu63*64* @param[in] app The application needed to build the popup-menu65* @param[in] parent The parent window needed to build the popup-menu66* @return The built popup-menu67* @see GUIGlObject::getPopUpMenu68*/69GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;7071/** @brief Returns an own parameter window72*73* @param[in] app The application needed to build the parameter window74* @param[in] parent The parent window needed to build the parameter window75* @return The built parameter window76* @see GUIGlObject::getParameterWindow77*/78GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;7980/** @brief Returns an own type parameter window81*82* @param[in] app The application needed to build the parameter window83* @param[in] parent The parent window needed to build the parameter window84* @return The built parameter window85*/86GUIParameterTableWindow* getTypeParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;8788/// @brief return exaggeration associated with this GLObject89double getExaggeration(const GUIVisualizationSettings& s) const override;9091/** @brief Returns the boundary to which the view shall be centered in order to show the object92*93* @return The boundary the object is within94* @see GUIGlObject::getCenteringBoundary95*/96Boundary getCenteringBoundary() const override;9798/** @brief Draws the object99* @param[in] s The settings for the current view (may influence drawing)100* @see GUIGlObject::drawGL101*/102void drawGL(const GUIVisualizationSettings& s) const override;103104/** @brief Draws additionally triggered visualisations105* @param[in] parent The view106* @param[in] s The settings for the current view (may influence drawing)107*/108virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const override;109//* @}110111/* @brief proceeds to the next step of the route,112* @return Whether the transportables plan continues */113bool proceed(MSNet* net, SUMOTime time, const bool vehicleArrived = false) override;114115/* @brief set the position of a person while riding in a vehicle116* @note This must be called by the vehicle before the call to drawGl */117void setPositionInVehicle(const GUIBaseVehicle::Seat& pos);118119/// @name inherited from MSPerson with added locking120/// @{121/// @brief return the offset from the start of the current edge122double getEdgePos() const override;123124/// @brief Return the movement directon on the edge125int getDirection() const override;126127/// @brief return the Network coordinate of the person128// @note overrides the base method and returns myPositionInVehicle while in driving stage129Position getPosition() const override;130131/// @brief return the Network coordinate of the person (only for drawing centering and tracking)132Position getGUIPosition(const GUIVisualizationSettings* s = nullptr) const;133134/// @brief return the angle of the person (only for drawing centering and tracking)135double getGUIAngle() const;136137/// @brief return the current angle of the person138double getNaviDegree() const;139140/// @brief the time this person spent waiting in seconds141double getWaitingSeconds() const override;142143/// @brief the current speed of the person144double getSpeed() const override;145146/// @brief get stage index description147std::string getStageIndexDescription() const;148149/// @brief get edge ID150std::string getEdgeID() const;151152/// @brief get lane ID153std::string getLaneID() const;154155/// @brief get from edge ID156std::string getFromEdgeID() const;157158/// @brief get destination edge ID159std::string getDestinationEdgeID() const;160161/// @brief get destination stop ID162std::string getDestinationStopID() const;163164/// @brief get current vehicle id if applicable165std::string getVehicleID() const;166167/// @brief get remaining duration of current stop or -1168double getStopDuration() const;169170/// @brief get stage arrival position171double getStageArrivalPos() const;172173//@}174175/// @brief whether this person is selected in the GUI176bool isSelected() const override;177178/// @brief sets the color according to the current scheme index and some vehicle function179static bool setFunctionalColor(int activeScheme, const MSPerson* person, RGBColor& col);180181/// @brief gets the color value according to the current scheme index182double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;183184double getScaleVisual() const override {185return getVehicleType().getParameter().scaleVisual;186}187188/**189* @class GUIPersonPopupMenu190*191* A popup-menu for vehicles. In comparison to the normal popup-menu, this one192* also allows to trigger further visualisations and to track the vehicle.193*/194class GUIPersonPopupMenu : public GUIGLObjectPopupMenu {195FXDECLARE(GUIPersonPopupMenu)196197public:198/** @brief Constructor199* @param[in] app The main window for instantiation of other windows200* @param[in] parent The parent view for changing it201* @param[in] o The object of interest202*/203GUIPersonPopupMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, GUIGlObject* o);204205/// @brief Destructor206~GUIPersonPopupMenu();207208/// @brief Called if the current route of the person shall be shown209long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);210211/// @brief Called if the current route of the person shall be hidden212long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);213214/// @brief Called if the walkingarea path of the person shall be shown215long onCmdShowWalkingareaPath(FXObject*, FXSelector, void*);216217/// @brief Called if the walkingarea path of the person shall be hidden218long onCmdHideWalkingareaPath(FXObject*, FXSelector, void*);219220/// @brief Called if the plan shall be shown221long onCmdShowPlan(FXObject*, FXSelector, void*);222223/// @brief Called if the person shall be tracked224long onCmdStartTrack(FXObject*, FXSelector, void*);225226/// @brief Called if the person shall not be tracked any longer227long onCmdStopTrack(FXObject*, FXSelector, void*);228229/// @brief Called when removing the person230long onCmdRemoveObject(FXObject*, FXSelector, void*);231232protected:233/// @brief default constructor needed by FOX234FOX_CONSTRUCTOR(GUIPersonPopupMenu)235};236237/// @brief Additional visualisation feature ids238enum VisualisationFeatures {239/// @brief show the current walkingarea path240VO_SHOW_WALKINGAREA_PATH = 1,241/// @brief show persons's current route242VO_SHOW_ROUTE = 2,243/// @brief track person244VO_TRACKED = 8245};246247/// @name Additional visualisations248/// @{249/** @brief Returns whether the named feature is enabled in the given view250* @param[in] parent The view for which the feature may be enabled251* @param[in] which The visualisation feature252* @return see comment253*/254bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;255256/** @brief Adds the named visualisation feature to the given view257* @param[in] parent The view for which the feature shall be enabled258* @param[in] which The visualisation feature to enable259* @see GUISUMOAbstractView::addAdditionalGLVisualisation260*/261void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);262263/** @brief Adds the named visualisation feature to the given view264* @param[in] parent The view for which the feature shall be enabled265* @param[in] which The visualisation feature to enable266* @see GUISUMOAbstractView::removeAdditionalGLVisualisation267*/268void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) override;269270/// @}271272private:273/// @brief sets the color according to the currente settings274void setColor(const GUIVisualizationSettings& s) const;275276/// @brief draw walking area path277void drawAction_drawWalkingareaPath(const GUIVisualizationSettings& s) const;278279/// The mutex used to avoid concurrent updates of the vehicle buffer280mutable FXMutex myLock;281282/// The position of a person while riding a vehicle283GUIBaseVehicle::Seat myPositionInVehicle;284285/// @brief Enabled visualisations, per view286std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;287};288289290