LCOV - code coverage report
Current view: top level - src/gui - GUITLLogicPhasesTrackerWindow.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 4 0.0 %
Date: 2024-05-18 15:37:58 Functions: 0 3 0.0 %

          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    GUITLLogicPhasesTrackerWindow.h
      15             : /// @author  Daniel Krajzewicz
      16             : /// @author  Jakob Erdmann
      17             : /// @author  Michael Behrisch
      18             : /// @date    Oct/Nov 2003
      19             : ///
      20             : // A window displaying the phase diagram of a tl-logic
      21             : /****************************************************************************/
      22             : #pragma once
      23             : #include <config.h>
      24             : 
      25             : #include <vector>
      26             : #include <string>
      27             : #include <bitset>
      28             : #include <utility>
      29             : #include <utils/foxtools/fxheader.h>
      30             : // fx3d includes windows.h so we need to guard against macro pollution
      31             : #ifdef WIN32
      32             : #define NOMINMAX
      33             : #endif
      34             : #include <fx3d.h>
      35             : #ifdef WIN32
      36             : #undef NOMINMAX
      37             : #endif
      38             : #include <microsim/traffic_lights/MSSimpleTrafficLightLogic.h>
      39             : #include <microsim/traffic_lights/MSTLLogicControl.h>
      40             : #include <utils/common/ValueRetriever.h>
      41             : #include <utils/gui/div/GLObjectValuePassConnector.h>
      42             : #include <microsim/logging/FunctionBinding.h>
      43             : #include <utils/common/SUMOTime.h>
      44             : 
      45             : 
      46             : // ===========================================================================
      47             : // class declarations
      48             : // ===========================================================================
      49             : class GUIMainWindow;
      50             : class MSTrafficLightLogic;
      51             : class GUITrafficLightLogicWrapper;
      52             : 
      53             : 
      54             : // ===========================================================================
      55             : // class definitions
      56             : // ===========================================================================
      57             : /**
      58             :  * @class GUITLLogicPhasesTrackerWindow
      59             :  * @brief This window displays a phase diagram for a chosen tl-logic.
      60             :  */
      61             : class GUITLLogicPhasesTrackerWindow
      62             :     : public FXMainWindow,
      63             :       public ValueRetriever<std::pair<SUMOTime, MSPhaseDefinition> > {
      64           0 :     FXDECLARE(GUITLLogicPhasesTrackerWindow)
      65             : public:
      66             :     /** @brief Constructor to track current phases
      67             :      * @param[in] app The main application window
      68             :      * @param[in] logic The logic to track
      69             :      * @param[in] wrapper The tracked logic's wrapper
      70             :      * @param[in] src The value source to track
      71             :      */
      72             :     GUITLLogicPhasesTrackerWindow(GUIMainWindow& app,
      73             :                                   MSTrafficLightLogic& logic, GUITrafficLightLogicWrapper& wrapper,
      74             :                                   ValueSource<std::pair<SUMOTime, MSPhaseDefinition> >* src);
      75             : 
      76             : 
      77             :     /** @brief Constructor to show the complete phase diagram
      78             :      * @param[in] app The main application window
      79             :      * @param[in] logic The logic to show
      80             :      * @param[in] wrapper The shown logic's wrapper
      81             :      * @param[in] phases The phases to show
      82             :      */
      83             :     GUITLLogicPhasesTrackerWindow(
      84             :         GUIMainWindow& app,
      85             :         MSTrafficLightLogic& logic, GUITrafficLightLogicWrapper& wrapper,
      86             :         const MSSimpleTrafficLightLogic::Phases& phases);
      87             : 
      88             : 
      89             :     /// @brief Destructor
      90             :     ~GUITLLogicPhasesTrackerWindow();
      91             : 
      92             : 
      93             :     /// @brief Creates the window (FOX-Toolkit)
      94             :     void create();
      95             : 
      96             : 
      97             :     /** @brief Adds a further phase definition
      98             :      * @param[in] def The definition to add
      99             :      */
     100             :     void addValue(std::pair<SUMOTime, MSPhaseDefinition> def);
     101             : 
     102             : 
     103             :     /** @brief Sets the time the display shall be shown as beginning at
     104             :      * @param[in] time The time to start to show the phases from
     105             :      */
     106             :     void setBeginTime(SUMOTime time);
     107             : 
     108             : 
     109             :     /// @name FOX-callbacks
     110             :     /// {
     111             : 
     112             :     /// @brief called on size change
     113             :     long onConfigure(FXObject* sender, FXSelector sel, void* ptr);
     114             : 
     115             :     /// @brief called if the widget shall be repainted
     116             :     long onPaint(FXObject* sender, FXSelector sel, void* ptr);
     117             : 
     118             :     /// @brief called on a simulation step
     119             :     long onSimStep(FXObject* sender, FXSelector sel, void* ptr);
     120             : 
     121             :     /// }
     122             : 
     123             : 
     124             : 
     125             : public:
     126             :     /// @brief Definition of a storage for phases
     127             :     typedef std::vector<MSPhaseDefinition> PhasesVector;
     128             : 
     129             :     /// @brief Definition of a storage for durations
     130             :     typedef std::vector<SUMOTime> DurationsVector;
     131             : 
     132             :     /// @brief Definition of a storage for indices
     133             :     typedef std::vector<int> IndexVector;
     134             : 
     135             :     /// @brief Definition of a storage for detector and condition states
     136             :     typedef std::vector<std::vector<double > > AdditionalStatesVector;
     137             : 
     138             :     /**
     139             :      * @class GUITLLogicPhasesTrackerPanel
     140             :      * @brief The canvas for the visualisation of phases
     141             :      *
     142             :      * The drawing itself id done by the parent.
     143             :      */
     144             :     class GUITLLogicPhasesTrackerPanel : public FXGLCanvas {
     145           0 :         FXDECLARE(GUITLLogicPhasesTrackerPanel)
     146             :     public:
     147             :         /** @brief Constructor
     148             :          * @param[in] c The container for this panel
     149             :          * @param[in] app The main application window
     150             :          * @param[in] parent This panel's logical parent
     151             :          */
     152             :         GUITLLogicPhasesTrackerPanel(FXComposite* c,
     153             :                                      GUIMainWindow& app, GUITLLogicPhasesTrackerWindow& parent);
     154             : 
     155             :         /// @brief Destructor
     156             :         ~GUITLLogicPhasesTrackerPanel();
     157             : 
     158             :         /// needed to update
     159             :         friend class GUITLLogicPhasesTrackerWindow;
     160             : 
     161             : 
     162             :         /// @name FOX-callbacks
     163             :         /// {
     164             : 
     165             :         /// @brief called on size change
     166             :         long onConfigure(FXObject*, FXSelector, void*);
     167             : 
     168             :         /// @brief called if the widget shall be repainted
     169             :         long onPaint(FXObject*, FXSelector, void*);
     170             : 
     171             :         /// @brief called on mouse movement (for updating tooltip)
     172             :         long onMouseMove(FXObject*, FXSelector, void*);
     173             :         /// }
     174             : 
     175             :         const Position& getMousePos() const {
     176             :             return myMousePos;
     177             :         };
     178             : 
     179             :     private:
     180             :         /// @brief The parent window
     181             :         GUITLLogicPhasesTrackerWindow* myParent;
     182             : 
     183             :         Position myMousePos;
     184             : 
     185             :     protected:
     186             :         /// @brief protected constructor for FOX
     187           0 :         GUITLLogicPhasesTrackerPanel() { }
     188             : 
     189             :     };
     190             : 
     191             : 
     192             :     /** @brief Draws all values
     193             :      * @param[in] The target panel
     194             :      */
     195             :     void drawValues(GUITLLogicPhasesTrackerPanel& caller);
     196             : 
     197             : 
     198             : private:
     199             :     /// @brief The main application
     200             :     GUIMainWindow* myApplication;
     201             : 
     202             :     /// @brief The logic to display
     203             :     MSTrafficLightLogic* myTLLogic;
     204             : 
     205             :     /// @brief The list of phases
     206             :     PhasesVector myPhases;
     207             : 
     208             :     /// @brief The list of phase durations
     209             :     DurationsVector myDurations;
     210             : 
     211             :     /// @brief The time within the cycle for the current phase
     212             :     DurationsVector myTimeInCycle;
     213             : 
     214             :     /// @brief The index of the current phase
     215             :     IndexVector myPhaseIndex;
     216             : 
     217             :     /// @brief The state of all used detectors of the current phase
     218             :     AdditionalStatesVector myDetectorStates;
     219             :     AdditionalStatesVector myConditionStates;
     220             : 
     221             :     /// @brief The list of detector state durations
     222             :     DurationsVector myDetectorDurations;
     223             :     DurationsVector myConditionDurations;
     224             : 
     225             :     /// @brief The panel to draw on
     226             :     GUITLLogicPhasesTrackerPanel* myPanel;
     227             : 
     228             :     /// @brief A lock to avoid addition of new values while drawing
     229             :     FXMutex myLock;
     230             : 
     231             :     /** @brief The names of links
     232             :      *
     233             :      * This holds an enumeration only - used to avoid time consuming string representation of ints */
     234             :     std::vector<std::string> myLinkNames;
     235             :     std::vector<std::string> myDetectorNames;
     236             :     std::vector<std::string> myConditionNames;
     237             : 
     238             :     /// @brief The index of the first phase that fits into the window
     239             :     int myFirstPhase2Show;
     240             :     int myFirstDet2Show;
     241             :     int myFirstCond2Show;
     242             : 
     243             :     /// @brief The offset to draw the first phase (left offset)
     244             :     SUMOTime myFirstPhaseOffset;
     245             :     SUMOTime myFirstDetOffset;
     246             :     SUMOTime myFirstCondOffset;
     247             : 
     248             :     /// @brief The time the diagram begins at
     249             :     SUMOTime myFirstTime2Show;
     250             : 
     251             :     /// @brief The first time a phase was added at
     252             :     SUMOTime myBeginTime;
     253             : 
     254             :     /// @brief The last time a phase was added at
     255             :     SUMOTime myLastTime;
     256             : 
     257             :     /// @brief The connector for retrieval of further phases
     258             :     GLObjectValuePassConnector<std::pair<SUMOTime, MSPhaseDefinition> >* myConnector;
     259             : 
     260             :     /// @brief Information whether the tracking mode is on
     261             :     bool myAmInTrackingMode;
     262             : 
     263             :     /// @brief The tool bar drag (tracking mode)
     264             :     FXToolBarShell* myToolBarDrag;
     265             : 
     266             :     /// @brief The tool bar (tracking mode)
     267             :     FXToolBar* myToolBar;
     268             : 
     269             :     /// @brief The offset changer (tracking mode)
     270             :     FXRealSpinner* myBeginOffset;
     271             : 
     272             :     /// @brief The time mode
     273             :     MFXComboBoxIcon* myTimeMode;
     274             : 
     275             :     /// @brief Whether green durations are printed
     276             :     MFXComboBoxIcon* myGreenMode;
     277             : 
     278             :     /// @brief Whether phase names shall be printed instead of indices
     279             :     FXCheckButton* myIndexMode;
     280             : 
     281             :     /// @brief Whether detector states are drawn
     282             :     FXCheckButton* myDetectorMode;
     283             : 
     284             :     /// @brief Whether detector states are drawn
     285             :     FXCheckButton* myConditionMode;
     286             : 
     287             :     /// @brief y-Position of previously opened window
     288             :     static int myLastY;
     289             : 
     290             : private:
     291             : 
     292             :     void initToolBar();
     293             : 
     294             :     void saveSettings();
     295             :     void loadSettings();
     296             : 
     297             :     /// @brief compute required windowHeight
     298             :     int computeHeight();
     299             : 
     300             :     /// @brief draw row title
     301             :     void drawNames(const std::vector<std::string>& names, double fontHeight, double fontWidth, double divHeight, double divWidth, double& h, int extraLines);
     302             : 
     303             :     /// @brief draw detector and condition states
     304             :     void drawAdditionalStates(GUITLLogicPhasesTrackerPanel& caller,
     305             :                               const AdditionalStatesVector& states, const DurationsVector& durations,
     306             :                               SUMOTime firstOffset, int first2Show, double hStart,
     307             :                               double panelWidth, double leftOffset, double barWidth, double stateHeight, double h20, double& h);
     308             : 
     309             :     /// @brief find time in cycle based on myTimeInCycle
     310             :     SUMOTime findTimeInCycle(SUMOTime t);
     311             : 
     312             : protected:
     313             :     /// protected constructor for FOX
     314           0 :     GUITLLogicPhasesTrackerWindow() { }
     315             : 
     316             : 
     317             : };

Generated by: LCOV version 1.14