SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 class GNEConnection;
79 
80 // ===========================================================================
81 // class definitions
82 // ===========================================================================
87 class GNENet : public GUIGlObject {
88 
90  friend class GNEChange_Junction;
91  friend class GNEChange_Edge;
92  friend class GNEChange_Connection;
93 
94 public:
96  static const RGBColor selectionColor;
97 
100 
103 
108  GNENet(NBNetBuilder* netBuilder);
109 
111  ~GNENet();
112 
115 
123 
132 
139 
141  const Boundary& getZBoundary() const;
142 
147  void drawGL(const GUIVisualizationSettings& s) const;
149 
151  const Boundary& getBoundary() const;
152 
156 
159  const SUMORTree& getVisualisationSpeedUp() const;
160 
166  GNEJunction* createJunction(const Position& pos, GNEUndoList* undoList);
167 
179  GNEEdge* createEdge(GNEJunction* src, GNEJunction* dest, GNEEdge* tpl, GNEUndoList* undoList,
180  const std::string& suggestedName = "", bool wasSplit = false, bool allowDuplicateGeom = false);
181 
186  void deleteJunction(GNEJunction* junction, GNEUndoList* undoList);
187 
192  void deleteEdge(GNEEdge* edge, GNEUndoList* undoList);
193 
198  void deleteLane(GNELane* lane, GNEUndoList* undoList);
199 
204  void deleteConnection(GNEConnection* connection, GNEUndoList* undoList);
205 
210  void duplicateLane(GNELane* lane, GNEUndoList* undoList);
211 
217  bool restrictLane(SUMOVehicleClass vclass, GNELane* lane, GNEUndoList* undoList);
218 
223  bool revertLaneRestriction(GNELane* lane, GNEUndoList* undoList);
224 
230  bool addSRestrictedLane(SUMOVehicleClass vclass, GNEEdge& edge, GNEUndoList* undoList);
231 
237  bool removeRestrictedLane(SUMOVehicleClass vclass, GNEEdge& edge, GNEUndoList* undoList);
238 
245  void deleteGeometryOrEdge(GNEEdge* edge, const Position& pos, GNEUndoList* undoList);
246 
252  GNEJunction* splitEdge(GNEEdge* edge, const Position& pos, GNEUndoList* undoList, GNEJunction* newJunction = 0);
253 
258  void splitEdgesBidi(const std::set<GNEEdge*>& edges, const Position& pos, GNEUndoList* undoList);
259 
263  void reverseEdge(GNEEdge* edge, GNEUndoList* undoList);
264 
269  GNEEdge* addReversedEdge(GNEEdge* edge, GNEUndoList* undoList);
270 
277  void mergeJunctions(GNEJunction* moved, GNEJunction* target, GNEUndoList* undoList);
278 
284  GNEJunction* retrieveJunction(const std::string& id, bool failHard = true);
285 
291  GNEEdge* retrieveEdge(const std::string& id, bool failHard = true);
292 
298  std::vector<GNEAttributeCarrier*> retrieveAttributeCarriers(const std::set<GUIGlID>& ids, GUIGlObjectType type);
299 
303  std::vector<GNEEdge*> retrieveEdges(bool onlySelected = false);
304 
308  std::vector<GNELane*> retrieveLanes(bool onlySelected = false);
309 
315  GNELane* retrieveLane(const std::string& id, bool failHard = true);
316 
320  std::vector<GNEJunction*> retrieveJunctions(bool onlySelected = false);
321 
325  void save(OptionsCont& oc);
326 
330  void saveAdditionals(const std::string& filename);
331 
335  void savePlain(OptionsCont& oc);
336 
340  void saveJoined(OptionsCont& oc);
341 
343  void setViewNet(GNEViewNet* viewNet);
344 
346  void refreshElement(GUIGlObject* o);
347 
350  void refreshAdditional(GNEAdditional* additional);
351 
353  void renameEdge(GNEEdge* edge, const std::string& newID);
354 
356  void renameJunction(GNEJunction* junction, const std::string& newID);
357 
359  void changeEdgeEndpoints(GNEEdge* edge, const std::string& newSourceID, const std::string& newDestID);
360 
362  GNEViewNet* getViewNet() const;
363 
366 
367  /* @brief get ids of currently active objects
368  * param[in] type If type != GLO_MAX, get active ids of that type, otherwise get all active ids
369  */
370  std::set<GUIGlID> getGlIDs(GUIGlObjectType type = GLO_MAX);
371 
373  void initGNEConnections();
374 
376  void computeAndUpdate(OptionsCont& oc);
377 
378  /* @brief trigger full netbuild computation
379  * param[in] window The window to inform about delay
380  * param[in] force Whether to force recomputation even if not needed
381  */
382  void computeEverything(GNEApplicationWindow* window, bool force = false);
383 
384  /* @brief join selected junctions
385  * @note difference to mergeJunctions:
386  * - can join more than 2
387  * - connected edges will keep their geometry (big junction shape is created)
388  * - no hirarchy: if any junction has a traffic light than the resuling junction will
389  */
390  void joinSelectedJunctions(GNEUndoList* undoList);
391 
392  /* @brief removes junctions that have no edges
393  */
394  void removeSolitaryJunctions(GNEUndoList* undoList);
395 
396  /* @brief replace the selected junction by geometry node(s)
397  * and merge the edges
398  */
399  void replaceJunctionByGeometry(GNEJunction* junction, GNEUndoList* undoList);
400 
401  /* @brief trigger recomputation of junction shape and logic
402  * param[in] window The window to inform about delay
403  */
404  void computeJunction(GNEJunction* junction);
405 
407  void updateJunctionShapes();
408 
410  void requireRecompute();
411 
413  FXApp* getApp();
414 
416  void addExplicitTurnaround(std::string id);
417 
419  void removeExplicitTurnaround(std::string id);
420 
423  void moveSelection(const Position& moveSrc, const Position& moveDest);
424 
426  void finishMoveSelection(GNEUndoList* undoList);
427 
430 
433  void setAdditionalsFile(const std::string& additionalFile);
434 
437  void setAdditionalsOutputFile(const std::string& additionalOutputFile);
438 
443  void insertAdditional(GNEAdditional* additional, bool hardFail = true);
444 
448  void deleteAdditional(GNEAdditional* additional);
449 
452  void updateAdditionalID(const std::string& oldID, GNEAdditional* additional);
453 
459  GNEAdditional* getAdditional(SumoXMLTag type, const std::string& id) const;
460 
467  std::string getAdditionalID(SumoXMLTag type, const GNELane* lane, const SUMOReal pos) const;
468 
473  std::vector<GNEAdditional*> getAdditionals(SumoXMLTag type = SUMO_TAG_NOTHING);
474 
480 
481 protected:
484 
487 
490 
493  typedef std::map<std::string, GNEJunction*> GNEJunctions;
494  typedef std::map<std::string, GNEEdge*> GNEEdges;
495  typedef std::map<std::pair<std::string, SumoXMLTag>, GNEAdditional*> GNEAdditionals;
496  // @}
497 
499  GNEJunctions myJunctions;
500 
502  GNEEdges myEdges;
503 
505  GNEAdditionals myAdditionals;
506 
508  // @{
511  // @}
512 
515 
517  std::set<std::string> myExplicitTurnarounds;
518 
521 
522 private:
524  void initDetectors();
525 
527  void initTLMap();
528 
530  void insertJunction(GNEJunction* junction);
531 
533  void insertEdge(GNEEdge* edge);
534 
535 
536 
539 
541  GNEEdge* registerEdge(GNEEdge* edge);
542 
544  void deleteSingleJunction(GNEJunction* junction);
545 
547  void deleteSingleEdge(GNEEdge* edge);
548 
550  void update();
551 
553  void reserveEdgeID(const std::string& id);
554 
556  void reserveJunctionID(const std::string& id);
557 
558  /* @brief helper function for changing the endpoints of a junction
559  * @param[in] keepEndpoints Whether to keep the original edge endpoints (influences junction shape)
560  */
561  void remapEdge(GNEEdge* oldEdge, GNEJunction* from, GNEJunction* to, GNEUndoList* undoList, bool keepEndpoints = false);
562 
565 
567  static const SUMOReal Z_INITIALIZED;
568 };
569 
570 #endif
571 
572 /****************************************************************************/
void setViewNet(GNEViewNet *viewNet)
Set the viewNet to be notified of network changes.
Definition: GNENet.cpp:683
GNEJunction * splitEdge(GNEEdge *edge, const Position &pos, GNEUndoList *undoList, GNEJunction *newJunction=0)
split edge at position by inserting a new junction
Definition: GNENet.cpp:496
void computeAndUpdate(OptionsCont &oc)
recompute the network and update lane geometries
Definition: GNENet.cpp:1406
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
Definition: GNENet.cpp:764
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNENet.cpp:194
ShapeContainer & getShapeContainer()
get shape container
Definition: GNENet.cpp:1169
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
Definition: GNENet.cpp:729
GNEViewNet * myViewNet
The viewNet to be notofied of about changes.
Definition: GNENet.h:486
SumoXMLTag
Numbers representing SUMO-XML - element names.
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:702
IDSupplier myEdgeIDSupplier
Definition: GNENet.h:509
SUMORTree myGrid
the rtree which contains all GUIGlObjects (so named for historical reasons)
Definition: GNENet.h:483
void joinSelectedJunctions(GNEUndoList *undoList)
Definition: GNENet.cpp:975
GUIGlObjectType
FXApp * getApp()
get pointer to the main App
Definition: GNENet.cpp:969
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
Storage for geometrical objects extended by mutexes.
void refreshElement(GUIGlObject *o)
refreshes boundary information for o and update
Definition: GNENet.cpp:776
GNEAdditionals myAdditionals
map with the name and pointer to additional elements of net
Definition: GNENet.h:505
The main window of the Netedit.
static const RGBColor selectedLaneColor
color of selected lane
Definition: GNENet.h:99
bool revertLaneRestriction(GNELane *lane, GNEUndoList *undoList)
revert prevously restricted lane
Definition: GNENet.cpp:441
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:838
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNENet.cpp:216
void computeEverything(GNEApplicationWindow *window, bool force=false)
Definition: GNENet.cpp:911
void reverseEdge(GNEEdge *edge, GNEUndoList *undoList)
reverse edge
Definition: GNENet.cpp:560
void update()
notify myViewNet
Definition: GNENet.cpp:1376
void insertJunction(GNEJunction *junction)
inserts a single junction into the net and into the underlying netbuild-container ...
Definition: GNENet.cpp:1300
void updateJunctionShapes()
update junction shapes
Definition: GNENet.cpp:952
void deleteConnection(GNEConnection *connection, GNEUndoList *undoList)
remove connectino
Definition: GNENet.cpp:384
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:549
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
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:251
void addExplicitTurnaround(std::string id)
add edge id to the list of explicit turnarounds
Definition: GNENet.cpp:1103
GUIShapeContainer myShapeContainer
the container for additional pois and polygons
Definition: GNENet.h:514
Storage for geometrical objects.
void insertEdge(GNEEdge *edge)
inserts a single edge into the net and into the underlying netbuild-container
Definition: GNENet.cpp:1307
An Element wich group additionalSet elements.
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList)
removes edge
Definition: GNENet.cpp:331
A RT-tree for efficient storing of SUMO'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:1262
void remapEdge(GNEEdge *oldEdge, GNEJunction *from, GNEJunction *to, GNEUndoList *undoList, bool keepEndpoints=false)
Definition: GNENet.cpp:628
GNEJunction * registerJunction(GNEJunction *junction)
registers a junction with GNENet containers
Definition: GNENet.cpp:1319
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
bool myNeedRecompute
whether the net needs recomputation
Definition: GNENet.h:520
NBNetBuilder * myNetBuilder
The internal netbuilder.
Definition: GNENet.h:489
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GNENet.cpp:187
bool restrictLane(SUMOVehicleClass vclass, GNELane *lane, GNEUndoList *undoList)
transform lane to restricted lane
Definition: GNENet.cpp:414
void renameJunction(GNEJunction *junction, const std::string &newID)
updates the map and reserves new id
Definition: GNENet.cpp:1094
IDSupplier myJunctionIDSupplier
Definition: GNENet.h:510
void updateAdditionalID(const std::string &oldID, GNEAdditional *additional)
update additional ID in container
Definition: GNENet.cpp:1239
bool removeRestrictedLane(SUMOVehicleClass vclass, GNEEdge &edge, GNEUndoList *undoList)
remove restricted lane
Definition: GNENet.cpp:474
std::map< std::string, GNEJunction * > GNEJunctions
Definition: GNENet.h:493
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNENet.cpp:205
void refreshAdditional(GNEAdditional *additional)
refreshes boundary information of an additional after a geometry update
Definition: GNENet.cpp:784
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:689
GNEJunctions myJunctions
map with the name and pointer to junctions of net
Definition: GNENet.h:499
GNELane * retrieveLane(const std::string &id, bool failHard=true)
get lane by id
Definition: GNENet.cpp:744
Boundary myZBoundary
the z boundary (stored in the x-coordinate), values of 0 are ignored
Definition: GNENet.h:564
void deleteLane(GNELane *lane, GNEUndoList *undoList)
removes lane
Definition: GNENet.cpp:356
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:488
std::vector< GNEAdditional * > getAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING)
get vector with additionals
Definition: GNENet.cpp:1273
void computeJunction(GNEJunction *junction)
Definition: GNENet.cpp:933
A lane area vehicles can halt at (netedit-version)
Definition: GNEBusStop.h:58
void initGNEConnections()
initialize GNEConnections
Definition: GNENet.cpp:1396
int getNumberOfAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING)
Returns the number of additionals of the net.
Definition: GNENet.cpp:1285
void save(OptionsCont &oc)
save the network
Definition: GNENet.cpp:643
std::vector< GNEAttributeCarrier * > retrieveAttributeCarriers(const std::set< GUIGlID > &ids, GUIGlObjectType type)
get the attribute carriers based on GlIDs
Definition: GNENet.cpp:796
void moveSelection(const Position &moveSrc, const Position &moveDest)
move all selected junctions and edges
Definition: GNENet.cpp:1115
GNEJunction * createJunction(const Position &pos, GNEUndoList *undoList)
creates a new junction
Definition: GNENet.cpp:240
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GNENet.cpp:228
void setAdditionalsOutputFile(const std::string &additionalOutputFile)
set additionals File
Definition: GNENet.cpp:1181
std::set< std::string > myExplicitTurnarounds
list of edge ids for which turn-arounds must be added explicitly
Definition: GNENet.h:517
void setAdditionalsFile(const std::string &additionalFile)
set additionals File
Definition: GNENet.cpp:1175
void replaceJunctionByGeometry(GNEJunction *junction, GNEUndoList *undoList)
Definition: GNENet.cpp:1042
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:55
void reserveJunctionID(const std::string &id)
reserve junction ID (To avoid duplicates)
Definition: GNENet.cpp:1390
GNEAdditional * getAdditional(SumoXMLTag type, const std::string &id) const
Returns the named additional.
Definition: GNENet.cpp:1250
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNENet.cpp:211
void deleteSingleJunction(GNEJunction *junction)
deletes a single junction
Definition: GNENet.cpp:1348
~GNENet()
Destructor.
Definition: GNENet.cpp:156
const Boundary & getZBoundary() const
Returns the Z boundary (stored in the x() coordinate) values of 0 do not affect the boundary...
Definition: GNENet.cpp:222
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:717
GNEEdge * registerEdge(GNEEdge *edge)
registers an edge with GNENet containers
Definition: GNENet.cpp:1336
GNENet(NBNetBuilder *netBuilder)
Constructor.
Definition: GNENet.cpp:99
An Element which don'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:1025
static const RGBColor selectedConnectionColor
color of selected connection
Definition: GNENet.h:102
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:1063
void deleteJunction(GNEJunction *junction, GNEUndoList *undoList)
removes junction and all incident edges
Definition: GNENet.cpp:306
void initDetectors()
Initialises the detector wrappers.
void removeExplicitTurnaround(std::string id)
remove edge id from the list of explicit turnarounds
Definition: GNENet.cpp:1109
void saveJoined(OptionsCont &oc)
save log of joined junctions (and nothing else)
Definition: GNENet.cpp:676
void deleteAdditional(GNEAdditional *additional)
delete additional element previously inserted
Definition: GNENet.cpp:1214
GNEEdge * addReversedEdge(GNEEdge *edge, GNEUndoList *undoList)
add reversed edge
Definition: GNENet.cpp:571
#define SUMOReal
Definition: config.h:214
GNEEdges myEdges
map with the name and pointer to edges of net
Definition: GNENet.h:502
std::map< std::pair< std::string, SumoXMLTag >, GNEAdditional * > GNEAdditionals
Definition: GNENet.h:495
static const RGBColor selectionColor
color of selection
Definition: GNENet.h:96
empty max
void reserveEdgeID(const std::string &id)
reserve edge ID (To avoid duplicates)
Definition: GNENet.cpp:1384
void deleteSingleEdge(GNEEdge *edge)
deletes a single edge
Definition: GNENet.cpp:1361
std::map< std::string, GNEEdge * > GNEEdges
Definition: GNENet.h:494
void mergeJunctions(GNEJunction *moved, GNEJunction *target, GNEUndoList *undoList)
merge the given junctions edges between the given junctions will be deleted
Definition: GNENet.cpp:604
void insertAdditional(GNEAdditional *additional, bool hardFail=true)
Insert a additional element previously created in GNEAdditionalHandler.
Definition: GNENet.cpp:1187
bool addSRestrictedLane(SUMOVehicleClass vclass, GNEEdge &edge, GNEUndoList *undoList)
add restricted lane to edge
Definition: GNENet.cpp:459
A window containing a gl-object's parameter.
void changeEdgeEndpoints(GNEEdge *edge, const std::string &newSourceID, const std::string &newDestID)
modifies endpoins of the given edge
Definition: GNENet.cpp:1072
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition: GNENet.cpp:1088
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1082
void saveAdditionals(const std::string &filename)
save additional elements of the network
Definition: GNENet.cpp:650
void savePlain(OptionsCont &oc)
save plain xml representation of the network (and nothing else)
Definition: GNENet.cpp:669
void requireRecompute()
inform the net about the need for recomputation
Definition: GNENet.cpp:963
static const SUMOReal Z_INITIALIZED
marker for whether the z-boundary is initialized
Definition: GNENet.h:567
void duplicateLane(GNELane *lane, GNEUndoList *undoList)
duplicates lane
Definition: GNENet.cpp:402
void finishMoveSelection(GNEUndoList *undoList)
register changes to junction and edge positions with the undoList
Definition: GNENet.cpp:1145