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-2022 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>
22 #include "GNEDemandElement.h"
24 
25 // ===========================================================================
26 // class declarations
27 // ===========================================================================
28 class GNEEdge;
29 class GNEConnection;
30 class GNEVehicle;
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
35 
36 class GNERide : public GNEDemandElement, public Parameterised {
37 
38 public:
40  GNERide(SumoXMLTag tag, GNENet* net);
41 
51  GNERide(GNENet* net, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEEdge* toEdge,
52  double arrivalPosition, const std::vector<std::string>& lines);
53 
63  GNERide(GNENet* net, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEAdditional* toBusStop,
64  double arrivalPosition, const std::vector<std::string>& lines);
65 
67  ~GNERide();
68 
73 
77  void writeDemandElement(OutputDevice& device) const;
78 
81 
83  std::string getDemandElementProblem() const;
84 
87 
92 
94  const RGBColor& getColor() const;
95 
97 
101  void updateGeometry();
102 
104  Position getPositionInView() const;
106 
109 
118 
122  std::string getParentName() const;
123 
125  double getExaggeration(const GUIVisualizationSettings& s) const;
126 
131 
133  void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
134 
139  void drawGL(const GUIVisualizationSettings& s) const;
140 
142 
145 
147  void computePathElement();
148 
155  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const;
156 
164  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const;
165 
167  GNELane* getFirstPathLane() const;
168 
170  GNELane* getLastPathLane() const;
172 
175  /* @brief method for getting the Attribute of an XML key
176  * @param[in] key The attribute key
177  * @return string with the value associated to key
178  */
179  std::string getAttribute(SumoXMLAttr key) const;
180 
181  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
182  * @param[in] key The attribute key
183  * @return double with the value associated to key
184  */
185  double getAttributeDouble(SumoXMLAttr key) const;
186 
187  /* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
188  * @param[in] key The attribute key
189  * @return double with the value associated to key
190  */
192 
193  /* @brief method for setting the attribute and letting the object perform additional changes
194  * @param[in] key The attribute key
195  * @param[in] value The new value
196  * @param[in] undoList The undoList on which to register changes
197  * @param[in] net optionally the GNENet to inform about gui updates
198  */
199  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
200 
201  /* @brief method for setting the attribute and letting the object perform additional changes
202  * @param[in] key The attribute key
203  * @param[in] value The new value
204  * @param[in] undoList The undoList on which to register changes
205  */
206  bool isValid(SumoXMLAttr key, const std::string& value);
207 
208  /* @brief method for enable attribute
209  * @param[in] key The attribute key
210  * @param[in] undoList The undoList on which to register changes
211  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
212  */
213  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
214 
215  /* @brief method for disable attribute
216  * @param[in] key The attribute key
217  * @param[in] undoList The undoList on which to register changes
218  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
219  */
220  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
221 
222  /* @brief method for check if the value for certain attribute is set
223  * @param[in] key The attribute key
224  */
225  bool isAttributeEnabled(SumoXMLAttr key) const;
226 
228  std::string getPopUpID() const;
229 
231  std::string getHierarchyName() const;
233 
235  const std::map<std::string, std::string>& getACParametersMap() const;
236 
237 protected:
240 
242  std::vector<std::string> myLines;
243 
244 private:
246  void setAttribute(SumoXMLAttr key, const std::string& value);
247 
249  void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters);
250 
252  void setMoveShape(const GNEMoveResult& moveResult);
253 
255  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
256 
258  GNERide(GNERide*) = delete;
259 
261  GNERide& operator=(GNERide*) = delete;
262 };
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 belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:48
An Element which don't belongs to GNENet but has influency in the simulation.
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:322
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNERide.cpp:482
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object.
Definition: GNERide.cpp:258
Position getPositionInView() const
Returns position of additional in view.
Definition: GNERide.cpp:184
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNERide.cpp:157
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNERide.cpp:218
SUMOVehicleClass getVClass() const
Definition: GNERide.cpp:163
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNERide.cpp:151
GNERide(SumoXMLTag tag, GNENet *net)
default constructor
Definition: GNERide.cpp:36
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNERide.cpp:464
double myArrivalPosition
arrival position
Definition: GNERide.h:239
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNERide.cpp:202
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNERide.cpp:555
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNERide.cpp:224
std::string getParentName() const
Returns the name of the parent object.
Definition: GNERide.cpp:190
~GNERide()
destructor
Definition: GNERide.cpp:63
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNERide.cpp:67
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERide.cpp:442
void updateGeometry()
update pre-computed geometry information
Definition: GNERide.cpp:175
Problem isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNERide.cpp:145
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNERide.cpp:86
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNERide.cpp:407
const RGBColor & getColor() const
get color
Definition: GNERide.cpp:169
Position getAttributePosition(SumoXMLAttr key) const
Definition: GNERide.cpp:337
std::vector< std::string > myLines
valid line or vehicle ids or ANY
Definition: GNERide.h:242
GNELane * getLastPathLane() const
get last path lane
Definition: GNERide.cpp:278
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
Definition: GNERide.cpp:196
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNERide.cpp:454
GNERide & operator=(GNERide *)=delete
Invalidated assignment operator.
void computePathElement()
compute pathElement
Definition: GNERide.cpp:231
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:358
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition: GNERide.cpp:289
void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters)
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNERide.cpp:540
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNERide.cpp:546
GNELane * getFirstPathLane() const
get first path lane
Definition: GNERide.cpp:272
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNERide.cpp:448
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNERide.cpp:470
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNERide.cpp:111
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:61
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37