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