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-2026 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
26
27// ===========================================================================
28// class declarations
29// ===========================================================================
30
31class FileBucket;
33class GNELane;
34class GNEMoveElement;
35class GNENet;
37class GNEUndoList;
38class GUIGlObject;
39class Parameterised;
40
41// ===========================================================================
42// class definitions
43// ===========================================================================
44
46
48 friend class GNEChange_Attribute;
51
52public:
57 GNEAttributeCarrier(const SumoXMLTag tag, GNENet* net);
58
64 GNEAttributeCarrier(const SumoXMLTag tag, GNENet* net, FileBucket* fileBucket);
65
67 virtual ~GNEAttributeCarrier();
68
71
74
76 virtual GNEMoveElement* getMoveElement() const = 0;
77
80
82 virtual const Parameterised* getParameters() const = 0;
83
86
88 virtual const GUIGlObject* getGUIGlObject() const = 0;
89
91
93 const std::string getID() const override;
94
96 GNENet* getNet() const;
97
99 virtual FileBucket* getFileBucket() const = 0;
100
102 virtual void setFileBucket(FileBucket* fileBucket);
103
105 virtual void updateGeometry() = 0;
106
111
114
116 bool isAttributeCarrierSelected() const;
117
119
122
124 bool drawUsingSelectColor() const;
125
127 bool drawMovingGeometryPoints() const;
128
130
133
135 void markForDrawingFront();
136
139
141 bool isMarkedForDrawingFront() const;
142
144 void drawInLayer(const double typeOrLayer, const double extraOffset = 0) const;
145
147
150
152 void setInGrid(bool value);
153
155 bool inGrid() const;
156
158
161
163 bool checkDrawInspectContour() const;
164
166 bool checkDrawFrontContour() const;
167
169 virtual bool checkDrawFromContour() const = 0;
170
172 virtual bool checkDrawToContour() const = 0;
173
175 virtual bool checkDrawRelatedContour() const = 0;
176
178 virtual bool checkDrawOverContour() const = 0;
179
181 virtual bool checkDrawDeleteContour() const = 0;
182
184 virtual bool checkDrawDeleteContourSmall() const = 0;
185
187 virtual bool checkDrawSelectContour() const = 0;
188
190 virtual bool checkDrawMoveContour() const = 0;
191
193
195 void resetDefaultValues(const bool allowUndoRedo);
196
199
200 /* @brief method for getting the Attribute of an XML key
201 * @param[in] key The attribute key
202 * @return string with the value associated to key
203 */
204 virtual std::string getAttribute(SumoXMLAttr key) const = 0;
205
206 /* @brief method for getting the Attribute of an XML key in double format
207 * @param[in] key The attribute key
208 * @return double with the value associated to key
209 */
210 virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
211
212 /* @brief method for getting the Attribute of an XML key in position format
213 * @param[in] key The attribute key
214 * @return position with the value associated to key
215 */
217
218 /* @brief method for getting the Attribute of an XML key in positionVector format
219 * @param[in] key The attribute key
220 * @return positionVector with the value associated to key
221 */
223
224 /* @brief method for setting the attribute and letting the object perform additional changes
225 * @param[in] key The attribute key
226 * @param[in] value The new value
227 * @param[in] undoList The undoList on which to register changes
228 */
229 virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
230
231 /* @brief method for check if new value for certain attribute is valid
232 * @param[in] key The attribute key
233 * @param[in] value The new value
234 */
235 virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
236
237 /* @brief method for enable attribute
238 * @param[in] key The attribute key
239 * @param[in] undoList The undoList on which to register changes
240 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
241 */
242 virtual void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
243
244 /* @brief method for disable attribute
245 * @param[in] key The attribute key
246 * @param[in] undoList The undoList on which to register changes
247 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
248 */
249 virtual void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
250
251 /* @brief method for check if the value for certain attribute is set
252 * @param[in] key The attribute key
253 */
254 virtual bool isAttributeEnabled(SumoXMLAttr key) const;
255
256 /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
257 * @param[in] key The attribute key
258 */
259 virtual bool isAttributeComputed(SumoXMLAttr key) const;
260
261 /* @brief method for check if the value for certain attribute is set
262 * @param[in] key The attribute key
263 */
264 bool hasAttribute(SumoXMLAttr key) const;
265
267 virtual std::string getPopUpID() const = 0;
268
270 virtual std::string getHierarchyName() const = 0;
271
273
276
278 void setACParameters(const std::vector<std::pair<std::string, std::string> >& parameters);
279
281 void setACParameters(const std::vector<std::pair<std::string, std::string> >& parameters, GNEUndoList* undoList);
282
284 void setACParameters(const Parameterised::Map& parameters, GNEUndoList* undoList);
285
287
288 /* @brief method for return an alternative value for disabled attributes. Used only in GNEFrames
289 * @param[in] key The attribute key
290 */
292
294 virtual std::string getAttributeForSelection(SumoXMLAttr key) const;
295
297 const std::string& getTagStr() const;
298
300 FXIcon* getACIcon() const;
301
303 bool isTemplate() const;
304
306 const GNETagProperties* getTagProperty() const;
307
310
312 template<typename T>
313 static bool canParse(const std::string& string);
314
316 template<typename T>
317 static T parse(const std::string& string);
318
322 template<typename T>
323 static bool canParse(const GNENet* net, const std::string& value, const bool checkConsecutivity);
324
326 template<typename T>
327 static T parse(const GNENet* net, const std::string& value);
328
330 template<typename T>
331 static std::string parseIDs(const std::vector<T>& ACs);
332
334
337 /* @brief method for getting the common attribute of an XML key
338 * @param[in] key The attribute key
339 * @return string with the value associated to key
340 */
341 std::string getCommonAttribute(SumoXMLAttr key) const;
342
343 /* @brief method for getting the common attribute of an XML key in double format
344 * @param[in] key The attribute key
345 * @return double with the value associated to key
346 */
347 double getCommonAttributeDouble(SumoXMLAttr key) const;
348
349 /* @brief method for getting the common attribute of an XML key in position format
350 * @param[in] key The attribute key
351 * @return double with the value associated to key
352 */
354
355 /* @brief method for getting the common attribute of an XML key in positionVector format
356 * @param[in] key The attribute key
357 * @return double with the value associated to key
358 */
360
361 /* @brief method for setting the common attribute and letting the object perform additional changes
362 * @param[in] key The attribute key
363 * @param[in] value The new value
364 * @param[in] undoList The undoList on which to register changes
365 */
366 void setCommonAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
367
368 /* @brief method for check if new value for certain common attribute is valid
369 * @param[in] key The attribute key
370 * @param[in] value The new value
371 */
372 bool isCommonAttributeValid(SumoXMLAttr key, const std::string& value) const;
373
375 void setCommonAttribute(SumoXMLAttr key, const std::string& value);
376
378
381
383 static const std::string FEATURE_LOADED;
384
386 static const std::string FEATURE_GUESSED;
387
389 static const std::string FEATURE_MODIFIED;
390
392 static const std::string FEATURE_APPROVED;
393
395
397 static const std::string TRUE_STR;
398
400 static const std::string FALSE_STR;
401
402protected:
405
407 GNENet* myNet = nullptr;
408
410 bool mySelected = false;
411
413 bool myDrawInFront = false;
414
416 bool myInGrid = false;
417
420
423
425 const bool myIsTemplate = false;
426
428 virtual void toggleAttribute(SumoXMLAttr key, const bool value);
429
430private:
432 virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
433
436
439};
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
virtual double getAttributeDouble(SumoXMLAttr key) const =0
bool drawMovingGeometryPoints() const
check if draw moving geometry points
GNEAttributeCarrier(const GNEAttributeCarrier &)=delete
Invalidated copy constructor.
virtual PositionVector getAttributePositionVector(SumoXMLAttr key) const =0
virtual std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
virtual bool checkDrawMoveContour() const =0
check if draw move contour (red)
void markForDrawingFront()
mark for drawing front
virtual bool checkDrawDeleteContourSmall() const =0
check if draw delete contour small (pink/white)
virtual FileBucket * getFileBucket() const =0
get reference to fileBucket in which save this AC
GNEAttributeCarrier & operator=(const GNEAttributeCarrier &src)=delete
Invalidated assignment operator.
double getCommonAttributeDouble(SumoXMLAttr key) const
virtual void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
void setInGrid(bool value)
mark if this AC was inserted in grid or not
virtual void setFileBucket(FileBucket *fileBucket)
set reference to fileBucket in which save this AC
virtual bool checkDrawRelatedContour() const =0
check if draw related contour (cyan)
bool isMarkedForDrawingFront() const
check if this AC is marked for drawing front
bool myDrawInFront
boolean to check if drawn this AC over other elements
bool myCenterAfterCreation
boolean to check if center this element after creation
FXIcon * getACIcon() const
get FXIcon associated to this AC
bool mySelected
boolean to check if this AC is selected (more quickly as checking GUIGlObjectStorage)
virtual const Parameterised * getParameters() const =0
get parameters associated with this AttributeCarrier (constant)
virtual GNEMoveElement * getMoveElement() const =0
get GNEMoveElement associated with this AttributeCarrier
FileBucket * myFileBucket
filebucket vinculated whith this AC
virtual const GUIGlObject * getGUIGlObject() const =0
get GUIGlObject associated with this AttributeCarrier (constant)
static bool canParse(const GNENet *net, const std::string &value, const bool checkConsecutivity)
true if a value of type T can be parsed from string (requires network)
static const std::string FALSE_STR
true value in string format(used for comparing boolean values in getAttribute(...))
virtual bool checkDrawToContour() const =0
check if draw from contour (magenta)
static const std::string TRUE_STR
true value in string format (used for comparing boolean values in getAttribute(......
bool checkDrawFrontContour() const
check if draw front contour (green/blue)
const std::string getID() const override
get ID (all Attribute Carriers have one)
const bool myIsTemplate
whether the current object is a template object (used for edit attributes)
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)
virtual void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
static const std::string FEATURE_LOADED
feature is still unchanged after being loaded (implies approval)
virtual std::string getPopUpID() const =0
get PopPup ID (Used in AC Hierarchy)
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....
virtual Parameterised * getParameters()=0
get parameters associated with this AttributeCarrier
bool myInGrid
boolean to check if this AC is in grid
std::string getAlternativeValueForDisabledAttributes(SumoXMLAttr key) const
virtual bool isAttributeComputed(SumoXMLAttr key) const
PositionVector getCommonAttributePositionVector(SumoXMLAttr key) const
void unselectAttributeCarrier()
unselect attribute carrier using GUIGlobalSelection
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
virtual bool isAttributeEnabled(SumoXMLAttr key) const
const std::string & getTagStr() const
get tag assigned to this object in string format
static const std::string FEATURE_GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
bool isTemplate() const
check if this AC is template
void setACParameters(const std::vector< std::pair< std::string, std::string > > &parameters)
set parameters (string vector)
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
Position getCommonAttributePosition(SumoXMLAttr key) const
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
static T parse(const GNENet *net, const std::string &value)
parses a complex value of type T from string (use for list of edges, list of lanes,...
void resetDefaultValues(const bool allowUndoRedo)
reset attribute carrier to their default values
virtual Position getAttributePosition(SumoXMLAttr key) const =0
bool hasAttribute(SumoXMLAttr key) const
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
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
methods to retrieve the elements linked to this AttributeCarrier
GNENet * myNet
pointer to net
bool inGrid() const
check if this AC was inserted in grid
void unmarkForDrawingFront()
unmark for drawing front
virtual std::string getHierarchyName() const =0
get Hierarchy Name (Used in AC Hierarchy)
GNENet * getNet() const
get pointer to net
virtual void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
static const std::string FEATURE_MODIFIED
feature has been manually modified (implies approval)
bool isCommonAttributeValid(SumoXMLAttr key, const std::string &value) const
virtual void updateGeometry()=0
update pre-computed geometry information
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
virtual ~GNEAttributeCarrier()
Destructor.
virtual std::string getAttribute(SumoXMLAttr key) const =0
std::string getCommonAttribute(SumoXMLAttr key) const
bool checkDrawInspectContour() const
check if draw inspect contour (black/white)
virtual GUIGlObject * getGUIGlObject()=0
get GUIGlObject associated with this AttributeCarrier
virtual bool checkDrawOverContour() const =0
check if draw over contour (orange)
virtual bool checkDrawDeleteContour() const =0
check if draw delete contour (pink/white)
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
the function-object for an editing operation (abstract base)
the function-object for an editing operation (abstract base)
An upper class for objects with additional parameters.
std::map< std::string, std::string > Map
parameters map
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.