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 "GNEShape.h"
26 
27 // ===========================================================================
28 // class declarations
29 // ===========================================================================
30 class GeoConvHelper;
31 class GNENetworkElement;
32 
33 // ===========================================================================
34 // class definitions
35 // ===========================================================================
43 class GNEPoly : public SUMOPolygon, public GNEShape {
44 
45 public:
47  using GNEShape::getID;
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 std::map<std::string, std::string>& parameters);
71 
73  ~GNEPoly();
74 
79 
81  void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
82 
84  std::string generateChildID(SumoXMLTag childTag);
85 
90  void setParameter(const std::string& key, const std::string& value);
91 
95  void updateGeometry();
96 
99 
101  double getExaggeration(const GUIVisualizationSettings& s) const;
102 
104  void updateCenteringBoundary(const bool updateGrid);
105 
109  void writeShape(OutputDevice& device);
110 
112  GUIGlID getGlID() const;
113 
115 
118 
121  std::string getParentName() const;
122 
131 
140 
145  void drawGL(const GUIVisualizationSettings& s) const;
147 
150  /* @brief method for getting the Attribute of an XML key
151  * @param[in] key The attribute key
152  * @return string with the value associated to key
153  */
154  std::string getAttribute(SumoXMLAttr key) const;
155 
161  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
162 
168  bool isValid(SumoXMLAttr key, const std::string& value);
169 
170  /* @brief method for check if the value for certain attribute is set
171  * @param[in] key The attribute key
172  */
173  bool isAttributeEnabled(SumoXMLAttr key) const;
175 
177  const std::map<std::string, std::string>& getACParametersMap() const;
178 
184  int getVertexIndex(Position pos, bool snapToGrid);
185 
187  void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
188 
190  bool isPolygonClosed() const;
191 
193  void openPolygon(bool allowUndo = true);
194 
196  void closePolygon(bool allowUndo = true);
197 
199  void changeFirstGeometryPoint(int oldIndex, bool allowUndo = true);
200 
202  void simplifyShape(bool allowUndo = true);
203 
204 protected:
207 
210 
213 
214 private:
216  void setAttribute(SumoXMLAttr key, const std::string& value);
217 
219  void setMoveShape(const GNEMoveResult& moveResult);
220 
222  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
223 
225  GNEPoly(const GNEPoly&) = delete;
226 
228  GNEPoly& operator=(const GNEPoly&) = delete;
229 };
unsigned int GUIGlID
Definition: GUIGlObject.h:40
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
void updateGeometry()
update pre-computed geometry information
Definition: GNEPoly.cpp:126
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEPoly.cpp:235
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition: GNEPoly.h:209
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEPoly.cpp:607
~GNEPoly()
Destructor.
Definition: GNEPoly.cpp:73
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEPoly.cpp:532
GNEPoly & operator=(const GNEPoly &)=delete
Invalidated assignment operator.
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNEPoly.cpp:806
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:357
PositionVector myGeoShape
Latitude of Polygon.
Definition: GNEPoly.h:206
GUIGeometry myPolygonGeometry
geometry for lenghts/rotations
Definition: GNEPoly.h:212
GNEPoly(GNENet *net)
default Constructor
Definition: GNEPoly.cpp:42
void closePolygon(bool allowUndo=true)
close polygon
Definition: GNEPoly.cpp:435
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition: GNEPoly.cpp:456
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition: GNEPoly.cpp:91
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNEPoly.cpp:815
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEPoly.cpp:180
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNEPoly.cpp:77
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
Definition: GNEPoly.cpp:120
GNEPoly(const GNEPoly &)=delete
Invalidated copy constructor.
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEPoly.cpp:675
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
Definition: GNEPoly.cpp:139
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNEPoly.cpp:224
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:373
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEPoly.cpp:174
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
Definition: GNEPoly.cpp:577
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition: GNEPoly.cpp:145
void writeShape(OutputDevice &device)
writte shape element into a xml file
Definition: GNEPoly.cpp:162
bool isPolygonClosed() const
check if polygon is closed
Definition: GNEPoly.cpp:408
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition: GNEPoly.cpp:496
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNEPoly.cpp:686
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GNEPoly.cpp:168
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNEPoly.cpp:114
Position getPositionInView() const
Returns position of shape in view.
Definition: GNEPoly.cpp:133
void openPolygon(bool allowUndo=true)
open polygon
Definition: GNEPoly.cpp:414
const std::string & getID() const
get ID (all shapes have one)
Definition: GNEShape.cpp:53
The popup menu of a globject.
A window containing a gl-object's parameter.
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
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.