Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEAttributeCarrier.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// Abstract Base class for gui objects which carry attributes
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
25
26#include "GNETagProperties.h"
27
28
29// ===========================================================================
30// class declarations
31// ===========================================================================
32class GNENet;
33class GNEUndoList;
34class GUIGlObject;
36class GNELane;
37class GNEEdge;
38
39// ===========================================================================
40// class definitions
41// ===========================================================================
49
51 friend class GNEChange_Attribute;
55 friend class GNEFlowEditor;
56
57public:
58
63 GNEAttributeCarrier(const SumoXMLTag tag, GNENet* net);
64
66 virtual ~GNEAttributeCarrier();
67
69 const std::string getID() const;
70
72 GNENet* getNet() const;
73
75 void selectAttributeCarrier(const bool changeFlag = true);
76
78 void unselectAttributeCarrier(const bool changeFlag = true);
79
81 bool isAttributeCarrierSelected() const;
82
84 bool drawUsingSelectColor() const;
85
88
92 void setInGrid(bool value);
93
95 bool inGrid() const;
96
98
103
105 virtual const GUIGlObject* getGUIGlObject() const = 0;
106
108 virtual void updateGeometry() = 0;
109
111
114
116 bool checkDrawInspectContour() const;
117
119 bool checkDrawFrontContour() const;
120
122 virtual bool checkDrawFromContour() const = 0;
123
125 virtual bool checkDrawToContour() const = 0;
126
128 virtual bool checkDrawRelatedContour() const = 0;
129
131 virtual bool checkDrawOverContour() const = 0;
132
134 virtual bool checkDrawDeleteContour() const = 0;
135
137 virtual bool checkDrawSelectContour() const = 0;
138
140 virtual bool checkDrawMoveContour() const = 0;
141
143
145 void resetDefaultValues();
146
149 /* @brief method for getting the Attribute of an XML key
150 * @param[in] key The attribute key
151 * @return string with the value associated to key
152 */
153 virtual std::string getAttribute(SumoXMLAttr key) const = 0;
154
155 /* @brief method for setting the attribute and letting the object perform additional changes
156 * @param[in] key The attribute key
157 * @param[in] value The new value
158 * @param[in] undoList The undoList on which to register changes
159 */
160 virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
161
162 /* @brief method for check if new value for certain attribute is valid
163 * @param[in] key The attribute key
164 * @param[in] value The new value
165 */
166 virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
167
168 /* @brief method for enable attribute
169 * @param[in] key The attribute key
170 * @param[in] undoList The undoList on which to register changes
171 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
172 */
173 virtual void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
174
175 /* @brief method for disable attribute
176 * @param[in] key The attribute key
177 * @param[in] undoList The undoList on which to register changes
178 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
179 */
180 virtual void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
181
182 /* @brief method for check if the value for certain attribute is set
183 * @param[in] key The attribute key
184 */
185 virtual bool isAttributeEnabled(SumoXMLAttr key) const;
186
187 /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
188 * @param[in] key The attribute key
189 */
190 virtual bool isAttributeComputed(SumoXMLAttr key) const;
191
192 /* @brief method for check if the value for certain attribute is set
193 * @param[in] key The attribute key
194 */
195 bool hasAttribute(SumoXMLAttr key) const {
196 return myTagProperty.hasAttribute(key);
197 }
198
200 virtual std::string getPopUpID() const = 0;
201
203 virtual std::string getHierarchyName() const = 0;
204
206
210 virtual const Parameterised::Map& getACParametersMap() const = 0;
211
213 template<typename T>
215
217 void setACParameters(const std::string& parameters, GNEUndoList* undoList);
218
220 void setACParameters(const std::vector<std::pair<std::string, std::string> >& parameters, GNEUndoList* undoList);
221
223 void setACParameters(const Parameterised::Map& parameters, GNEUndoList* undoList);
224
226 void addACParameters(const std::string& key, const std::string& attribute, GNEUndoList* undoList);
227
229 void removeACParametersKeys(const std::vector<std::string>& keepKeys, GNEUndoList* undoList);
230
232
233 /* @brief method for return an alternative value for disabled attributes. Used only in GNEFrames
234 * @param[in] key The attribute key
235 */
237
239 virtual std::string getAttributeForSelection(SumoXMLAttr key) const;
240
242 const std::string& getTagStr() const;
243
245 FXIcon* getACIcon() const;
246
248 bool isTemplate() const;
249
251 const GNETagProperties& getTagProperty() const;
252
254 static const GNETagProperties& getTagProperty(SumoXMLTag tag);
255
257 static const std::vector<GNETagProperties> getTagPropertiesByType(const int tagPropertyCategory, const bool mergeCommonPlans);
258
260 static const std::vector<GNETagProperties> getTagPropertiesByMergingTag(SumoXMLTag mergingTag);
261
263 template<typename T>
264 static bool canParse(const std::string& string) {
265 try {
266 GNEAttributeCarrier::parse<T>(string);
267 } catch (EmptyData&) {
268 // general
269 return false;
270 } catch (FormatException&) {
271 // numbers, time, boolean, colors
272 return false;
273 }
274 return true;
275 }
276
278 template<typename T>
279 static T parse(const std::string& string);
280
282 template<typename T>
283 static bool canParse(GNENet* net, const std::string& value, bool report) {
284 try {
285 parse<T>(net, value);
286 } catch (FormatException& exception) {
287 if (report) {
288 WRITE_WARNING(exception.what())
289 }
290 return false;
291 }
292 return true;
293 }
294
296 template<typename T>
297 static T parse(GNENet* net, const std::string& value);
298
300 template<typename T>
301 static std::string parseIDs(const std::vector<T>& ACs);
302
304 static bool lanesConsecutives(const std::vector<GNELane*>& lanes);
305
307 static void writeAttributeHelp();
308
311
313 static const std::string FEATURE_LOADED;
314
316 static const std::string FEATURE_GUESSED;
317
319 static const std::string FEATURE_MODIFIED;
320
322 static const std::string FEATURE_APPROVED;
323
325
327 static const size_t MAXNUMBEROFATTRIBUTES;
328
331
333 static const std::string True;
334
336 static const std::string False;
337
338protected:
341
343 GNENet* myNet = nullptr;
344
346 bool mySelected = false;
347
349 bool myInGrid = false;
350
352 bool myIsTemplate = false;
353
355 virtual void toggleAttribute(SumoXMLAttr key, const bool value);
356
357private:
359 virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
360
362 void resetAttributes();
363
365 static void fillAttributeCarriers();
366
368 static void fillNetworkElements();
369
371 static void fillAdditionalElements();
372
374 static void fillShapeElements();
375
377 static void fillTAZElements();
378
380 static void fillWireElements();
381
383 static void fillJuPedSimElements();
384
386 static void fillDemandElements();
387
389 static void fillVehicleElements();
390
392 static void fillStopElements();
393
395 static void fillWaypointElements();
396
398 static void fillPersonElements();
399
401 static void fillPersonPlanTrips();
402
404 static void fillPersonPlanWalks();
405
407 static void fillPersonPlanRides();
408
410 static void fillPersonStopElements();
411
413 static void fillContainerElements();
414
416 static void fillContainerTransportElements();
417
419 static void fillContainerTranshipElements();
420
422 static void fillContainerStopElements();
423
425 static void fillPOIAttributes(SumoXMLTag currentTag);
426
428 static void fillCommonVehicleAttributes(SumoXMLTag currentTag);
429
431 static void fillCommonFlowAttributes(SumoXMLTag currentTag, SumoXMLAttr perHour);
432
434 static void fillCarFollowingModelAttributes(SumoXMLTag currentTag);
435
437 static void fillJunctionModelAttributes(SumoXMLTag currentTag);
438
440 static void fillLaneChangingModelAttributes(SumoXMLTag currentTag);
441
443 static void fillCommonPersonAttributes(SumoXMLTag currentTag);
444
446 static void fillCommonContainerAttributes(SumoXMLTag currentTag);
447
449 static void fillCommonStopAttributes(SumoXMLTag currentTag, const bool waypoint);
450
452 static void fillPlanParentAttributes(SumoXMLTag currentTag);
453
455 static void fillPersonTripCommonAttributes(GNETagProperties& tagProperties);
456
458 static void fillWalkCommonAttributes(GNETagProperties& tagProperties);
459
461 static void fillRideCommonAttributes(GNETagProperties& tagProperties);
462
464 static void fillTransportCommonAttributes(GNETagProperties& tagProperties);
465
467 static void fillTranshipCommonAttributes(GNETagProperties& tagProperties);
468
470 static void fillPlanStopCommonAttributes(GNETagProperties& tagProperties);
471
473 static void fillDataElements();
474
476 static void fillCommonMeanDataAttributes(SumoXMLTag currentTag);
477
479 static std::map<SumoXMLTag, GNETagProperties> myTagProperties;
480
482 static std::map<SumoXMLTag, GNETagProperties> myMergedPlanTagProperties;
483
486
489};
#define WRITE_WARNING(msg)
Definition MsgHandler.h:295
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
static void fillPersonTripCommonAttributes(GNETagProperties &tagProperties)
fill person trip common attributes
static void fillPlanStopCommonAttributes(GNETagProperties &tagProperties)
fill plan stop common attributes
GNEAttributeCarrier(const GNEAttributeCarrier &)=delete
Invalidated copy constructor.
virtual std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
virtual bool checkDrawMoveContour() const =0
check if draw move contour (red)
GNEAttributeCarrier & operator=(const GNEAttributeCarrier &src)=delete
Invalidated assignment operator.
virtual void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
static std::map< SumoXMLTag, GNETagProperties > myMergedPlanTagProperties
map with the merged tags properties
virtual bool checkDrawRelatedContour() const =0
check if draw related contour (cyan)
FXIcon * getACIcon() const
get FXIcon associated to this AC
bool mySelected
boolean to check if this AC is selected (instead of GUIGlObjectStorage)
static void writeAttributeHelp()
write machine readable attribute help to file
static void fillContainerStopElements()
fill container stop elements
static void fillVehicleElements()
fill vehicle elements
static void fillDemandElements()
fill demand elements
virtual const GUIGlObject * getGUIGlObject() const =0
get GUIGlObject associated with this AttributeCarrier (constant)
static void fillWaypointElements()
fill waypoint elements
static void fillPersonElements()
fill person elements
virtual bool checkDrawToContour() const =0
check if draw from contour (magenta)
void setACParameters(const std::string &parameters, GNEUndoList *undoList)
set parameters (string)
static void fillDataElements()
fill Data elements
static void fillPersonPlanRides()
fill person plan rides
static void fillCommonStopAttributes(SumoXMLTag currentTag, const bool waypoint)
fill stop person attributes
bool checkDrawFrontContour() const
check if draw front contour (green/blue)
static void fillLaneChangingModelAttributes(SumoXMLTag currentTag)
fill Junction Model Attributes of Vehicle/Person Types
void resetAttributes()
reset attributes to their default values without undo-redo (used in GNEFrameAttributeModules)
bool myIsTemplate
whether the current object is a template object (not drawn in the view)
virtual void setAttribute(SumoXMLAttr key, const std::string &value)=0
method for setting the attribute and nothing else (used in GNEChange_Attribute)
virtual bool checkDrawFromContour() const =0
check if draw from contour (green)
static void fillAttributeCarriers()
fill Attribute Carriers
virtual void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
static void fillAdditionalElements()
fill additional elements
static const std::string FEATURE_LOADED
feature is still unchanged after being loaded (implies approval)
static void fillCommonMeanDataAttributes(SumoXMLTag currentTag)
fill stop person attributes
static void fillCommonPersonAttributes(SumoXMLTag currentTag)
fill common person attributes (used by person and personFlows)
virtual std::string getPopUpID() const =0
get PopPup ID (Used in AC Hierarchy)
static void fillNetworkElements()
fill network elements
static void fillWalkCommonAttributes(GNETagProperties &tagProperties)
fill walk common attributes
static void fillPersonStopElements()
fill person stop elements
static const std::vector< GNETagProperties > getTagPropertiesByType(const int tagPropertyCategory, const bool mergeCommonPlans)
get tagProperties associated to the given GNETagProperties::TagType (NETWORKELEMENT,...
static void fillTransportCommonAttributes(GNETagProperties &tagProperties)
fill transport common attributes
static const std::string FEATURE_APPROVED
feature has been approved but not changed (i.e. after being reguessed)
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
bool myInGrid
boolean to check if this AC is in grid
std::string getAlternativeValueForDisabledAttributes(SumoXMLAttr key) const
virtual bool isAttributeComputed(SumoXMLAttr key) const
static void fillWireElements()
fill Wire elements
static const std::string True
true value in string format (used for comparing boolean values in getAttribute(......
static T parse(GNENet *net, const std::string &value)
parses a complex value of type T from string (use for list of edges, list of lanes,...
static void fillPOIAttributes(SumoXMLTag currentTag)
fill common POI attributes
static void fillTranshipCommonAttributes(GNETagProperties &tagProperties)
fill ride common attributes
void removeACParametersKeys(const std::vector< std::string > &keepKeys, GNEUndoList *undoList)
remove keys
virtual bool isAttributeEnabled(SumoXMLAttr key) const
const std::string & getTagStr() const
get tag assigned to this object in string format
static void fillJuPedSimElements()
fill JuPedSim elements
static const std::string FEATURE_GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
static void fillStopElements()
fill stop elements
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
bool isTemplate() const
check if this AC is template
virtual const Parameterised::Map & getACParametersMap() const =0
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
static bool canParse(GNENet *net, const std::string &value, bool report)
true if a value of type T can be parsed from string
static void fillShapeElements()
fill shape elements
static void fillCommonVehicleAttributes(SumoXMLTag currentTag)
fill common vehicle attributes (used by vehicles, trips, routeFlows and flows)
void addACParameters(const std::string &key, const std::string &attribute, GNEUndoList *undoList)
add (or update attribute) key and attribute
static const Parameterised::Map PARAMETERS_EMPTY
empty parameter maps (used by ACs without parameters)
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
static bool lanesConsecutives(const std::vector< GNELane * > &lanes)
check if lanes are consecutives
bool hasAttribute(SumoXMLAttr key) const
void resetDefaultValues()
reset attribute carrier to their default values
static void fillPersonPlanWalks()
fill person plan walks
static void fillTAZElements()
fill TAZ elements
virtual bool checkDrawSelectContour() const =0
check if draw select contour (blue)
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
virtual GNEHierarchicalElement * getHierarchicalElement()=0
get GNEHierarchicalElement associated with this AttributeCarrier
GNENet * myNet
pointer to net
bool inGrid() const
check if this AC was inserted in grid
static void fillCommonContainerAttributes(SumoXMLTag currentTag)
fill common container attributes (used by container and containerFlows)
virtual std::string getHierarchyName() const =0
get Hierarchy Name (Used in AC Hierarchy)
static void fillPlanParentAttributes(SumoXMLTag currentTag)
fill plan from-to attribute
static void fillCommonFlowAttributes(SumoXMLTag currentTag, SumoXMLAttr perHour)
fill common flow attributes (used by flows, routeFlows and personFlows)
static void fillJunctionModelAttributes(SumoXMLTag currentTag)
fill Junction Model Attributes of Vehicle/Person Types
GNENet * getNet() const
get pointer to net
virtual void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
static void fillPersonPlanTrips()
fill person plan trips
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
static const std::string FEATURE_MODIFIED
feature has been manually modified (implies approval)
static const std::string False
true value in string format(used for comparing boolean values in getAttribute(...))
static void fillCarFollowingModelAttributes(SumoXMLTag currentTag)
fill Car Following Model of Vehicle/Person Types
static void fillContainerElements()
fill container elements
virtual void updateGeometry()=0
update pre-computed geometry information
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
T getACParameters() const
get parameters
virtual ~GNEAttributeCarrier()
Destructor.
virtual std::string getAttribute(SumoXMLAttr key) const =0
bool checkDrawInspectContour() const
check if draw inspect contour (black/white)
static const std::vector< GNETagProperties > getTagPropertiesByMergingTag(SumoXMLTag mergingTag)
get tagProperties associated to the given merging tag
static void fillContainerTranshipElements()
fill container tranship elements
virtual GUIGlObject * getGUIGlObject()=0
static void fillRideCommonAttributes(GNETagProperties &tagProperties)
fill ride common attributes
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
static std::map< SumoXMLTag, GNETagProperties > myTagProperties
map with the tags properties
static const size_t MAXNUMBEROFATTRIBUTES
max number of attributes allowed for every tag
virtual bool checkDrawOverContour() const =0
check if draw over contour (orange)
virtual bool checkDrawDeleteContour() const =0
check if draw delete contour (pink/white)
static void fillContainerTransportElements()
fill container transport elements
the function-object for an editing operation (abstract base)
the function-object for an editing operation (abstract base)
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
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute "attr"
std::map< std::string, std::string > Map
parameters map