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 
59 
60 // ===========================================================================
61 // class declarations
62 // ===========================================================================
65 class GNEEdge;
66 class GNELane;
67 class GNEJunction;
68 class GNEUndoList;
69 
70 // ===========================================================================
71 // class definitions
72 // ===========================================================================
77 class GNENet : public GUIGlObject {
78 
79  friend class GNEChange_Junction;
80  friend class GNEChange_Edge;
81 
82 public:
83  static const RGBColor selectionColor;
85 
90  GNENet(NBNetBuilder* netBuilder);
91 
92 
94  ~GNENet() ;
95 
96 
97 
99 
100 
109  GUISUMOAbstractView& parent) ;
110 
111 
120  GUIMainWindow& app, GUISUMOAbstractView& parent) ;
121 
122 
129 
130 
134  const Boundary& getZBoundary() const {
135  return myZBoundary;
136  }
137 
138 
143  void drawGL(const GUIVisualizationSettings& s) const ;
145 
146 
148  const Boundary& getBoundary() const;
149 
150 
155  return myGrid;
156  }
157 
158 
163  return myGrid;
164  }
165 
166 
172  GNEJunction* createJunction(const Position& pos, GNEUndoList* undoList);
173 
186  GNEJunction* src,
187  GNEJunction* dest,
188  GNEEdge* tpl,
189  GNEUndoList* undoList,
190  const std::string& suggestedName = "",
191  bool wasSplit = false,
192  bool allowDuplicateGeom = false);
193 
194 
199  void deleteJunction(GNEJunction* junction, GNEUndoList* undoList);
200 
201 
206  void deleteEdge(GNEEdge* edge, GNEUndoList* undoList);
207 
212  void deleteLane(GNELane* lane, GNEUndoList* undoList);
213 
218  void duplicateLane(GNELane* lane, GNEUndoList* undoList);
219 
226  void deleteGeometryOrEdge(GNEEdge* edge, const Position& pos, GNEUndoList* undoList);
227 
228 
234  GNEJunction* splitEdge(GNEEdge* edge, const Position& pos, GNEUndoList* undoList, GNEJunction* newJunction = 0);
235 
236 
241  void splitEdgesBidi(const std::set<GNEEdge*>& edges, const Position& pos, GNEUndoList* undoList);
242 
246  void reverseEdge(GNEEdge* edge, GNEUndoList* undoList);
247 
252  GNEEdge* addReversedEdge(GNEEdge* edge, GNEUndoList* undoList);
253 
260  void mergeJunctions(GNEJunction* moved, GNEJunction* target, GNEUndoList* undoList);
261 
262 
269  GNEJunction* retrieveJunction(const std::string& id, bool failHard = true);
270 
271 
278  GNEEdge* retrieveEdge(const std::string& id, bool failHard = true);
279 
280 
286  std::vector<GNEAttributeCarrier*> retrieveAttributeCarriers(
287  const std::set<GUIGlID>& ids, GUIGlObjectType type);
288 
292  std::vector<GNEEdge*> retrieveEdges(bool onlySelected = false);
293 
297  std::vector<GNELane*> retrieveLanes(bool onlySelected = false);
298 
302  std::vector<GNEJunction*> retrieveJunctions(bool onlySelected = false);
303 
307  void save(OptionsCont& oc);
308 
312  void savePlain(OptionsCont& oc);
313 
317  void saveJoined(OptionsCont& oc);
318 
320  void setUpdateTarget(FXWindow* updateTarget) {
321  myUpdateTarget = updateTarget;
322  }
323 
325  void refreshElement(GUIGlObject* o);
326 
328  void renameEdge(GNEEdge* edge, const std::string& newID);
329 
331  void renameJunction(GNEJunction* junction, const std::string& newID);
332 
334  void changeEdgeEndpoints(GNEEdge* edge, const std::string& newSourceID, const std::string& newDestID);
335 
338  return myNetBuilder->getTLLogicCont();
339  };
340 
341  /* @brief get ids of currently active objects
342  * param[in] type If type != GLO_MAX, get active ids of that type, otherwise get all active ids
343  */
344  std::set<GUIGlID> getGlIDs(GUIGlObjectType type = GLO_MAX);
345 
347  void computeAndUpdate(OptionsCont& oc);
348 
349  /* @brief trigger full netbuild computation
350  * param[in] window The window to inform about delay
351  * param[in] force Whether to force recomputation even if not needed
352  */
353  void computeEverything(GNEApplicationWindow* window, bool force = false);
354 
355  /* @brief join selected junctions
356  * @note difference to mergeJunctions:
357  * - can join more than 2
358  * - connected edges will keep their geometry (big junction shape is created)
359  * - no hirarchy: if any junction has a traffic light than the resuling junction will
360  */
361  void joinSelectedJunctions(GNEUndoList* undoList);
362 
363  /* @brief removes junctions that have no edges
364  */
365  void removeSolitaryJunctions(GNEUndoList* undoList);
366 
367  /* @brief replace the selected junction by geometry node(s)
368  * and merge the edges
369  */
370  void replaceJunctionByGeometry(GNEJunction* junction, GNEUndoList* undoList);
371 
372  /* @brief trigger recomputation of junction shape and logic
373  * param[in] window The window to inform about delay
374  */
375  void computeJunction(GNEJunction* junction);
376 
377 
379  inline void requireRecompute() {
380  myNeedRecompute = true;
381  }
382 
383 
384  FXApp* getApp() {
385  return myUpdateTarget->getApp();
386  }
387 
389  void addExplicitTurnaround(std::string id);
390 
392  void removeExplicitTurnaround(std::string id);
393 
394  /* @brief move all selected junctions and edges
395  * @note: inner points of an edge will only be modified if the edge and its endpoints are selected
396  */
397  void moveSelection(const Position& moveSrc, const Position& moveDest);
398 
400  void finishMoveSelection(GNEUndoList* undoList);
401 
403  return myShapeContainer;
404  }
405 
406 private:
409 
411  FXWindow* myUpdateTarget;
412 
415 
417 
418 
419  typedef std::map<std::string, GNEEdge*> GNEEdges;
420  typedef std::map<std::string, GNEJunction*> GNEJunctions;
421 
422  GNEEdges myEdges;
423  GNEJunctions myJunctions;
424 
426  // @{
429  // @}
430 
433 
435  std::set<std::string> myExplicitTurnarounds;
436 
439 
440 
441 private:
442 
444  void initDetectors();
445 
447  void initTLMap();
448 
450  //netbuild-container
451  void insertJunction(GNEJunction* junction);
452 
454  //netbuild-container
455  void insertEdge(GNEEdge* edge);
456 
459 
461  GNEEdge* registerEdge(GNEEdge* edge);
462 
464  void deleteSingleJunction(GNEJunction* junction);
465 
467  void deleteSingleEdge(GNEEdge* edge);
468 
470  void update();
471 
472  void reserveEdgeID(const std::string& id);
473 
474  void reserveJunctionID(const std::string& id);
475 
476  /* @brief helper function for changing the endpoints of a junction
477  * @param[in] keepEndpoints Whether to keep the original edge endpoints (influences junction shape)
478  */
479  void remapEdge(GNEEdge* oldEdge, GNEJunction* from, GNEJunction* to, GNEUndoList* undoList, bool keepEndpoints = false);
480 
483 
485  static const SUMOReal Z_INITIALIZED;
486 };
487 
488 
489 #endif
490 
491 /****************************************************************************/
492 
GNEJunction * splitEdge(GNEEdge *edge, const Position &pos, GNEUndoList *undoList, GNEJunction *newJunction=0)
split edge at position by inserting a new junction
Definition: GNENet.cpp:360
void computeAndUpdate(OptionsCont &oc)
recompute the network and update lane geometries
Definition: GNENet.cpp:1004
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
Definition: GNENet.cpp:580
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNENet.cpp:180
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
Definition: GNENet.cpp:565
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:541
IDSupplier myEdgeIDSupplier
Definition: GNENet.h:427
SUMORTree myGrid
the rtree which contains all GUIGlObjects (so named for historical reasons)
Definition: GNENet.h:408
void joinSelectedJunctions(GNEUndoList *undoList)
Definition: GNENet.cpp:728
GUIGlObjectType
Storage for geometrical objects extended by mutexes.
void refreshElement(GUIGlObject *o)
refreshes boundary information for o and update
Definition: GNENet.cpp:592
The main window of the Netedit.
static const RGBColor selectedLaneColor
Definition: GNENet.h:84
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:635
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNENet.cpp:202
void computeEverything(GNEApplicationWindow *window, bool force=false)
Definition: GNENet.cpp:687
void reverseEdge(GNEEdge *edge, GNEUndoList *undoList)
reverse edge
Definition: GNENet.cpp:425
void update()
notify myUpdateTarget
Definition: GNENet.cpp:984
void insertJunction(GNEJunction *junction)
inserts a single junction into the net and into the underlying
Definition: GNENet.cpp:912
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:414
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition: GNENet.h:337
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:56
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:219
void addExplicitTurnaround(std::string id)
add edge id to the list of explicit turnarounds
Definition: GNENet.cpp:844
GUIShapeContainer myShapeContainer
the container for additional pois and polygons
Definition: GNENet.h:432
Storage for geometrical objects.
void insertEdge(GNEEdge *edge)
inserts a single edge into the net and into the underlying
Definition: GNENet.cpp:919
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList)
removes edge
Definition: GNENet.cpp:299
A RT-tree for efficient storing of SUMO&#39;s GL-objects.
Definition: SUMORTree.h:74
void remapEdge(GNEEdge *oldEdge, GNEJunction *from, GNEJunction *to, GNEUndoList *undoList, bool keepEndpoints=false)
Definition: GNENet.cpp:493
GNEJunction * registerJunction(GNEJunction *junction)
registers a junction with GNENet containers
Definition: GNENet.cpp:931
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
bool myNeedRecompute
whether the net needs recomputation
Definition: GNENet.h:438
NBNetBuilder * myNetBuilder
The internal netbuilder.
Definition: GNENet.h:414
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GNENet.cpp:173
const Boundary & getZBoundary() const
Returns the Z boundary (stored in the x() coordinate) values of 0 do not affect the boundary...
Definition: GNENet.h:134
void renameJunction(GNEJunction *junction, const std::string &newID)
updates the map and reserves new id
Definition: GNENet.cpp:835
IDSupplier myJunctionIDSupplier
Definition: GNENet.h:428
ShapeContainer & getShapeContainer()
Definition: GNENet.h:402
std::map< std::string, GNEJunction * > GNEJunctions
Definition: GNENet.h:420
FXWindow * myUpdateTarget
The window to be notofied of about changes.
Definition: GNENet.h:411
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNENet.cpp:191
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:529
GNEJunctions myJunctions
Definition: GNENet.h:423
Boundary myZBoundary
the z boundary (stored in the x-coordinate), values of 0 are ignored
Definition: GNENet.h:482
void deleteLane(GNELane *lane, GNEUndoList *undoList)
removes lane
Definition: GNENet.cpp:317
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:352
void computeJunction(GNEJunction *junction)
Definition: GNENet.cpp:709
void save(OptionsCont &oc)
save the network
Definition: GNENet.cpp:508
std::vector< GNEAttributeCarrier * > retrieveAttributeCarriers(const std::set< GUIGlID > &ids, GUIGlObjectType type)
get the attribute carriers based on GlIDs
Definition: GNENet.cpp:600
void moveSelection(const Position &moveSrc, const Position &moveDest)
Definition: GNENet.cpp:856
GNEJunction * createJunction(const Position &pos, GNEUndoList *undoList)
creates a new junction
Definition: GNENet.cpp:208
std::set< std::string > myExplicitTurnarounds
list of edge ids for which turn-arounds must be added explicitly
Definition: GNENet.h:435
void replaceJunctionByGeometry(GNEJunction *junction, GNEUndoList *undoList)
Definition: GNENet.cpp:795
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:61
void reserveJunctionID(const std::string &id)
Definition: GNENet.cpp:998
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNENet.cpp:197
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GNENet.h:154
void deleteSingleJunction(GNEJunction *junction)
deletes a single junction
Definition: GNENet.cpp:960
~GNENet()
Destructor.
Definition: GNENet.cpp:142
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:553
GNEEdge * registerEdge(GNEEdge *edge)
registers an edge with GNENet containers
Definition: GNENet.cpp:948
GNENet(NBNetBuilder *netBuilder)
Constructor.
Definition: GNENet.cpp:88
Instance responsible for building networks.
Definition: NBNetBuilder.h:113
void removeSolitaryJunctions(GNEUndoList *undoList)
Definition: GNENet.cpp:778
A storage for options typed value containers)
Definition: OptionsCont.h:108
The popup menu of a globject.
void initTLMap()
Initialises the tl-logic map and wrappers.
NBTrafficLightLogicCont & getTLLogicCont()
Returns the traffic light logics container.
Definition: NBNetBuilder.h:178
void renameEdge(GNEEdge *edge, const std::string &newID)
updates the map and reserves new id
Definition: GNENet.cpp:816
void deleteJunction(GNEJunction *junction, GNEUndoList *undoList)
removes junction and all incident edges
Definition: GNENet.cpp:274
void initDetectors()
Initialises the detector wrappers.
void removeExplicitTurnaround(std::string id)
remove edge id from the list of explicit turnarounds
Definition: GNENet.cpp:850
void saveJoined(OptionsCont &oc)
save log of joined junctions (and nothing else)
Definition: GNENet.cpp:522
GNEEdge * addReversedEdge(GNEEdge *edge, GNEUndoList *undoList)
add reversed edge
Definition: GNENet.cpp:436
void setUpdateTarget(FXWindow *updateTarget)
Set the target to be notified of network changes.
Definition: GNENet.h:320
#define SUMOReal
Definition: config.h:213
GNEEdges myEdges
Definition: GNENet.h:422
static const RGBColor selectionColor
Definition: GNENet.h:83
empty max
void reserveEdgeID(const std::string &id)
Definition: GNENet.cpp:992
void deleteSingleEdge(GNEEdge *edge)
deletes a single edge
Definition: GNENet.cpp:971
std::map< std::string, GNEEdge * > GNEEdges
Definition: GNENet.h:419
void mergeJunctions(GNEJunction *moved, GNEJunction *target, GNEUndoList *undoList)
merge the given junctions edges between the given junctions will be deleted
Definition: GNENet.cpp:469
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:825
void savePlain(OptionsCont &oc)
save plain xml representation of the network (and nothing else)
Definition: GNENet.cpp:515
void requireRecompute()
inform the net about the need for recomputation
Definition: GNENet.h:379
static const SUMOReal Z_INITIALIZED
marker for whether the z-boundary is initialized
Definition: GNENet.h:485
void duplicateLane(GNELane *lane, GNEUndoList *undoList)
duplicates lane
Definition: GNENet.cpp:340
FXApp * getApp()
Definition: GNENet.h:384
const SUMORTree & getVisualisationSpeedUp() const
Returns the RTree used for visualisation speed-up.
Definition: GNENet.h:162
void finishMoveSelection(GNEUndoList *undoList)
register changes to junction and edge positions with the undoList
Definition: GNENet.cpp:886