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 /****************************************************************************/
15 // A class for visualizing rides in Netedit
16 /****************************************************************************/
17 #ifndef GNERide_h
18 #define GNERide_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 
25 
27 
28 #include "GNEDemandElement.h"
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class GNEEdge;
34 class GNEConnection;
35 class GNEVehicle;
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
40 
41 class GNERide : public GNEDemandElement, public Parameterised {
42 
43 public:
51  GNERide(GNEViewNet* viewNet, GNEDemandElement* personParent, const std::vector<GNEEdge*>& edges, double arrivalPosition, const std::vector<std::string>& lines);
52 
60  GNERide(GNEViewNet* viewNet, GNEDemandElement* personParent, const std::vector<GNEEdge*>& edges, GNEAdditional* busStop, const std::vector<std::string>& lines);
61 
63  ~GNERide();
64 
68  void writeDemandElement(OutputDevice& device) const;
69 
71  bool isDemandElementValid() const;
72 
74  std::string getDemandElementProblem() const;
75 
78 
82  GNEEdge* getFromEdge() const;
83 
85  GNEEdge* getToEdge() const;
86 
89 
91  const RGBColor& getColor() const;
92 
94  void compute();
95 
97 
101  void startGeometryMoving();
102 
104  void endGeometryMoving();
105 
109  void moveGeometry(const Position& offset);
110 
114  void commitGeometryMoving(GNEUndoList* undoList);
115 
117  void updateGeometry();
118 
120  Position getPositionInView() const;
122 
125 
134 
138  std::string getParentName() const;
139 
144 
149  void drawGL(const GUIVisualizationSettings& s) const;
151 
155  void selectAttributeCarrier(bool changeFlag = true);
156 
158  void unselectAttributeCarrier(bool changeFlag = true);
159 
160  /* @brief method for getting the Attribute of an XML key
161  * @param[in] key The attribute key
162  * @return string with the value associated to key
163  */
164  std::string getAttribute(SumoXMLAttr key) const;
165 
166  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
167  * @param[in] key The attribute key
168  * @return double with the value associated to key
169  */
170  double getAttributeDouble(SumoXMLAttr key) const;
171 
172  /* @brief method for setting the attribute and letting the object perform additional changes
173  * @param[in] key The attribute key
174  * @param[in] value The new value
175  * @param[in] undoList The undoList on which to register changes
176  * @param[in] net optionally the GNENet to inform about gui updates
177  */
178  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
179 
180  /* @brief method for setting the attribute and letting the object perform additional changes
181  * @param[in] key The attribute key
182  * @param[in] value The new value
183  * @param[in] undoList The undoList on which to register changes
184  */
185  bool isValid(SumoXMLAttr key, const std::string& value);
186 
187  /* @brief method for enabling attribute
188  * @param[in] key The attribute key
189  * @param[in] undoList The undoList on which to register changes
190  * @note only certain attributes can be enabled, and can produce the disabling of other attributes
191  */
192  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
193 
194  /* @brief method for check if the value for certain attribute is set
195  * @param[in] key The attribute key
196  */
197  bool isAttributeEnabled(SumoXMLAttr key) const;
198 
200  std::string getPopUpID() const;
201 
203  std::string getHierarchyName() const;
205 
209  std::string getGenericParametersStr() const;
210 
212  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
213 
215  void setGenericParametersStr(const std::string& value);
216 
218 
219 protected:
222 
224  std::vector<std::string> myLines;
225 
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:346
GNERide::compute
void compute()
compute demand element
Definition: GNERide.cpp:182
GNERide::GNERide
GNERide(GNEViewNet *viewNet, GNEDemandElement *personParent, const std::vector< GNEEdge * > &edges, double arrivalPosition, const std::vector< std::string > &lines)
parameter constructor
Definition: GNERide.cpp:44
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:134
GNEDemandElement
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEDemandElement.h:54
GNERide::getToEdge
GNEEdge * getToEdge() const
obtain to edge of this demand element
Definition: GNERide.cpp:164
GNEAdditional
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
GNERide::getGenericParameters
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
Definition: GNERide.cpp:453
GNERide::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNERide.cpp:66
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:43
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
GNERide::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
inherited from GNEAttributeCarrier
Definition: GNERide.cpp:288
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
GNERide::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNERide.cpp:428
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:378
GNERide::~GNERide
~GNERide()
destructor
Definition: GNERide.cpp:62
GUIGLObjectPopupMenu.h
GNEDemandElement::DemandElementMove
struct for pack all variables related with Demand Element moving
Definition: GNEDemandElement.h:155
GNERide::endGeometryMoving
void endGeometryMoving()
end geometry movement
Definition: GNERide.cpp:202
GNERide::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNERide.cpp:416
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:135
GNEViewNet
Definition: GNEViewNet.h:43
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:91
GNERide::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNERide.cpp:282
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:48
GNERide::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNERide.cpp:422
GNERide::moveGeometry
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNERide.cpp:212
GNERide
Definition: GNERide.h:41
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
RGBColor
Definition: RGBColor.h:40
GNERide::getFromEdge
GNEEdge * getFromEdge() const
Definition: GNERide.cpp:158
GNERide::setGenericParametersStr
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNERide.cpp:464
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:357
GNEDemandElement.h
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GNERide::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNERide.cpp:243
GNERide::fixDemandElementProblem
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNERide.cpp:152
GNERide::myArrivalPosition
double myArrivalPosition
arrival position
Definition: GNERide.h:227
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GNERide::commitGeometryMoving
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
Definition: GNERide.cpp:232
GNERide::setEnabledAttribute
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNERide.cpp:546
GNERide::getVClass
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNERide.cpp:170
GNERide::myLines
std::vector< std::string > myLines
valid line or vehicle ids or ANY
Definition: GNERide.h:224
GNERide::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNERide.cpp:303
GNERide::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNERide.cpp:319
GUIMainWindow
Definition: GUIMainWindow.h:47
GNERide::getParentName
std::string getParentName() const
Returns the name of the parent object.
Definition: GNERide.cpp:260
GNERide::operator=
GNERide & operator=(GNERide *)=delete
Invalidated assignment operator.
GNEVehicle
Definition: GNEVehicle.h:36
GNEConnection
Definition: GNEConnection.h:38
GNERide::getGenericParametersStr
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNERide.cpp:438
GNERide::getColor
const RGBColor & getColor() const
get color
Definition: GNERide.cpp:176
GNERide::enableAttribute
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERide.cpp:410
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:116
GNEUndoList
Definition: GNEUndoList.h:49
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
GNERide::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNERide.cpp:254
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:373
GNERide::startGeometryMoving
void startGeometryMoving()
Definition: GNERide.cpp:188
GNERide::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNERide.cpp:266