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 /****************************************************************************/
14 // A class for visualizing and editing POIS in netedit (adapted from
15 // GUIPolygon and NLHandler)
16 /****************************************************************************/
17 #ifndef GNEPoly_h
18 #define GNEPoly_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 
26 
27 #include "GNEShape.h"
28 
29 // ===========================================================================
30 // class declarations
31 // ===========================================================================
32 class GeoConvHelper;
33 class GNENetElement;
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
45 class GNEPoly : public GUIPolygon, public GNEShape {
46 
47 public:
49  using GNEShape::getID;
50 
67  GNEPoly(GNENet* net, const std::string& id, const std::string& type, const PositionVector& shape, bool geo, bool fill, double lineWidth,
68  const RGBColor& color, double layer, double angle, const std::string& imgFile, bool relativePath, bool movementBlocked, bool shapeBlocked);
69 
71  ~GNEPoly();
72 
74  std::string generateChildID(SumoXMLTag childTag);
75 
79  void startGeometryMoving();
80 
82  void endGeometryMoving();
83 
89  int moveVertexShape(const int index, const Position& oldPos, const Position& offset);
90 
95  void moveEntireShape(const PositionVector& oldShape, const Position& offset);
96 
101  void commitShapeChange(const PositionVector& oldShape, GNEUndoList* undoList);
103 
107  void updateGeometry();
108 
111 
115  void writeShape(OutputDevice& device);
116 
118  Position getPositionInView() const;
119 
121  GUIGlID getGlID() const;
123 
126 
129  std::string getParentName() const;
130 
139 
148 
153  void drawGL(const GUIVisualizationSettings& s) const;
155 
158  /* @brief method for getting the Attribute of an XML key
159  * @param[in] key The attribute key
160  * @return string with the value associated to key
161  */
162  std::string getAttribute(SumoXMLAttr key) const;
163 
169  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
170 
176  bool isValid(SumoXMLAttr key, const std::string& value);
177 
178  /* @brief method for check if the value for certain attribute is set
179  * @param[in] key The attribute key
180  */
181  bool isAttributeEnabled(SumoXMLAttr key) const;
183 
190  int getVertexIndex(Position pos, bool createIfNoExist, bool snapToGrid);
191 
193  void deleteGeometryPoint(const Position& pos, bool allowUndo = true);
194 
196  bool isPolygonBlocked() const;
197 
199  bool isPolygonClosed() const;
200 
202  void setShapeEditedElement(GNENetElement* element);
203 
206 
208  void openPolygon(bool allowUndo = true);
209 
211  void closePolygon(bool allowUndo = true);
212 
214  void changeFirstGeometryPoint(int oldIndex, bool allowUndo = true);
215 
217  void simplifyShape(bool allowUndo = true);
218 
219 protected:
222 
225 
228 
231 
234 
237 
238 private:
240  static const double myHintSize;
241 
243  void setAttribute(SumoXMLAttr key, const std::string& value);
244 
246  const GUIGlObject* getGUIGlObject() const;
247 
249  GNEPoly(const GNEPoly&) = delete;
250 
252  GNEPoly& operator=(const GNEPoly&) = delete;
253 };
254 
255 
256 #endif
257 
258 /****************************************************************************/
259 
GNEPoly::getCenteringBoundary
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEPoly.cpp:204
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:62
GNEAttributeCarrier::getID
const std::string getID() const
function to support debugging
Definition: GNEAttributeCarrier.cpp:1289
GNEPoly::getParentName
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEPoly.cpp:221
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
GNEPoly::openPolygon
void openPolygon(bool allowUndo=true)
open polygon
Definition: GNEPoly.cpp:496
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
GNENet
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
GUIPolygon.h
GNEPoly::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNEPoly.cpp:187
GNEPoly::generateChildID
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
Definition: GNEPoly.cpp:71
GNEPoly
Definition: GNEPoly.h:45
GNEPoly::mySimplifiedShape
bool mySimplifiedShape
flag to indicate if polygon is simplified
Definition: GNEPoly.h:233
GNEPoly::isPolygonClosed
bool isPolygonClosed() const
check if polygon is closed
Definition: GNEPoly.cpp:474
GNEPoly::commitShapeChange
void commitShapeChange(const PositionVector &oldShape, GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of changeShapeGeometry(....
Definition: GNEPoly.cpp:153
GNEPoly::myGeoShape
PositionVector myGeoShape
Latitude of Polygon.
Definition: GNEPoly.h:224
GNEPoly::GNEPoly
GNEPoly(const GNEPoly &)=delete
Invalidated copy constructor.
GNEPoly::GNEPoly
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:46
PositionVector
A list of positions.
Definition: PositionVector.h:45
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:47
GeoConvHelper
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:55
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:41
GNEPoly::myNetElementShapeEdited
GNENetElement * myNetElementShapeEdited
junction of which the shape is being edited (optional)
Definition: GNEPoly.h:221
GNEPoly::isPolygonBlocked
bool isPolygonBlocked() const
return true if polygon is blocked
Definition: GNEPoly.cpp:468
RGBColor
Definition: RGBColor.h:39
GNEPoly::closePolygon
void closePolygon(bool allowUndo=true)
close polygon
Definition: GNEPoly.cpp:518
GNEShape
Definition: GNEShape.h:34
GNEPoly::myHintSize
static const double myHintSize
hint size of vertex
Definition: GNEPoly.h:240
GNEPoly::myCurrentMovingVertexIndex
int myCurrentMovingVertexIndex
index of vertex that is been moved (-1 means that none vertex is been moved)
Definition: GNEPoly.h:236
GNEPoly::operator=
GNEPoly & operator=(const GNEPoly &)=delete
Invalidated assignment operator.
GNEPoly::startGeometryMoving
void startGeometryMoving()
Definition: GNEPoly.cpp:81
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GNEPoly::writeShape
void writeShape(OutputDevice &device)
writte shape element into a xml file
Definition: GNEPoly.cpp:192
GNEPoly::deleteGeometryPoint
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:431
GNEPoly::setAttribute
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:667
GNENetElement
Definition: GNENetElement.h:43
GUIGlObject
Definition: GUIGlObject.h:65
GNEPoly::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEPoly.cpp:620
GNEPoly::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEPoly.cpp:231
GNEPoly::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEPoly.cpp:277
GNEShape.h
GNEPoly::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEPoly.cpp:698
GNEPoly::moveVertexShape
int moveVertexShape(const int index, const Position &oldPos, const Position &offset)
change position of a vertex of shape without commiting change
Definition: GNEPoly.cpp:102
GNEPoly::getGUIGlObject
const GUIGlObject * getGUIGlObject() const
get GUIGlObject associated to this GNEShape
Definition: GNEPoly.cpp:901
GUIMainWindow
Definition: GUIMainWindow.h:46
GUIGlID
unsigned int GUIGlID
Definition: GUIGlObject.h:42
GNEPoly::setShapeEditedElement
void setShapeEditedElement(GNENetElement *element)
retrieve the netElement of which the shape is being edited
Definition: GNEPoly.cpp:480
GNEPoly::simplifyShape
void simplifyShape(bool allowUndo=true)
replace the current shape with a rectangle
Definition: GNEPoly.cpp:582
GNEPoly::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEPoly.cpp:198
GNEPoly::~GNEPoly
~GNEPoly()
Destructor.
Definition: GNEPoly.cpp:67
GNEPoly::getGlID
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GNEPoly.cpp:215
GNEPoly::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNEPoly.cpp:271
GNEPoly::getShapeEditedElement
GNENetElement * getShapeEditedElement() const
retrieve the junction of which the shape is being edited
Definition: GNEPoly.cpp:490
GNEUndoList
Definition: GNEUndoList.h:48
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GNEPoly::myBlockShape
bool myBlockShape
flag for block shape
Definition: GNEPoly.h:227
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
GNEPoly::getVertexIndex
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's edge
Definition: GNEPoly.cpp:410
GNEPoly::moveEntireShape
void moveEntireShape(const PositionVector &oldShape, const Position &offset)
move entire shape without commiting change
Definition: GNEPoly.cpp:137
GNEPoly::myClosedShape
bool myClosedShape
flag to indicate if polygon is open or closed
Definition: GNEPoly.h:230
GUIPolygon
Definition: GUIPolygon.h:41
GNEPoly::endGeometryMoving
void endGeometryMoving()
begin movement (used when user click over edge to start a movement, to avoid problems with problems w...
Definition: GNEPoly.cpp:88
GNEPoly::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEPoly.cpp:766
GNEPoly::changeFirstGeometryPoint
void changeFirstGeometryPoint(int oldIndex, bool allowUndo=true)
change first geometry point
Definition: GNEPoly.cpp:540