Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNEAdditional.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// A abstract class for representation of additional elements
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
30
31// ===========================================================================
32// class declarations
33// ===========================================================================
34
37
38// ===========================================================================
39// class definitions
40// ===========================================================================
41
43
44public:
52 GNEAdditional(const std::string& id, GNENet* net, const std::string& filename,
53 SumoXMLTag tag, const std::string& additionalName);
54
60 GNEAdditional(GNEAdditional* additionalParent, SumoXMLTag tag, const std::string& additionalName);
61
64
67
72
74 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
75
78
80 const GUIGlObject* getGUIGlObject() const;
81
83 virtual const std::string getOptionalName() const;
84
87
89 void setSpecialColor(const RGBColor* color);
90
93
96
100 virtual void writeAdditional(OutputDevice& device) const = 0;
101
103 virtual bool isAdditionalValid() const = 0;
104
106 virtual std::string getAdditionalProblem() const = 0;
107
109 virtual void fixAdditionalProblem() = 0;
110
112
115
120 virtual void openAdditionalDialog();
121
123 virtual void updateGeometry() = 0;
124
126 virtual Position getPositionInView() const = 0;
127
129 double getExaggeration(const GUIVisualizationSettings& s) const;
130
133
135 virtual void updateCenteringBoundary(const bool updateGrid) = 0;
136
138 virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;
139
141
144
146 bool checkDrawFromContour() const;
147
149 bool checkDrawToContour() const;
150
152 bool checkDrawRelatedContour() const;
153
155 bool checkDrawOverContour() const;
156
158 bool checkDrawDeleteContour() const;
159
161 bool checkDrawDeleteContourSmall() const;
162
164 bool checkDrawSelectContour() const;
165
167 virtual bool checkDrawMoveContour() const = 0;
168
170
173
182
191
193 const std::string& getOptionalAdditionalName() const;
194
199 virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
200
202 bool isGLObjectLocked() const;
203
205 void markAsFrontElement();
206
208 void deleteGLObject();
209
211 void selectGLObject();
212
214 void updateGLObject();
215
217
220
222 virtual void computePathElement();
223
225 bool isPathElementSelected() const;
226
232 virtual void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const;
233
239 virtual void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const;
240
242 GNELane* getFirstPathLane() const;
243
245 GNELane* getLastPathLane() const;
246
248
251
252 /* @brief method for getting the Attribute of an XML key
253 * @param[in] key The attribute key
254 * @return string with the value associated to key
255 */
256 virtual std::string getAttribute(SumoXMLAttr key) const = 0;
257
258 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
259 * @param[in] key The attribute key
260 * @return double with the value associated to key
261 */
262 virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
263
264 /* @brief method for getting the Attribute of an XML key in position format (to avoid unnecessary parse<position>(...) for certain attributes)
265 * @param[in] key The attribute key
266 * @return double with the value associated to key
267 */
268 virtual Position getAttributePosition(SumoXMLAttr key) const;
269
271 virtual const Parameterised::Map& getACParametersMap() const = 0;
272
278 virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
279
285 virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
286
288 virtual std::string getPopUpID() const = 0;
289
291 virtual std::string getHierarchyName() const = 0;
292
294
296 void drawParentChildLines(const GUIVisualizationSettings& s, const RGBColor& color, const bool onlySymbols = false) const;
297
300 const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;
301
304 const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;
305
308 const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;
309
312 const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;
313
315 int getDrawPositionIndex() const;
316
318 static bool areLaneConsecutives(const std::vector<GNELane*>& lanes);
319
321 static bool areLaneConnected(const std::vector<GNELane*>& lanes);
322
323protected:
326
329
332
334 std::string myAdditionalName;
335
337 const RGBColor* mySpecialColor = nullptr;
338
341
343 bool isValidAdditionalID(const std::string& value) const;
344
346 bool isValidAdditionalID(const std::vector<SumoXMLTag>& tags, const std::string& value) const;
347
349 bool isValidDetectorID(const std::string& value) const;
350
352 bool isValidDetectorID(const std::vector<SumoXMLTag>& tags, const std::string& value) const;
353
355 void setAdditionalID(const std::string& newID);
356
358
360 void drawAdditionalID(const GUIVisualizationSettings& s) const;
361
363 void drawAdditionalName(const GUIVisualizationSettings& s) const;
364
366 void replaceAdditionalParentEdges(const std::string& value);
367
369 void replaceAdditionalParentLanes(const std::string& value);
370
372 void replaceAdditionalChildEdges(const std::string& value);
373
375 void replaceAdditionalChildLanes(const std::string& value);
376
378 void replaceAdditionalParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
379
381 void replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
382
384 void shiftLaneIndex();
385
387 void calculatePerpendicularLine(const double endLaneposition);
388
390 void drawSquaredAdditional(const GUIVisualizationSettings& s, const Position& pos, const double size,
391 GUITexture texture, GUITexture selectedTexture) const;
392
394 void drawListedAdditional(const GUIVisualizationSettings& s, const Position& parentPosition, const double offsetX,
395 const double extraOffsetY, const RGBColor baseCol, const RGBColor textCol, GUITexture texture,
396 const std::string text) const;
397
399 bool drawMovingGeometryPoints(const bool ignoreShift) const;
400
403
405 GNEMoveOperation* getMoveOperationSingleLane(const double startPos, const double endPos);
406
408 GNEMoveOperation* getMoveOperationMultiLane(const double startPos, const double endPos);
409
412
414 static std::string getJuPedSimType(SumoXMLTag tag);
415
418
420 static bool getJuPedSimFill(SumoXMLTag tag);
421
423 static double getJuPedSimLayer(SumoXMLTag tag);
424
426
429
432 const double layer, const double exaggeration, const bool filledShape) const;
433
435
436private:
440 virtual bool checkChildAdditionalRestriction() const;
441
443 virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
444
446 virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
447
449 virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
450
453 const Position& pos, const double rot, const RGBColor& baseColor,
454 const double fromAngle, const double toAngle, const bool ignoreShift) const;
455
457 std::string adjustListedAdditionalText(const std::string& text) const;
458
460 GNEAdditional(const GNEAdditional&) = delete;
461
464};
GUITexture
An enumeration of gifs used by the gui applications.
Definition GUITextures.h:31
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
virtual void updateCenteringBoundary(const bool updateGrid)=0
update centering boundary (implies change in RTREE)
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
virtual const std::string getOptionalName() const
Returns the name of the object (default "")
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
virtual void setMoveShape(const GNEMoveResult &moveResult)=0
set move shape
virtual std::string getAttribute(SumoXMLAttr key) const =0
GNELane * getLastPathLane() const
get last path lane
bool isValidAdditionalID(const std::string &value) const
check if a new additional ID is valid
virtual void updateGeometry()=0
update pre-computed geometry information
GNEAdditional & operator=(const GNEAdditional &)=delete
Invalidated assignment operator.
virtual void writeAdditional(OutputDevice &device) const =0
write additional element into a xml file
void deleteGLObject()
delete element
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
void replaceAdditionalParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace additional parent
static bool areLaneConnected(const std::vector< GNELane * > &lanes)
check if the given lanes are connected
void drawRightGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw right geometry point
virtual bool isAdditionalValid() const =0
check if current additional is valid to be written into XML (by default true, can be reimplemented in...
virtual std::string getAdditionalProblem() const =0
return a string with the current additional problem (by default empty, can be reimplemented in childr...
std::string adjustListedAdditionalText(const std::string &text) const
adjust listed additional text
virtual void openAdditionalDialog()
open Additional Dialog
static std::string getJuPedSimType(SumoXMLTag tag)
get JuPedSim type
bool checkDrawSelectContour() const
check if draw select contour (blue)
void replaceAdditionalChildLanes(const std::string &value)
replace additional child lanes
void drawListedAdditional(const GUIVisualizationSettings &s, const Position &parentPosition, const double offsetX, const double extraOffsetY, const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const
draw listed additional
void setAdditionalID(const std::string &newID)
set additional ID
GNEContour myAdditionalContour
variable used for draw additional contours
bool isPathElementSelected() const
check if path element is selected
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
bool checkDrawFromContour() const
check if draw from contour (green)
virtual const Parameterised::Map & getACParametersMap() const =0
get parameters map
void replaceAdditionalParentEdges(const std::string &value)
replace additional parent edges
virtual std::string getPopUpID() const =0
get PopPup ID (Used in AC Hierarchy)
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
GNELane * getFirstPathLane() const
get first path lane
bool isValidDetectorID(const std::string &value) const
check if a new detector ID is valid
void drawUpGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw up geometry point
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
bool checkDrawDeleteContourSmall() const
check if draw delete contour small (pink/white)
void shiftLaneIndex()
shift lane index
virtual Position getAttributePosition(SumoXMLAttr key) const
virtual bool checkDrawMoveContour() const =0
check if draw move contour (red)
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void calculatePerpendicularLine(const double endLaneposition)
calculate perpendicular line between lane parents
GNEMoveOperation * getMoveOperationMultiLane(const double startPos, const double endPos)
get moveOperation for an element over multi lane
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
GNEAdditional(const GNEAdditional &)=delete
Invalidated copy constructor.
std::string myAdditionalName
name of additional
void selectGLObject()
select element
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
void resetAdditionalContour()
reset additional contour
void drawDemandElementChildren(const GUIVisualizationSettings &s) const
draw demand element children
static double getJuPedSimLayer(SumoXMLTag tag)
get JuPedSim color
void updateGLObject()
update GLObject (geometry, ID, etc.)
void setSpecialColor(const RGBColor *color)
set special color
const RGBColor * mySpecialColor
pointer to special color (used for drawing Additional with a certain color, mainly used for selection...
virtual void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)=0
commit move shape
virtual GNEMoveOperation * getMoveOperation()=0
get move operation
virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)=0
split geometry
bool checkDrawToContour() const
check if draw from contour (magenta)
virtual void setAttribute(SumoXMLAttr key, const std::string &value)=0
method for setting the attribute and nothing else (used in GNEChange_Attribute)
virtual std::string getHierarchyName() const =0
get Hierarchy Name (Used in AC Hierarchy)
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes
void drawSquaredAdditional(const GUIVisualizationSettings &s, const Position &pos, const double size, GUITexture texture, GUITexture selectedTexture) const
draw squared additional
bool drawMovingGeometryPoints(const bool ignoreShift) const
check if draw additional extrem geometry points
virtual bool checkChildAdditionalRestriction() const
check restriction with the number of children
GNEHierarchicalElement * getHierarchicalElement()
get GNEHierarchicalElement associated with this AttributeCarrier
void drawSemiCircleGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const double fromAngle, const double toAngle, const bool ignoreShift) const
draw geometry point
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
virtual void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
bool isGLObjectLocked() const
check if element is locked
void replaceAdditionalChildEdges(const std::string &value)
replace additional child edges
virtual double getAttributeDouble(SumoXMLAttr key) const =0
virtual void computePathElement()
compute pathElement
void calculateContourPolygons(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double layer, const double exaggeration, const bool filledShape) const
calculate contour for polygons
void drawDownGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw down geometry point
static RGBColor getJuPedSimColor(SumoXMLTag tag)
get JuPedSim color
int getDrawPositionIndex() const
get draw position index (used in rerouters and VSS)
const GUIGeometry & getAdditionalGeometry() const
obtain additional geometry
Boundary myAdditionalBoundary
Additional Boundary (used only by additionals placed over grid)
void drawLeftGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw left geometry point
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
static bool getJuPedSimFill(SumoXMLTag tag)
get JuPedSim fill
~GNEAdditional()
Destructor.
const std::string & getOptionalAdditionalName() const
Returns the additional name.
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their correspondent attribute are valids
GNEMoveOperation * getMoveOperationSingleLane(const double startPos, const double endPos)
get moveOperation for an element over single lane
virtual Position getPositionInView() const =0
Returns position of additional in view.
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position (Currently unused in shapes)
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
virtual void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
virtual void fixAdditionalProblem()=0
fix additional problem (by default throw an exception, has to be reimplemented in children)
void drawParentChildLines(const GUIVisualizationSettings &s, const RGBColor &color, const bool onlySymbols=false) const
draw parent and child lines
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void markAsFrontElement()
mark element as front element
bool checkDrawOverContour() const
check if draw over contour (orange)
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
move element
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
The popup menu of a globject.
A window containing a gl-object's parameter.
Stores the information about how to visualize structures.
Static storage of an output device and its base (abstract) implementation.
std::map< std::string, std::string > Map
parameters map
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37