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-2020 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
23 
24 #include "GNEShape.h"
25 
26 // ===========================================================================
27 // class declarations
28 // ===========================================================================
29 class GeoConvHelper;
30 class GNENetworkElement;
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
42 class GNEPoly : public SUMOPolygon, public GNEShape {
43 
44 public:
46  using GNEShape::getID;
47 
64  GNEPoly(GNENet* net, const std::string& id, const std::string& type, const PositionVector& shape, bool geo, bool fill, double lineWidth,
65  const RGBColor& color, double layer, double angle, const std::string& imgFile, bool relativePath, bool movementBlocked, bool shapeBlocked);
66 
68  ~GNEPoly();
69 
73  GNEMoveOperation* getMoveOperation(const double shapeOffset);
74 
76  void removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList);
77 
79  std::string generateChildID(SumoXMLTag childTag);
80 
85  void setParameter(const std::string& key, const std::string& value);
86 
90  void updateGeometry();
91 
93  void updateCenteringBoundary(const bool updateGrid);
94 
98  void writeShape(OutputDevice& device);
99 
101  GUIGlID getGlID() const;
102 
104 
107 
110  std::string getParentName() const;
111 
120 
129 
134  void drawGL(const GUIVisualizationSettings& s) const;
136 
139  /* @brief method for getting the Attribute of an XML key
140  * @param[in] key The attribute key
141  * @return string with the value associated to key
142  */
143  std::string getAttribute(SumoXMLAttr key) const;
144 
150  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
151 
157  bool isValid(SumoXMLAttr key, const std::string& value);
158 
159  /* @brief method for check if the value for certain attribute is set
160  * @param[in] key The attribute key
161  */
162  bool isAttributeEnabled(SumoXMLAttr key) const;
164 
166  const std::map<std::string, std::string>& getACParametersMap() const;
167 
173  int getVertexIndex(Position pos, bool snapToGrid);
174 
176  void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
177 
179  bool isPolygonBlocked() const;
180 
182  bool isPolygonClosed() const;
183 
185  void openPolygon(bool allowUndo = true);
186 
188  void closePolygon(bool allowUndo = true);
189 
191  void changeFirstGeometryPoint(int oldIndex, bool allowUndo = true);
192 
194  void simplifyShape(bool allowUndo = true);
195 
196 protected:
199 
202 
205 
208 
209 private:
211  void setAttribute(SumoXMLAttr key, const std::string& value);
212 
214  void setMoveShape(const GNEMoveResult& moveResult);
215 
217  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
218 
220  GNEPoly(const GNEPoly&) = delete;
221 
223  GNEPoly& operator=(const GNEPoly&) = delete;
224 };
unsigned int GUIGlID
Definition: GUIGlObject.h:40
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
class for NETEDIT geometries over lanes
Definition: GNEGeometry.h:76
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
void updateGeometry()
update pre-computed geometry information
Definition: GNEPoly.cpp:145
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:204
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEPoly.cpp:591
bool isPolygonBlocked() const
return true if polygon is blocked
Definition: GNEPoly.cpp:383
~GNEPoly()
Destructor.
Definition: GNEPoly.cpp:61
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEPoly.cpp:513
GNEPoly & operator=(const GNEPoly &)=delete
Invalidated assignment operator.
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNEPoly.cpp:793
bool myBlockShape
flag for block shape
Definition: GNEPoly.h:201
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:332
PositionVector myGeoShape
Latitude of Polygon.
Definition: GNEPoly.h:198
GNEMoveOperation * getMoveOperation(const double shapeOffset)
get move operation for the given shapeOffset
Definition: GNEPoly.cpp:65
void closePolygon(bool allowUndo=true)
close polygon
Definition: GNEPoly.cpp:416
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition: GNEPoly.cpp:437
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
Definition: GNEPoly.cpp:106
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNEPoly.cpp:802
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEPoly.cpp:187
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
Definition: GNEPoly.cpp:139
GNEPoly(const GNEPoly &)=delete
Invalidated copy constructor.
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEPoly.cpp:659
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:348
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEPoly.cpp:181
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:560
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition: GNEPoly.cpp:152
void writeShape(OutputDevice &device)
writte shape element into a xml file
Definition: GNEPoly.cpp:169
bool isPolygonClosed() const
check if polygon is closed
Definition: GNEPoly.cpp:389
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition: GNEPoly.cpp:477
GNEGeometry::Geometry myPolygonGeometry
geometry for lenghts/rotations
Definition: GNEPoly.h:207
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
Definition: GNEPoly.cpp:670
GNEPoly(GNENet *net, const std::string &id, const std::string &type, const PositionVector &shape, bool geo, bool fill, double lineWidth, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool relativePath, bool movementBlocked, bool shapeBlocked)
Constructor.
Definition: GNEPoly.cpp:39
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GNEPoly.cpp:175
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNEPoly.cpp:129
void openPolygon(bool allowUndo=true)
open polygon
Definition: GNEPoly.cpp:395
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:60
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
A list of positions.