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 selectionScale = gSelected.isSelected(getType(), getGlID()) ? s.selectionScale : 1;
174  if (s.scale * selectionScale * myMaxSize < 1.) {
175  // draw something simple so that selection still works
177  } else {
178  // node shape has been computed and is valid for drawing
179  const bool drawShape = myNBNode.getShape().size() > 0 && s.drawJunctionShape;
180  const bool drawBubble = (!drawShape || myNBNode.getShape().area() < 4) && s.drawJunctionShape; // magic threshold
181 
182  if (drawShape) {
183  glPushMatrix();
184  setColor(s, false);
185  glTranslated(0, 0, getType());
186  PositionVector shape = myNBNode.getShape();
187  shape.closePolygon();
188  if (selectionScale > 1) {
189  shape.scaleRelative(selectionScale);
190  }
191  if (s.scale * selectionScale * myMaxSize < 40.) {
192  GLHelper::drawFilledPoly(shape, true);
193  } else {
195  }
196  glPopMatrix();
197  }
198  if (drawBubble) {
199  glPushMatrix();
200  setColor(s, true);
201  Position pos = myNBNode.getPosition();
202  glTranslated(pos.x(), pos.y(), getType() - 0.05);
203  GLHelper::drawFilledCircle(4 * selectionScale, 32);
204  glPopMatrix();
205  }
206 
208  glPushMatrix();
209  Position pos = myNBNode.getPosition();
210  glTranslated(pos.x(), pos.y(), getType() + 0.1);
211  glColor3d(1, 1, 1);
212  const SUMOReal halfWidth = 32 / s.scale;
213  const SUMOReal halfHeight = 64 / s.scale;
214  GUITexturesHelper::drawTexturedBox(GUITextureSubSys::getGif(GNETEXTURE_TLS), -halfWidth, -halfHeight, halfWidth, halfHeight);
215  glPopMatrix();
216  }
217  // draw crossings
218  if (s.editMode != GNE_MODE_TLS) {
219  for (std::vector<GNECrossing*>::const_iterator it = myCrossings.begin(); it != myCrossings.end(); it++) {
220  (*it)->drawGL(s);
221  }
222  }
223  // (optional) draw name @todo expose this setting
225  }
226  glPopName();
227 }
228 
229 Boundary
231  return myBoundary;
232 }
233 
234 
235 NBNode*
237  return &myNBNode;
238 }
239 
240 void
242  myAmCreateEdgeSource = true;
243 }
244 
245 
246 void
248  myAmCreateEdgeSource = false;
249 }
250 
251 
252 void
253 GNEJunction::selectTLS(bool selected) {
254  myAmTLSSelected = selected;
255 }
256 
257 
258 void
260  const Position orig = myNBNode.getPosition();
261  setPosition(pos);
262  myNet->refreshElement(this);
263  const EdgeVector& incident = getNBNode()->getEdges();
264  for (EdgeVector::const_iterator it = incident.begin(); it != incident.end(); it++) {
265  GNEEdge* edge = myNet->retrieveEdge((*it)->getID());
266  edge->updateJunctionPosition(this, orig);
267  }
268 }
269 
270 
271 void
273  Position newPos = myNBNode.getPosition();
274  std::string newPosValue = getAttribute(SUMO_ATTR_POSITION);
275  // actually the geometry is already up to date
276  // set the restore point to the end of the last change-set
278  // do not execute the command to avoid changing the edge geometry twice
279  undoList->add(new GNEChange_Attribute(this, SUMO_ATTR_POSITION, newPosValue), false);
280  setPosition(newPos);
281 }
282 
283 
284 void
286  if (!myNBNode.hasCustomShape()) {
287  myNBNode.myPoly.clear();
289  }
290 }
291 
292 
293 void
294 GNEJunction::setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status) {
295  myHasValidLogic = valid;
296  // If new logic isn't valid
297  if (!valid) {
298  // Check preconditions
299  assert(undoList != 0);
300  assert(undoList->hasCommandGroup());
301  // Registre a modification of status
302  undoList->add(new GNEChange_Attribute(this, GNE_ATTR_MODIFICATION_STATUS, status));
303  // allow edges to recompute their connections
305  // Obtain a copy of incoming edges
306  EdgeVector incoming = myNBNode.getIncomingEdges();
307  // Iterate over incoming edges
308  for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
309  NBEdge* srcNBE = *it;
310  NBEdge* turnEdge = srcNBE->getTurnDestination();
311  GNEEdge* srcEdge = myNet->retrieveEdge(srcNBE->getID());
312  // Make a copy of connections
313  std::vector<NBEdge::Connection> connections = srcNBE->getConnections();
314  // delete in reverse so that undoing will add connections in the original order
315  for (std::vector<NBEdge::Connection>::reverse_iterator con_it = connections.rbegin(); con_it != connections.rend(); con_it++) {
316  bool hasTurn = con_it->toEdge == turnEdge;
317  undoList->add(new GNEChange_Connection(
318  srcEdge, con_it->fromLane, con_it->toEdge->getID(),
319  con_it->toLane, con_it->mayDefinitelyPass, false), true);
320  // needs to come after GNEChange_Connection
321  // XXX bug: this code path will not be used on a redo!
322  if (hasTurn) {
323  myNet->addExplicitTurnaround(srcNBE->getID());
324  }
325  }
326  undoList->add(new GNEChange_Attribute(srcEdge, GNE_ATTR_MODIFICATION_STATUS, status), true);
327  }
328  // Invalidate traffic light
329  invalidateTLS(undoList);
330  } else {
331  rebuildCrossings(false);
332  }
333 }
334 
335 
336 void
337 GNEJunction::invalidateTLS(GNEUndoList* undoList, const NBConnection& deletedConnection) {
338  assert(undoList->hasCommandGroup());
339  // NBLoadedSUMOTLDef becomes invalid, replace with NBOwnTLDef which will be dynamically recomputed
340  const std::set<NBTrafficLightDefinition*> tls = myNBNode.getControllingTLS(); // make a copy!
341  for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
342  NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(*it);
343  if (tlDef != 0) {
344  NBTrafficLightDefinition* replacementDef = 0;
345  std::string newID = tlDef->getID(); // + "_reguessed"; // changes due to reguessing will be visible in diff
346  if (deletedConnection != NBConnection::InvalidConnection) {
347  // create replacement before deleting the original because deletion will mess up saving original nodes
348  NBLoadedSUMOTLDef* repl = new NBLoadedSUMOTLDef(tlDef, tlDef->getLogic());
349  repl->removeConnection(deletedConnection);
350  replacementDef = repl;
351  } else {
352  replacementDef = new NBOwnTLDef(newID, tlDef->getOffset(), tlDef->getType());
353  replacementDef->setProgramID(tlDef->getProgramID());
354  }
355  undoList->add(new GNEChange_TLS(this, tlDef, false), true);
356  undoList->add(new GNEChange_TLS(this, replacementDef, true, false, newID), true);
357  // the removed traffic light may have controlled more than one junction. These too have become invalid now
358  const std::vector<NBNode*> coNodes = tlDef->getNodes(); // make a copy!
359  for (std::vector<NBNode*>::const_iterator it_node = coNodes.begin(); it_node != coNodes.end(); it_node++) {
360  GNEJunction* sharing = myNet->retrieveJunction((*it_node)->getID());
361  undoList->add(new GNEChange_TLS(sharing, tlDef, false), true);
362  undoList->add(new GNEChange_TLS(sharing, replacementDef, true, false, newID), true);
363  }
364  }
365  }
366 }
367 
368 void
370  // @todo implement GNEChange_Crossing
371  UNUSED_PARAMETER(undoList);
372  // make a copy because the original will be modified
373  const std::vector<NBNode::Crossing> crossings = myNBNode.getCrossings();
374  for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
375  EdgeSet edgeSet((*it).edges.begin(), (*it).edges.end());
376  if (edgeSet.count(edge->getNBEdge()) == 1) {
377  myNBNode.removeCrossing((*it).edges);
378  }
379  }
380 }
381 
382 
383 bool
385  return myHasValidLogic;
386 }
387 
388 
389 std::string
391  switch (key) {
392  case SUMO_ATTR_ID:
393  return getMicrosimID();
394  break;
395  case SUMO_ATTR_POSITION:
396  return toString(myNBNode.getPosition());
397  break;
398  case SUMO_ATTR_TYPE:
399  return toString(myNBNode.getType());
400  break;
402  return myLogicStatus;
403  break;
404  case SUMO_ATTR_SHAPE:
405  return toString(myNBNode.getShape());
406  case SUMO_ATTR_RADIUS:
407  return toString(myNBNode.getRadius());
409  return myNBNode.getKeepClear() ? "true" : "false";
410  default:
411  throw InvalidArgument("junction attribute '" + toString(key) + "' not allowed");
412  }
413 }
414 
415 
416 void
417 GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
418  if (value == getAttribute(key)) {
419  return; //avoid needless changes, later logic relies on the fact that attributes have changed
420  }
421  switch (key) {
422  case SUMO_ATTR_ID:
423  case SUMO_ATTR_POSITION:
425  case SUMO_ATTR_SHAPE:
426  case SUMO_ATTR_RADIUS:
428  undoList->add(new GNEChange_Attribute(this, key, value), true);
429  break;
430  case SUMO_ATTR_TYPE: {
431  undoList->p_begin("change junction type");
433  if (!getNBNode()->isTLControlled()) {
434  // create new traffic light
435  undoList->add(new GNEChange_TLS(this, 0, true), true);
436  }
437  } else if (getNBNode()->isTLControlled()) {
438  // delete old traffic light
439  // make a copy because we will modify the original
440  const std::set<NBTrafficLightDefinition*> tls = myNBNode.getControllingTLS();
441  for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
442  undoList->add(new GNEChange_TLS(this, *it, false), true);
443  }
444  }
445  // must be the final step, otherwise we do not know which traffic lights to remove via GNEChange_TLS
446  undoList->add(new GNEChange_Attribute(this, key, value), true);
447  undoList->p_end();
448  break;
449  }
450  default:
451  throw InvalidArgument("junction attribute '" + toString(key) + "' not allowed");
452  }
453 }
454 
455 
456 bool
457 GNEJunction::isValid(SumoXMLAttr key, const std::string& value) {
458  switch (key) {
459  case SUMO_ATTR_ID:
460  return isValidID(value) && myNet->retrieveJunction(value, false) == 0;
461  break;
462  case SUMO_ATTR_TYPE:
464  break;
465  case SUMO_ATTR_POSITION:
466  bool ok;
467  return GeomConvHelper::parseShapeReporting(value, "user-supplied position", 0, ok, false).size() == 1;
468  break;
469  case SUMO_ATTR_SHAPE: {
470  bool ok = true;
472  value, "user-supplied position", 0, ok, true);
473  return ok;
474  break;
475  }
476  case SUMO_ATTR_RADIUS:
477  return canParse<SUMOReal>(value);
478  break;
480  return value == "true" || value == "false";
481  break;
482  default:
483  throw InvalidArgument("junction attribute '" + toString(key) + "' not allowed");
484  }
485 }
486 
487 
488 void
490  myAmResponsible = newVal;
491 }
492 
493 // ===========================================================================
494 // private
495 // ===========================================================================
496 
497 void
498 GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value) {
499  switch (key) {
500  case SUMO_ATTR_ID:
501  myNet->renameJunction(this, value);
502  break;
503  case SUMO_ATTR_TYPE: {
505  break;
506  }
507  case SUMO_ATTR_POSITION:
508  bool ok;
509  myOrigPos = GeomConvHelper::parseShapeReporting(value, "netedit-given", 0, ok, false)[0];
510  move(myOrigPos);
511  break;
513  myLogicStatus = value;
514  break;
515  case SUMO_ATTR_SHAPE: {
516  bool ok;
517  const PositionVector shape = GeomConvHelper::parseShapeReporting(value, "netedit-given", 0, ok, true);
518  myNBNode.setCustomShape(shape);
519  break;
520  }
521  case SUMO_ATTR_RADIUS:
522  myNBNode.setRadius(parse<SUMOReal>(value));
523  break;
525  myNBNode.setKeepClear(value == "true");
526  break;
527  default:
528  throw InvalidArgument("junction attribute '" + toString(key) + "' not allowed");
529  }
530 }
531 
532 
533 void
535  const Position& orig = myNBNode.getPosition();
536  myBoundary.moveby(pos.x() - orig.x(), pos.y() - orig.y());
538  /* //reshift also shifts the junction shape. this is not needed because shape is not yet computed
539  * const Position& orig = myNBNode.getPosition();
540  * myNBNode.reshiftPosition(pos.x() - orig.x(), pos.y() - orig.y());
541  */
542 }
543 
544 
545 SUMOReal
547  switch (s.junctionColorer.getActive()) {
548  case 0:
549  if (bubble) {
550  return 1;
551  } else {
552  return 0;
553  }
554  case 1:
555  return gSelected.isSelected(getType(), getGlID()) ? 1 : 0;
556  case 2:
557  switch (myNBNode.getType()) {
559  return 0;
561  return 1;
562  case NODETYPE_PRIORITY:
563  return 2;
565  return 3;
567  return 4;
569  return 5;
570  case NODETYPE_DISTRICT:
571  return 6;
572  case NODETYPE_NOJUNCTION:
573  return 7;
574  case NODETYPE_DEAD_END:
576  return 8;
577  case NODETYPE_UNKNOWN:
578  case NODETYPE_INTERNAL:
579  assert(false);
580  return 8;
582  return 9;
583  case NODETYPE_ZIPPER:
584  return 10;
586  return 11;
588  return 12;
589  }
590  default:
591  assert(false);
592  return 0;
593  }
594 }
595 
596 
597 void
598 GNEJunction::setColor(const GUIVisualizationSettings& s, bool bubble) const {
600  // override with special colors
601  if (gSelected.isSelected(getType(), getGlID())) {
603  }
604  if (myAmCreateEdgeSource) {
605  glColor3d(0, 1, 0);
606  }
607 }
608 
609 void
612  tlCont.insert(tlDef, forceInsert); // may return false for tlDef which controls multiple junctions
613  tlDef->addNode(&myNBNode);
614 }
615 
616 
617 void
620  tlCont.extract(tlDef);
622 }
623 
624 void
626  EdgeSet edgeSet(crossing.edges.begin(), crossing.edges.end());
627  for (std::vector<NBNode::Crossing>::iterator it = myNBNode.myCrossings.begin(); it != myNBNode.myCrossings.end(); ++it) {
628  EdgeSet edgeSet2((*it).edges.begin(), (*it).edges.end());
629  if (edgeSet == edgeSet2) {
630  (*it).width = crossing.width;
631  (*it).priority = crossing.priority;
632  myNet->refreshElement(this);
633  break;
634  }
635  }
636 }
637 
638 /****************************************************************************/
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:751
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:766
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:640
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:1568
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:1648
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:2458
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 drawTexturedBox(unsigned int which, SUMOReal size)
Draws a named texture as a box with the given size.
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:1642
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:214
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:94
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:2341
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition: GNENet.cpp:959
static bool isTrafficLight(SumoXMLNodeType type)
return whether the given type is a traffic light
Definition: NBNode.cpp:2572
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