1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file GUITriggeredRerouter.h 11 /// @author Daniel Krajzewicz 12 /// @author Jakob Erdmann 13 /// @author Michael Behrisch 14 /// @date Mon, 25.07.2005 15 /// @version $Id$ 16 /// 17 // Reroutes vehicles passing an edge (gui-version) 18 /****************************************************************************/ 19 #ifndef GUITriggeredRerouter_h 20 #define GUITriggeredRerouter_h 21 22 23 // =========================================================================== 24 // included modules 25 // =========================================================================== 26 #include <config.h> 27 28 #include <vector> 29 #include <string> 30 #include <foreign/rtree/SUMORTree.h> 31 #include <microsim/trigger/MSTriggeredRerouter.h> 32 #include <utils/gui/globjects/GUIGlObject_AbstractAdd.h> 33 #include <utils/gui/globjects/GUIGLObjectPopupMenu.h> 34 #include <gui/GUIManipulator.h> 35 36 // =========================================================================== 37 // class declarations 38 // =========================================================================== 39 class GUIEdge; 40 41 // =========================================================================== 42 // class definitions 43 // =========================================================================== 44 /** 45 * @class GUITriggeredRerouter 46 * @brief Reroutes vehicles passing an edge 47 * One rerouter can be active on multiple edges. To reduce drawing load we 48 * instantiate GUIGlObjects for every edge 49 * XXX multiple rerouters active on the same edge are problematic 50 */ 51 class GUITriggeredRerouter 52 : public MSTriggeredRerouter, 53 public GUIGlObject_AbstractAdd { 54 public: 55 /** @brief Constructor 56 * @param[in] id The id of the rerouter 57 * @param[in] edges The edges the rerouter is placed at 58 * @param[in] prob The probability to reroute vehicles 59 * @param[in] aXMLFilename The file to read further definitions from 60 * @param[in] off Whether the rerouter is off (not working) initially 61 */ 62 GUITriggeredRerouter(const std::string& id, 63 const MSEdgeVector& edges, double prob, 64 const std::string& aXMLFilename, bool off, 65 SUMOTime timeThreshold, 66 const std::string& vTypes, 67 SUMORTree& rtree); 68 69 70 /// @brief Destructor 71 ~GUITriggeredRerouter(); 72 73 74 /** @brief Called when a closing tag occurs 75 * 76 * @param[in] element ID of the currently opened element 77 * @exception ProcessError If something fails 78 * @see GenericSAXHandler::myEndElement 79 */ 80 void myEndElement(int element); 81 82 /// @name inherited from GUIGlObject 83 //@{ 84 85 /** @brief Returns an own popup-menu 86 * 87 * @param[in] app The application needed to build the popup-menu 88 * @param[in] parent The parent window needed to build the popup-menu 89 * @return The built popup-menu 90 * @see GUIGlObject::getPopUpMenu 91 */ 92 GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, 93 GUISUMOAbstractView& parent); 94 95 96 /** @brief Returns an own parameter window 97 * 98 * @param[in] app The application needed to build the parameter window 99 * @param[in] parent The parent window needed to build the parameter window 100 * @return The built parameter window 101 * @see GUIGlObject::getParameterWindow 102 */ 103 GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, 104 GUISUMOAbstractView& parent); 105 106 107 /** @brief Returns the boundary to which the view shall be centered in order to show the object 108 * 109 * @return The boundary the object is within 110 * @see GUIGlObject::getCenteringBoundary 111 */ 112 Boundary getCenteringBoundary() const; 113 114 115 /** @brief Draws the object 116 * @param[in] s The settings for the current view (may influence drawing) 117 * @see GUIGlObject::drawGL 118 */ 119 void drawGL(const GUIVisualizationSettings& s) const; 120 //@} 121 122 123 124 GUIManipulator* openManipulator(GUIMainWindow& app, 125 GUISUMOAbstractView& parent); 126 127 public: 128 class GUITriggeredRerouterEdge : public GUIGlObject { 129 130 public: 131 GUITriggeredRerouterEdge(GUIEdge* edge, GUITriggeredRerouter* parent, bool closed); 132 133 virtual ~GUITriggeredRerouterEdge(); 134 135 /// @name inherited from GUIGlObject 136 //@{ 137 138 /** @brief Returns an own popup-menu 139 * 140 * @param[in] app The application needed to build the popup-menu 141 * @param[in] parent The parent window needed to build the popup-menu 142 * @return The built popup-menu 143 * @see GUIGlObject::getPopUpMenu 144 */ 145 GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, 146 GUISUMOAbstractView& parent); 147 148 149 /** @brief Returns an own parameter window 150 * 151 * @param[in] app The application needed to build the parameter window 152 * @param[in] parent The parent window needed to build the parameter window 153 * @return The built parameter window 154 * @see GUIGlObject::getParameterWindow 155 */ 156 GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, 157 GUISUMOAbstractView& parent); 158 159 160 /** @brief Returns the boundary to which the view shall be centered in order to show the object 161 * 162 * @return The boundary the object is within 163 * @see GUIGlObject::getCenteringBoundary 164 */ 165 Boundary getCenteringBoundary() const; 166 167 168 /** @brief Draws the object 169 * @param[in] s The settings for the current view (may influence drawing) 170 * @see GUIGlObject::drawGL 171 */ 172 void drawGL(const GUIVisualizationSettings& s) const; 173 //@} 174 175 private: 176 /// Definition of a positions container 177 typedef std::vector<Position> PosCont; 178 179 /// Definition of a rotation container 180 typedef std::vector<double> RotCont; 181 182 private: 183 /// The parent rerouter to which this edge instance belongs 184 GUITriggeredRerouter* myParent; 185 186 /// The edge for which this visualization applies 187 MSEdge* myEdge; 188 189 /// whether this edge instance visualizes a closed edge 190 const bool myAmClosedEdge; 191 192 /// The positions in full-geometry mode 193 PosCont myFGPositions; 194 195 /// The rotations in full-geometry mode 196 RotCont myFGRotations; 197 198 /// The boundary of this rerouter 199 Boundary myBoundary; 200 }; 201 202 public: 203 class GUITriggeredRerouterPopupMenu : public GUIGLObjectPopupMenu { 204 FXDECLARE(GUITriggeredRerouterPopupMenu) 205 public: 206 207 GUITriggeredRerouterPopupMenu(GUIMainWindow& app, 208 GUISUMOAbstractView& parent, GUIGlObject& o); 209 210 ~GUITriggeredRerouterPopupMenu(); 211 212 /** @brief Called if the object's manipulator shall be shown */ 213 long onCmdOpenManip(FXObject*, FXSelector, void*); 214 215 protected: GUITriggeredRerouterPopupMenu()216 GUITriggeredRerouterPopupMenu() { } 217 218 }; 219 220 221 class GUIManip_TriggeredRerouter : public GUIManipulator { 222 FXDECLARE(GUIManip_TriggeredRerouter) 223 public: 224 enum { 225 MID_USER_DEF = FXDialogBox::ID_LAST, 226 MID_PRE_DEF, 227 MID_OPTION, 228 MID_CLOSE, 229 ID_LAST 230 }; 231 /// Constructor 232 GUIManip_TriggeredRerouter(GUIMainWindow& app, 233 const std::string& name, GUITriggeredRerouter& o, 234 int xpos, int ypos); 235 236 /// Destructor 237 virtual ~GUIManip_TriggeredRerouter(); 238 239 long onCmdOverride(FXObject*, FXSelector, void*); 240 long onCmdClose(FXObject*, FXSelector, void*); 241 long onCmdUserDef(FXObject*, FXSelector, void*); 242 long onUpdUserDef(FXObject*, FXSelector, void*); 243 long onCmdChangeOption(FXObject*, FXSelector, void*); 244 245 private: 246 GUIMainWindow* myParent; 247 248 FXint myChosenValue; 249 250 FXDataTarget myChosenTarget; 251 252 double myUsageProbability; 253 254 FXRealSpinner* myUsageProbabilityDial; 255 256 FXDataTarget myUsageProbabilityTarget; 257 258 GUITriggeredRerouter* myObject; 259 260 protected: GUIManip_TriggeredRerouter()261 GUIManip_TriggeredRerouter() { } 262 263 }; 264 265 266 private: 267 /// The boundary of this rerouter 268 Boundary myBoundary; 269 270 std::vector<GUITriggeredRerouterEdge*> myEdgeVisualizations; 271 272 }; 273 274 275 #endif 276 277 /****************************************************************************/ 278 279