Eclipse SUMO - Simulation of Urban MObility
GNERide.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 rides in Netedit
15 /****************************************************************************/
16 #ifndef GNERide_h
17 #define GNERide_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 GNERide : public GNEDemandElement, public Parameterised {
39 
40 public:
47  GNERide(GNEViewNet* viewNet, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEEdge* toEdge,
48  const std::vector<GNEEdge*>& via, double arrivalPosition, const std::vector<std::string>& lines);
49 
56  GNERide(GNEViewNet* viewNet, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEAdditional* busStop,
57  const std::vector<GNEEdge*>& via, const std::vector<std::string>& lines);
58 
60  ~GNERide();
61 
65  void writeDemandElement(OutputDevice& device) const;
66 
68  bool isDemandElementValid() const;
69 
71  std::string getDemandElementProblem() const;
72 
75 
79  GNEEdge* getFromEdge() const;
80 
82  GNEEdge* getToEdge() const;
83 
86 
88  const RGBColor& getColor() const;
89 
91 
95  void startGeometryMoving();
96 
98  void endGeometryMoving();
99 
103  void moveGeometry(const Position& offset);
104 
108  void commitGeometryMoving(GNEUndoList* undoList);
109 
111  void updateGeometry();
112 
114  void updatePartialGeometry(const GNEEdge* edge);
115 
117  void computePath();
118 
120  void invalidatePath();
121 
123  Position getPositionInView() const;
125 
128 
137 
141  std::string getParentName() const;
142 
147 
149  void splitEdgeGeometry(const double splitPosition, const GNENetElement* originalElement, const GNENetElement* newElement, GNEUndoList* undoList);
150 
155  void drawGL(const GUIVisualizationSettings& s) const;
157 
161  void selectAttributeCarrier(bool changeFlag = true);
162 
164  void unselectAttributeCarrier(bool changeFlag = true);
165 
166  /* @brief method for getting the Attribute of an XML key
167  * @param[in] key The attribute key
168  * @return string with the value associated to key
169  */
170  std::string getAttribute(SumoXMLAttr key) const;
171 
172  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
173  * @param[in] key The attribute key
174  * @return double with the value associated to key
175  */
176  double getAttributeDouble(SumoXMLAttr key) const;
177 
178  /* @brief method for setting the attribute and letting the object perform additional changes
179  * @param[in] key The attribute key
180  * @param[in] value The new value
181  * @param[in] undoList The undoList on which to register changes
182  * @param[in] net optionally the GNENet to inform about gui updates
183  */
184  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
185 
186  /* @brief method for setting the attribute and letting the object perform additional changes
187  * @param[in] key The attribute key
188  * @param[in] value The new value
189  * @param[in] undoList The undoList on which to register changes
190  */
191  bool isValid(SumoXMLAttr key, const std::string& value);
192 
193  /* @brief method for enable attribute
194  * @param[in] key The attribute key
195  * @param[in] undoList The undoList on which to register changes
196  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
197  */
198  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
199 
200  /* @brief method for disable attribute
201  * @param[in] key The attribute key
202  * @param[in] undoList The undoList on which to register changes
203  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
204  */
205  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
206 
207  /* @brief method for check if the value for certain attribute is set
208  * @param[in] key The attribute key
209  */
210  bool isAttributeEnabled(SumoXMLAttr key) const;
211 
213  std::string getPopUpID() const;
214 
216  std::string getHierarchyName() const;
218 
219 protected:
222 
225 
227  std::vector<std::string> myLines;
228 
229 private:
231  void setAttribute(SumoXMLAttr key, const std::string& value);
232 
234  void setEnabledAttribute(const int enabledAttributes);
235 
237  GNERide(GNERide*) = delete;
238 
240  GNERide& operator=(GNERide*) = delete;
241 };
242 
243 
244 #endif
245 
246 /****************************************************************************/
247 
GNERide::getAttributeDouble
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNERide.cpp:448
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
GNERide::updatePartialGeometry
void updatePartialGeometry(const GNEEdge *edge)
partial update pre-computed geometry information
Definition: GNERide.cpp:287
GNEDemandElement
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEDemandElement.h:55
GNERide::getToEdge
GNEEdge * getToEdge() const
obtain to edge of this demand element
Definition: GNERide.cpp:180
GNEAdditional
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
GNERide::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNERide.cpp:77
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:42
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
GNERide::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
inherited from GNEAttributeCarrier
Definition: GNERide.cpp:384
GNERide::computePath
void computePath()
compute path
Definition: GNERide.cpp:308
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
GNERide::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNERide.cpp:548
GNERide::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNERide.cpp:485
GNERide::~GNERide
~GNERide()
destructor
Definition: GNERide.cpp:73
GUIGLObjectPopupMenu.h
GNEDemandElement::DemandElementMove
struct for pack all variables related with Demand Element moving
Definition: GNEDemandElement.h:59
GNERide::endGeometryMoving
void endGeometryMoving()
end geometry movement
Definition: GNERide.cpp:217
GNERide::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNERide.cpp:536
GNERide::getDemandElementProblem
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNERide.cpp:146
GNEViewNet
Definition: GNEViewNet.h:42
GNERide::myRideMove
DemandElementMove myRideMove
variable for move rides
Definition: GNERide.h:221
GNERide::writeDemandElement
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNERide.cpp:102
GNERide::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNERide.cpp:378
GNERide::GNERide
GNERide(GNEViewNet *viewNet, GNEDemandElement *personParent, GNEEdge *fromEdge, GNEEdge *toEdge, const std::vector< GNEEdge * > &via, double arrivalPosition, const std::vector< std::string > &lines)
parameter constructor for rideEdges
Definition: GNERide.cpp:43
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:47
GNERide::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNERide.cpp:542
GNERide::moveGeometry
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNERide.cpp:227
GNERide
Definition: GNERide.h:38
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:51
RGBColor
Definition: RGBColor.h:39
GNERide::getFromEdge
GNEEdge * getFromEdge() const
Definition: GNERide.cpp:169
GNERide::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: GNERide.cpp:463
GNEDemandElement.h
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GNERide::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNERide.cpp:260
GNERide::fixDemandElementProblem
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNERide.cpp:163
GNERide::myArrivalPosition
double myArrivalPosition
arrival position
Definition: GNERide.h:224
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GNERide::commitGeometryMoving
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
Definition: GNERide.cpp:249
GNERide::setEnabledAttribute
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNERide.cpp:618
GNENetElement
Definition: GNENetElement.h:43
GNERide::getVClass
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNERide.cpp:191
GNERide::myLines
std::vector< std::string > myLines
valid line or vehicle ids or ANY
Definition: GNERide.h:227
GNERide::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNERide.cpp:399
GNERide::invalidatePath
void invalidatePath()
invalidate path
Definition: GNERide.cpp:326
GNERide::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNERide.cpp:415
GUIMainWindow
Definition: GUIMainWindow.h:46
GNERide::getParentName
std::string getParentName() const
Returns the name of the parent object.
Definition: GNERide.cpp:350
GNERide::operator=
GNERide & operator=(GNERide *)=delete
Invalidated assignment operator.
GNEVehicle
Definition: GNEVehicle.h:35
GNEConnection
Definition: GNEConnection.h:38
GNERide::getColor
const RGBColor & getColor() const
get color
Definition: GNERide.cpp:197
GNERide::enableAttribute
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERide.cpp:524
GNERide::isDemandElementValid
bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNERide.cpp:127
GNEUndoList
Definition: GNEUndoList.h:48
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GNERide::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNERide.cpp:344
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
GNERide::splitEdgeGeometry
void splitEdgeGeometry(const double splitPosition, const GNENetElement *originalElement, const GNENetElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNERide.cpp:372
GNERide::startGeometryMoving
void startGeometryMoving()
Definition: GNERide.cpp:203
GNERide::disableAttribute
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERide.cpp:530
GNERide::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNERide.cpp:356