1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file GNETAZ.h 11 /// @author Pablo Alvarez Lopez 12 /// @date Oct 2018 13 /// @version $Id$ 14 /// 15 // 16 /****************************************************************************/ 17 #ifndef GNETAZ_h 18 #define GNETAZ_h 19 20 21 // =========================================================================== 22 // included modules 23 // =========================================================================== 24 25 #include "GNEAdditional.h" 26 27 28 // =========================================================================== 29 // class definitions 30 // =========================================================================== 31 /** 32 * @class GNETAZ 33 * Class for multy Entry/multy Exits detectors 34 */ 35 class GNETAZ : public GNEAdditional { 36 37 public: 38 /**@brief GNETAZ Constructor 39 * @param[in] id The storage of gl-ids to get the one for this lane representation from 40 * @param[in] viewNet pointer to GNEViewNet of this additional element belongs 41 * @param[in] block movement enable or disable additional movement 42 */ 43 GNETAZ(const std::string& id, GNEViewNet* viewNet, PositionVector shape, RGBColor color, bool blockMovement); 44 45 /// @brief GNETAZ Destructor 46 ~GNETAZ(); 47 48 /// @name Functions related with geometry of element 49 /// @{ 50 /**@brief change the position of the element geometry without saving in undoList 51 * @param[in] offset Position used for calculate new position of geometry without updating RTree 52 */ 53 void moveGeometry(const Position& offset); 54 55 /**@brief commit geometry changes in the attributes of an element after use of moveGeometry(...) 56 * @param[in] undoList The undoList on which to register changes 57 */ 58 void commitGeometryMoving(GNEUndoList* undoList); 59 60 /// @brief update pre-computed geometry information 61 void updateGeometry(bool updateGrid); 62 63 /// @brief Returns position of additional in view 64 Position getPositionInView() const; 65 /// @} 66 67 /// @name Functions related with shape of element 68 /// @{ 69 /**@brief change position of a vertex of shape without commiting change 70 * @param[in] index index of Vertex shape 71 * @param[in] newPos The new position of vertex 72 * @return index of vertex (in some cases index can change 73 */ 74 int moveVertexShape(const int index, const Position& oldPos, const Position& offset); 75 76 /**@brief move entire shape without commiting change 77 * @param[in] oldShape the old shape of polygon before moving 78 * @param[in] offset the offset of movement 79 */ 80 void moveEntireShape(const PositionVector& oldShape, const Position& offset); 81 82 /**@brief commit geometry changes in the attributes of an element after use of changeShapeGeometry(...) 83 * @param[in] oldShape the old shape of polygon 84 * @param[in] undoList The undoList on which to register changes 85 */ 86 void commitShapeChange(const PositionVector& oldShape, GNEUndoList* undoList); 87 88 /**@brief return index of a vertex of shape, or of a new vertex if position is over an shape's edge 89 * @param pos position of new/existent vertex 90 * @param createIfNoExist enable or disable creation of new verte if there isn't another vertex in position 91 * @param snapToGrid enable or disable snapToActiveGrid 92 * @return index of position vector 93 */ 94 int getVertexIndex(Position pos, bool createIfNoExist, bool snapToGrid); 95 96 /// @brief delete the geometry point closest to the given pos 97 void deleteGeometryPoint(const Position& pos, bool allowUndo = true); 98 99 /// @brief return true if Shape TAZ is blocked 100 bool isShapeBlocked() const; 101 /// @} 102 103 /// @name inherited from GUIGlObject 104 /// @{ 105 /// @brief Returns the name of the parent object 106 /// @return This object's parent id 107 std::string getParentName() const; 108 109 /**@brief Draws the object 110 * @param[in] s The settings for the current view (may influence drawing) 111 * @see GUIGlObject::drawGL 112 */ 113 void drawGL(const GUIVisualizationSettings& s) const; 114 /// @} 115 116 /// @name inherited from GNEAttributeCarrier 117 /// @{ 118 /* @brief method for getting the Attribute of an XML key 119 * @param[in] key The attribute key 120 * @return string with the value associated to key 121 */ 122 std::string getAttribute(SumoXMLAttr key) const; 123 124 /* @brief method for setting the attribute and letting the object perform additional changes 125 * @param[in] key The attribute key 126 * @param[in] value The new value 127 * @param[in] undoList The undoList on which to register changes 128 */ 129 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList); 130 131 /* @brief method for checking if the key and their conrrespond attribute are valids 132 * @param[in] key The attribute key 133 * @param[in] value The value asociated to key key 134 * @return true if the value is valid, false in other case 135 */ 136 bool isValid(SumoXMLAttr key, const std::string& value); 137 138 /// @brief get PopPup ID (Used in AC Hierarchy) 139 std::string getPopUpID() const; 140 141 /// @brief get Hierarchy Name (Used in AC Hierarchy) 142 std::string getHierarchyName() const; 143 /// @} 144 145 /// @brief update TAZ after add or remove a Source/sink, or change their weight 146 void updateAdditionalParent(); 147 148 protected: 149 /// @brief TAZ Color 150 RGBColor myColor; 151 152 /// @brief flag for block shape 153 bool myBlockShape; 154 155 /// @brief index of vertex that is been moved (-1 means that none vertex is been moved) 156 int myCurrentMovingVertexIndex; 157 158 private: 159 /// @brief hint size of vertex 160 static const double myHintSize; 161 162 /// @brief squaredhint size of vertex 163 static const double myHintSizeSquared; 164 165 /// @brief Max source weight 166 double myMaxWeightSource; 167 168 /// @brief Min source weight 169 double myMinWeightSource; 170 171 /// @brief Average source weight 172 double myAverageWeightSource; 173 174 /// @brief Max Sink weight 175 double myMaxWeightSink; 176 177 /// @brief Min Sink weight 178 double myMinWeightSink; 179 180 /// @brief Average Sink weight 181 double myAverageWeightSink; 182 183 /// @brief set attribute after validation 184 void setAttribute(SumoXMLAttr key, const std::string& value); 185 186 /// @brief Invalidated copy constructor. 187 GNETAZ(const GNETAZ&) = delete; 188 189 /// @brief Invalidated assignment operator. 190 GNETAZ& operator=(const GNETAZ&) = delete; 191 }; 192 193 #endif 194 /****************************************************************************/ 195