Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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>
25
26#include "GNEAdditional.h"
27
28// ===========================================================================
29// class declarations
30// ===========================================================================
31
32class GeoConvHelper;
34
35// ===========================================================================
36// class definitions
37// ===========================================================================
38
39class GNEPoly : public TesselatedPolygon, public GNEAdditional {
40
41public:
44
46 GNEPoly(SumoXMLTag tag, GNENet* net);
47
64 GNEPoly(const std::string& id, GNENet* net, const std::string& filename, const std::string& type, const PositionVector& shape,
65 bool geo, bool fill, double lineWidth, const RGBColor& color, double layer, double angle, const std::string& imgFile,
66 const std::string& name, const Parameterised::Map& parameters);
67
77 GNEPoly(SumoXMLTag tag, const std::string& id, GNENet* net, const std::string& filename, const PositionVector& shape,
78 bool geo, const std::string& name, const Parameterised::Map& parameters);
79
81 ~GNEPoly();
82
87
89 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) override;
90
92 std::string generateChildID(SumoXMLTag childTag);
93
97 void updateGeometry() override;
98
100 Position getPositionInView() const override;
101
103 double getExaggeration(const GUIVisualizationSettings& s) const override;
104
106 void updateCenteringBoundary(const bool updateGrid) override;
107
109 void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement,
110 const GNENetworkElement* newElement, GNEUndoList* undoList) override;
111
115 void writeAdditional(OutputDevice& device) const override;
116
118 bool isAdditionalValid() const override;
119
121 std::string getAdditionalProblem() const override;
122
124 void fixAdditionalProblem() override;
125
127 GUIGlID getGlID() const;
128
130
133
135 bool checkDrawMoveContour() const override;
136
138
141
144 std::string getParentName() const override;
145
154
159 void drawGL(const GUIVisualizationSettings& s) const override;
160
162
165 /* @brief method for getting the Attribute of an XML key
166 * @param[in] key The attribute key
167 * @return string with the value associated to key
168 */
169 std::string getAttribute(SumoXMLAttr key) const override;
170
171 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
172 * @param[in] key The attribute key
173 * @return double with the value associated to key
174 */
175 double getAttributeDouble(SumoXMLAttr key) const override;
176
178 const Parameterised::Map& getACParametersMap() const override;
179
185 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
186
192 bool isValid(SumoXMLAttr key, const std::string& value) override;
193
194 /* @brief method for check if the value for certain attribute is set
195 * @param[in] key The attribute key
196 */
197 bool isAttributeEnabled(SumoXMLAttr key) const override;
199
201 std::string getPopUpID() const override;
202
204 std::string getHierarchyName() const override;
205
211 int getVertexIndex(Position pos, bool snapToGrid);
212
214 void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
215
217 bool isPolygonClosed() const;
218
220 void openPolygon(bool allowUndo = true);
221
223 void closePolygon(bool allowUndo = true);
224
226 void changeFirstGeometryPoint(int oldIndex, bool allowUndo = true);
227
229 void simplifyShape(bool allowUndo = true);
230
233
234protected:
237
239 bool myClosedShape = false;
240
242 bool mySimplifiedShape = false;
243
244private:
246 void setAttribute(SumoXMLAttr key, const std::string& value) override;
247
249 void setMoveShape(const GNEMoveResult& moveResult) override;
250
252 void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) override;
253
256 const RGBColor& color, const double exaggeration) const;
257
260 const RGBColor& color, const double exaggeration) const;
261
264 const RGBColor& color, const double exaggeration) const;
265
268
270 GNEPoly(const GNEPoly&) = delete;
271
273 GNEPoly& operator=(const GNEPoly&) = delete;
274};
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)
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition GNEPoly.h:242
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:211
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNEPoly.cpp:697
GNEPoly & operator=(const GNEPoly &)=delete
Invalidated assignment operator.
std::string getParentName() const override
Returns the name of the parent object.
Definition GNEPoly.cpp:245
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNEPoly.cpp:580
~GNEPoly()
Destructor.
Definition GNEPoly.cpp:102
bool isValid(SumoXMLAttr key, const std::string &value) override
method for checking if the key and their conrrespond attribute are valids
Definition GNEPoly.cpp:620
void updateGeometry() override
update pre-computed geometry information
Definition GNEPoly.cpp:156
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNEPoly.cpp:703
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:217
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
Definition GNEPoly.cpp:199
void drawPolygonNameAndType(const GUIVisualizationSettings &s) const
draw polygon name and type
Definition GNEPoly.cpp:891
GNEMoveOperation * getMoveOperation() override
get move operation
Definition GNEPoly.cpp:106
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:345
PositionVector myGeoShape
Latitude of Polygon.
Definition GNEPoly.h:236
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition GNEPoly.cpp:170
void closePolygon(bool allowUndo=true)
close polygon
Definition GNEPoly.cpp:424
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition GNEPoly.cpp:445
std::string getAttribute(SumoXMLAttr key) const override
Definition GNEPoly.cpp:537
bool checkDrawMoveContour() const override
check if draw move contour (red)
Definition GNEPoly.cpp:229
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
Definition GNEPoly.cpp:825
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:205
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
Definition GNEPoly.cpp:816
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:592
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:361
Position getPositionInView() const override
Returns position of shape in view.
Definition GNEPoly.cpp:164
void drawGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw geometry points
Definition GNEPoly.cpp:870
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
Definition GNEPoly.cpp:127
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNEPoly.cpp:298
void drawPolygon(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw polygon
Definition GNEPoly.cpp:834
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNEPoly.cpp:668
void drawPolygonContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw contour
Definition GNEPoly.cpp:854
CommonXMLStructure::SumoBaseObject * getSumoBaseObject() const
get SUMOBaseObject with all polygon attributes
Definition GNEPoly.cpp:517
bool isPolygonClosed() const
check if polygon is closed
Definition GNEPoly.cpp:397
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNEPoly.cpp:251
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition GNEPoly.cpp:485
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNEPoly.cpp:193
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
Definition GNEPoly.cpp:176
const Parameterised::Map & getACParametersMap() const override
get parameters map
Definition GNEPoly.cpp:586
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition GNEPoly.cpp:223
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition GNEPoly.cpp:150
void openPolygon(bool allowUndo=true)
open polygon
Definition GNEPoly.cpp:403
bool myClosedShape
flag to indicate if polygon is closed
Definition GNEPoly.h:239
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.
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.