/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 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) override;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, GUISUMOAbstractView& parent) override;8687/** @brief Returns an own parameter window88*89* @param[in] app The application needed to build the parameter window90* @param[in] parent The parent window needed to build the parameter window91* @return The built parameter window92* @see GUIGlObject::getParameterWindow93*/94GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;9596/// @brief return exaggeration associated with this GLObject97double getExaggeration(const GUIVisualizationSettings& s) const override;9899/** @brief Returns the boundary to which the view shall be centered in order to show the object100*101* @return The boundary the object is within102* @see GUIGlObject::getCenteringBoundary103*/104Boundary getCenteringBoundary() const override;105106/** @brief Draws the object107* @param[in] s The settings for the current view (may influence drawing)108* @see GUIGlObject::drawGL109*/110void drawGL(const GUIVisualizationSettings& s) const override;111//@}112113GUIManipulator* openManipulator(GUIMainWindow& app,114GUISUMOAbstractView& parent);115116/// @brief shift route probabilities117void shiftProbs();118119public:120121enum RerouterEdgeType {122REROUTER_TRIGGER_EDGE,123REROUTER_CLOSED_EDGE,124REROUTER_SWITCH_EDGE125};126127class GUITriggeredRerouterEdge : public GUIGlObject {128129public:130GUITriggeredRerouterEdge(GUIEdge* edge, GUITriggeredRerouter* parent, RerouterEdgeType edgeType, int distIndex = -1,131const Position& pos = Position::INVALID, const double radius = std::numeric_limits<double>::max());132133virtual ~GUITriggeredRerouterEdge();134135/// @name inherited from GUIGlObject136//@{137138/** @brief Returns an own popup-menu139*140* @param[in] app The application needed to build the popup-menu141* @param[in] parent The parent window needed to build the popup-menu142* @return The built popup-menu143* @see GUIGlObject::getPopUpMenu144*/145GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) override;146147/** @brief Returns an own parameter window148*149* @param[in] app The application needed to build the parameter window150* @param[in] parent The parent window needed to build the parameter window151* @return The built parameter window152* @see GUIGlObject::getParameterWindow153*/154GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override;155156/// @brief return exaggeration associated with this GLObject157double getExaggeration(const GUIVisualizationSettings& s) const override;158159/** @brief Returns the boundary to which the view shall be centered in order to show the object160*161* @return The boundary the object is within162* @see GUIGlObject::getCenteringBoundary163*/164Boundary getCenteringBoundary() const override;165166/** @brief Draws the object167* @param[in] s The settings for the current view (may influence drawing)168* @see GUIGlObject::drawGL169*/170void drawGL(const GUIVisualizationSettings& s) const override;171172void onLeftBtnPress(void* data) override;173174RerouterEdgeType getRerouterEdgeType() const {175return myEdgeType;176}177178const MSEdge* getEdge() const {179return myEdge;180}181//@}182183private:184/// Definition of a positions container185typedef std::vector<Position> PosCont;186187/// Definition of a rotation container188typedef std::vector<double> RotCont;189190private:191/// The parent rerouter to which this edge instance belongs192GUITriggeredRerouter* myParent;193194/// The edge for which this visualization applies195MSEdge* myEdge;196197/// whether this edge instance visualizes a closed edge198const RerouterEdgeType myEdgeType;199200/// The positions in full-geometry mode201PosCont myFGPositions;202203/// The rotations in full-geometry mode204RotCont myFGRotations;205206/// The boundary of this rerouter207Boundary myBoundary;208209/// The sign half-widths210std::vector<double> myHalfWidths;211212/// @brief the index for this in edge in routeProbs213int myDistIndex;214};215216public:217class GUITriggeredRerouterPopupMenu : public GUIGLObjectPopupMenu {218FXDECLARE(GUITriggeredRerouterPopupMenu)219public:220221GUITriggeredRerouterPopupMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, GUIGlObject* o);222223~GUITriggeredRerouterPopupMenu();224225/** @brief Called if the object's manipulator shall be shown */226long onCmdOpenManip(FXObject*, FXSelector, void*);227228protected:229GUITriggeredRerouterPopupMenu() { }230231};232233234class GUIManip_TriggeredRerouter : public GUIManipulator {235FXDECLARE(GUIManip_TriggeredRerouter)236public:237enum {238MID_USER_DEF = FXDialogBox::ID_LAST,239MID_PRE_DEF,240MID_OPTION,241MID_CLOSE,242MID_SHIFT_PROBS,243ID_LAST244};245/// Constructor246GUIManip_TriggeredRerouter(GUIMainWindow& app, const std::string& name, GUITriggeredRerouter& o);247248/// Destructor249virtual ~GUIManip_TriggeredRerouter();250251long onCmdClose(FXObject*, FXSelector, void*);252long onCmdUserDef(FXObject*, FXSelector, void*);253long onUpdUserDef(FXObject*, FXSelector, void*);254long onCmdChangeOption(FXObject*, FXSelector, void*);255long onCmdShiftProbs(FXObject*, FXSelector, void*);256257private:258GUIMainWindow* myParent;259260FXint myChosenValue;261262FXDataTarget myChosenTarget;263264double myUsageProbability;265266FXRealSpinner* myUsageProbabilityDial;267268FXDataTarget myUsageProbabilityTarget;269270GUITriggeredRerouter* myObject;271272protected:273GUIManip_TriggeredRerouter() { }274275};276277278private:279/// The boundary of this rerouter280Boundary myBoundary;281282std::vector<GUITriggeredRerouterEdge*> myEdgeVisualizations;283284int myShiftProbDistIndex;285};286287288