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 GUIContainer.h
15 : /// @author Melanie Weber
16 : /// @author Andreas Kendziorra
17 : /// @date Wed, 01.08.2014
18 : ///
19 : // A MSVehicle extended by some values for usage within the gui
20 : /****************************************************************************/
21 : #pragma once
22 : #include <config.h>
23 :
24 : #include <vector>
25 : #include <set>
26 : #include <string>
27 : #include <utils/foxtools/fxheader.h>
28 : #include <utils/gui/globjects/GUIGlObject.h>
29 : #include <utils/common/RGBColor.h>
30 : #include <microsim/transportables/MSTransportable.h>
31 : #include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
32 : #include <utils/gui/settings/GUIPropertySchemeStorage.h>
33 : #include "GUIBaseVehicle.h"
34 :
35 :
36 : // ===========================================================================
37 : // class declarations
38 : // ===========================================================================
39 : class GUISUMOAbstractView;
40 : class GUIGLObjectPopupMenu;
41 : class MSDevice_Vehroutes;
42 :
43 :
44 : // ===========================================================================
45 : // class definitions
46 : // ===========================================================================
47 : /**
48 : * @class GUIContainer
49 : */
50 : class GUIContainer : public MSTransportable, public GUIGlObject {
51 : public:
52 : /** @brief Constructor
53 : */
54 : GUIContainer(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan);
55 :
56 : /// @brief destructor
57 : ~GUIContainer();
58 :
59 : /// @name inherited from GUIGlObject
60 : //@{
61 :
62 : /** @brief Returns an own popup-menu
63 : *
64 : * @param[in] app The application needed to build the popup-menu
65 : * @param[in] parent The parent window needed to build the popup-menu
66 : * @return The built popup-menu
67 : * @see GUIGlObject::getPopUpMenu
68 : */
69 : GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
70 :
71 : /** @brief Returns an own parameter window
72 : *
73 : * @param[in] app The application needed to build the parameter window
74 : * @param[in] parent The parent window needed to build the parameter window
75 : * @return The built parameter window
76 : * @see GUIGlObject::getParameterWindow
77 : */
78 : GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
79 :
80 : /** @brief Returns an own type parameter window
81 : *
82 : * @param[in] app The application needed to build the parameter window
83 : * @param[in] parent The parent window needed to build the parameter window
84 : * @return The built parameter window
85 : */
86 : GUIParameterTableWindow* getTypeParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;
87 :
88 : /// @brief return exaggeration associated with this GLObject
89 : double getExaggeration(const GUIVisualizationSettings& s) const override;
90 :
91 : /** @brief Returns the boundary to which the view shall be centered in order to show the object
92 : *
93 : * @return The boundary the object is within
94 : * @see GUIGlObject::getCenteringBoundary
95 : */
96 : Boundary getCenteringBoundary() const override;
97 :
98 : /** @brief Draws the object
99 : * @param[in] s The settings for the current view (may influence drawing)
100 : * @see GUIGlObject::drawGL
101 : */
102 : void drawGL(const GUIVisualizationSettings& s) const override;
103 :
104 : /** @brief Draws additionally triggered visualisations
105 : * @param[in] parent The view
106 : * @param[in] s The settings for the current view (may influence drawing)
107 : */
108 : virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const override;
109 : //@}
110 :
111 : /* @brief set the position of a container while being transported by a vehicle
112 : * @note This must be called by the vehicle before the call to drawGl */
113 : void setPositionInVehicle(const GUIBaseVehicle::Seat& pos) {
114 5855 : myPositionInVehicle = pos;
115 : }
116 :
117 : /// @name inherited from MSContainer with added locking
118 : //@{
119 :
120 : /// @brief return the offset from the start of the current edge
121 : double getEdgePos() const override;
122 :
123 : /// @brief Return the movement directon on the edge
124 : int getDirection() const override;
125 :
126 : /// @brief return the Network coordinate of the container
127 : // @note overrides the base method and returns myPositionInVehicle while in driving stage
128 : Position getPosition() const override;
129 :
130 : /// @brief return the current angle of the container
131 : double getAngle() const override;
132 :
133 : /// @brief the time this container spent waiting in seconds
134 : double getWaitingSeconds() const override;
135 :
136 : /// @brief the current speed of the container
137 : double getSpeed() const override;
138 :
139 : //@}
140 :
141 : /// @brief whether this container is selected in the GUI
142 : bool isSelected() const override;
143 :
144 22252 : double getScaleVisual() const override {
145 22252 : return getVehicleType().getParameter().scaleVisual;
146 : }
147 : /**
148 : * @class GUIContainerPopupMenu
149 : *
150 : * A popup-menu for vehicles. In comparison to the normal popup-menu, this one
151 : * also allows to trigger further visualisations and to track the vehicle.
152 : */
153 : class GUIContainerPopupMenu : public GUIGLObjectPopupMenu {
154 0 : FXDECLARE(GUIContainerPopupMenu)
155 : public:
156 : /** @brief Constructor
157 : * @param[in] app The main window for instantiation of other windows
158 : * @param[in] parent The parent view for changing it
159 : * @param[in] o The object of interest
160 : */
161 : GUIContainerPopupMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, GUIGlObject* o);
162 :
163 : /// @brief Destructor
164 : ~GUIContainerPopupMenu();
165 :
166 : /// @brief Called if the plan shall be shown
167 : long onCmdShowPlan(FXObject*, FXSelector, void*);
168 :
169 : /// @brief Called if the person shall be tracked
170 : long onCmdStartTrack(FXObject*, FXSelector, void*);
171 :
172 : /// @brief Called if the person shall not be tracked any longer
173 : long onCmdStopTrack(FXObject*, FXSelector, void*);
174 :
175 : protected:
176 : /// @brief default constructor needed by FOX
177 0 : FOX_CONSTRUCTOR(GUIContainerPopupMenu)
178 :
179 : };
180 :
181 :
182 :
183 : /// @brief Enabled visualisations, per view
184 : std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations;
185 :
186 :
187 :
188 :
189 : private:
190 : /// The mutex used to avoid concurrent updates of the vehicle buffer
191 : mutable FXMutex myLock;
192 :
193 : /// The position of a container while riding a vehicle
194 : GUIBaseVehicle::Seat myPositionInVehicle;
195 :
196 : /// @brief sets the color according to the currente settings
197 : void setColor(const GUIVisualizationSettings& s) const;
198 :
199 : /// @brief gets the color value according to the current scheme index
200 : double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override;
201 :
202 : /// @brief sets the color according to the current scheme index and some vehicle function
203 : bool setFunctionalColor(int activeScheme) const;
204 :
205 : /// @name drawing helper methods
206 : /// @{
207 : void drawAction_drawAsPoly(const GUIVisualizationSettings& s) const;
208 : void drawAction_drawAsImage(const GUIVisualizationSettings& s) const;
209 : /// @}
210 : };
|