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-2024 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 definitions
29// ===========================================================================
30
32
33public:
37
38 public:
45
48
50 long onCmdTransform(FXObject*, FXSelector sel, void*);
51
52 protected:
55
56 private:
59 };
60
64
65 public:
72 GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent);
73
76
78 long onCmdTransform(FXObject* obj, FXSelector sel, void*);
79
80 protected:
83
84 private:
86 std::vector<GNEVehicle*> mySelectedVehicles;
87
89 std::map<FXObject*, SumoXMLTag> myRestrictedMenuCommands;
90
93 };
94
97
99 GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEDemandElement* route);
100
102 GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters);
103
105 GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters);
106
108 GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge);
109
111 GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const SUMOVehicleParameter& vehicleParameters);
112
114 GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction);
115
117 GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters);
118
120 GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEAdditional* fromTAZ, GNEAdditional* toTAZ, const SUMOVehicleParameter& vehicleParameters);
121
123 ~GNEVehicle();
124
129
133 void writeDemandElement(OutputDevice& device) const;
134
137
139 std::string getDemandElementProblem() const;
140
143
148
150 const RGBColor& getColor() const;
151
153
157 void updateGeometry();
158
161
163
167 bool checkDrawRelatedContour() const;
168
170
173
181
185 std::string getParentName() const;
186
188 double getExaggeration(const GUIVisualizationSettings& s) const;
189
194
196 void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
197
202 void drawGL(const GUIVisualizationSettings& s) const;
203
205
208
210 void computePathElement();
211
217 void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const;
218
224 void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const;
225
227 GNELane* getFirstPathLane() const;
228
230 GNELane* getLastPathLane() const;
232
235 /* @brief method for getting the Attribute of an XML key
236 * @param[in] key The attribute key
237 * @return string with the value associated to key
238 */
239 std::string getAttribute(SumoXMLAttr key) const;
240
241 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
242 * @param[in] key The attribute key
243 * @return double with the value associated to key
244 */
245 double getAttributeDouble(SumoXMLAttr key) const;
246
247 /* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
248 * @param[in] key The attribute key
249 * @return double with the value associated to key
250 */
252
253 /* @brief method for setting the attribute and letting the object perform demand element changes
254 * @param[in] key The attribute key
255 * @param[in] value The new value
256 * @param[in] undoList The undoList on which to register changes
257 * @param[in] net optionally the GNENet to inform about gui updates
258 */
259 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
260
261 /* @brief method for setting the attribute and letting the object perform demand element changes
262 * @param[in] key The attribute key
263 * @param[in] value The new value
264 * @param[in] undoList The undoList on which to register changes
265 */
266 bool isValid(SumoXMLAttr key, const std::string& value);
267
268 /* @brief method for enable attribute
269 * @param[in] key The attribute key
270 * @param[in] undoList The undoList on which to register changes
271 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
272 */
273 void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
274
275 /* @brief method for disable attribute
276 * @param[in] key The attribute key
277 * @param[in] undoList The undoList on which to register changes
278 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
279 */
280 void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
281
282 /* @brief method for check if the value for certain attribute is set
283 * @param[in] key The attribute key
284 */
285 bool isAttributeEnabled(SumoXMLAttr key) const;
286
288 std::string getPopUpID() const;
289
291 std::string getHierarchyName() const;
293
296
298 static GNEDemandElement* copyVehicle(const GNEVehicle* originalVehicle);
299
300protected:
303
306
309
310private:
312 static const double myArrivalPositionDiameter;
313
315 void setAttribute(SumoXMLAttr key, const std::string& value);
316
318 void toggleAttribute(SumoXMLAttr key, const bool value);
319
321 void setMoveShape(const GNEMoveResult& moveResult);
322
324 void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
325
327 GNEVehicle(const GNEVehicle&) = delete;
328
330 GNEVehicle& operator=(const GNEVehicle&) = delete;
331};
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:62
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:89
SumoXMLTag myVehicleTag
tag of clicked vehicle
Definition GNEVehicle.h:92
std::vector< GNEVehicle * > mySelectedVehicles
current selected vehicles
Definition GNEVehicle.h:86
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition GNEVehicle.h:35
long onCmdTransform(FXObject *, FXSelector sel, void *)
Called to transform the current vehicle to another vehicle type.
GNEVehicle * myVehicle
current vehicle
Definition GNEVehicle.h:58
FOX_CONSTRUCTOR(GNESingleVehiclePopupMenu)
default constructor needed by FOX
const Parameterised::Map & getACParametersMap() const
get parameters map
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
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.
GNEMoveOperation * getMoveOperation()
get move operation
std::string getAttribute(SumoXMLAttr key) const
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:302
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
~GNEVehicle()
destructor
double getAttributeDouble(SumoXMLAttr key) const
RGBColor getDrawingColor(const GUIVisualizationSettings &s) const
get drawing color
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
bool isAttributeEnabled(SumoXMLAttr key) const
GNEVehicle(const GNEVehicle &)=delete
Invalidated copy constructor.
const RGBColor & getColor() const
get color
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...
static const double myArrivalPositionDiameter
vehicle arrival position radius
Definition GNEVehicle.h:312
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
const SUMOVehicleParameter & getSUMOVehicleParameter() const
@brier get sumo vehicle parameter
void updateGeometry()
update pre-computed geometry information
Position getAttributePosition(SumoXMLAttr key) const
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
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.
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Position getPositionInView() const
Returns position of demand element in view.
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_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
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.
std::map< std::string, std::string > Map
parameters map
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.