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-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 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 bool isAdditionalValid() const override;
111
113 std::string getAdditionalProblem() const override;
114
116 void fixAdditionalProblem() override;
117
119 GUIGlID getGlID() const;
120
122
125
128 std::string getParentName() const override;
129
138
143 void drawGL(const GUIVisualizationSettings& s) const override;
144
145 double getClickPriority() const override {
146 return getShapeLayer();
147 }
149
152 /* @brief method for getting the Attribute of an XML key
153 * @param[in] key The attribute key
154 * @return string with the value associated to key
155 */
156 std::string getAttribute(SumoXMLAttr key) const override;
157
158 /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
159 * @param[in] key The attribute key
160 * @return double with the value associated to key
161 */
162 double getAttributeDouble(SumoXMLAttr key) const override;
163
165 const Parameterised::Map& getACParametersMap() const override;
166
172 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) override;
173
179 bool isValid(SumoXMLAttr key, const std::string& value) override;
180
181 /* @brief method for check if the value for certain attribute is set
182 * @param[in] key The attribute key
183 */
184 bool isAttributeEnabled(SumoXMLAttr key) const override;
186
188 std::string getPopUpID() const override;
189
191 std::string getHierarchyName() const override;
192
198 int getVertexIndex(Position pos, bool snapToGrid);
199
201 void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
202
204 bool isPolygonClosed() const;
205
207 void openPolygon(bool allowUndo = true);
208
210 void closePolygon(bool allowUndo = true);
211
213 void changeFirstGeometryPoint(int oldIndex, bool allowUndo = true);
214
216 void simplifyShape(bool allowUndo = true);
217
218protected:
221
224
227
228private:
230 void setAttribute(SumoXMLAttr key, const std::string& value) override;
231
233 void setMoveShape(const GNEMoveResult& moveResult) override;
234
236 void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) override;
237
239 GNEPoly(const GNEPoly&) = delete;
240
242 GNEPoly& operator=(const GNEPoly&) = delete;
243};
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:223
std::string getAdditionalProblem() const override
return a string with the current additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:182
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNEPoly.cpp:744
GNEPoly & operator=(const GNEPoly &)=delete
Invalidated assignment operator.
std::string getParentName() const override
Returns the name of the parent object.
Definition GNEPoly.cpp:200
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNEPoly.cpp:622
~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:664
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:750
void fixAdditionalProblem() override
fix additional problem (must be reimplemented in all detector children)
Definition GNEPoly.cpp:188
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:401
PositionVector myGeoShape
Latitude of Polygon.
Definition GNEPoly.h:220
GUIGeometry myPolygonGeometry
geometry for lengths/rotations
Definition GNEPoly.h:226
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:480
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition GNEPoly.cpp:501
std::string getAttribute(SumoXMLAttr key) const override
Definition GNEPoly.cpp:577
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList) override
commit move shape
Definition GNEPoly.cpp:879
bool isAdditionalValid() const override
check if current additional is valid to be writed into XML (must be reimplemented in all detector chi...
Definition GNEPoly.cpp:176
void setMoveShape(const GNEMoveResult &moveResult) override
set move shape
Definition GNEPoly.cpp:870
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:634
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:417
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:145
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNEPoly.cpp:250
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNEPoly.cpp:733
bool isPolygonClosed() const
check if polygon is closed
Definition GNEPoly.cpp:453
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNEPoly.cpp:206
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition GNEPoly.cpp:541
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:628
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition GNEPoly.cpp:194
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:459
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.
double getShapeLayer() const
Returns the layer of the Shape.
Definition Shape.h:91