Eclipse SUMO - Simulation of Urban MObility
GNEPoly.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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(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
73 ~GNEPoly();
74
79
81 void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) override;
82
84 std::string generateChildID(SumoXMLTag childTag);
85
89 void updateGeometry() override;
90
92 Position getPositionInView() const override;
93
95 double getExaggeration(const GUIVisualizationSettings& s) const override;
96
98 void updateCenteringBoundary(const bool updateGrid) override;
99
101 void splitEdgeGeometry(const double splitPosition, const GNENetworkElement* originalElement,
102 const GNENetworkElement* newElement, GNEUndoList* undoList) override;
103
107 void writeAdditional(OutputDevice& device) const override;
108
110 GUIGlID getGlID() const;
111
113
116
119 std::string getParentName() const override;
120
129
134 void drawGL(const GUIVisualizationSettings& s) const override;
135
136 double getClickPriority() const override {
137 return getShapeLayer();
138 }
140
143 /* @brief method for getting the Attribute of an XML key
144 * @param[in] key The attribute key
145 * @return string with the value associated to key
146 */
147 std::string getAttribute(SumoXMLAttr key) const override;
148
149 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
150 * @param[in] key The attribute key
151 * @return double with the value associated to key
152 */
153 double getAttributeDouble(SumoXMLAttr key) const override;
154
156 const Parameterised::Map& getACParametersMap() const override;
157
163 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
164
170 bool isValid(SumoXMLAttr key, const std::string& value) override;
171
172 /* @brief method for check if the value for certain attribute is set
173 * @param[in] key The attribute key
174 */
175 bool isAttributeEnabled(SumoXMLAttr key) const override;
177
179 std::string getPopUpID() const override;
180
182 std::string getHierarchyName() const override;
183
189 int getVertexIndex(Position pos, bool snapToGrid);
190
192 void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
193
195 bool isPolygonClosed() const;
196
198 void openPolygon(bool allowUndo = true);
199
201 void closePolygon(bool allowUndo = true);
202
204 void changeFirstGeometryPoint(int oldIndex, bool allowUndo = true);
205
207 void simplifyShape(bool allowUndo = true);
208
209protected:
212
215
218
219private:
221 void setAttribute(SumoXMLAttr key, const std::string& value) override;
222
224 void setMoveShape(const GNEMoveResult& moveResult) override;
225
227 void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) override;
228
230 GNEPoly(const GNEPoly&) = delete;
231
233 GNEPoly& operator=(const GNEPoly&) = delete;
234};
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.
Definition: GNEAdditional.h:48
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:214
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition: GNEPoly.cpp:723
GNEPoly & operator=(const GNEPoly &)=delete
Invalidated assignment operator.
std::string getParentName() const override
Returns the name of the parent object.
Definition: GNEPoly.cpp:182
double getAttributeDouble(SumoXMLAttr key) const override
Definition: GNEPoly.cpp:601
~GNEPoly()
Destructor.
Definition: GNEPoly.cpp:80
bool isValid(SumoXMLAttr key, const std::string &value) override
method for checking if the key and their conrrespond attribute are valids
Definition: GNEPoly.cpp:643
void updateGeometry() override
update pre-computed geometry information
Definition: GNEPoly.cpp:127
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEPoly.cpp:729
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
Definition: GNEPoly.cpp:170
GNEMoveOperation * getMoveOperation() override
get move operation
Definition: GNEPoly.cpp:84
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:380
PositionVector myGeoShape
Latitude of Polygon.
Definition: GNEPoly.h:211
GUIGeometry myPolygonGeometry
geometry for lengths/rotations
Definition: GNEPoly.h:217
GNEPoly(GNENet *net)
default Constructor
Definition: GNEPoly.cpp:43
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition: GNEPoly.cpp:141
void closePolygon(bool allowUndo=true)
close polygon
Definition: GNEPoly.cpp:459
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition: GNEPoly.cpp:480
std::string getAttribute(SumoXMLAttr key) const override
Definition: GNEPoly.cpp:556
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
Definition: GNEPoly.cpp:858
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
Definition: GNEPoly.cpp:849
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:613
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:396
Position getPositionInView() const override
Returns position of shape in view.
Definition: GNEPoly.cpp:135
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList) override
remove geometry point in the clicked position
Definition: GNEPoly.cpp:98
double getClickPriority() const override
Returns the priority of receiving mouse clicks.
Definition: GNEPoly.h:136
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GNEPoly.cpp:232
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition: GNEPoly.cpp:712
bool isPolygonClosed() const
check if polygon is closed
Definition: GNEPoly.cpp:432
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GNEPoly.cpp:188
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition: GNEPoly.cpp:520
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition: GNEPoly.cpp:164
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
Definition: GNEPoly.cpp:147
const Parameterised::Map & getACParametersMap() const override
get parameters map
Definition: GNEPoly.cpp:607
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GNEPoly.cpp:176
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNEPoly.cpp:121
void openPolygon(bool allowUndo=true)
open polygon
Definition: GNEPoly.cpp:438
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
Definition: GeoConvHelper.h:53
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.
double getShapeLayer() const
Returns the layer of the Shape.
Definition: Shape.h:91