Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-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// A abstract class for representation of additional elements
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
33
34// ===========================================================================
35// class declarations
36// ===========================================================================
37
38class GNEViewNet;
41
42// ===========================================================================
43// class definitions
44// ===========================================================================
45
51
52public:
67 GNEAdditional(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, std::string additionalName,
68 const std::vector<GNEJunction*>& junctionParents,
69 const std::vector<GNEEdge*>& edgeParents,
70 const std::vector<GNELane*>& laneParents,
71 const std::vector<GNEAdditional*>& additionalParents,
72 const std::vector<GNEDemandElement*>& demandElementParents,
73 const std::vector<GNEGenericData*>& genericDataParents);
74
88 GNEAdditional(GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, std::string additionalName,
89 const std::vector<GNEJunction*>& junctionParents,
90 const std::vector<GNEEdge*>& edgeParents,
91 const std::vector<GNELane*>& laneParents,
92 const std::vector<GNEAdditional*>& additionalParents,
93 const std::vector<GNEDemandElement*>& demandElementParents,
94 const std::vector<GNEGenericData*>& genericDataParents);
95
98
103
105 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
106
109
111 const GUIGlObject* getGUIGlObject() const;
112
114 virtual const std::string getOptionalName() const;
115
117 const GUIGeometry& getAdditionalGeometry() const;
118
120 void setSpecialColor(const RGBColor* color);
121
124
127
131 virtual void writeAdditional(OutputDevice& device) const = 0;
132
134 virtual bool isAdditionalValid() const = 0;
135
137 virtual std::string getAdditionalProblem() const = 0;
138
140 virtual void fixAdditionalProblem() = 0;
141
143
146
151 virtual void openAdditionalDialog();
152
154 virtual void updateGeometry() = 0;
155
157 virtual Position getPositionInView() const = 0;
158
160 double getExaggeration(const GUIVisualizationSettings& s) const;
161
164
166 virtual void updateCenteringBoundary(const bool updateGrid) = 0;
167
169 virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;
170
172
175
177 bool checkDrawFromContour() const;
178
180 bool checkDrawToContour() const;
181
183 bool checkDrawRelatedContour() const;
184
186 bool checkDrawOverContour() const;
187
189 bool checkDrawDeleteContour() const;
190
192 bool checkDrawSelectContour() const;
193
195 virtual bool checkDrawMoveContour() const = 0;
196
198
201
210
219
221 const std::string& getOptionalAdditionalName() const;
222
227 virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
228
230 bool isGLObjectLocked() const;
231
233 void markAsFrontElement();
234
236 void deleteGLObject();
237
239 void selectGLObject();
240
242 void updateGLObject();
243
245
248
250 virtual void computePathElement();
251
253 bool isPathElementSelected() const;
254
260 virtual void drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const;
261
267 virtual void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const;
268
270 GNELane* getFirstPathLane() const;
271
273 GNELane* getLastPathLane() const;
274
276
279
280 /* @brief method for getting the Attribute of an XML key
281 * @param[in] key The attribute key
282 * @return string with the value associated to key
283 */
284 virtual std::string getAttribute(SumoXMLAttr key) const = 0;
285
286 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
287 * @param[in] key The attribute key
288 * @return double with the value associated to key
289 */
290 virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
291
292 /* @brief method for getting the Attribute of an XML key in position format (to avoid unnecessary parse<position>(...) for certain attributes)
293 * @param[in] key The attribute key
294 * @return double with the value associated to key
295 */
296 virtual Position getAttributePosition(SumoXMLAttr key) const;
297
299 virtual const Parameterised::Map& getACParametersMap() const = 0;
300
306 virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
307
313 virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
314
316 virtual std::string getPopUpID() const = 0;
317
319 virtual std::string getHierarchyName() const = 0;
320
322
324 void drawParentChildLines(const GUIVisualizationSettings& s, const RGBColor& color, const bool onlySymbols = false) const;
325
328 const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;
329
332 const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;
333
336 const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;
337
340 const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;
341
343 int getDrawPositionIndex() const;
344
346 static bool areLaneConsecutives(const std::vector<GNELane*>& lanes);
347
349 static bool areLaneConnected(const std::vector<GNELane*>& lanes);
350
351protected:
354
357
360
362 std::string myAdditionalName;
363
365 const RGBColor* mySpecialColor = nullptr;
366
369
371 bool isValidAdditionalID(const std::string& value) const;
372
374 bool isValidAdditionalID(const std::vector<SumoXMLTag>& tags, const std::string& value) const;
375
377 bool isValidDetectorID(const std::string& value) const;
378
380 bool isValidDetectorID(const std::vector<SumoXMLTag>& tags, const std::string& value) const;
381
383 void setAdditionalID(const std::string& newID);
384
386
388 void drawAdditionalID(const GUIVisualizationSettings& s) const;
389
391 void drawAdditionalName(const GUIVisualizationSettings& s) const;
392
394 void replaceAdditionalParentEdges(const std::string& value);
395
397 void replaceAdditionalParentLanes(const std::string& value);
398
400 void replaceAdditionalChildEdges(const std::string& value);
401
403 void replaceAdditionalChildLanes(const std::string& value);
404
406 void replaceAdditionalParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
407
409 void replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
410
412 void shiftLaneIndex();
413
415 void calculatePerpendicularLine(const double endLaneposition);
416
418 void drawSquaredAdditional(const GUIVisualizationSettings& s, const Position& pos, const double size,
419 GUITexture texture, GUITexture selectedTexture) const;
420
422 void drawListedAdditional(const GUIVisualizationSettings& s, const Position& parentPosition, const double offsetX,
423 const double extraOffsetY, const RGBColor baseCol, const RGBColor textCol, GUITexture texture,
424 const std::string text) const;
425
427 bool drawMovingGeometryPoints(const bool ignoreShift) const;
428
431
433 GNEMoveOperation* getMoveOperationSingleLane(const double startPos, const double endPos);
434
436 GNEMoveOperation* getMoveOperationMultiLane(const double startPos, const double endPos);
437
440
442 static std::string getJuPedSimType(SumoXMLTag tag);
443
446
448 static bool getJuPedSimFill(SumoXMLTag tag);
449
451 static double getJuPedSimLayer(SumoXMLTag tag);
452
455
457 static FXIcon* getJuPedSimIcon(SumoXMLTag tag);
458
460
463
466 const double layer, const double exaggeration, const bool filledShape) const;
467
469
470private:
474 virtual bool checkChildAdditionalRestriction() const;
475
477 virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
478
480 virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
481
483 virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
484
487 const Position& pos, const double rot, const RGBColor& baseColor,
488 const double fromAngle, const double toAngle, const bool ignoreShift) const;
489
491 std::string adjustListedAdditionalText(const std::string& text) const;
492
494 GNEAdditional(const GNEAdditional&) = delete;
495
498};
GUIGlObjectType
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
An Element which don't belong to GNENet but has influence in the simulation.
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
static FXIcon * getJuPedSimIcon(SumoXMLTag tag)
get JuPedSim icon
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
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
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)
static GUIGlObjectType getJuPedSimGLO(SumoXMLTag tag)
get GLO color
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