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-2023 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
31
32// ===========================================================================
33// class declarations
34// ===========================================================================
35
36class GNEViewNet;
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
43
49
50public:
65 GNEAdditional(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, std::string additionalName,
66 const std::vector<GNEJunction*>& junctionParents,
67 const std::vector<GNEEdge*>& edgeParents,
68 const std::vector<GNELane*>& laneParents,
69 const std::vector<GNEAdditional*>& additionalParents,
70 const std::vector<GNEDemandElement*>& demandElementParents,
71 const std::vector<GNEGenericData*>& genericDataParents);
72
86 GNEAdditional(GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, std::string additionalName,
87 const std::vector<GNEJunction*>& junctionParents,
88 const std::vector<GNEEdge*>& edgeParents,
89 const std::vector<GNELane*>& laneParents,
90 const std::vector<GNEAdditional*>& additionalParents,
91 const std::vector<GNEDemandElement*>& demandElementParents,
92 const std::vector<GNEGenericData*>& genericDataParents);
93
96
101
103 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
104
107
109 virtual const std::string getOptionalName() const;
110
112 const GUIGeometry& getAdditionalGeometry() const;
113
115 void setSpecialColor(const RGBColor* color);
116
119
123 virtual void writeAdditional(OutputDevice& device) const = 0;
124
126 virtual bool isAdditionalValid() const = 0;
127
129 virtual std::string getAdditionalProblem() const = 0;
130
132 virtual void fixAdditionalProblem() = 0;
133
135
138
143 virtual void openAdditionalDialog();
144
146 virtual void updateGeometry() = 0;
147
149 virtual Position getPositionInView() const = 0;
150
152 double getExaggeration(const GUIVisualizationSettings& s) const;
153
156
158 virtual void updateCenteringBoundary(const bool updateGrid) = 0;
159
161 virtual void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) = 0;
162
164
167
176
185
187 const std::string& getOptionalAdditionalName() const;
188
193 virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
194
196 bool isGLObjectLocked();
197
199 void markAsFrontElement();
200
202 void deleteGLObject();
203
205 void selectGLObject();
206
208 void updateGLObject();
209
211
214
216 virtual void computePathElement();
217
219 bool isPathElementSelected() const;
220
226 virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const;
227
234 virtual void drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* segment, const double offsetFront) const;
235
237 GNELane* getFirstPathLane() const;
238
240 GNELane* getLastPathLane() const;
241
243 double getPathElementDepartValue() const;
244
247
249 double getPathElementArrivalValue() const;
250
253
255
258
259 /* @brief method for getting the Attribute of an XML key
260 * @param[in] key The attribute key
261 * @return string with the value associated to key
262 */
263 virtual std::string getAttribute(SumoXMLAttr key) const = 0;
264
265 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
266 * @param[in] key The attribute key
267 * @return double with the value associated to key
268 */
269 virtual double getAttributeDouble(SumoXMLAttr key) const = 0;
270
271 /* @brief method for getting the Attribute of an XML key in position format (to avoid unnecessary parse<position>(...) for certain attributes)
272 * @param[in] key The attribute key
273 * @return double with the value associated to key
274 */
275 virtual Position getAttributePosition(SumoXMLAttr key) const;
276
278 virtual const Parameterised::Map& getACParametersMap() const = 0;
279
285 virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
286
292 virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
293
295 virtual std::string getPopUpID() const = 0;
296
298 virtual std::string getHierarchyName() const = 0;
299
301
303 void drawParentChildLines(const GUIVisualizationSettings& s, const RGBColor& color, const bool onlySymbols = false) const;
304
306 static void drawUpGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor, const bool ignoreShift = false);
307
309 static void drawDownGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor, const bool ignoreShift = false);
310
312 static void drawLeftGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor, const bool ignoreShift = false);
313
315 static void drawRightGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor, const bool ignoreShift = false);
316
318 int getDrawPositionIndex() const;
319
321 static bool areLaneConsecutives(const std::vector<GNELane*>& lanes);
322
324 static bool areLaneConnected(const std::vector<GNELane*>& lanes);
325
326protected:
329
332
334 std::string myAdditionalName;
335
337 const RGBColor* mySpecialColor = nullptr;
338
341
343 bool isValidAdditionalID(const std::string& newID) const;
344
346 bool isValidDetectorID(const std::string& newID) const;
347
349
351 void drawAdditionalID(const GUIVisualizationSettings& s) const;
352
354 void drawAdditionalName(const GUIVisualizationSettings& s) const;
355
357 void replaceAdditionalParentEdges(const std::string& value);
358
360 void replaceAdditionalParentLanes(const std::string& value);
361
363 void replaceAdditionalChildEdges(const std::string& value);
364
366 void replaceAdditionalChildLanes(const std::string& value);
367
369 void replaceAdditionalParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
370
372 void replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex);
373
375 void shiftLaneIndex();
376
378 void calculatePerpendicularLine(const double endLaneposition);
379
381 void drawSquaredAdditional(const GUIVisualizationSettings& s, const Position& pos, const double size, GUITexture texture, GUITexture selectedTexture) const;
382
384 void drawListedAddtional(const GUIVisualizationSettings& s, const Position& parentPosition, const double offsetX, const double extraOffsetY,
385 const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const;
386
387
389 GNEMoveOperation* getMoveOperationSingleLane(const double startPos, const double endPos);
390
392 GNEMoveOperation* getMoveOperationMultiLane(const double startPos, const double endPos);
393
394private:
398 virtual bool checkChildAdditionalRestriction() const;
399
401 virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
402
404 virtual void setMoveShape(const GNEMoveResult& moveResult) = 0;
405
407 virtual void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) = 0;
408
410 static void drawSemiCircleGeometryPoint(const GNEViewNet* viewNet, const Position& pos, const double rot, const RGBColor& baseColor,
411 const double fromAngle, const double toAngle, const bool ignoreShift);
412
414 std::string adjustListedAdditionalText(const std::string& text) const;
415
417 GNEAdditional(const GNEAdditional&) = delete;
418
421};
422
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)
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
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
double getPathElementArrivalValue() const
get path element arrival lane pos
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
virtual bool isAdditionalValid() const =0
check if current additional is valid to be written into XML (by default true, can be reimplemented in...
static void drawRightGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false)
draw right geometry point
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
void replaceAdditionalChildLanes(const std::string &value)
replace additional child lanes
bool isPathElementSelected() const
check if path element is selected
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
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
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
void shiftLaneIndex()
shift lane index
virtual Position getAttributePosition(SumoXMLAttr key) const
double getPathElementDepartValue() const
get path element depart lane pos
static void drawSemiCircleGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor, const double fromAngle, const double toAngle, const bool ignoreShift)
draw geometry point
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 drawListedAddtional(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 selectGLObject()
select element
static void drawUpGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false)
draw up geometry point
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
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
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
static void drawDownGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false)
draw down geometry point
void drawSquaredAdditional(const GUIVisualizationSettings &s, const Position &pos, const double size, GUITexture texture, GUITexture selectedTexture) const
draw squared additional
virtual bool checkChildAdditionalRestriction() const
check restriction with the number of children
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
void replaceAdditionalChildEdges(const std::string &value)
replace additional child edges
bool isGLObjectLocked()
check if element is locked
virtual double getAttributeDouble(SumoXMLAttr key) const =0
virtual void computePathElement()
compute pathElement
Position getPathElementDepartPos() const
get path element depart position
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
int getDrawPositionIndex() const
get draw position index (used in rerouters and VSS)
const GUIGeometry & getAdditionalGeometry() const
obtain additional geometry
Boundary myAdditionalBoundary
Additional Boundary.
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
~GNEAdditional()
Destructor.
const std::string & getOptionalAdditionalName() const
Returns the additional name.
virtual void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object (lane)
Position getPathElementArrivalPos() const
get path element arrival position
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)
static void drawLeftGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false)
draw left geometry point
bool isValidAdditionalID(const std::string &newID) const
check if a new additional ID is valid
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
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