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 /****************************************************************************/
15 // Representation of vehicles in NETEDIT
16 /****************************************************************************/
17 #ifndef GNEVehicle_h
18 #define GNEVehicle_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 
27 
28 #include "GNEDemandElement.h"
29 
30 // ===========================================================================
31 // class definitions
32 // ===========================================================================
37 
38 public:
41  FXDECLARE(GNESingleVehiclePopupMenu)
42 
43  public:
50 
53 
55  long onCmdTransform(FXObject* obj, FXSelector, void*);
56 
57  protected:
60 
61  private:
64 
66  FXMenuCommand* myTransformToVehicle;
67 
70 
72  FXMenuCommand* myTransformToRouteFlow;
73 
76 
78  FXMenuCommand* myTransformToTrip;
79 
81  FXMenuCommand* myTransformToFlow;
82  };
83 
87 
88  public:
95  GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent);
96 
99 
101  long onCmdTransform(FXObject* obj, FXSelector, void*);
102 
103  protected:
106 
107  private:
109  std::vector<GNEVehicle*> mySelectedVehicles;
110 
113 
115  FXMenuCommand* myTransformToVehicle;
116 
119 
121  FXMenuCommand* myTransformToRouteFlow;
122 
125 
127  FXMenuCommand* myTransformToTrip;
128 
130  FXMenuCommand* myTransformToFlow;
131 
134 
137 
140 
143 
146 
149  };
150 
152  GNEVehicle(SumoXMLTag tag, GNEViewNet* viewNet, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEDemandElement* route);
153 
155  GNEVehicle(GNEViewNet* viewNet, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters);
156 
158  GNEVehicle(GNEViewNet* viewNet, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters);
159 
161  GNEVehicle(SumoXMLTag tag, GNEViewNet* viewNet, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge);
162 
164  GNEVehicle(GNEViewNet* viewNet, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const SUMOVehicleParameter& vehicleParameters);
165 
167  ~GNEVehicle();
168 
173  std::string getBegin() const;
174 
178  void writeDemandElement(OutputDevice& device) const;
179 
181  bool isDemandElementValid() const;
182 
184  std::string getDemandElementProblem() const;
185 
188 
192  GNEEdge* getFromEdge() const;
193 
195  GNEEdge* getToEdge() const;
196 
198  SUMOVehicleClass getVClass() const;
199 
201  const RGBColor& getColor() const;
202 
204  void compute();
205 
207 
211  void startGeometryMoving();
212 
214  void endGeometryMoving();
215 
219  void moveGeometry(const Position& offset);
220 
224  void commitGeometryMoving(GNEUndoList* undoList);
225 
227  void updateGeometry();
228 
230  Position getPositionInView() const;
232 
235 
243 
247  std::string getParentName() const;
248 
253 
258  void drawGL(const GUIVisualizationSettings& s) const;
260 
264  void selectAttributeCarrier(bool changeFlag = true);
265 
267  void unselectAttributeCarrier(bool changeFlag = true);
268 
269  /* @brief method for getting the Attribute of an XML key
270  * @param[in] key The attribute key
271  * @return string with the value associated to key
272  */
273  std::string getAttribute(SumoXMLAttr key) const;
274 
275  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
276  * @param[in] key The attribute key
277  * @return double with the value associated to key
278  */
279  double getAttributeDouble(SumoXMLAttr key) const;
280 
281  /* @brief method for setting the attribute and letting the object perform demand element changes
282  * @param[in] key The attribute key
283  * @param[in] value The new value
284  * @param[in] undoList The undoList on which to register changes
285  * @param[in] net optionally the GNENet to inform about gui updates
286  */
287  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
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  */
294  bool isValid(SumoXMLAttr key, const std::string& value);
295 
296  /* @brief method for enabling attribute
297  * @param[in] key The attribute key
298  * @param[in] undoList The undoList on which to register changes
299  * @note only certain attributes can be enabled, and can produce the disabling of other attributes
300  */
301  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
302 
303  /* @brief method for check if the value for certain attribute is set
304  * @param[in] key The attribute key
305  */
306  bool isAttributeEnabled(SumoXMLAttr key) const;
307 
309  std::string getPopUpID() const;
310 
312  std::string getHierarchyName() const;
314 
318  std::string getGenericParametersStr() const;
319 
321  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
322 
324  void setGenericParametersStr(const std::string& value);
325 
327 
328 protected:
331 
333  ConnectionGeometry(const NBEdge::Connection* _con, const GNELane* _laneFrom, const GNELane* _laneTo);
334 
336  ConnectionGeometry(const GNELane* _laneFrom, const GNELane* _laneTo);
337 
339  void calculateConnectionShape();
340 
343 
346 
349 
351  const GNELane* laneTo;
352 
353  private:
356  };
357 
359  void setColor(const GUIVisualizationSettings& s) const;
360 
363 
366 
367 private:
369  void setAttribute(SumoXMLAttr key, const std::string& value);
370 
372  void setEnabledAttribute(const int enabledAttributes);
373 
375  GNEVehicle(const GNEVehicle&) = delete;
376 
378  GNEVehicle& operator=(const GNEVehicle&) = delete;
379 };
380 
381 #endif
382 /****************************************************************************/
void compute()
compute demand element
Definition: GNEVehicle.cpp:496
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEVehicle.cpp:756
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
struct used for calculating routes
Definition: GNEVehicle.h:330
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEVehicle.cpp:735
SumoXMLTag
Numbers representing SUMO-XML - element names.
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNEVehicle.cpp:484
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:184
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition: GNEVehicle.h:85
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(...)
Definition: GNEVehicle.cpp:542
GNEEdge * myFromEdge
from edge (used by flows and trips)
Definition: GNEVehicle.h:362
FXMenuCommand * myTransformToTrip
menu command for transform to trip
Definition: GNEVehicle.h:127
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
void startGeometryMoving()
Definition: GNEVehicle.cpp:524
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNEVehicle.cpp:536
Stores the information about how to visualize structures.
void endGeometryMoving()
end geometry movement
Definition: GNEVehicle.cpp:530
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children) ...
Definition: GNEVehicle.cpp:446
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNEVehicle.cpp:347
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition: GNEVehicle.h:40
FXMenuCommand * myTransformToFlow
menu command for transform to flow
Definition: GNEVehicle.h:130
const RGBColor & getColor() const
get color
Definition: GNEVehicle.cpp:490
void setEnabledAttribute(const int enabledAttributes)
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute) ...
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
FXMenuCommand * myTransformToVehicleWithEmbeddedRoute
menu command for transform to vehicle with an embedded route
Definition: GNEVehicle.h:69
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNEVehicle.cpp:428
GNESelectedVehiclesPopupMenu()
default constructor needed by FOX
Definition: GNEVehicle.h:105
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:261
SumoXMLTag myVehicleTag
tag of clicked vehicle
Definition: GNEVehicle.h:112
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GNEEdge * getToEdge() const
obtain to edge of this demand element
Definition: GNEVehicle.cpp:468
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
FXMenuCommand * myTransformToFlow
menu command for transform to flow
Definition: GNEVehicle.h:81
const GNELane * laneFrom
lane from
Definition: GNEVehicle.h:348
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:129
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes ...
const GNELane * laneTo
lane to
Definition: GNEVehicle.h:351
GNEVehicle * myVehicle
current vehicle
Definition: GNEVehicle.h:63
FXMenuCommand * myTransformAllVehiclesToRouteFlow
menu command for transform all selected vehicles to route flow
Definition: GNEVehicle.h:139
const NBEdge::Connection * con
Pointer to NBEdge::Connection.
Definition: GNEVehicle.h:345
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEVehicle.cpp:940
A list of positions.
FXMenuCommand * myTransformToRouteFlowWithEmbeddedRoute
menu command for transform to route flow with an embedded route
Definition: GNEVehicle.h:75
GNEEdge * getFromEdge() const
Definition: GNEVehicle.cpp:452
bool isAttributeEnabled(SumoXMLAttr key) const
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
FXMenuCommand * myTransformToRouteFlowWithEmbeddedRoute
menu command for transform to route flow with an embedded route
Definition: GNEVehicle.h:124
GNEVehicle & operator=(const GNEVehicle &)=delete
Invalidated assignment operator.
GNESingleVehiclePopupMenu()
default constructor needed by FOX
Definition: GNEVehicle.h:59
FXMenuCommand * myTransformToRouteFlow
menu command for transform to route flow
Definition: GNEVehicle.h:121
FXMenuCommand * myTransformToTrip
menu command for transform to trip
Definition: GNEVehicle.h:78
PositionVector connectionShape
calculated connection shape
Definition: GNEVehicle.h:342
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNEVehicle.cpp:924
std::vector< GNEVehicle * > mySelectedVehicles
current selected vehicles
Definition: GNEVehicle.h:109
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEVehicle.cpp:768
~GNEVehicle()
destructor
Definition: GNEVehicle.cpp:324
void selectAttributeCarrier(bool changeFlag=true)
inherited from GNEAttributeCarrier
Definition: GNEVehicle.cpp:909
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
FXMenuCommand * myTransformAllVehiclesToTrip
menu command for transform all selected vehicles to trip
Definition: GNEVehicle.h:145
Structure representing possible vehicle parameter.
double getAttributeDouble(SumoXMLAttr key) const
void updateGeometry()
update pre-computed geometry information
Definition: GNEVehicle.cpp:548
FXMenuCommand * myTransformAllVehiclesToVehicleWithEmbeddedRoute
menu command for transform all selected vehicles to vehicle with an embedded route ...
Definition: GNEVehicle.h:136
SumoXMLTag tag
The vehicle tag.
FXMenuCommand * myTransformAllVehiclesToRouteFlowWithEmbeddedRoute
menu command for transform all selected vehicles to route flow with an embedded route ...
Definition: GNEVehicle.h:142
The popup menu of a globject.
std::string getBegin() const
get begin time of demand element
Definition: GNEVehicle.cpp:328
bool isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNEVehicle.cpp:406
GNEEdge * myToEdge
to edge (used by flows and trips)
Definition: GNEVehicle.h:365
FXMenuCommand * myTransformToVehicleWithEmbeddedRoute
menu command for transform to vehicle with an embedded route
Definition: GNEVehicle.h:118
std::string getGenericParametersStr() const
return generic parameters in string format
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
Position getPositionInView() const
Returns position of demand element in view.
Definition: GNEVehicle.cpp:719
FXMenuCommand * myTransformToVehicle
menu command for transform to vehicle
Definition: GNEVehicle.h:66
FXMenuCommand * myTransformAllVehiclesToFlow
menu command for transform all selected vehicles to flow
Definition: GNEVehicle.h:148
FXMenuCommand * myTransformToVehicle
menu command for transform to vehicle
Definition: GNEVehicle.h:115
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEVehicle.cpp:777
FXMenuCommand * myTransformAllVehiclesToVehicle
menu command for transform all selected vehicles to vehicle
Definition: GNEVehicle.h:133
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
FXMenuCommand * myTransformToRouteFlow
menu command for transform to route flow
Definition: GNEVehicle.h:72