SUMO - Simulation of Urban MObility
GNENet.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // The lop level container for GNE-network-components such as GNEEdge and
8 // GNEJunction. Contains an internal instances of NBNetBuilder GNE components
9 // wrap netbuild-components of this underlying NBNetBuilder and supply
10 // visualisation and editing capabilities (adapted from GUINet)
11 //
12 // Workflow (rough draft)
13 // wrap NB-components
14 // do netedit stuff
15 // call NBNetBuilder::buildLoaded to save results
16 //
17 /****************************************************************************/
18 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
19 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
20 /****************************************************************************/
21 //
22 // This file is part of SUMO.
23 // SUMO is free software: you can redistribute it and/or modify
24 // it under the terms of the GNU General Public License as published by
25 // the Free Software Foundation, either version 3 of the License, or
26 // (at your option) any later version.
27 //
28 /****************************************************************************/
29 #ifndef GNENet_h
30 #define GNENet_h
31 
32 
33 // ===========================================================================
34 // included modules
35 // ===========================================================================
36 #ifdef _MSC_VER
37 #include <windows_config.h>
38 #else
39 #include <config.h>
40 #endif
41 
42 #include <string>
43 #include <utility>
45 #include <netbuild/NBNetBuilder.h>
46 #include <utils/geom/Boundary.h>
47 #include <utils/geom/Position.h>
54 #include <utils/common/RGBColor.h>
58 #include "GNEDetectorE3.h"
59 
60 
61 // ===========================================================================
62 // class declarations
63 // ===========================================================================
66 class GNEEdge;
67 class GNELane;
68 class GNEJunction;
69 class GNEUndoList;
70 class GNEAdditional;
71 class GNEAdditionalSet;
72 class GNEBusStop;
73 class GNEChargingStation;
74 class GNEDetectorE1;
75 class GNEDetectorE2;
76 class GNEDetectorE3;
77 class GNEDetectorE3EntryExit;
78 
79 // ===========================================================================
80 // class definitions
81 // ===========================================================================
86 class GNENet : public GUIGlObject {
87 
89  friend class GNEChange_Junction;
90  friend class GNEChange_Edge;
91  friend class GNEChange_Connection;
92 
93 public:
95  static const RGBColor selectionColor;
96 
99 
104  GNENet(NBNetBuilder* netBuilder);
105 
107  ~GNENet();
108 
111 
119 
128 
135 
137  const Boundary& getZBoundary() const;
138 
143  void drawGL(const GUIVisualizationSettings& s) const;
145 
147  const Boundary& getBoundary() const;
148 
152 
155  const SUMORTree& getVisualisationSpeedUp() const;
156 
162  GNEJunction* createJunction(const Position& pos, GNEUndoList* undoList);
163 
175  GNEEdge* createEdge(GNEJunction* src, GNEJunction* dest, GNEEdge* tpl, GNEUndoList* undoList,
176  const std::string& suggestedName = "", bool wasSplit = false, bool allowDuplicateGeom = false);
177 
182  void deleteJunction(GNEJunction* junction, GNEUndoList* undoList);
183 
188  void deleteEdge(GNEEdge* edge, GNEUndoList* undoList);
189 
194  void deleteLane(GNELane* lane, GNEUndoList* undoList);
195 
200  void duplicateLane(GNELane* lane, GNEUndoList* undoList);
201 
208  void deleteGeometryOrEdge(GNEEdge* edge, const Position& pos, GNEUndoList* undoList);
209 
215  GNEJunction* splitEdge(GNEEdge* edge, const Position& pos, GNEUndoList* undoList, GNEJunction* newJunction = 0);
216 
221  void splitEdgesBidi(const std::set<GNEEdge*>& edges, const Position& pos, GNEUndoList* undoList);
222 
226  void reverseEdge(GNEEdge* edge, GNEUndoList* undoList);
227 
232  GNEEdge* addReversedEdge(GNEEdge* edge, GNEUndoList* undoList);
233 
240  void mergeJunctions(GNEJunction* moved, GNEJunction* target, GNEUndoList* undoList);
241 
247  GNEJunction* retrieveJunction(const std::string& id, bool failHard = true);
248 
254  GNEEdge* retrieveEdge(const std::string& id, bool failHard = true);
255 
261  std::vector<GNEAttributeCarrier*> retrieveAttributeCarriers(const std::set<GUIGlID>& ids, GUIGlObjectType type);
262 
266  std::vector<GNEEdge*> retrieveEdges(bool onlySelected = false);
267 
271  std::vector<GNELane*> retrieveLanes(bool onlySelected = false);
272 
278  GNELane* retrieveLane(const std::string& id, bool failHard = true);
279 
283  std::vector<GNEJunction*> retrieveJunctions(bool onlySelected = false);
284 
288  void save(OptionsCont& oc);
289 
293  void saveAdditionals(const std::string& filename);
294 
298  void savePlain(OptionsCont& oc);
299 
303  void saveJoined(OptionsCont& oc);
304 
306  void setUpdateTarget(FXWindow* updateTarget);
307 
309  void refreshElement(GUIGlObject* o);
310 
312  void renameEdge(GNEEdge* edge, const std::string& newID);
313 
315  void renameJunction(GNEJunction* junction, const std::string& newID);
316 
318  void changeEdgeEndpoints(GNEEdge* edge, const std::string& newSourceID, const std::string& newDestID);
319 
322 
323  /* @brief get ids of currently active objects
324  * param[in] type If type != GLO_MAX, get active ids of that type, otherwise get all active ids
325  */
326  std::set<GUIGlID> getGlIDs(GUIGlObjectType type = GLO_MAX);
327 
329  void computeAndUpdate(OptionsCont& oc);
330 
331  /* @brief trigger full netbuild computation
332  * param[in] window The window to inform about delay
333  * param[in] force Whether to force recomputation even if not needed
334  */
335  void computeEverything(GNEApplicationWindow* window, bool force = false);
336 
337  /* @brief join selected junctions
338  * @note difference to mergeJunctions:
339  * - can join more than 2
340  * - connected edges will keep their geometry (big junction shape is created)
341  * - no hirarchy: if any junction has a traffic light than the resuling junction will
342  */
343  void joinSelectedJunctions(GNEUndoList* undoList);
344 
345  /* @brief removes junctions that have no edges
346  */
347  void removeSolitaryJunctions(GNEUndoList* undoList);
348 
349  /* @brief replace the selected junction by geometry node(s)
350  * and merge the edges
351  */
352  void replaceJunctionByGeometry(GNEJunction* junction, GNEUndoList* undoList);
353 
354  /* @brief trigger recomputation of junction shape and logic
355  * param[in] window The window to inform about delay
356  */
357  void computeJunction(GNEJunction* junction);
358 
360  void requireRecompute();
361 
363  FXApp* getApp();
364 
366  void addExplicitTurnaround(std::string id);
367 
369  void removeExplicitTurnaround(std::string id);
370 
373  void moveSelection(const Position& moveSrc, const Position& moveDest);
374 
376  void finishMoveSelection(GNEUndoList* undoList);
377 
380 
385  void insertAdditional(GNEAdditional* additional, bool hardFail = true);
386 
390  void deleteAdditional(GNEAdditional* additional);
391 
394  void updateAdditionalID(const std::string& oldID, GNEAdditional* additional);
395 
401  GNEAdditional* getAdditional(SumoXMLTag type, const std::string& id) const;
402 
409  std::string getAdditionalID(SumoXMLTag type, const GNELane* lane, const SUMOReal pos) const;
410 
415  std::vector<GNEAdditional*> getAdditionals(SumoXMLTag type = SUMO_TAG_NOTHING);
416 
422 
423 protected:
426 
428  FXWindow* myUpdateTarget;
429 
432 
435  typedef std::map<std::string, GNEJunction*> GNEJunctions;
436  typedef std::map<std::string, GNEEdge*> GNEEdges;
437  typedef std::map<std::pair<std::string, SumoXMLTag>, GNEAdditional*> GNEAdditionals;
438  // @}
439 
441  GNEJunctions myJunctions;
442 
444  GNEEdges myEdges;
445 
447  GNEAdditionals myAdditionals;
448 
450  // @{
453  // @}
454 
457 
459  std::set<std::string> myExplicitTurnarounds;
460 
463 
464 private:
466  void initDetectors();
467 
469  void initTLMap();
470 
472  void insertJunction(GNEJunction* junction);
473 
475  void insertEdge(GNEEdge* edge);
476 
477 
478 
481 
483  GNEEdge* registerEdge(GNEEdge* edge);
484 
486  void deleteSingleJunction(GNEJunction* junction);
487 
489  void deleteSingleEdge(GNEEdge* edge);
490 
492  void update();
493 
495  void reserveEdgeID(const std::string& id);
496 
498  void reserveJunctionID(const std::string& id);
499 
500  /* @brief helper function for changing the endpoints of a junction
501  * @param[in] keepEndpoints Whether to keep the original edge endpoints (influences junction shape)
502  */
503  void remapEdge(GNEEdge* oldEdge, GNEJunction* from, GNEJunction* to, GNEUndoList* undoList, bool keepEndpoints = false);
504 
507 
509  static const SUMOReal Z_INITIALIZED;
510 };
511 
512 #endif
513 
514 /****************************************************************************/
GNEJunction * splitEdge(GNEEdge *edge, const Position &pos, GNEUndoList *undoList, GNEJunction *newJunction=0)
split edge at position by inserting a new junction
Definition: GNENet.cpp:409
void computeAndUpdate(OptionsCont &oc)
recompute the network and update lane geometries
Definition: GNENet.cpp:1235
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
Definition: GNENet.cpp:678
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNENet.cpp:189
ShapeContainer & getShapeContainer()
get shape container
Definition: GNENet.cpp:1040
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
Definition: GNENet.cpp:643
SumoXMLTag
Numbers representing SUMO-XML - element names.
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:616
IDSupplier myEdgeIDSupplier
Definition: GNENet.h:451
SUMORTree myGrid
the rtree which contains all GUIGlObjects (so named for historical reasons)
Definition: GNENet.h:425
void joinSelectedJunctions(GNEUndoList *undoList)
Definition: GNENet.cpp:852
GUIGlObjectType
FXApp * getApp()
get pointer to the main App
Definition: GNENet.cpp:846
Storage for geometrical objects extended by mutexes.
void refreshElement(GUIGlObject *o)
refreshes boundary information for o and update
Definition: GNENet.cpp:690
GNEAdditionals myAdditionals
map with the name and pointer to additional elements of net
Definition: GNENet.h:447
The main window of the Netedit.
static const RGBColor selectedLaneColor
color of selected lane
Definition: GNENet.h:98
A container for traffic light definitions and built programs.
Stores the information about how to visualize structures.
std::set< GUIGlID > getGlIDs(GUIGlObjectType type=GLO_MAX)
Definition: GNENet.cpp:740
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNENet.cpp:211
void computeEverything(GNEApplicationWindow *window, bool force=false)
Definition: GNENet.cpp:799
void reverseEdge(GNEEdge *edge, GNEUndoList *undoList)
reverse edge
Definition: GNENet.cpp:474
void update()
notify myUpdateTarget
Definition: GNENet.cpp:1215
void insertJunction(GNEJunction *junction)
inserts a single junction into the net and into the underlying netbuild-container ...
Definition: GNENet.cpp:1143
void splitEdgesBidi(const std::set< GNEEdge * > &edges, const Position &pos, GNEUndoList *undoList)
split all edges at position by inserting one new junction
Definition: GNENet.cpp:463
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:86
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:54
GNEEdge * createEdge(GNEJunction *src, GNEJunction *dest, GNEEdge *tpl, GNEUndoList *undoList, const std::string &suggestedName="", bool wasSplit=false, bool allowDuplicateGeom=false)
creates a new edge (unless an edge with the same geometry already exists)
Definition: GNENet.cpp:246
void addExplicitTurnaround(std::string id)
add edge id to the list of explicit turnarounds
Definition: GNENet.cpp:974
GUIShapeContainer myShapeContainer
the container for additional pois and polygons
Definition: GNENet.h:456
Storage for geometrical objects.
void insertEdge(GNEEdge *edge)
inserts a single edge into the net and into the underlying netbuild-container
Definition: GNENet.cpp:1150
An Element wich group additionalSet elements.
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList)
removes edge
Definition: GNENet.cpp:326
A RT-tree for efficient storing of SUMO&#39;s GL-objects.
Definition: SUMORTree.h:74
std::string getAdditionalID(SumoXMLTag type, const GNELane *lane, const SUMOReal pos) const
Returns the additional close to the given position.
Definition: GNENet.cpp:1105
void remapEdge(GNEEdge *oldEdge, GNEJunction *from, GNEJunction *to, GNEUndoList *undoList, bool keepEndpoints=false)
Definition: GNENet.cpp:542
GNEJunction * registerJunction(GNEJunction *junction)
registers a junction with GNENet containers
Definition: GNENet.cpp:1162
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
bool myNeedRecompute
whether the net needs recomputation
Definition: GNENet.h:462
NBNetBuilder * myNetBuilder
The internal netbuilder.
Definition: GNENet.h:431
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GNENet.cpp:182
void renameJunction(GNEJunction *junction, const std::string &newID)
updates the map and reserves new id
Definition: GNENet.cpp:965
IDSupplier myJunctionIDSupplier
Definition: GNENet.h:452
void updateAdditionalID(const std::string &oldID, GNEAdditional *additional)
update additional ID in container
Definition: GNENet.cpp:1082
std::map< std::string, GNEJunction * > GNEJunctions
Definition: GNENet.h:435
FXWindow * myUpdateTarget
The window to be notofied of about changes.
Definition: GNENet.h:428
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNENet.cpp:200
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
GNEJunction * retrieveJunction(const std::string &id, bool failHard=true)
get junction by id
Definition: GNENet.cpp:603
GNEJunctions myJunctions
map with the name and pointer to junctions of net
Definition: GNENet.h:441
GNELane * retrieveLane(const std::string &id, bool failHard=true)
get lane by id
Definition: GNENet.cpp:658
Boundary myZBoundary
the z boundary (stored in the x-coordinate), values of 0 are ignored
Definition: GNENet.h:506
void deleteLane(GNELane *lane, GNEUndoList *undoList)
removes lane
Definition: GNENet.cpp:361
void deleteGeometryOrEdge(GNEEdge *edge, const Position &pos, GNEUndoList *undoList)
removes geometry when pos is close to a geometry node, deletes the whole edge otherwise ...
Definition: GNENet.cpp:401
std::vector< GNEAdditional * > getAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING)
get vector with additionals
Definition: GNENet.cpp:1116
void computeJunction(GNEJunction *junction)
Definition: GNENet.cpp:821
A lane area vehicles can halt at (netedit-version)
Definition: GNEBusStop.h:58
int getNumberOfAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING)
Returns the number of additionals of the net.
Definition: GNENet.cpp:1128
void save(OptionsCont &oc)
save the network
Definition: GNENet.cpp:557
std::vector< GNEAttributeCarrier * > retrieveAttributeCarriers(const std::set< GUIGlID > &ids, GUIGlObjectType type)
get the attribute carriers based on GlIDs
Definition: GNENet.cpp:698
void moveSelection(const Position &moveSrc, const Position &moveDest)
move all selected junctions and edges
Definition: GNENet.cpp:986
GNEJunction * createJunction(const Position &pos, GNEUndoList *undoList)
creates a new junction
Definition: GNENet.cpp:235
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GNENet.cpp:223
std::set< std::string > myExplicitTurnarounds
list of edge ids for which turn-arounds must be added explicitly
Definition: GNENet.h:459
void replaceJunctionByGeometry(GNEJunction *junction, GNEUndoList *undoList)
Definition: GNENet.cpp:919
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:54
void reserveJunctionID(const std::string &id)
reserve junction ID (To avoid duplicates)
Definition: GNENet.cpp:1229
GNEAdditional * getAdditional(SumoXMLTag type, const std::string &id) const
Returns the named additional.
Definition: GNENet.cpp:1093
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNENet.cpp:206
void deleteSingleJunction(GNEJunction *junction)
deletes a single junction
Definition: GNENet.cpp:1191
~GNENet()
Destructor.
Definition: GNENet.cpp:151
const Boundary & getZBoundary() const
Returns the Z boundary (stored in the x() coordinate) values of 0 do not affect the boundary...
Definition: GNENet.cpp:217
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:631
GNEEdge * registerEdge(GNEEdge *edge)
registers an edge with GNENet containers
Definition: GNENet.cpp:1179
GNENet(NBNetBuilder *netBuilder)
Constructor.
Definition: GNENet.cpp:94
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:63
Instance responsible for building networks.
Definition: NBNetBuilder.h:112
void removeSolitaryJunctions(GNEUndoList *undoList)
Definition: GNENet.cpp:902
A storage for options typed value containers)
Definition: OptionsCont.h:99
The popup menu of a globject.
void initTLMap()
Initialises the tl-logic map and wrappers.
void renameEdge(GNEEdge *edge, const std::string &newID)
updates the map and reserves new id
Definition: GNENet.cpp:940
void deleteJunction(GNEJunction *junction, GNEUndoList *undoList)
removes junction and all incident edges
Definition: GNENet.cpp:301
void initDetectors()
Initialises the detector wrappers.
void removeExplicitTurnaround(std::string id)
remove edge id from the list of explicit turnarounds
Definition: GNENet.cpp:980
void saveJoined(OptionsCont &oc)
save log of joined junctions (and nothing else)
Definition: GNENet.cpp:590
void deleteAdditional(GNEAdditional *additional)
delete additional element previously inserted
Definition: GNENet.cpp:1065
GNEEdge * addReversedEdge(GNEEdge *edge, GNEUndoList *undoList)
add reversed edge
Definition: GNENet.cpp:485
void setUpdateTarget(FXWindow *updateTarget)
Set the target to be notified of network changes.
Definition: GNENet.cpp:597
#define SUMOReal
Definition: config.h:213
GNEEdges myEdges
map with the name and pointer to edges of net
Definition: GNENet.h:444
std::map< std::pair< std::string, SumoXMLTag >, GNEAdditional * > GNEAdditionals
Definition: GNENet.h:437
static const RGBColor selectionColor
color of selection
Definition: GNENet.h:95
empty max
void reserveEdgeID(const std::string &id)
reserve edge ID (To avoid duplicates)
Definition: GNENet.cpp:1223
void deleteSingleEdge(GNEEdge *edge)
deletes a single edge
Definition: GNENet.cpp:1202
std::map< std::string, GNEEdge * > GNEEdges
Definition: GNENet.h:436
void mergeJunctions(GNEJunction *moved, GNEJunction *target, GNEUndoList *undoList)
merge the given junctions edges between the given junctions will be deleted
Definition: GNENet.cpp:518
void insertAdditional(GNEAdditional *additional, bool hardFail=true)
Insert a additional element previously created in GNEAdditionalHandler.
Definition: GNENet.cpp:1046
A window containing a gl-object&#39;s parameter.
void changeEdgeEndpoints(GNEEdge *edge, const std::string &newSourceID, const std::string &newDestID)
modifies endpoins of the given edge
Definition: GNENet.cpp:949
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition: GNENet.cpp:959
void saveAdditionals(const std::string &filename)
save additional elements of the network
Definition: GNENet.cpp:564
void savePlain(OptionsCont &oc)
save plain xml representation of the network (and nothing else)
Definition: GNENet.cpp:583
void requireRecompute()
inform the net about the need for recomputation
Definition: GNENet.cpp:840
static const SUMOReal Z_INITIALIZED
marker for whether the z-boundary is initialized
Definition: GNENet.h:509
void duplicateLane(GNELane *lane, GNEUndoList *undoList)
duplicates lane
Definition: GNENet.cpp:389
void finishMoveSelection(GNEUndoList *undoList)
register changes to junction and edge positions with the undoList
Definition: GNENet.cpp:1016