Eclipse SUMO - Simulation of Urban MObility
GNEVehicle.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-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 // Representation of vehicles in netedit
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
23 
24 #include "GNEDemandElement.h"
25 #include "GNEDemandElementFlow.h"
26 
27 // ===========================================================================
28 // class definitions
29 // ===========================================================================
30 
32 
33 public:
36  FXDECLARE(GNESingleVehiclePopupMenu)
37 
38  public:
45 
48 
50  long onCmdTransform(FXObject*, FXSelector sel, void*);
51 
52  protected:
55 
56  private:
59  };
60 
64 
65  public:
72  GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent);
73 
76 
78  long onCmdTransform(FXObject* obj, FXSelector sel, void*);
79 
80  protected:
83 
84  private:
86  std::vector<GNEVehicle*> mySelectedVehicles;
87 
89  std::map<FXObject*, SumoXMLTag> myRestrictedMenuCommands;
90 
93  };
94 
97 
99  GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEDemandElement* route);
100 
102  GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters);
103 
105  GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters);
106 
108  GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge);
109 
111  GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const SUMOVehicleParameter& vehicleParameters);
112 
114  GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction);
115 
117  GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters);
118 
120  GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEAdditional* fromTAZ, GNEAdditional* toTAZ, const SUMOVehicleParameter& vehicleParameters);
121 
123  ~GNEVehicle();
124 
129 
133  void writeDemandElement(OutputDevice& device) const;
134 
137 
139  std::string getDemandElementProblem() const;
140 
143 
147  SUMOVehicleClass getVClass() const;
148 
150  const RGBColor& getColor() const;
151 
153 
157  void updateGeometry();
158 
160  Position getPositionInView() const;
161 
163 
167  bool checkDrawRelatedContour() const;
168 
170 
173 
181 
185  std::string getParentName() const;
186 
188  double getExaggeration(const GUIVisualizationSettings& s) const;
189 
194 
196  void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
197 
202  void drawGL(const GUIVisualizationSettings& s) const;
203 
205 
208 
210  void computePathElement();
211 
217  void drawLanePartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const;
218 
224  void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const;
225 
227  GNELane* getFirstPathLane() const;
228 
230  GNELane* getLastPathLane() const;
232 
235  /* @brief method for getting the Attribute of an XML key
236  * @param[in] key The attribute key
237  * @return string with the value associated to key
238  */
239  std::string getAttribute(SumoXMLAttr key) const;
240 
241  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
242  * @param[in] key The attribute key
243  * @return double with the value associated to key
244  */
245  double getAttributeDouble(SumoXMLAttr key) const;
246 
247  /* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
248  * @param[in] key The attribute key
249  * @return double with the value associated to key
250  */
252 
253  /* @brief method for setting the attribute and letting the object perform demand element changes
254  * @param[in] key The attribute key
255  * @param[in] value The new value
256  * @param[in] undoList The undoList on which to register changes
257  * @param[in] net optionally the GNENet to inform about gui updates
258  */
259  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
260 
261  /* @brief method for setting the attribute and letting the object perform demand element changes
262  * @param[in] key The attribute key
263  * @param[in] value The new value
264  * @param[in] undoList The undoList on which to register changes
265  */
266  bool isValid(SumoXMLAttr key, const std::string& value);
267 
268  /* @brief method for enable attribute
269  * @param[in] key The attribute key
270  * @param[in] undoList The undoList on which to register changes
271  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
272  */
273  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
274 
275  /* @brief method for disable attribute
276  * @param[in] key The attribute key
277  * @param[in] undoList The undoList on which to register changes
278  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
279  */
280  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
281 
282  /* @brief method for check if the value for certain attribute is set
283  * @param[in] key The attribute key
284  */
285  bool isAttributeEnabled(SumoXMLAttr key) const;
286 
288  std::string getPopUpID() const;
289 
291  std::string getHierarchyName() const;
293 
295  const Parameterised::Map& getACParametersMap() const;
296 
298  static GNEDemandElement* copyVehicle(const GNEVehicle* originalVehicle);
299 
300 protected:
303 
306 
309 
310 private:
312  static const double myArrivalPositionDiameter;
313 
315  void setAttribute(SumoXMLAttr key, const std::string& value);
316 
318  void toggleAttribute(SumoXMLAttr key, const bool value);
319 
321  void setMoveShape(const GNEMoveResult& moveResult);
322 
324  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
325 
327  GNEVehicle(const GNEVehicle&) = delete;
328 
330  GNEVehicle& operator=(const GNEVehicle&) = delete;
331 };
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
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition: GNEVehicle.h:62
GNESelectedVehiclesPopupMenu(GNEVehicle *vehicle, const std::vector< GNEVehicle * > &selectedVehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
Definition: GNEVehicle.cpp:193
long onCmdTransform(FXObject *obj, FXSelector sel, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:312
FOX_CONSTRUCTOR(GNESelectedVehiclesPopupMenu)
default constructor needed by FOX
std::map< FXObject *, SumoXMLTag > myRestrictedMenuCommands
selected menu commands
Definition: GNEVehicle.h:89
SumoXMLTag myVehicleTag
tag of clicked vehicle
Definition: GNEVehicle.h:92
std::vector< GNEVehicle * > mySelectedVehicles
current selected vehicles
Definition: GNEVehicle.h:86
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition: GNEVehicle.h:35
long onCmdTransform(FXObject *, FXSelector sel, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:151
GNESingleVehiclePopupMenu(GNEVehicle *vehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
Definition: GNEVehicle.cpp:62
GNEVehicle * myVehicle
current vehicle
Definition: GNEVehicle.h:58
FOX_CONSTRUCTOR(GNESingleVehiclePopupMenu)
default constructor needed by FOX
const Parameterised::Map & getACParametersMap() const
get parameters map
GNELane * getLastPathLane() const
get last path lane
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition: GNEVehicle.cpp:836
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNEVehicle.cpp:717
GNEVehicle & operator=(const GNEVehicle &)=delete
Invalidated assignment operator.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEVehicle.cpp:842
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNEVehicle.cpp:542
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEVehicle.cpp:820
void computePathElement()
compute pathElement
Definition: GNEVehicle.cpp:976
GNEContour myVehicleContour
variable used for draw vehicle contours
Definition: GNEVehicle.h:302
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
~GNEVehicle()
destructor
Definition: GNEVehicle.cpp:538
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over junction.
double getAttributeDouble(SumoXMLAttr key) const
RGBColor getDrawingColor(const GUIVisualizationSettings &s) const
get drawing color
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEVehicle.cpp:857
bool isAttributeEnabled(SumoXMLAttr key) const
GNEVehicle(const GNEVehicle &)=delete
Invalidated copy constructor.
const RGBColor & getColor() const
get color
Definition: GNEVehicle.cpp:729
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
GNELane * getFirstPathLane() const
get first path lane
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
Definition: GNEVehicle.cpp:631
static const double myArrivalPositionDiameter
vehicle arrival position radius
Definition: GNEVehicle.h:312
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNEVehicle.cpp:851
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
Definition: GNEVehicle.cpp:785
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEVehicle.cpp:799
const SUMOVehicleParameter & getSUMOVehicleParameter() const
@brier get sumo vehicle parameter
void updateGeometry()
update pre-computed geometry information
Definition: GNEVehicle.cpp:735
Position getAttributePosition(SumoXMLAttr key) const
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNEVehicle.cpp:675
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Position getPositionInView() const
Returns position of demand element in view.
Definition: GNEVehicle.cpp:779
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over lane.
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
Definition: GNEVehicle.cpp:570
GNEVehicle(SumoXMLTag tag, GNENet *net)
default constructor
Definition: GNEVehicle.cpp:437
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNEVehicle.cpp:723
static GNEDemandElement * copyVehicle(const GNEVehicle *originalVehicle)
create a copy of the given vehicle
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
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
Structure representing possible vehicle parameter.
SumoXMLTag tag
The vehicle tag.