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 GUIMEVehicle.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 <guisim/GUIBaseVehicle.h>
30 : #include <mesosim/MEVehicle.h>
31 :
32 :
33 : // ===========================================================================
34 : // class declarations
35 : // ===========================================================================
36 : class GUISUMOAbstractView;
37 : class GUIVisualizationSettings;
38 :
39 :
40 : // ===========================================================================
41 : // class definitions
42 : // ===========================================================================
43 : /**
44 : * @class GUIMEVehicle
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 GUIMEVehicle : public MEVehicle, public GUIBaseVehicle {
53 :
54 : public:
55 : /** @brief Constructor
56 : * @param[in] pars The vehicle description
57 : * @param[in] route The vehicle's route
58 : * @param[in] type The vehicle's type
59 : * @param[in] speedFactor The factor for driven lane's speed limits
60 : * @exception ProcessError If a value is wrong
61 : */
62 : GUIMEVehicle(SUMOVehicleParameter* pars, ConstMSRoutePtr route,
63 : MSVehicleType* type, const double speedFactor);
64 :
65 : /// @brief destructor
66 : ~GUIMEVehicle();
67 :
68 : /** @brief Return current position (x/y, cartesian)
69 : *
70 : * @note implementation of abstract method does not work otherwise
71 : */
72 47545 : Position getPosition(const double offset = 0) const override {
73 47545 : return MEVehicle::getPosition(offset);
74 : }
75 :
76 : Position getVisualPosition(bool s2, const double offset = 0) const override;
77 :
78 : /// @brief return exaggeration associated with this GLObject
79 : double getExaggeration(const GUIVisualizationSettings& s) const override;
80 :
81 : /** @brief Returns the boundary to which the view shall be centered in order to show the object
82 : *
83 : * @return The boundary the object is within
84 : * @see GUIGlObject::getCenteringBoundary
85 : */
86 : virtual Boundary getCenteringBoundary() const override;
87 :
88 : /** @brief Return current angle
89 : *
90 : * @note implementation of abstract method does not work otherwise
91 : */
92 24084 : double getAngle() const override {
93 24084 : return MEVehicle::getAngle();
94 : }
95 :
96 463 : double getVisualAngle(bool /*s2*/) const override {
97 463 : return MEVehicle::getAngle();
98 : }
99 :
100 : /// @brief gets the color value according to the current scheme index
101 : double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
102 :
103 : /// @brief draws the given guiShape with distinct carriages/modules
104 : void drawAction_drawCarriageClass(const GUIVisualizationSettings& s, double scaledLength, bool asImage) const override;
105 :
106 : /** @brief Returns the time since the last lane change in seconds
107 : * @see MSVehicle::myLastLaneChangeOffset
108 : * @return The time since the last lane change in seconds
109 : */
110 : double getLastLaneChangeOffset() const override;
111 :
112 : /** @brief Draws the route
113 : * @param[in] r The route to draw
114 : */
115 : void drawRouteHelper(const GUIVisualizationSettings& s, ConstMSRoutePtr r,
116 : bool future, bool noLoop, const RGBColor& col) const override;
117 :
118 : /// @brief retrieve information about the current stop state
119 : std::string getStopInfo() const override;
120 :
121 : std::string getEdgeID() const;
122 :
123 : /// @brief adds the blocking foes to the current selection
124 : void selectBlockingFoes() const override;
125 :
126 : /** @brief Returns an own parameter window
127 : *
128 : * @param[in] app The application needed to build the parameter window
129 : * @param[in] parent The parent window needed to build the parameter window
130 : * @return The built parameter window
131 : * @see GUIGlObject::getParameterWindow
132 : */
133 : GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
134 :
135 : /** @brief Returns an own type parameter window
136 : *
137 : * @param[in] app The application needed to build the parameter window
138 : * @param[in] parent The parent window needed to build the parameter window
139 : * @return The built parameter window
140 : */
141 : GUIParameterTableWindow* getTypeParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
142 :
143 : /// @brief whether this vehicle is selected in the GUI
144 : bool isSelected() const override;
145 : };
|