LCOV - code coverage report
Current view: top level - src/guisim - GUIVehicle.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 60.0 % 10 6
Test Date: 2026-03-02 16:00:03 Functions: 60.0 % 5 3

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

Generated by: LCOV version 2.0-1