SUMO - Simulation of Urban MObility
GNEJunction.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // A class for visualizing and editing junctions in netedit (adapted from
18 // GUIJunctionWrapper)
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <string>
32 #include <utility>
34 #include <utils/geom/Position.h>
40 #include <utils/gui/div/GLHelper.h>
45 #include <netbuild/NBOwnTLDef.h>
47 #include <netbuild/NBAlgorithms.h>
49 
50 #include "GNENet.h"
51 #include "GNEEdge.h"
52 #include "GNECrossing.h"
53 #include "GNEUndoList.h"
54 #include "GNEViewNet.h"
55 #include "GNEChange_Attribute.h"
56 #include "GNEChange_Connection.h"
57 #include "GNEChange_TLS.h"
58 #include "GNEConnection.h"
59 #include "GNEJunction.h"
60 
61 const double GNEJunction::BUBBLE_RADIUS(4);
62 
63 // ===========================================================================
64 // method definitions
65 // ===========================================================================
66 GNEJunction::GNEJunction(NBNode& nbn, GNENet* net, bool loaded) :
68  myNBNode(nbn),
69  myAmCreateEdgeSource(false),
70  myLogicStatus(loaded ? LOADED : GUESSED),
71  myAmResponsible(false),
72  myHasValidLogic(loaded),
73  myAmTLSSelected(false) {
75 }
76 
77 
79  // delete all GNECrossing
80  for (auto it : myGNECrossings) {
81  it->decRef();
82  if (it->unreferenced()) {
83  // show extra information for tests
84  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
85  WRITE_WARNING("Deleting unreferenced " + toString(it->getTag()) + " '" + it->getID() + "' in GNEJunction destructor");
86  }
87  delete it;
88  }
89  }
90 
91  if (myAmResponsible) {
92  // show extra information for tests
93  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
94  WRITE_WARNING("Deleting NBNode of '" + getID() + "' in GNEJunction destructor");
95  }
96  delete &myNBNode;
97  }
98 }
99 
100 
101 void
103  // calculate boundary using EXTENT as size
104  const double EXTENT = 2;
105  myBoundary = Boundary(myNBNode.getPosition().x() - EXTENT, myNBNode.getPosition().y() - EXTENT,
106  myNBNode.getPosition().x() + EXTENT, myNBNode.getPosition().y() + EXTENT);
107  // if junctio own a extra shape, add it to boundary
108  if (myNBNode.getShape().size() > 0) {
110  }
112  // rebuild GNECrossings
113  // (but don't rebuild the crossings in NBNode because they are already finished)
114  rebuildGNECrossings(false);
115 }
116 
117 
118 void
119 GNEJunction::rebuildGNECrossings(bool rebuildNBNodeCrossings) {
120  // rebuild GNECrossings only if create crossings and walkingAreas in net is enabled
122  if (rebuildNBNodeCrossings) {
123  // build new NBNode::Crossings and walking areas
125  }
126  // create a vector to keep retrieved and created crossings
127  std::vector<GNECrossing*> retrievedCrossings;
128  // iterate over NBNode::Crossings of GNEJunction
129  for (auto c : myNBNode.getCrossingsIncludingInvalid()) {
130  // retrieve existent GNECrossing, or create it
131  GNECrossing* retrievedGNECrossing = retrieveGNECrossing(c);
132  retrievedCrossings.push_back(retrievedGNECrossing);
133  // check if previously this GNECrossings exists, and if true, remove it from myGNECrossings
134  std::vector<GNECrossing*>::iterator retrievedExists = std::find(myGNECrossings.begin(), myGNECrossings.end(), retrievedGNECrossing);
135  if (retrievedExists != myGNECrossings.end()) {
136  myGNECrossings.erase(retrievedExists);
137  // update geometry of retrieved crossing
138  retrievedGNECrossing->updateGeometry();
139  } else {
140  // include reference to created GNECrossing
141  retrievedGNECrossing->incRef();
142  }
143  }
144  // delete non retrieved GNECrossings
145  for (auto it : myGNECrossings) {
146  it->decRef();
147  if (it->unreferenced()) {
148  // show extra information for tests
149  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
150  WRITE_WARNING("Deleting unreferenced " + toString(it->getTag()) + " '" + it->getID() + "' in rebuildGNECrossings()");
151  }
152  delete it;
153  }
154  }
155  // copy retrieved (existent and created) GNECrossigns to myGNECrossings
156  myGNECrossings = retrievedCrossings;
157  }
158 }
159 
160 
163  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
164  buildPopupHeader(ret, app);
167  // build selection and show parameters menu
170  buildPositionCopyEntry(ret, false);
171  //if (parent.getVisualisationSettings()->editMode != GNE_MODE_CONNECT) {
172  // // XXX if joinable
173  // new FXMenuCommand(ret, "Join adjacent edges", 0, &parent, MID_GNE_JOIN_EDGES);
174  //}
175  // create menu commands
176  FXMenuCommand* mcCustomShape = new FXMenuCommand(ret, "Set custom junction shape", 0, &parent, MID_GNE_JUNCTION_EDIT_SHAPE);
177  FXMenuCommand* mcReplace = new FXMenuCommand(ret, "Replace junction by geometry point", 0, &parent, MID_GNE_JUNCTION_REPLACE);
178  FXMenuCommand* mcClearConnections = new FXMenuCommand(ret, "Clear connections", 0, &parent, MID_GNE_JUNCTION_CLEAR_CONNECTIONS);
179  FXMenuCommand* mcResetConnections = new FXMenuCommand(ret, "Reset connections", 0, &parent, MID_GNE_JUNCTION_RESET_CONNECTIONS);
180  // check if menu commands has to be disabled
181  EditMode editMode = myNet->getViewNet()->getCurrentEditMode();
182  const bool wrongMode = (editMode == GNE_MODE_CONNECT || editMode == GNE_MODE_TLS || editMode == GNE_MODE_CREATE_EDGE);
183  if (wrongMode) {
184  mcCustomShape->disable();
185  mcClearConnections->disable();
186  mcResetConnections->disable();
187  }
188  // disable mcClearConnections if juction hasn't connections
189  if (getGNEConnections().empty()) {
190  mcClearConnections->disable();
191  }
192  // checkIsRemovable requiers turnarounds to be computed. This is ugly
193  if (myNBNode.getIncomingEdges().size() == 2 && myNBNode.getOutgoingEdges().size() == 2) {
195  }
196  std::string reason = "wrong edit mode";
197  if (wrongMode || !myNBNode.checkIsRemovableReporting(reason)) {
198  mcReplace->setText(mcReplace->getText() + " (" + reason.c_str() + ")");
199  mcReplace->disable();
200  }
201  return ret;
202 }
203 
204 
205 Boundary
207  Boundary b = myBoundary;
208  b.grow(20);
209  return b;
210 }
211 
212 
213 void
215  // declare variables
216  GLfloat color[4];
217  double exaggeration = gSelected.isSelected(getType(), getGlID()) ? s.selectionScale : 1;
218  exaggeration *= s.junctionSize.getExaggeration(s);
219  // push name
220  glPushName(getGlID());
221  if (s.scale * exaggeration * myMaxSize < 1.) {
222  // draw something simple so that selection still works
224  } else {
225  // node shape has been computed and is valid for drawing
226  const bool drawShape = myNBNode.getShape().size() > 0 && s.drawJunctionShape;
227  const bool drawBubble = (!drawShape || myNBNode.getShape().area() < 4) && s.drawJunctionShape; // magic threshold
228 
229  if (drawShape) {
230  setColor(s, false);
231  // recognize full transparency and simply don't draw
232  glGetFloatv(GL_CURRENT_COLOR, color);
233  if (color[3] != 0) {
234  glPushMatrix();
235  glTranslated(0, 0, getType());
236  PositionVector shape = myNBNode.getShape();
237  shape.closePolygon();
238  if (exaggeration > 1) {
239  shape.scaleRelative(exaggeration);
240  }
241  if (s.scale * exaggeration * myMaxSize < 40.) {
242  GLHelper::drawFilledPoly(shape, true);
243  } else {
245  }
246  glPopMatrix();
247  }
248  // Check if a buuble must be drawed over junction
250  setColor(s, true);
251  // recognize full transparency and simply don't draw
252  glGetFloatv(GL_CURRENT_COLOR, color);
253  if (color[3] != 0) {
254  glPushMatrix();
255  Position pos = myNBNode.getPosition();
256  glTranslated(pos.x(), pos.y(), getType() + 0.05);
257  GLHelper::drawFilledCircle(BUBBLE_RADIUS * exaggeration, 32);
258  glPopMatrix();
259  }
260  }
261  }
262  if (drawBubble) {
263  setColor(s, true);
264  // recognize full transparency and simply don't draw
265  glGetFloatv(GL_CURRENT_COLOR, color);
266  if (color[3] != 0) {
267  glPushMatrix();
268  Position pos = myNBNode.getPosition();
269  glTranslated(pos.x(), pos.y(), getType() - 0.05);
270  // resolution of drawn circle depending of the zoom (To improve smothness)
271  if (s.scale >= 10) {
272  GLHelper::drawFilledCircle(BUBBLE_RADIUS * exaggeration, 32);
273  } else if (s.scale >= 2) {
274  GLHelper::drawFilledCircle(BUBBLE_RADIUS * exaggeration, 16);
275  } else if (s.scale >= 1) {
276  GLHelper::drawFilledCircle(BUBBLE_RADIUS * exaggeration, 8);
277  } else {
278  GLHelper::drawFilledCircle(BUBBLE_RADIUS * exaggeration, 4);
279  }
280  glPopMatrix();
281  }
282  }
283 
285  glPushMatrix();
286  Position pos = myNBNode.getPosition();
287  glTranslated(pos.x(), pos.y(), getType() + 0.1);
288  glColor3d(1, 1, 1);
289  const double halfWidth = 32 / s.scale;
290  const double halfHeight = 64 / s.scale;
291  GUITexturesHelper::drawTexturedBox(GUITextureSubSys::getTexture(GNETEXTURE_TLS), -halfWidth, -halfHeight, halfWidth, halfHeight);
292  glPopMatrix();
293  }
294  // draw crossings
295  if (s.editMode != GNE_MODE_TLS) {
296  for (auto it : myGNECrossings) {
297  it->drawGL(s);
298  }
299  }
300  // (optional) draw name @todo expose this setting
302  }
303  glPopName();
304 }
305 
306 Boundary
308  return myBoundary;
309 }
310 
311 
312 NBNode*
314  return &myNBNode;
315 }
316 
317 
318 Position
320  return myNBNode.getPosition();
321 }
322 
323 
324 std::vector<GNEJunction*>
326  // use set to avoid duplicates junctions
327  std::set<GNEJunction*> junctions;
328  for (auto i : myGNEIncomingEdges) {
329  junctions.insert(i->getGNEJunctionSource());
330  }
331  for (auto i : myGNEOutgoingEdges) {
332  junctions.insert(i->getGNEJunctionDestiny());
333  }
334  return std::vector<GNEJunction*>(junctions.begin(), junctions.end());
335 }
336 
337 
338 void
340  // Check if incoming edge was already inserted
341  std::vector<GNEEdge*>::iterator i = std::find(myGNEIncomingEdges.begin(), myGNEIncomingEdges.end(), edge);
342  if (i != myGNEIncomingEdges.end()) {
343  throw InvalidArgument("Incoming " + toString(SUMO_TAG_EDGE) + " with ID '" + edge->getID() + "' was already inserted into " + toString(getTag()) + " with ID " + getID() + "'");
344  } else {
345  // Add edge into containers
346  myGNEIncomingEdges.push_back(edge);
347  myGNEEdges.push_back(edge);
348  }
349 }
350 
351 
352 
353 void
355  // Check if outgoing edge was already inserted
356  std::vector<GNEEdge*>::iterator i = std::find(myGNEOutgoingEdges.begin(), myGNEOutgoingEdges.end(), edge);
357  if (i != myGNEOutgoingEdges.end()) {
358  throw InvalidArgument("Outgoing " + toString(SUMO_TAG_EDGE) + " with ID '" + edge->getID() + "' was already inserted into " + toString(getTag()) + " with ID " + getID() + "'");
359  } else {
360  // Add edge into containers
361  myGNEOutgoingEdges.push_back(edge);
362  myGNEEdges.push_back(edge);
363  }
364 }
365 
366 
367 void
369  // Check if incoming edge was already inserted
370  std::vector<GNEEdge*>::iterator i = std::find(myGNEIncomingEdges.begin(), myGNEIncomingEdges.end(), edge);
371  if (i == myGNEIncomingEdges.end()) {
372  throw InvalidArgument("Incoming " + toString(SUMO_TAG_EDGE) + " with ID '" + edge->getID() + "' doesn't found into " + toString(getTag()) + " with ID " + getID() + "'");
373  } else {
374  // remove edge from containers
375  myGNEIncomingEdges.erase(i);
376  myGNEEdges.erase(std::find(myGNEEdges.begin(), myGNEEdges.end(), edge));
377  }
378 }
379 
380 
381 void
383  // Check if outgoing edge was already inserted
384  std::vector<GNEEdge*>::iterator i = std::find(myGNEOutgoingEdges.begin(), myGNEOutgoingEdges.end(), edge);
385  if (i == myGNEOutgoingEdges.end()) {
386  throw InvalidArgument("Outgoing " + toString(SUMO_TAG_EDGE) + " with ID '" + edge->getID() + "' doesn't found into " + toString(getTag()) + " with ID " + getID() + "'");
387  } else {
388  // remove edge from containers
389  myGNEOutgoingEdges.erase(i);
390  myGNEEdges.erase(std::find(myGNEEdges.begin(), myGNEEdges.end(), edge));
391  }
392 }
393 
394 
395 const std::vector<GNEEdge*>&
397  return myGNEEdges;
398 }
399 
400 
401 const std::vector<GNEEdge*>&
403  return myGNEIncomingEdges;
404 }
405 
406 
407 const std::vector<GNEEdge*>&
409  return myGNEOutgoingEdges;
410 }
411 
412 
413 const std::vector<GNECrossing*>&
415  return myGNECrossings;
416 }
417 
418 
419 std::vector<GNEConnection*>
421  std::vector<GNEConnection*> connections;
422  for (auto i : myGNEIncomingEdges) {
423  for (auto j : i->getGNEConnections()) {
424  connections.push_back(j);
425  }
426  }
427  return connections;
428 }
429 
430 
431 void
433  myAmCreateEdgeSource = true;
434 }
435 
436 
437 void
439  myAmCreateEdgeSource = false;
440 }
441 
442 
443 void
444 GNEJunction::selectTLS(bool selected) {
445  myAmTLSSelected = selected;
446 }
447 
448 
449 void
450 GNEJunction::moveGeometry(const Position& oldPos, const Position& offset) {
451  // Abort moving if there is another junction in the exactly target position
452  bool abort = false;
453  std::vector<GNEJunction*> junctionNeighbours = getJunctionNeighbours();
454  for (auto i : junctionNeighbours) {
455  if (i->getPositionInView() == myNBNode.getPosition()) {
456  abort = true;
457  }
458  }
459  if (!abort) {
460  Position newPosition = oldPos;
461  newPosition.add(offset);
462  moveJunctionGeometry(newPosition);
463  }
464 }
465 
466 
467 void
470  undoList->p_begin("position of " + toString(getTag()));
471  undoList->p_add(new GNEChange_Attribute(this, SUMO_ATTR_POSITION, toString(myNBNode.getPosition()), true, toString(oldPos)));
472  undoList->p_end();
473  } else {
474  // tried to set an invalid position, revert back to the previous one
475  moveJunctionGeometry(oldPos);
476  }
477 }
478 
479 
480 void
482  // First declare three sets with all affected GNEJunctions, GNEEdges and GNEConnections
483  std::set<GNEJunction*> affectedJunctions;
484  std::set<GNEEdge*> affectedEdges;
485  // Iterate over GNEEdges
486  for (auto i : myGNEEdges) {
487  // Add source and destiny junctions
488  affectedJunctions.insert(i->getGNEJunctionSource());
489  affectedJunctions.insert(i->getGNEJunctionDestiny());
490  // Obtain neighbors of Junction source
491  for (auto j : i->getGNEJunctionSource()->getGNEEdges()) {
492  affectedEdges.insert(j);
493  }
494  // Obtain neighbors of Junction destiny
495  for (auto j : i->getGNEJunctionDestiny()->getGNEEdges()) {
496  affectedEdges.insert(j);
497  }
498  }
499  // Iterate over affected Junctions
500  for (auto i : affectedJunctions) {
501  // Update geometry of Junction
502  i->updateGeometry();
503  }
504  // Iterate over affected Edges
505  for (auto i : affectedEdges) {
506  // Update edge geometry
507  i->updateGeometry();
508  }
509  // Finally update geometry of this junction
510  updateGeometry();
511  // Update view to show the new shapes
512  if (myNet->getViewNet()) {
513  myNet->getViewNet()->update();
514  }
515 }
516 
517 
518 void
520  if (!myNBNode.hasCustomShape()) {
521  myNBNode.myPoly.clear();
523  }
524 }
525 
526 
527 void
528 GNEJunction::setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status) {
529  myHasValidLogic = valid;
530  if (!valid) {
531  assert(undoList != 0);
532  assert(undoList->hasCommandGroup());
534  EdgeVector incoming = myNBNode.getIncomingEdges();
535  for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
536  NBEdge* srcNBE = *it;
537  NBEdge* turnEdge = srcNBE->getTurnDestination();
538  GNEEdge* srcEdge = myNet->retrieveEdge(srcNBE->getID());
539  // Make a copy of connections
540  std::vector<NBEdge::Connection> connections = srcNBE->getConnections();
541  // delete in reverse so that undoing will add connections in the original order
542  for (std::vector<NBEdge::Connection>::reverse_iterator con_it = connections.rbegin(); con_it != connections.rend(); con_it++) {
543  bool hasTurn = con_it->toEdge == turnEdge;
544  undoList->add(new GNEChange_Connection(srcEdge, *con_it, false, false), true);
545  // needs to come after GNEChange_Connection
546  // XXX bug: this code path will not be used on a redo!
547  if (hasTurn) {
548  myNet->addExplicitTurnaround(srcNBE->getID());
549  }
550  }
551  undoList->add(new GNEChange_Attribute(srcEdge, GNE_ATTR_MODIFICATION_STATUS, status), true);
552  }
553  undoList->add(new GNEChange_Attribute(this, GNE_ATTR_MODIFICATION_STATUS, status), true);
554  invalidateTLS(undoList);
555  } else {
556  // logic valed, then rebuild GNECrossings to adapt it to the new logic
557  // (but don't rebuild the crossings in NBNode because they are already finished)
558  rebuildGNECrossings(false);
559  }
560 }
561 
562 
563 void
565  EdgeVector incoming = myNBNode.getIncomingEdges();
566  for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
567  NBEdge* srcNBE = *it;
568  GNEEdge* srcEdge = myNet->retrieveEdge(srcNBE->getID());
569  undoList->add(new GNEChange_Attribute(srcEdge, GNE_ATTR_MODIFICATION_STATUS, MODIFIED), true);
570  }
571 }
572 
573 
574 void
575 GNEJunction::invalidateTLS(GNEUndoList* undoList, const NBConnection& deletedConnection) {
576  assert(undoList->hasCommandGroup());
577  // NBLoadedSUMOTLDef becomes invalid, replace with NBOwnTLDef which will be dynamically recomputed
578  const std::set<NBTrafficLightDefinition*> coypOfTls = myNBNode.getControllingTLS(); // make a copy!
579  for (auto it : coypOfTls) {
580  NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(it);
581  if (tlDef != 0) {
582  NBTrafficLightDefinition* replacementDef = 0;
583  std::string newID = tlDef->getID(); // + "_reguessed"; // changes due to reguessing will be visible in diff
584  if (deletedConnection != NBConnection::InvalidConnection) {
585  // create replacement before deleting the original because deletion will mess up saving original nodes
586  NBLoadedSUMOTLDef* repl = new NBLoadedSUMOTLDef(tlDef, tlDef->getLogic());
587  repl->removeConnection(deletedConnection);
588  replacementDef = repl;
589  } else {
590  replacementDef = new NBOwnTLDef(newID, tlDef->getOffset(), tlDef->getType());
591  replacementDef->setProgramID(tlDef->getProgramID());
592  }
593  undoList->add(new GNEChange_TLS(this, tlDef, false), true);
594  undoList->add(new GNEChange_TLS(this, replacementDef, true, false, newID), true);
595  // the removed traffic light may have controlled more than one junction. These too have become invalid now
596  const std::vector<NBNode*> copyOfNodes = tlDef->getNodes(); // make a copy!
597  for (auto it_node : copyOfNodes) {
598  GNEJunction* sharing = myNet->retrieveJunction(it_node->getID());
599  undoList->add(new GNEChange_TLS(sharing, tlDef, false), true);
600  undoList->add(new GNEChange_TLS(sharing, replacementDef, true, false, newID), true);
601  }
602  }
603  }
604 }
605 
606 void
608  // obtain a copy of GNECrossing of junctions
609  auto copyOfGNECrossings = myGNECrossings;
610  // iterate over copy of GNECrossings
611  for (auto c : copyOfGNECrossings) {
612  // obtain the set of edges vinculated with the crossing (due it works as ID)
613  EdgeSet edgeSet(c->getNBCrossing()->edges.begin(), c->getNBCrossing()->edges.end());
614  // If this edge is part of the set of edges of crossing
615  if (edgeSet.count(edge->getNBEdge()) == 1) {
616  // delete crossing if this is their last edge
617  if ((c->getNBCrossing()->edges.size() == 1) && (c->getNBCrossing()->edges.front() == edge->getNBEdge())) {
618  myNet->deleteCrossing(c, undoList);
619  } else {
620  // remove this edge of the edge's attribute of crossing (note: This can invalidate the crossing)
621  std::vector<std::string> edges = GNEAttributeCarrier::parse<std::vector<std::string>>(c->getAttribute(SUMO_ATTR_EDGES));
622  edges.erase(std::find(edges.begin(), edges.end(), edge->getID()));
623  c->setAttribute(SUMO_ATTR_EDGES, joinToString(edges, " "), undoList);
624  }
625  }
626  }
627 }
628 
629 
630 bool
632  return myHasValidLogic;
633 }
634 
635 
637 GNEJunction::retrieveGNECrossing(NBNode::Crossing* crossing, bool createIfNoExist) {
638  for (auto i : myGNECrossings) {
639  if (i->getNBCrossing() == crossing) {
640  return i;
641  }
642  }
643  if (createIfNoExist) {
644  // create new GNECrossing
645  GNECrossing* createdGNECrossing = new GNECrossing(this, crossing);
646  // show extra information for tests
647  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
648  WRITE_WARNING("Created " + toString(createdGNECrossing->getTag()) + " '" + createdGNECrossing->getID() + "' in retrieveGNECrossing()");
649  }
650  return createdGNECrossing;
651  } else {
652  return NULL;
653  }
654 }
655 
656 
657 std::string
659  switch (key) {
660  case SUMO_ATTR_ID:
661  return getMicrosimID();
662  case SUMO_ATTR_POSITION:
663  return toString(myNBNode.getPosition());
664  case SUMO_ATTR_TYPE:
665  return toString(myNBNode.getType());
667  return myLogicStatus;
668  case SUMO_ATTR_SHAPE:
669  return toString(myNBNode.getShape());
670  case SUMO_ATTR_RADIUS:
671  return toString(myNBNode.getRadius());
672  case SUMO_ATTR_TLTYPE:
673  // @todo this causes problems if the node were to have multiple programs of different type (plausible)
674  return myNBNode.isTLControlled() ? toString((*myNBNode.getControllingTLS().begin())->getType()) : "";
675  case SUMO_ATTR_TLID:
676  return myNBNode.isTLControlled() ? toString((*myNBNode.getControllingTLS().begin())->getID()) : "";
678  return myNBNode.getKeepClear() ? "true" : "false";
679  default:
680  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
681  }
682 }
683 
684 
685 void
686 GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
687  if (value == getAttribute(key)) {
688  return; //avoid needless changes, later logic relies on the fact that attributes have changed
689  }
690  switch (key) {
691  case SUMO_ATTR_ID:
692  case SUMO_ATTR_POSITION:
694  case SUMO_ATTR_SHAPE:
695  case SUMO_ATTR_RADIUS:
696  case SUMO_ATTR_TLTYPE:
698  undoList->add(new GNEChange_Attribute(this, key, value), true);
699  break;
700  case SUMO_ATTR_TYPE: {
701  undoList->p_begin("change " + toString(getTag()) + " type");
703  if (getNBNode()->isTLControlled() &&
704  // if switching changing from or to traffic_light_right_on_red we need to remove the old plan
707  ) {
708  // make a copy because we will modify the original
709  const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode.getControllingTLS();
710  for (auto it : copyOfTls) {
711  undoList->add(new GNEChange_TLS(this, it, false), true);
712  }
713  }
714  if (!getNBNode()->isTLControlled()) {
715  // create new traffic light
716  undoList->add(new GNEChange_TLS(this, 0, true), true);
717  }
718  } else if (getNBNode()->isTLControlled()) {
719  // delete old traffic light
720  // make a copy because we will modify the original
721  const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode.getControllingTLS();
722  for (auto it : copyOfTls) {
723  undoList->add(new GNEChange_TLS(this, it, false, OptionsCont::getOptions().getBool("gui-testing-debug")), true);
724  }
725  }
726  // must be the final step, otherwise we do not know which traffic lights to remove via GNEChange_TLS
727  undoList->add(new GNEChange_Attribute(this, key, value), true);
728  undoList->p_end();
729  break;
730  }
731  case SUMO_ATTR_TLID: {
732  undoList->p_begin("change " + toString(SUMO_TAG_TRAFFIC_LIGHT) + " id");
733  // junction is already controlled, remove from previous tls
734  const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode.getControllingTLS();
735  for (auto it : copyOfTls) {
736  undoList->add(new GNEChange_TLS(this, it, false), true);
737  }
739  const std::map<std::string, NBTrafficLightDefinition*> programs = tlCont.getPrograms(value);
740  if (programs.size() > 0) {
741  // add to existing tls definitions
742  for (auto it : programs) {
743  NBTrafficLightDefinition* oldTLS = it.second;
744  if (dynamic_cast<NBOwnTLDef*>(oldTLS) != 0) {
745  undoList->add(new GNEChange_TLS(this, oldTLS, true), true);
746  } else {
747  // delete and re-create the definition because the loaded phases are now invalid
748  const std::vector<NBNode*> copyOfNodes = oldTLS->getNodes();
749  for (auto it_node : copyOfNodes) {
750  GNEJunction* oldJunction = myNet->retrieveJunction(it_node->getID());
751  undoList->add(new GNEChange_TLS(oldJunction, oldTLS, false), true);
752  }
753  undoList->add(new GNEChange_TLS(this, 0, true, false, value), true);
755  // re-add existing nodes
756  for (auto it_node : copyOfNodes) {
757  GNEJunction* oldJunction = myNet->retrieveJunction(it_node->getID());
758  undoList->add(new GNEChange_TLS(oldJunction, newTLS, true), true);
759  }
760  }
761  }
762  } else {
763  // create new traffic light
764  undoList->add(new GNEChange_TLS(this, 0, true, false, value), true);
765  }
766  undoList->p_end();
767  break;
768  }
769  default:
770  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
771  }
772 }
773 
774 
775 bool
776 GNEJunction::isValid(SumoXMLAttr key, const std::string& value) {
777  switch (key) {
778  case SUMO_ATTR_ID:
779  return isValidID(value) && (myNet->retrieveJunction(value, false) == 0);
780  case SUMO_ATTR_TYPE:
782  case SUMO_ATTR_POSITION: {
783  bool ok;
784  return GeomConvHelper::parseShapeReporting(value, "user-supplied position", 0, ok, false).size() == 1;
785  }
786  case SUMO_ATTR_SHAPE: {
787  bool ok = true;
788  PositionVector shape = GeomConvHelper::parseShapeReporting(value, "user-supplied position", 0, ok, true);
789  return ok;
790  }
791  case SUMO_ATTR_RADIUS:
792  return canParse<double>(value);
793  case SUMO_ATTR_TLTYPE:
795  case SUMO_ATTR_TLID:
796  return myNBNode.isTLControlled() && (value != "");
798  return canParse<bool>(value);
799  default:
800  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
801  }
802 }
803 
804 
805 void
807  myAmResponsible = newVal;
808 }
809 
810 // ===========================================================================
811 // private
812 // ===========================================================================
813 
814 void
815 GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value) {
816  switch (key) {
817  case SUMO_ATTR_ID: {
818  myNet->renameJunction(this, value);
819  break;
820  }
821  case SUMO_ATTR_TYPE: {
823  break;
824  }
825  case SUMO_ATTR_POSITION: {
826  // set new position in NBNode
827  bool ok;
828  moveJunctionGeometry(GeomConvHelper::parseShapeReporting(value, "netedit-given", 0, ok, false)[0]);
829  // Refresh element to avoid grabbing problems
830  myNet->refreshElement(this);
831  break;
832  }
834  if (myLogicStatus == GUESSED && value != GUESSED) {
835  // clear guessed connections. previous connections will be restored
837  // Clear GNEConnections of incoming edges
838  for (auto i : myGNEIncomingEdges) {
839  i->clearGNEConnections();
840  }
841  }
842  myLogicStatus = value;
843  break;
844  case SUMO_ATTR_SHAPE: {
845  bool ok;
846  const PositionVector shape = GeomConvHelper::parseShapeReporting(value, "netedit-given", 0, ok, true);
847  myNBNode.setCustomShape(shape);
848  // Refresh element to avoid grabbing problems
849  myNet->refreshElement(this);
850  break;
851  }
852  case SUMO_ATTR_RADIUS: {
853  myNBNode.setRadius(parse<double>(value));
854  break;
855  }
856  case SUMO_ATTR_TLTYPE: {
857  const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode.getControllingTLS();
858  for (auto it : copyOfTls) {
859  it->setType(SUMOXMLDefinitions::TrafficLightTypes.get(value));
860  }
861  break;
862  }
863  case SUMO_ATTR_KEEP_CLEAR: {
864  myNBNode.setKeepClear(value == "true");
865  break;
866  }
867  default:
868  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
869  }
870 }
871 
872 
873 double
875  switch (s.junctionColorer.getActive()) {
876  case 0:
877  if (bubble) {
878  return 1;
879  } else {
880  return 0;
881  }
882  case 1:
883  return gSelected.isSelected(getType(), getGlID()) ? 1 : 0;
884  case 2:
885  switch (myNBNode.getType()) {
887  return 0;
889  return 1;
890  case NODETYPE_PRIORITY:
891  return 2;
893  return 3;
895  return 4;
897  return 5;
898  case NODETYPE_DISTRICT:
899  return 6;
900  case NODETYPE_NOJUNCTION:
901  return 7;
902  case NODETYPE_DEAD_END:
904  return 8;
905  case NODETYPE_UNKNOWN:
906  case NODETYPE_INTERNAL:
907  assert(false);
908  return 8;
910  return 9;
911  case NODETYPE_ZIPPER:
912  return 10;
914  return 11;
916  return 12;
917  }
918  case 3:
919  return myNBNode.getPosition().z();
920  default:
921  assert(false);
922  return 0;
923  }
924 }
925 
926 
927 void
929  const Position orig = myNBNode.getPosition();
931  // set new position of adjacent edges
932  for (auto i : getNBNode()->getEdges()) {
933  myNet->retrieveEdge(i->getID())->updateJunctionPosition(this, orig);
934  }
935  // Update shapes without include connections, because the aren't showed in Move mode
937 }
938 
939 
940 void
941 GNEJunction::setColor(const GUIVisualizationSettings& s, bool bubble) const {
943  // override with special colors (unless the color scheme is based on selection)
946  }
947  if (myAmCreateEdgeSource) {
948  glColor3d(0, 1, 0);
949  }
950 }
951 
952 void
955  tlCont.insert(tlDef, forceInsert); // may return false for tlDef which controls multiple junctions
956  tlDef->addNode(&myNBNode);
957 }
958 
959 
960 void
963  if (tlDef->getNodes().size() == 1) {
964  tlCont.extract(tlDef);
965  }
967 }
968 
969 /****************************************************************************/
GUIVisualizationSizeSettings junctionSize
bool getKeepClear() const
Returns the keepClear flag.
Definition: NBNode.h:276
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:247
GUIVisualizationTextSettings junctionName
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
void removeConnection(const NBConnection &conn, bool reconstruct=true)
removes the given connection from the traffic light if recontruct=true, reconstructs the logic and in...
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:250
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
double myMaxSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not...
Definition: GNEJunction.h:234
Position getPositionInView() const
Return current position.
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:244
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
static StringBijection< SumoXMLNodeType > NodeTypes
node types
void setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=GUESSED)
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:902
double scale
information about a lane&#39;s width (temporary, used for a single view)
Whether vehicles must keep the junction clear.
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
reset junction&#39;s connections
Definition: GUIAppEnum.h:717
GNENet * myNet
the net to inform about updates
virtual void addNode(NBNode *node)
Adds a node to the traffic light logic.
void invalidateShape()
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
double z() const
Returns the z-position.
Definition: Position.h:72
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
begin/end of the description of a junction
void add(const Position &pos)
Adds the given position to this one.
Definition: Position.h:132
PositionVector myPoly
the (outer) shape of the junction
Definition: NBNode.h:755
void refreshElement(GUIGlObject *o)
refreshes boundary information for o and update
Definition: GNENet.cpp:1082
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
void removeEdgeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
NBNetBuilder * getNetBuilder() const
get net builder
Definition: GNENet.cpp:1331
A loaded (complete) traffic light logic.
bool myAmCreateEdgeSource
whether this junction is the first junction for a newly creatededge
Definition: GNEJunction.h:241
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
static const NBConnection InvalidConnection
Definition: NBConnection.h:126
A container for traffic light definitions and built programs.
std::vector< GNEEdge * > myGNEIncomingEdges
vector with the incomings GNEEdges vinculated with this junction
Definition: GNEJunction.h:228
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
Definition: NBNode.cpp:273
bool isValid(SumoXMLAttr key, const std::string &value)
turn junction into geometry node
Definition: GUIAppEnum.h:719
friend class GNEChange_TLS
Declare friend class.
Definition: GNEJunction.h:57
Stores the information about how to visualize structures.
double y() const
Returns the y-position.
Definition: Position.h:67
bool hasCustomShape() const
return whether the shape was set by the user
Definition: NBNode.h:489
The representation of a single edge during network building.
Definition: NBEdge.h:70
TrafficLightType getType() const
get the algorithm type (static etc..)
double x() const
Returns the x-position.
Definition: Position.h:62
mode for editing tls
Definition: GNEViewNet.h:62
The base class for traffic light logic definitions.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
link,node: the traffic light id responsible for this link
T MAX2(T a, T b)
Definition: StdDefs.h:73
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:161
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:91
NBEdge * getTurnDestination(bool possibleDestination=false) const
Definition: NBEdge.cpp:2774
static void drawFilledPoly(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:83
int editMode
the current NETEDIT mode (temporary)
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:84
void addExplicitTurnaround(std::string id)
add edge id to the list of explicit turnarounds
Definition: GNENet.cpp:1628
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
Definition: Named.h:65
bool myAmTLSSelected
whether this junction is selected in tls-mode
Definition: GNEJunction.h:253
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
Removes the given traffic light from this node.
Definition: NBNode.cpp:331
void setCustomShape(const PositionVector &shape)
set the junction shape
Definition: NBNode.cpp:1732
void extract(NBTrafficLightDefinition *definition)
Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * del...
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:350
edit junction shape
Definition: GUIAppEnum.h:721
void updateShapesAndGeometries()
update shapes of all elements associated to the junction
const std::vector< GNEEdge * > & getGNEEdges() const
Returns all GNEEdges vinculated with this Junction.
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
removes a traffic light
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.
Boundary getBoundary() const
Returns the boundary of the junction.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
whether a feature has been loaded,guessed,modified or approved
const EdgeVector & getOutgoingEdges() const
Returns this node&#39;s outgoing edges (The edges which start at this node)
Definition: NBNode.h:254
double area() const
Returns the area (0 for non-closed)
SUMOTime getOffset()
Returns the offset.
void updateGeometry()
update pre-computed geometry information
Definition: GNECrossing.cpp:71
void renameJunction(GNEJunction *junction, const std::string &newID)
updates the map and reserves new id
Definition: GNENet.cpp:1619
static void drawFilledPolyTesselated(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:102
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
static bool isValidID(const std::string &value)
true if value is a valid sumo ID
static const std::string MODIFIED
feature has been manually modified (implies approval)
void setRadius(double radius)
set the turning radius
Definition: NBNode.h:479
std::string getAttribute(SumoXMLAttr key) const
This functions has to be implemented in all GNEAttributeCarriers.
bool isTLControlled() const
Returns whether this node is controlled by any tls.
Definition: NBNode.h:297
void invalidateIncomingConnections()
invalidate incoming connections
Definition: NBNode.cpp:1339
The turning radius at an intersection in m.
std::set< NBEdge * > EdgeSet
container for unique edges
Definition: NBCont.h:50
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
bool hasCommandGroup() const
Check if undoList has command group.
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:449
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:51
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
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:91
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
GNEJunction * retrieveJunction(const std::string &id, bool failHard=true)
get junction by id
Definition: GNENet.cpp:889
A list of positions.
bool isLogicValid()
whether this junction has a valid logic
void buildCrossingsAndWalkingAreas()
build crossings, and walkingareas. Also removes invalid loaded crossings if wished ...
Definition: NBNode.cpp:2015
friend class GNEChange_Attribute
declare friend class
T get(const std::string &str) const
void commitGeometryMoving(const Position &oldPos, GNEUndoList *undoList)
registers completed movement with the undoList
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node) ...
Definition: NBNode.h:259
bool showJunctionAsBubbles() const
return true if junction must be showed as bubbles
Definition: GNEViewNet.cpp:364
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
NBTrafficLightLogic * getLogic()
Returns the internal logic.
node: the type of traffic light
edge: the shape in xml-definition
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
GUIColorer junctionColorer
The junction colorer.
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void deleteCrossing(GNECrossing *crossing, GNEUndoList *undoList)
remove crossing
Definition: GNENet.cpp:590
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
std::vector< GNEEdge * > myGNEEdges
vector with the GNEEdges vinculated with this junction
Definition: GNEJunction.h:225
const std::string getID() const
function to support debugging
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
void setProgramID(const std::string &programID)
Sets the programID.
const T getColor(const double value) const
const std::string & getProgramID() const
Returns the ProgramID.
void incRef(const std::string &debugMsg="")
Increarse reference.
double getColorValue(const GUIVisualizationSettings &s, bool bubble) const
determines color value
NBNode & myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:222
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
EditMode
Definition: GNEViewNet.h:46
void setKeepClear(bool keepClear)
set the keepClear flag
Definition: NBNode.h:484
bool checkIsRemovableReporting(std::string &reason) const
check if node is removable and return reason if not
Definition: NBNode.cpp:1640
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection)
static void computeTurnDirectionsForNode(NBNode *node, bool warn)
Computes turnaround destinations for all incoming edges of the given nodes (if any) ...
begin/end of the description of an edge
EditMode getCurrentEditMode() const
get the current edit mode
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:1726
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:56
static const double BUBBLE_RADIUS
Definition: GNEJunction.h:62
double selectionScale
the current selection scaling in NETEDIT (temporary)
~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:78
double getRadius() const
Returns the turning radius of this node.
Definition: NBNode.h:271
bool haveNetworkCrossings()
notify about style of loaded network (Without Crossings)
Definition: NBNetBuilder.h:202
void updateGeometry()
Update the boundary of the junction.
const EdgeVector & getIncomingEdges() const
Returns this node&#39;s incoming edges (The edges which yield in this node)
Definition: NBNode.h:249
const std::vector< Connection > & getConnections() const
Returns the connections.
Definition: NBEdge.h:845
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:167
Boundary myBoundary
The represented junction&#39;s boundary.
Definition: GNEJunction.h:237
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:302
void setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:40
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
Definition: GNEJunction.h:256
void scaleRelative(double factor)
enlarges/shrinks the polygon by a factor based at the centroid
void moveGeometry(const Position &oldPos, const Position &offset)
change the position of the element geometry without saving in undoList
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
The popup menu of a globject.
SumoXMLNodeType getType() const
Returns the type of this node.
Definition: NBNode.h:266
std::vector< GNEEdge * > myGNEOutgoingEdges
vector with the outgoings GNEEdges vinculated with this junction
Definition: GNEJunction.h:231
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
clear junction&#39;s connections
Definition: GUIAppEnum.h:715
const Position & getPosition() const
Definition: NBNode.h:241
Represents a single node (junction) during network building.
Definition: NBNode.h:74
GUIGlID getGlID() const
Returns the numerical id of the object.
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
A definition of a pedestrian crossing.
Definition: NBNode.h:131
GNEJunction(NBNode &nbn, GNENet *net, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:66
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
void rebuildGNECrossings(bool rebuildNBNodeCrossings=true)
rebuilds crossing objects for this junction
static const std::string GUESSED
feature has been reguessed (may still be unchanged be we can&#39;t tell (yet)
const std::vector< Crossing * > & getCrossingsIncludingInvalid() const
Definition: NBNode.h:622
bool drawJunctionShape
whether the shape of the junction should be drawn
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
static const RGBColor selectionColor
Definition: GNENet.h:107
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
mode for connecting lanes
Definition: GNEViewNet.h:60
mode for creating new edges
Definition: GNEViewNet.h:50
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:137
bool hasString(const std::string &str) const
GNECrossing * retrieveGNECrossing(NBNode::Crossing *crossing, bool createIfNoExist=true)
get GNECrossing if exist, and if not create it if create is enabled
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:412
std::vector< GNEJunction * > getJunctionNeighbours() const
return GNEJunction neighbours
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:85
A traffic light logics which must be computed (only nodes/edges are given)
Definition: NBOwnTLDef.h:53
void closePolygon()
ensures that the last position equals the first
NBNode * getNBNode() const
Return net build node.
GUISelectedStorage gSelected
A global holder of selected objects.
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition: GNENet.cpp:1613
static bool isTrafficLight(SumoXMLNodeType type)
return whether the given type is a traffic light
Definition: NBNode.cpp:2793
static PositionVector parseShapeReporting(const std::string &shpdef, const std::string &objecttype, const char *objectid, bool &ok, bool allowEmpty, bool report=true)
Builds a PositionVector from a string representation, reporting occured errors.
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:236
void requireRecompute()
inform the net about the need for recomputation
Definition: GNENet.cpp:1308
void moveJunctionGeometry(const Position &pos)
reposition the node at pos and informs the edges
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1607
a junction
SumoXMLTag getTag() const
get XML Tag assigned to this object