SUMO - Simulation of Urban MObility
GNEPoly.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // A class for visualizing and editing POIS in netedit (adapted from
8 // GUIPolygon and NLHandler)
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef GNEPoly_h
22 #define GNEPoly_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include "GNEShape.h"
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class GeoConvHelper;
40 class GNEJunction;
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
52 class GNEPoly : public GUIPolygon, public GNEShape {
53 
54 public:
56  using GNEShape::getID;
57 
71  GNEPoly(GNENet* net, const std::string& id, const std::string& type, const PositionVector& shape, bool fill,
72  const RGBColor& color, double layer, double angle, const std::string& imgFile, bool movementBlocked, bool shapeBlocked);
73 
75  ~GNEPoly();
76 
82  int moveVertexShape(int index, const Position& newPos);
83 
88  void moveEntireShape(const PositionVector& oldShape, const Position& offset);
89 
94  void commitShapeChange(const PositionVector& oldShape, GNEUndoList* undoList);
95 
98 
101  void writeShape(OutputDevice& device);
102 
104  Position getPositionInView() const;
106 
109 
112  const std::string& getParentName() const;
113 
122 
131 
134 
139  void drawGL(const GUIVisualizationSettings& s) const;
141 
144  /* @brief method for getting the Attribute of an XML key
145  * @param[in] key The attribute key
146  * @return string with the value associated to key
147  */
148  std::string getAttribute(SumoXMLAttr key) const;
149 
155  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
156 
162  bool isValid(SumoXMLAttr key, const std::string& value);
164 
170  int getVertexIndex(const Position& pos, bool createIfNoExist = true);
171 
173  bool isPolygonClosed() const;
174 
176  void setShapeEditedJunction(GNEJunction* junction);
177 
180 
182  void openPolygon(bool allowUndo = true);
183 
185  void closePolygon(bool allowUndo = true);
186 
188  void changeFirstGeometryPoint(int oldIndex, bool allowUndo = true);
189 
191  void simplifyShape(bool allowUndo = true);
192 
194  void deleteGeometryNear(const Position& pos, bool allowUndo = true);
195 
196 protected:
199 
202 
205 
208 
209 private:
211  static const double myHintSize;
212 
214  void setAttribute(SumoXMLAttr key, const std::string& value);
215 
217  GNEPoly(const GNEPoly&) = delete;
218 
220  GNEPoly& operator=(const GNEPoly&) = delete;
221 };
222 
223 
224 #endif
225 
226 /****************************************************************************/
227 
void openPolygon(bool allowUndo=true)
open polygon
Definition: GNEPoly.cpp:351
GNEPoly(GNENet *net, const std::string &id, const std::string &type, const PositionVector &shape, bool fill, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool movementBlocked, bool shapeBlocked)
Constructor.
Definition: GNEPoly.cpp:71
Stores the information about how to visualize structures.
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(...)
Definition: GNEPoly.cpp:134
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEPoly.cpp:238
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:314
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:92
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition: GNEPoly.h:204
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
GNEJunction * myShapeEditedJunction
junction of which the shape is being edited (optional)
Definition: GNEPoly.h:198
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
void closePolygon(bool allowUndo=true)
close polygon
Definition: GNEPoly.cpp:373
GNEPoly & operator=(const GNEPoly &)=delete
Invalidated assignment operator.
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:60
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEPoly.cpp:170
void writeShape(OutputDevice &device)
writte shape element into a xml file
Definition: GNEPoly.cpp:164
int moveVertexShape(int index, const Position &newPos)
change position of a vertex of shape without commiting change
Definition: GNEPoly.cpp:90
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
static const double myHintSize
hint size of vertex
Definition: GNEPoly.h:211
int myCurrentMovingVertexIndex
index of vertex that is been moved (-1 means that none vertex is been moved)
Definition: GNEPoly.h:207
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEPoly.cpp:560
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:535
const std::string getID() const
function to support debugging
GNEJunction * getShapeEditedJunction() const
retrieve the junction of which the shape is being edited
Definition: GNEPoly.cpp:345
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEPoly.cpp:232
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEPoly.cpp:186
void deleteGeometryNear(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:469
bool isPolygonClosed() const
check if polygon is closed
Definition: GNEPoly.cpp:331
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition: GNEPoly.cpp:437
const std::string & getParentName() const
Returns the name of the parent object.
Definition: GNEPoly.cpp:176
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNEPoly.cpp:226
The popup menu of a globject.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
~GNEPoly()
Destructor.
Definition: GNEPoly.cpp:86
void setShapeEditedJunction(GNEJunction *junction)
retrieve the junction of which the shape is being edited
Definition: GNEPoly.cpp:336
bool myClosedShape
flag to indicate if polygon is open or closed
Definition: GNEPoly.h:201
A window containing a gl-object&#39;s parameter.
std::string getAttribute(SumoXMLAttr key) const
This functions has to be implemented in allGNEAttributeCarrier.
Definition: GNEPoly.cpp:504
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition: GNEPoly.cpp:395
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
Definition: GNEPoly.cpp:117