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.dev/sumo
3 // Copyright (C) 2016-2024 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 <config.h>
23 
24 #include "GNEDemandElement.h"
25 #include "GNEDemandElementPlan.h"
26 
27 // ===========================================================================
28 // class declarations
29 // ===========================================================================
30 
31 class GNEEdge;
32 class GNEConnection;
33 class GNEVehicle;
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
38 
40 
41 public:
54  static GNERide* buildRide(GNENet* net, GNEDemandElement* personParent,
55  GNEEdge* fromEdge, GNEAdditional* fromBusStop, GNEAdditional* fromTrainStop,
56  GNEEdge* toEdge, GNEAdditional* toBusStop, GNEAdditional* toTrainStop,
57  double arrivalPosition, const std::vector<std::string>& lines);
58 
60  GNERide(SumoXMLTag tag, GNENet* net);
61 
63  ~GNERide();
64 
69 
73  void writeDemandElement(OutputDevice& device) const;
74 
77 
79  std::string getDemandElementProblem() const;
80 
83 
88 
90  const RGBColor& getColor() const;
91 
93 
97  void updateGeometry();
98 
100  Position getPositionInView() const;
102 
105 
114 
118  std::string getParentName() const;
119 
124 
126  void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
127 
132  void drawGL(const GUIVisualizationSettings& s) const;
133 
135 
138 
140  void computePathElement();
141 
147  void drawLanePartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const;
148 
154  void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const;
155 
157  GNELane* getFirstPathLane() const;
158 
160  GNELane* getLastPathLane() const;
162 
165  /* @brief method for getting the Attribute of an XML key
166  * @param[in] key The attribute key
167  * @return string with the value associated to key
168  */
169  std::string getAttribute(SumoXMLAttr key) const;
170 
171  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
172  * @param[in] key The attribute key
173  * @return double with the value associated to key
174  */
175  double getAttributeDouble(SumoXMLAttr key) const;
176 
177  /* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
178  * @param[in] key The attribute key
179  * @return double with the value associated to key
180  */
182 
183  /* @brief method for setting the attribute and letting the object perform additional changes
184  * @param[in] key The attribute key
185  * @param[in] value The new value
186  * @param[in] undoList The undoList on which to register changes
187  * @param[in] net optionally the GNENet to inform about gui updates
188  */
189  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
190 
191  /* @brief method for setting the attribute and letting the object perform additional changes
192  * @param[in] key The attribute key
193  * @param[in] value The new value
194  * @param[in] undoList The undoList on which to register changes
195  */
196  bool isValid(SumoXMLAttr key, const std::string& value);
197 
198  /* @brief method for check if the value for certain attribute is set
199  * @param[in] key The attribute key
200  */
201  bool isAttributeEnabled(SumoXMLAttr key) const;
202 
204  std::string getPopUpID() const;
205 
207  std::string getHierarchyName() const;
209 
211  const Parameterised::Map& getACParametersMap() const;
212 
213 protected:
215  std::vector<std::string> myLines;
216 
217 private:
219  void setAttribute(SumoXMLAttr key, const std::string& value);
220 
222  void setMoveShape(const GNEMoveResult& moveResult);
223 
225  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
226 
236  GNERide(GNENet* net, SumoXMLTag tag, GUIIcon icon, GNEDemandElement* personParent, const std::vector<GNEEdge*>& edges,
237  const std::vector<GNEAdditional*>& additionals, double arrivalPosition, const std::vector<std::string>& lines);
238 
240  GNERide(GNERide*) = delete;
241 
243  GNERide& operator=(GNERide*) = delete;
244 };
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:49
Problem
enum class for demandElement problems
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNERide.cpp:226
Position getPositionInView() const
Returns position of additional in view.
Definition: GNERide.cpp:139
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNERide.cpp:115
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNERide.cpp:157
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNERide.cpp:121
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNERide.cpp:109
GNERide(SumoXMLTag tag, GNENet *net)
default constructor
Definition: GNERide.cpp:64
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNERide.cpp:268
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNERide.cpp:151
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNERide.cpp:311
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNERide.cpp:163
std::string getParentName() const
Returns the name of the parent object.
Definition: GNERide.cpp:145
~GNERide()
destructor
Definition: GNERide.cpp:73
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNERide.cpp:77
void updateGeometry()
update pre-computed geometry information
Definition: GNERide.cpp:133
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
Definition: GNERide.cpp:103
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNERide.cpp:83
static GNERide * buildRide(GNENet *net, GNEDemandElement *personParent, GNEEdge *fromEdge, GNEAdditional *fromBusStop, GNEAdditional *fromTrainStop, GNEEdge *toEdge, GNEAdditional *toBusStop, GNEAdditional *toTrainStop, double arrivalPosition, const std::vector< std::string > &lines)
general constructor for rides
Definition: GNERide.cpp:35
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNERide.cpp:251
const RGBColor & getColor() const
get color
Definition: GNERide.cpp:127
Position getAttributePosition(SumoXMLAttr key) const
Definition: GNERide.cpp:232
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition: GNERide.cpp:280
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over junction.
Definition: GNERide.cpp:197
std::vector< std::string > myLines
valid line or vehicle ids or ANY
Definition: GNERide.h:215
GNELane * getLastPathLane() const
get last path lane
Definition: GNERide.cpp:209
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNERide.cpp:262
GNERide & operator=(GNERide *)=delete
Invalidated assignment operator.
void computePathElement()
compute pathElement
Definition: GNERide.cpp:169
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:238
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition: GNERide.cpp:215
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNERide.cpp:302
GNELane * getFirstPathLane() const
get first path lane
Definition: GNERide.cpp:203
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNERide.cpp:274
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
Definition: GNERide.cpp:89
GNERide(GNERide *)=delete
Invalidated copy constructor.
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over lane.
Definition: GNERide.cpp:191
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:61
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37