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
32
33// ===========================================================================
34// class declarations
35// ===========================================================================
36
37class GNEViewNet;
40
41// ===========================================================================
42// class definitions
43// ===========================================================================
44
50
51public:
66 GNEAdditional(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, std::string additionalName,
67 const std::vector<GNEJunction*>& junctionParents,
68 const std::vector<GNEEdge*>& edgeParents,
69 const std::vector<GNELane*>& laneParents,
70 const std::vector<GNEAdditional*>& additionalParents,
71 const std::vector<GNEDemandElement*>& demandElementParents,
72 const std::vector<GNEGenericData*>& genericDataParents);
73
87 GNEAdditional(GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, std::string additionalName,
88 const std::vector<GNEJunction*>& junctionParents,
89 const std::vector<GNEEdge*>& edgeParents,
90 const std::vector<GNELane*>& laneParents,
91 const std::vector<GNEAdditional*>& additionalParents,
92 const std::vector<GNEDemandElement*>& demandElementParents,
93 const std::vector<GNEGenericData*>& genericDataParents);
94
97
102
104 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
105
108
110 const GUIGlObject* getGUIGlObject() const;
111
113 virtual const std::string getOptionalName() const;
114
116 const GUIGeometry& getAdditionalGeometry() const;
117
119 void setSpecialColor(const RGBColor* color);
120
123
126
130 virtual void writeAdditional(OutputDevice& device) const = 0;
131
133 virtual bool isAdditionalValid() const = 0;
134
136 virtual std::string getAdditionalProblem() const = 0;
137
139 virtual void fixAdditionalProblem() = 0;
140
142
145
150 virtual void openAdditionalDialog();
151
153 virtual void updateGeometry() = 0;
154
156 virtual Position getPositionInView() const = 0;
157
159 double getExaggeration(const GUIVisualizationSettings& s) const;
160
163
165 virtual void updateCenteringBoundary(const bool updateGrid) = 0;
166
168 virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;
169
171
174
176 bool checkDrawFromContour() const;
177
179 bool checkDrawToContour() const;
180
182 bool checkDrawRelatedContour() const;
183
185 bool checkDrawOverContour() const;
186
188 bool checkDrawDeleteContour() const;
189
191 bool checkDrawSelectContour() const;
192
194 virtual bool checkDrawMoveContour() const = 0;
195
197
200
209
218
220 const std::string& getOptionalAdditionalName() const;
221
226 virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
227
229 bool isGLObjectLocked() const;
230
232 void markAsFrontElement();
233
235 void deleteGLObject();
236
238 void selectGLObject();
239
241 void updateGLObject();
242
244
247
249 virtual void computePathElement();
250
252 bool isPathElementSelected() const;
253
259 virtual void drawLanePartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const;
260
266 virtual void drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const;
267
269 GNELane* getFirstPathLane() const;
270
272 GNELane* getLastPathLane() const;
273
275
278
279 /* @brief method for getting the Attribute of an XML key
280 * @param[in] key The attribute key
281 * @return string with the value associated to key
282 */
283 virtual std::string getAttribute(SumoXMLAttr key) const = 0;
284
285 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
286 * @param[in] key The attribute key
287 * @return double with the value associated to key
288 */
289 virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
290
291 /* @brief method for getting the Attribute of an XML key in position format (to avoid unnecessary parse<position>(...) for certain attributes)
292 * @param[in] key The attribute key
293 * @return double with the value associated to key
294 */
295 virtual Position getAttributePosition(SumoXMLAttr key) const;
296
298 virtual const Parameterised::Map& getACParametersMap() const = 0;
299
305 virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
306
312 virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
313
315 virtual std::string getPopUpID() const = 0;
316
318 virtual std::string getHierarchyName() const = 0;
319
321
323 void drawParentChildLines(const GUIVisualizationSettings& s, const RGBColor& color, const bool onlySymbols = false) const;
324
327 const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;
328
331 const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;
332
335 const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;
336
339 const double rot, const RGBColor& baseColor, const bool ignoreShift = false) const;
340
342 int getDrawPositionIndex() const;
343
345 static bool areLaneConsecutives(const std::vector<GNELane*>& lanes);
346
348 static bool areLaneConnected(const std::vector<GNELane*>& lanes);
349
350protected:
353
356
359
361 std::string myAdditionalName;
362
364 const RGBColor* mySpecialColor = nullptr;
365
368
370 bool isValidAdditionalID(const std::string& value) const;
371
373 bool isValidAdditionalID(const std::vector<SumoXMLTag>& tags, const std::string& value) const;
374
376 bool isValidDetectorID(const std::string& value) const;
377
379 bool isValidDetectorID(const std::vector<SumoXMLTag>& tags, const std::string& value) const;
380
382 void setAdditionalID(const std::string& newID);
383
385
387 void drawAdditionalID(const GUIVisualizationSettings& s) const;
388
390 void drawAdditionalName(const GUIVisualizationSettings& s) const;
391
393 void replaceAdditionalParentEdges(const std::string& value);
394
396 void replaceAdditionalParentLanes(const std::string& value);
397
399 void replaceAdditionalChildEdges(const std::string& value);
400
402 void replaceAdditionalChildLanes(const std::string& value);
403
405 void replaceAdditionalParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
406
408 void replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
409
411 void shiftLaneIndex();
412
414 void calculatePerpendicularLine(const double endLaneposition);
415
417 void drawSquaredAdditional(const GUIVisualizationSettings& s, const Position& pos, const double size,
418 GUITexture texture, GUITexture selectedTexture) const;
419
421 void drawListedAdditional(const GUIVisualizationSettings& s, const Position& parentPosition, const double offsetX,
422 const double extraOffsetY, const RGBColor baseCol, const RGBColor textCol, GUITexture texture,
423 const std::string text) const;
424
426 bool drawMovingGeometryPoints(const bool ignoreShift) const;
427
430
432 GNEMoveOperation* getMoveOperationSingleLane(const double startPos, const double endPos);
433
435 GNEMoveOperation* getMoveOperationMultiLane(const double startPos, const double endPos);
436
439
441 static std::string getJuPedSimType(SumoXMLTag tag);
442
445
447 static bool getJuPedSimFill(SumoXMLTag tag);
448
450 static double getJuPedSimLayer(SumoXMLTag tag);
451
454
456 static FXIcon* getJuPedSimIcon(SumoXMLTag tag);
457
459
462
465 const double layer, const double exaggeration, const bool filledShape) const;
466
468
469private:
473 virtual bool checkChildAdditionalRestriction() const;
474
476 virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
477
479 virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
480
482 virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
483
486 const Position& pos, const double rot, const RGBColor& baseColor,
487 const double fromAngle, const double toAngle, const bool ignoreShift) const;
488
490 std::string adjustListedAdditionalText(const std::string& text) const;
491
493 GNEAdditional(const GNEAdditional&) = delete;
494
497};
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
virtual void drawLanePartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over lane.
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
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
virtual void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over junction.
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 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
class used for path elements
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