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-2015 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 <string>
35 #include <utility>
38 
39 #include "GNEAttributeCarrier.h"
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class GeoConvHelper;
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
57 class GNEPoly : public GUIPolygon, public GNEAttributeCarrier {
58 
59  //friend class GNEChange_POI;
60 public:
61  class GNEPolyHandler : public SUMOSAXHandler {
62  public:
63 
64  GNEPolyHandler(GNENet* net);
65  virtual ~GNEPolyHandler();
67 
68 
76  virtual void myStartElement(int element,
77  const SUMOSAXAttributes& attrs);
78 
79 
86  virtual void myEndElement(int element);
88 
89  int getNumLoaded() {
90  return myNumLoaded;
91  }
92 
93  private:
95 
98 
101 
102  private:
103  void loadPOI(const SUMOSAXAttributes& attrs);
104  };
105 
106 public:
109  GNEPoly(GNENet* net, GNEJunction* junction, const std::string& id, const std::string& type, const PositionVector& shape, bool fill,
110  const RGBColor& color, SUMOReal layer,
111  SUMOReal angle = 0, const std::string& imgFile = "");
112 
114  virtual ~GNEPoly() ;
115 
117 
118 
127  GUISUMOAbstractView& parent) ;
128 
129 
134  void drawGL(const GUIVisualizationSettings& s) const ;
136 
137 
139 
148  Position moveGeometry(const Position& oldPos, const Position& newPos, bool relative = false);
149 
151  void simplifyShape();
152 
154  void deleteGeometryNear(const Position& pos);
155 
158  return myJunction;
159  }
160 
161 
163  //void registerMove(GNEUndoList *undoList);
164 
165 
166  //@name inherited from GNEAttributeCarrier
168  std::string getAttribute(SumoXMLAttr key) const;
169 
170  /* @brief method for setting the attribute and letting the object perform additional changes
171  * @param[in] key The attribute key
172  * @param[in] value The new value
173  * @param[in] undoList The undoList on which to register changes
174  */
175  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
176 
177  bool isValid(SumoXMLAttr key, const std::string& value);
179 
181  static void loadFromFile(const std::string& file, GNENet* net);
182 
184  static void saveToFile(const std::string& file);
185 
186 protected:
189 
192 
193 private:
195  GNEPoly(const GNEPoly&);
196 
198  GNEPoly& operator=(const GNEPoly&);
199 
200  void setAttribute(SumoXMLAttr key, const std::string& value);
201 
202 };
203 
204 
205 #endif
206 
207 /****************************************************************************/
208 
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
Stores the information about how to visualize structures.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEPoly.cpp:88
GNEPolyHandler(GNENet *net)
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
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:97
static void loadFromFile(const std::string &file, GNENet *net)
load POIs from file
GNENet * myNet
the net for querying updates
Definition: GNEPoly.h:188
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:191
const SUMOSAXHandler & operator=(const SUMOSAXHandler &s)
invalidated assignment operator
The popup menu of a globject.
void simplifyShape()
replace the current shape with a rectangle
Definition: GNEPoly.cpp:140
int myNumLoaded
number of loaded pois
Definition: GNEPoly.h:100
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:157
std::string getAttribute(SumoXMLAttr key) const
registers completed movement with the undoList
Definition: GNEPoly.cpp:168
void deleteGeometryNear(const Position &pos)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:152