LCOV - code coverage report
Current view: top level - src/guisim - GUIVehicle.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 50.0 % 8 4
Test Date: 2025-11-14 15:59:05 Functions: 50.0 % 4 2

            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    GUIVehicle.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 <string>
      28              : #include <utils/geom/PositionVector.h>
      29              : #include <microsim/MSVehicle.h>
      30              : #include "GUIBaseVehicle.h"
      31              : 
      32              : 
      33              : // ===========================================================================
      34              : // class declarations
      35              : // ===========================================================================
      36              : class GUISUMOAbstractView;
      37              : 
      38              : 
      39              : // ===========================================================================
      40              : // class definitions
      41              : // ===========================================================================
      42              : /**
      43              :  * @class GUIVehicle
      44              :  * @brief A MSVehicle extended by some values for usage within the gui
      45              :  *
      46              :  * A visualisable MSVehicle. Extended by the possibility to retrieve names
      47              :  * of all available vehicles (static) and the possibility to retrieve the
      48              :  * color of the vehicle which is available in different forms allowing an
      49              :  * easier recognition of done actions such as lane changing.
      50              :  */
      51              : class GUIVehicle : public MSVehicle, public GUIBaseVehicle {
      52              : public:
      53              :     /** @brief Constructor
      54              :      * @param[in] pars The vehicle description
      55              :      * @param[in] route The vehicle's route
      56              :      * @param[in] type The vehicle's type
      57              :      * @param[in] speedFactor The factor for driven lane's speed limits
      58              :      * @exception ProcessError If a value is wrong
      59              :      */
      60              :     GUIVehicle(SUMOVehicleParameter* pars, ConstMSRoutePtr route,
      61              :                MSVehicleType* type, const double speedFactor);
      62              : 
      63              : 
      64              :     /// @brief destructor
      65              :     ~GUIVehicle();
      66              : 
      67              :     /** @brief Return current position (x/y, cartesian)
      68              :      *
      69              :      * @note implementation of abstract method does not work otherwise
      70              :      */
      71    129553680 :     Position getPosition(const double offset = 0) const override {
      72    129553680 :         return MSVehicle::getPosition(offset);
      73              :     }
      74              : 
      75              :     Position getVisualPosition(bool s2, const double offset = 0) const override;
      76              : 
      77              :     /** @brief Return current angle
      78              :      *
      79              :      * @note implementation of abstract method does not work otherwise
      80              :      */
      81    102775075 :     double getAngle() const override {
      82    102775075 :         return MSVehicle::getAngle();
      83              :     }
      84              : 
      85              :     /** @brief Returns the vehicle's direction in radians taking into account
      86              :      * secondary shape
      87              :      * @return The vehicle's current angle
      88              :      */
      89              :     double getVisualAngle(bool s2) const override;
      90              : 
      91              :     /** @brief Draws the route
      92              :      * @param[in] r The route to draw
      93              :      */
      94              :     void drawRouteHelper(const GUIVisualizationSettings& s, ConstMSRoutePtr r, bool future,
      95              :                          bool noLoop, const RGBColor& col) const override;
      96              : 
      97              :     void drawAction_drawVehicleBlinker(double length) const override;
      98              :     void drawAction_drawVehicleBrakeLight(double length, bool onlyOne = false) const override;
      99              :     void drawAction_drawLinkItems(const GUIVisualizationSettings& s) const override;
     100              :     void drawAction_drawVehicleBlueLight() const override;
     101              : 
     102              :     /** @brief Returns the time since the last lane change in seconds
     103              :      * @see MSVehicle::myLastLaneChangeOffset
     104              :      * @return The time since the last lane change in seconds
     105              :      */
     106              :     double getLastLaneChangeOffset() const override;
     107              : 
     108              :     /// @brief Draws the vehicle's best lanes
     109              :     void drawBestLanes() const override;
     110              :     /// @}
     111              : 
     112              :     /// @brief adds the blocking foes to the current selection
     113              :     void selectBlockingFoes() const override;
     114              : 
     115              :     /// @brief gets the color value according to the current scheme index
     116              :     double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
     117              : 
     118              :     /** @brief Returns an own parameter window
     119              :      *
     120              :      * @param[in] app The application needed to build the parameter window
     121              :      * @param[in] parent The parent window needed to build the parameter window
     122              :      * @return The built parameter window
     123              :      * @see GUIGlObject::getParameterWindow
     124              :      */
     125              :     GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
     126              : 
     127              :     /** @brief Returns an own type parameter window
     128              :      *
     129              :      * @param[in] app The application needed to build the parameter window
     130              :      * @param[in] parent The parent window needed to build the parameter window
     131              :      * @return The built parameter window
     132              :      */
     133              :     GUIParameterTableWindow* getTypeParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
     134              : 
     135              :     /// @brief whether this vehicle is selected in the GUI
     136              :     bool isSelected() const override;
     137              : 
     138              :     /// @brief return right vehicle side on current edge (without argument)
     139            0 :     double getRightSideOnEdge2() const {
     140            0 :         return getRightSideOnEdge();
     141              :     }
     142              : 
     143              :     /// @brief return left vehicle side on current edge
     144            0 :     double getLeftSideOnEdge() const {
     145            0 :         return getRightSideOnEdge() + getVehicleType().getWidth();
     146              :     }
     147              : 
     148              :     /// @brief return the righmost sublane on the edge occupied by the vehicle
     149              :     int getRightSublaneOnEdge() const;
     150              :     int getLeftSublaneOnEdge() const;
     151              : 
     152              :     /// @brief return the lanechange state
     153              :     std::string getLCStateRight() const;
     154              :     std::string getLCStateLeft() const;
     155              :     std::string getLCStateCenter() const;
     156              : 
     157              :     /// @brief return vehicle lane id
     158              :     std::string getLaneID() const;
     159              :     std::string getBackLaneIDs() const;
     160              :     std::string getShadowLaneID() const;
     161              :     std::string getTargetLaneID() const;
     162              : 
     163              :     std::string getDriveWays() const;
     164              : 
     165              :     /// @brief return the lane-change maneuver distance
     166              :     double getManeuverDist() const;
     167              :     /// @brief return the speed mode as bit string
     168              :     std::string getSpeedMode() const;
     169              :     /// @brief return the lane change mode as bit string
     170              :     std::string getLaneChangeMode() const;
     171              : 
     172              :     /// @brief return the current lateral alignment as string
     173              :     std::string getDynamicAlignment() const;
     174              : 
     175              :     /// @brief handle route to accomodate to given stop
     176              :     void rerouteDRTStop(MSStoppingPlace* busStop);
     177              : 
     178              : protected:
     179              :     /// @brief register vehicle for drawing while outside the network
     180              :     void drawOutsideNetwork(bool add) override;
     181              : 
     182              : private:
     183              :     /* @brief draw train with individual carriages. The number of carriages is
     184              :      * determined from defaultLength of carriages and vehicle length
     185              :      * passengerSeats are computed beginning at firstPassengerCarriage */
     186              :     void drawAction_drawCarriageClass(const GUIVisualizationSettings& s, double scaledLength, bool asImage) const override;
     187              : 
     188              :     /// @brief retrieve information about the current stop state
     189              :     std::string getStopInfo() const override;
     190              : };
        

Generated by: LCOV version 2.0-1