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-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// 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 updateGeometry() = 0;
103
108
111
113 bool isAttributeCarrierSelected() const;
114
116
119
121 bool drawUsingSelectColor() const;
122
124 bool drawMovingGeometryPoints() const;
125
127
130
132 void markForDrawingFront();
133
136
138 bool isMarkedForDrawingFront() const;
139
141 void drawInLayer(const double typeOrLayer, const double extraOffset = 0) const;
142
144
147
149 void setInGrid(bool value);
150
152 bool inGrid() const;
153
155
158
160 bool checkDrawInspectContour() const;
161
163 bool checkDrawFrontContour() const;
164
166 virtual bool checkDrawFromContour() const = 0;
167
169 virtual bool checkDrawToContour() const = 0;
170
172 virtual bool checkDrawRelatedContour() const = 0;
173
175 virtual bool checkDrawOverContour() const = 0;
176
178 virtual bool checkDrawDeleteContour() const = 0;
179
181 virtual bool checkDrawDeleteContourSmall() const = 0;
182
184 virtual bool checkDrawSelectContour() const = 0;
185
187 virtual bool checkDrawMoveContour() const = 0;
188
190
192 void resetDefaultValues(const bool allowUndoRedo);
193
196
197 /* @brief method for getting the Attribute of an XML key
198 * @param[in] key The attribute key
199 * @return string with the value associated to key
200 */
201 virtual std::string getAttribute(SumoXMLAttr key) const = 0;
202
203 /* @brief method for getting the Attribute of an XML key in double format
204 * @param[in] key The attribute key
205 * @return double with the value associated to key
206 */
207 virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
208
209 /* @brief method for getting the Attribute of an XML key in position format
210 * @param[in] key The attribute key
211 * @return position with the value associated to key
212 */
214
215 /* @brief method for getting the Attribute of an XML key in positionVector format
216 * @param[in] key The attribute key
217 * @return positionVector with the value associated to key
218 */
220
221 /* @brief method for setting the attribute and letting the object perform additional changes
222 * @param[in] key The attribute key
223 * @param[in] value The new value
224 * @param[in] undoList The undoList on which to register changes
225 */
226 virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
227
228 /* @brief method for check if new value for certain attribute is valid
229 * @param[in] key The attribute key
230 * @param[in] value The new value
231 */
232 virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
233
234 /* @brief method for enable attribute
235 * @param[in] key The attribute key
236 * @param[in] undoList The undoList on which to register changes
237 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
238 */
239 virtual void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
240
241 /* @brief method for disable attribute
242 * @param[in] key The attribute key
243 * @param[in] undoList The undoList on which to register changes
244 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
245 */
246 virtual void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
247
248 /* @brief method for check if the value for certain attribute is set
249 * @param[in] key The attribute key
250 */
251 virtual bool isAttributeEnabled(SumoXMLAttr key) const;
252
253 /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
254 * @param[in] key The attribute key
255 */
256 virtual bool isAttributeComputed(SumoXMLAttr key) const;
257
258 /* @brief method for check if the value for certain attribute is set
259 * @param[in] key The attribute key
260 */
261 bool hasAttribute(SumoXMLAttr key) const;
262
264 virtual std::string getPopUpID() const = 0;
265
267 virtual std::string getHierarchyName() const = 0;
268
270
273
275 void setACParameters(const std::vector<std::pair<std::string, std::string> >& parameters);
276
278 void setACParameters(const std::vector<std::pair<std::string, std::string> >& parameters, GNEUndoList* undoList);
279
281 void setACParameters(const Parameterised::Map& parameters, GNEUndoList* undoList);
282
284
285 /* @brief method for return an alternative value for disabled attributes. Used only in GNEFrames
286 * @param[in] key The attribute key
287 */
289
291 virtual std::string getAttributeForSelection(SumoXMLAttr key) const;
292
294 const std::string& getTagStr() const;
295
297 FXIcon* getACIcon() const;
298
300 bool isTemplate() const;
301
303 const GNETagProperties* getTagProperty() const;
304
307
309 template<typename T>
310 static bool canParse(const std::string& string);
311
313 template<typename T>
314 static T parse(const std::string& string);
315
319 template<typename T>
320 static bool canParse(const GNENet* net, const std::string& value, const bool checkConsecutivity);
321
323 template<typename T>
324 static T parse(const GNENet* net, const std::string& value);
325
327 template<typename T>
328 static std::string parseIDs(const std::vector<T>& ACs);
329
331
334 /* @brief method for getting the common attribute of an XML key
335 * @param[in] key The attribute key
336 * @return string with the value associated to key
337 */
338 std::string getCommonAttribute(SumoXMLAttr key) const;
339
340 /* @brief method for getting the common attribute of an XML key in double format
341 * @param[in] key The attribute key
342 * @return double with the value associated to key
343 */
344 double getCommonAttributeDouble(SumoXMLAttr key) const;
345
346 /* @brief method for getting the common attribute of an XML key in position format
347 * @param[in] key The attribute key
348 * @return double with the value associated to key
349 */
351
352 /* @brief method for getting the common attribute of an XML key in positionVector format
353 * @param[in] key The attribute key
354 * @return double with the value associated to key
355 */
357
358 /* @brief method for setting the common attribute and letting the object perform additional changes
359 * @param[in] key The attribute key
360 * @param[in] value The new value
361 * @param[in] undoList The undoList on which to register changes
362 */
363 void setCommonAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
364
365 /* @brief method for check if new value for certain common attribute is valid
366 * @param[in] key The attribute key
367 * @param[in] value The new value
368 */
369 bool isCommonAttributeValid(SumoXMLAttr key, const std::string& value) const;
370
372 void setCommonAttribute(SumoXMLAttr key, const std::string& value);
373
375
378
380 static const std::string FEATURE_LOADED;
381
383 static const std::string FEATURE_GUESSED;
384
386 static const std::string FEATURE_MODIFIED;
387
389 static const std::string FEATURE_APPROVED;
390
392
394 static const std::string TRUE_STR;
395
397 static const std::string FALSE_STR;
398
399protected:
402
404 GNENet* myNet = nullptr;
405
407 bool mySelected = false;
408
410 bool myDrawInFront = false;
411
413 bool myInGrid = false;
414
417
420
422 const bool myIsTemplate = false;
423
425 virtual void toggleAttribute(SumoXMLAttr key, const bool value);
426
427private:
429 virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
430
433
436};
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 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 (requieres 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.