Eclipse SUMO - Simulation of Urban MObility
GNEWalk.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2016-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 /****************************************************************************/
14 // A class for visualizing walks in Netedit
15 /****************************************************************************/
16 #ifndef GNEWalk_h
17 #define GNEWalk_h
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 
24 #include "GNEDemandElement.h"
26 
27 // ===========================================================================
28 // class declarations
29 // ===========================================================================
30 class GNEEdge;
31 class GNEConnection;
32 class GNEVehicle;
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
37 
38 class GNEWalk : public GNEDemandElement, public Parameterised {
39 
40 public:
47  GNEWalk(GNEViewNet* viewNet, GNEDemandElement* personParent, const std::vector<GNEEdge*>& edges, double arrivalPosition);
48 
55  GNEWalk(GNEViewNet* viewNet, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEEdge* toEdge,
56  const std::vector<GNEEdge*>& via, double arrivalPosition);
57 
64  GNEWalk(GNEViewNet* viewNet, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEAdditional* busStop,
65  const std::vector<GNEEdge*>& via);
66 
73  GNEWalk(GNEViewNet* viewNet, GNEDemandElement* personParent, GNEDemandElement* routeParent, double arrivalPosition);
74 
76  ~GNEWalk();
77 
81  void writeDemandElement(OutputDevice& device) const;
82 
84  bool isDemandElementValid() const;
85 
87  std::string getDemandElementProblem() const;
88 
91 
95  GNEEdge* getFromEdge() const;
96 
98  GNEEdge* getToEdge() const;
99 
101  SUMOVehicleClass getVClass() const;
102 
104  const RGBColor& getColor() const;
105 
107 
111  void startGeometryMoving();
112 
114  void endGeometryMoving();
115 
119  void moveGeometry(const Position& offset);
120 
124  void commitGeometryMoving(GNEUndoList* undoList);
125 
127  void updateGeometry();
128 
130  void updatePartialGeometry(const GNEEdge* edge);
131 
133  void computePath();
134 
136  void invalidatePath();
137 
139  Position getPositionInView() const;
141 
144 
153 
157  std::string getParentName() const;
158 
163 
165  void splitEdgeGeometry(const double splitPosition, const GNENetElement* originalElement, const GNENetElement* newElement, GNEUndoList* undoList);
166 
171  void drawGL(const GUIVisualizationSettings& s) const;
173 
177  void selectAttributeCarrier(bool changeFlag = true);
178 
180  void unselectAttributeCarrier(bool changeFlag = true);
181 
182  /* @brief method for getting the Attribute of an XML key
183  * @param[in] key The attribute key
184  * @return string with the value associated to key
185  */
186  std::string getAttribute(SumoXMLAttr key) const;
187 
188  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
189  * @param[in] key The attribute key
190  * @return double with the value associated to key
191  */
192  double getAttributeDouble(SumoXMLAttr key) const;
193 
194  /* @brief method for setting the attribute and letting the object perform additional changes
195  * @param[in] key The attribute key
196  * @param[in] value The new value
197  * @param[in] undoList The undoList on which to register changes
198  * @param[in] net optionally the GNENet to inform about gui updates
199  */
200  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
201 
202  /* @brief method for setting the attribute and letting the object perform additional changes
203  * @param[in] key The attribute key
204  * @param[in] value The new value
205  * @param[in] undoList The undoList on which to register changes
206  */
207  bool isValid(SumoXMLAttr key, const std::string& value);
208 
209  /* @brief method for enable attribute
210  * @param[in] key The attribute key
211  * @param[in] undoList The undoList on which to register changes
212  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
213  */
214  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
215 
216  /* @brief method for disable attribute
217  * @param[in] key The attribute key
218  * @param[in] undoList The undoList on which to register changes
219  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
220  */
221  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
222 
223  /* @brief method for check if the value for certain attribute is set
224  * @param[in] key The attribute key
225  */
226  bool isAttributeEnabled(SumoXMLAttr key) const;
227 
229  std::string getPopUpID() const;
230 
232  std::string getHierarchyName() const;
234 
235 protected:
238 
241 
242 private:
244  void setAttribute(SumoXMLAttr key, const std::string& value);
245 
247  void setEnabledAttribute(const int enabledAttributes);
248 
250  GNEWalk(GNEWalk*) = delete;
251 
253  GNEWalk& operator=(GNEWalk*) = delete;
254 };
255 
256 
257 #endif
258 
259 /****************************************************************************/
260 
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
GNEWalk::computePath
void computePath()
compute path
Definition: GNEWalk.cpp:337
GNEDemandElement
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEDemandElement.h:55
GNEAdditional
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:42
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
GNEWalk::GNEWalk
GNEWalk(GNEViewNet *viewNet, GNEDemandElement *personParent, const std::vector< GNEEdge * > &edges, double arrivalPosition)
parameter constructor for walkEdges
Definition: GNEWalk.cpp:43
GNEWalk::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEWalk.cpp:454
GNEWalk::moveGeometry
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNEWalk.cpp:252
GNEWalk::commitGeometryMoving
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
Definition: GNEWalk.cpp:274
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
GNEWalk::setEnabledAttribute
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNEWalk.cpp:674
GNEWalk::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEWalk.cpp:597
GNEWalk::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEWalk.cpp:585
GNEWalk::splitEdgeGeometry
void splitEdgeGeometry(const double splitPosition, const GNENetElement *originalElement, const GNENetElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNEWalk.cpp:401
GUIGLObjectPopupMenu.h
GNEDemandElement::DemandElementMove
struct for pack all variables related with Demand Element moving
Definition: GNEDemandElement.h:59
GNEWalk
Definition: GNEWalk.h:38
GNEViewNet
Definition: GNEViewNet.h:42
GNEWalk::getVClass
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNEWalk.cpp:216
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:47
GNEWalk::operator=
GNEWalk & operator=(GNEWalk *)=delete
Invalidated assignment operator.
GNEWalk::myWalkMove
DemandElementMove myWalkMove
variable for move walks
Definition: GNEWalk.h:237
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:51
GNEWalk::writeDemandElement
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNEWalk.cpp:116
RGBColor
Definition: RGBColor.h:39
GNEWalk::isDemandElementValid
bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNEWalk.cpp:148
GNEWalk::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEWalk.cpp:527
GNEWalk::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEWalk.cpp:91
GNEWalk::getAttributeDouble
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNEWalk.cpp:489
GNEWalk::getColor
const RGBColor & getColor() const
get color
Definition: GNEWalk.cpp:222
GNEDemandElement.h
GNEWalk::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEWalk.cpp:591
GNEWalk::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNEWalk.cpp:438
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GNEWalk::enableAttribute
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEWalk.cpp:573
GNEWalk::updatePartialGeometry
void updatePartialGeometry(const GNEEdge *edge)
partial update pre-computed geometry information
Definition: GNEWalk.cpp:316
GNEWalk::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEWalk.cpp:373
GNENetElement
Definition: GNENetElement.h:43
GNEWalk::startGeometryMoving
void startGeometryMoving()
Definition: GNEWalk.cpp:228
GNEWalk::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNEWalk.cpp:285
GNEWalk::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
Definition: GNEWalk.cpp:504
GNEWalk::~GNEWalk
~GNEWalk()
destructor
Definition: GNEWalk.cpp:87
GNEWalk::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
inherited from GNEAttributeCarrier
Definition: GNEWalk.cpp:423
GNEWalk::disableAttribute
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEWalk.cpp:579
GNEWalk::myArrivalPosition
double myArrivalPosition
arrival position
Definition: GNEWalk.h:240
GUIMainWindow
Definition: GUIMainWindow.h:46
GNEWalk::getToEdge
GNEEdge * getToEdge() const
obtain to edge of this demand element
Definition: GNEWalk.cpp:205
GNEWalk::fixDemandElementProblem
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNEWalk.cpp:188
GNEVehicle
Definition: GNEVehicle.h:35
GNEConnection
Definition: GNEConnection.h:38
GNEWalk::endGeometryMoving
void endGeometryMoving()
end geometry movement
Definition: GNEWalk.cpp:242
GNEWalk::invalidatePath
void invalidatePath()
invalidate path
Definition: GNEWalk.cpp:355
GNEWalk::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEWalk.cpp:417
GNEWalk::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEWalk.cpp:385
GNEUndoList
Definition: GNEUndoList.h:48
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GNEWalk::getDemandElementProblem
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNEWalk.cpp:169
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
GNEWalk::getFromEdge
GNEEdge * getFromEdge() const
Definition: GNEWalk.cpp:194
GNEWalk::getParentName
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEWalk.cpp:379