Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEPoly.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 class for visualizing and editing POIS in netedit (adapted from
19// GUIPolygon and NLHandler)
20/****************************************************************************/
21#pragma once
22#include <config.h>
23
26
27#include "GNEAdditional.h"
28
29// ===========================================================================
30// class declarations
31// ===========================================================================
32
33class GeoConvHelper;
36
37// ===========================================================================
38// class definitions
39// ===========================================================================
40
41class GNEPoly : public TesselatedPolygon, public GNEAdditional {
42
43public:
46
48 GNEPoly(SumoXMLTag tag, GNENet* net);
49
66 GNEPoly(const std::string& id, GNENet* net, const std::string& filename, const std::string& type, const PositionVector& shape,
67 bool geo, bool fill, double lineWidth, const RGBColor& color, double layer, double angle, const std::string& imgFile,
68 const std::string& name, const Parameterised::Map& parameters);
69
79 GNEPoly(SumoXMLTag tag, const std::string& id, GNENet* net, const std::string& filename, const PositionVector& shape,
80 bool geo, const std::string& name, const Parameterised::Map& parameters);
81
83 ~GNEPoly();
84
87
89 GNEMoveElement* getMoveElement() const override;
90
92 Parameterised* getParameters() override;
93
95 const Parameterised* getParameters() const override;
96
98
100 std::string generateChildID(SumoXMLTag childTag);
101
105 void updateGeometry() override;
106
108 Position getPositionInView() const override;
109
111 double getExaggeration(const GUIVisualizationSettings& s) const override;
112
114 void updateCenteringBoundary(const bool updateGrid) override;
115
117 void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement,
118 const GNENetworkElement* newElement, GNEUndoList* undoList) override;
119
123 void writeAdditional(OutputDevice& device) const override;
124
126 bool isAdditionalValid() const override;
127
129 std::string getAdditionalProblem() const override;
130
132 void fixAdditionalProblem() override;
133
135 GUIGlID getGlID() const;
136
138
141
143 bool checkDrawMoveContour() const override;
144
146
149
152 std::string getParentName() const override;
153
162
167 void drawGL(const GUIVisualizationSettings& s) const override;
168
170
173 /* @brief method for getting the Attribute of an XML key
174 * @param[in] key The attribute key
175 * @return string with the value associated to key
176 */
177 std::string getAttribute(SumoXMLAttr key) const override;
178
179 /* @brief method for getting the Attribute of an XML key in double format
180 * @param[in] key The attribute key
181 * @return double with the value associated to key
182 */
183 double getAttributeDouble(SumoXMLAttr key) const override;
184
185 /* @brief method for getting the Attribute of an XML key in position format
186 * @param[in] key The attribute key
187 * @return position with the value associated to key
188 */
189 Position getAttributePosition(SumoXMLAttr key) const override;
190
191 /* @brief method for getting the Attribute of an XML key in positionVector format
192 * @param[in] key The attribute key
193 * @return positionVector with the value associated to key
194 */
196
202 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
203
209 bool isValid(SumoXMLAttr key, const std::string& value) override;
210
211 /* @brief method for check if the value for certain attribute is set
212 * @param[in] key The attribute key
213 */
214 bool isAttributeEnabled(SumoXMLAttr key) const override;
216
218 std::string getPopUpID() const override;
219
221 std::string getHierarchyName() const override;
222
228 int getVertexIndex(Position pos, bool snapToGrid);
229
231 void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
232
234 bool isPolygonClosed() const;
235
237 void openPolygon(bool allowUndo = true);
238
240 void closePolygon(bool allowUndo = true);
241
243 void changeFirstGeometryPoint(int oldIndex, bool allowUndo = true);
244
246 void simplifyShape(bool allowUndo = true);
247
250
251protected:
254
257
259 bool myClosedShape = false;
260
262 bool mySimplifiedShape = false;
263
264private:
266 void setAttribute(SumoXMLAttr key, const std::string& value) override;
267
270 const RGBColor& color, const double exaggeration) const;
271
274 const RGBColor& color, const double exaggeration) const;
275
278 const RGBColor& color, const double exaggeration) const;
279
282
284 GNEPoly(const GNEPoly&) = delete;
285
287 GNEPoly& operator=(const GNEPoly&) = delete;
288};
unsigned int GUIGlID
Definition GUIGlObject.h:44
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
const std::string getID() const
get ID (all Attribute Carriers have one)
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
Parameterised * getParameters() override
get parameters associated with this poly
Definition GNEPoly.cpp:116
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition GNEPoly.h:262
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:224
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNEPoly.cpp:716
GNEPoly & operator=(const GNEPoly &)=delete
Invalidated assignment operator.
std::string getParentName() const override
Returns the name of the parent object.
Definition GNEPoly.cpp:258
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNEPoly.cpp:593
~GNEPoly()
Destructor.
Definition GNEPoly.cpp:104
bool isValid(SumoXMLAttr key, const std::string &value) override
method for checking if the key and their conrrespond attribute are valids
Definition GNEPoly.cpp:639
void updateGeometry() override
update pre-computed geometry information
Definition GNEPoly.cpp:134
GNEMoveElementShape * myMoveElementShape
move element shape
Definition GNEPoly.h:253
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNEPoly.cpp:722
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:230
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
Definition GNEPoly.cpp:177
void drawPolygonNameAndType(const GUIVisualizationSettings &s) const
draw polygon name and type
Definition GNEPoly.cpp:892
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this poly
Definition GNEPoly.cpp:110
int getVertexIndex(Position pos, bool snapToGrid)
return index of a vertex of shape, or of a new vertex if position is over an shape's edge
Definition GNEPoly.cpp:358
PositionVector myGeoShape
Latitude of Polygon.
Definition GNEPoly.h:256
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition GNEPoly.cpp:148
void closePolygon(bool allowUndo=true)
close polygon
Definition GNEPoly.cpp:437
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition GNEPoly.cpp:458
std::string getAttribute(SumoXMLAttr key) const override
Definition GNEPoly.cpp:550
bool checkDrawMoveContour() const override
check if draw move contour (red)
Definition GNEPoly.cpp:242
bool isAdditionalValid() const override
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
Definition GNEPoly.cpp:218
Position getAttributePosition(SumoXMLAttr key) const override
Definition GNEPoly.cpp:599
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
method for setting the attribute and letting the object perform additional changes
Definition GNEPoly.cpp:611
GNEPoly(const GNEPoly &)=delete
Invalidated copy constructor.
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition GNEPoly.cpp:374
Position getPositionInView() const override
Returns position of shape in view.
Definition GNEPoly.cpp:142
void drawGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw geometry points
Definition GNEPoly.cpp:871
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNEPoly.cpp:311
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
Definition GNEPoly.cpp:605
void drawPolygon(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw polygon
Definition GNEPoly.cpp:835
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNEPoly.cpp:687
void drawPolygonContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw contour
Definition GNEPoly.cpp:855
CommonXMLStructure::SumoBaseObject * getSumoBaseObject() const
get SUMOBaseObject with all polygon attributes
Definition GNEPoly.cpp:530
bool isPolygonClosed() const
check if polygon is closed
Definition GNEPoly.cpp:410
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNEPoly.cpp:264
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition GNEPoly.cpp:498
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNEPoly.cpp:171
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
Definition GNEPoly.cpp:154
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition GNEPoly.cpp:236
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition GNEPoly.cpp:128
void openPolygon(bool allowUndo=true)
open polygon
Definition GNEPoly.cpp:416
bool myClosedShape
flag to indicate if polygon is closed
Definition GNEPoly.h:259
The popup menu of a globject.
Stores the information about how to visualize structures.
static methods for processing the coordinates conversion for the current net
Static storage of an output device and its base (abstract) implementation.
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.