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    GNEAccess.h
11 /// @author  Pablo Alvarez Lopez
12 /// @date    Jun 2018
13 /// @version $Id$
14 ///
15 //
16 /****************************************************************************/
17 #ifndef GNEAccess_h
18 #define GNEAccess_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 
25 #include "GNEAdditional.h"
26 
27 // ===========================================================================
28 // class declarations
29 // ===========================================================================
30 class GNEBusStop;
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
35 /**
36  * @class GNEAccess
37  * class for busStop acces
38  */
39 class GNEAccess : public GNEAdditional {
40 
41 public:
42     /**@brief Constructor
43      * @param[in] id The storage of gl-ids to get the one for this lane representation from
44      * @param[in] busStop GNEBusStop of this Access belongs
45      * @param[in] lane GNELane of this Access belongs
46      * @param[in] viewNet pointer to GNEViewNet of this additional element belongs
47      * @param[in] pos position of the Access on the lane
48      * @param[in] length The length of the Access in meters.
49      * @param[in] friendlyPos enable or disable friendly positions
50      * @param[in] block movement enable or disable additional movement
51      */
52     GNEAccess(GNEAdditional* busStop, GNELane* lane, GNEViewNet* viewNet, const std::string& pos, const std::string& length, bool friendlyPos, bool blockMovement);
53 
54     /// @brief Destructor
55     ~GNEAccess();
56 
57     /// @brief check if Position of Access is fixed
58     bool isAccessPositionFixed() const;
59 
60     /// @brief get edge in which this Access is placed
61     GNEEdge& getEdge() const;
62 
63     /// @name Functions related with geometry of element
64     /// @{
65     /**@brief change the position of the element geometry without saving in undoList
66      * @param[in] offset Position used for calculate new position of geometry without updating RTree
67      */
68     void moveGeometry(const Position& offset);
69 
70     /**@brief commit geometry changes in the attributes of an element after use of moveGeometry(...)
71     * @param[in] undoList The undoList on which to register changes
72     */
73     void commitGeometryMoving(GNEUndoList* undoList);
74 
75     /// @brief update pre-computed geometry information
76     void updateGeometry(bool updateGrid);
77 
78     /// @brief Returns position of additional in view
79     Position getPositionInView() const ;
80     /// @}
81 
82     /// @name inherited from GUIGlObject
83     /// @{
84     /// @brief Returns the name (ID) of the parent object
85     std::string getParentName() const;
86 
87     /// @{
88     /**@brief Draws the object
89      * @param[in] s The settings for the current view (may influence drawing)
90      * @see GUIGlObject::drawGL
91      */
92     void drawGL(const GUIVisualizationSettings& s) const;
93     /// @}
94 
95     /// @name inherited from GNEAttributeCarrier
96     /// @{
97     /* @brief method for getting the Attribute of an XML key
98      * @param[in] key The attribute key
99      * @return string with the value associated to key
100      */
101     std::string getAttribute(SumoXMLAttr key) const;
102 
103     /* @brief method for setting the attribute and letting the object perform additional changes
104      * @param[in] key The attribute key
105      * @param[in] value The new value
106      * @param[in] undoList The undoList on which to register changes
107      */
108     void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
109 
110     /* @brief method for checking if the key and their correspond attribute are valids
111      * @param[in] key The attribute key
112      * @param[in] value The value asociated to key key
113      * @return true if the value is valid, false in other case
114      */
115     bool isValid(SumoXMLAttr key, const std::string& value);
116 
117     /// @brief get PopPup ID (Used in AC Hierarchy)
118     std::string getPopUpID() const;
119 
120     /// @brief get Hierarchy Name (Used in AC Hierarchy)
121     std::string getHierarchyName() const;
122     /// @}
123 
124 protected:
125     /// @brief position over lane
126     std::string myPositionOverLane;
127 
128     /// @brief Acces lenght
129     std::string myLength;
130 
131     /// @brief flag to check if friendly position is enabled
132     bool myFriendlyPosition;
133 
134 private:
135     /// @brief set attribute after validation
136     void setAttribute(SumoXMLAttr key, const std::string& value);
137 
138     /// @brief Invalidated copy constructor.
139     GNEAccess(const GNEAccess&) = delete;
140 
141     /// @brief Invalidated assignment operator.
142     GNEAccess& operator=(const GNEAccess&) = delete;
143 };
144 
145 #endif
146 /****************************************************************************/
147