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.org/sumo
3 // Copyright (C) 2001-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 // Representation of vehicles in NETEDIT
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
24 
25 #include "GNEDemandElement.h"
26 
27 // ===========================================================================
28 // class definitions
29 // ===========================================================================
34 
35 public:
38  FXDECLARE(GNESingleVehiclePopupMenu)
39 
40  public:
47 
50 
52  long onCmdTransform(FXObject* obj, FXSelector, void*);
53 
54  protected:
57 
58  private:
61 
63  FXMenuCommand* myTransformToVehicle;
64 
67 
69  FXMenuCommand* myTransformToRouteFlow;
70 
73 
75  FXMenuCommand* myTransformToTrip;
76 
78  FXMenuCommand* myTransformToFlow;
79  };
80 
84 
85  public:
92  GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent);
93 
96 
98  long onCmdTransform(FXObject* obj, FXSelector, void*);
99 
100  protected:
103 
104  private:
106  std::vector<GNEVehicle*> mySelectedVehicles;
107 
110 
112  FXMenuCommand* myTransformToVehicle;
113 
116 
118  FXMenuCommand* myTransformToRouteFlow;
119 
122 
124  FXMenuCommand* myTransformToTrip;
125 
127  FXMenuCommand* myTransformToFlow;
128 
131 
134 
137 
140 
143 
146  };
147 
150 
152  GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEDemandElement* route);
153 
155  GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters);
156 
158  GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters);
159 
161  GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const std::vector<GNEEdge*>& via);
162 
164  GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const std::vector<GNEEdge*>& via, const SUMOVehicleParameter& vehicleParameters);
165 
167  GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction);
168 
170  GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters);
171 
173  ~GNEVehicle();
174 
179 
184  std::string getBegin() const;
185 
189  void writeDemandElement(OutputDevice& device) const;
190 
193 
195  std::string getDemandElementProblem() const;
196 
199 
203  SUMOVehicleClass getVClass() const;
204 
206  const RGBColor& getColor() const;
207 
209 
213  void updateGeometry();
214 
216  Position getPositionInView() const;
218 
221 
229 
233  std::string getParentName() const;
234 
236  double getExaggeration(const GUIVisualizationSettings& s) const;
237 
242 
244  void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
245 
250  void drawGL(const GUIVisualizationSettings& s) const;
251 
253 
256 
258  void computePathElement();
259 
266  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const;
267 
275  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const;
276 
278  GNELane* getFirstPathLane() const;
279 
281  GNELane* getLastPathLane() const;
283 
286  /* @brief method for getting the Attribute of an XML key
287  * @param[in] key The attribute key
288  * @return string with the value associated to key
289  */
290  std::string getAttribute(SumoXMLAttr key) const;
291 
292  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
293  * @param[in] key The attribute key
294  * @return double with the value associated to key
295  */
296  double getAttributeDouble(SumoXMLAttr key) const;
297 
298  /* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
299  * @param[in] key The attribute key
300  * @return double with the value associated to key
301  */
303 
304  /* @brief method for setting the attribute and letting the object perform demand element changes
305  * @param[in] key The attribute key
306  * @param[in] value The new value
307  * @param[in] undoList The undoList on which to register changes
308  * @param[in] net optionally the GNENet to inform about gui updates
309  */
310  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
311 
312  /* @brief method for setting the attribute and letting the object perform demand element changes
313  * @param[in] key The attribute key
314  * @param[in] value The new value
315  * @param[in] undoList The undoList on which to register changes
316  */
317  bool isValid(SumoXMLAttr key, const std::string& value);
318 
319  /* @brief method for enable attribute
320  * @param[in] key The attribute key
321  * @param[in] undoList The undoList on which to register changes
322  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
323  */
324  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
325 
326  /* @brief method for disable attribute
327  * @param[in] key The attribute key
328  * @param[in] undoList The undoList on which to register changes
329  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
330  */
331  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
332 
333  /* @brief method for check if the value for certain attribute is set
334  * @param[in] key The attribute key
335  */
336  bool isAttributeEnabled(SumoXMLAttr key) const;
337 
339  std::string getPopUpID() const;
340 
342  std::string getHierarchyName() const;
344 
346  const std::map<std::string, std::string>& getACParametersMap() const;
347 
348 protected:
350  void setColor(const GUIVisualizationSettings& s) const;
351 
352 private:
354  static const double myArrivalPositionDiameter;
355 
357  void setAttribute(SumoXMLAttr key, const std::string& value);
358 
360  void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters);
361 
363  void setMoveShape(const GNEMoveResult& moveResult);
364 
366  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
367 
369  void drawStackLabel(const Position& vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const;
370 
372  void drawFlowLabel(const Position& vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const;
373 
375  void drawJunctionLine() const;
376 
378  GNEVehicle(const GNEVehicle&) = delete;
379 
381  GNEVehicle& operator=(const GNEVehicle&) = delete;
382 };
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.
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:82
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:213
GNESelectedVehiclesPopupMenu(GNEVehicle *vehicle, const std::vector< GNEVehicle * > &selectedVehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
Definition: GNEVehicle.cpp:144
FXMenuCommand * myTransformToRouteFlowWithEmbeddedRoute
menu command for transform to route flow with an embedded route
Definition: GNEVehicle.h:121
FXMenuCommand * myTransformToVehicle
menu command for transform to vehicle
Definition: GNEVehicle.h:112
FOX_CONSTRUCTOR(GNESelectedVehiclesPopupMenu)
default constructor needed by FOX
FXMenuCommand * myTransformToVehicleWithEmbeddedRoute
menu command for transform to vehicle with an embedded route
Definition: GNEVehicle.h:115
FXMenuCommand * myTransformAllVehiclesToVehicleWithEmbeddedRoute
menu command for transform all selected vehicles to vehicle with an embedded route
Definition: GNEVehicle.h:133
SumoXMLTag myVehicleTag
tag of clicked vehicle
Definition: GNEVehicle.h:109
FXMenuCommand * myTransformAllVehiclesToRouteFlow
menu command for transform all selected vehicles to route flow
Definition: GNEVehicle.h:136
FXMenuCommand * myTransformToTrip
menu command for transform to trip
Definition: GNEVehicle.h:124
FXMenuCommand * myTransformAllVehiclesToTrip
menu command for transform all selected vehicles to trip
Definition: GNEVehicle.h:142
FXMenuCommand * myTransformToFlow
menu command for transform to flow
Definition: GNEVehicle.h:127
FXMenuCommand * myTransformAllVehiclesToVehicle
menu command for transform all selected vehicles to vehicle
Definition: GNEVehicle.h:130
FXMenuCommand * myTransformAllVehiclesToFlow
menu command for transform all selected vehicles to flow
Definition: GNEVehicle.h:145
std::vector< GNEVehicle * > mySelectedVehicles
current selected vehicles
Definition: GNEVehicle.h:106
FXMenuCommand * myTransformAllVehiclesToRouteFlowWithEmbeddedRoute
menu command for transform all selected vehicles to route flow with an embedded route
Definition: GNEVehicle.h:139
FXMenuCommand * myTransformToRouteFlow
menu command for transform to route flow
Definition: GNEVehicle.h:118
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition: GNEVehicle.h:37
GNESingleVehiclePopupMenu(GNEVehicle *vehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
Definition: GNEVehicle.cpp:62
FXMenuCommand * myTransformToVehicle
menu command for transform to vehicle
Definition: GNEVehicle.h:63
GNEVehicle * myVehicle
current vehicle
Definition: GNEVehicle.h:60
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:123
FXMenuCommand * myTransformToFlow
menu command for transform to flow
Definition: GNEVehicle.h:78
FXMenuCommand * myTransformToRouteFlow
menu command for transform to route flow
Definition: GNEVehicle.h:69
FXMenuCommand * myTransformToTrip
menu command for transform to trip
Definition: GNEVehicle.h:75
FXMenuCommand * myTransformToRouteFlowWithEmbeddedRoute
menu command for transform to route flow with an embedded route
Definition: GNEVehicle.h:72
FOX_CONSTRUCTOR(GNESingleVehiclePopupMenu)
default constructor needed by FOX
FXMenuCommand * myTransformToVehicleWithEmbeddedRoute
menu command for transform to vehicle with an embedded route
Definition: GNEVehicle.h:66
void drawFlowLabel(const Position &vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const
draw flow label
GNELane * getLastPathLane() const
get last path lane
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
Definition: GNEVehicle.cpp:642
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNEVehicle.cpp:552
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:648
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNEVehicle.cpp:342
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEVehicle.cpp:630
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object.
Definition: GNEVehicle.cpp:835
void computePathElement()
compute pathElement
Definition: GNEVehicle.cpp:786
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
~GNEVehicle()
destructor
Definition: GNEVehicle.cpp:338
double getAttributeDouble(SumoXMLAttr key) const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEVehicle.cpp:663
bool isAttributeEnabled(SumoXMLAttr key) const
GNEVehicle(const GNEVehicle &)=delete
Invalidated copy constructor.
const RGBColor & getColor() const
get color
Definition: GNEVehicle.cpp:564
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
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 writed into XML (by default true, can be reimplemented...
Definition: GNEVehicle.cpp:458
static const double myArrivalPositionDiameter
vehicle arrival position radius
Definition: GNEVehicle.h:354
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:657
void drawJunctionLine() const
draw junction line
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:609
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 updateGeometry()
update pre-computed geometry information
Definition: GNEVehicle.cpp:570
Position getAttributePosition(SumoXMLAttr key) const
std::string getBegin() const
get begin time of demand element
Definition: GNEVehicle.cpp:367
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNEVehicle.cpp:501
void drawStackLabel(const Position &vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const
draw stack label
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Position getPositionInView() const
Returns position of demand element in view.
Definition: GNEVehicle.cpp:603
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 writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNEVehicle.cpp:381
GNEVehicle(SumoXMLTag tag, GNENet *net)
default constructor
Definition: GNEVehicle.cpp:255
SUMOVehicleClass getVClass() const
Definition: GNEVehicle.cpp:558
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
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.
std::vector< std::string > via
List of the via-edges the vehicle must visit.