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: 2024-11-22 15:46:21 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-2024 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    120823617 :     Position getPosition(const double offset = 0) const {
      72    120823617 :         return MSVehicle::getPosition(offset);
      73              :     }
      74              : 
      75              :     Position getVisualPosition(bool s2, const double offset = 0) const;
      76              : 
      77              :     /** @brief Return current angle
      78              :      *
      79              :      * @note implementation of abstract method does not work otherwise
      80              :      */
      81     11226837 :     double getAngle() const {
      82     11226837 :         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;
      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, bool noLoop, const RGBColor& col) const;
      95              : 
      96              :     void drawAction_drawVehicleBlinker(double length) const;
      97              :     void drawAction_drawVehicleBrakeLight(double length, bool onlyOne = false) const;
      98              :     void drawAction_drawLinkItems(const GUIVisualizationSettings& s) const;
      99              :     void drawAction_drawVehicleBlueLight() const;
     100              : 
     101              :     /** @brief Returns the time since the last lane change in seconds
     102              :      * @see MSVehicle::myLastLaneChangeOffset
     103              :      * @return The time since the last lane change in seconds
     104              :      */
     105              :     double getLastLaneChangeOffset() const;
     106              : 
     107              : 
     108              :     /** @brief Draws the vehicle's best lanes
     109              :      */
     110              :     void drawBestLanes() const;
     111              :     /// @}
     112              : 
     113              :     /// @brief adds the blocking foes to the current selection
     114              :     void selectBlockingFoes() const;
     115              : 
     116              :     /// @brief gets the color value according to the current scheme index
     117              :     double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const;
     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);
     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);
     135              : 
     136              :     /// @brief whether this vehicle is selected in the GUI
     137              :     bool isSelected() const;
     138              : 
     139              :     /// @brief return right vehicle side on current edge (without argument)
     140            0 :     double getRightSideOnEdge2() const {
     141            0 :         return getRightSideOnEdge();
     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);
     181              : 
     182              : private:
     183              : 
     184              :     /* @brief draw train with individual carriages. The number of carriages is
     185              :      * determined from defaultLength of carriages and vehicle length
     186              :      * passengerSeats are computed beginning at firstPassengerCarriage */
     187              :     void drawAction_drawCarriageClass(const GUIVisualizationSettings& s, bool asImage) const;
     188              : 
     189              :     /// @brief retrieve information about the current stop state
     190              :     std::string getStopInfo() const;
     191              : 
     192              : };
        

Generated by: LCOV version 2.0-1