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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A class for visualizing and editing POIS in netedit (adapted from
16 // GUIPolygon and NLHandler)
17 /****************************************************************************/
18 #ifndef GNEPoly_h
19 #define GNEPoly_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 
27 
28 #include "GNEShape.h"
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class GeoConvHelper;
34 class GNENetElement;
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
46 class GNEPoly : public GUIPolygon, public GNEShape {
47 
48 public:
50  using GNEShape::getID;
51 
68  GNEPoly(GNENet* net, const std::string& id, const std::string& type, const PositionVector& shape, bool geo, bool fill, double lineWidth,
69  const RGBColor& color, double layer, double angle, const std::string& imgFile, bool relativePath, bool movementBlocked, bool shapeBlocked);
70 
72  ~GNEPoly();
73 
75  std::string generateChildID(SumoXMLTag childTag);
76 
80  void startGeometryMoving();
81 
83  void endGeometryMoving();
84 
90  int moveVertexShape(const int index, const Position& oldPos, const Position& offset);
91 
96  void moveEntireShape(const PositionVector& oldShape, const Position& offset);
97 
102  void commitShapeChange(const PositionVector& oldShape, GNEUndoList* undoList);
104 
108  void updateGeometry();
109 
112 
116  void writeShape(OutputDevice& device);
117 
119  Position getPositionInView() const;
120 
122  GUIGlID getGlID() const;
124 
127 
130  std::string getParentName() const;
131 
140 
149 
154  void drawGL(const GUIVisualizationSettings& s) const;
156 
159  /* @brief method for getting the Attribute of an XML key
160  * @param[in] key The attribute key
161  * @return string with the value associated to key
162  */
163  std::string getAttribute(SumoXMLAttr key) const;
164 
170  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
171 
177  bool isValid(SumoXMLAttr key, const std::string& value);
179 
182 
184  std::string getGenericParametersStr() const;
185 
187  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
188 
190  void setGenericParametersStr(const std::string& value);
191 
193 
200  int getVertexIndex(Position pos, bool createIfNoExist, bool snapToGrid);
201 
203  void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
204 
206  bool isPolygonBlocked() const;
207 
209  bool isPolygonClosed() const;
210 
212  void setShapeEditedElement(GNENetElement* element);
213 
216 
218  void openPolygon(bool allowUndo = true);
219 
221  void closePolygon(bool allowUndo = true);
222 
224  void changeFirstGeometryPoint(int oldIndex, bool allowUndo = true);
225 
227  void simplifyShape(bool allowUndo = true);
228 
229 protected:
232 
235 
238 
241 
244 
247 
248 private:
250  static const double myHintSize;
251 
253  void setAttribute(SumoXMLAttr key, const std::string& value);
254 
256  const GUIGlObject* getGUIGlObject() const;
257 
259  GNEPoly(const GNEPoly&) = delete;
260 
262  GNEPoly& operator=(const GNEPoly&) = delete;
263 };
264 
265 
266 #endif
267 
268 /****************************************************************************/
269 
void endGeometryMoving()
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
Definition: GNEPoly.cpp:89
SumoXMLTag
Numbers representing SUMO-XML - element names.
void openPolygon(bool allowUndo=true)
open polygon
Definition: GNEPoly.cpp:471
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNEPoly.cpp:72
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEPoly.cpp:222
Stores the information about how to visualize structures.
bool isPolygonClosed() const
check if polygon is closed
Definition: GNEPoly.cpp:449
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(...)
Definition: GNEPoly.cpp:154
void updateGeometry()
update pre-computed geometry information
Definition: GNEPoly.cpp:188
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:78
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition: GNEPoly.h:243
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
PositionVector myGeoShape
Latitude of Polygon.
Definition: GNEPoly.h:234
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:47
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
void closePolygon(bool allowUndo=true)
close polygon
Definition: GNEPoly.cpp:493
GNENetElement * myNetElementShapeEdited
junction of which the shape is being edited (optional)
Definition: GNEPoly.h:231
GNEPoly & operator=(const GNEPoly &)=delete
Invalidated assignment operator.
bool isPolygonBlocked() const
return true if polygon is blocked
Definition: GNEPoly.cpp:443
void startGeometryMoving()
Definition: GNEPoly.cpp:82
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:56
void writeShape(OutputDevice &device)
writte shape element into a xml file
Definition: GNEPoly.cpp:193
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNEPoly.cpp:768
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
A list of positions.
static const double myHintSize
hint size of vertex
Definition: GNEPoly.h:250
int myCurrentMovingVertexIndex
index of vertex that is been moved (-1 means that none vertex is been moved)
Definition: GNEPoly.h:246
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEPoly.cpp:278
const std::string getID() const
function to support debugging
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEPoly.cpp:673
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:406
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:642
const GUIGlObject * getGUIGlObject() const
get GUIGlObject associated to this GNEShape
Definition: GNEPoly.cpp:917
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEPoly.cpp:595
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEPoly.cpp:232
unsigned int GUIGlID
Definition: GUIGlObject.h:43
int moveVertexShape(const int index, const Position &oldPos, const Position &offset)
change position of a vertex of shape without commiting change
Definition: GNEPoly.cpp:103
void setShapeEditedElement(GNENetElement *element)
retrieve the netElement of which the shape is being edited
Definition: GNEPoly.cpp:455
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition: GNEPoly.cpp:557
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEPoly.cpp:199
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GNEPoly.cpp:216
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNEPoly.cpp:272
The popup menu of a globject.
GNENetElement * getShapeEditedElement() const
retrieve the junction of which the shape is being edited
Definition: GNEPoly.cpp:465
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
Definition: GNEPoly.cpp:757
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
~GNEPoly()
Destructor.
Definition: GNEPoly.cpp:68
bool myBlockShape
flag for block shape
Definition: GNEPoly.h:237
bool myClosedShape
flag to indicate if polygon is open or closed
Definition: GNEPoly.h:240
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNEPoly.cpp:742
A window containing a gl-object&#39;s parameter.
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition: GNEPoly.cpp:515
int getVertexIndex(Position pos, bool createIfNoExist, bool snapToGrid)
return index of a vertex of shape, or of a new vertex if position is over an shape&#39;s edge ...
Definition: GNEPoly.cpp:385
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEPoly.cpp:205
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
Definition: GNEPoly.cpp:138