SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GNEAdditionalSet.h
Go to the documentation of this file.
1 /****************************************************************************/
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software; you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation; either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef GNEAdditionalSet_h
21 #define GNEAdditionalSet_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 "GNEAdditional.h"
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 
40 class PositionVector;
41 class GNEAdditional;
42 class GNENet;
43 class GNEViewNet;
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
48 
54 public:
55 
65  GNEAdditionalSet(const std::string& id, GNEViewNet* viewNet, Position pos, SumoXMLTag tag, bool blocked = false,
66  std::vector<GNEAdditional*> additionalChilds = std::vector<GNEAdditional*>(),
67  std::vector<GNEEdge*> edgeChilds = std::vector<GNEEdge*>(),
68  std::vector<GNELane*> laneChilds = std::vector<GNELane*>());
69 
72 
74  // @note: must be called when geometry changes (i.e. lane moved)
75  virtual void updateGeometry() = 0;
76 
80  virtual void writeAdditional(OutputDevice& device, const std::string& currentDirectory) = 0;
81 
86  bool addAdditionalChild(GNEAdditional* additional);
87 
93 
99  bool addEdgeChild(GNEEdge* edge);
100 
105  bool removeEdgeChild(GNEEdge* edge);
106 
112  bool addLaneChild(GNELane* lane);
113 
118  bool removeLaneChild(GNELane* lane);
119 
121  int getNumberOfAdditionalChilds() const;
122 
124  int getNumberOfEdgeChilds() const;
125 
127  int getNumberOfLaneChilds() const;
128 
130  std::vector<std::string> getAdditionalChildIds() const;
131 
133  std::vector<std::string> getEdgeChildIds() const;
134 
136  std::vector<std::string> getLaneChildIds() const;
137 
140  void setEdgeChilds(std::vector<GNEEdge*> edges);
141 
144  void setLaneChilds(std::vector<GNELane*> lanes);
145 
150  virtual const std::string& getParentName() const = 0;
151 
156  virtual void drawGL(const GUIVisualizationSettings& s) const = 0;
158 
161  /* @brief method for getting the Attribute of an XML key
162  * @param[in] key The attribute key
163  * @return string with the value associated to key
164  */
165  virtual std::string getAttribute(SumoXMLAttr key) const = 0;
166 
167  /* @brief method for setting the attribute and letting the object perform additionalSet changes
168  * @param[in] key The attribute key
169  * @param[in] value The new value
170  * @param[in] undoList The undoList on which to register changes
171  */
172  virtual void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) = 0;
173 
174  /* @brief method for checking if the key and their conrrespond attribute are valids
175  * @param[in] key The attribute key
176  * @param[in] value The value asociated to key key
177  * @return true if the value is valid, false in other case
178  */
179  virtual bool isValid(SumoXMLAttr key, const std::string& value) = 0;
181 
182 protected:
184  struct edgeChild {
186  std::vector<Position> positionsOverLanes;
187  std::vector<SUMOReal> rotationsOverLanes;
188  };
189 
191  struct laneChild {
195  };
196 
198  typedef std::vector<GNEAdditional*> childAdditionals;
199  typedef std::vector<edgeChild> childEdges;
200  typedef std::vector<laneChild> childLanes;
201 
203  std::vector<GNEAdditional*> myChildAdditionals;
204 
206  childEdges myChildEdges;
207 
209  childLanes myChildLanes;
210 
212  std::map<GUIGlObject*, Position> myConnectionMiddlePosition;
213 
216  void updateConnections();
217 
220  void drawConnections() const;
221 
226  void writeAdditionalChildrens(OutputDevice& device, const std::string& currentDirectory);
227 
228 private:
230  virtual void setAttribute(SumoXMLAttr key, const std::string& value) = 0;
231 
234 
237 };
238 
239 
240 #endif
bool removeLaneChild(GNELane *lane)
remove lane element to this set
bool addEdgeChild(GNEEdge *edge)
add edge element to this set
SumoXMLTag
Numbers representing SUMO-XML - element names.
void setLaneChilds(std::vector< GNELane * > lanes)
set lane childs
std::vector< GNEAdditional * > childAdditionals
typedef for containers
bool addLaneChild(GNELane *lane)
add lane element to this set
int getNumberOfAdditionalChilds() const
get number of additional childs of this additionalSet
~GNEAdditionalSet()
Destructor.
virtual std::string getAttribute(SumoXMLAttr key) const =0
Stores the information about how to visualize structures.
childEdges myChildEdges
map of child edges and their positions and rotation
childLanes myChildLanes
list of child lanes and their positions and rotation
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:87
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:55
std::vector< SUMOReal > rotationsOverLanes
GNEAdditionalSet(const std::string &id, GNEViewNet *viewNet, Position pos, SumoXMLTag tag, bool blocked=false, std::vector< GNEAdditional * > additionalChilds=std::vector< GNEAdditional * >(), std::vector< GNEEdge * > edgeChilds=std::vector< GNEEdge * >(), std::vector< GNELane * > laneChilds=std::vector< GNELane * >())
Constructor.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
An Element wich group additionalSet elements.
GNEAdditionalSet & operator=(const GNEAdditionalSet &)
Invalidated assignment operator.
struct for edge childs
bool removeEdgeChild(GNEEdge *edge)
remove edge element to this set
std::map< GUIGlObject *, Position > myConnectionMiddlePosition
map to keep the middle position of connection
void updateConnections()
update connections.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
bool removeAdditionalGeometryChild(GNEAdditional *additional)
remove additional element to this set
A list of positions.
void setEdgeChilds(std::vector< GNEEdge * > edges)
set edge childs
bool addAdditionalChild(GNEAdditional *additional)
add additional element to this set
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
void drawConnections() const
draw connections.
struct for lane childs
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:55
std::vector< GNEAdditional * > myChildAdditionals
list of additional childs (Position and rotations is derived from additional)
int getNumberOfEdgeChilds() const
get number of edge childs of this additionalSet
virtual void writeAdditional(OutputDevice &device, const std::string &currentDirectory)=0
writte additionalSet element into a xml file
std::vector< std::string > getAdditionalChildIds() const
get ids of additional childs
int getNumberOfLaneChilds() const
get number of lane childs of this additionalSet
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:63
virtual void updateGeometry()=0
update pre-computed geometry information
The popup menu of a globject.
std::vector< laneChild > childLanes
void writeAdditionalChildrens(OutputDevice &device, const std::string &currentDirectory)
writte children of this additionalSet
std::vector< std::string > getEdgeChildIds() const
get ids of edge childs
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:214
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes ...
virtual bool isValid(SumoXMLAttr key, const std::string &value)=0
method for checking if the key and their conrrespond attribute are valids
std::vector< std::string > getLaneChildIds() const
get ids of lane childs
std::vector< edgeChild > childEdges
std::vector< Position > positionsOverLanes
virtual const std::string & getParentName() const =0
Returns the name of the parent object (if any)