Eclipse SUMO - Simulation of Urban MObility
GNEVType.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 // Definition of Vehicle Types in NETEDIT
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
23 
24 #include "GNEDemandElement.h"
25 
26 
27 // ===========================================================================
28 // class definitions
29 // ===========================================================================
30 
32 
33 public:
35  GNEVType(GNENet* net);
36 
38  GNEVType(GNENet* net, const std::string& vTypeID, const SUMOVehicleClass& defaultVClass);
39 
41  GNEVType(GNENet* net, const SUMOVTypeParameter& vTypeParameter);
42 
44  GNEVType(GNENet* net, const std::string& vTypeID, GNEVType* vTypeOriginal);
45 
47  ~GNEVType();
48 
53 
57  void writeDemandElement(OutputDevice& device) const;
58 
61 
63  std::string getDemandElementProblem() const;
64 
67 
72 
74  const RGBColor& getColor() const;
75 
77 
81  void updateGeometry();
82 
86 
89 
92  std::string getParentName() const;
93 
95  double getExaggeration(const GUIVisualizationSettings& s) const;
96 
101 
103  void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList);
104 
109  void drawGL(const GUIVisualizationSettings& s) const;
110 
112 
115 
117  void computePathElement();
118 
125  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const;
126 
134  void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const;
135 
137  GNELane* getFirstPathLane() const;
138 
140  GNELane* getLastPathLane() const;
142 
145  /* @brief method for getting the Attribute of an XML key
146  * @param[in] key The attribute key
147  * @return string with the value associated to key
148  */
149  std::string getAttribute(SumoXMLAttr key) const;
150 
151  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
152  * @param[in] key The attribute key
153  * @return double with the value associated to key
154  */
155  double getAttributeDouble(SumoXMLAttr key) const;
156 
157  /* @brief method for getting the Attribute of an XML key in Position format (used in person plans)
158  * @param[in] key The attribute key
159  * @return double with the value associated to key
160  */
162 
163  /* @brief method for setting the attribute and letting the object perform additional changes
164  * @param[in] key The attribute key
165  * @param[in] value The new value
166  * @param[in] undoList The undoList on which to register changes
167  * @param[in] net optionally the GNENet to inform about gui updates
168  */
169  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
170 
171  /* @brief method for setting the attribute and letting the object perform additional changes
172  * @param[in] key The attribute key
173  * @param[in] value The new value
174  * @param[in] undoList The undoList on which to register changes
175  */
176  bool isValid(SumoXMLAttr key, const std::string& value);
177 
178  /* @brief method for enable attribute
179  * @param[in] key The attribute key
180  * @param[in] undoList The undoList on which to register changes
181  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
182  */
183  void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
184 
185  /* @brief method for disable attribute
186  * @param[in] key The attribute key
187  * @param[in] undoList The undoList on which to register changes
188  * @note certain attributes can be only enabled, and can produce the disabling of other attributes
189  */
190  void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
191 
192  /* @brief method for check if the value for certain attribute is set
193  * @param[in] key The attribute key
194  */
195  bool isAttributeEnabled(SumoXMLAttr key) const;
196 
198  std::string getPopUpID() const;
199 
201  std::string getHierarchyName() const;
203 
205  const std::map<std::string, std::string>& getACParametersMap() const;
206 
208  static void overwriteVType(GNEDemandElement* vType, const SUMOVTypeParameter newVTypeParameter, GNEUndoList* undoList);
209 
210 protected:
213 
216 
218  void editVTypeDistribution(const std::string& vTypeDistributionID, GNEUndoList* undoList);
219 
221  bool askAddVTypeDistribution(const std::string& vTypeDistribution) const;
222 
224  bool askRemoveVTypeDistribution(const std::string& vTypeDistribution) const;
225 
226 private:
228  void setAttribute(SumoXMLAttr key, const std::string& value);
229 
231  void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters);
232 
234  void setMoveShape(const GNEMoveResult& moveResult);
235 
237  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
238 
240  void updateDefaultVClassAttributes(const VClassDefaultValues& defaultValues);
241 
243  GNEVType(GNEVType*) = delete;
244 
247 };
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
An Element which don't belongs to GNENet but has influency in the simulation.
Problem
enum class for demandElement problems
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
Problem isDemandElementValid() const
check if current demand element is valid to be writed into XML
Definition: GNEVType.cpp:109
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
Definition: GNEVType.cpp:161
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEVType.cpp:923
void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters)
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
Definition: GNEVType.cpp:1839
void updateGeometry()
update pre-computed geometry information
Definition: GNEVType.cpp:140
GNEVType * operator=(GNEVType *)=delete
Invalidated assignment operator.
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEVType.cpp:155
~GNEVType()
destructor
Definition: GNEVType.cpp:86
bool askRemoveVTypeDistribution(const std::string &vTypeDistribution) const
ask if remove vTypeDistribution
Definition: GNEVType.cpp:1328
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEVType.cpp:678
bool askAddVTypeDistribution(const std::string &vTypeDistribution) const
ask if add vTypeDistribution
Definition: GNEVType.cpp:1304
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNEVType.cpp:90
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEVType.cpp:149
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object.
Definition: GNEVType.cpp:192
GNEVType(GNEVType *)=delete
Invalidated copy constructor.
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEVType.cpp:882
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
Definition: GNEVType.cpp:542
static void overwriteVType(GNEDemandElement *vType, const SUMOVTypeParameter newVTypeParameter, GNEUndoList *undoList)
overwrite all values of GNEVType with a SUMOVTypeParameter
Definition: GNEVType.cpp:935
void updateDefaultVClassAttributes(const VClassDefaultValues &defaultValues)
function called after set new VClass
Definition: GNEVType.cpp:1857
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNEVType.cpp:1851
GNELane * getFirstPathLane() const
get first path lane
Definition: GNEVType.cpp:204
GNELane * getLastPathLane() const
get last path lane
Definition: GNEVType.cpp:211
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNEVType.cpp:174
void writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNEVType.cpp:96
bool myDefaultVehicleType
flag to check if this GNEVType is a default vehicle Type (For Vehicles, Pedestrians....
Definition: GNEVType.h:212
const RGBColor & getColor() const
get color
Definition: GNEVType.cpp:134
std::string getDemandElementProblem() const
return a string with the current demand element problem
Definition: GNEVType.cpp:116
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNEVType.cpp:929
void fixDemandElementProblem()
fix demand element problem
Definition: GNEVType.cpp:122
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNEVType.cpp:1845
GNEVType(GNENet *net)
default constructor
Definition: GNEVType.cpp:35
Position getAttributePosition(SumoXMLAttr key) const
Definition: GNEVType.cpp:536
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNEVType.cpp:495
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEVType.cpp:180
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition: GNEVType.cpp:218
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEVType.cpp:167
void computePathElement()
compute pathElement
Definition: GNEVType.cpp:186
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEVType.cpp:917
SUMOVehicleClass getVClass() const
Definition: GNEVType.cpp:128
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEVType.cpp:870
void editVTypeDistribution(const std::string &vTypeDistributionID, GNEUndoList *undoList)
edit vType distribution
Definition: GNEVType.cpp:1247
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEVType.cpp:876
bool myDefaultVehicleTypeModified
flag to check if this default GNEVType was modified
Definition: GNEVType.h:215
Stores the information about how to visualize structures.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
Structure representing possible vehicle parameter.
struct for default values that depend of VClass