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-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 class for visualizing and editing POIS in netedit (adapted from
19// GUIPolygon and NLHandler)
20/****************************************************************************/
21#pragma once
22#include <config.h>
24
25#include "GNEAdditional.h"
26
27// ===========================================================================
28// class declarations
29// ===========================================================================
30class GeoConvHelper;
32
33// ===========================================================================
34// class definitions
35// ===========================================================================
43class GNEPoly : public TesselatedPolygon, public GNEAdditional {
44
45public:
48
50 GNEPoly(SumoXMLTag tag, GNENet* net);
51
68 GNEPoly(GNENet* net, const std::string& id, const std::string& type, const PositionVector& shape, bool geo, bool fill,
69 double lineWidth, const RGBColor& color, double layer, double angle, const std::string& imgFile, bool relativePath,
70 const std::string& name, const Parameterised::Map& parameters);
71
80 GNEPoly(SumoXMLTag tag, GNENet* net, const std::string& id, const PositionVector& shape, bool geo, const std::string& name,
81 const Parameterised::Map& parameters);
82
84 ~GNEPoly();
85
90
92 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) override;
93
95 std::string generateChildID(SumoXMLTag childTag);
96
100 void updateGeometry() override;
101
103 Position getPositionInView() const override;
104
106 double getExaggeration(const GUIVisualizationSettings& s) const override;
107
109 void updateCenteringBoundary(const bool updateGrid) override;
110
112 void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement,
113 const GNENetworkElement* newElement, GNEUndoList* undoList) override;
114
118 void writeAdditional(OutputDevice& device) const override;
119
121 bool isAdditionalValid() const override;
122
124 std::string getAdditionalProblem() const override;
125
127 void fixAdditionalProblem() override;
128
130 GUIGlID getGlID() const;
131
133
136
138 bool checkDrawMoveContour() const override;
139
141
144
147 std::string getParentName() const override;
148
157
162 void drawGL(const GUIVisualizationSettings& s) const override;
163
165
168 /* @brief method for getting the Attribute of an XML key
169 * @param[in] key The attribute key
170 * @return string with the value associated to key
171 */
172 std::string getAttribute(SumoXMLAttr key) const override;
173
174 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
175 * @param[in] key The attribute key
176 * @return double with the value associated to key
177 */
178 double getAttributeDouble(SumoXMLAttr key) const override;
179
181 const Parameterised::Map& getACParametersMap() const override;
182
188 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
189
195 bool isValid(SumoXMLAttr key, const std::string& value) override;
196
197 /* @brief method for check if the value for certain attribute is set
198 * @param[in] key The attribute key
199 */
200 bool isAttributeEnabled(SumoXMLAttr key) const override;
202
204 std::string getPopUpID() const override;
205
207 std::string getHierarchyName() const override;
208
214 int getVertexIndex(Position pos, bool snapToGrid);
215
217 void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
218
220 bool isPolygonClosed() const;
221
223 void openPolygon(bool allowUndo = true);
224
226 void closePolygon(bool allowUndo = true);
227
229 void changeFirstGeometryPoint(int oldIndex, bool allowUndo = true);
230
232 void simplifyShape(bool allowUndo = true);
233
234protected:
237
240
241private:
243 void setAttribute(SumoXMLAttr key, const std::string& value) override;
244
246 void setMoveShape(const GNEMoveResult& moveResult) override;
247
249 void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) override;
250
253 const RGBColor& color, const double exaggeration) const;
254
257 const RGBColor& color, const double exaggeration) const;
258
261 const RGBColor& color, const double exaggeration) const;
262
265
267 GNEPoly(const GNEPoly&) = delete;
268
270 GNEPoly& operator=(const GNEPoly&) = delete;
271};
unsigned int GUIGlID
Definition GUIGlObject.h:43
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
An Element which don't belong to GNENet but has influence in the simulation.
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:239
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:214
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNEPoly.cpp:687
GNEPoly & operator=(const GNEPoly &)=delete
Invalidated assignment operator.
std::string getParentName() const override
Returns the name of the parent object.
Definition GNEPoly.cpp:248
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNEPoly.cpp:567
~GNEPoly()
Destructor.
Definition GNEPoly.cpp:105
bool isValid(SumoXMLAttr key, const std::string &value) override
method for checking if the key and their conrrespond attribute are valids
Definition GNEPoly.cpp:609
void updateGeometry() override
update pre-computed geometry information
Definition GNEPoly.cpp:159
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNEPoly.cpp:693
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:220
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
Definition GNEPoly.cpp:202
void drawPolygonNameAndType(const GUIVisualizationSettings &s) const
draw polygon name and type
Definition GNEPoly.cpp:889
GNEMoveOperation * getMoveOperation() override
get move operation
Definition GNEPoly.cpp:109
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:350
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:173
void closePolygon(bool allowUndo=true)
close polygon
Definition GNEPoly.cpp:429
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition GNEPoly.cpp:450
std::string getAttribute(SumoXMLAttr key) const override
Definition GNEPoly.cpp:522
bool checkDrawMoveContour() const override
check if draw move contour (red)
Definition GNEPoly.cpp:232
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
Definition GNEPoly.cpp:823
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:208
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
Definition GNEPoly.cpp:814
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:579
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:366
Position getPositionInView() const override
Returns position of shape in view.
Definition GNEPoly.cpp:167
void drawGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw geometry points
Definition GNEPoly.cpp:868
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
Definition GNEPoly.cpp:130
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNEPoly.cpp:303
void drawPolygon(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw polygon
Definition GNEPoly.cpp:832
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNEPoly.cpp:676
void drawPolygonContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const RGBColor &color, const double exaggeration) const
draw contour
Definition GNEPoly.cpp:852
bool isPolygonClosed() const
check if polygon is closed
Definition GNEPoly.cpp:402
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNEPoly.cpp:254
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition GNEPoly.cpp:490
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNEPoly.cpp:196
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
Definition GNEPoly.cpp:179
const Parameterised::Map & getACParametersMap() const override
get parameters map
Definition GNEPoly.cpp:573
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition GNEPoly.cpp:226
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition GNEPoly.cpp:153
void openPolygon(bool allowUndo=true)
open polygon
Definition GNEPoly.cpp:408
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.