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