Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEVehicle.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 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"
26
27// ===========================================================================
28// class declaration
29// ===========================================================================
30
32
33// ===========================================================================
34// class definitions
35// ===========================================================================
36
38
39public:
43
44 public:
51
54
56 long onCmdTransform(FXObject*, FXSelector sel, void*);
57
58 protected:
61
62 private:
65 };
66
70
71 public:
78 GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent);
79
82
84 long onCmdTransform(FXObject* obj, FXSelector sel, void*);
85
86 protected:
89
90 private:
92 std::vector<GNEVehicle*> mySelectedVehicles;
93
95 std::map<FXObject*, SumoXMLTag> myRestrictedMenuCommands;
96
99 };
100
103
105 GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEDemandElement* route);
106
108 GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters);
109
111 GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters);
112
114 GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge);
115
117 GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const SUMOVehicleParameter& vehicleParameters);
118
120 GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction);
121
123 GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters);
124
126 GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEAdditional* fromTAZ, GNEAdditional* toTAZ, const SUMOVehicleParameter& vehicleParameters);
127
129 ~GNEVehicle();
130
133
135 GNEMoveElement* getMoveElement() const override;
136
138 Parameterised* getParameters() override;
139
141 const Parameterised* getParameters() const override;
142
144
148 void writeDemandElement(OutputDevice& device) const;
149
152
154 std::string getDemandElementProblem() const;
155
158
163
165 const RGBColor& getColor() const;
166
168
172 void updateGeometry() override;
173
176
178
182 bool checkDrawRelatedContour() const override;
183
185
188
196
200 std::string getParentName() const;
201
203 double getExaggeration(const GUIVisualizationSettings& s) const;
204
209
211 void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
212
217 void drawGL(const GUIVisualizationSettings& s) const;
218
220
223
225 void computePathElement();
226
232 void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const;
233
239 void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const;
240
242 GNELane* getFirstPathLane() const;
243
245 GNELane* getLastPathLane() const;
247
250 /* @brief method for getting the Attribute of an XML key
251 * @param[in] key The attribute key
252 * @return string with the value associated to key
253 */
254 std::string getAttribute(SumoXMLAttr key) const override;
255
256 /* @brief method for getting the Attribute of an XML key in double format
257 * @param[in] key The attribute key
258 * @return double with the value associated to key
259 */
260 double getAttributeDouble(SumoXMLAttr key) const override;
261
262 /* @brief method for getting the Attribute of an XML key in position format
263 * @param[in] key The attribute key
264 * @return position with the value associated to key
265 */
266 Position getAttributePosition(SumoXMLAttr key) const override;
267
268 /* @brief method for setting the attribute and letting the object perform demand element changes
269 * @param[in] key The attribute key
270 * @param[in] value The new value
271 * @param[in] undoList The undoList on which to register changes
272 * @param[in] net optionally the GNENet to inform about gui updates
273 */
274 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
275
276 /* @brief method for setting the attribute and letting the object perform demand element changes
277 * @param[in] key The attribute key
278 * @param[in] value The new value
279 * @param[in] undoList The undoList on which to register changes
280 */
281 bool isValid(SumoXMLAttr key, const std::string& value) override;
282
283 /* @brief method for enable attribute
284 * @param[in] key The attribute key
285 * @param[in] undoList The undoList on which to register changes
286 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
287 */
288 void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
289
290 /* @brief method for disable attribute
291 * @param[in] key The attribute key
292 * @param[in] undoList The undoList on which to register changes
293 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
294 */
295 void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
296
297 /* @brief method for check if the value for certain attribute is set
298 * @param[in] key The attribute key
299 */
300 bool isAttributeEnabled(SumoXMLAttr key) const;
301
303 std::string getPopUpID() const override;
304
306 std::string getHierarchyName() const override;
307
309
311 static GNEDemandElement* copyVehicle(const GNEVehicle* originalVehicle);
312
313protected:
316
319
322
325
326private:
328 void setAttribute(SumoXMLAttr key, const std::string& value) override;
329
331 void toggleAttribute(SumoXMLAttr key, const bool value);
332
334 GNEVehicle(const GNEVehicle&) = delete;
335
337 GNEVehicle& operator=(const GNEVehicle&) = delete;
338};
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
Problem
enum class for demandElement problems
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition GNEVehicle.h:68
long onCmdTransform(FXObject *obj, FXSelector sel, void *)
Called to transform the current vehicle to another vehicle type.
FOX_CONSTRUCTOR(GNESelectedVehiclesPopupMenu)
default constructor needed by FOX
std::map< FXObject *, SumoXMLTag > myRestrictedMenuCommands
selected menu commands
Definition GNEVehicle.h:95
SumoXMLTag myVehicleTag
tag of clicked vehicle
Definition GNEVehicle.h:98
std::vector< GNEVehicle * > mySelectedVehicles
current selected vehicles
Definition GNEVehicle.h:92
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition GNEVehicle.h:41
long onCmdTransform(FXObject *, FXSelector sel, void *)
Called to transform the current vehicle to another vehicle type.
GNEVehicle * myVehicle
current vehicle
Definition GNEVehicle.h:64
FOX_CONSTRUCTOR(GNESingleVehiclePopupMenu)
default constructor needed by FOX
GNELane * getLastPathLane() const
get last path lane
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
GNEMoveElementVehicle * myMoveElementVehicle
move element demand
Definition GNEVehicle.h:315
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
bool checkDrawRelatedContour() const override
check if draw related contour (cyan)
std::string getAttribute(SumoXMLAttr key) const override
inherited from GNEAttributeCarrier
std::string getParentName() const
Returns the name of the parent object.
void computePathElement()
compute pathElement
GNEContour myVehicleContour
variable used for draw vehicle contours
Definition GNEVehicle.h:318
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
~GNEVehicle()
destructor
Position getAttributePosition(SumoXMLAttr key) const override
RGBColor getDrawingColor(const GUIVisualizationSettings &s) const
get drawing color
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
bool isAttributeEnabled(SumoXMLAttr key) const
void updateGeometry() override
update pre-computed geometry information
GNEVehicle(const GNEVehicle &)=delete
Invalidated copy constructor.
double getAttributeDouble(SumoXMLAttr key) const override
const RGBColor & getColor() const
get color
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
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 written into XML (by default true, can be reimplemente...
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Parameterised * getParameters() override
get parameters associated with this vehicle
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
const SUMOVehicleParameter & getSUMOVehicleParameter() const
@brier get sumo vehicle parameter
bool isValid(SumoXMLAttr key, const std::string &value) override
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this vehicle
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
GNEVehicle & operator=(const GNEVehicle &)=delete
Invalidated assignment operator.
Position getPositionInView() const
Returns position of demand element in view.
void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
static GNEDemandElement * copyVehicle(const GNEVehicle *originalVehicle)
create a copy of the given vehicle
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
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.
An upper class for objects with additional parameters.
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.