SUMO - Simulation of Urban MObility
GNENet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A visual container for GNE-network-components such as GNEEdge and GNEJunction.
8 // GNE components wrap netbuild-components and supply visualisation and editing
9 // capabilities (adapted from GUINet)
10 //
11 // Workflow (rough draft)
12 // use NILoader to fill
13 // do netedit stuff
14 // call compute to save results
15 //
16 /****************************************************************************/
17 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
18 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
19 /****************************************************************************/
20 //
21 // This file is part of SUMO.
22 // SUMO is free software: you can redistribute it and/or modify
23 // it under the terms of the GNU General Public License as published by
24 // the Free Software Foundation, either version 3 of the License, or
25 // (at your option) any later version.
26 //
27 /****************************************************************************/
28 
29 
30 // ===========================================================================
31 // included modules
32 // ===========================================================================
33 #ifdef _MSC_VER
34 #include <windows_config.h>
35 #else
36 #include <config.h>
37 #endif
38 
39 #include <utility>
40 #include <set>
41 #include <vector>
42 #include <map>
43 
45 #include <utils/common/RGBColor.h>
55 #include <netbuild/NBEdgeCont.h>
56 #include <netbuild/NBNodeCont.h>
57 #include <netbuild/NBAlgorithms.h>
58 #include <netwrite/NWFrame.h>
59 #include <netwrite/NWWriter_XML.h>
60 #include "GNENet.h"
61 #include "GNEApplicationWindow.h"
62 #include "GNEJunction.h"
63 #include "GNEEdge.h"
64 #include "GNELane.h"
65 #include "GNEUndoList.h"
66 #include "GNEChange_Junction.h"
67 #include "GNEChange_Edge.h"
68 #include "GNEChange_Lane.h"
69 #include "GNEChange_Connection.h"
70 #include "GNEChange_Selection.h"
71 
72 
73 #ifdef CHECK_MEMORY_LEAKS
74 #include <foreign/nvwa/debug_new.h>
75 #endif // CHECK_MEMORY_LEAKS
76 
77 
78 // ===========================================================================
79 // static members
80 // ===========================================================================
81 const RGBColor GNENet::selectionColor(0, 0, 204, 255);
82 const RGBColor GNENet::selectedLaneColor(0, 0, 128, 255);
84 
85 // ===========================================================================
86 // member method definitions
87 // ===========================================================================
90  myUpdateTarget(0),
91  myNetBuilder(netBuilder),
92  myEdges(),
93  myJunctions(),
94  myEdgeIDSupplier("gneE", netBuilder->getEdgeCont().getAllNames()),
95  myJunctionIDSupplier("gneJ", netBuilder->getNodeCont().getAllNames()),
96  myShapeContainer(myGrid),
97  myNeedRecompute(true) {
99 
100  // init edges
102  const std::vector<std::string>& edgeNames = ec.getAllNames();
103  for (std::vector<std::string>::const_iterator name_it = edgeNames.begin(); name_it != edgeNames.end(); ++name_it) {
104  NBEdge* nbe = ec.retrieve(*name_it);
105  registerEdge(new GNEEdge(*nbe, this, false, true));
106  if (myGrid.getWidth() > 10e16 || myGrid.getHeight() > 10e16) {
107  throw ProcessError("Network size exceeds 1 Lightyear. Please reconsider your inputs.\n");
108  }
109  }
110 
111  // init junctions
113  const std::vector<std::string>& nodeNames = nc.getAllNames();
114  for (std::vector<std::string>::const_iterator name_it = nodeNames.begin(); name_it != nodeNames.end(); ++name_it) {
115  NBNode* nbn = nc.retrieve(*name_it);
116  registerJunction(new GNEJunction(*nbn, this, true));
117  }
118  // make sure myGrid is initialized even for an empty net
119  if (myEdges.size() == 0) {
120  myGrid.add(Boundary(0, 0, 100, 100));
121  }
122 
123  // sort nodes edges so that arrows can be drawn correctly
125 
126  /*
127  // initialise detector storage for gui
128  initDetectors();
129  // initialise the tl-map
130  initTLMap();
131  // initialise edge storage for gui
132  GUIEdge::fill(myEdgeWrapper);
133  */
134  //if (myGrid.count() == 0) // myGrid methods will return garbage
135 
136  if (myZBoundary.ymin() != Z_INITIALIZED) {
137  myZBoundary.add(0, 0);
138  }
139 }
140 
141 
143  /*
144  // delete allocated wrappers
145  // of junctions
146  for (std::vector<GUIJunctionWrapper*>::iterator i1=myJunctionWrapper.begin(); i1!=myJunctionWrapper.end(); i1++) {
147  delete(*i1);
148  }
149  // of additional structures
150  GUIGlObject_AbstractAdd::clearDictionary();
151  // of tl-logics
152  for (Logics2WrapperMap::iterator i3=myLogics2Wrapper.begin(); i3!=myLogics2Wrapper.end(); i3++) {
153  delete(*i3).second;
154  }
155  // of detectors
156  for (std::map<std::string, GUIDetectorWrapper*>::iterator i=myDetectorDict.begin(); i!=myDetectorDict.end(); ++i) {
157  delete(*i).second;
158  }
159  */
160  for (GNEEdges::iterator it = myEdges.begin(); it != myEdges.end(); it++) {
161  it->second->decRef("GNENet::~GNENet");
162  delete it->second;
163  }
164  for (GNEJunctions::iterator it = myJunctions.begin(); it != myJunctions.end(); it++) {
165  it->second->decRef("GNENet::~GNENet");
166  delete it->second;
167  }
168  delete myNetBuilder;
169 }
170 
171 
172 const Boundary&
174  // SUMORTree is also a Boundary
175  return myGrid;
176 }
177 
178 
181  GUISUMOAbstractView& parent) {
182  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
183  buildPopupHeader(ret, app);
185  buildPositionCopyEntry(ret, false);
186  return ret;
187 }
188 
189 
192  return 0;
193 }
194 
195 
196 void
198 }
199 
200 
201 Boundary
203  return getBoundary();
204 }
205 
206 
209  std::string id = myJunctionIDSupplier.getNext();
210  NBNode* nbn = new NBNode(id, pos);
211  GNEJunction* junction = new GNEJunction(*nbn, this);
212  undoList->add(new GNEChange_Junction(this, junction, true), true);
213  assert(myJunctions[id]);
214  return junction;
215 }
216 
217 
218 GNEEdge*
220  GNEJunction* src, GNEJunction* dest, GNEEdge* tpl, GNEUndoList* undoList,
221  const std::string& suggestedName,
222  bool wasSplit,
223  bool allowDuplicateGeom) {
224  // prevent duplicate edge (same geometry)
225  const EdgeVector& outgoing = src->getNBNode()->getOutgoingEdges();
226  for (EdgeVector::const_iterator it = outgoing.begin(); it != outgoing.end(); it++) {
227  if ((*it)->getToNode() == dest->getNBNode() && (*it)->getGeometry().size() == 2) {
228  if (!allowDuplicateGeom) {
229  return 0;
230  }
231  }
232  }
233 
234  std::string id;
235  if (suggestedName != "" && !retrieveEdge(suggestedName, false)) {
236  id = suggestedName;
237  reserveEdgeID(id);
238  } else {
239  id = myEdgeIDSupplier.getNext();
240  }
241 
242  GNEEdge* edge;
243  if (tpl) {
244  NBEdge* nbeTpl = tpl->getNBEdge();
245  NBEdge* nbe = new NBEdge(id, src->getNBNode(), dest->getNBNode(), nbeTpl);
246  edge = new GNEEdge(*nbe, this, wasSplit);
247  } else {
248  // default if no template is given
249  SUMOReal defaultSpeed = 50 / 3.6;
250  std::string defaultType = "";
251  int defaultNrLanes = 1;
252  int defaultPriority = 1;
253  SUMOReal defaultWidth = NBEdge::UNSPECIFIED_WIDTH;
254  SUMOReal defaultOffset = NBEdge::UNSPECIFIED_OFFSET;
255  NBEdge* nbe = new NBEdge(id, src->getNBNode(), dest->getNBNode(),
256  defaultType, defaultSpeed,
257  defaultNrLanes, defaultPriority,
258  defaultWidth,
259  defaultOffset);
260  edge = new GNEEdge(*nbe, this, wasSplit);
261  }
262  undoList->p_begin("create edge");
263  undoList->add(new GNEChange_Edge(this, edge, true), true);
264  src->setLogicValid(false, undoList);
265  dest->setLogicValid(false, undoList);
267  undoList->p_end();
268  assert(myEdges[id]);
269  return edge;
270 }
271 
272 
273 void
275  // we have to delete all incident edges because they cannot exist without that junction
276  // all deletions must be undone/redone together so we start a new command group
277  // @todo if any of those edges are dead-ends should we remove their orphan junctions as well?
278  undoList->p_begin("delete junction");
279 
280  // deleting edges changes in the underlying EdgeVector so we have to make a copy
281  const EdgeVector incident = junction->getNBNode()->getEdges();
282  for (EdgeVector::const_iterator it = incident.begin(); it != incident.end(); it++) {
283  deleteEdge(myEdges[(*it)->getID()], undoList);
284  }
285 
286  // remove any traffic lights from the traffic light container (avoids lots of warnings)
287  junction->setAttribute(SUMO_ATTR_TYPE, toString(NODETYPE_PRIORITY), undoList);
288  undoList->add(new GNEChange_Junction(this, junction, false), true);
289  if (gSelected.isSelected(GLO_JUNCTION, junction->getGlID())) {
290  std::set<GUIGlID> deselected;
291  deselected.insert(junction->getGlID());
292  undoList->add(new GNEChange_Selection(std::set<GUIGlID>(), deselected, true), true);
293  }
294  undoList->p_end();
295 }
296 
297 
298 void
300  undoList->p_begin("delete edge");
301  undoList->add(new GNEChange_Edge(this, edge, false), true);
302  if (gSelected.isSelected(GLO_EDGE, edge->getGlID())) {
303  std::set<GUIGlID> deselected;
304  deselected.insert(edge->getGlID());
305  undoList->add(new GNEChange_Selection(std::set<GUIGlID>(), deselected, true), true);
306  }
307  edge->getSource()->removeFromCrossings(edge, undoList);
308  edge->getDest()->removeFromCrossings(edge, undoList);
309  edge->getSource()->setLogicValid(false, undoList);
310  edge->getDest()->setLogicValid(false, undoList);
312  undoList->p_end();
313 }
314 
315 
316 void
318  undoList->p_begin("delete lane");
319  GNEEdge* edge = &lane->getParentEdge();
320  const NBEdge::Lane& laneAttrs = edge->getNBEdge()->getLaneStruct(lane->getIndex());
321  const bool sidewalk = laneAttrs.permissions == SVC_PEDESTRIAN;
322  undoList->add(new GNEChange_Lane(edge, lane, laneAttrs, false), true);
323  if (gSelected.isSelected(GLO_LANE, lane->getGlID())) {
324  std::set<GUIGlID> deselected;
325  deselected.insert(lane->getGlID());
326  undoList->add(new GNEChange_Selection(std::set<GUIGlID>(), deselected, true), true);
327  }
328  if (sidewalk) {
329  edge->getSource()->removeFromCrossings(edge, undoList);
330  edge->getDest()->removeFromCrossings(edge, undoList);
331  edge->getSource()->setLogicValid(false, undoList);
332  edge->getDest()->setLogicValid(false, undoList);
333  }
335  undoList->p_end();
336 }
337 
338 
339 void
341  undoList->p_begin("duplicate lane");
342  GNEEdge* edge = &lane->getParentEdge();
343  const NBEdge::Lane& laneAttrs = edge->getNBEdge()->getLaneStruct(lane->getIndex());
344  GNELane* newLane = new GNELane(*edge, lane->getIndex());
345  undoList->add(new GNEChange_Lane(edge, newLane, laneAttrs, true), true);
347  undoList->p_end();
348 }
349 
350 
351 void
353  if (!edge->deleteGeometry(pos, undoList)) {
354  deleteEdge(edge, undoList);
355  }
356 }
357 
358 
360 GNENet::splitEdge(GNEEdge* edge, const Position& pos, GNEUndoList* undoList, GNEJunction* newJunction) {
361  undoList->p_begin("split edge");
362  deleteEdge(edge, undoList); // still exists. we delete it so we can reuse the name in case of resplit
363  // compute geometry
364  const PositionVector& oldGeom = edge->getNBEdge()->getGeometry();
365  const SUMOReal linePos = oldGeom.nearest_offset_to_point2D(pos, false);
366  std::pair<PositionVector, PositionVector> newGeoms = oldGeom.splitAt(linePos);
367  // figure out the new name
368  int posBase = 0;
369  std::string baseName = edge->getMicrosimID();
370  if (edge->wasSplit()) {
371  size_t sep_index = baseName.rfind('.');
372  if (sep_index != std::string::npos) { // edge may have been renamed in between
373  std::string posString = baseName.substr(sep_index + 1);
374  try {
375  posBase = TplConvert::_2int(posString.c_str());
376  baseName = baseName.substr(0, sep_index); // includes the .
377  } catch (NumberFormatException) {
378  }
379  }
380  }
381  baseName += '.';
382  // create edges
383  if (newJunction == 0) {
384  newJunction = createJunction(pos, undoList);
385  }
386  GNEEdge* firstPart = createEdge(edge->getSource(), newJunction, edge,
387  undoList, baseName + toString(posBase), true);
388  GNEEdge* secondPart = createEdge(newJunction, edge->getDest(), edge,
389  undoList, baseName + toString(posBase + (int)linePos), true);
390  // fix geometry
391  firstPart->setAttribute(GNE_ATTR_SHAPE_START, toString(newGeoms.first[0]), undoList);
392  firstPart->setAttribute(GNE_ATTR_SHAPE_END, toString(newGeoms.first[-1]), undoList);
393  newGeoms.first.pop_back();
394  newGeoms.first.erase(newGeoms.first.begin());
395  firstPart->setAttribute(SUMO_ATTR_SHAPE, toString(newGeoms.first), undoList);
396 
397  secondPart->setAttribute(GNE_ATTR_SHAPE_START, toString(newGeoms.second[0]), undoList);
398  secondPart->setAttribute(GNE_ATTR_SHAPE_END, toString(newGeoms.second[-1]), undoList);
399  newGeoms.second.pop_back();
400  newGeoms.second.erase(newGeoms.second.begin());
401  secondPart->setAttribute(SUMO_ATTR_SHAPE, toString(newGeoms.second), undoList);
402  // fix connections
403  std::vector<NBEdge::Connection>& connections = edge->getNBEdge()->getConnections();
404  for (std::vector<NBEdge::Connection>::iterator con_it = connections.begin(); con_it != connections.end(); con_it++) {
405  undoList->add(new GNEChange_Connection(
406  secondPart, con_it->fromLane, con_it->toEdge->getID(), con_it->toLane, false, true), true);
407  }
408  undoList->p_end();
409  return newJunction;
410 }
411 
412 
413 void
414 GNENet::splitEdgesBidi(const std::set<GNEEdge*>& edges, const Position& pos, GNEUndoList* undoList) {
415  GNEJunction* newJunction = 0;
416  undoList->p_begin("split edges");
417  for (std::set<GNEEdge*>::const_iterator it = edges.begin(); it != edges.end(); ++it) {
418  newJunction = splitEdge(*it, pos, undoList, newJunction);
419  }
420  undoList->p_end();
421 }
422 
423 
424 void
426  undoList->p_begin("reverse edge");
427  deleteEdge(edge, undoList); // still exists. we delete it so we can reuse the name in case of resplit
428  GNEEdge* reversed = createEdge(edge->getDest(), edge->getSource(), edge, undoList, edge->getID(), false, true);
429  assert(reversed != 0);
430  reversed->setAttribute(SUMO_ATTR_SHAPE, toString(edge->getNBEdge()->getInnerGeometry().reverse()), undoList);
431  undoList->p_end();
432 }
433 
434 
435 GNEEdge*
437  undoList->p_begin("add reversed edge");
438  GNEEdge* reversed = 0;
440  GNEEdge* reversed = createEdge(edge->getDest(), edge->getSource(), edge, undoList, "-" + edge->getID(), false, true);
441  assert(reversed != 0);
442  reversed->setAttribute(SUMO_ATTR_SHAPE, toString(edge->getNBEdge()->getInnerGeometry().reverse()), undoList);
443  } else {
444  // if the edge is centered it should probably connect somewhere else
445  // make it easy to move and reconnect it
446  PositionVector orig = edge->getNBEdge()->getGeometry();
447  PositionVector origInner = edge->getNBEdge()->getInnerGeometry();
448  const SUMOReal tentativeShift = edge->getNBEdge()->getTotalWidth() + 2;
449  orig.move2side(-tentativeShift);
450  origInner.move2side(-tentativeShift);
451  GNEJunction* src = createJunction(orig.back(), undoList);
452  GNEJunction* dest = createJunction(orig.front(), undoList);
453  GNEEdge* reversed = createEdge(src, dest, edge, undoList, "-" + edge->getID(), false, true);
454  assert(reversed != 0);
455  reversed->setAttribute(SUMO_ATTR_SHAPE, toString(origInner.reverse()), undoList);
456  // select the new edge and its nodes
457  std::set<GUIGlID> toSelect;
458  toSelect.insert(reversed->getGlID());
459  toSelect.insert(src->getGlID());
460  toSelect.insert(dest->getGlID());
461  undoList->add(new GNEChange_Selection(toSelect, gSelected.getSelected(), true), true);
462  }
463  undoList->p_end();
464  return reversed;
465 }
466 
467 
468 void
470  undoList->p_begin("merge junctions");
471  // position of moved and target are probably a bit different (snap radius)
472  moved->move(target->getNBNode()->getPosition());
473  // register the move with undolist (must happend within the undo group)
474  moved->registerMove(undoList);
475  // deleting edges changes in the underlying EdgeVector so we have to make a copy
476  const EdgeVector incoming = moved->getNBNode()->getIncomingEdges();
477  for (EdgeVector::const_iterator it = incoming.begin(); it != incoming.end(); it++) {
478  GNEEdge* oldEdge = myEdges[(*it)->getID()];
479  remapEdge(oldEdge, oldEdge->getSource(), target, undoList);
480  }
481  // deleting edges changes in the underlying EdgeVector so we have to make a copy
482  const EdgeVector outgoing = moved->getNBNode()->getOutgoingEdges();
483  for (EdgeVector::const_iterator it = outgoing.begin(); it != outgoing.end(); it++) {
484  GNEEdge* oldEdge = myEdges[(*it)->getID()];
485  remapEdge(oldEdge, target, oldEdge->getDest(), undoList);
486  }
487  deleteJunction(moved, undoList);
488  undoList->p_end();
489 }
490 
491 
492 void
493 GNENet::remapEdge(GNEEdge* oldEdge, GNEJunction* from, GNEJunction* to, GNEUndoList* undoList, bool keepEndpoints) {
494  deleteEdge(oldEdge, undoList); // delete first so we can reuse the name, reference stays valid
495  if (from != to) {
496  GNEEdge* newEdge = createEdge(from, to, oldEdge, undoList, oldEdge->getMicrosimID(), false, true);
497  newEdge->setAttribute(SUMO_ATTR_SHAPE, oldEdge->getAttribute(SUMO_ATTR_SHAPE), undoList);
498  if (keepEndpoints) {
500  newEdge->setAttribute(GNE_ATTR_SHAPE_END, oldEdge->getAttribute(GNE_ATTR_SHAPE_END), undoList);
501  }
502  }
503  // @todo remap connectivity as well
504 }
505 
506 
507 void
509  computeAndUpdate(oc);
511 }
512 
513 
514 void
516  computeAndUpdate(oc);
518 }
519 
520 
521 void
523  computeAndUpdate(oc);
525 }
526 
527 
529 GNENet::retrieveJunction(const std::string& id, bool failHard) {
530  if (myJunctions.count(id)) {
531  return myJunctions[id];
532  } else if (failHard) {
533  throw UnknownElement("Junction " + id);
534  } else {
535  return 0;
536  }
537 }
538 
539 
540 GNEEdge*
541 GNENet::retrieveEdge(const std::string& id, bool failHard) {
542  if (myEdges.count(id)) {
543  return myEdges[id];
544  } else if (failHard) {
545  throw UnknownElement("Edge " + id);
546  } else {
547  return 0;
548  }
549 }
550 
551 
552 std::vector<GNEEdge*>
553 GNENet::retrieveEdges(bool onlySelected) {
554  std::vector<GNEEdge*> result;
555  for (GNEEdges::const_iterator it = myEdges.begin(); it != myEdges.end(); ++it) {
556  if (!onlySelected || gSelected.isSelected(GLO_EDGE, it->second->getGlID())) {
557  result.push_back(it->second);
558  }
559  }
560  return result;
561 }
562 
563 
564 std::vector<GNELane*>
565 GNENet::retrieveLanes(bool onlySelected) {
566  std::vector<GNELane*> result;
567  for (GNEEdges::const_iterator it = myEdges.begin(); it != myEdges.end(); ++it) {
568  const GNEEdge::LaneVector& lanes = it->second->getLanes();
569  for (GNEEdge::LaneVector::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); ++it_lane) {
570  if (!onlySelected || gSelected.isSelected(GLO_LANE, (*it_lane)->getGlID())) {
571  result.push_back(*it_lane);
572  }
573  }
574  }
575  return result;
576 }
577 
578 
579 std::vector<GNEJunction*>
580 GNENet::retrieveJunctions(bool onlySelected) {
581  std::vector<GNEJunction*> result;
582  for (GNEJunctions::const_iterator it = myJunctions.begin(); it != myJunctions.end(); it++) {
583  if (!onlySelected || gSelected.isSelected(GLO_JUNCTION, it->second->getGlID())) {
584  result.push_back(it->second);
585  }
586  }
587  return result;
588 }
589 
590 
591 void
595  update();
596 }
597 
598 
599 std::vector<GNEAttributeCarrier*>
600 GNENet::retrieveAttributeCarriers(const std::set<GUIGlID>& ids, GUIGlObjectType type) {
601  std::vector<GNEAttributeCarrier*> result;
602  for (std::set<GUIGlID>::iterator it = ids.begin(); it != ids.end(); it++) {
604  if (object != 0) {
605  std::string id = object->getMicrosimID();
607  GNEAttributeCarrier* ac = 0;
608  switch (type) {
609  case GLO_JUNCTION:
610  ac = dynamic_cast<GNEJunction*>(object);
611  break;
612  case GLO_EDGE:
613  ac = dynamic_cast<GNEEdge*>(object);
614  break;
615  case GLO_LANE:
616  ac = dynamic_cast<GNELane*>(object);
617  break;
618  default:
619  break;
620  }
621  if (ac == 0) {
622  throw ProcessError("GUIGlObject does not match the declared type");
623  } else {
624  result.push_back(ac);
625  }
626  } else {
627  throw ProcessError("Attempted to retrieve non-existant GUIGlObject");
628  }
629  }
630  return result;
631 }
632 
633 
634 std::set<GUIGlID>
636  std::set<GUIGlID> result;
637  switch (type) {
638  case GLO_MAX: {
639  std::set<GUIGlObjectType> knownTypes;
640  knownTypes.insert(GLO_JUNCTION);
641  knownTypes.insert(GLO_EDGE);
642  knownTypes.insert(GLO_LANE);
643  // knownTypes.insert(GLO_TLLOGIC); makes no sense to include them
644  for (std::set<GUIGlObjectType>::const_iterator it = knownTypes.begin(); it != knownTypes.end(); it++) {
645  const std::set<GUIGlID> tmp = getGlIDs(*it);
646  result.insert(tmp.begin(), tmp.end());
647  }
648  break;
649  }
650  case GLO_JUNCTION:
651  for (GNEJunctions::const_iterator it = myJunctions.begin(); it != myJunctions.end(); it++) {
652  result.insert(it->second->getGlID());
653  }
654  break;
655  case GLO_EDGE:
656  for (GNEEdges::const_iterator it = myEdges.begin(); it != myEdges.end(); it++) {
657  result.insert(it->second->getGlID());
658  }
659  break;
660  case GLO_LANE: {
661  for (GNEEdges::const_iterator it = myEdges.begin(); it != myEdges.end(); it++) {
662  const std::set<GUIGlID> laneIDs = it->second->getLaneGlIDs();
663  for (std::set<GUIGlID>::const_iterator lid_it = laneIDs.begin(); lid_it != laneIDs.end(); lid_it++) {
664  result.insert(*lid_it);
665  }
666  }
667  break;
668  }
669  case GLO_TLLOGIC: {
670  // return all junctions which have a traffic light (we do not
671  // have a GUIGlObject for each traffic light)
672  for (GNEJunctions::const_iterator it = myJunctions.begin(); it != myJunctions.end(); it++) {
673  if (it->second->getNBNode()->isTLControlled()) {
674  result.insert(it->second->getGlID());
675  }
676  }
677  break;
678  }
679  default: // add other types once we know them
680  break;
681  }
682  return result;
683 }
684 
685 
686 void
688  if (!myNeedRecompute) {
689  if (force) {
690  window->setStatusBarText("Forced computing junctions ...");
691  } else {
692  return;
693  }
694  } else {
695  window->setStatusBarText("Computing junctions ...");
696  }
697  // compute
699  computeAndUpdate(oc);
700  WRITE_MESSAGE("\nFinished computing junctions.");
701 
702  window->getApp()->endWaitCursor();
703  window->setStatusBarText("Finished computing junctions.");
704  update();
705 }
706 
707 
708 void
710  // recompute tl-logics
713 
714  NBNode* nbn = junction->getNBNode();
715  std::set<NBTrafficLightDefinition*> tldefs = nbn->getControllingTLS();
716  for (std::set<NBTrafficLightDefinition*>::iterator it = tldefs.begin(); it != tldefs.end(); it++) {
717  NBTrafficLightDefinition* def = *it;
720  tllCont.computeSingleLogic(oc, def);
721  }
722 
723  // @todo compute connections etc...
724 }
725 
726 
727 void
729  std::vector<GNEJunction*> selected = retrieveJunctions(true);
730  if (selected.size() < 2) {
731  return;
732  }
733  undoList->p_begin("Join selected junctions");
734 
735  EdgeVector allIncoming;
736  EdgeVector allOutgoing;
737  std::set<NBNode*> cluster;
738  for (std::vector<GNEJunction*>::iterator it = selected.begin(); it != selected.end(); it++) {
739  cluster.insert((*it)->getNBNode());
740  const EdgeVector& incoming = (*it)->getNBNode()->getIncomingEdges();
741  allIncoming.insert(allIncoming.end(), incoming.begin(), incoming.end());
742  const EdgeVector& outgoing = (*it)->getNBNode()->getOutgoingEdges();
743  allOutgoing.insert(allOutgoing.end(), outgoing.begin(), outgoing.end());
744  }
745  // create new junction
746  Position pos;
747  bool setTL;
748  std::string id;
749  TrafficLightType type;
750  myNetBuilder->getNodeCont().analyzeCluster(cluster, id, pos, setTL, type);
751  // XXX this is not undone when calling 'undo'
753  GNEJunction* joined = createJunction(pos, undoList);
754  if (setTL) {
756  // XXX ticket831
757  //joined-><getTrafficLight>->setAttribute(SUMO_ATTR_TYPE, toString(type), undoList);
758  }
759  // remap edges
760  for (EdgeVector::const_iterator it = allIncoming.begin(); it != allIncoming.end(); it++) {
761  GNEEdge* oldEdge = myEdges[(*it)->getID()];
762  remapEdge(oldEdge, oldEdge->getSource(), joined, undoList, true);
763  }
764  for (EdgeVector::const_iterator it = allOutgoing.begin(); it != allOutgoing.end(); it++) {
765  GNEEdge* oldEdge = myEdges[(*it)->getID()];
766  remapEdge(oldEdge, joined, oldEdge->getDest(), undoList, true);
767  }
768  // delete original junctions
769  for (std::vector<GNEJunction*>::iterator it = selected.begin(); it != selected.end(); it++) {
770  deleteJunction(*it, undoList);
771  }
772  joined->setAttribute(SUMO_ATTR_ID, id, undoList);
773  undoList->p_end();
774 }
775 
776 
777 void
779  undoList->p_begin("Clean junctions");
780  std::vector<GNEJunction*> toRemove;
781  for (GNEJunctions::const_iterator it = myJunctions.begin(); it != myJunctions.end(); it++) {
782  GNEJunction* junction = it->second;
783  if (junction->getNBNode()->getEdges().size() == 0) {
784  toRemove.push_back(junction);
785  }
786  }
787  for (std::vector<GNEJunction*>::iterator it = toRemove.begin(); it != toRemove.end(); ++it) {
788  deleteJunction(*it, undoList);
789  }
790  undoList->p_end();
791 }
792 
793 
794 void
796  undoList->p_begin("Replace junction by geometry");
797  assert(junction->getNBNode()->checkIsRemovable());
798  std::vector<std::pair<NBEdge*, NBEdge*> > toJoin = junction->getNBNode()->getEdgesToJoin();
799  for (std::vector<std::pair<NBEdge*, NBEdge*> >::iterator j = toJoin.begin(); j != toJoin.end(); j++) {
800  GNEEdge* begin = myEdges[(*j).first->getID()];
801  GNEEdge* continuation = myEdges[(*j).second->getID()];
802  deleteEdge(begin, undoList);
803  deleteEdge(continuation, undoList);
804  GNEEdge* newEdge = createEdge(begin->getSource(), continuation->getDest(), begin, undoList, begin->getMicrosimID(), false, true);
805  PositionVector newShape = begin->getNBEdge()->getInnerGeometry();
806  newShape.push_back(junction->getNBNode()->getPosition());
807  newShape.append(continuation->getNBEdge()->getInnerGeometry());
808  newEdge->setAttribute(SUMO_ATTR_SHAPE, toString(newShape), undoList);
809  // @todo what about trafficlights at the end of oontinuation?
810  }
811  deleteJunction(junction, undoList);
812  undoList->p_end();
813 }
814 
815 void
816 GNENet::renameEdge(GNEEdge* edge, const std::string& newID) {
817  myEdges.erase(edge->getNBEdge()->getID());
818  myNetBuilder->getEdgeCont().rename(edge->getNBEdge(), newID);
819  edge->setMicrosimID(newID);
820  myEdges[newID] = edge;
821 }
822 
823 
824 void
825 GNENet::changeEdgeEndpoints(GNEEdge* edge, const std::string& newSource, const std::string& newDest) {
826  NBNode* from = retrieveJunction(newSource)->getNBNode();
827  NBNode* to = retrieveJunction(newDest)->getNBNode();
828  edge->getNBEdge()->reinitNodes(from, to);
830  update();
831 }
832 
833 
834 void
835 GNENet::renameJunction(GNEJunction* junction, const std::string& newID) {
836  myJunctions.erase(junction->getNBNode()->getID());
837  myNetBuilder->getNodeCont().rename(junction->getNBNode(), newID);
838  junction->setMicrosimID(newID);
839  myJunctions[newID] = junction;
840 }
841 
842 
843 void
845  myExplicitTurnarounds.insert(id);
846 }
847 
848 
849 void
851  myExplicitTurnarounds.erase(id);
852 }
853 
854 
855 void
856 GNENet::moveSelection(const Position& moveSrc, const Position& moveDest) {
857  Position delta = moveDest - moveSrc;
858  // move junctions
859  std::set<GNEJunction*> junctionSet;
860  std::vector<GNEJunction*> junctions = retrieveJunctions(true);
861  for (std::vector<GNEJunction*>::iterator it = junctions.begin(); it != junctions.end(); it++) {
862  Position newPos = (*it)->getNBNode()->getPosition() + delta;
863  (*it)->move(newPos);
864  junctionSet.insert(*it);
865  }
866 
867  // move edge geometry (endpoints are already moved)
868  std::vector<GNEEdge*> edges = retrieveEdges(true);
869  for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
870  GNEEdge* edge = *it;
871  if (edge) {
872  if (junctionSet.count(edge->getSource()) > 0 &&
873  junctionSet.count(edge->getDest()) > 0) {
874  // edge and its endpoints are selected, move all the inner points as well
875  edge->moveGeometry(delta);
876  } else {
877  // move only geometry near mouse
878  edge->moveGeometry(moveSrc, delta, true);
879  }
880  }
881  }
882 }
883 
884 
885 void
887  undoList->p_begin("move selection");
888  // register moved junctions
889  std::set<GNEJunction*> junctionSet;
890  std::vector<GNEJunction*> junctions = retrieveJunctions(true);
891  for (std::vector<GNEJunction*>::iterator it = junctions.begin(); it != junctions.end(); it++) {
892  (*it)->registerMove(undoList);
893  junctionSet.insert(*it);
894  }
895 
896  // register moved edge geometry (endpoints are already moved)
897  std::vector<GNEEdge*> edges = retrieveEdges(true);
898  for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
899  GNEEdge* edge = *it;
900  if (edge) {
901  const std::string& newShape = edge->getAttribute(SUMO_ATTR_SHAPE);
902  edge->setAttribute(SUMO_ATTR_SHAPE, newShape, undoList);
903  }
904  }
905  undoList->p_end();
906 }
907 
908 // ===========================================================================
909 // private
910 // ===========================================================================
911 void
913  myNetBuilder->getNodeCont().insert(junction->getNBNode());
914  registerJunction(junction);
915 }
916 
917 
918 void
920  NBEdge* nbe = edge->getNBEdge();
921  myNetBuilder->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
922  // if this edge was previouls extracted from the edgeContainer we have to
923  // rewire the nodes
924  nbe->getFromNode()->addOutgoingEdge(nbe);
925  nbe->getToNode()->addIncomingEdge(nbe);
926  registerEdge(edge);
927 }
928 
929 
932  junction->incRef("GNENet::registerJunction");
933  junction->setResponsible(false);
934  myJunctions[junction->getMicrosimID()] = junction;
935  myGrid.add(junction->getBoundary());
936  myGrid.addAdditionalGLObject(junction);
937  // @todo let Boundary class track z-coordinate natively
938  const SUMOReal z = junction->getNBNode()->getPosition().z();
939  if (z != 0) {
941  }
942  update();
943  return junction;
944 }
945 
946 
947 GNEEdge*
949  edge->incRef("GNENet::registerEdge");
950  edge->setResponsible(false);
951  myEdges[edge->getMicrosimID()] = edge;
952  myGrid.add(edge->getBoundary());
954  update();
955  return edge;
956 }
957 
958 
959 void
962  myJunctions.erase(junction->getMicrosimID());
963  myNetBuilder->getNodeCont().extract(junction->getNBNode());
964  junction->decRef("GNENet::deleteSingleJunction");
965  junction->setResponsible(true);
966  update();
967 }
968 
969 
970 void
973  myEdges.erase(edge->getMicrosimID());
976  edge->decRef("GNENet::deleteSingleEdge");
977  edge->setResponsible(true);
978  // invalidate junction logic
979  update();
980 }
981 
982 
983 void
985  if (myUpdateTarget) {
986  myUpdateTarget->update();
987  }
988 }
989 
990 
991 void
992 GNENet::reserveEdgeID(const std::string& id) {
994 }
995 
996 
997 void
998 GNENet::reserveJunctionID(const std::string& id) {
1000 }
1001 
1002 
1003 void
1005  // make sure we only add turn arounds to edges which currently exist within the network
1006  std::set<std::string> liveExplicitTurnarounds;
1007  for (std::set<std::string>::const_iterator it = myExplicitTurnarounds.begin(); it != myExplicitTurnarounds.end(); it++) {
1008  if (myEdges.count(*it) > 0) {
1009  liveExplicitTurnarounds.insert(*it);
1010  }
1011  }
1012  myNetBuilder->compute(oc, liveExplicitTurnarounds, false);
1013  // update precomputed lane geometries
1014  for (GNEEdges::const_iterator it = myEdges.begin(); it != myEdges.end(); it++) {
1015  it->second->updateLaneGeometries();
1016  }
1017  for (GNEJunctions::const_iterator it = myJunctions.begin(); it != myJunctions.end(); it++) {
1018  it->second->setLogicValid(true);
1019  // updated shape
1020  it->second->updateBoundary();
1021  refreshElement(it->second);
1022  }
1023  myNeedRecompute = false;
1024 }
1025 /****************************************************************************/
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
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEJunction.h:185
virtual void setParticipantsInformation()
Builds the list of participating nodes/edges/links.
const EdgeVector & getIncomingEdges() const
Returns this node&#39;s incoming edges.
Definition: NBNode.h:240
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
Definition: GNENet.cpp:565
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
SUMOReal getHeight() const
Returns the height of the boundary.
Definition: Boundary.cpp:142
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:541
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:201
IDSupplier myEdgeIDSupplier
Definition: GNENet.h:427
is a pedestrian
SUMOReal getWidth() const
Returns the width of the boudary.
Definition: Boundary.cpp:136
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
Definition: NBEdgeCont.cpp:519
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
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
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:770
A container for traffic light definitions and built programs.
void compute(OptionsCont &oc, const std::set< std::string > &explicitTurnarounds=std::set< std::string >(), bool removeElements=true)
Performs the network building steps.
void setLogicValid(bool valid, GNEUndoList *undoList=0, const std::string &status=GUESSED)
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:124
Stores the information about how to visualize structures.
std::set< GUIGlID > getGlIDs(GUIGlObjectType type=GLO_MAX)
Definition: GNENet.cpp:635
void addIncomingEdge(NBEdge *edge)
adds an incoming edge
Definition: NBNode.cpp:424
The representation of a single edge during network building.
Definition: NBEdge.h:70
void reinitNodes(NBNode *from, NBNode *to)
Resets nodes but keeps all other values the same (used when joining)
Definition: NBEdge.cpp:314
Position moveGeometry(const Position &oldPos, const Position &newPos, bool relative=false)
change the edge geometry without registering undo/redo It is up to the Edge to decide whether an new ...
Definition: GNEEdge.cpp:231
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNENet.cpp:202
static void writeJoinedJunctions(const OptionsCont &oc, NBNodeCont &nc)
Writes the joined-juncionts to file.
void computeEverything(GNEApplicationWindow *window, bool force=false)
Definition: GNENet.cpp:687
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.h:108
std::vector< GNELane * > LaneVector
Definition of the lane&#39;s positions vector.
Definition: GNEEdge.h:68
void removeAdditionalGLObject(GUIGlObject *o)
Removes an additional object (detector/shape/trigger) from being visualised.
Definition: SUMORTree.h:141
void avoid(const std::string &id)
make sure that the given id is never supplied
Definition: IDSupplier.cpp:71
void reverseEdge(GNEEdge *edge, GNEUndoList *undoList)
reverse edge
Definition: GNENet.cpp:425
The base class for traffic light logic definitions.
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 buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:167
SUMOReal getTotalWidth() const
Returns the combined width of all lanes of this edge.
Definition: NBEdge.cpp:2318
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:401
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
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
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 p_begin(const std::string &description)
Definition: GNEUndoList.cpp:75
void addExplicitTurnaround(std::string id)
add edge id to the list of explicit turnarounds
Definition: GNENet.cpp:844
void rename(NBEdge *edge, const std::string &newID)
Renames the edge. Throws exception if newID already exists.
Definition: NBEdgeCont.cpp:399
void insertEdge(GNEEdge *edge)
inserts a single edge into the net and into the underlying
Definition: GNENet.cpp:919
bool checkIsRemovable() const
Definition: NBNode.cpp:1564
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:203
unsigned int getIndex() const
Definition: GNELane.h:139
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList)
removes edge
Definition: GNENet.cpp:299
static void sortNodesEdges(NBNodeCont &nc, bool useNodeShape=false)
Sorts a node&#39;s edges clockwise regarding driving direction.
void registerMove(GNEUndoList *undoList)
registers completed movement with the undoList
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used, also builds an entry for copying the geo-position.
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
Definition: NBNode.cpp:434
void remapEdge(GNEEdge *oldEdge, GNEJunction *from, GNEJunction *to, GNEUndoList *undoList, bool keepEndpoints=false)
Definition: GNENet.cpp:493
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:123
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
void setNetObject(GUIGlObject *object)
Sets the given object as the "network" object.
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GNENet.cpp:173
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
PositionVector reverse() const
void renameJunction(GNEJunction *junction, const std::string &newID)
updates the map and reserves new id
Definition: GNENet.cpp:835
const EdgeVector & getOutgoingEdges() const
Returns this node&#39;s outgoing edges.
Definition: NBNode.h:248
IDSupplier myJunctionIDSupplier
Definition: GNENet.h:428
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:122
const std::string & getID() const
Returns the id.
Definition: Named.h:65
SVCPermissions permissions
List of vehicle types that are allowed on this lane.
Definition: NBEdge.h:132
const PositionVector getInnerGeometry() const
Returns the geometry of the edge without the endpoints.
Definition: NBEdge.cpp:417
const Position & getPosition() const
Returns the position of this node.
Definition: NBNode.h:228
const std::set< GUIGlID > & getSelected() const
Returns the list of ids of all selected objects.
std::string getNext()
Returns the next id.
Definition: IDSupplier.cpp:63
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node.
Definition: NBNode.h:318
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:161
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
void extract(NBDistrictCont &dc, NBEdge *edge, bool remember=false)
Removes the given edge from the container like erase but does not delete it.
Definition: NBEdgeCont.cpp:387
void p_end()
Definition: GNEUndoList.cpp:82
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
NBEdgeCont & getEdgeCont()
Returns the edge container.
Definition: NBNetBuilder.h:154
A list of positions.
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
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
a tl-logic
Boundary getBoundary() const
Returns the street&#39;s geometry.
Definition: GNEEdge.cpp:98
SUMOReal z() const
Returns the z-position.
Definition: Position.h:73
void removeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
void computeJunction(GNEJunction *junction)
Definition: GNENet.cpp:709
const EdgeVector & getEdges() const
Returns all edges which participate in this node.
Definition: NBNode.h:256
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
NBNode * getNBNode()
returns the internal NBNode
Definition: GNEJunction.h:153
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network into XML-files (nodes, edges, connections, traffic lights)
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
std::vector< std::string > getAllNames() const
get all node names
friend class GNEChange_Edge
Definition: GNENet.h:80
const std::string getID() const
function to support debugging
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::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:54
void incRef(const std::string &debugMsg="")
std::set< std::string > myExplicitTurnarounds
list of edge ids for which turn-arounds must be added explicitly
Definition: GNENet.h:435
void decRef(const std::string &debugMsg="")
void rename(NBNode *node, const std::string &newID)
Renames the node. Throws exception if newID already exists.
std::vector< std::pair< NBEdge *, NBEdge * > > getEdgesToJoin() const
Definition: NBNode.cpp:1615
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.h:132
std::pair< PositionVector, PositionVector > splitAt(SUMOReal where) const
Returns the two lists made when this list vector is splitted at the given point.
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network stored in the given net builder.
Definition: NWFrame.cpp:137
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
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:76
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.h:193
static int _2int(const E *const data)
Definition: TplConvert.h:114
void deleteSingleJunction(GNEJunction *junction)
deletes a single junction
Definition: GNENet.cpp:960
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:369
~GNENet()
Destructor.
Definition: GNENet.cpp:142
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:246
bool deleteGeometry(const Position &pos, GNEUndoList *undoList)
deletes the closest geometry node within SNAP_RADIUS.
Definition: GNEEdge.cpp:297
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
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object (happens in NETEDIT)
NBNodeCont & getNodeCont()
Returns the node container.
Definition: NBNetBuilder.h:162
void addAdditionalGLObject(GUIGlObject *o)
Adds an additional object (detector/shape/trigger) for visualisation.
Definition: SUMORTree.h:129
bool computeSingleLogic(OptionsCont &oc, NBTrafficLightDefinition *def)
Computes a specific traffic light logic (using by NETEDIT)
GNENet(NBNetBuilder *netBuilder)
Constructor.
Definition: GNENet.cpp:88
Boundary getBoundary() const
Returns the boundary of the junction.
Definition: GNEJunction.h:123
Instance responsible for building networks.
Definition: NBNetBuilder.h:113
friend class GNEChange_Junction
Definition: GNENet.h:79
void removeSolitaryJunctions(GNEUndoList *undoList)
Definition: GNENet.cpp:778
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:41
void analyzeCluster(std::set< NBNode * > cluster, std::string &id, Position &pos, bool &hasTLS, TrafficLightType &type)
Definition: NBNodeCont.cpp:776
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:523
void move(Position pos)
reposition the node at pos and informs the edges
A storage for options typed value containers)
Definition: OptionsCont.h:108
The popup menu of a globject.
an edge
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
Definition: NBNodeCont.cpp:80
GNEJunction * getDest() const
returns the destination-junction
Definition: GNEEdge.cpp:135
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
The network - empty.
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge&#39;s lanes&#39; lateral offset is computed.
Definition: NBEdge.h:603
void removeExplicitTurnaround(std::string id)
remove edge id from the list of explicit turnarounds
Definition: GNENet.cpp:850
Represents a single node (junction) during network building.
Definition: NBNode.h:74
void saveJoined(OptionsCont &oc)
save log of joined junctions (and nothing else)
Definition: GNENet.cpp:522
Lane & getLaneStruct(unsigned int lane)
Definition: NBEdge.h:1067
GNEEdge * addReversedEdge(GNEEdge *edge, GNEUndoList *undoList)
add reversed edge
Definition: GNENet.cpp:436
void move2side(SUMOReal amount)
#define SUMOReal
Definition: config.h:213
GNEEdges myEdges
Definition: GNENet.h:422
static const RGBColor selectionColor
Definition: GNENet.h:83
empty max
void unblockObject(GUIGlID id)
Marks an object as unblocked.
void reserveEdgeID(const std::string &id)
Definition: GNENet.cpp:992
void deleteSingleEdge(GNEEdge *edge)
deletes a single edge
Definition: GNENet.cpp:971
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:109
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:64
void mergeJunctions(GNEJunction *moved, GNEJunction *target, GNEUndoList *undoList)
merge the given junctions edges between the given junctions will be deleted
Definition: GNENet.cpp:469
bool extract(NBNode *node, bool remember=false)
Removes the given node but does not delete it.
Definition: NBNodeCont.cpp:150
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
NBDistrictCont & getDistrictCont()
Returns the districts container.
Definition: NBNetBuilder.h:186
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:467
GUISelectedStorage gSelected
A global holder of selected objects.
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
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.h:224
void setStatusBarText(const std::string &)
GNEJunction * getSource() const
returns the source-junction
Definition: GNEEdge.cpp:129
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
virtual void setTLControllingInformation() const =0
Informs edges about being controlled by a tls.
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
void append(const PositionVector &v, SUMOReal sameThreshold=2.0)
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
TrafficLightType
void registerJoinedCluster(const std::set< NBNode * > &cluster)
gets all joined clusters (see doc for myClusters2Join)
Definition: NBNodeCont.cpp:766
a junction
void finishMoveSelection(GNEUndoList *undoList)
register changes to junction and edge positions with the undoList
Definition: GNENet.cpp:886
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:361