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 GUIE2Collector.h 15 : /// @author Daniel Krajzewicz 16 : /// @author Jakob Erdmann 17 : /// @author Michael Behrisch 18 : /// @date Okt 2003 19 : /// 20 : // The gui-version of the MS_E2_ZS_Collector 21 : /****************************************************************************/ 22 : #pragma once 23 : #include <config.h> 24 : 25 : #include <microsim/output/MSE2Collector.h> 26 : #include "GUIDetectorWrapper.h" 27 : 28 : 29 : // =========================================================================== 30 : // class definitions 31 : // =========================================================================== 32 : /** 33 : * @class GUIE2Collector 34 : * @brief The gui-version of the MSE2Collector 35 : * 36 : * Allows the building of a wrapper (also declared herein) which draws the 37 : * detector on the gl-canvas. Beside this, the method "amVisible" is 38 : * overridden to signalise that this detector is not used for simulation- 39 : * -internal reasons, but is placed over the simulation by the user. 40 : */ 41 : class GUIE2Collector : public MSE2Collector { 42 : public: 43 : /** @brief Constructor with given end position and detector length 44 : * 45 : * @param[in] id The detector's unique id. 46 : * @param[in] usage Information how the detector is used 47 : * @param[in] lane The lane the detector ends 48 : * @param[in] startPos The start position on the lane the detector is placed at 49 : * @param[in] endPos The end position on the lane the detector is placed at 50 : * @param[in] length The length the detector has (heuristic lane selection is done if the continuation is not unique) 51 : * @param[in] haltingTimeThreshold The time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed 52 : * @param[in] haltingSpeedThreshold The speed a vehicle's speed must be below to be assigned as jammed 53 : * @param[in] jamDistThreshold The distance between two vehicles in order to not count them to one jam 54 : * @param[in] vTypes Vehicle types, that the detector takes into account 55 : * @param[in] friendlyPositioning Whether positions should be corrected to "snap" on lane beginnings or ends if closer than POS_EPSILON 56 : * @param[in] showDetector Whether the detector should be visible in the GUI 57 : * 58 : * @note Exactly one of the arguments startPos, endPos and length should be invalid (i.e. equal to std::numeric_limits<double>::max()). 59 : * If length is invalid, it is required that 0 <= startPos < endPos <= lane->length 60 : * If endPos is invalid, the detector may span over several lanes downstream of the lane 61 : * If pos is invalid, the detector may span over several lanes upstream of the lane 62 : */ 63 : GUIE2Collector(const std::string& id, DetectorUsage usage, 64 : MSLane* lane, double startPos, double endPos, double detLength, 65 : SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold, 66 : const std::string name, const std::string& vTypes, 67 : const std::string& nextEdges, 68 : int detectPersons, bool showDetector); 69 : 70 : 71 : /** @brief Constructor with a sequence of lanes and given start and end position on the first and last lanes 72 : * 73 : * @param[in] id The detector's unique id. 74 : * @param[in] usage Information how the detector is used 75 : * @param[in] lanes A sequence of lanes the detector covers (must form a continuous piece) 76 : * @param[in] startPos The position of the detector start on the first lane the detector is placed at 77 : * @param[in] endPos The position of the detector end on the last lane the detector is placed at 78 : * @param[in] haltingTimeThreshold The time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed 79 : * @param[in] haltingSpeedThreshold The speed a vehicle's speed must be below to be assigned as jammed 80 : * @param[in] jamDistThreshold The distance between two vehicles in order to not count them to one jam 81 : * @param[in] vTypes Vehicle types, that the detector takes into account 82 : * @param[in] friendlyPositioning Whether positions should be corrected to "snap" on lane beginnings or ends if closer than POS_EPSILON 83 : * @param[in] showDetector Whether the detector should be visible in the GUI 84 : */ 85 : GUIE2Collector(const std::string& id, DetectorUsage usage, 86 : std::vector<MSLane*> lanes, double startPos, double endPos, 87 : SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold, 88 : const std::string name, const std::string& vTypes, 89 : const std::string& nextEdges, 90 : int detectPersons, bool showDetector); 91 : 92 : 93 : /// @brief Destructor 94 : ~GUIE2Collector(); 95 : 96 : 97 : /** @brief Returns the wrapper for this detector 98 : * @return The wrapper representing the detector 99 : * @see MyWrapper 100 : */ 101 : virtual GUIDetectorWrapper* buildDetectorGUIRepresentation(); 102 : 103 : /// @brief whether the induction loop shall be visible 104 : bool isVisible() const { 105 : return myShow; 106 : } 107 : 108 : /// @brief toggle visibility 109 0 : void setVisible(bool show) { 110 0 : myShow = show; 111 0 : } 112 : 113 : 114 : private: 115 : /// @brief Whether the detector shall be drawn in the gui 116 : bool myShow; 117 : 118 : public: 119 : /** 120 : * @class GUIE2Collector::MyWrapper 121 : * A GUIE2Collector-visualiser 122 : */ 123 : class MyWrapper : public GUIDetectorWrapper { 124 : public: 125 : /// @brief Constructor 126 : MyWrapper(GUIE2Collector& detector); 127 : 128 : /// @brief Destrutor 129 : ~MyWrapper(); 130 : 131 : /// @name inherited from GUIGlObject 132 : //@{ 133 : 134 : /** @brief Returns an own parameter window 135 : * 136 : * @param[in] app The application needed to build the parameter window 137 : * @param[in] parent The parent window needed to build the parameter window 138 : * @return The built parameter window 139 : * @see GUIGlObject::getParameterWindow 140 : */ 141 : GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent) override; 142 : 143 : /// @brief return exaggeration associated with this GLObject 144 : double getExaggeration(const GUIVisualizationSettings& s) const override; 145 : 146 : /** @brief Returns the boundary to which the view shall be centered in order to show the object 147 : * 148 : * @return The boundary the object is within 149 : * @see GUIGlObject::getCenteringBoundary 150 : */ 151 : Boundary getCenteringBoundary() const override; 152 : 153 : /** @brief Draws the object 154 : * @param[in] s The settings for the current view (may influence drawing) 155 : * @see GUIGlObject::drawGL 156 : */ 157 : void drawGL(const GUIVisualizationSettings& s) const override; 158 : //@} 159 : 160 : 161 : /// @brief Returns the detector itself 162 : GUIE2Collector& getDetector(); 163 : 164 : protected: 165 : /// @brief whether this detector has an active virtual detector call 166 : bool haveOverride() const override; 167 : 168 : /// @brief toggle virtual detector call 169 : void toggleOverride() const override; 170 : 171 : private: 172 : /// @brief The wrapped detector 173 : GUIE2Collector& myDetector; 174 : 175 : /// @brief The detector's boundary 176 : Boundary myBoundary; 177 : 178 : /// @brief A sequence of positions in full-geometry mode 179 : PositionVector myFullGeometry; 180 : 181 : /// @brief A sequence of lengths in full-geometry mode 182 : std::vector<double> myShapeLengths; 183 : 184 : /// @brief A sequence of rotations in full-geometry mode 185 : std::vector<double> myShapeRotations; 186 : 187 : private: 188 : /// @brief Invalidated copy constructor. 189 : MyWrapper(const MyWrapper&); 190 : 191 : /// @brief Invalidated assignment operator. 192 : MyWrapper& operator=(const MyWrapper&); 193 : 194 : }; 195 : 196 : };