LCOV - code coverage report
Current view: top level - src/guisim - GUITriggeredRerouter.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 0.0 % 6 0
Test Date: 2025-11-13 15:38:19 Functions: 0.0 % 2 0

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

Generated by: LCOV version 2.0-1