/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GUITriggeredRerouter.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Michael Behrisch17/// @date Mon, 25.07.200518///19// Reroutes vehicles passing an edge (gui-version)20/****************************************************************************/21#pragma once22#include <config.h>2324#include <vector>25#include <string>26#include <foreign/rtree/SUMORTree.h>27#include <microsim/trigger/MSTriggeredRerouter.h>28#include <utils/gui/globjects/GUIGlObject_AbstractAdd.h>29#include <utils/gui/globjects/GUIGLObjectPopupMenu.h>30#include <gui/GUIManipulator.h>3132// ===========================================================================33// class declarations34// ===========================================================================35class GUIEdge;3637// ===========================================================================38// class definitions39// ===========================================================================40/**41* @class GUITriggeredRerouter42* @brief Reroutes vehicles passing an edge43* One rerouter can be active on multiple edges. To reduce drawing load we44* instantiate GUIGlObjects for every edge45* XXX multiple rerouters active on the same edge are problematic46*/47class GUITriggeredRerouter48: public MSTriggeredRerouter,49public GUIGlObject_AbstractAdd {50public:51/** @brief Constructor52* @param[in] id The id of the rerouter53* @param[in] edges The edges the rerouter is placed at54* @param[in] prob The probability to reroute vehicles55* @param[in] off Whether the rerouter is off (not working) initially56*/57GUITriggeredRerouter(const std::string& id, const MSEdgeVector& edges, double prob,58bool off, bool optional, SUMOTime timeThreshold,59const std::string& vTypes, const Position& pos, const double radius,60SUMORTree& rtree);616263/// @brief Destructor64~GUITriggeredRerouter();656667/** @brief Called when a closing tag occurs68*69* @param[in] element ID of the currently opened element70* @exception ProcessError If something fails71* @see GenericSAXHandler::myEndElement72*/73void myEndElement(int element);7475/// @name inherited from GUIGlObject76//@{7778/** @brief Returns an own popup-menu79*80* @param[in] app The application needed to build the popup-menu81* @param[in] parent The parent window needed to build the popup-menu82* @return The built popup-menu83* @see GUIGlObject::getPopUpMenu84*/85GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app,86GUISUMOAbstractView& parent);8788/** @brief Returns an own parameter window89*90* @param[in] app The application needed to build the parameter window91* @param[in] parent The parent window needed to build the parameter window92* @return The built parameter window93* @see GUIGlObject::getParameterWindow94*/95GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app,96GUISUMOAbstractView& parent);9798/// @brief return exaggeration associated with this GLObject99double getExaggeration(const GUIVisualizationSettings& s) const;100101/** @brief Returns the boundary to which the view shall be centered in order to show the object102*103* @return The boundary the object is within104* @see GUIGlObject::getCenteringBoundary105*/106Boundary getCenteringBoundary() const;107108/** @brief Draws the object109* @param[in] s The settings for the current view (may influence drawing)110* @see GUIGlObject::drawGL111*/112void drawGL(const GUIVisualizationSettings& s) const;113//@}114115GUIManipulator* openManipulator(GUIMainWindow& app,116GUISUMOAbstractView& parent);117118/// @brief shift route probabilities119void shiftProbs();120121public:122123enum RerouterEdgeType {124REROUTER_TRIGGER_EDGE,125REROUTER_CLOSED_EDGE,126REROUTER_SWITCH_EDGE127};128129class GUITriggeredRerouterEdge : public GUIGlObject {130131public:132GUITriggeredRerouterEdge(GUIEdge* edge, GUITriggeredRerouter* parent, RerouterEdgeType edgeType, int distIndex = -1,133const Position& pos = Position::INVALID, const double radius = std::numeric_limits<double>::max());134135virtual ~GUITriggeredRerouterEdge();136137/// @name inherited from GUIGlObject138//@{139140/** @brief Returns an own popup-menu141*142* @param[in] app The application needed to build the popup-menu143* @param[in] parent The parent window needed to build the popup-menu144* @return The built popup-menu145* @see GUIGlObject::getPopUpMenu146*/147GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app,148GUISUMOAbstractView& parent);149150/** @brief Returns an own parameter window151*152* @param[in] app The application needed to build the parameter window153* @param[in] parent The parent window needed to build the parameter window154* @return The built parameter window155* @see GUIGlObject::getParameterWindow156*/157GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app,158GUISUMOAbstractView& parent);159160/// @brief return exaggeration associated with this GLObject161double getExaggeration(const GUIVisualizationSettings& s) const;162163/** @brief Returns the boundary to which the view shall be centered in order to show the object164*165* @return The boundary the object is within166* @see GUIGlObject::getCenteringBoundary167*/168Boundary getCenteringBoundary() const;169170/** @brief Draws the object171* @param[in] s The settings for the current view (may influence drawing)172* @see GUIGlObject::drawGL173*/174void drawGL(const GUIVisualizationSettings& s) const;175176void onLeftBtnPress(void* data);177178RerouterEdgeType getRerouterEdgeType() const {179return myEdgeType;180}181182const MSEdge* getEdge() const {183return myEdge;184}185//@}186187private:188/// Definition of a positions container189typedef std::vector<Position> PosCont;190191/// Definition of a rotation container192typedef std::vector<double> RotCont;193194private:195/// The parent rerouter to which this edge instance belongs196GUITriggeredRerouter* myParent;197198/// The edge for which this visualization applies199MSEdge* myEdge;200201/// whether this edge instance visualizes a closed edge202const RerouterEdgeType myEdgeType;203204/// The positions in full-geometry mode205PosCont myFGPositions;206207/// The rotations in full-geometry mode208RotCont myFGRotations;209210/// The boundary of this rerouter211Boundary myBoundary;212213/// The sign half-widths214std::vector<double> myHalfWidths;215216/// @brief the index for this in edge in routeProbs217int myDistIndex;218};219220public:221class GUITriggeredRerouterPopupMenu : public GUIGLObjectPopupMenu {222FXDECLARE(GUITriggeredRerouterPopupMenu)223public:224225GUITriggeredRerouterPopupMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, GUIGlObject* o);226227~GUITriggeredRerouterPopupMenu();228229/** @brief Called if the object's manipulator shall be shown */230long onCmdOpenManip(FXObject*, FXSelector, void*);231232protected:233GUITriggeredRerouterPopupMenu() { }234235};236237238class GUIManip_TriggeredRerouter : public GUIManipulator {239FXDECLARE(GUIManip_TriggeredRerouter)240public:241enum {242MID_USER_DEF = FXDialogBox::ID_LAST,243MID_PRE_DEF,244MID_OPTION,245MID_CLOSE,246MID_SHIFT_PROBS,247ID_LAST248};249/// Constructor250GUIManip_TriggeredRerouter(GUIMainWindow& app, const std::string& name, GUITriggeredRerouter& o);251252/// Destructor253virtual ~GUIManip_TriggeredRerouter();254255long onCmdClose(FXObject*, FXSelector, void*);256long onCmdUserDef(FXObject*, FXSelector, void*);257long onUpdUserDef(FXObject*, FXSelector, void*);258long onCmdChangeOption(FXObject*, FXSelector, void*);259long onCmdShiftProbs(FXObject*, FXSelector, void*);260261private:262GUIMainWindow* myParent;263264FXint myChosenValue;265266FXDataTarget myChosenTarget;267268double myUsageProbability;269270FXRealSpinner* myUsageProbabilityDial;271272FXDataTarget myUsageProbabilityTarget;273274GUITriggeredRerouter* myObject;275276protected:277GUIManip_TriggeredRerouter() { }278279};280281282private:283/// The boundary of this rerouter284Boundary myBoundary;285286std::vector<GUITriggeredRerouterEdge*> myEdgeVisualizations;287288int myShiftProbDistIndex;289};290291292