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>
23
24#include "GNEDemandElement.h"
25
26// ===========================================================================
27// class definitions
28// ===========================================================================
33
34public:
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
118
121
123 FXMenuCommand* myTransformToTrip;
124
126 FXMenuCommand* myTransformToFlow;
127
130
133
136
139
142
145 };
146
149
151 GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEDemandElement* route);
152
154 GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters);
155
157 GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters);
158
160 GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const std::vector<GNEEdge*>& via);
161
163 GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const std::vector<GNEEdge*>& via, const SUMOVehicleParameter& vehicleParameters);
164
166 GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction);
167
169 GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters);
170
172 ~GNEVehicle();
173
178
183 std::string getBegin() const;
184
188 void writeDemandElement(OutputDevice& device) const;
189
192
194 std::string getDemandElementProblem() const;
195
198
203
205 const RGBColor& getColor() const;
206
208
212 void updateGeometry();
213
217
220
228
232 std::string getParentName() const;
233
235 double getExaggeration(const GUIVisualizationSettings& s) const;
236
241
243 void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
244
249 void drawGL(const GUIVisualizationSettings& s) const;
250
252
255
257 void computePathElement();
258
265 void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const;
266
274 void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const;
275
277 GNELane* getFirstPathLane() const;
278
280 GNELane* getLastPathLane() const;
282
285 /* @brief method for getting the Attribute of an XML key
286 * @param[in] key The attribute key
287 * @return string with the value associated to key
288 */
289 std::string getAttribute(SumoXMLAttr key) const;
290
291 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
292 * @param[in] key The attribute key
293 * @return double with the value associated to key
294 */
295 double getAttributeDouble(SumoXMLAttr key) const;
296
297 /* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
298 * @param[in] key The attribute key
299 * @return double with the value associated to key
300 */
302
303 /* @brief method for setting the attribute and letting the object perform demand element changes
304 * @param[in] key The attribute key
305 * @param[in] value The new value
306 * @param[in] undoList The undoList on which to register changes
307 * @param[in] net optionally the GNENet to inform about gui updates
308 */
309 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
310
311 /* @brief method for setting the attribute and letting the object perform demand element changes
312 * @param[in] key The attribute key
313 * @param[in] value The new value
314 * @param[in] undoList The undoList on which to register changes
315 */
316 bool isValid(SumoXMLAttr key, const std::string& value);
317
318 /* @brief method for enable attribute
319 * @param[in] key The attribute key
320 * @param[in] undoList The undoList on which to register changes
321 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
322 */
323 void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
324
325 /* @brief method for disable attribute
326 * @param[in] key The attribute key
327 * @param[in] undoList The undoList on which to register changes
328 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
329 */
330 void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
331
332 /* @brief method for check if the value for certain attribute is set
333 * @param[in] key The attribute key
334 */
335 bool isAttributeEnabled(SumoXMLAttr key) const;
336
338 std::string getPopUpID() const;
339
341 std::string getHierarchyName() const;
343
346
347protected:
349 void setColor(const GUIVisualizationSettings& s) const;
350
351private:
353 static const double myArrivalPositionDiameter;
354
356 void setAttribute(SumoXMLAttr key, const std::string& value);
357
359 void toggleAttribute(SumoXMLAttr key, const bool value);
360
362 void setMoveShape(const GNEMoveResult& moveResult);
363
365 void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
366
368 void drawStackLabel(const Position& vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const;
369
371 void drawFlowLabel(const Position& vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const;
372
374 GNEVehicle(const GNEVehicle&) = delete;
375
377 GNEVehicle& operator=(const GNEVehicle&) = delete;
378};
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.
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:81
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:220
GNESelectedVehiclesPopupMenu(GNEVehicle *vehicle, const std::vector< GNEVehicle * > &selectedVehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
Definition: GNEVehicle.cpp:149
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:65
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:128
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
const Parameterised::Map & getACParametersMap() const
get parameters map
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 associated with this GLObject
Definition: GNEVehicle.cpp:676
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNEVehicle.cpp:586
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEVehicle.cpp:682
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNEVehicle.cpp:372
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEVehicle.cpp:664
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object.
Definition: GNEVehicle.cpp:891
void computePathElement()
compute pathElement
Definition: GNEVehicle.cpp:839
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
~GNEVehicle()
destructor
Definition: GNEVehicle.cpp:368
double getAttributeDouble(SumoXMLAttr key) const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEVehicle.cpp:697
bool isAttributeEnabled(SumoXMLAttr key) const
GNEVehicle(const GNEVehicle &)=delete
Invalidated copy constructor.
const RGBColor & getColor() const
get color
Definition: GNEVehicle.cpp:598
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:491
static const double myArrivalPositionDiameter
vehicle arrival position radius
Definition: GNEVehicle.h:353
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:691
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:643
void updateGeometry()
update pre-computed geometry information
Definition: GNEVehicle.cpp:604
Position getAttributePosition(SumoXMLAttr key) const
std::string getBegin() const
get begin time of demand element
Definition: GNEVehicle.cpp:397
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNEVehicle.cpp:533
void drawStackLabel(const Position &vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const
draw stack label
GNEVehicle & operator=(const GNEVehicle &)=delete
Invalidated assignment operator.
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Position getPositionInView() const
Returns position of demand element in view.
Definition: GNEVehicle.cpp:637
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_EnableAttribute)
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
Definition: GNEVehicle.cpp:411
GNEVehicle(SumoXMLTag tag, GNENet *net)
default constructor
Definition: GNEVehicle.cpp:262
SUMOVehicleClass getVClass() const
Definition: GNEVehicle.cpp:592
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.
std::vector< std::string > via
List of the via-edges the vehicle must visit.