LCOV - code coverage report
Current view: top level - src/guisim - GUIPerson.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 50.0 % 4 2
Test Date: 2025-07-30 21:30:17 Functions: 50.0 % 2 1

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    GUIPerson.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Sascha Krieg
      18              : /// @author  Michael Behrisch
      19              : /// @date    Sept 2002
      20              : ///
      21              : // A MSVehicle extended by some values for usage within the gui
      22              : /****************************************************************************/
      23              : #pragma once
      24              : #include <config.h>
      25              : 
      26              : #include <vector>
      27              : #include <set>
      28              : #include <string>
      29              : #include <utils/foxtools/fxheader.h>
      30              : #include <utils/gui/globjects/GUIGlObject.h>
      31              : #include <utils/common/RGBColor.h>
      32              : #include <microsim/transportables/MSPerson.h>
      33              : #include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
      34              : #include <utils/gui/settings/GUIPropertySchemeStorage.h>
      35              : #include "GUIBaseVehicle.h"
      36              : 
      37              : 
      38              : // ===========================================================================
      39              : // class declarations
      40              : // ===========================================================================
      41              : class GUISUMOAbstractView;
      42              : class GUIGLObjectPopupMenu;
      43              : class MSDevice_Vehroutes;
      44              : 
      45              : 
      46              : // ===========================================================================
      47              : // class definitions
      48              : // ===========================================================================
      49              : /**
      50              :  * @class GUIPerson
      51              :  */
      52              : class GUIPerson : public MSPerson, public GUIGlObject {
      53              : 
      54              : public:
      55              :     /// @brief Constructor
      56              :     GUIPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan, const double speedFactor);
      57              : 
      58              :     /// @brief destructor
      59              :     ~GUIPerson();
      60              : 
      61              :     /// @name inherited from GUIGlObject
      62              :     /// @{
      63              :     /** @brief Returns an own popup-menu
      64              :      *
      65              :      * @param[in] app The application needed to build the popup-menu
      66              :      * @param[in] parent The parent window needed to build the popup-menu
      67              :      * @return The built popup-menu
      68              :      * @see GUIGlObject::getPopUpMenu
      69              :      */
      70              :     GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
      71              : 
      72              :     /** @brief Returns an own parameter window
      73              :      *
      74              :      * @param[in] app The application needed to build the parameter window
      75              :      * @param[in] parent The parent window needed to build the parameter window
      76              :      * @return The built parameter window
      77              :      * @see GUIGlObject::getParameterWindow
      78              :      */
      79              :     GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
      80              : 
      81              :     /** @brief Returns an own type parameter window
      82              :      *
      83              :      * @param[in] app The application needed to build the parameter window
      84              :      * @param[in] parent The parent window needed to build the parameter window
      85              :      * @return The built parameter window
      86              :      */
      87              :     GUIParameterTableWindow* getTypeParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
      88              : 
      89              :     /// @brief return exaggeration associated with this GLObject
      90              :     double getExaggeration(const GUIVisualizationSettings& s) const override;
      91              : 
      92              :     /** @brief Returns the boundary to which the view shall be centered in order to show the object
      93              :      *
      94              :      * @return The boundary the object is within
      95              :      * @see GUIGlObject::getCenteringBoundary
      96              :      */
      97              :     Boundary getCenteringBoundary() const override;
      98              : 
      99              :     /** @brief Draws the object
     100              :      * @param[in] s The settings for the current view (may influence drawing)
     101              :      * @see GUIGlObject::drawGL
     102              :      */
     103              :     void drawGL(const GUIVisualizationSettings& s) const override;
     104              : 
     105              :     /** @brief Draws additionally triggered visualisations
     106              :      * @param[in] parent The view
     107              :      * @param[in] s The settings for the current view (may influence drawing)
     108              :      */
     109              :     virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const override;
     110              :     //* @}
     111              : 
     112              :     /* @brief proceeds to the next step of the route,
     113              :      * @return Whether the transportables plan continues  */
     114              :     bool proceed(MSNet* net, SUMOTime time, const bool vehicleArrived = false) override;
     115              : 
     116              :     /* @brief set the position of a person while riding in a vehicle
     117              :      * @note This must be called by the vehicle before the call to drawGl */
     118              :     void setPositionInVehicle(const GUIBaseVehicle::Seat& pos);
     119              : 
     120              :     /// @name inherited from MSPerson with added locking
     121              :     /// @{
     122              :     /// @brief return the offset from the start of the current edge
     123              :     double getEdgePos() const override;
     124              : 
     125              :     /// @brief Return the movement directon on the edge
     126              :     int getDirection() const override;
     127              : 
     128              :     /// @brief return the Network coordinate of the person
     129              :     // @note overrides the base method and returns myPositionInVehicle while in driving stage
     130              :     Position getPosition() const override;
     131              : 
     132              :     /// @brief return the Network coordinate of the person (only for drawing centering and tracking)
     133              :     Position getGUIPosition(const GUIVisualizationSettings* s = nullptr) const;
     134              : 
     135              :     /// @brief return the angle of the person (only for drawing centering and tracking)
     136              :     double getGUIAngle() const;
     137              : 
     138              :     /// @brief return the current angle of the person
     139              :     double getNaviDegree() const;
     140              : 
     141              :     /// @brief the time this person spent waiting in seconds
     142              :     double getWaitingSeconds() const override;
     143              : 
     144              :     /// @brief the current speed of the person
     145              :     double getSpeed() const override;
     146              : 
     147              :     /// @brief get stage index description
     148              :     std::string getStageIndexDescription() const;
     149              : 
     150              :     /// @brief get edge ID
     151              :     std::string getEdgeID() const;
     152              : 
     153              :     /// @brief get lane ID
     154              :     std::string getLaneID() const;
     155              : 
     156              :     /// @brief get from edge ID
     157              :     std::string getFromEdgeID() const;
     158              : 
     159              :     /// @brief get destination edge ID
     160              :     std::string getDestinationEdgeID() const;
     161              : 
     162              :     /// @brief get destination stop ID
     163              :     std::string getDestinationStopID() const;
     164              : 
     165              :     /// @brief get current vehicle id if applicable
     166              :     std::string getVehicleID() const;
     167              : 
     168              :     /// @brief get remaining duration of current stop or -1
     169              :     double getStopDuration() const;
     170              : 
     171              :     /// @brief get stage arrival position
     172              :     double getStageArrivalPos() const;
     173              : 
     174              :     //@}
     175              : 
     176              :     /// @brief whether this person is selected in the GUI
     177              :     bool isSelected() const override;
     178              : 
     179              :     /// @brief sets the color according to the current scheme index and some vehicle function
     180              :     static bool setFunctionalColor(int activeScheme, const MSPerson* person, RGBColor& col);
     181              : 
     182              :     /// @brief gets the color value according to the current scheme index
     183              :     double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
     184              : 
     185      1231591 :     double getScaleVisual() const override {
     186      1231591 :         return getVehicleType().getParameter().scaleVisual;
     187              :     }
     188              : 
     189              :     /**
     190              :      * @class GUIPersonPopupMenu
     191              :      *
     192              :      * A popup-menu for vehicles. In comparison to the normal popup-menu, this one
     193              :      *  also allows to trigger further visualisations and to track the vehicle.
     194              :      */
     195              :     class GUIPersonPopupMenu : public GUIGLObjectPopupMenu {
     196            0 :         FXDECLARE(GUIPersonPopupMenu)
     197              : 
     198              :     public:
     199              :         /** @brief Constructor
     200              :          * @param[in] app The main window for instantiation of other windows
     201              :          * @param[in] parent The parent view for changing it
     202              :          * @param[in] o The object of interest
     203              :          */
     204              :         GUIPersonPopupMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, GUIGlObject* o);
     205              : 
     206              :         /// @brief Destructor
     207              :         ~GUIPersonPopupMenu();
     208              : 
     209              :         /// @brief Called if the current route of the person shall be shown
     210              :         long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
     211              : 
     212              :         /// @brief Called if the current route of the person shall be hidden
     213              :         long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
     214              : 
     215              :         /// @brief Called if the walkingarea path of the person shall be shown
     216              :         long onCmdShowWalkingareaPath(FXObject*, FXSelector, void*);
     217              : 
     218              :         /// @brief Called if the walkingarea path of the person shall be hidden
     219              :         long onCmdHideWalkingareaPath(FXObject*, FXSelector, void*);
     220              : 
     221              :         /// @brief Called if the plan shall be shown
     222              :         long onCmdShowPlan(FXObject*, FXSelector, void*);
     223              : 
     224              :         /// @brief Called if the person shall be tracked
     225              :         long onCmdStartTrack(FXObject*, FXSelector, void*);
     226              : 
     227              :         /// @brief Called if the person shall not be tracked any longer
     228              :         long onCmdStopTrack(FXObject*, FXSelector, void*);
     229              : 
     230              :         /// @brief Called when removing the person
     231              :         long onCmdRemoveObject(FXObject*, FXSelector, void*);
     232              : 
     233              :     protected:
     234              :         /// @brief default constructor needed by FOX
     235            0 :         FOX_CONSTRUCTOR(GUIPersonPopupMenu)
     236              :     };
     237              : 
     238              :     /// @brief Additional visualisation feature ids
     239              :     enum VisualisationFeatures {
     240              :         /// @brief show the current walkingarea path
     241              :         VO_SHOW_WALKINGAREA_PATH = 1,
     242              :         /// @brief show persons's current route
     243              :         VO_SHOW_ROUTE = 2,
     244              :         /// @brief track person
     245              :         VO_TRACKED = 8
     246              :     };
     247              : 
     248              :     /// @name Additional visualisations
     249              :     /// @{
     250              :     /** @brief Returns whether the named feature is enabled in the given view
     251              :      * @param[in] parent The view for which the feature may be enabled
     252              :      * @param[in] which The visualisation feature
     253              :      * @return see comment
     254              :      */
     255              :     bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
     256              : 
     257              :     /** @brief Adds the named visualisation feature to the given view
     258              :      * @param[in] parent The view for which the feature shall be enabled
     259              :      * @param[in] which The visualisation feature to enable
     260              :      * @see GUISUMOAbstractView::addAdditionalGLVisualisation
     261              :      */
     262              :     void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
     263              : 
     264              :     /** @brief Adds the named visualisation feature to the given view
     265              :      * @param[in] parent The view for which the feature shall be enabled
     266              :      * @param[in] which The visualisation feature to enable
     267              :      * @see GUISUMOAbstractView::removeAdditionalGLVisualisation
     268              :      */
     269              :     void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) override;
     270              : 
     271              :     /// @}
     272              : 
     273              : private:
     274              :     /// @brief sets the color according to the currente settings
     275              :     void setColor(const GUIVisualizationSettings& s) const;
     276              : 
     277              :     /// @brief draw walking area path
     278              :     void drawAction_drawWalkingareaPath(const GUIVisualizationSettings& s) const;
     279              : 
     280              :     /// The mutex used to avoid concurrent updates of the vehicle buffer
     281              :     mutable FXMutex myLock;
     282              : 
     283              :     /// The position of a person while riding a vehicle
     284              :     GUIBaseVehicle::Seat myPositionInVehicle;
     285              : 
     286              :     /// @brief Enabled visualisations, per view
     287              :     std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
     288              : };
        

Generated by: LCOV version 2.0-1