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 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 5826 : 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 : /** 145 : * @class GUIContainerPopupMenu 146 : * 147 : * A popup-menu for vehicles. In comparison to the normal popup-menu, this one 148 : * also allows to trigger further visualisations and to track the vehicle. 149 : */ 150 : class GUIContainerPopupMenu : public GUIGLObjectPopupMenu { 151 0 : FXDECLARE(GUIContainerPopupMenu) 152 : public: 153 : /** @brief Constructor 154 : * @param[in] app The main window for instantiation of other windows 155 : * @param[in] parent The parent view for changing it 156 : * @param[in] o The object of interest 157 : */ 158 : GUIContainerPopupMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, GUIGlObject& o); 159 : 160 : /// @brief Destructor 161 : ~GUIContainerPopupMenu(); 162 : 163 : /// @brief Called if the plan shall be shown 164 : long onCmdShowPlan(FXObject*, FXSelector, void*); 165 : /// @brief Called if the person shall be tracked 166 : long onCmdStartTrack(FXObject*, FXSelector, void*); 167 : /// @brief Called if the person shall not be tracked any longer 168 : long onCmdStopTrack(FXObject*, FXSelector, void*); 169 : 170 : protected: 171 : /// @brief default constructor needed by FOX 172 0 : FOX_CONSTRUCTOR(GUIContainerPopupMenu) 173 : 174 : }; 175 : 176 : 177 : 178 : /// @brief Enabled visualisations, per view 179 : std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations; 180 : 181 : 182 : 183 : 184 : private: 185 : /// The mutex used to avoid concurrent updates of the vehicle buffer 186 : mutable FXMutex myLock; 187 : 188 : /// The position of a container while riding a vehicle 189 : GUIBaseVehicle::Seat myPositionInVehicle; 190 : 191 : /// @brief sets the color according to the currente settings 192 : void setColor(const GUIVisualizationSettings& s) const; 193 : 194 : /// @brief gets the color value according to the current scheme index 195 : double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const override; 196 : 197 : /// @brief sets the color according to the current scheme index and some vehicle function 198 : bool setFunctionalColor(int activeScheme) const; 199 : 200 : /// @name drawing helper methods 201 : /// @{ 202 : void drawAction_drawAsPoly(const GUIVisualizationSettings& s) const; 203 : void drawAction_drawAsImage(const GUIVisualizationSettings& s) const; 204 : /// @} 205 : };