Eclipse SUMO - Simulation of Urban MObility
GNETranship.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 tranships in Netedit
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
23 
24 #include "GNEDemandElement.h"
25 
26 // ===========================================================================
27 // class declarations
28 // ===========================================================================
29 class GNEEdge;
30 class GNEConnection;
31 class GNEVehicle;
32 
33 // ===========================================================================
34 // class definitions
35 // ===========================================================================
36 
37 class GNETranship : public GNEDemandElement, public Parameterised {
38 
39 public:
41  GNETranship(SumoXMLTag tag, GNENet* net);
42 
52  GNETranship(GNENet* net, GNEDemandElement* containerParent, GNEEdge* fromEdge, GNEEdge* toEdge,
53  const double speed, const double departPosition, const double arrivalPosition);
54 
65  GNETranship(GNENet* net, GNEDemandElement* containerParent, GNEEdge* fromEdge, GNEAdditional* toContainerStop,
66  const double speed, const double departPosition, const double arrivalPosition);
67 
77  GNETranship(GNENet* net, GNEDemandElement* containerParent, std::vector<GNEEdge*> edges,
78  const double speed, const double departPosition, const double arrivalPosition);
79 
81  ~GNETranship();
82 
87 
91  void writeDemandElement(OutputDevice& device) const;
92 
95 
97  std::string getDemandElementProblem() const;
98 
101 
105  SUMOVehicleClass getVClass() const;
106 
108  const RGBColor& getColor() const;
109 
111 
115  void updateGeometry();
116 
118  Position getPositionInView() const;
120 
123 
132 
136  std::string getParentName() const;
137 
139  double getExaggeration(const GUIVisualizationSettings& s) const;
140 
145 
147  void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
148 
153  void drawGL(const GUIVisualizationSettings& s) const;
154 
156 
159 
161  void computePathElement();
162 
169  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const;
170 
178  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const;
179 
181  GNELane* getFirstPathLane() const;
182 
184  GNELane* getLastPathLane() const;
186 
189  /* @brief method for getting the Attribute of an XML key
190  * @param[in] key The attribute key
191  * @return string with the value associated to key
192  */
193  std::string getAttribute(SumoXMLAttr key) const;
194 
195  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
196  * @param[in] key The attribute key
197  * @return double with the value associated to key
198  */
199  double getAttributeDouble(SumoXMLAttr key) const;
200 
201  /* @brief method for getting the Attribute of an XML key in Position format (used in container plans)
202  * @param[in] key The attribute key
203  * @return double with the value associated to key
204  */
206 
207  /* @brief method for setting the attribute and letting the object perform additional changes
208  * @param[in] key The attribute key
209  * @param[in] value The new value
210  * @param[in] undoList The undoList on which to register changes
211  * @param[in] net optionally the GNENet to inform about gui updates
212  */
213  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
214 
215  /* @brief method for setting the attribute and letting the object perform additional changes
216  * @param[in] key The attribute key
217  * @param[in] value The new value
218  * @param[in] undoList The undoList on which to register changes
219  */
220  bool isValid(SumoXMLAttr key, const std::string& value);
221 
222  /* @brief method for enable attribute
223  * @param[in] key The attribute key
224  * @param[in] undoList The undoList on which to register changes
225  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
226  */
227  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
228 
229  /* @brief method for disable attribute
230  * @param[in] key The attribute key
231  * @param[in] undoList The undoList on which to register changes
232  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
233  */
234  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
235 
236  /* @brief method for check if the value for certain attribute is set
237  * @param[in] key The attribute key
238  */
239  bool isAttributeEnabled(SumoXMLAttr key) const;
240 
242  std::string getPopUpID() const;
243 
245  std::string getHierarchyName() const;
247 
249  const std::map<std::string, std::string>& getACParametersMap() const;
250 
251 protected:
253  double mySpeed;
254 
257 
260 
261 private:
263  void setAttribute(SumoXMLAttr key, const std::string& value);
264 
266  void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters);
267 
269  void setMoveShape(const GNEMoveResult& moveResult);
270 
272  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
273 
276 
279 };
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
GNETranship(GNETranship *)=delete
Invalidated copy constructor.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
~GNETranship()
destructor
Definition: GNETranship.cpp:78
SUMOVehicleClass getVClass() const
double mySpeed
speed
Definition: GNETranship.h:253
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
GNELane * getFirstPathLane() const
get first path lane
GNETranship(SumoXMLTag tag, GNENet *net)
default constructor
Definition: GNETranship.cpp:37
bool isAttributeEnabled(SumoXMLAttr key) const
void updateGeometry()
update pre-computed geometry information
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Position getAttributePosition(SumoXMLAttr key) const
GNETranship & operator=(GNETranship *)=delete
Invalidated assignment operator.
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNETranship.cpp:82
Position getPositionInView() const
Returns position of additional in view.
void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters)
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
double getAttributeDouble(SumoXMLAttr key) const
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
double myArrivalPosition
arrival position
Definition: GNETranship.h:259
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void computePathElement()
compute pathElement
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object.
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Problem isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
std::string getParentName() const
Returns the name of the parent object.
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
GNELane * getLastPathLane() const
get last path lane
const RGBColor & getColor() const
get color
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
double myDepartPosition
depart position
Definition: GNETranship.h:256
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