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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // Representation of vehicles in NETEDIT
15 /****************************************************************************/
16 #ifndef GNEVehicle_h
17 #define GNEVehicle_h
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 
26 
27 #include "GNEDemandElement.h"
28 
29 // ===========================================================================
30 // class definitions
31 // ===========================================================================
36 
37 public:
40  FXDECLARE(GNESingleVehiclePopupMenu)
41 
42  public:
49 
52 
54  long onCmdTransform(FXObject* obj, FXSelector, void*);
55 
56  protected:
59 
60  private:
63 
65  FXMenuCommand* myTransformToVehicle;
66 
69 
71  FXMenuCommand* myTransformToRouteFlow;
72 
75 
77  FXMenuCommand* myTransformToTrip;
78 
80  FXMenuCommand* myTransformToFlow;
81  };
82 
86 
87  public:
94  GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent);
95 
98 
100  long onCmdTransform(FXObject* obj, FXSelector, void*);
101 
102  protected:
105 
106  private:
108  std::vector<GNEVehicle*> mySelectedVehicles;
109 
112 
114  FXMenuCommand* myTransformToVehicle;
115 
118 
120  FXMenuCommand* myTransformToRouteFlow;
121 
124 
126  FXMenuCommand* myTransformToTrip;
127 
129  FXMenuCommand* myTransformToFlow;
130 
133 
136 
139 
142 
145 
148  };
149 
151  GNEVehicle(SumoXMLTag tag, GNEViewNet* viewNet, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEDemandElement* route);
152 
154  GNEVehicle(GNEViewNet* viewNet, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters);
155 
157  GNEVehicle(GNEViewNet* viewNet, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters);
158 
160  GNEVehicle(SumoXMLTag tag, GNEViewNet* viewNet, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const std::vector<GNEEdge*>& via);
161 
163  GNEVehicle(GNEViewNet* viewNet, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const std::vector<GNEEdge*>& via, const SUMOVehicleParameter& vehicleParameters);
164 
166  ~GNEVehicle();
167 
172  std::string getBegin() const;
173 
177  void writeDemandElement(OutputDevice& device) const;
178 
180  bool isDemandElementValid() const;
181 
183  std::string getDemandElementProblem() const;
184 
187 
191  GNEEdge* getFromEdge() const;
192 
194  GNEEdge* getToEdge() const;
195 
197  SUMOVehicleClass getVClass() const;
198 
200  const RGBColor& getColor() const;
201 
203 
207  void startGeometryMoving();
208 
210  void endGeometryMoving();
211 
215  void moveGeometry(const Position& offset);
216 
220  void commitGeometryMoving(GNEUndoList* undoList);
221 
223  void updateGeometry();
224 
226  void updatePartialGeometry(const GNEEdge* edge);
227 
229  void computePath();
230 
232  void invalidatePath();
233 
235  Position getPositionInView() const;
237 
240 
248 
252  std::string getParentName() const;
253 
258 
260  void splitEdgeGeometry(const double splitPosition, const GNENetElement* originalElement, const GNENetElement* newElement, GNEUndoList* undoList);
261 
266  void drawGL(const GUIVisualizationSettings& s) const;
268 
272  void selectAttributeCarrier(bool changeFlag = true);
273 
275  void unselectAttributeCarrier(bool changeFlag = true);
276 
277  /* @brief method for getting the Attribute of an XML key
278  * @param[in] key The attribute key
279  * @return string with the value associated to key
280  */
281  std::string getAttribute(SumoXMLAttr key) const;
282 
283  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
284  * @param[in] key The attribute key
285  * @return double with the value associated to key
286  */
287  double getAttributeDouble(SumoXMLAttr key) const;
288 
289  /* @brief method for setting the attribute and letting the object perform demand element changes
290  * @param[in] key The attribute key
291  * @param[in] value The new value
292  * @param[in] undoList The undoList on which to register changes
293  * @param[in] net optionally the GNENet to inform about gui updates
294  */
295  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
296 
297  /* @brief method for setting the attribute and letting the object perform demand element changes
298  * @param[in] key The attribute key
299  * @param[in] value The new value
300  * @param[in] undoList The undoList on which to register changes
301  */
302  bool isValid(SumoXMLAttr key, const std::string& value);
303 
304  /* @brief method for enable attribute
305  * @param[in] key The attribute key
306  * @param[in] undoList The undoList on which to register changes
307  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
308  */
309  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
310 
311  /* @brief method for disable attribute
312  * @param[in] key The attribute key
313  * @param[in] undoList The undoList on which to register changes
314  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
315  */
316  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
317 
318  /* @brief method for check if the value for certain attribute is set
319  * @param[in] key The attribute key
320  */
321  bool isAttributeEnabled(SumoXMLAttr key) const;
322 
324  std::string getPopUpID() const;
325 
327  std::string getHierarchyName() 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  GNEVehicle(const GNEVehicle&) = delete;
343 
345  GNEVehicle& operator=(const GNEVehicle&) = delete;
346 };
347 
348 #endif
349 /****************************************************************************/
GNEVehicle::getAttributeDouble
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNEVehicle.cpp:946
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
GNEDemandElement
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEDemandElement.h:55
GNEVehicle::startGeometryMoving
void startGeometryMoving()
Definition: GNEVehicle.cpp:495
GNEVehicle::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
inherited from GNEAttributeCarrier
Definition: GNEVehicle.cpp:788
GNEVehicle::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNEVehicle.cpp:519
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
GNEVehicle::GNESelectedVehiclesPopupMenu::~GNESelectedVehiclesPopupMenu
~GNESelectedVehiclesPopupMenu()
Destructor.
Definition: GNEVehicle.cpp:214
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
GNEVehicle::computePath
void computePath()
compute path
Definition: GNEVehicle.cpp:567
GNEVehicle::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
Definition: GNEVehicle.cpp:952
GNEVehicle::GNESelectedVehiclesPopupMenu::myTransformToRouteFlowWithEmbeddedRoute
FXMenuCommand * myTransformToRouteFlowWithEmbeddedRoute
menu command for transform to route flow with an embedded route
Definition: GNEVehicle.h:123
GUIGLObjectPopupMenu.h
GNEVehicle::getFromEdge
GNEEdge * getFromEdge() const
Definition: GNEVehicle.cpp:451
GNEVehicle::isDemandElementValid
bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNEVehicle.cpp:405
GNEVehicle::getBegin
std::string getBegin() const
get begin time of demand element
Definition: GNEVehicle.cpp:325
GNEViewNet
Definition: GNEViewNet.h:42
GNEVehicle::getPositionInView
Position getPositionInView() const
Returns position of demand element in view.
Definition: GNEVehicle.cpp:589
GNEVehicle::GNESingleVehiclePopupMenu::myTransformToRouteFlow
FXMenuCommand * myTransformToRouteFlow
menu command for transform to route flow
Definition: GNEVehicle.h:71
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:297
GNEVehicle::~GNEVehicle
~GNEVehicle()
destructor
Definition: GNEVehicle.cpp:321
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:47
GNEVehicle::getVClass
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNEVehicle.cpp:483
GNEVehicle::GNESelectedVehiclesPopupMenu::GNESelectedVehiclesPopupMenu
GNESelectedVehiclesPopupMenu()
default constructor needed by FOX
Definition: GNEVehicle.h:104
GNEVehicle::enableAttribute
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEVehicle.cpp:1179
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:41
GNEVehicle::setColor
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GNEVehicle.cpp:1250
GNEVehicle::getPopUpID
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEVehicle.cpp:1215
GNEVehicle::GNESelectedVehiclesPopupMenu
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition: GNEVehicle.h:84
SUMOVehicleParameter::tag
SumoXMLTag tag
The vehicle tag.
Definition: SUMOVehicleParameter.h:465
SUMOVehicleParameter.h
GNEVehicle::GNESelectedVehiclesPopupMenu::myVehicleTag
SumoXMLTag myVehicleTag
tag of clicked vehicle
Definition: GNEVehicle.h:111
GNEEdge
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:51
GNEVehicle::GNESelectedVehiclesPopupMenu::myTransformToFlow
FXMenuCommand * myTransformToFlow
menu command for transform to flow
Definition: GNEVehicle.h:129
RGBColor
Definition: RGBColor.h:39
GNEVehicle::getColor
const RGBColor & getColor() const
get color
Definition: GNEVehicle.cpp:489
GNEVehicle::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEVehicle.cpp:1196
GNEVehicle::GNESelectedVehiclesPopupMenu::myTransformToTrip
FXMenuCommand * myTransformToTrip
menu command for transform to trip
Definition: GNEVehicle.h:126
GNEDemandElement.h
GNEVehicle::fixDemandElementProblem
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNEVehicle.cpp:445
GNEVehicle::disableAttribute
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEVehicle.cpp:1190
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GNEVehicle::getDemandElementProblem
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNEVehicle.cpp:427
GNEVehicle::GNESingleVehiclePopupMenu::~GNESingleVehiclePopupMenu
~GNESingleVehiclePopupMenu()
Destructor.
Definition: GNEVehicle.cpp:124
GNEVehicle::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEVehicle.cpp:819
GNEVehicle::GNESingleVehiclePopupMenu::myTransformToRouteFlowWithEmbeddedRoute
FXMenuCommand * myTransformToRouteFlowWithEmbeddedRoute
menu command for transform to route flow with an embedded route
Definition: GNEVehicle.h:74
GNEVehicle::GNESelectedVehiclesPopupMenu::mySelectedVehicles
std::vector< GNEVehicle * > mySelectedVehicles
current selected vehicles
Definition: GNEVehicle.h:108
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GNEVehicle::invalidatePath
void invalidatePath()
invalidate path
Definition: GNEVehicle.cpp:578
GNEVehicle::GNESingleVehiclePopupMenu::GNESingleVehiclePopupMenu
GNESingleVehiclePopupMenu()
default constructor needed by FOX
Definition: GNEVehicle.h:58
GNEVehicle::GNESelectedVehiclesPopupMenu::myTransformToRouteFlow
FXMenuCommand * myTransformToRouteFlow
menu command for transform to route flow
Definition: GNEVehicle.h:120
GNEVehicle::GNESingleVehiclePopupMenu::myVehicle
GNEVehicle * myVehicle
current vehicle
Definition: GNEVehicle.h:62
GNENetElement
Definition: GNENetElement.h:43
GNEVehicle::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEVehicle.cpp:999
GNEVehicle::getToEdge
GNEEdge * getToEdge() const
obtain to edge of this demand element
Definition: GNEVehicle.cpp:467
GNEVehicle::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEVehicle.cpp:638
GNEVehicle::GNESelectedVehiclesPopupMenu::myTransformAllVehiclesToVehicleWithEmbeddedRoute
FXMenuCommand * myTransformAllVehiclesToVehicleWithEmbeddedRoute
menu command for transform all selected vehicles to vehicle with an embedded route
Definition: GNEVehicle.h:135
GNEVehicle::GNESingleVehiclePopupMenu::myTransformToVehicleWithEmbeddedRoute
FXMenuCommand * myTransformToVehicleWithEmbeddedRoute
menu command for transform to vehicle with an embedded route
Definition: GNEVehicle.h:68
GNEVehicle::GNESelectedVehiclesPopupMenu::myTransformAllVehiclesToRouteFlow
FXMenuCommand * myTransformAllVehiclesToRouteFlow
menu command for transform all selected vehicles to route flow
Definition: GNEVehicle.h:138
GNEVehicle::updatePartialGeometry
void updatePartialGeometry(const GNEEdge *edge)
partial update pre-computed geometry information
Definition: GNEVehicle.cpp:546
GNEVehicle::getHierarchyName
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEVehicle.cpp:1221
GNEVehicle::commitGeometryMoving
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
Definition: GNEVehicle.cpp:513
GUIMainWindow
Definition: GUIMainWindow.h:46
SUMOVehicleParameter::via
std::vector< std::string > via
List of the via-edges the vehicle must visit.
Definition: SUMOVehicleParameter.h:659
GNEVehicle::writeDemandElement
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNEVehicle.cpp:344
GNEVehicle::GNESelectedVehiclesPopupMenu::myTransformAllVehiclesToTrip
FXMenuCommand * myTransformAllVehiclesToTrip
menu command for transform all selected vehicles to trip
Definition: GNEVehicle.h:144
GNEVehicle::GNEVehicle
GNEVehicle(SumoXMLTag tag, GNEViewNet *viewNet, const std::string &vehicleID, GNEDemandElement *vehicleType, GNEDemandElement *route)
default constructor for vehicles and routeFlows without embedded routes
Definition: GNEVehicle.cpp:260
GNEVehicle::GNESelectedVehiclesPopupMenu::onCmdTransform
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:218
GNEVehicle::GNESelectedVehiclesPopupMenu::myTransformToVehicleWithEmbeddedRoute
FXMenuCommand * myTransformToVehicleWithEmbeddedRoute
menu command for transform to vehicle with an embedded route
Definition: GNEVehicle.h:117
GNEVehicle::setEnabledAttribute
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNEVehicle.cpp:1614
GNEVehicle::GNESingleVehiclePopupMenu::myTransformToFlow
FXMenuCommand * myTransformToFlow
menu command for transform to flow
Definition: GNEVehicle.h:80
GNEVehicle
Definition: GNEVehicle.h:35
GNEVehicle::GNESingleVehiclePopupMenu::myTransformToVehicle
FXMenuCommand * myTransformToVehicle
menu command for transform to vehicle
Definition: GNEVehicle.h:65
GNEVehicle::getParentName
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEVehicle.cpp:626
GNEVehicle::GNESelectedVehiclesPopupMenu::myTransformToVehicle
FXMenuCommand * myTransformToVehicle
menu command for transform to vehicle
Definition: GNEVehicle.h:114
GNEVehicle::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEVehicle.cpp:605
GNEVehicle::GNESingleVehiclePopupMenu
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition: GNEVehicle.h:39
GNEVehicle::splitEdgeGeometry
void splitEdgeGeometry(const double splitPosition, const GNENetElement *originalElement, const GNENetElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNEVehicle.cpp:647
GNEVehicle::GNESingleVehiclePopupMenu::myTransformToTrip
FXMenuCommand * myTransformToTrip
menu command for transform to trip
Definition: GNEVehicle.h:77
GNEVehicle::GNESingleVehiclePopupMenu::onCmdTransform
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:128
GNEVehicle::GNESelectedVehiclesPopupMenu::myTransformAllVehiclesToVehicle
FXMenuCommand * myTransformAllVehiclesToVehicle
menu command for transform all selected vehicles to vehicle
Definition: GNEVehicle.h:132
GNEVehicle::GNESelectedVehiclesPopupMenu::myTransformAllVehiclesToRouteFlowWithEmbeddedRoute
FXMenuCommand * myTransformAllVehiclesToRouteFlowWithEmbeddedRoute
menu command for transform all selected vehicles to route flow with an embedded route
Definition: GNEVehicle.h:141
GNEUndoList
Definition: GNEUndoList.h:48
GNEVehicle::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEVehicle.cpp:653
GNEVehicle::moveGeometry
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNEVehicle.cpp:507
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GNEVehicle::GNESelectedVehiclesPopupMenu::myTransformAllVehiclesToFlow
FXMenuCommand * myTransformAllVehiclesToFlow
menu command for transform all selected vehicles to flow
Definition: GNEVehicle.h:147
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
GNEVehicle::endGeometryMoving
void endGeometryMoving()
end geometry movement
Definition: GNEVehicle.cpp:501
GNEVehicle::operator=
GNEVehicle & operator=(const GNEVehicle &)=delete
Invalidated assignment operator.
GNEVehicle::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNEVehicle.cpp:803