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 GUIPerson.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/fxheader.h>
30 : #include <utils/gui/globjects/GUIGlObject.h>
31 : #include <utils/common/RGBColor.h>
32 : #include <microsim/transportables/MSPerson.h>
33 : #include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
34 : #include <utils/gui/settings/GUIPropertySchemeStorage.h>
35 : #include "GUIBaseVehicle.h"
36 :
37 :
38 : // ===========================================================================
39 : // class declarations
40 : // ===========================================================================
41 : class GUISUMOAbstractView;
42 : class GUIGLObjectPopupMenu;
43 : class MSDevice_Vehroutes;
44 :
45 :
46 : // ===========================================================================
47 : // class definitions
48 : // ===========================================================================
49 : /**
50 : * @class GUIPerson
51 : */
52 : class GUIPerson : public MSPerson, public GUIGlObject {
53 :
54 : public:
55 : /// @brief Constructor
56 : GUIPerson(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan, const double speedFactor);
57 :
58 : /// @brief destructor
59 : ~GUIPerson();
60 :
61 : /// @name inherited from GUIGlObject
62 : /// @{
63 : /** @brief Returns an own popup-menu
64 : *
65 : * @param[in] app The application needed to build the popup-menu
66 : * @param[in] parent The parent window needed to build the popup-menu
67 : * @return The built popup-menu
68 : * @see GUIGlObject::getPopUpMenu
69 : */
70 : GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
71 :
72 : /** @brief Returns an own parameter window
73 : *
74 : * @param[in] app The application needed to build the parameter window
75 : * @param[in] parent The parent window needed to build the parameter window
76 : * @return The built parameter window
77 : * @see GUIGlObject::getParameterWindow
78 : */
79 : GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
80 :
81 : /** @brief Returns an own type parameter window
82 : *
83 : * @param[in] app The application needed to build the parameter window
84 : * @param[in] parent The parent window needed to build the parameter window
85 : * @return The built parameter window
86 : */
87 : GUIParameterTableWindow* getTypeParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
88 :
89 : /// @brief return exaggeration associated with this GLObject
90 : double getExaggeration(const GUIVisualizationSettings& s) const override;
91 :
92 : /** @brief Returns the boundary to which the view shall be centered in order to show the object
93 : *
94 : * @return The boundary the object is within
95 : * @see GUIGlObject::getCenteringBoundary
96 : */
97 : Boundary getCenteringBoundary() const override;
98 :
99 : /** @brief Draws the object
100 : * @param[in] s The settings for the current view (may influence drawing)
101 : * @see GUIGlObject::drawGL
102 : */
103 : void drawGL(const GUIVisualizationSettings& s) const override;
104 :
105 : /** @brief Draws additionally triggered visualisations
106 : * @param[in] parent The view
107 : * @param[in] s The settings for the current view (may influence drawing)
108 : */
109 : virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const override;
110 : //* @}
111 :
112 : /* @brief proceeds to the next step of the route,
113 : * @return Whether the transportables plan continues */
114 : bool proceed(MSNet* net, SUMOTime time, const bool vehicleArrived = false) override;
115 :
116 : /* @brief set the position of a person while riding in a vehicle
117 : * @note This must be called by the vehicle before the call to drawGl */
118 : void setPositionInVehicle(const GUIBaseVehicle::Seat& pos);
119 :
120 : /// @name inherited from MSPerson with added locking
121 : /// @{
122 : /// @brief return the offset from the start of the current edge
123 : double getEdgePos() const override;
124 :
125 : /// @brief Return the movement directon on the edge
126 : int getDirection() const override;
127 :
128 : /// @brief return the Network coordinate of the person
129 : // @note overrides the base method and returns myPositionInVehicle while in driving stage
130 : Position getPosition() const override;
131 :
132 : /// @brief return the Network coordinate of the person (only for drawing centering and tracking)
133 : Position getGUIPosition(const GUIVisualizationSettings* s = nullptr) const;
134 :
135 : /// @brief return the angle of the person (only for drawing centering and tracking)
136 : double getGUIAngle() const;
137 :
138 : /// @brief return the current angle of the person
139 : double getNaviDegree() const;
140 :
141 : /// @brief the time this person spent waiting in seconds
142 : double getWaitingSeconds() const override;
143 :
144 : /// @brief the current speed of the person
145 : double getSpeed() const override;
146 :
147 : /// @brief get stage index description
148 : std::string getStageIndexDescription() const;
149 :
150 : /// @brief get edge ID
151 : std::string getEdgeID() const;
152 :
153 : /// @brief ger from edge ID
154 : std::string getFromEdgeID() const;
155 :
156 : /// @brief get destination edge ID
157 : std::string getDestinationEdgeID() const;
158 :
159 : /// @brief get destination stop ID
160 : std::string getDestinationStopID() const;
161 :
162 : /// @brief get current vehicle id if applicable
163 : std::string getVehicleID() const;
164 :
165 : /// @brief get remaining duration of current stop or -1
166 : double getStopDuration() const;
167 :
168 : /// @brief get stage arrival position
169 : double getStageArrivalPos() const;
170 :
171 : //@}
172 :
173 : /// @brief whether this person is selected in the GUI
174 : bool isSelected() const override;
175 :
176 : /// @brief sets the color according to the current scheme index and some vehicle function
177 : static bool setFunctionalColor(int activeScheme, const MSPerson* person, RGBColor& col);
178 :
179 : /// @brief gets the color value according to the current scheme index
180 : double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
181 :
182 : /**
183 : * @class GUIPersonPopupMenu
184 : *
185 : * A popup-menu for vehicles. In comparison to the normal popup-menu, this one
186 : * also allows to trigger further visualisations and to track the vehicle.
187 : */
188 : class GUIPersonPopupMenu : public GUIGLObjectPopupMenu {
189 0 : FXDECLARE(GUIPersonPopupMenu)
190 :
191 : public:
192 : /** @brief Constructor
193 : * @param[in] app The main window for instantiation of other windows
194 : * @param[in] parent The parent view for changing it
195 : * @param[in] o The object of interest
196 : */
197 : GUIPersonPopupMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, GUIGlObject& o);
198 :
199 : /// @brief Destructor
200 : ~GUIPersonPopupMenu();
201 :
202 : /// @brief Called if the current route of the person shall be shown
203 : long onCmdShowCurrentRoute(FXObject*, FXSelector, void*);
204 :
205 : /// @brief Called if the current route of the person shall be hidden
206 : long onCmdHideCurrentRoute(FXObject*, FXSelector, void*);
207 :
208 : /// @brief Called if the walkingarea path of the person shall be shown
209 : long onCmdShowWalkingareaPath(FXObject*, FXSelector, void*);
210 :
211 : /// @brief Called if the walkingarea path of the person shall be hidden
212 : long onCmdHideWalkingareaPath(FXObject*, FXSelector, void*);
213 :
214 : /// @brief Called if the plan shall be shown
215 : long onCmdShowPlan(FXObject*, FXSelector, void*);
216 :
217 : /// @brief Called if the person shall be tracked
218 : long onCmdStartTrack(FXObject*, FXSelector, void*);
219 :
220 : /// @brief Called if the person shall not be tracked any longer
221 : long onCmdStopTrack(FXObject*, FXSelector, void*);
222 :
223 : /// @brief Called when removing the person
224 : long onCmdRemoveObject(FXObject*, FXSelector, void*);
225 :
226 : protected:
227 : /// @brief default constructor needed by FOX
228 0 : FOX_CONSTRUCTOR(GUIPersonPopupMenu)
229 : };
230 :
231 : /// @brief Additional visualisation feature ids
232 : enum VisualisationFeatures {
233 : /// @brief show the current walkingarea path
234 : VO_SHOW_WALKINGAREA_PATH = 1,
235 : /// @brief show persons's current route
236 : VO_SHOW_ROUTE = 2,
237 : /// @brief track person
238 : VO_TRACKED = 8
239 : };
240 :
241 : /// @name Additional visualisations
242 : /// @{
243 : /** @brief Returns whether the named feature is enabled in the given view
244 : * @param[in] parent The view for which the feature may be enabled
245 : * @param[in] which The visualisation feature
246 : * @return see comment
247 : */
248 : bool hasActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) const;
249 :
250 : /** @brief Adds the named visualisation feature to the given view
251 : * @param[in] parent The view for which the feature shall be enabled
252 : * @param[in] which The visualisation feature to enable
253 : * @see GUISUMOAbstractView::addAdditionalGLVisualisation
254 : */
255 : void addActiveAddVisualisation(GUISUMOAbstractView* const parent, int which);
256 :
257 : /** @brief Adds the named visualisation feature to the given view
258 : * @param[in] parent The view for which the feature shall be enabled
259 : * @param[in] which The visualisation feature to enable
260 : * @see GUISUMOAbstractView::removeAdditionalGLVisualisation
261 : */
262 : void removeActiveAddVisualisation(GUISUMOAbstractView* const parent, int which) override;
263 :
264 : /// @}
265 :
266 : private:
267 : /// @brief sets the color according to the currente settings
268 : void setColor(const GUIVisualizationSettings& s) const;
269 :
270 : /// @brief draw walking area path
271 : void drawAction_drawWalkingareaPath(const GUIVisualizationSettings& s) const;
272 :
273 : /// The mutex used to avoid concurrent updates of the vehicle buffer
274 : mutable FXMutex myLock;
275 :
276 : /// The position of a person while riding a vehicle
277 : GUIBaseVehicle::Seat myPositionInVehicle;
278 :
279 : /// @brief Enabled visualisations, per view
280 : std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
281 : };
|