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-2020 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
23 
24 #include "GNEDemandElement.h"
25 
26 // ===========================================================================
27 // class definitions
28 // ===========================================================================
33 
34 public:
37  FXDECLARE(GNESingleVehiclePopupMenu)
38 
39  public:
46 
49 
51  long onCmdTransform(FXObject* obj, FXSelector, void*);
52 
53  protected:
56 
57  private:
60 
62  FXMenuCommand* myTransformToVehicle;
63 
66 
68  FXMenuCommand* myTransformToRouteFlow;
69 
72 
74  FXMenuCommand* myTransformToTrip;
75 
77  FXMenuCommand* myTransformToFlow;
78  };
79 
83 
84  public:
91  GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent);
92 
95 
97  long onCmdTransform(FXObject* obj, FXSelector, void*);
98 
99  protected:
102 
103  private:
105  std::vector<GNEVehicle*> mySelectedVehicles;
106 
109 
111  FXMenuCommand* myTransformToVehicle;
112 
115 
117  FXMenuCommand* myTransformToRouteFlow;
118 
121 
123  FXMenuCommand* myTransformToTrip;
124 
126  FXMenuCommand* myTransformToFlow;
127 
130 
133 
136 
139 
142 
145  };
146 
148  GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEDemandElement* route);
149 
151  GNEVehicle(GNENet* net, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters);
152 
154  GNEVehicle(GNENet* net, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters);
155 
157  GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const std::vector<GNEEdge*>& via);
158 
160  GNEVehicle(GNENet* net, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const std::vector<GNEEdge*>& via, const SUMOVehicleParameter& vehicleParameters);
161 
163  ~GNEVehicle();
164 
169  std::string getBegin() const;
170 
174  void writeDemandElement(OutputDevice& device) const;
175 
177  bool isDemandElementValid() const;
178 
180  std::string getDemandElementProblem() const;
181 
184 
188  SUMOVehicleClass getVClass() const;
189 
191  const RGBColor& getColor() const;
192 
194 
198  void startGeometryMoving();
199 
201  void endGeometryMoving();
202 
206  void moveGeometry(const Position& offset);
207 
211  void commitGeometryMoving(GNEUndoList* undoList);
212 
214  void updateGeometry();
215 
217  void computePath();
218 
220  void invalidatePath();
221 
223  Position getPositionInView() const;
225 
228 
236 
240  std::string getParentName() const;
241 
246 
248  void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
249 
254  void drawGL(const GUIVisualizationSettings& s) const;
255 
261  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const double offsetFront) const;
262 
269  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const double offsetFront) const;
271 
274  /* @brief method for getting the Attribute of an XML key
275  * @param[in] key The attribute key
276  * @return string with the value associated to key
277  */
278  std::string getAttribute(SumoXMLAttr key) const;
279 
280  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
281  * @param[in] key The attribute key
282  * @return double with the value associated to key
283  */
284  double getAttributeDouble(SumoXMLAttr key) const;
285 
286  /* @brief method for setting the attribute and letting the object perform demand element changes
287  * @param[in] key The attribute key
288  * @param[in] value The new value
289  * @param[in] undoList The undoList on which to register changes
290  * @param[in] net optionally the GNENet to inform about gui updates
291  */
292  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
293 
294  /* @brief method for setting the attribute and letting the object perform demand element changes
295  * @param[in] key The attribute key
296  * @param[in] value The new value
297  * @param[in] undoList The undoList on which to register changes
298  */
299  bool isValid(SumoXMLAttr key, const std::string& value);
300 
301  /* @brief method for enable attribute
302  * @param[in] key The attribute key
303  * @param[in] undoList The undoList on which to register changes
304  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
305  */
306  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
307 
308  /* @brief method for disable attribute
309  * @param[in] key The attribute key
310  * @param[in] undoList The undoList on which to register changes
311  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
312  */
313  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
314 
315  /* @brief method for check if the value for certain attribute is set
316  * @param[in] key The attribute key
317  */
318  bool isAttributeEnabled(SumoXMLAttr key) const;
319 
321  std::string getPopUpID() const;
322 
324  std::string getHierarchyName() const;
326 
328  const std::map<std::string, std::string>& getACParametersMap() const;
329 
330 protected:
332  void setColor(const GUIVisualizationSettings& s) const;
333 
334 private:
336  void setAttribute(SumoXMLAttr key, const std::string& value);
337 
339  void setEnabledAttribute(const int enabledAttributes);
340 
342  void drawStackLabel(const Position& vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const;
343 
345  void drawFlowLabel(const Position& vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const;
346 
348  GNEVehicle(const GNEVehicle&) = delete;
349 
351  GNEVehicle& operator=(const GNEVehicle&) = delete;
352 };
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.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition: GNEVehicle.h:81
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:207
GNESelectedVehiclesPopupMenu(GNEVehicle *vehicle, const std::vector< GNEVehicle * > &selectedVehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
Definition: GNEVehicle.cpp:138
FXMenuCommand * myTransformToRouteFlowWithEmbeddedRoute
menu command for transform to route flow with an embedded route
Definition: GNEVehicle.h:120
FXMenuCommand * myTransformToVehicle
menu command for transform to vehicle
Definition: GNEVehicle.h:111
FOX_CONSTRUCTOR(GNESelectedVehiclesPopupMenu)
default constructor needed by FOX
FXMenuCommand * myTransformToVehicleWithEmbeddedRoute
menu command for transform to vehicle with an embedded route
Definition: GNEVehicle.h:114
FXMenuCommand * myTransformAllVehiclesToVehicleWithEmbeddedRoute
menu command for transform all selected vehicles to vehicle with an embedded route
Definition: GNEVehicle.h:132
SumoXMLTag myVehicleTag
tag of clicked vehicle
Definition: GNEVehicle.h:108
FXMenuCommand * myTransformAllVehiclesToRouteFlow
menu command for transform all selected vehicles to route flow
Definition: GNEVehicle.h:135
FXMenuCommand * myTransformToTrip
menu command for transform to trip
Definition: GNEVehicle.h:123
FXMenuCommand * myTransformAllVehiclesToTrip
menu command for transform all selected vehicles to trip
Definition: GNEVehicle.h:141
FXMenuCommand * myTransformToFlow
menu command for transform to flow
Definition: GNEVehicle.h:126
FXMenuCommand * myTransformAllVehiclesToVehicle
menu command for transform all selected vehicles to vehicle
Definition: GNEVehicle.h:129
FXMenuCommand * myTransformAllVehiclesToFlow
menu command for transform all selected vehicles to flow
Definition: GNEVehicle.h:144
std::vector< GNEVehicle * > mySelectedVehicles
current selected vehicles
Definition: GNEVehicle.h:105
FXMenuCommand * myTransformAllVehiclesToRouteFlowWithEmbeddedRoute
menu command for transform all selected vehicles to route flow with an embedded route
Definition: GNEVehicle.h:138
FXMenuCommand * myTransformToRouteFlow
menu command for transform to route flow
Definition: GNEVehicle.h:117
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition: GNEVehicle.h:36
GNESingleVehiclePopupMenu(GNEVehicle *vehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
Definition: GNEVehicle.cpp:56
FXMenuCommand * myTransformToVehicle
menu command for transform to vehicle
Definition: GNEVehicle.h:62
GNEVehicle * myVehicle
current vehicle
Definition: GNEVehicle.h:59
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:117
FXMenuCommand * myTransformToFlow
menu command for transform to flow
Definition: GNEVehicle.h:77
FXMenuCommand * myTransformToRouteFlow
menu command for transform to route flow
Definition: GNEVehicle.h:68
FXMenuCommand * myTransformToTrip
menu command for transform to trip
Definition: GNEVehicle.h:74
FXMenuCommand * myTransformToRouteFlowWithEmbeddedRoute
menu command for transform to route flow with an embedded route
Definition: GNEVehicle.h:71
FOX_CONSTRUCTOR(GNESingleVehiclePopupMenu)
default constructor needed by FOX
FXMenuCommand * myTransformToVehicleWithEmbeddedRoute
menu command for transform to vehicle with an embedded route
Definition: GNEVehicle.h:65
void drawFlowLabel(const Position &vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const
draw flow label
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNEVehicle.cpp:460
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:632
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition: GNEVehicle.cpp:884
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEVehicle.cpp:620
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
~GNEVehicle()
destructor
Definition: GNEVehicle.cpp:308
double getAttributeDouble(SumoXMLAttr key) const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEVehicle.cpp:647
bool isAttributeEnabled(SumoXMLAttr key) const
GNEVehicle(const GNEVehicle &)=delete
Invalidated copy constructor.
const RGBColor & getColor() const
get color
Definition: GNEVehicle.cpp:472
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNEVehicle.cpp:641
void computePath()
compute path
Definition: GNEVehicle.cpp:565
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNEVehicle.cpp:490
void startGeometryMoving()
Definition: GNEVehicle.cpp:478
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:599
void updateGeometry()
update pre-computed geometry information
Definition: GNEVehicle.cpp:502
std::string getBegin() const
get begin time of demand element
Definition: GNEVehicle.cpp:312
bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNEVehicle.cpp:387
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNEVehicle.cpp:420
void drawStackLabel(const Position &vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const
draw stack label
Position getPositionInView() const
Returns position of demand element in view.
Definition: GNEVehicle.cpp:593
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
Definition: GNEVehicle.cpp:496
void invalidatePath()
invalidate path
Definition: GNEVehicle.cpp:579
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 drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const double offsetFront) const
Draws partial object.
Definition: GNEVehicle.cpp:778
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNEVehicle.cpp:326
SUMOVehicleClass getVClass() const
Definition: GNEVehicle.cpp:466
GNEVehicle(SumoXMLTag tag, GNENet *net, const std::string &vehicleID, GNEDemandElement *vehicleType, GNEDemandElement *route)
default constructor for vehicles and routeFlows without embedded routes
Definition: GNEVehicle.cpp:249
void endGeometryMoving()
end geometry movement
Definition: GNEVehicle.cpp:484
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:60
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
Structure representing possible vehicle parameter.
SumoXMLTag tag
The vehicle tag.
std::vector< std::string > via
List of the via-edges the vehicle must visit.