SUMO - Simulation of Urban MObility
GNEJunction.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A class for visualizing and editing junctions in netedit (adapted from
8 // GUIJunctionWrapper)
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <string>
33 #include <utility>
36 #include <utils/geom/Position.h>
43 #include <utils/gui/div/GLHelper.h>
48 #include <netbuild/NBOwnTLDef.h>
50 #include <netbuild/NBAlgorithms.h>
51 #include "GNENet.h"
52 #include "GNEEdge.h"
53 #include "GNECrossing.h"
54 #include "GNEUndoList.h"
55 #include "GNEViewNet.h"
56 #include "GNEChange_Attribute.h"
57 #include "GNEChange_Connection.h"
58 #include "GNEChange_TLS.h"
59 #include "GNEJunction.h"
60 
61 #ifdef CHECK_MEMORY_LEAKS
62 #include <foreign/nvwa/debug_new.h>
63 #endif // CHECK_MEMORY_LEAKS
64 
65 // ===========================================================================
66 // method definitions
67 // ===========================================================================
68 GNEJunction::GNEJunction(NBNode& nbn, GNENet* net, bool loaded) :
69  GNENetElement(net, nbn.getID(), GLO_JUNCTION, SUMO_TAG_JUNCTION),
70  myNBNode(nbn),
71  myOrigPos(nbn.getPosition()),
72  myAmCreateEdgeSource(false),
73  myLogicStatus(loaded ? LOADED : GUESSED),
74  myAmResponsible(false),
75  myHasValidLogic(loaded),
76  myAmTLSSelected(false) {
78  rebuildCrossings(false);
79 }
80 
81 
83  if (myAmResponsible) {
84  delete &myNBNode;
85  }
86  rebuildCrossings(true);
87 }
88 
89 
90 void
92  const double EXTENT = 2;
94  myOrigPos.x() - EXTENT, myOrigPos.y() - EXTENT,
95  myOrigPos.x() + EXTENT, myOrigPos.y() + EXTENT);
96  if (myNBNode.getShape().size() > 0) {
98  }
100 }
101 
102 
103 void
105  for (std::vector<GNECrossing*>::const_iterator it = myCrossings.begin(); it != myCrossings.end(); it++) {
106  (*it)->decRef();
107  if ((*it)->unreferenced()) {
108  delete *it;
109  }
110  }
111  myCrossings.clear();
112  if (!deleteOnly) {
113  const std::vector<NBNode::Crossing>& crossings = myNBNode.getCrossings();
114  for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
115  myCrossings.push_back(new GNECrossing(*this, (*it).id));
116  myCrossings.back()->incRef();
117  }
118  }
119 }
120 
121 
124  GUISUMOAbstractView& parent) {
125  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
126  buildPopupHeader(ret, app);
130  buildPositionCopyEntry(ret, false);
131  //if (parent.getVisualisationSettings()->editMode != GNE_MODE_CONNECT) {
132  // // XXX if joinable
133  // new FXMenuCommand(ret, "Join adjacent edges", 0, &parent, MID_GNE_JOIN_EDGES);
134  //}
135  FXMenuCommand* mcCustomShape = new FXMenuCommand(ret, "Set custom shape", 0, &parent, MID_GNE_NODE_SHAPE);
136  FXMenuCommand* mcReplace = new FXMenuCommand(ret, "Replace by geometry node", 0, &parent, MID_GNE_NODE_REPLACE);
137  const int editMode = parent.getVisualisationSettings()->editMode;
138  const bool wrongMode = (editMode == GNE_MODE_CONNECT || editMode == GNE_MODE_TLS || editMode == GNE_MODE_CREATE_EDGE);
139  if (wrongMode) {
140  mcCustomShape->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), 0);
141  }
142  // checkIsRemovable requiers turnarounds to be computed. This is ugly
143  if (myNBNode.getIncomingEdges().size() == 2 && myNBNode.getOutgoingEdges().size() == 2) {
145  }
146  if (wrongMode || !myNBNode.checkIsRemovable()) {
147  mcReplace->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), 0);
148  }
149  // let the GNEViewNet store the popup position
150  (dynamic_cast<GNEViewNet&>(parent)).markPopupPosition();
151  return ret;
152 }
153 
154 
158  return 0;
159 }
160 
161 
162 Boundary
164  Boundary b = myBoundary;
165  b.grow(20);
166  return b;
167 }
168 
169 
170 void
172  glPushName(getGlID());
173  SUMOReal exaggeration = gSelected.isSelected(getType(), getGlID()) ? s.selectionScale : 1;
174  exaggeration *= s.junctionSize.getExaggeration(s);
175  if (s.scale * exaggeration * myMaxSize < 1.) {
176  // draw something simple so that selection still works
178  } else {
179  // node shape has been computed and is valid for drawing
180  const bool drawShape = myNBNode.getShape().size() > 0 && s.drawJunctionShape;
181  const bool drawBubble = (!drawShape || myNBNode.getShape().area() < 4) && s.drawJunctionShape; // magic threshold
182 
183  if (drawShape) {
184  setColor(s, false);
185  // recognize full transparency and simply don't draw
186  GLfloat color[4];
187  glGetFloatv(GL_CURRENT_COLOR, color);
188  if (color[3] != 0) {
189  glPushMatrix();
190  glTranslated(0, 0, getType());
191  PositionVector shape = myNBNode.getShape();
192  shape.closePolygon();
193  if (exaggeration > 1) {
194  shape.scaleRelative(exaggeration);
195  }
196  if (s.scale * exaggeration * myMaxSize < 40.) {
197  GLHelper::drawFilledPoly(shape, true);
198  } else {
200  }
201  glPopMatrix();
202  }
203  }
204  if (drawBubble) {
205  setColor(s, true);
206  // recognize full transparency and simply don't draw
207  GLfloat color[4];
208  glGetFloatv(GL_CURRENT_COLOR, color);
209  if (color[3] != 0) {
210  glPushMatrix();
211  Position pos = myNBNode.getPosition();
212  glTranslated(pos.x(), pos.y(), getType() - 0.05);
213  GLHelper::drawFilledCircle(4 * exaggeration, 32);
214  glPopMatrix();
215  }
216  }
217 
219  glPushMatrix();
220  Position pos = myNBNode.getPosition();
221  glTranslated(pos.x(), pos.y(), getType() + 0.1);
222  glColor3d(1, 1, 1);
223  const SUMOReal halfWidth = 32 / s.scale;
224  const SUMOReal halfHeight = 64 / s.scale;
225  GUITexturesHelper::drawTexturedBox(GUITextureSubSys::getGif(GNETEXTURE_TLS), -halfWidth, -halfHeight, halfWidth, halfHeight);
226  glPopMatrix();
227  }
228  // draw crossings
229  if (s.editMode != GNE_MODE_TLS) {
230  for (std::vector<GNECrossing*>::const_iterator it = myCrossings.begin(); it != myCrossings.end(); it++) {
231  (*it)->drawGL(s);
232  }
233  }
234  // (optional) draw name @todo expose this setting
236  }
237  glPopName();
238 }
239 
240 Boundary
242  return myBoundary;
243 }
244 
245 
246 NBNode*
248  return &myNBNode;
249 }
250 
251 void
253  myAmCreateEdgeSource = true;
254 }
255 
256 
257 void
259  myAmCreateEdgeSource = false;
260 }
261 
262 
263 void
264 GNEJunction::selectTLS(bool selected) {
265  myAmTLSSelected = selected;
266 }
267 
268 
269 void
271  const Position orig = myNBNode.getPosition();
272  setPosition(pos);
273  myNet->refreshElement(this);
274  const EdgeVector& incident = getNBNode()->getEdges();
275  for (EdgeVector::const_iterator it = incident.begin(); it != incident.end(); it++) {
276  GNEEdge* edge = myNet->retrieveEdge((*it)->getID());
277  edge->updateJunctionPosition(this, orig);
278  }
279 }
280 
281 
282 void
284  Position newPos = myNBNode.getPosition();
285  std::string newPosValue = getAttribute(SUMO_ATTR_POSITION);
286  // actually the geometry is already up to date
287  // set the restore point to the end of the last change-set
289  // do not execute the command to avoid changing the edge geometry twice
290  undoList->add(new GNEChange_Attribute(this, SUMO_ATTR_POSITION, newPosValue), false);
291  setPosition(newPos);
292 }
293 
294 
295 void
297  if (!myNBNode.hasCustomShape()) {
298  myNBNode.myPoly.clear();
300  }
301 }
302 
303 
304 void
305 GNEJunction::setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status) {
306  myHasValidLogic = valid;
307  // If new logic isn't valid
308  if (!valid) {
309 
310  // Check preconditions
311  assert(undoList != 0);
312  assert(undoList->hasCommandGroup());
313 
314  // Registre a modification of status
315  undoList->add(new GNEChange_Attribute(this, GNE_ATTR_MODIFICATION_STATUS, status));
316 
317  // allow edges to recompute their connections
319 
320  // Obtain a copy of incoming edges
321  EdgeVector incoming = myNBNode.getIncomingEdges();
322 
323  // Iterate over incoming edges
324  for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
325  NBEdge* srcNBE = *it;
326  NBEdge* turnEdge = srcNBE->getTurnDestination();
327  GNEEdge* srcEdge = myNet->retrieveEdge(srcNBE->getID());
328  // Make a copy of connections
329  std::vector<NBEdge::Connection> connections = srcNBE->getConnections();
330  // delete in reverse so that undoing will add connections in the original order
331  for (std::vector<NBEdge::Connection>::reverse_iterator con_it = connections.rbegin(); con_it != connections.rend(); con_it++) {
332  bool hasTurn = con_it->toEdge == turnEdge;
333  undoList->add(new GNEChange_Connection(
334  srcEdge, con_it->fromLane, con_it->toEdge->getID(),
335  con_it->toLane, con_it->mayDefinitelyPass, false), true);
336  // needs to come after GNEChange_Connection
337  // XXX bug: this code path will not be used on a redo!
338  if (hasTurn) {
339  myNet->addExplicitTurnaround(srcNBE->getID());
340  }
341  }
342  undoList->add(new GNEChange_Attribute(srcEdge, GNE_ATTR_MODIFICATION_STATUS, status), true);
343  }
344  // Invalidate traffic light
345  invalidateTLS(undoList);
346  } else {
347  rebuildCrossings(false);
348  }
349 }
350 
351 
352 void
353 GNEJunction::invalidateTLS(GNEUndoList* undoList, const NBConnection& deletedConnection) {
354  assert(undoList->hasCommandGroup());
355  // NBLoadedSUMOTLDef becomes invalid, replace with NBOwnTLDef which will be dynamically recomputed
356  const std::set<NBTrafficLightDefinition*> tls = myNBNode.getControllingTLS(); // make a copy!
357  for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
358  NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(*it);
359  if (tlDef != 0) {
360  NBTrafficLightDefinition* replacementDef = 0;
361  std::string newID = tlDef->getID(); // + "_reguessed"; // changes due to reguessing will be visible in diff
362  if (deletedConnection != NBConnection::InvalidConnection) {
363  // create replacement before deleting the original because deletion will mess up saving original nodes
364  NBLoadedSUMOTLDef* repl = new NBLoadedSUMOTLDef(tlDef, tlDef->getLogic());
365  repl->removeConnection(deletedConnection);
366  replacementDef = repl;
367  } else {
368  replacementDef = new NBOwnTLDef(newID, tlDef->getOffset(), tlDef->getType());
369  replacementDef->setProgramID(tlDef->getProgramID());
370  }
371  undoList->add(new GNEChange_TLS(this, tlDef, false), true);
372  undoList->add(new GNEChange_TLS(this, replacementDef, true, false, newID), true);
373  // the removed traffic light may have controlled more than one junction. These too have become invalid now
374  const std::vector<NBNode*> coNodes = tlDef->getNodes(); // make a copy!
375  for (std::vector<NBNode*>::const_iterator it_node = coNodes.begin(); it_node != coNodes.end(); it_node++) {
376  GNEJunction* sharing = myNet->retrieveJunction((*it_node)->getID());
377  undoList->add(new GNEChange_TLS(sharing, tlDef, false), true);
378  undoList->add(new GNEChange_TLS(sharing, replacementDef, true, false, newID), true);
379  }
380  }
381  }
382 }
383 
384 void
386  // @todo implement GNEChange_Crossing
387  UNUSED_PARAMETER(undoList);
388  // make a copy because the original will be modified
389  const std::vector<NBNode::Crossing> crossings = myNBNode.getCrossings();
390  for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
391  EdgeSet edgeSet((*it).edges.begin(), (*it).edges.end());
392  if (edgeSet.count(edge->getNBEdge()) == 1) {
393  myNBNode.removeCrossing((*it).edges);
394  }
395  }
396 }
397 
398 
399 bool
401  return myHasValidLogic;
402 }
403 
404 
405 std::string
407  switch (key) {
408  case SUMO_ATTR_ID:
409  return getMicrosimID();
410  break;
411  case SUMO_ATTR_POSITION:
412  return toString(myNBNode.getPosition());
413  break;
414  case SUMO_ATTR_TYPE:
415  return toString(myNBNode.getType());
416  break;
418  return myLogicStatus;
419  break;
420  case SUMO_ATTR_SHAPE:
421  return toString(myNBNode.getShape());
422  case SUMO_ATTR_RADIUS:
423  return toString(myNBNode.getRadius());
425  return myNBNode.getKeepClear() ? "true" : "false";
426  default:
427  throw InvalidArgument("junction attribute '" + toString(key) + "' not allowed");
428  }
429 }
430 
431 
432 void
433 GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
434  if (value == getAttribute(key)) {
435  return; //avoid needless changes, later logic relies on the fact that attributes have changed
436  }
437  switch (key) {
438  case SUMO_ATTR_ID:
439  case SUMO_ATTR_POSITION:
441  case SUMO_ATTR_SHAPE:
442  case SUMO_ATTR_RADIUS:
444  undoList->add(new GNEChange_Attribute(this, key, value), true);
445  break;
446  case SUMO_ATTR_TYPE: {
447  undoList->p_begin("change junction type");
449  if (!getNBNode()->isTLControlled()) {
450  // create new traffic light
451  undoList->add(new GNEChange_TLS(this, 0, true), true);
452  }
453  } else if (getNBNode()->isTLControlled()) {
454  // delete old traffic light
455  // make a copy because we will modify the original
456  const std::set<NBTrafficLightDefinition*> tls = myNBNode.getControllingTLS();
457  for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
458  undoList->add(new GNEChange_TLS(this, *it, false), true);
459  }
460  }
461  // must be the final step, otherwise we do not know which traffic lights to remove via GNEChange_TLS
462  undoList->add(new GNEChange_Attribute(this, key, value), true);
463  undoList->p_end();
464  break;
465  }
466  default:
467  throw InvalidArgument("junction attribute '" + toString(key) + "' not allowed");
468  }
469 }
470 
471 
472 bool
473 GNEJunction::isValid(SumoXMLAttr key, const std::string& value) {
474  switch (key) {
475  case SUMO_ATTR_ID:
476  return isValidID(value) && myNet->retrieveJunction(value, false) == 0;
477  break;
478  case SUMO_ATTR_TYPE:
480  break;
481  case SUMO_ATTR_POSITION:
482  bool ok;
483  return GeomConvHelper::parseShapeReporting(value, "user-supplied position", 0, ok, false).size() == 1;
484  break;
485  case SUMO_ATTR_SHAPE: {
486  bool ok = true;
488  value, "user-supplied position", 0, ok, true);
489  return ok;
490  break;
491  }
492  case SUMO_ATTR_RADIUS:
493  return canParse<SUMOReal>(value);
494  break;
496  return value == "true" || value == "false";
497  break;
498  default:
499  throw InvalidArgument("junction attribute '" + toString(key) + "' not allowed");
500  }
501 }
502 
503 
504 void
506  myAmResponsible = newVal;
507 }
508 
509 // ===========================================================================
510 // private
511 // ===========================================================================
512 
513 void
514 GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value) {
515  switch (key) {
516  case SUMO_ATTR_ID:
517  myNet->renameJunction(this, value);
518  break;
519  case SUMO_ATTR_TYPE: {
521  break;
522  }
523  case SUMO_ATTR_POSITION:
524  bool ok;
525  myOrigPos = GeomConvHelper::parseShapeReporting(value, "netedit-given", 0, ok, false)[0];
526  move(myOrigPos);
527  break;
529  myLogicStatus = value;
530  break;
531  case SUMO_ATTR_SHAPE: {
532  bool ok;
533  const PositionVector shape = GeomConvHelper::parseShapeReporting(value, "netedit-given", 0, ok, true);
534  myNBNode.setCustomShape(shape);
535  break;
536  }
537  case SUMO_ATTR_RADIUS:
538  myNBNode.setRadius(parse<SUMOReal>(value));
539  break;
541  myNBNode.setKeepClear(value == "true");
542  break;
543  default:
544  throw InvalidArgument("junction attribute '" + toString(key) + "' not allowed");
545  }
546 }
547 
548 
549 void
551  const Position& orig = myNBNode.getPosition();
552  myBoundary.moveby(pos.x() - orig.x(), pos.y() - orig.y());
554  /* //reshift also shifts the junction shape. this is not needed because shape is not yet computed
555  * const Position& orig = myNBNode.getPosition();
556  * myNBNode.reshiftPosition(pos.x() - orig.x(), pos.y() - orig.y());
557  */
558 }
559 
560 
561 SUMOReal
563  switch (s.junctionColorer.getActive()) {
564  case 0:
565  if (bubble) {
566  return 1;
567  } else {
568  return 0;
569  }
570  case 1:
571  return gSelected.isSelected(getType(), getGlID()) ? 1 : 0;
572  case 2:
573  switch (myNBNode.getType()) {
575  return 0;
577  return 1;
578  case NODETYPE_PRIORITY:
579  return 2;
581  return 3;
583  return 4;
585  return 5;
586  case NODETYPE_DISTRICT:
587  return 6;
588  case NODETYPE_NOJUNCTION:
589  return 7;
590  case NODETYPE_DEAD_END:
592  return 8;
593  case NODETYPE_UNKNOWN:
594  case NODETYPE_INTERNAL:
595  assert(false);
596  return 8;
598  return 9;
599  case NODETYPE_ZIPPER:
600  return 10;
602  return 11;
604  return 12;
605  }
606  default:
607  assert(false);
608  return 0;
609  }
610 }
611 
612 
613 void
614 GNEJunction::setColor(const GUIVisualizationSettings& s, bool bubble) const {
616  // override with special colors (unless the color scheme is based on selection)
619  }
620  if (myAmCreateEdgeSource) {
621  glColor3d(0, 1, 0);
622  }
623 }
624 
625 void
628  tlCont.insert(tlDef, forceInsert); // may return false for tlDef which controls multiple junctions
629  tlDef->addNode(&myNBNode);
630 }
631 
632 
633 void
636  tlCont.extract(tlDef);
638 }
639 
640 void
642  EdgeSet edgeSet(crossing.edges.begin(), crossing.edges.end());
643  for (std::vector<NBNode::Crossing>::iterator it = myNBNode.myCrossings.begin(); it != myNBNode.myCrossings.end(); ++it) {
644  EdgeSet edgeSet2((*it).edges.begin(), (*it).edges.end());
645  if (edgeSet == edgeSet2) {
646  (*it).width = crossing.width;
647  (*it).priority = crossing.priority;
648  myNet->refreshElement(this);
649  break;
650  }
651  }
652 }
653 
654 /****************************************************************************/
GUIVisualizationSizeSettings junctionSize
SUMOReal getExaggeration(const GUIVisualizationSettings &s, SUMOReal factor=20) const
return the drawing size including exaggeration and constantSize values
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:207
void rebuildCrossings(bool deleteOnly)
rebuilds crossing objects for this junction
GUIVisualizationTextSettings junctionName
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:210
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
const EdgeVector & getIncomingEdges() const
Returns this node&#39;s incoming edges.
Definition: NBNode.h:240
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:204
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
bool getKeepClear() const
Returns the keepClear flag.
Definition: NBNode.h:278
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
SUMOReal getHeight() const
Returns the height of the boundary.
Definition: Boundary.cpp:142
static StringBijection< SumoXMLNodeType > NodeTypes
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
Definition: GNENet.cpp:616
std::vector< Crossing > myCrossings
Vector of crossings.
Definition: NBNode.h:757
SUMOReal width
This lane&#39;s width.
Definition: NBNode.h:143
Whether vehicles must keep the junction clear.
GNENet * myNet
the net to inform about updates
virtual void addNode(NBNode *node)
Adds a node to the traffic light logic.
SUMOReal getWidth() const
Returns the width of the boudary.
Definition: Boundary.cpp:136
void invalidateShape()
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
SUMOReal getRadius() const
Returns the turning radius of this node.
Definition: NBNode.h:272
PositionVector myPoly
the (outer) shape of the junction
Definition: NBNode.h:772
void refreshElement(GUIGlObject *o)
refreshes boundary information for o and update
Definition: GNENet.cpp:690
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
bool hasString(const std::string &str) const
A loaded (complete) traffic light logic.
bool myAmCreateEdgeSource
whether this junction is the first junction for a newly creatededge
Definition: GNEJunction.h:201
static const NBConnection InvalidConnection
Definition: NBConnection.h:128
A container for traffic light definitions and built programs.
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
Definition: NBNode.cpp:264
bool isTLControlled() const
Returns whether this node is controlled by any tls.
Definition: NBNode.h:304
bool isValid(SumoXMLAttr key, const std::string &value)
TrafficLightType getType() const
get the algorithm type (static etc..)
void setLogicValid(bool valid, GNEUndoList *undoList=0, const std::string &status=GUESSED)
friend class GNEChange_TLS
Declare friend class.
Definition: GNEJunction.h:57
Stores the information about how to visualize structures.
const std::string & getProgramID() const
Returns the ProgramID.
The representation of a single edge during network building.
Definition: NBEdge.h:70
mode for editing tls
Definition: GNEViewNet.h:62
NBNode * getNBNode() const
Return net build node.
const std::vector< Crossing > & getCrossings() const
return this junctions pedestrian crossings
Definition: NBNode.h:646
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.
void scaleRelative(SUMOReal factor)
enlarges/shrinks the polygon by a factor based at the centroid
T MAX2(T a, T b)
Definition: StdDefs.h:75
static void drawBoxLine(const Position &beg, SUMOReal rot, SUMOReal visLength, SUMOReal width, SUMOReal offset=0)
Draws a thick line.
Definition: GLHelper.cpp:130
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:86
static void drawFilledPoly(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:76
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:86
bool hasCustomShape() const
return whether the shape was set by the user
Definition: NBNode.h:520
void addExplicitTurnaround(std::string id)
add edge id to the list of explicit turnarounds
Definition: GNENet.cpp:974
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
bool checkIsRemovable() const
Definition: NBNode.cpp:1625
bool myAmTLSSelected
whether this junction is selected in tls-mode
Definition: GNEJunction.h:213
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
Removes the given traffic light from this node.
Definition: NBNode.cpp:322
void setCustomShape(const PositionVector &shape)
set the junction shape
Definition: NBNode.cpp:1705
void extract(NBTrafficLightDefinition *definition)
Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * del...
void registerMove(GNEUndoList *undoList)
registers completed movement with the undoList
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
removes a traffic light
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
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.
GUIGlID getGlID() const
Returns the numerical id of the object.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
Position myOrigPos
restore point for undo
Definition: GNEJunction.h:191
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
void setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
bool priority
whether the pedestrians have priority
Definition: NBNode.h:151
SUMOTime getOffset()
Returns the offset.
void renameJunction(GNEJunction *junction, const std::string &newID)
updates the map and reserves new id
Definition: GNENet.cpp:965
static void drawFilledPolyTesselated(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:95
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
const EdgeVector & getOutgoingEdges() const
Returns this node&#39;s outgoing edges.
Definition: NBNode.h:248
static void drawFilledCircle(SUMOReal width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:344
const std::string & getID() const
Returns the id.
Definition: Named.h:66
static bool isValidID(const std::string &value)
true if value is a valid sumo ID
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void removeCrossing(const EdgeVector &edges)
remove a pedestrian crossing from this node (identified by its edges)
Definition: NBNode.cpp:2515
const Position & getPosition() const
Returns the position of this node.
Definition: NBNode.h:228
The turning radius at an intersection in m.
std::set< NBEdge * > EdgeSet
Definition: NBCont.h:51
SUMOReal selectionScale
the current selection scaling in NETEDIT (temporary)
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node.
Definition: NBNode.h:318
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:443
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:51
void updateCrossingAttributes(NBNode::Crossing crossing)
modify the specified crossing (using friend privileges)
void setRadius(SUMOReal radius)
set the turning radius
Definition: NBNode.h:510
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:603
A list of positions.
bool isLogicValid()
whether this junction has a valid logic
SUMOReal getColorValue(const GUIVisualizationSettings &s, bool bubble) const
determines color value
friend class GNEChange_Attribute
declare friend class
SumoXMLNodeType getType() const
Returns the type of this node.
Definition: NBNode.h:265
void removeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
SUMOReal myMaxSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not...
Definition: GNEJunction.h:194
const EdgeVector & getEdges() const
Returns all edges which participate in this node.
Definition: NBNode.h:256
const T getColor(const SUMOReal value) const
NBTrafficLightLogic * getLogic()
Returns the internal logic.
GUIColorer junctionColorer
The junction colorer.
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
void setProgramID(const std::string &programID)
Sets the programID.
const std::string getID() const
function to support debugging
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
draw name of item
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:1699
NBNode & myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:188
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
void setKeepClear(bool keepClear)
set the keepClear flag
Definition: NBNode.h:515
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) ...
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:54
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:76
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:201
bool hasCommandGroup() const
Check if undoList has command group.
virtual ~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:82
void updateGeometry()
Update the boundary of the junction.
Definition: GNEJunction.cpp:91
Boundary getBoundary() const
Returns the boundary of the junction.
Boundary myBoundary
The represented junction&#39;s boundary.
Definition: GNEJunction.h:197
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:41
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
void move(Position pos)
reposition the node at pos and informs the edges
void updateJunctionPosition(GNEJunction *junction, const Position &origPos)
update edge geometry after junction move
Definition: GNEEdge.cpp:212
The popup menu of a globject.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
EdgeVector edges
The edges being crossed.
Definition: NBNode.h:139
Represents a single node (junction) during network building.
Definition: NBNode.h:74
T get(const std::string &str) const
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
A definition of a pedestrian crossing.
Definition: NBNode.h:132
GNEJunction(NBNode &nbn, GNENet *net, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:68
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
GUIVisualizationSettings * getVisualisationSettings() const
get visualitation settings
#define SUMOReal
Definition: config.h:213
std::vector< GNECrossing * > myCrossings
the built crossing objects
Definition: GNEJunction.h:216
bool drawJunctionShape
whether the shape of the junction should be drawn
static const RGBColor selectionColor
color of selection
Definition: GNENet.h:95
mode for connecting lanes
Definition: GNEViewNet.h:60
mode for creating new edges
Definition: GNEViewNet.h:50
void moveby(SUMOReal x, SUMOReal y)
Moves the boundary by the given amount.
Definition: Boundary.cpp:250
std::string getAttribute(SumoXMLAttr key) const
void setPosition(Position pos)
reposition the NBNnode and nothing else
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:225
SUMOReal area() const
Returns the area (0 for non-closed)
A traffic light logics which must be computed (only nodes/edges are given)
Definition: NBOwnTLDef.h:54
static GUIGlID getGif(GUITexture which)
returns a texture Gif previously defined in the enum GUITexture
void closePolygon()
ensures that the last position equals the first
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
GUISelectedStorage gSelected
A global holder of selected objects.
const std::vector< Connection > & getConnections() const
Returns the connections.
Definition: NBEdge.h:786
A window containing a gl-object&#39;s parameter.
NBEdge * getTurnDestination(bool possibleDestination=false) const
Definition: NBEdge.cpp:2339
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition: GNENet.cpp:959
static void drawTexturedBox(int which, SUMOReal size)
Draws a named texture as a box with the given size.
static bool isTrafficLight(SumoXMLNodeType type)
return whether the given type is a traffic light
Definition: NBNode.cpp:2629
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.
void requireRecompute()
inform the net about the need for recomputation
Definition: GNENet.cpp:840
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
a junction