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
25
26// ===========================================================================
27// class declarations
28// ===========================================================================
29
31class GNELane;
32class GNEMoveElement;
33class GNENet;
35class GNEUndoList;
36class GUIGlObject;
37class Parameterised;
38
39// ===========================================================================
40// class definitions
41// ===========================================================================
42
44
46 friend class GNEChange_Attribute;
49
50public:
57 GNEAttributeCarrier(const SumoXMLTag tag, GNENet* net, const std::string& filename, const bool isTemplate);
58
60 virtual ~GNEAttributeCarrier();
61
64
67
69 virtual GNEMoveElement* getMoveElement() const = 0;
70
73
75 virtual const Parameterised* getParameters() const = 0;
76
79
81 virtual const GUIGlObject* getGUIGlObject() const = 0;
82
84
86 const std::string getID() const;
87
89 GNENet* getNet() const;
90
92 const std::string& getFilename() const;
93
95 void changeDefaultFilename(const std::string& file);
96
99
102
104 bool isAttributeCarrierSelected() const;
105
107 virtual void updateGeometry() = 0;
108
111
113 bool drawUsingSelectColor() const;
114
116 bool drawMovingGeometryPoints() const;
117
119
122
124 void markForDrawingFront();
125
128
130 bool isMarkedForDrawingFront() const;
131
133 void drawInLayer(const double typeOrLayer, const double extraOffset = 0) const;
134
136
139
141 void setInGrid(bool value);
142
144 bool inGrid() const;
145
147
150
152 bool checkDrawInspectContour() const;
153
155 bool checkDrawFrontContour() const;
156
158 virtual bool checkDrawFromContour() const = 0;
159
161 virtual bool checkDrawToContour() const = 0;
162
164 virtual bool checkDrawRelatedContour() const = 0;
165
167 virtual bool checkDrawOverContour() const = 0;
168
170 virtual bool checkDrawDeleteContour() const = 0;
171
173 virtual bool checkDrawDeleteContourSmall() const = 0;
174
176 virtual bool checkDrawSelectContour() const = 0;
177
179 virtual bool checkDrawMoveContour() const = 0;
180
182
184 void resetDefaultValues(const bool allowUndoRedo);
185
188
189 /* @brief method for getting the Attribute of an XML key
190 * @param[in] key The attribute key
191 * @return string with the value associated to key
192 */
193 virtual std::string getAttribute(SumoXMLAttr key) const = 0;
194
195 /* @brief method for getting the Attribute of an XML key in double format
196 * @param[in] key The attribute key
197 * @return double with the value associated to key
198 */
199 virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
200
201 /* @brief method for getting the Attribute of an XML key in position format
202 * @param[in] key The attribute key
203 * @return position with the value associated to key
204 */
206
207 /* @brief method for getting the Attribute of an XML key in positionVector format
208 * @param[in] key The attribute key
209 * @return positionVector with the value associated to key
210 */
212
213 /* @brief method for setting the attribute and letting the object perform additional changes
214 * @param[in] key The attribute key
215 * @param[in] value The new value
216 * @param[in] undoList The undoList on which to register changes
217 */
218 virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
219
220 /* @brief method for check if new value for certain attribute is valid
221 * @param[in] key The attribute key
222 * @param[in] value The new value
223 */
224 virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
225
226 /* @brief method for enable attribute
227 * @param[in] key The attribute key
228 * @param[in] undoList The undoList on which to register changes
229 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
230 */
231 virtual void enableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
232
233 /* @brief method for disable attribute
234 * @param[in] key The attribute key
235 * @param[in] undoList The undoList on which to register changes
236 * @note certain attributes can be only enabled, and can produce the disabling of other attributes
237 */
238 virtual void disableAttribute(SumoXMLAttr key, GNEUndoList* undoList);
239
240 /* @brief method for check if the value for certain attribute is set
241 * @param[in] key The attribute key
242 */
243 virtual bool isAttributeEnabled(SumoXMLAttr key) const;
244
245 /* @brief method for check if the value for certain attribute is computed (for example, due a network recomputing)
246 * @param[in] key The attribute key
247 */
248 virtual bool isAttributeComputed(SumoXMLAttr key) const;
249
250 /* @brief method for check if the value for certain attribute is set
251 * @param[in] key The attribute key
252 */
253 bool hasAttribute(SumoXMLAttr key) const;
254
256 virtual std::string getPopUpID() const = 0;
257
259 virtual std::string getHierarchyName() const = 0;
260
262
265
267 void setACParameters(const std::vector<std::pair<std::string, std::string> >& parameters);
268
270 void setACParameters(const std::vector<std::pair<std::string, std::string> >& parameters, GNEUndoList* undoList);
271
273 void setACParameters(const Parameterised::Map& parameters, GNEUndoList* undoList);
274
276
277 /* @brief method for return an alternative value for disabled attributes. Used only in GNEFrames
278 * @param[in] key The attribute key
279 */
281
283 virtual std::string getAttributeForSelection(SumoXMLAttr key) const;
284
286 const std::string& getTagStr() const;
287
289 FXIcon* getACIcon() const;
290
292 bool isTemplate() const;
293
295 const GNETagProperties* getTagProperty() const;
296
299
301 template<typename T>
302 static bool canParse(const std::string& string);
303
305 template<typename T>
306 static T parse(const std::string& string);
307
311 template<typename T>
312 static bool canParse(const GNENet* net, const std::string& value, const bool checkConsecutivity);
313
315 template<typename T>
316 static T parse(const GNENet* net, const std::string& value);
317
319 template<typename T>
320 static std::string parseIDs(const std::vector<T>& ACs);
321
323
326 /* @brief method for getting the common attribute of an XML key
327 * @param[in] key The attribute key
328 * @return string with the value associated to key
329 */
330 std::string getCommonAttribute(SumoXMLAttr key) const;
331
332 /* @brief method for getting the common attribute of an XML key in double format
333 * @param[in] key The attribute key
334 * @return double with the value associated to key
335 */
336 double getCommonAttributeDouble(SumoXMLAttr key) const;
337
338 /* @brief method for getting the common attribute of an XML key in position format
339 * @param[in] key The attribute key
340 * @return double with the value associated to key
341 */
343
344 /* @brief method for getting the common attribute of an XML key in positionVector format
345 * @param[in] key The attribute key
346 * @return double with the value associated to key
347 */
349
350 /* @brief method for setting the common attribute and letting the object perform additional changes
351 * @param[in] key The attribute key
352 * @param[in] value The new value
353 * @param[in] undoList The undoList on which to register changes
354 */
355 void setCommonAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
356
357 /* @brief method for check if new value for certain common attribute is valid
358 * @param[in] key The attribute key
359 * @param[in] value The new value
360 */
361 bool isCommonAttributeValid(SumoXMLAttr key, const std::string& value) const;
362
364 void setCommonAttribute(SumoXMLAttr key, const std::string& value);
365
367
370
372 static const std::string FEATURE_LOADED;
373
375 static const std::string FEATURE_GUESSED;
376
378 static const std::string FEATURE_MODIFIED;
379
381 static const std::string FEATURE_APPROVED;
382
384
386 static const std::string TRUE_STR;
387
389 static const std::string FALSE_STR;
390
391protected:
394
396 GNENet* myNet = nullptr;
397
399 bool mySelected = false;
400
402 bool myDrawInFront = false;
403
405 bool myInGrid = false;
406
408 std::string myFilename;
409
412
414 const bool myIsTemplate = false;
415
417 virtual void toggleAttribute(SumoXMLAttr key, const bool value);
418
419private:
421 virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
422
425
428};
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
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)
void markForDrawingFront()
mark for drawing front
virtual bool checkDrawDeleteContourSmall() const =0
check if draw delete contour small (pink/white)
GNEAttributeCarrier & operator=(const GNEAttributeCarrier &src)=delete
Invalidated assignment operator.
double getCommonAttributeDouble(SumoXMLAttr key) const
virtual void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
void selectAttributeCarrier()
select attribute carrier using GUIGlobalSelection
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
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 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
std::string myFilename
filename in which save this AC
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
const std::string & getFilename() const
get filename in which save this AC
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
void changeDefaultFilename(const std::string &file)
change defaultFilename (only used in SavingFilesHandler)
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)
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
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.