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-2017 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 <map>
40 #include <set>
41 #include <vector>
42 
43 #include <netbuild/NBAlgorithms.h>
44 #include <netwrite/NWFrame.h>
45 #include <netwrite/NWWriter_XML.h>
46 #include <utility>
48 #include <utils/common/RGBColor.h>
60 
61 #include "GNEAdditional.h"
62 #include "GNEAdditionalFrame.h"
63 #include "GNEApplicationWindow.h"
64 #include "GNEChange_Additional.h"
65 #include "GNEChange_Attribute.h"
66 #include "GNEChange_Connection.h"
67 #include "GNEChange_Crossing.h"
68 #include "GNEChange_Edge.h"
69 #include "GNEChange_Junction.h"
70 #include "GNEChange_Lane.h"
71 #include "GNEChange_Selection.h"
72 #include "GNEConnection.h"
73 #include "GNECrossing.h"
74 #include "GNEDetector.h"
75 #include "GNEEdge.h"
76 #include "GNEJunction.h"
77 #include "GNELane.h"
78 #include "GNENet.h"
79 #include "GNEStoppingPlace.h"
80 #include "GNEUndoList.h"
81 #include "GNEViewNet.h"
82 #include "GNEViewParent.h"
83 
84 
85 #ifdef CHECK_MEMORY_LEAKS
86 #include <foreign/nvwa/debug_new.h>
87 #endif // CHECK_MEMORY_LEAKS
88 
89 
90 // ===========================================================================
91 // static members
92 // ===========================================================================
93 const RGBColor GNENet::selectionColor(0, 0, 204, 255);
94 const RGBColor GNENet::selectedLaneColor(0, 0, 128, 255);
95 const RGBColor GNENet::selectedConnectionColor(0, 0, 100, 255);
97 
98 // ===========================================================================
99 // member method definitions
100 // ===========================================================================
103  myViewNet(0),
104  myNetBuilder(netBuilder),
105  myJunctions(),
106  myEdges(),
107  myEdgeIDSupplier("gneE", netBuilder->getEdgeCont().getAllNames()),
108  myJunctionIDSupplier("gneJ", netBuilder->getNodeCont().getAllNames()),
109  myShapeContainer(myGrid),
110  myNeedRecompute(true) {
112 
113  // init junctions (by default Crossing and walking areas aren't created)
115  const std::vector<std::string>& nodeNames = nc.getAllNames();
116  for (std::vector<std::string>::const_iterator name_it = nodeNames.begin(); name_it != nodeNames.end(); ++name_it) {
117  NBNode* nbn = nc.retrieve(*name_it);
118  registerJunction(new GNEJunction(*nbn, this, true));
119  }
120 
121  // init edges
123  const std::vector<std::string>& edgeNames = ec.getAllNames();
124  for (std::vector<std::string>::const_iterator name_it = edgeNames.begin(); name_it != edgeNames.end(); ++name_it) {
125  NBEdge* nbe = ec.retrieve(*name_it);
126  registerEdge(new GNEEdge(*nbe, this, false, true));
127  if (myGrid.getWidth() > 10e16 || myGrid.getHeight() > 10e16) {
128  throw ProcessError("Network size exceeds 1 Lightyear. Please reconsider your inputs.\n");
129  }
130  }
131 
132  // make sure myGrid is initialized even for an empty net
133  if (myEdges.size() == 0) {
134  myGrid.add(Boundary(0, 0, 100, 100));
135  }
136 
137  // sort nodes edges so that arrows can be drawn correctly
139 
140  /*
141  // initialise detector storage for gui
142  initDetectors();
143  // initialise the tl-map
144  initTLMap();
145  // initialise edge storage for gui
146  GUIEdge::fill(myEdgeWrapper);
147  */
148  //if (myGrid.count() == 0) // myGrid methods will return garbage
149 
150  // Init AdditionalHandler
151 
152  if (myZBoundary.ymin() != Z_INITIALIZED) {
153  myZBoundary.add(0, 0);
154  }
155 }
156 
157 
159  /*
160  // delete allocated wrappers
161  // of junctions
162  for (std::vector<GUIJunctionWrapper*>::iterator i1=myJunctionWrapper.begin(); i1!=myJunctionWrapper.end(); i1++) {
163  delete(*i1);
164  }
165  // of additional structures
166  GUIGlObject_AbstractAdd::clearDictionary();
167  // of tl-logics
168  for (Logics2WrapperMap::iterator i3=myLogics2Wrapper.begin(); i3!=myLogics2Wrapper.end(); i3++) {
169  delete(*i3).second;
170  }
171  // of detectors
172  for (std::map<std::string, GUIDetectorWrapper*>::iterator i=myDetectorDict.begin(); i!=myDetectorDict.end(); ++i) {
173  delete(*i).second;
174  }
175  */
176  for (GNEEdges::iterator it = myEdges.begin(); it != myEdges.end(); it++) {
177  it->second->decRef("GNENet::~GNENet");
178  delete it->second;
179  }
180  for (GNEJunctions::iterator it = myJunctions.begin(); it != myJunctions.end(); it++) {
181  it->second->decRef("GNENet::~GNENet");
182  delete it->second;
183  }
184  delete myNetBuilder;
185 }
186 
187 
188 const Boundary&
190  // SUMORTree is also a Boundary
191  return myGrid;
192 }
193 
194 
197  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
198  buildPopupHeader(ret, app);
200  buildPositionCopyEntry(ret, false);
201  return ret;
202 }
203 
204 
207  return 0;
208 }
209 
210 
211 void
213 }
214 
215 
216 Boundary
218  return getBoundary();
219 }
220 
221 
222 const Boundary&
224  return myZBoundary;
225 }
226 
227 
228 SUMORTree&
230  return myGrid;
231 }
232 
233 
234 const SUMORTree&
236  return myGrid;
237 }
238 
239 
242  std::string id = myJunctionIDSupplier.getNext();
243  NBNode* nbn = new NBNode(id, pos);
244  GNEJunction* junction = new GNEJunction(*nbn, this);
245  undoList->add(new GNEChange_Junction(junction, true), true);
246  assert(myJunctions[id]);
247  return junction;
248 }
249 
250 
251 GNEEdge*
253  GNEJunction* src, GNEJunction* dest, GNEEdge* tpl, GNEUndoList* undoList,
254  const std::string& suggestedName,
255  bool wasSplit,
256  bool allowDuplicateGeom) {
257  // prevent duplicate edge (same geometry)
258  const EdgeVector& outgoing = src->getNBNode()->getOutgoingEdges();
259  for (EdgeVector::const_iterator it = outgoing.begin(); it != outgoing.end(); it++) {
260  if ((*it)->getToNode() == dest->getNBNode() && (*it)->getGeometry().size() == 2) {
261  if (!allowDuplicateGeom) {
262  return 0;
263  }
264  }
265  }
266 
267  std::string id;
268  if (suggestedName != "" && !retrieveEdge(suggestedName, false)) {
269  id = suggestedName;
270  reserveEdgeID(id);
271  } else {
272  id = myEdgeIDSupplier.getNext();
273  }
274 
275  GNEEdge* edge;
276  if (tpl) {
277  NBEdge* nbeTpl = tpl->getNBEdge();
278  NBEdge* nbe = new NBEdge(id, src->getNBNode(), dest->getNBNode(), nbeTpl);
279  edge = new GNEEdge(*nbe, this, wasSplit);
280  } else {
281  // default if no template is given
282  SUMOReal defaultSpeed = 50 / 3.6;
283  std::string defaultType = "";
284  int defaultNrLanes = 1;
285  int defaultPriority = 1;
286  SUMOReal defaultWidth = NBEdge::UNSPECIFIED_WIDTH;
287  SUMOReal defaultOffset = NBEdge::UNSPECIFIED_OFFSET;
288  NBEdge* nbe = new NBEdge(id, src->getNBNode(), dest->getNBNode(),
289  defaultType, defaultSpeed,
290  defaultNrLanes, defaultPriority,
291  defaultWidth,
292  defaultOffset);
293  edge = new GNEEdge(*nbe, this, wasSplit);
294  }
295  undoList->p_begin("create " + toString(SUMO_TAG_EDGE));
296  undoList->add(new GNEChange_Edge(edge, true), true);
297  src->setLogicValid(false, undoList);
298  dest->setLogicValid(false, undoList);
300  undoList->p_end();
301  assert(myEdges[id]);
302  return edge;
303 }
304 
305 
306 void
308  // we have to delete all incident edges because they cannot exist without that junction
309  // all deletions must be undone/redone together so we start a new command group
310  // @todo if any of those edges are dead-ends should we remove their orphan junctions as well?
311  undoList->p_begin("delete " + toString(SUMO_TAG_JUNCTION));
312 
313  // delete all crossings vinculated with junction
314  while (junction->getGNECrossings().size() > 0) {
315  deleteCrossing(junction->getGNECrossings().front(), undoList);
316  }
317 
318  // deleting edges changes in the underlying EdgeVector so we have to make a copy
319  const EdgeVector incident = junction->getNBNode()->getEdges();
320  for (EdgeVector::const_iterator it = incident.begin(); it != incident.end(); it++) {
321  deleteEdge(myEdges[(*it)->getID()], undoList);
322  }
323 
324  // remove any traffic lights from the traffic light container (avoids lots of warnings)
325  junction->setAttribute(SUMO_ATTR_TYPE, toString(NODETYPE_PRIORITY), undoList);
326  undoList->add(new GNEChange_Junction(junction, false), true);
327  if (gSelected.isSelected(GLO_JUNCTION, junction->getGlID())) {
328  std::set<GUIGlID> deselected;
329  deselected.insert(junction->getGlID());
330  undoList->add(new GNEChange_Selection(this, std::set<GUIGlID>(), deselected, true), true);
331  }
332  undoList->p_end();
333 }
334 
335 
336 void
338  undoList->p_begin("delete " + toString(SUMO_TAG_EDGE));
339  // delete additionals childs of edge
340  std::vector<GNEAdditional*> copyOfEdgeAdditionals = edge->getAdditionalChilds();
341  for (std::vector<GNEAdditional*>::iterator i = copyOfEdgeAdditionals.begin(); i != copyOfEdgeAdditionals.end(); i++) {
342  undoList->add(new GNEChange_Additional((*i), false), true);
343  }
344  // delete additionals childs of lane
345  for (std::vector<GNELane*>::const_iterator i = edge->getLanes().begin(); i != edge->getLanes().end(); i++) {
346  std::vector<GNEAdditional*> copyOfLaneAdditionals = (*i)->getAdditionalChilds();
347  for (std::vector<GNEAdditional*>::iterator j = copyOfLaneAdditionals.begin(); j != copyOfLaneAdditionals.end(); j++) {
348  undoList->add(new GNEChange_Additional((*j), false), true);
349  }
350  }
351 
352  // invalidate junction (saving connections)
353  edge->getGNEJunctionSource()->removeFromCrossings(edge, undoList);
354  edge->getGNEJunctionDestiny()->removeFromCrossings(edge, undoList);
355  edge->getGNEJunctionSource()->setLogicValid(false, undoList);
356  edge->getGNEJunctionDestiny()->setLogicValid(false, undoList);
357 
358  // Delete edge
359  undoList->add(new GNEChange_Edge(edge, false), true);
360 
361  // If previously was selected
362  if (gSelected.isSelected(GLO_EDGE, edge->getGlID())) {
363  std::set<GUIGlID> deselected;
364  deselected.insert(edge->getGlID());
365  undoList->add(new GNEChange_Selection(this, std::set<GUIGlID>(), deselected, true), true);
366  }
367 
369  undoList->p_end();
370 }
371 
372 
373 void
375  GNEEdge* edge = &lane->getParentEdge();
376  if (edge->getNBEdge()->getNumLanes() == 1) {
377  // remove the whole edge instead
378  deleteEdge(edge, undoList);
379  } else {
380  undoList->p_begin("delete " + toString(SUMO_TAG_LANE));
381  // delete additionals childs of lane
382  std::vector<GNEAdditional*> copyOfAdditionals = lane->getAdditionalChilds();
383  for (std::vector<GNEAdditional*>::const_iterator i = copyOfAdditionals.begin(); i != copyOfAdditionals.end(); i++) {
384  undoList->add(new GNEChange_Additional((*i), false), true);
385  }
386  // invalidate junctions (saving connections)
387  edge->getGNEJunctionSource()->removeFromCrossings(edge, undoList);
388  edge->getGNEJunctionDestiny()->removeFromCrossings(edge, undoList);
389  edge->getGNEJunctionSource()->setLogicValid(false, undoList);
390  edge->getGNEJunctionDestiny()->setLogicValid(false, undoList);
391 
392  // delete lane
393  const NBEdge::Lane& laneAttrs = edge->getNBEdge()->getLaneStruct(lane->getIndex());
394  undoList->add(new GNEChange_Lane(edge, lane, laneAttrs, false), true);
395  if (gSelected.isSelected(GLO_LANE, lane->getGlID())) {
396  std::set<GUIGlID> deselected;
397  deselected.insert(lane->getGlID());
398  undoList->add(new GNEChange_Selection(this, std::set<GUIGlID>(), deselected, true), true);
399  }
401  undoList->p_end();
402  }
403 }
404 
405 
406 void
408  undoList->p_begin("delete " + toString(SUMO_TAG_CONNECTION));
409  NBConnection deleted = connection->getNBConnection();
410  GNEJunction* affected = connection->getEdgeFrom()->getGNEJunctionDestiny();
411  affected->markAsModified(undoList);
412  undoList->add(new GNEChange_Connection(connection->getEdgeFrom(), connection->getNBEdgeConnection(), false), true);
413  affected->invalidateTLS(myViewNet->getUndoList(), deleted);
414  if (gSelected.isSelected(GLO_CONNECTION, connection->getGlID())) {
415  std::set<GUIGlID> deselected;
416  deselected.insert(connection->getGlID());
417  undoList->add(new GNEChange_Selection(this, std::set<GUIGlID>(), deselected, true), true);
418  }
420  undoList->p_end();
421 }
422 
423 
424 void
426  undoList->p_begin("delete crossing");
427  undoList->add(new GNEChange_Crossing(crossing->getParentJunction(), crossing->getNBCrossing().edges,
428  crossing->getNBCrossing().width, crossing->getNBCrossing().priority, false), true);
429  if (gSelected.isSelected(GLO_CROSSING, crossing->getGlID())) {
430  std::set<GUIGlID> deselected;
431  deselected.insert(crossing->getGlID());
432  undoList->add(new GNEChange_Selection(this, std::set<GUIGlID>(), deselected, true), true);
433  }
435  undoList->p_end();
436 }
437 
438 void
440  undoList->p_begin("duplicate " + toString(SUMO_TAG_LANE));
441  GNEEdge* edge = &lane->getParentEdge();
442  const NBEdge::Lane& laneAttrs = edge->getNBEdge()->getLaneStruct(lane->getIndex());
443  GNELane* newLane = new GNELane(*edge, lane->getIndex());
444  undoList->add(new GNEChange_Lane(edge, newLane, laneAttrs, true), true);
446  undoList->p_end();
447 }
448 
449 
450 bool
452  bool addRestriction = true;
453  if (vclass == SVC_PEDESTRIAN) {
454  GNEEdge& edge = lane->getParentEdge();
455  for (std::vector<GNELane*>::const_iterator i = edge.getLanes().begin(); i != edge.getLanes().end(); i++) {
456  if ((*i)->isRestricted(SVC_PEDESTRIAN)) {
457  // prevent adding a 2nd sidewalk
458  addRestriction = false;
459  } else {
460  // ensure that the sidewalk is used exclusively
461  const SVCPermissions allOldWithoutPeds = edge.getNBEdge()->getPermissions((*i)->getIndex()) & ~SVC_PEDESTRIAN;
462  (*i)->setAttribute(SUMO_ATTR_ALLOW, getVehicleClassNames(allOldWithoutPeds), undoList);
463  }
464  }
465  }
466  // restrict the lane
467  if (addRestriction) {
468  lane->setAttribute(SUMO_ATTR_ALLOW, toString(vclass), undoList);
469  return true;
470  } else {
471  return false;
472  }
473 }
474 
475 
476 bool
478  // First check that this lane is restricted
479  if (lane->isRestricted(SVC_PEDESTRIAN) == false &&
480  lane->isRestricted(SVC_BICYCLE) == false &&
481  lane->isRestricted(SVC_BUS) == false) {
482  return false;
483  }
484 
485  // Get all possible vehicle classes
486  std::vector<std::string> VClasses = SumoVehicleClassStrings.getStrings();
487  // Change allow and disallow attributes of lane
488  lane->setAttribute(SUMO_ATTR_ALLOW, joinToString(VClasses, " "), undoList);
489  lane->setAttribute(SUMO_ATTR_DISALLOW, std::string(), undoList);
490  return true;
491 }
492 
493 
494 bool
496  // First check that edge don't have a sidewalk
497  for (std::vector<GNELane*>::const_iterator i = edge.getLanes().begin(); i != edge.getLanes().end(); i++) {
498  if ((*i)->isRestricted(vclass)) {
499  return false;
500  }
501  }
502  // duplicate last lane
503  duplicateLane(edge.getLanes().at(0), undoList);
504  // transform the created (last) lane to a sidewalk
505  return restrictLane(vclass, edge.getLanes()[0], undoList);
506 }
507 
508 
509 bool
511  // iterate over lanes of edge
512  for (std::vector<GNELane*>::const_iterator i = edge.getLanes().begin(); i != edge.getLanes().end(); i++) {
513  if ((*i)->isRestricted(vclass)) {
514  // Delete lane
515  deleteLane(*i, undoList);
516  return true;
517  }
518  }
519  return false;
520 }
521 
522 
523 void
525  if (!edge->deleteGeometry(pos, undoList)) {
526  deleteEdge(edge, undoList);
527  }
528 }
529 
530 
532 GNENet::splitEdge(GNEEdge* edge, const Position& pos, GNEUndoList* undoList, GNEJunction* newJunction) {
533  undoList->p_begin("split " + toString(SUMO_TAG_EDGE));
534  deleteEdge(edge, undoList); // still exists. we delete it so we can reuse the name in case of resplit
535  // compute geometry
536  const PositionVector& oldGeom = edge->getNBEdge()->getGeometry();
537  const SUMOReal linePos = oldGeom.nearest_offset_to_point2D(pos, false);
538  std::pair<PositionVector, PositionVector> newGeoms = oldGeom.splitAt(linePos);
539  // figure out the new name
540  int posBase = 0;
541  std::string baseName = edge->getMicrosimID();
542  if (edge->wasSplit()) {
543  const std::string::size_type sep_index = baseName.rfind('.');
544  if (sep_index != std::string::npos) { // edge may have been renamed in between
545  std::string posString = baseName.substr(sep_index + 1);
546  try {
547  posBase = TplConvert::_2int(posString.c_str());
548  baseName = baseName.substr(0, sep_index); // includes the .
549  } catch (NumberFormatException) {
550  }
551  }
552  }
553  baseName += '.';
554  // create edges
555  if (newJunction == 0) {
556  newJunction = createJunction(pos, undoList);
557  }
558  GNEEdge* firstPart = createEdge(edge->getGNEJunctionSource(), newJunction, edge,
559  undoList, baseName + toString(posBase), true);
560  GNEEdge* secondPart = createEdge(newJunction, edge->getGNEJunctionDestiny(), edge,
561  undoList, baseName + toString(posBase + (int)linePos), true);
562  // fix geometry
563  firstPart->setAttribute(GNE_ATTR_SHAPE_START, toString(newGeoms.first[0]), undoList);
564  firstPart->setAttribute(GNE_ATTR_SHAPE_END, toString(newGeoms.first[-1]), undoList);
565  newGeoms.first.pop_back();
566  newGeoms.first.erase(newGeoms.first.begin());
567  firstPart->setAttribute(SUMO_ATTR_SHAPE, toString(newGeoms.first), undoList);
568 
569  secondPart->setAttribute(GNE_ATTR_SHAPE_START, toString(newGeoms.second[0]), undoList);
570  secondPart->setAttribute(GNE_ATTR_SHAPE_END, toString(newGeoms.second[-1]), undoList);
571  newGeoms.second.pop_back();
572  newGeoms.second.erase(newGeoms.second.begin());
573  secondPart->setAttribute(SUMO_ATTR_SHAPE, toString(newGeoms.second), undoList);
574  // fix connections
575  std::vector<NBEdge::Connection>& connections = edge->getNBEdge()->getConnections();
576  for (std::vector<NBEdge::Connection>::iterator con_it = connections.begin(); con_it != connections.end(); con_it++) {
577  undoList->add(new GNEChange_Connection(secondPart, *con_it, true), true);
578  }
579  undoList->p_end();
580  return newJunction;
581 }
582 
583 
584 void
585 GNENet::splitEdgesBidi(const std::set<GNEEdge*>& edges, const Position& pos, GNEUndoList* undoList) {
586  GNEJunction* newJunction = 0;
587  undoList->p_begin("split " + toString(SUMO_TAG_EDGE) + "s");
588  for (std::set<GNEEdge*>::const_iterator it = edges.begin(); it != edges.end(); ++it) {
589  newJunction = splitEdge(*it, pos, undoList, newJunction);
590  }
591  undoList->p_end();
592 }
593 
594 
595 void
597  undoList->p_begin("reverse " + toString(SUMO_TAG_EDGE));
598  deleteEdge(edge, undoList); // still exists. we delete it so we can reuse the name in case of resplit
599  GNEEdge* reversed = createEdge(edge->getGNEJunctionDestiny(), edge->getGNEJunctionSource(), edge, undoList, edge->getID(), false, true);
600  assert(reversed != 0);
601  reversed->setAttribute(SUMO_ATTR_SHAPE, toString(edge->getNBEdge()->getInnerGeometry().reverse()), undoList);
602  undoList->p_end();
603 }
604 
605 
606 GNEEdge*
608  undoList->p_begin("add reversed " + toString(SUMO_TAG_EDGE));
609  GNEEdge* reversed = 0;
611  GNEEdge* reversed = createEdge(edge->getGNEJunctionDestiny(), edge->getGNEJunctionSource(), edge, undoList, "-" + edge->getID(), false, true);
612  assert(reversed != 0);
613  reversed->setAttribute(SUMO_ATTR_SHAPE, toString(edge->getNBEdge()->getInnerGeometry().reverse()), undoList);
614  } else {
615  // if the edge is centered it should probably connect somewhere else
616  // make it easy to move and reconnect it
617  PositionVector orig = edge->getNBEdge()->getGeometry();
618  PositionVector origInner = edge->getNBEdge()->getInnerGeometry();
619  const SUMOReal tentativeShift = edge->getNBEdge()->getTotalWidth() + 2;
620  orig.move2side(-tentativeShift);
621  origInner.move2side(-tentativeShift);
622  GNEJunction* src = createJunction(orig.back(), undoList);
623  GNEJunction* dest = createJunction(orig.front(), undoList);
624  GNEEdge* reversed = createEdge(src, dest, edge, undoList, "-" + edge->getID(), false, true);
625  assert(reversed != 0);
626  reversed->setAttribute(SUMO_ATTR_SHAPE, toString(origInner.reverse()), undoList);
627  // select the new edge and its nodes
628  std::set<GUIGlID> toSelect;
629  toSelect.insert(reversed->getGlID());
630  toSelect.insert(src->getGlID());
631  toSelect.insert(dest->getGlID());
632  undoList->add(new GNEChange_Selection(this, toSelect, gSelected.getSelected(), true), true);
633  }
634  undoList->p_end();
635  return reversed;
636 }
637 
638 
639 void
641  undoList->p_begin("merge " + toString(SUMO_TAG_JUNCTION) + "s");
642  // position of moved and target are probably a bit different (snap radius)
643  moved->move(target->getNBNode()->getPosition());
644  // register the move with undolist (must happend within the undo group)
645  moved->registerMove(undoList);
646  // deleting edges changes in the underlying EdgeVector so we have to make a copy
647  const EdgeVector incoming = moved->getNBNode()->getIncomingEdges();
648  for (EdgeVector::const_iterator it = incoming.begin(); it != incoming.end(); it++) {
649  GNEEdge* oldEdge = myEdges[(*it)->getID()];
650  remapEdge(oldEdge, oldEdge->getGNEJunctionSource(), target, undoList);
651  }
652  // deleting edges changes in the underlying EdgeVector so we have to make a copy
653  const EdgeVector outgoing = moved->getNBNode()->getOutgoingEdges();
654  for (EdgeVector::const_iterator it = outgoing.begin(); it != outgoing.end(); it++) {
655  GNEEdge* oldEdge = myEdges[(*it)->getID()];
656  remapEdge(oldEdge, target, oldEdge->getGNEJunctionDestiny(), undoList);
657  }
658  deleteJunction(moved, undoList);
659  undoList->p_end();
660 }
661 
662 
663 void
664 GNENet::remapEdge(GNEEdge* oldEdge, GNEJunction* from, GNEJunction* to, GNEUndoList* undoList, bool keepEndpoints) {
665  deleteEdge(oldEdge, undoList); // delete first so we can reuse the name, reference stays valid
666  if (from != to) {
667  GNEEdge* newEdge = createEdge(from, to, oldEdge, undoList, oldEdge->getMicrosimID(), false, true);
668  newEdge->setAttribute(SUMO_ATTR_SHAPE, oldEdge->getAttribute(SUMO_ATTR_SHAPE), undoList);
669  if (keepEndpoints) {
671  newEdge->setAttribute(GNE_ATTR_SHAPE_END, oldEdge->getAttribute(GNE_ATTR_SHAPE_END), undoList);
672  }
673  }
674  // @todo remap connectivity as well
675 }
676 
677 
678 void
680  // compute and update network
681  computeAndUpdate(oc);
682  // write network
684 }
685 
686 
687 void
688 GNENet::saveAdditionals(const std::string& filename) {
689  OutputDevice& device = OutputDevice::getDevice(filename);
690  device.openTag("additionals");
691  for (GNEAdditionals::const_iterator i = myAdditionals.begin(); i != myAdditionals.end(); ++i) {
692  i->second->writeAdditional(device);
693  }
694  device.close();
695 }
696 
697 
698 void
700  computeAndUpdate(oc);
702 }
703 
704 
705 void
707  computeAndUpdate(oc);
709 }
710 
711 
712 void
714  myViewNet = viewNet;
715 }
716 
717 
719 GNENet::retrieveJunction(const std::string& id, bool failHard) {
720  if (myJunctions.count(id)) {
721  return myJunctions[id];
722  } else if (failHard) {
723  // If junction wasn't found, throw exception
724  throw UnknownElement("Junction " + id);
725  } else {
726  return NULL;
727  }
728 }
729 
730 
731 GNEEdge*
732 GNENet::retrieveEdge(const std::string& id, bool failHard) {
733  GNEEdges::const_iterator i = myEdges.find(id);
734  // If edge was fund
735  if (i != myEdges.end()) {
736  return i->second;
737  } else if (failHard) {
738  // If edge wasn't found, throw exception
739  throw UnknownElement("Edge " + id);
740  } else {
741  return NULL;
742  }
743 }
744 
745 
746 std::vector<GNEEdge*>
747 GNENet::retrieveEdges(bool onlySelected) {
748  std::vector<GNEEdge*> result;
749  for (GNEEdges::const_iterator it = myEdges.begin(); it != myEdges.end(); ++it) {
750  if (!onlySelected || gSelected.isSelected(GLO_EDGE, it->second->getGlID())) {
751  result.push_back(it->second);
752  }
753  }
754  return result;
755 }
756 
757 
758 std::vector<GNELane*>
759 GNENet::retrieveLanes(bool onlySelected) {
760  std::vector<GNELane*> result;
761  for (GNEEdges::const_iterator it = myEdges.begin(); it != myEdges.end(); ++it) {
762  const GNEEdge::LaneVector& lanes = it->second->getLanes();
763  for (GNEEdge::LaneVector::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); ++it_lane) {
764  if (!onlySelected || gSelected.isSelected(GLO_LANE, (*it_lane)->getGlID())) {
765  result.push_back(*it_lane);
766  }
767  }
768  }
769  return result;
770 }
771 
772 
773 GNELane*
774 GNENet::retrieveLane(const std::string& id, bool failHard) {
775  const std::string edge_id = SUMOXMLDefinitions::getEdgeIDFromLane(id);
776  GNEEdge* edge = retrieveEdge(edge_id, failHard);
777  if (edge != 0) {
778  const GNEEdge::LaneVector& lanes = edge->getLanes();
779  for (GNEEdge::LaneVector::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); ++it_lane) {
780  if ((*it_lane)->getID() == id) {
781  return (*it_lane);
782  }
783  }
784  if (failHard) {
785  // Throw exception if failHard is enabled
786  throw UnknownElement(toString(SUMO_TAG_LANE) + " " + id);
787  }
788  }
789  return 0;
790 }
791 
792 
793 std::vector<GNEJunction*>
794 GNENet::retrieveJunctions(bool onlySelected) {
795  std::vector<GNEJunction*> result;
796  for (GNEJunctions::const_iterator it = myJunctions.begin(); it != myJunctions.end(); it++) {
797  if (!onlySelected || gSelected.isSelected(GLO_JUNCTION, it->second->getGlID())) {
798  result.push_back(it->second);
799  }
800  }
801  return result;
802 }
803 
804 
805 void
809  update();
810 }
811 
812 
813 void
815  GNEAdditionals::iterator positionToRemove = myAdditionals.find(std::pair<std::string, SumoXMLTag>(additional->getID(), additional->getTag()));
816  // Check if additional element exists before refresh
817  if (positionToRemove != myAdditionals.end()) {
818  myGrid.removeAdditionalGLObject(additional);
819  myGrid.addAdditionalGLObject(additional);
820  update();
821  }
822 }
823 
824 
825 std::vector<GNEAttributeCarrier*>
826 GNENet::retrieveAttributeCarriers(const std::set<GUIGlID>& ids, GUIGlObjectType type) {
827  std::vector<GNEAttributeCarrier*> result;
828  for (std::set<GUIGlID>::iterator it = ids.begin(); it != ids.end(); it++) {
830  if (object != 0) {
831  std::string id = object->getMicrosimID();
833  GNEAttributeCarrier* ac = 0;
834  switch (type) {
835  case GLO_JUNCTION:
836  ac = dynamic_cast<GNEJunction*>(object);
837  break;
838  case GLO_EDGE:
839  ac = dynamic_cast<GNEEdge*>(object);
840  break;
841  case GLO_LANE:
842  ac = dynamic_cast<GNELane*>(object);
843  break;
844  case GLO_ADDITIONAL:
845  ac = dynamic_cast<GNEAdditional*>(object);
846  break;
847  default:
848  break;
849  }
850  if (ac == 0) {
851  throw ProcessError("GUIGlObject does not match the declared type");
852  } else {
853  result.push_back(ac);
854  }
855  } else {
856  throw ProcessError("Attempted to retrieve non-existant GUIGlObject");
857  }
858  }
859  return result;
860 }
861 
862 
863 std::set<GUIGlID>
865  std::set<GUIGlID> result;
866  switch (type) {
867  case GLO_MAX: {
868  std::set<GUIGlObjectType> knownTypes;
869  knownTypes.insert(GLO_JUNCTION);
870  knownTypes.insert(GLO_EDGE);
871  knownTypes.insert(GLO_LANE);
872  // knownTypes.insert(GLO_TLLOGIC); makes no sense to include them
873  knownTypes.insert(GLO_ADDITIONAL);
874  knownTypes.insert(GLO_CONNECTION);
875  for (std::set<GUIGlObjectType>::const_iterator it = knownTypes.begin(); it != knownTypes.end(); it++) {
876  const std::set<GUIGlID> tmp = getGlIDs(*it);
877  result.insert(tmp.begin(), tmp.end());
878  }
879  break;
880  }
881  case GLO_JUNCTION:
882  for (GNEJunctions::const_iterator it = myJunctions.begin(); it != myJunctions.end(); it++) {
883  result.insert(it->second->getGlID());
884  }
885  break;
886  case GLO_EDGE:
887  for (GNEEdges::const_iterator it = myEdges.begin(); it != myEdges.end(); it++) {
888  result.insert(it->second->getGlID());
889  }
890  break;
891  case GLO_LANE: {
892  for (GNEEdges::const_iterator it = myEdges.begin(); it != myEdges.end(); it++) {
893  const std::set<GUIGlID> laneIDs = it->second->getLaneGlIDs();
894  for (std::set<GUIGlID>::const_iterator lid_it = laneIDs.begin(); lid_it != laneIDs.end(); lid_it++) {
895  result.insert(*lid_it);
896  }
897  }
898  break;
899  }
900  case GLO_TLLOGIC: {
901  // return all junctions which have a traffic light (we do not have a GUIGlObject for each traffic light)
902  for (GNEJunctions::const_iterator it = myJunctions.begin(); it != myJunctions.end(); it++) {
903  if (it->second->getNBNode()->isTLControlled()) {
904  result.insert(it->second->getGlID());
905  }
906  }
907  break;
908  }
909  case GLO_ADDITIONAL: {
910  // Iterate over all additionals of net
911  for (GNEAdditionals::iterator it = myAdditionals.begin(); it != myAdditionals.end(); it++) {
912  // Insert every additional in result
913  result.insert(it->second->getGlID());
914  }
915  break;
916  }
917  case GLO_CONNECTION: {
918  for (GNEEdges::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
919  // Get connections of edge
920  const std::vector<GNEConnection*>& connections = i->second->getGNEConnections();
921  // Iterate over connections
922  for (std::vector<GNEConnection*>::const_iterator j = connections.begin(); j != connections.end(); j++) {
923  // Insert every connection of edge it in result
924  result.insert((*j)->getGlID());
925  }
926  }
927  break;
928  }
929  default: // add other types once we know them
930  break;
931  }
932  return result;
933 }
934 
935 
936 void
938  if (!myNeedRecompute) {
939  if (force) {
940  window->setStatusBarText("Forced computing junctions ...");
941  } else {
942  return;
943  }
944  } else {
945  window->setStatusBarText("Computing junctions ...");
946  }
947  // compute
949  computeAndUpdate(oc);
950  WRITE_MESSAGE("\nFinished computing junctions.");
951 
952  window->getApp()->endWaitCursor();
953  window->setStatusBarText("Finished computing junctions.");
954  update();
955 }
956 
957 
958 void
960  // recompute tl-logics
963 
964  NBNode* nbn = junction->getNBNode();
965  std::set<NBTrafficLightDefinition*> tldefs = nbn->getControllingTLS();
966  for (std::set<NBTrafficLightDefinition*>::iterator it = tldefs.begin(); it != tldefs.end(); it++) {
967  NBTrafficLightDefinition* def = *it;
970  tllCont.computeSingleLogic(oc, def);
971  }
972 
973  // @todo compute connections etc...
974 }
975 
976 
977 void
979  myNeedRecompute = true;
980 }
981 
982 
983 bool
985  for (std::map<std::string, NBNode*>::const_iterator i = myNetBuilder->getNodeCont().begin(); i != myNetBuilder->getNodeCont().end() ; i++) {
986  if (i->second->getCrossings().size() > 0) {
987  return true;
988  }
989  }
990  return false;
991 }
992 
993 
994 FXApp*
996  return myViewNet->getApp();
997 }
998 
999 
1000 NBNetBuilder*
1002  return myNetBuilder;
1003 }
1004 
1005 
1006 void
1008  std::vector<GNEJunction*> selected = retrieveJunctions(true);
1009  if (selected.size() < 2) {
1010  return;
1011  }
1012  undoList->p_begin("Join selected " + toString(SUMO_TAG_JUNCTION) + "s");
1013 
1014  EdgeVector allIncoming;
1015  EdgeVector allOutgoing;
1016  std::set<NBNode*> cluster;
1017  for (std::vector<GNEJunction*>::iterator it = selected.begin(); it != selected.end(); it++) {
1018  cluster.insert((*it)->getNBNode());
1019  const EdgeVector& incoming = (*it)->getNBNode()->getIncomingEdges();
1020  allIncoming.insert(allIncoming.end(), incoming.begin(), incoming.end());
1021  const EdgeVector& outgoing = (*it)->getNBNode()->getOutgoingEdges();
1022  allOutgoing.insert(allOutgoing.end(), outgoing.begin(), outgoing.end());
1023  }
1024  // create new junction
1025  Position pos;
1026  bool setTL;
1027  std::string id;
1028  TrafficLightType type;
1029  myNetBuilder->getNodeCont().analyzeCluster(cluster, id, pos, setTL, type);
1030  // XXX this is not undone when calling 'undo'
1032  GNEJunction* joined = createJunction(pos, undoList);
1033  if (setTL) {
1035  // XXX ticket831
1036  //joined-><getTrafficLight>->setAttribute(SUMO_ATTR_TYPE, toString(type), undoList);
1037  }
1038  // remap edges
1039  for (EdgeVector::const_iterator it = allIncoming.begin(); it != allIncoming.end(); it++) {
1040  GNEEdge* oldEdge = myEdges[(*it)->getID()];
1041  remapEdge(oldEdge, oldEdge->getGNEJunctionSource(), joined, undoList, true);
1042  }
1043  for (EdgeVector::const_iterator it = allOutgoing.begin(); it != allOutgoing.end(); it++) {
1044  GNEEdge* oldEdge = myEdges[(*it)->getID()];
1045  remapEdge(oldEdge, joined, oldEdge->getGNEJunctionDestiny(), undoList, true);
1046  }
1047  // delete original junctions
1048  for (std::vector<GNEJunction*>::iterator it = selected.begin(); it != selected.end(); it++) {
1049  deleteJunction(*it, undoList);
1050  }
1051  joined->setAttribute(SUMO_ATTR_ID, id, undoList);
1052  undoList->p_end();
1053 }
1054 
1055 
1056 void
1058  undoList->p_begin("Clean " + toString(SUMO_TAG_JUNCTION) + "s");
1059  std::vector<GNEJunction*> toRemove;
1060  for (GNEJunctions::const_iterator it = myJunctions.begin(); it != myJunctions.end(); it++) {
1061  GNEJunction* junction = it->second;
1062  if (junction->getNBNode()->getEdges().size() == 0) {
1063  toRemove.push_back(junction);
1064  }
1065  }
1066  for (std::vector<GNEJunction*>::iterator it = toRemove.begin(); it != toRemove.end(); ++it) {
1067  deleteJunction(*it, undoList);
1068  }
1069  undoList->p_end();
1070 }
1071 
1072 
1073 void
1075  undoList->p_begin("Replace junction by geometry");
1076  assert(junction->getNBNode()->checkIsRemovable());
1077  std::vector<std::pair<NBEdge*, NBEdge*> > toJoin = junction->getNBNode()->getEdgesToJoin();
1078  for (std::vector<std::pair<NBEdge*, NBEdge*> >::iterator j = toJoin.begin(); j != toJoin.end(); j++) {
1079  GNEEdge* begin = myEdges[(*j).first->getID()];
1080  GNEEdge* continuation = myEdges[(*j).second->getID()];
1081  deleteEdge(begin, undoList);
1082  deleteEdge(continuation, undoList);
1083  GNEEdge* newEdge = createEdge(begin->getGNEJunctionSource(), continuation->getGNEJunctionDestiny(), begin, undoList, begin->getMicrosimID(), false, true);
1084  PositionVector newShape = begin->getNBEdge()->getInnerGeometry();
1085  newShape.push_back(junction->getNBNode()->getPosition());
1086  newShape.append(continuation->getNBEdge()->getInnerGeometry());
1087  newEdge->setAttribute(SUMO_ATTR_SHAPE, toString(newShape), undoList);
1088  // @todo what about trafficlights at the end of oontinuation?
1089  }
1090  deleteJunction(junction, undoList);
1091  undoList->p_end();
1092 }
1093 
1094 void
1095 GNENet::renameEdge(GNEEdge* edge, const std::string& newID) {
1096  myEdges.erase(edge->getNBEdge()->getID());
1097  myNetBuilder->getEdgeCont().rename(edge->getNBEdge(), newID);
1098  edge->setMicrosimID(newID);
1099  myEdges[newID] = edge;
1100 }
1101 
1102 
1103 void
1104 GNENet::changeEdgeEndpoints(GNEEdge* edge, const std::string& newSource, const std::string& newDest) {
1105  NBNode* from = retrieveJunction(newSource)->getNBNode();
1106  NBNode* to = retrieveJunction(newDest)->getNBNode();
1107  edge->getNBEdge()->reinitNodes(from, to);
1108  requireRecompute();
1109  update();
1110 }
1111 
1112 
1113 GNEViewNet*
1115  return myViewNet;
1116 }
1117 
1118 
1121  return myNetBuilder->getTLLogicCont();
1122 }
1123 
1124 
1125 void
1126 GNENet::renameJunction(GNEJunction* junction, const std::string& newID) {
1127  myJunctions.erase(junction->getNBNode()->getID());
1128  myNetBuilder->getNodeCont().rename(junction->getNBNode(), newID);
1129  junction->setMicrosimID(newID);
1130  myJunctions[newID] = junction;
1131 }
1132 
1133 
1134 void
1136  myExplicitTurnarounds.insert(id);
1137 }
1138 
1139 
1140 void
1142  myExplicitTurnarounds.erase(id);
1143 }
1144 
1145 
1146 void
1147 GNENet::moveSelection(const Position& moveSrc, const Position& moveDest) {
1148  Position delta = moveDest - moveSrc;
1149  // move junctions
1150  std::set<GNEJunction*> junctionSet;
1151  std::vector<GNEJunction*> junctions = retrieveJunctions(true);
1152  for (std::vector<GNEJunction*>::iterator it = junctions.begin(); it != junctions.end(); it++) {
1153  Position newPos = (*it)->getNBNode()->getPosition() + delta;
1154  (*it)->move(newPos);
1155  junctionSet.insert(*it);
1156  }
1157 
1158  // move edge geometry (endpoints are already moved)
1159  std::vector<GNEEdge*> edges = retrieveEdges(true);
1160  for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
1161  GNEEdge* edge = *it;
1162  if (edge) {
1163  if (junctionSet.count(edge->getGNEJunctionSource()) > 0 &&
1164  junctionSet.count(edge->getGNEJunctionDestiny()) > 0) {
1165  // edge and its endpoints are selected, move all the inner points as well
1166  edge->moveGeometry(delta);
1167  } else {
1168  // move only geometry near mouse
1169  edge->moveGeometry(moveSrc, delta, true);
1170  }
1171  }
1172  }
1173 }
1174 
1175 
1176 void
1178  undoList->p_begin("move selection");
1179  // register moved junctions
1180  std::set<GNEJunction*> junctionSet;
1181  std::vector<GNEJunction*> junctions = retrieveJunctions(true);
1182  for (std::vector<GNEJunction*>::iterator it = junctions.begin(); it != junctions.end(); it++) {
1183  (*it)->registerMove(undoList);
1184  junctionSet.insert(*it);
1185  }
1186 
1187  // register moved edge geometry (endpoints are already moved)
1188  std::vector<GNEEdge*> edges = retrieveEdges(true);
1189  for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
1190  GNEEdge* edge = *it;
1191  if (edge) {
1192  const std::string& newShape = edge->getAttribute(SUMO_ATTR_SHAPE);
1193  edge->setAttribute(SUMO_ATTR_SHAPE, newShape, undoList);
1194  }
1195  }
1196  undoList->p_end();
1197 }
1198 
1199 
1202  return myShapeContainer;
1203 }
1204 
1205 
1206 void
1207 GNENet::insertAdditional(GNEAdditional* additional, bool hardFail) {
1208  // Check if additional element exists before insertion
1209  if (myAdditionals.find(std::pair<std::string, SumoXMLTag>(additional->getID(), additional->getTag())) != myAdditionals.end()) {
1210  // Throw exception only if hardFail is enabled
1211  if (hardFail) {
1212  throw ProcessError(toString(additional->getTag()) + " with ID='" + additional->getID() + "' already exist");
1213  }
1214  } else {
1215  myAdditionals[std::pair<std::string, SumoXMLTag>(additional->getID(), additional->getTag())] = additional;
1216  myGrid.addAdditionalGLObject(additional);
1217  update();
1218  }
1219 }
1220 
1221 
1222 void
1224  GNEAdditionals::iterator additionalToRemove = myAdditionals.find(std::pair<std::string, SumoXMLTag>(additional->getID(), additional->getTag()));
1225  // Check if additional element exists before deletion
1226  if (additionalToRemove == myAdditionals.end()) {
1227  throw ProcessError(toString(additional->getTag()) + " with ID='" + additional->getID() + "' doesn't exist");
1228  } else {
1229  myAdditionals.erase(additionalToRemove);
1230  myGrid.removeAdditionalGLObject(additional);
1231  update();
1232  }
1233 }
1234 
1235 
1236 void
1237 GNENet::updateAdditionalID(const std::string& oldID, GNEAdditional* additional) {
1238  GNEAdditionals::iterator additionalToUpdate = myAdditionals.find(std::pair<std::string, SumoXMLTag>(oldID, additional->getTag()));
1239  if (additionalToUpdate == myAdditionals.end()) {
1240  throw ProcessError(toString(additional->getTag()) + " with old ID='" + oldID + "' doesn't exist");
1241  } else {
1242  // remove an insert additional again into container
1243  myAdditionals.erase(additionalToUpdate);
1244  myAdditionals[std::pair<std::string, SumoXMLTag>(additional->getID(), additional->getTag())] = additional;
1245  }
1246 }
1247 
1248 
1250 GNENet::retrieveAdditional(const std::string& id, bool hardFail) const {
1251  for (GNEAdditionals::const_iterator i = myAdditionals.begin(); i != myAdditionals.end(); i++) {
1252  if (i->second->getID() == id) {
1253  return i->second;
1254  }
1255  }
1256  if (hardFail) {
1257  throw ProcessError("Attempted to retrieve non-existant additional");
1258  } else {
1259  return NULL;
1260  }
1261 }
1262 
1263 
1265 GNENet::getAdditional(SumoXMLTag type, const std::string& id) const {
1266  if (myAdditionals.empty()) {
1267  return NULL;
1268  } else if (myAdditionals.find(std::pair<std::string, SumoXMLTag>(id, type)) != myAdditionals.end()) {
1269  return myAdditionals.at(std::pair<std::string, SumoXMLTag>(id, type));
1270  } else {
1271  return NULL;
1272  }
1273 }
1274 
1275 
1276 std::string
1277 GNENet::getAdditionalID(SumoXMLTag type, const GNELane* lane, const SUMOReal pos) const {
1278  for (GNEAdditionals::const_iterator it = myAdditionals.begin(); it != myAdditionals.end(); ++it) {
1279  if ((it->second->getTag() == type) && (it->second->getLane() != NULL) && (it->second->getLane() == lane) && (fabs(it->second->getPositionInView().x() - pos) < POSITION_EPS)) {
1280  return it->second->getID();
1281  }
1282  }
1283  return "";
1284 }
1285 
1286 
1287 std::vector<GNEAdditional*>
1289  std::vector<GNEAdditional*> vectorOfAdditionals;
1290  for (GNEAdditionals::iterator i = myAdditionals.begin(); i != myAdditionals.end(); i++) {
1291  if (type == SUMO_TAG_NOTHING || type == i->second->getTag()) {
1292  vectorOfAdditionals.push_back(i->second);
1293  }
1294  }
1295  return vectorOfAdditionals;
1296 }
1297 
1298 
1299 int
1301  int counter = 0;
1302  for (GNEAdditionals::iterator i = myAdditionals.begin(); i != myAdditionals.end(); i++) {
1303  if (type == SUMO_TAG_NOTHING || type == i->second->getTag()) {
1304  counter++;
1305  }
1306  }
1307  return counter;
1308 }
1309 
1310 // ===========================================================================
1311 // private
1312 // ===========================================================================
1313 
1314 void
1316  myNetBuilder->getNodeCont().insert(junction->getNBNode());
1317  registerJunction(junction);
1318 }
1319 
1320 
1321 void
1323  NBEdge* nbe = edge->getNBEdge();
1324  myNetBuilder->getEdgeCont().insert(nbe); // should we ignore pruning double edges?
1325  // if this edge was previouls extracted from the edgeContainer we have to rewire the nodes
1326  nbe->getFromNode()->addOutgoingEdge(nbe);
1327  nbe->getToNode()->addIncomingEdge(nbe);
1328  registerEdge(edge);
1329 }
1330 
1331 
1332 GNEJunction*
1334  junction->incRef("GNENet::registerJunction");
1335  junction->setResponsible(false);
1336  myJunctions[junction->getMicrosimID()] = junction;
1337  myGrid.add(junction->getBoundary());
1338  myGrid.addAdditionalGLObject(junction);
1339  // @todo let Boundary class track z-coordinate natively
1340  const SUMOReal z = junction->getNBNode()->getPosition().z();
1341  if (z != 0) {
1343  }
1344  update();
1345  return junction;
1346 }
1347 
1348 
1349 GNEEdge*
1351  edge->incRef("GNENet::registerEdge");
1352  edge->setResponsible(false);
1353  // add edge to internal container of GNENet
1354  myEdges[edge->getMicrosimID()] = edge;
1355  // add edge to grid
1356  myGrid.add(edge->getBoundary());
1358  // Add references into GNEJunctions
1361  // update view
1362  update();
1363  return edge;
1364 }
1365 
1366 
1367 void
1369  myGrid.removeAdditionalGLObject(junction);
1370  myJunctions.erase(junction->getMicrosimID());
1371  myNetBuilder->getNodeCont().extract(junction->getNBNode());
1372  junction->decRef("GNENet::deleteSingleJunction");
1373  junction->setResponsible(true);
1374  // selection status is lost when removing junction via undo and the selection operation was not part of a command group
1375  gSelected.deselect(junction->getGlID());
1376  update();
1377 }
1378 
1379 
1380 void
1382  // remove edge from visual grid and container
1384  myEdges.erase(edge->getMicrosimID());
1385  // extract edge of district container
1387  edge->decRef("GNENet::deleteSingleEdge");
1388  edge->setResponsible(true);
1389  // selection status is lost when removing edge via undo and the selection operation was not part of a command group
1390  gSelected.deselect(edge->getGlID());
1391  // Remove refrences from GNEJunctions
1394  // invalidate junction logic
1395  update();
1396 }
1397 
1398 
1399 void
1401  if (myViewNet) {
1402  myViewNet->update();
1403  }
1404 }
1405 
1406 
1407 void
1408 GNENet::reserveEdgeID(const std::string& id) {
1409  myEdgeIDSupplier.avoid(id);
1410 }
1411 
1412 
1413 void
1414 GNENet::reserveJunctionID(const std::string& id) {
1416 }
1417 
1418 
1419 void
1421  for (GNEEdges::const_iterator it = myEdges.begin(); it != myEdges.end(); it++) {
1422  it->second->remakeGNEConnections();
1423  }
1424  for (GNEEdges::const_iterator it = myEdges.begin(); it != myEdges.end(); it++) {
1425  it->second->updateGeometry();
1426  }
1427 }
1428 
1429 void
1431  // make sure we only add turn arounds to edges which currently exist within the network
1432  std::set<std::string> liveExplicitTurnarounds;
1433  for (std::set<std::string>::const_iterator it = myExplicitTurnarounds.begin(); it != myExplicitTurnarounds.end(); it++) {
1434  if (myEdges.count(*it) > 0) {
1435  liveExplicitTurnarounds.insert(*it);
1436  }
1437  }
1438  myNetBuilder->compute(oc, liveExplicitTurnarounds, false);
1439  // update ids if necessary
1440  if (oc.getBool("numerical-ids") || oc.isSet("reserved-ids")) {
1441  GNEEdges newEdgeMap;
1442  GNEJunctions newJunctionMap;
1443  for (GNEEdges::const_iterator it = myEdges.begin(); it != myEdges.end(); it++) {
1444  it->second->setMicrosimID(it->second->getNBEdge()->getID());
1445  newEdgeMap[it->second->getNBEdge()->getID()] = it->second;
1446  }
1447  for (GNEJunctions::const_iterator it = myJunctions.begin(); it != myJunctions.end(); it++) {
1448  newJunctionMap[it->second->getNBNode()->getID()] = it->second;
1449  it->second->setMicrosimID(it->second->getNBNode()->getID());
1450  }
1451  myEdges = newEdgeMap;
1452  myJunctions = newJunctionMap;
1453  }
1454  // update rtree if necessary
1455  if (!oc.getBool("offset.disable-normalization")) {
1456  for (GNEEdges::const_iterator it = myEdges.begin(); it != myEdges.end(); it++) {
1457  refreshElement(it->second);
1458  }
1459  }
1460  myGrid.reset();
1461  myGrid.add(GeoConvHelper::getProcessing().getConvBoundary());
1462  // update precomputed geometries
1464 
1465  for (GNEJunctions::const_iterator it = myJunctions.begin(); it != myJunctions.end(); it++) {
1466  it->second->setLogicValid(true);
1467  // updated shape
1468  it->second->updateGeometry();
1469  refreshElement(it->second);
1470  }
1471 
1472  myNeedRecompute = false;
1473 }
1474 
1475 
1476 /****************************************************************************/
void setViewNet(GNEViewNet *viewNet)
Set the viewNet to be notified of network changes.
Definition: GNENet.cpp:713
GNEJunction * splitEdge(GNEEdge *edge, const Position &pos, GNEUndoList *undoList, GNEJunction *newJunction=0)
split edge at position by inserting a new junction
Definition: GNENet.cpp:532
void computeAndUpdate(OptionsCont &oc)
recompute the network and update lane geometries
Definition: GNENet.cpp:1430
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
Definition: GNENet.cpp:794
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNENet.cpp:196
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
a tl-logic
virtual void setParticipantsInformation()
Builds the list of participating nodes/edges/links.
ShapeContainer & getShapeContainer()
get shape container
Definition: GNENet.cpp:1201
const EdgeVector & getIncomingEdges() const
Returns this node&#39;s incoming edges (The edges which yield in this node)
Definition: NBNode.h:240
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
Definition: GNENet.cpp:759
void close()
Closes the device and removes it from the dictionary.
GNEViewNet * myViewNet
The viewNet to be notofied of about changes.
Definition: GNENet.h:491
SumoXMLTag
Numbers representing SUMO-XML - element names.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
SUMOReal getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:172
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:732
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:244
SUMOReal width
This lane&#39;s width.
Definition: NBNode.h:151
IDSupplier myEdgeIDSupplier
Definition: GNENet.h:514
GNEJunction * getGNEJunctionSource() const
returns the source-junction
Definition: GNEEdge.cpp:156
void setStatusBarText(const std::string &statusBarText)
set text of the statusBar
is a pedestrian
SUMOReal getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:166
NBNode::Crossing & getNBCrossing() const
get referente to NBode::Crossing
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
Definition: NBEdgeCont.cpp:544
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
SUMORTree myGrid
the rtree which contains all GUIGlObjects (so named for historical reasons)
Definition: GNENet.h:488
void joinSelectedJunctions(GNEUndoList *undoList)
Definition: GNENet.cpp:1007
GUIGlObjectType
begin/end of the description of a junction
begin/end of the description of a single lane
FXApp * getApp()
get pointer to the main App
Definition: GNENet.cpp:995
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
void refreshElement(GUIGlObject *o)
refreshes boundary information for o and update
Definition: GNENet.cpp:806
GNEAdditionals myAdditionals
map with the name and pointer to additional elements of net
Definition: GNENet.h:510
The main window of the Netedit.
static const RGBColor selectedLaneColor
color of selected lane
Definition: GNENet.h:99
void setMicrosimID(const std::string &newID)
override to also set lane ids
Definition: GNEEdge.cpp:936
bool revertLaneRestriction(GNELane *lane, GNEUndoList *undoList)
revert prevously restricted lane
Definition: GNENet.cpp:477
A container for traffic light definitions and built programs.
void setLogicValid(bool valid, GNEUndoList *undoList=0, const std::string &status=GUESSED)
SUMOReal ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:142
connectio between two lanes
Stores the information about how to visualize structures.
std::set< GUIGlID > getGlIDs(GUIGlObjectType type=GLO_MAX)
Definition: GNENet.cpp:864
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
Definition: GeoConvHelper.h:98
a connection
vehicle is a bicycle
virtual void setTLControllingInformation() const =0
Informs edges about being controlled by a tls.
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:736
const std::vector< GNEAdditional * > & getAdditionalChilds() const
get additional childs of lane
Definition: GNELane.cpp:730
void addIncomingEdge(NBEdge *edge)
adds an incoming edge
Definition: NBNode.cpp:416
int SVCPermissions
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
Definition: NBEdge.h:71
void reinitNodes(NBNode *from, NBNode *to)
Resets nodes but keeps all other values the same (used when joining)
Definition: NBEdge.cpp:373
Position moveGeometry(const Position &oldPos, const Position &newPos, bool relative=false)
change the edge geometry It is up to the Edge to decide whether an new geometry node should be genera...
Definition: GNEEdge.cpp:278
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNENet.cpp:217
static void writeJoinedJunctions(const OptionsCont &oc, NBNodeCont &nc)
Writes the joined-juncionts to file.
void computeEverything(GNEApplicationWindow *window, bool force=false)
Definition: GNENet.cpp:937
std::vector< GNELane * > LaneVector
Definition of the lane&#39;s vector.
Definition: GNEEdge.h:62
void removeAdditionalGLObject(GUIGlObject *o)
Removes an additional object (detector/shape/trigger) from being visualised.
Definition: SUMORTree.h:141
NBNode * getNBNode() const
Return net build node.
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:596
The base class for traffic light logic definitions.
void update()
notify myViewNet
Definition: GNENet.cpp:1400
void insertJunction(GNEJunction *junction)
inserts a single junction into the net and into the underlying netbuild-container ...
Definition: GNENet.cpp:1315
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
SUMOReal getTotalWidth() const
Returns the combined width of all lanes of this edge.
Definition: NBEdge.cpp:2688
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEEdge.cpp:497
void deleteConnection(GNEConnection *connection, GNEUndoList *undoList)
remove connection
Definition: GNENet.cpp:407
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:585
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:54
GNEEdge * createEdge(GNEJunction *src, GNEJunction *dest, GNEEdge *tpl, GNEUndoList *undoList, const std::string &suggestedName="", bool wasSplit=false, bool allowDuplicateGeom=false)
creates a new edge (unless an edge with the same geometry already exists)
Definition: GNENet.cpp:252
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:86
void addExplicitTurnaround(std::string id)
add edge id to the list of explicit turnarounds
Definition: GNENet.cpp:1135
void rename(NBEdge *edge, const std::string &newID)
Renames the edge. Throws exception if newID already exists.
Definition: NBEdgeCont.cpp:408
GUIShapeContainer myShapeContainer
the container for additional pois and polygons
Definition: GNENet.h:519
Storage for geometrical objects.
GNEEdge * getEdgeFrom() const
get the name of the edge the vehicles leave
void insertEdge(GNEEdge *edge)
inserts a single edge into the net and into the underlying netbuild-container
Definition: GNENet.cpp:1322
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return list of additionals associated with this edge
Definition: GNEEdge.cpp:968
bool checkIsRemovable() const
check if node is removable
Definition: NBNode.cpp:1646
Lane & getLaneStruct(int lane)
Definition: NBEdge.h:1123
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:247
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList)
removes edge
Definition: GNENet.cpp:337
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
A RT-tree for efficient storing of SUMO&#39;s GL-objects.
Definition: SUMORTree.h:74
first coordinate of edge shape
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:426
std::string getAdditionalID(SumoXMLTag type, const GNELane *lane, const SUMOReal pos) const
Returns the additional close to the given position.
Definition: GNENet.cpp:1277
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:659
void remapEdge(GNEEdge *oldEdge, GNEJunction *from, GNEJunction *to, GNEUndoList *undoList, bool keepEndpoints=false)
Definition: GNENet.cpp:664
GUIGlID getGlID() const
Returns the numerical id of the object.
GNEJunction * registerJunction(GNEJunction *junction)
registers a junction with GNENet containers
Definition: GNENet.cpp:1333
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
bool myNeedRecompute
whether the net needs recomputation
Definition: GNENet.h:525
NBNetBuilder * myNetBuilder
The internal netbuilder.
Definition: GNENet.h:494
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:189
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
GNEUndoList * getUndoList() const
get the undoList object
Definition: GNEViewNet.cpp:995
bool priority
whether the pedestrians have priority
Definition: NBNode.h:159
PositionVector reverse() const
reverse position vector
bool restrictLane(SUMOVehicleClass vclass, GNELane *lane, GNEUndoList *undoList)
transform lane to restricted lane
Definition: GNENet.cpp:451
void renameJunction(GNEJunction *junction, const std::string &newID)
updates the map and reserves new id
Definition: GNENet.cpp:1126
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
NBConnection getNBConnection() const
get NBConnection
const EdgeVector & getOutgoingEdges() const
Returns this node&#39;s outgoing edges (The edges which start at this node)
Definition: NBNode.h:245
IDSupplier myJunctionIDSupplier
Definition: GNENet.h:515
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:124
const std::string & getID() const
Returns the id.
Definition: Named.h:66
const PositionVector getInnerGeometry() const
Returns the geometry of the edge without the endpoints.
Definition: NBEdge.cpp:480
friend class GNEChange_Connection
Definition: GNENet.h:92
const Position & getPosition() const
Definition: NBNode.h:232
const std::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
void updateAdditionalID(const std::string &oldID, GNEAdditional *additional)
update additional ID in container
Definition: GNENet.cpp:1237
std::string getNext()
Returns the next id.
Definition: IDSupplier.cpp:63
bool removeRestrictedLane(SUMOVehicleClass vclass, GNEEdge &edge, GNEUndoList *undoList)
remove restricted lane
Definition: GNENet.cpp:510
std::map< std::string, GNEJunction * > GNEJunctions
Definition: GNENet.h:498
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node) ...
Definition: NBNode.h:298
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:162
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:51
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1027
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:772
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNENet.cpp:206
void refreshAdditional(GNEAdditional *additional)
refreshes boundary information of an additional after a geometry update
Definition: GNENet.cpp:814
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:396
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
Definition: GNEUndoList.cpp:93
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:719
GNEJunctions myJunctions
map with the name and pointer to junctions of net
Definition: GNENet.h:504
NBEdgeCont & getEdgeCont()
Definition: NBNetBuilder.h:144
A list of positions.
GNELane * retrieveLane(const std::string &id, bool failHard=true)
get lane by id
Definition: GNENet.cpp:774
Boundary myZBoundary
the z boundary (stored in the x-coordinate), values of 0 are ignored
Definition: GNENet.h:567
void deleteLane(GNELane *lane, GNEUndoList *undoList)
removes lane
Definition: GNENet.cpp:374
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:524
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:125
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
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:402
std::vector< GNEAdditional * > getAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING)
get vector with additionals
Definition: GNENet.cpp:1288
void computeJunction(GNEJunction *junction)
Definition: GNENet.cpp:959
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node) ...
Definition: NBNode.h:250
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
GNEJunction * getParentJunction() const
get parent Junction
Definition: GNECrossing.cpp:98
void initGNEConnections()
initialize GNEConnections
Definition: GNENet.cpp:1420
#define POSITION_EPS
Definition: config.h:182
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network into XML-files (nodes, edges, connections, traffic lights)
int getNumberOfAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING)
Returns the number of additionals of the net.
Definition: GNENet.cpp:1300
void save(OptionsCont &oc)
save the network
Definition: GNENet.cpp:679
edge: the shape in xml-definition
std::vector< GNEAttributeCarrier * > retrieveAttributeCarriers(const std::set< GUIGlID > &ids, GUIGlObjectType type)
get the attribute carriers based on GlIDs
Definition: GNENet.cpp:826
void deleteCrossing(GNECrossing *crossing, GNEUndoList *undoList)
remove crossing
Definition: GNENet.cpp:425
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
std::vector< std::string > getAllNames() const
get all node names
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
Definition: NBNodeCont.h:119
friend class GNEChange_Edge
Definition: GNENet.h:91
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
const std::string getID() const
function to support debugging
void moveSelection(const Position &moveSrc, const Position &moveDest)
move all selected junctions and edges
Definition: GNENet.cpp:1147
GNEJunction * createJunction(const Position &pos, GNEUndoList *undoList)
creates a new junction
Definition: GNENet.cpp:241
void incRef(const std::string &debugMsg="")
std::string getVehicleClassNames(SVCPermissions permissions)
Returns the ids of the given classes, divided using a &#39; &#39;.
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GNENet.cpp:229
std::set< std::string > myExplicitTurnarounds
list of edge ids for which turn-arounds must be added explicitly
Definition: GNENet.h:522
void decRef(const std::string &debugMsg="")
void rename(NBNode *node, const std::string &newID)
Renames the node. Throws exception if newID already exists.
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection)
std::vector< std::pair< NBEdge *, NBEdge * > > getEdgesToJoin() const
get edges to join
Definition: NBNode.cpp:1697
begin/end of the description of an edge
std::pair< PositionVector, PositionVector > splitAt(SUMOReal where) const
Returns the two lists made when this list vector is splitted at the given point.
NBEdge::Connection & getNBEdgeConnection() const
get Edge::Connection
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network stored in the given net builder.
Definition: NWFrame.cpp:153
void replaceJunctionByGeometry(GNEJunction *junction, GNEUndoList *undoList)
replace the selected junction by geometry node(s) and merge the edges
Definition: GNENet.cpp:1074
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:54
void reserveJunctionID(const std::string &id)
reserve junction ID (To avoid duplicates)
Definition: GNENet.cpp:1414
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition: NBEdge.cpp:2763
compound additional
vehicle is a bus
GNEAdditional * getAdditional(SumoXMLTag type, const std::string &id) const
Returns the named additional.
Definition: GNENet.cpp:1265
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNENet.cpp:212
void reset()
Resets the boundary.
Definition: Boundary.cpp:78
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Definition: GNEEdge.cpp:698
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
Definition: TplConvert.h:149
void deleteSingleJunction(GNEJunction *junction)
deletes a single junction
Definition: GNENet.cpp:1368
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:423
~GNENet()
Destructor.
Definition: GNENet.cpp:158
const Boundary & getZBoundary() const
Returns the Z boundary (stored in the x() coordinate) values of 0 do not affect the boundary...
Definition: GNENet.cpp:223
void deselect(GUIGlID id)
Deselects the object with the given id.
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:479
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:255
bool deleteGeometry(const Position &pos, GNEUndoList *undoList)
deletes the closest geometry node within SNAP_RADIUS.
Definition: GNEEdge.cpp:344
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:747
void add(SUMOReal x, SUMOReal y, SUMOReal z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:90
GNEEdge * registerEdge(GNEEdge *edge)
registers an edge with GNENet containers
Definition: GNENet.cpp:1350
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
Definition: NBNetBuilder.h:149
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:101
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:62
Boundary getBoundary() const
Returns the boundary of the junction.
Instance responsible for building networks.
Definition: NBNetBuilder.h:112
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
friend class GNEChange_Junction
declare friend class
Definition: GNENet.h:90
void removeSolitaryJunctions(GNEUndoList *undoList)
removes junctions that have no edges
Definition: GNENet.cpp:1057
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:41
void analyzeCluster(std::set< NBNode * > cluster, std::string &id, Position &pos, bool &hasTLS, TrafficLightType &type)
Definition: NBNodeCont.cpp:776
static const RGBColor selectedConnectionColor
color of selected connection
Definition: GNENet.h:102
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:584
void move(Position pos)
reposition the node at pos and informs the edges
A storage for options typed value containers)
Definition: OptionsCont.h:99
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:81
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
Definition: NBNetBuilder.h:159
void renameEdge(GNEEdge *edge, const std::string &newID)
updates the map and reserves new id
Definition: GNENet.cpp:1095
void deleteJunction(GNEJunction *junction, GNEUndoList *undoList)
removes junction and all incident edges
Definition: GNENet.cpp:307
The network - empty.
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge&#39;s lanes&#39; lateral offset is computed.
Definition: NBEdge.h:653
void removeExplicitTurnaround(std::string id)
remove edge id from the list of explicit turnarounds
Definition: GNENet.cpp:1141
EdgeVector edges
The edges being crossed.
Definition: NBNode.h:147
Represents a single node (junction) during network building.
Definition: NBNode.h:75
void saveJoined(OptionsCont &oc)
save log of joined junctions (and nothing else)
Definition: GNENet.cpp:706
void deleteAdditional(GNEAdditional *additional)
delete additional element previously inserted
Definition: GNENet.cpp:1223
SumoXMLTag getTag() const
get XML Tag assigned to this object
GNEEdge * addReversedEdge(GNEEdge *edge, GNEUndoList *undoList)
add reversed edge
Definition: GNENet.cpp:607
void move2side(SUMOReal amount)
move position vector to side using certain ammount
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:208
GNEEdges myEdges
map with the name and pointer to edges of net
Definition: GNENet.h:507
last coordinate of edge shape
static const RGBColor selectionColor
color of selection
Definition: GNENet.h:96
empty max
void unblockObject(GUIGlID id)
Marks an object as unblocked.
void reserveEdgeID(const std::string &id)
reserve edge ID (To avoid duplicates)
Definition: GNENet.cpp:1408
void compute(OptionsCont &oc, const std::set< std::string > &explicitTurnarounds=std::set< std::string >(), bool mayAddOrRemove=true)
Performs the network building steps.
void deleteSingleEdge(GNEEdge *edge)
deletes a single edge
Definition: GNENet.cpp:1381
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:110
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:63
std::map< std::string, GNEEdge * > GNEEdges
Definition: GNENet.h:499
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:258
GNEAdditional * retrieveAdditional(const std::string &idl, bool hardFail=true) const
Returns the named additional.
Definition: GNENet.cpp:1250
void mergeJunctions(GNEJunction *moved, GNEJunction *target, GNEUndoList *undoList)
merge the given junctions edges between the given junctions will be deleted
Definition: GNENet.cpp:640
bool extract(NBNode *node, bool remember=false)
Removes the given node but does not delete it.
Definition: NBNodeCont.cpp:151
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
bool netHasCrossings() const
check if net has crossings
Definition: GNENet.cpp:984
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
void insertAdditional(GNEAdditional *additional, bool hardFail=true)
Insert a additional element previously created in GNEAdditionalHandler.
Definition: GNENet.cpp:1207
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
Definition: NBNetBuilder.h:164
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNEEdge.cpp:565
bool addSRestrictedLane(SUMOVehicleClass vclass, GNEEdge &edge, GNEUndoList *undoList)
add restricted lane to edge
Definition: GNENet.cpp:495
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:1104
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition: GNENet.cpp:1120
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1114
bool wasSplit()
whether this edge was created from a split
Definition: GNEEdge.cpp:491
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
Definition: NBNodeCont.h:114
void saveAdditionals(const std::string &filename)
save additional elements of the network
Definition: GNENet.cpp:688
void savePlain(OptionsCont &oc)
save plain xml representation of the network (and nothing else)
Definition: GNENet.cpp:699
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:188
void requireRecompute()
inform the net about the need for recomputation
Definition: GNENet.cpp:978
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static const SUMOReal Z_INITIALIZED
marker for whether the z-boundary is initialized
Definition: GNENet.h:570
void duplicateLane(GNELane *lane, GNEUndoList *undoList)
duplicates lane
Definition: GNENet.cpp:439
void append(const PositionVector &v, SUMOReal sameThreshold=2.0)
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
TrafficLightType
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void registerJoinedCluster(const std::set< NBNode * > &cluster)
gets all joined clusters (see doc for myClusters2Join)
Definition: NBNodeCont.cpp:766
a junction
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:162
void finishMoveSelection(GNEUndoList *undoList)
register changes to junction and edge positions with the undoList
Definition: GNENet.cpp:1177
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:416
NBNetBuilder * getNetBuilder() const
get net builder
Definition: GNENet.cpp:1001