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-2018 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 
77  void startGeometryMoving();
78 
80  void endGeometryMoving();
81 
87  int moveVertexShape(const int index, const Position& oldPos, const Position& offset);
88 
93  void moveEntireShape(const PositionVector& oldShape, const Position& offset);
94 
99  void commitShapeChange(const PositionVector& oldShape, GNEUndoList* undoList);
101 
105  void updateGeometry(bool updateGrid);
106 
110  void writeShape(OutputDevice& device);
111 
113  Position getPositionInView() const;
114 
116  GUIGlID getGlID() const;
118 
121 
124  std::string getParentName() const;
125 
134 
143 
146 
151  void drawGL(const GUIVisualizationSettings& s) const;
153 
156  /* @brief method for getting the Attribute of an XML key
157  * @param[in] key The attribute key
158  * @return string with the value associated to key
159  */
160  std::string getAttribute(SumoXMLAttr key) const;
161 
167  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
168 
174  bool isValid(SumoXMLAttr key, const std::string& value);
176 
179 
181  std::string getGenericParametersStr() const;
182 
184  std::vector<std::pair<std::string, std::string> > getGenericParameters() const;
185 
187  void setGenericParametersStr(const std::string& value);
188 
190 
197  int getVertexIndex(Position pos, bool createIfNoExist, bool snapToGrid);
198 
200  void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
201 
203  bool isPolygonBlocked() const;
204 
206  bool isPolygonClosed() const;
207 
209  void setShapeEditedElement(GNENetElement* element);
210 
213 
215  void openPolygon(bool allowUndo = true);
216 
218  void closePolygon(bool allowUndo = true);
219 
221  void changeFirstGeometryPoint(int oldIndex, bool allowUndo = true);
222 
224  void simplifyShape(bool allowUndo = true);
225 
226 protected:
229 
232 
235 
238 
241 
244 
245 private:
247  static const double myHintSize;
248 
250  void setAttribute(SumoXMLAttr key, const std::string& value);
251 
253  void mouseOverObject(const GUIVisualizationSettings& s) const;
254 
256  GNEPoly(const GNEPoly&) = delete;
257 
259  GNEPoly& operator=(const GNEPoly&) = delete;
260 };
261 
262 
263 #endif
264 
265 /****************************************************************************/
266 
void endGeometryMoving()
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
Definition: GNEPoly.cpp:79
void openPolygon(bool allowUndo=true)
open polygon
Definition: GNEPoly.cpp:451
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEPoly.cpp:202
Stores the information about how to visualize structures.
bool isPolygonClosed() const
check if polygon is closed
Definition: GNEPoly.cpp:429
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(...)
Definition: GNEPoly.cpp:146
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition: GNEPoly.h:240
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
PositionVector myGeoShape
Latitude of Polygon.
Definition: GNEPoly.h:231
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:473
GNENetElement * myNetElementShapeEdited
junction of which the shape is being edited (optional)
Definition: GNEPoly.h:228
GNEPoly & operator=(const GNEPoly &)=delete
Invalidated assignment operator.
bool isPolygonBlocked() const
return true if polygon is blocked
Definition: GNEPoly.cpp:423
void startGeometryMoving()
Definition: GNEPoly.cpp:72
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:53
void writeShape(OutputDevice &device)
writte shape element into a xml file
Definition: GNEPoly.cpp:184
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNEPoly.cpp:748
void mouseOverObject(const GUIVisualizationSettings &s) const
method for check if mouse is over objects
Definition: GNEPoly.cpp:897
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:247
int myCurrentMovingVertexIndex
index of vertex that is been moved (-1 means that none vertex is been moved)
Definition: GNEPoly.h:243
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEPoly.cpp:269
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:653
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:386
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:622
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEPoly.cpp:575
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEPoly.cpp:212
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:95
void setShapeEditedElement(GNENetElement *element)
retrieve the netElement of which the shape is being edited
Definition: GNEPoly.cpp:435
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition: GNEPoly.cpp:537
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEPoly.cpp:190
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GNEPoly.cpp:196
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNEPoly.cpp:252
The popup menu of a globject.
GNENetElement * getShapeEditedElement() const
retrieve the junction of which the shape is being edited
Definition: GNEPoly.cpp:445
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
Definition: GNEPoly.cpp:737
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:234
bool myClosedShape
flag to indicate if polygon is open or closed
Definition: GNEPoly.h:237
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNEPoly.cpp:722
A window containing a gl-object&#39;s parameter.
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition: GNEPoly.cpp:495
void updateGeometry(bool updateGrid)
update pre-computed geometry information
Definition: GNEPoly.cpp:179
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:365
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEPoly.cpp:258
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
Definition: GNEPoly.cpp:130