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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // A class for visualizing and editing POIS in netedit (adapted from
18 // GUIPolygon and NLHandler)
19 /****************************************************************************/
20 #ifndef GNEPoly_h
21 #define GNEPoly_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "GNEShape.h"
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class GeoConvHelper;
39 class GNENetElement;
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
51 class GNEPoly : public GUIPolygon, public GNEShape {
52 
53 public:
55  using GNEShape::getID;
56  using Shape::getType;
57 
72  GNEPoly(GNENet* net, const std::string& id, const std::string& type, const PositionVector& shape, bool geo, bool fill,
73  const RGBColor& color, double layer, double angle, const std::string& imgFile, bool movementBlocked, bool shapeBlocked);
74 
76  ~GNEPoly();
77 
83  int moveVertexShape(const int index, const Position& oldPos, const Position& offset);
84 
89  void moveEntireShape(const PositionVector& oldShape, const Position& offset);
90 
95  void commitShapeChange(const PositionVector& oldShape, GNEUndoList* undoList);
96 
100  void updateGeometry();
101 
105  void writeShape(OutputDevice& device);
106 
108  Position getPositionInView() const;
109 
111  GUIGlID getGlID() const;
113 
116 
119  const std::string& getParentName() const;
120 
129 
138 
141 
146  void drawGL(const GUIVisualizationSettings& s) const;
148 
151  /* @brief method for getting the Attribute of an XML key
152  * @param[in] key The attribute key
153  * @return string with the value associated to key
154  */
155  std::string getAttribute(SumoXMLAttr key) const;
156 
162  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
163 
169  bool isValid(SumoXMLAttr key, const std::string& value);
171 
177  int getVertexIndex(const Position& pos, bool createIfNoExist = true);
178 
180  void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
181 
183  bool isPolygonClosed() const;
184 
186  void setShapeEditedElement(GNENetElement* element);
187 
190 
192  void openPolygon(bool allowUndo = true);
193 
195  void closePolygon(bool allowUndo = true);
196 
198  void changeFirstGeometryPoint(int oldIndex, bool allowUndo = true);
199 
201  void simplifyShape(bool allowUndo = true);
202 
203 protected:
206 
209 
212 
215 
218 
219 private:
221  static const double myHintSize;
222 
224  void setAttribute(SumoXMLAttr key, const std::string& value);
225 
227  GNEPoly(const GNEPoly&) = delete;
228 
230  GNEPoly& operator=(const GNEPoly&) = delete;
231 };
232 
233 
234 #endif
235 
236 /****************************************************************************/
237 
void openPolygon(bool allowUndo=true)
open polygon
Definition: GNEPoly.cpp:407
GNEPoly(GNENet *net, const std::string &id, const std::string &type, const PositionVector &shape, bool geo, bool fill, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool movementBlocked, bool shapeBlocked)
Constructor.
Definition: GNEPoly.cpp:69
const std::string & getParentName() const
Returns the name of the parent object.
Definition: GNEPoly.cpp:194
Stores the information about how to visualize structures.
bool isPolygonClosed() const
check if polygon is closed
Definition: GNEPoly.cpp:385
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(...)
Definition: GNEPoly.cpp:139
void updateGeometry()
update pre-computed geometry information
Definition: GNEPoly.cpp:170
int getVertexIndex(const Position &pos, bool createIfNoExist=true)
return index of a vertex of shape, or of a new vertex if position is over an shape&#39;s edge ...
Definition: GNEPoly.cpp:333
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:91
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition: GNEPoly.h:214
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
PositionVector myGeoShape
Latitude of Polygon.
Definition: GNEPoly.h:208
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
void closePolygon(bool allowUndo=true)
close polygon
Definition: GNEPoly.cpp:429
GNENetElement * myNetElementShapeEdited
junction of which the shape is being edited (optional)
Definition: GNEPoly.h:205
GNEPoly & operator=(const GNEPoly &)=delete
Invalidated assignment operator.
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:59
void writeShape(OutputDevice &device)
writte shape element into a xml file
Definition: GNEPoly.cpp:176
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
A list of positions.
static const double myHintSize
hint size of vertex
Definition: GNEPoly.h:221
int myCurrentMovingVertexIndex
index of vertex that is been moved (-1 means that none vertex is been moved)
Definition: GNEPoly.h:217
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEPoly.cpp:256
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:587
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:350
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
std::string getAttribute(SumoXMLAttr key) const
This functions has to be implemented in all GNEAttributeCarriers.
Definition: GNEPoly.cpp:525
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEPoly.cpp:204
unsigned int GUIGlID
Definition: GUIGlObject.h:49
const std::string & getType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:70
int moveVertexShape(const int index, const Position &oldPos, const Position &offset)
change position of a vertex of shape without commiting change
Definition: GNEPoly.cpp:93
void setShapeEditedElement(GNENetElement *element)
retrieve the netElement of which the shape is being edited
Definition: GNEPoly.cpp:391
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition: GNEPoly.cpp:493
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEPoly.cpp:182
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GNEPoly.cpp:188
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNEPoly.cpp:244
The popup menu of a globject.
GNENetElement * getShapeEditedElement() const
retrieve the junction of which the shape is being edited
Definition: GNEPoly.cpp:401
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
~GNEPoly()
Destructor.
Definition: GNEPoly.cpp:89
bool myClosedShape
flag to indicate if polygon is open or closed
Definition: GNEPoly.h:211
A window containing a gl-object&#39;s parameter.
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition: GNEPoly.cpp:451
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEPoly.cpp:250
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
Definition: GNEPoly.cpp:123