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 GUILaneSpeedTrigger.h 15 : /// @author Daniel Krajzewicz 16 : /// @author Jakob Erdmann 17 : /// @author Michael Behrisch 18 : /// @date Mon, 26.04.2004 19 : /// 20 : // Changes the speed allowed on a set of lanes (gui version) 21 : /****************************************************************************/ 22 : #pragma once 23 : #include <config.h> 24 : 25 : #include <vector> 26 : #include <string> 27 : #include <microsim/trigger/MSLaneSpeedTrigger.h> 28 : #include <utils/foxtools/MFXComboBoxIcon.h> 29 : #include <utils/gui/globjects/GUIGlObject_AbstractAdd.h> 30 : #include <utils/gui/globjects/GUIGLObjectPopupMenu.h> 31 : #include <gui/GUIManipulator.h> 32 : 33 : 34 : // =========================================================================== 35 : // class definitions 36 : // =========================================================================== 37 : /** 38 : * @class GUILaneSpeedTrigger 39 : * @brief Changes the speed allowed on a set of lanes (gui version) 40 : * 41 : * This is the gui-version of the MSLaneSpeedTrigger-object 42 : */ 43 : class GUILaneSpeedTrigger 44 : : public MSLaneSpeedTrigger, 45 : public GUIGlObject_AbstractAdd { 46 : public: 47 : /** @brief Constructor 48 : * @param[in] idStorage The gl-id storage for giving this object an gl-id 49 : * @param[in] id The id of the lane speed trigger 50 : * @param[in] destLanes List of lanes affected by this speed trigger 51 : * @param[in] file Name of the file to read the speeds to set from 52 : */ 53 : GUILaneSpeedTrigger(const std::string& id, 54 : const std::vector<MSLane*>& destLanes, 55 : const std::string& file); 56 : 57 : /** destructor */ 58 : ~GUILaneSpeedTrigger(); 59 : 60 : /// @name inherited from GUIGlObject 61 : //@{ 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, 71 : GUISUMOAbstractView& parent); 72 : 73 : /** @brief Returns an own parameter window 74 : * 75 : * @param[in] app The application needed to build the parameter window 76 : * @param[in] parent The parent window needed to build the parameter window 77 : * @return The built parameter window 78 : * @see GUIGlObject::getParameterWindow 79 : */ 80 : GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, 81 : GUISUMOAbstractView& parent); 82 : 83 : /// @brief return exaggeration associated with this GLObject 84 : double getExaggeration(const GUIVisualizationSettings& s) const; 85 : 86 : /** @brief Returns the boundary to which the view shall be centered in order to show the object 87 : * 88 : * @return The boundary the object is within 89 : * @see GUIGlObject::getCenteringBoundary 90 : */ 91 : Boundary getCenteringBoundary() const; 92 : 93 : /** @brief Draws the object 94 : * @param[in] s The settings for the current view (may influence drawing) 95 : * @see GUIGlObject::drawGL 96 : */ 97 : void drawGL(const GUIVisualizationSettings& s) const; 98 : //@} 99 : 100 : GUIManipulator* openManipulator(GUIMainWindow& app, 101 : GUISUMOAbstractView& parent); 102 : 103 : public: 104 : class GUILaneSpeedTriggerPopupMenu : public GUIGLObjectPopupMenu { 105 0 : FXDECLARE(GUILaneSpeedTriggerPopupMenu) 106 : public: 107 : 108 : GUILaneSpeedTriggerPopupMenu(GUIMainWindow& app, 109 : GUISUMOAbstractView& parent, GUIGlObject& o); 110 : 111 : ~GUILaneSpeedTriggerPopupMenu(); 112 : 113 : /** @brief Called if the object's manipulator shall be shown */ 114 : long onCmdOpenManip(FXObject*, FXSelector, void*); 115 : 116 : protected: 117 0 : GUILaneSpeedTriggerPopupMenu() { } 118 : 119 : }; 120 : 121 : class GUIManip_LaneSpeedTrigger : public GUIManipulator { 122 0 : FXDECLARE(GUIManip_LaneSpeedTrigger) 123 : public: 124 : enum { 125 : MID_USER_DEF = FXDialogBox::ID_LAST, 126 : MID_PRE_DEF, 127 : MID_OPTION, 128 : MID_CLOSE, 129 : ID_LAST 130 : }; 131 : /// Constructor 132 : GUIManip_LaneSpeedTrigger(GUIMainWindow& app, 133 : const std::string& name, GUILaneSpeedTrigger& o, 134 : int xpos, int ypos); 135 : 136 : /// Destructor 137 : virtual ~GUIManip_LaneSpeedTrigger(); 138 : 139 : long onCmdOverride(FXObject*, FXSelector, void*); 140 : long onCmdClose(FXObject*, FXSelector, void*); 141 : long onCmdUserDef(FXObject*, FXSelector, void*); 142 : long onUpdUserDef(FXObject*, FXSelector, void*); 143 : long onCmdPreDef(FXObject*, FXSelector, void*); 144 : long onUpdPreDef(FXObject*, FXSelector, void*); 145 : long onCmdChangeOption(FXObject*, FXSelector, void*); 146 : 147 : private: 148 : GUIMainWindow* myParent; 149 : 150 : FXint myChosenValue; 151 : 152 : FXDataTarget myChosenTarget; 153 : 154 : double mySpeed; 155 : 156 : FXDataTarget mySpeedTarget; 157 : 158 : FXRealSpinner* myUserDefinedSpeed; 159 : 160 : MFXComboBoxIcon* myPredefinedValues; 161 : 162 : GUILaneSpeedTrigger* myObject; 163 : 164 : protected: 165 0 : GUIManip_LaneSpeedTrigger() { } 166 : 167 : }; 168 : 169 : private: 170 : /// Definition of a positions container 171 : typedef std::vector<Position> PosCont; 172 : 173 : /// Definition of a rotation container 174 : typedef std::vector<double> RotCont; 175 : 176 : private: 177 : /// The positions in full-geometry mode 178 : PosCont myFGPositions; 179 : 180 : /// The rotations in full-geometry mode 181 : RotCont myFGRotations; 182 : 183 : /// The boundary of this rerouter 184 : Boundary myBoundary; 185 : 186 : /// The information whether the speed shall be shown in m/s or km/h 187 : bool myShowAsKMH; 188 : 189 : /// Storage for last value to avoid string recomputation 190 : mutable double myLastValue; 191 : 192 : /// Storage for speed string to avoid recomputation 193 : mutable std::string myLastValueString; 194 : 195 : };