SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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-2016 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 "GNENetElement.h"
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class GeoConvHelper;
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
51 class GNEPoly : public GUIPolygon, public GNEAttributeCarrier {
52 
54  //friend class GNEChange_POI
55 
56 public:
57  class GNEPolyHandler : public SUMOSAXHandler {
58  public:
60  GNEPolyHandler(GNENet* net);
61 
63  virtual ~GNEPolyHandler();
64 
67 
74  virtual void myStartElement(int element, const SUMOSAXAttributes& attrs);
75 
82  virtual void myEndElement(int element);
84 
85  int getNumLoaded() {
86  return myNumLoaded;
87  }
88 
89  private:
91 
94 
97 
98  private:
99  void loadPOI(const SUMOSAXAttributes& attrs);
100  };
101 
102 public:
105  GNEPoly(GNENet* net, GNEJunction* junction, const std::string& id, const std::string& type, const PositionVector& shape, bool fill,
106  const RGBColor& color, SUMOReal layer,
107  SUMOReal angle = 0, const std::string& imgFile = "");
108 
110  virtual ~GNEPoly();
111 
114 
123  GUISUMOAbstractView& parent);
124 
125 
130  void drawGL(const GUIVisualizationSettings& s) const;
132 
133 
135 
144  Position moveGeometry(const Position& oldPos, const Position& newPos, bool relative = false);
145 
147  void simplifyShape();
148 
150  void deleteGeometryNear(const Position& pos);
151 
154  return myJunction;
155  }
156 
157 
159  //void registerMove(GNEUndoList *undoList);
160 
161 
164  std::string getAttribute(SumoXMLAttr key) const;
165 
166  /* @brief method for setting the attribute and letting the object perform additional changes
167  * @param[in] key The attribute key
168  * @param[in] value The new value
169  * @param[in] undoList The undoList on which to register changes
170  */
171  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
172 
173  bool isValid(SumoXMLAttr key, const std::string& value);
175 
177  static void loadFromFile(const std::string& file, GNENet* net);
178 
180  static void saveToFile(const std::string& file);
181 
182 protected:
185 
188 
189 private:
191  GNEPoly(const GNEPoly&);
192 
194  GNEPoly& operator=(const GNEPoly&);
195 
196  void setAttribute(SumoXMLAttr key, const std::string& value);
197 
198 };
199 
200 
201 #endif
202 
203 /****************************************************************************/
204 
Position moveGeometry(const Position &oldPos, const Position &newPos, bool relative=false)
draw the polygon and also little movement handles
Definition: GNEPoly.cpp:126
static void saveToFile(const std::string &file)
save POIs to file
GNEPoly & operator=(const GNEPoly &)
Invalidated assignment operator.
Stores the information about how to visualize structures.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEPoly.cpp:88
GNEPolyHandler(GNENet *net)
constructor
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:87
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
SAX-handler base for SUMO-files.
GeoConvHelper * myLocation
The coordinate transformation which was used compute the POI coordinates.
Definition: GNEPoly.h:93
static void loadFromFile(const std::string &file, GNENet *net)
load POIs from file
GNENet * myNet
the net for querying updates
Definition: GNEPoly.h:184
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:60
Encapsulated SAX-Attributes.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
void loadPOI(const SUMOSAXAttributes &attrs)
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNEPoly.cpp:219
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEPoly.cpp:183
GNEPoly(GNENet *net, GNEJunction *junction, const std::string &id, const std::string &type, const PositionVector &shape, bool fill, const RGBColor &color, SUMOReal layer, SUMOReal angle=0, const std::string &imgFile="")
Constructor.
Definition: GNEPoly.cpp:74
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEPoly.cpp:111
GNEJunction * myJunction
junction of which the shape is being edited (optional)
Definition: GNEPoly.h:187
The popup menu of a globject.
void simplifyShape()
replace the current shape with a rectangle
Definition: GNEPoly.cpp:140
declare friend class
Definition: GNEPoly.h:57
int myNumLoaded
number of loaded pois
Definition: GNEPoly.h:96
virtual void myEndElement(int element)
Called when a closing tag occurs.
virtual ~GNEPoly()
Destructor.
Definition: GNEPoly.cpp:84
#define SUMOReal
Definition: config.h:214
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
GNEJunction * getEditedJunction() const
retrieve the junction of which the shape is being edited
Definition: GNEPoly.h:153
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEPoly.cpp:168
void deleteGeometryNear(const Position &pos)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:152