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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // A class for visualizing rides in Netedit
19 /****************************************************************************/
20 #pragma once
21 #include "GNEDemandElement.h"
23 
24 // ===========================================================================
25 // class declarations
26 // ===========================================================================
27 class GNEEdge;
28 class GNEConnection;
29 class GNEVehicle;
30 
31 // ===========================================================================
32 // class definitions
33 // ===========================================================================
34 
35 class GNERide : public GNEDemandElement, public Parameterised {
36 
37 public:
47  GNERide(GNENet* net, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEEdge* toEdge,
48  double arrivalPosition, const std::vector<std::string>& lines);
49 
59  GNERide(GNENet* net, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEAdditional* toBusStop,
60  double arrivalPosition, const std::vector<std::string>& lines);
61 
71  GNERide(GNENet* net, GNEDemandElement* personParent, GNEAdditional* fromBusStop, GNEEdge* toEdge,
72  double arrivalPosition, const std::vector<std::string>& lines);
73 
83  GNERide(GNENet* net, GNEDemandElement* personParent, GNEAdditional* fromBusStop, GNEAdditional* toBusStop,
84  double arrivalPosition, const std::vector<std::string>& lines);
85 
87  ~GNERide();
88 
92  void writeDemandElement(OutputDevice& device) const;
93 
95  bool isDemandElementValid() const;
96 
98  std::string getDemandElementProblem() const;
99 
102 
106  SUMOVehicleClass getVClass() const;
107 
109  const RGBColor& getColor() const;
110 
112 
116  void startGeometryMoving();
117 
119  void endGeometryMoving();
120 
124  void moveGeometry(const Position& offset);
125 
129  void commitGeometryMoving(GNEUndoList* undoList);
130 
132  void updateGeometry();
133 
135  void computePath();
136 
138  void invalidatePath();
139 
141  Position getPositionInView() const;
143 
146 
155 
159  std::string getParentName() const;
160 
165 
167  void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
168 
173  void drawGL(const GUIVisualizationSettings& s) const;
174 
180  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const double offsetFront) const;
181 
188  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const double offsetFront) const;
190 
193  /* @brief method for getting the Attribute of an XML key
194  * @param[in] key The attribute key
195  * @return string with the value associated to key
196  */
197  std::string getAttribute(SumoXMLAttr key) const;
198 
199  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
200  * @param[in] key The attribute key
201  * @return double with the value associated to key
202  */
203  double getAttributeDouble(SumoXMLAttr key) const;
204 
205  /* @brief method for setting the attribute and letting the object perform additional changes
206  * @param[in] key The attribute key
207  * @param[in] value The new value
208  * @param[in] undoList The undoList on which to register changes
209  * @param[in] net optionally the GNENet to inform about gui updates
210  */
211  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
212 
213  /* @brief method for setting the attribute and letting the object perform additional changes
214  * @param[in] key The attribute key
215  * @param[in] value The new value
216  * @param[in] undoList The undoList on which to register changes
217  */
218  bool isValid(SumoXMLAttr key, const std::string& value);
219 
220  /* @brief method for enable attribute
221  * @param[in] key The attribute key
222  * @param[in] undoList The undoList on which to register changes
223  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
224  */
225  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
226 
227  /* @brief method for disable attribute
228  * @param[in] key The attribute key
229  * @param[in] undoList The undoList on which to register changes
230  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
231  */
232  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
233 
234  /* @brief method for check if the value for certain attribute is set
235  * @param[in] key The attribute key
236  */
237  bool isAttributeEnabled(SumoXMLAttr key) const;
238 
240  std::string getPopUpID() const;
241 
243  std::string getHierarchyName() const;
245 
247  const std::map<std::string, std::string>& getACParametersMap() const;
248 
249 protected:
252 
255 
257  std::vector<std::string> myLines;
258 
259 private:
261  void setAttribute(SumoXMLAttr key, const std::string& value);
262 
264  void setEnabledAttribute(const int enabledAttributes);
265 
267  GNERide(GNERide*) = delete;
268 
270  GNERide& operator=(GNERide*) = delete;
271 };
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
An Element which don't belongs to GNENet but has influency in the simulation.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNERide.cpp:217
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNERide.cpp:409
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNERide.cpp:524
Position getPositionInView() const
Returns position of additional in view.
Definition: GNERide.cpp:320
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNERide.cpp:175
void endGeometryMoving()
end geometry movement
Definition: GNERide.cpp:207
void startGeometryMoving()
Definition: GNERide.cpp:193
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNERide.cpp:348
void invalidatePath()
invalidate path
Definition: GNERide.cpp:291
SUMOVehicleClass getVClass() const
Definition: GNERide.cpp:181
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNERide.cpp:158
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNERide.cpp:502
double myArrivalPosition
arrival position
Definition: GNERide.h:254
void computePath()
compute path
Definition: GNERide.cpp:262
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNERide.cpp:332
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNERide.cpp:354
std::string getParentName() const
Returns the name of the parent object.
Definition: GNERide.cpp:326
~GNERide()
destructor
Definition: GNERide.cpp:79
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNERide.cpp:592
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
Definition: GNERide.cpp:238
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERide.cpp:484
void updateGeometry()
update pre-computed geometry information
Definition: GNERide.cpp:249
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNERide.cpp:83
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNERide.cpp:448
const RGBColor & getColor() const
get color
Definition: GNERide.cpp:187
bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNERide.cpp:144
GNERide(GNENet *net, GNEDemandElement *personParent, GNEEdge *fromEdge, GNEEdge *toEdge, double arrivalPosition, const std::vector< std::string > &lines)
parameter constructor for person edge->edge
Definition: GNERide.cpp:36
std::vector< std::string > myLines
valid line or vehicle ids or ANY
Definition: GNERide.h:257
DemandElementMove myRideMove
variable for move rides
Definition: GNERide.h:251
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNERide.cpp:496
GNERide & operator=(GNERide *)=delete
Invalidated assignment operator.
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:424
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition: GNERide.cpp:374
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const double offsetFront) const
Draws partial object.
Definition: GNERide.cpp:360
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERide.cpp:490
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNERide.cpp:508
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNERide.cpp:108
GNERide(GNERide *)=delete
Invalidated copy constructor.
The popup menu of a globject.
Stores the information about how to visualize structures.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
struct for pack all variables related with Demand Element moving