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 "tlslogo.cpp"
52 #include "GNENet.h"
53 #include "GNEEdge.h"
54 #include "GNECrossing.h"
55 #include "GNEUndoList.h"
56 #include "GNEViewNet.h"
57 #include "GNEChange_Attribute.h"
58 #include "GNEChange_Connection.h"
59 #include "GNEChange_TLS.h"
60 #include "GNEJunction.h"
61 
62 #ifdef CHECK_MEMORY_LEAKS
63 #include <foreign/nvwa/debug_new.h>
64 #endif // CHECK_MEMORY_LEAKS
65 
66 
67 // ===========================================================================
68 // static members
69 // ===========================================================================
72 
73 // ===========================================================================
74 // method definitions
75 // ===========================================================================
76 GNEJunction::GNEJunction(NBNode& nbn, GNENet* net, bool loaded) :
77  GUIGlObject(GLO_JUNCTION, nbn.getID()),
79  myNBNode(nbn),
80  myOrigPos(nbn.getPosition()),
81  myAmCreateEdgeSource(false),
82  myNet(net),
83  myLogicStatus(loaded ? LOADED : GUESSED),
84  myAmResponsible(false),
85  myHasValidLogic(loaded),
86  myAmTLSSelected(false) {
88  rebuildCrossings(false);
89 }
90 
91 
93  if (myAmResponsible) {
94  delete &myNBNode;
95  }
96  rebuildCrossings(true);
97 }
98 
99 
100 void
102  const double EXTENT = 2;
104  myOrigPos.x() - EXTENT, myOrigPos.y() - EXTENT,
105  myOrigPos.x() + EXTENT, myOrigPos.y() + EXTENT);
106  if (myNBNode.getShape().size() > 0) {
108  }
110 }
111 
112 
113 void
115  for (std::vector<GNECrossing*>::const_iterator it = myCrossings.begin(); it != myCrossings.end(); it++) {
116  (*it)->decRef();
117  if ((*it)->unreferenced()) {
118  delete *it;
119  }
120  }
121  myCrossings.clear();
122  if (!deleteOnly) {
123  const std::vector<NBNode::Crossing>& crossings = myNBNode.getCrossings();
124  for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
125  myCrossings.push_back(new GNECrossing(*this, (*it).id));
126  myCrossings.back()->incRef();
127  }
128  }
129 }
130 
131 
134  GUISUMOAbstractView& parent) {
135  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
136  buildPopupHeader(ret, app);
140  buildPositionCopyEntry(ret, false);
141  //if (parent.getVisualisationSettings()->editMode != GNE_MODE_CONNECT) {
142  // // XXX if joinable
143  // new FXMenuCommand(ret, "Join adjacent edges", 0, &parent, MID_GNE_JOIN_EDGES);
144  //}
145  FXMenuCommand* mcCustomShape = new FXMenuCommand(ret, "Set custom shape", 0, &parent, MID_GNE_NODE_SHAPE);
146  FXMenuCommand* mcReplace = new FXMenuCommand(ret, "Replace by geometry node", 0, &parent, MID_GNE_NODE_REPLACE);
147  const int editMode = parent.getVisualisationSettings()->editMode;
148  const bool wrongMode = (editMode == GNE_MODE_CONNECT || editMode == GNE_MODE_TLS || editMode == GNE_MODE_CREATE_EDGE);
149  if (wrongMode) {
150  mcCustomShape->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), 0);
151  }
152  // checkIsRemovable requiers turnarounds to be computed. This is ugly
153  if (myNBNode.getIncomingEdges().size() == 2 && myNBNode.getOutgoingEdges().size() == 2) {
155  }
156  if (wrongMode || !myNBNode.checkIsRemovable()) {
157  mcReplace->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), 0);
158  }
159  // let the GNEViewNet store the popup position
160  (dynamic_cast<GNEViewNet&>(parent)).markPopupPosition();
161  return ret;
162 }
163 
164 
168  return 0;
169 }
170 
171 
172 Boundary
174  Boundary b = myBoundary;
175  b.grow(20);
176  return b;
177 }
178 
179 
180 void
182  glPushName(getGlID());
183  SUMOReal selectionScale = gSelected.isSelected(getType(), getGlID()) ? s.selectionScale : 1;
184  if (s.scale * selectionScale * myMaxSize < 1.) {
185  // draw something simple so that selection still works
187  } else {
188  // node shape has been computed and is valid for drawing
189  const bool drawShape = myNBNode.getShape().size() > 0 && s.drawJunctionShape;
190  const bool drawBubble = (!drawShape || myNBNode.getShape().area() < 4) && s.drawJunctionShape; // magic threshold
191 
192  if (drawShape) {
193  glPushMatrix();
194  setColor(s, false);
195  glTranslated(0, 0, getType());
196  PositionVector shape = myNBNode.getShape();
197  shape.closePolygon();
198  if (selectionScale > 1) {
199  shape.scaleRelative(selectionScale);
200  }
201  if (s.scale * selectionScale * myMaxSize < 40.) {
202  GLHelper::drawFilledPoly(shape, true);
203  } else {
205  }
206  glPopMatrix();
207  }
208  if (drawBubble) {
209  glPushMatrix();
210  setColor(s, true);
211  Position pos = myNBNode.getPosition();
212  glTranslated(pos.x(), pos.y(), getType() - 0.05);
213  GLHelper::drawFilledCircle(4 * selectionScale, 32);
214  glPopMatrix();
215  }
216 
218  // decorate in tls mode
219  if (!TLSDecalInitialized) {
220  FXImage* i = new FXGIFImage(myNet->getApp(), tlslogo, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP);
222  TLSDecalInitialized = true;
223  delete i;
224  }
225  glPushMatrix();
226  Position pos = myNBNode.getPosition();
227  glTranslated(pos.x(), pos.y(), getType() + 0.1);
228  glColor3d(1, 1, 1);
229  const SUMOReal halfWidth = 32 / s.scale;
230  const SUMOReal halfHeight = 64 / s.scale;
231  GUITexturesHelper::drawTexturedBox(TLSDecalGlID, -halfWidth, -halfHeight, halfWidth, halfHeight);
232  glPopMatrix();
233  }
234  // draw crossings
235  if (s.editMode != GNE_MODE_TLS) {
236  for (std::vector<GNECrossing*>::const_iterator it = myCrossings.begin(); it != myCrossings.end(); it++) {
237  (*it)->drawGL(s);
238  }
239  }
240  // (optional) draw name @todo expose this setting
242  }
243  glPopName();
244 }
245 
246 
247 void
249  const Position orig = myNBNode.getPosition();
250  setPosition(pos);
251  myNet->refreshElement(this);
252  const EdgeVector& incident = getNBNode()->getEdges();
253  for (EdgeVector::const_iterator it = incident.begin(); it != incident.end(); it++) {
254  GNEEdge* edge = myNet->retrieveEdge((*it)->getID());
255  edge->updateJunctionPosition(this, orig);
256  }
257 }
258 
259 
260 void
262  Position newPos = myNBNode.getPosition();
263  std::string newPosValue = getAttribute(SUMO_ATTR_POSITION);
264  // actually the geometry is already up to date
265  // set the restore point to the end of the last change-set
267  // do not execute the command to avoid changing the edge geometry twice
268  undoList->add(new GNEChange_Attribute(this, SUMO_ATTR_POSITION, newPosValue), false);
269  setPosition(newPos);
270 }
271 
272 
273 void
275  if (!myNBNode.hasCustomShape()) {
276  myNBNode.myPoly.clear();
278  }
279 }
280 
281 
282 void
283 GNEJunction::setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status) {
284  myHasValidLogic = valid;
285  if (!valid) {
286  assert(undoList != 0);
287  assert(undoList->hasCommandGroup());
288  undoList->add(new GNEChange_Attribute(this, GNE_ATTR_MODIFICATION_STATUS, status));
289  // allow edges to recompute their connections
292  for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
293  NBEdge* srcNBE = *it;
294  NBEdge* turnEdge = srcNBE->getTurnDestination();
295  GNEEdge* srcEdge = myNet->retrieveEdge(srcNBE->getID());
296  std::vector<NBEdge::Connection> connections = srcNBE->getConnections(); // make a copy!
297  // delete in reverse so that undoing will add connections in the original order
298  for (std::vector<NBEdge::Connection>::reverse_iterator con_it = connections.rbegin(); con_it != connections.rend(); con_it++) {
299  bool hasTurn = con_it->toEdge == turnEdge;
300  undoList->add(new GNEChange_Connection(
301  srcEdge, con_it->fromLane, con_it->toEdge->getID(),
302  con_it->toLane, con_it->mayDefinitelyPass, false), true);
303  // needs to come after GNEChange_Connection
304  // XXX bug: this code path will not be used on a redo!
305  if (hasTurn) {
306  myNet->addExplicitTurnaround(srcNBE->getID());
307  }
308  }
309  undoList->add(new GNEChange_Attribute(srcEdge, GNE_ATTR_MODIFICATION_STATUS, status), true);
310  }
311  invalidateTLS(undoList);
312  } else {
313  rebuildCrossings(false);
314  }
315 }
316 
317 
318 void
319 GNEJunction::invalidateTLS(GNEUndoList* undoList, const NBConnection& deletedConnection) {
320  assert(undoList->hasCommandGroup());
321  // NBLoadedSUMOTLDef becomes invalid, replace with NBOwnTLDef which will be dynamically recomputed
322  const std::set<NBTrafficLightDefinition*> tls = myNBNode.getControllingTLS(); // make a copy!
323  for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
324  NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(*it);
325  if (tlDef != 0) {
326  NBTrafficLightDefinition* replacementDef = 0;
327  std::string newID = tlDef->getID(); // + "_reguessed"; // changes due to reguessing will be visible in diff
328  if (deletedConnection != NBConnection::InvalidConnection) {
329  // create replacement before deleting the original because deletion will mess up saving original nodes
330  NBLoadedSUMOTLDef* repl = new NBLoadedSUMOTLDef(tlDef, tlDef->getLogic());
331  repl->removeConnection(deletedConnection);
332  replacementDef = repl;
333  } else {
334  replacementDef = new NBOwnTLDef(newID, tlDef->getOffset(), tlDef->getType());
335  }
336  undoList->add(new GNEChange_TLS(this, tlDef, false), true);
337  undoList->add(new GNEChange_TLS(this, replacementDef, true, false, newID), true);
338  // the removed traffic light may have controlled more than one junction. These too have become invalid now
339  const std::vector<NBNode*> coNodes = tlDef->getNodes(); // make a copy!
340  for (std::vector<NBNode*>::const_iterator it_node = coNodes.begin(); it_node != coNodes.end(); it_node++) {
341  GNEJunction* sharing = myNet->retrieveJunction((*it_node)->getID());
342  undoList->add(new GNEChange_TLS(sharing, tlDef, false), true);
343  undoList->add(new GNEChange_TLS(sharing, replacementDef, true, false, newID), true);
344  }
345  }
346  }
347 }
348 
349 void
351  // @todo implement GNEChange_Crossing
352  UNUSED_PARAMETER(undoList);
353  // make a copy because the original will be modified
354  const std::vector<NBNode::Crossing> crossings = myNBNode.getCrossings();
355  for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
356  EdgeSet edgeSet((*it).edges.begin(), (*it).edges.end());
357  if (edgeSet.count(edge->getNBEdge()) == 1) {
358  myNBNode.removeCrossing((*it).edges);
359  }
360  }
361 }
362 
363 
364 std::string
366  switch (key) {
367  case SUMO_ATTR_ID:
368  return getMicrosimID();
369  break;
370  case SUMO_ATTR_POSITION:
371  return toString(myNBNode.getPosition());
372  break;
373  case SUMO_ATTR_TYPE:
374  return toString(myNBNode.getType());
375  break;
377  return myLogicStatus;
378  break;
379  case SUMO_ATTR_SHAPE:
380  return toString(myNBNode.getShape());
381  case SUMO_ATTR_RADIUS:
382  return toString(myNBNode.getRadius());
384  return myNBNode.getKeepClear() ? "true" : "false";
385  default:
386  throw InvalidArgument("junction attribute '" + toString(key) + "' not allowed");
387  }
388 }
389 
390 
391 void
392 GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
393  if (value == getAttribute(key)) {
394  return; //avoid needless changes, later logic relies on the fact that attributes have changed
395  }
396  switch (key) {
397  case SUMO_ATTR_ID:
398  case SUMO_ATTR_POSITION:
400  case SUMO_ATTR_SHAPE:
401  case SUMO_ATTR_RADIUS:
403  undoList->add(new GNEChange_Attribute(this, key, value), true);
404  break;
405  case SUMO_ATTR_TYPE: {
406  undoList->p_begin("change junction type");
408  if (!getNBNode()->isTLControlled()) {
409  // create new traffic light
410  undoList->add(new GNEChange_TLS(this, 0, true), true);
411  }
412  } else if (getNBNode()->isTLControlled()) {
413  // delete old traffic light
414  // make a copy because we will modify the original
415  const std::set<NBTrafficLightDefinition*> tls = myNBNode.getControllingTLS();
416  for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
417  undoList->add(new GNEChange_TLS(this, *it, false), true);
418  }
419  }
420  // must be the final step, otherwise we do not know which traffic lights to remove via GNEChange_TLS
421  undoList->add(new GNEChange_Attribute(this, key, value), true);
422  undoList->p_end();
423  break;
424  }
425  default:
426  throw InvalidArgument("junction attribute '" + toString(key) + "' not allowed");
427  }
428 }
429 
430 
431 bool
432 GNEJunction::isValid(SumoXMLAttr key, const std::string& value) {
433  switch (key) {
434  case SUMO_ATTR_ID:
435  return isValidID(value) && myNet->retrieveJunction(value, false) == 0;
436  break;
437  case SUMO_ATTR_TYPE:
439  break;
440  case SUMO_ATTR_POSITION:
441  bool ok;
442  return GeomConvHelper::parseShapeReporting(value, "user-supplied position", 0, ok, false).size() == 1;
443  break;
444  case SUMO_ATTR_SHAPE: {
445  bool ok = true;
447  value, "user-supplied position", 0, ok, true);
448  return ok;
449  break;
450  }
451  case SUMO_ATTR_RADIUS:
452  return canParse<SUMOReal>(value);
453  break;
455  return value == "true" || value == "false";
456  break;
457  default:
458  throw InvalidArgument("junction attribute '" + toString(key) + "' not allowed");
459  }
460 }
461 
462 // ===========================================================================
463 // private
464 // ===========================================================================
465 
466 void
467 GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value) {
468  switch (key) {
469  case SUMO_ATTR_ID:
470  myNet->renameJunction(this, value);
471  break;
472  case SUMO_ATTR_TYPE: {
474  break;
475  }
476  case SUMO_ATTR_POSITION:
477  bool ok;
478  myOrigPos = GeomConvHelper::parseShapeReporting(value, "netedit-given", 0, ok, false)[0];
479  move(myOrigPos);
480  break;
482  myLogicStatus = value;
483  break;
484  case SUMO_ATTR_SHAPE: {
485  bool ok;
486  const PositionVector shape = GeomConvHelper::parseShapeReporting(value, "netedit-given", 0, ok, true);
487  myNBNode.setCustomShape(shape);
488  break;
489  }
490  case SUMO_ATTR_RADIUS:
491  myNBNode.setRadius(parse<SUMOReal>(value));
492  break;
494  myNBNode.setKeepClear(value == "true");
495  break;
496  default:
497  throw InvalidArgument("junction attribute '" + toString(key) + "' not allowed");
498  }
499 }
500 
501 
502 void
504  const Position& orig = myNBNode.getPosition();
505  myBoundary.moveby(pos.x() - orig.x(), pos.y() - orig.y());
507  /* //reshift also shifts the junction shape. this is not needed because shape is not yet computed
508  * const Position& orig = myNBNode.getPosition();
509  * myNBNode.reshiftPosition(pos.x() - orig.x(), pos.y() - orig.y());
510  */
511 }
512 
513 
514 SUMOReal
516  switch (s.junctionColorer.getActive()) {
517  case 0:
518  if (bubble) {
519  return 1;
520  } else {
521  return 0;
522  }
523  case 1:
524  return gSelected.isSelected(getType(), getGlID()) ? 1 : 0;
525  case 2:
526  switch (myNBNode.getType()) {
528  return 0;
530  return 1;
531  case NODETYPE_PRIORITY:
532  return 2;
534  return 3;
536  return 4;
538  return 5;
539  case NODETYPE_DISTRICT:
540  return 6;
541  case NODETYPE_NOJUNCTION:
542  return 7;
543  case NODETYPE_DEAD_END:
545  return 8;
546  case NODETYPE_UNKNOWN:
547  case NODETYPE_INTERNAL:
548  assert(false);
549  return 8;
551  return 9;
552  case NODETYPE_ZIPPER:
553  return 10;
555  return 11;
557  return 12;
558  }
559  default:
560  assert(false);
561  return 0;
562  }
563 }
564 
565 
566 void
567 GNEJunction::setColor(const GUIVisualizationSettings& s, bool bubble) const {
569  // override with special colors
570  if (gSelected.isSelected(getType(), getGlID())) {
572  }
573  if (myAmCreateEdgeSource) {
574  glColor3d(0, 1, 0);
575  }
576 }
577 
578 void
581  tlCont.insert(tlDef, forceInsert); // may return false for tlDef which controls multiple junctions
582  tlDef->addNode(&myNBNode);
583 }
584 
585 
586 void
589  tlCont.extract(tlDef);
591 }
592 
593 void
595  EdgeSet edgeSet(crossing.edges.begin(), crossing.edges.end());
596  for (std::vector<NBNode::Crossing>::iterator it = myNBNode.myCrossings.begin(); it != myNBNode.myCrossings.end(); ++it) {
597  EdgeSet edgeSet2((*it).edges.begin(), (*it).edges.end());
598  if (edgeSet == edgeSet2) {
599  (*it).width = crossing.width;
600  (*it).priority = crossing.priority;
601  myNet->refreshElement(this);
602  break;
603  }
604  }
605 }
606 
607 /****************************************************************************/
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:250
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:253
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:247
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:541
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.
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:592
bool hasString(const std::string &str) const
A loaded (complete) traffic light logic.
bool myAmCreateEdgeSource
Definition: GNEJunction.h:241
static GUIGlID add(FXImage *i)
Adds a texture to use.
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
Definition: GNEJunction.h:63
Stores the information about how to visualize structures.
static int TLSDecalGlID
gl-id of the tls-decal (drawn in tls-mode)
Definition: GNEJunction.h:262
The representation of a single edge during network building.
Definition: NBEdge.h:70
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.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:167
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
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition: GNENet.h:337
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:77
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)
Definition: GNEUndoList.cpp:75
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:844
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
static bool TLSDecalInitialized
whether the tls-decal has been initialized
Definition: GNEJunction.h:265
bool checkIsRemovable() const
Definition: NBNode.cpp:1564
bool myAmTLSSelected
whether this junction is selected in tls-mode
Definition: GNEJunction.h:256
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:1644
GNENet * myNet
Definition: GNEJunction.h:244
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.
Definition: GUIGlObject.h:123
#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:230
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:835
static void drawFilledPolyTesselated(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:95
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:65
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.
Definition: GUIGlObject.h:180
void removeCrossing(const EdgeVector &edges)
remove a pedestrian crossing from this node (identified by its edges)
Definition: NBNode.cpp:2454
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:55
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()
Definition: GNEUndoList.cpp:82
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:529
A list of positions.
SUMOReal getColorValue(const GUIVisualizationSettings &s, bool bubble) const
determines color value
const unsigned char tlslogo[]
Definition: tlslogo.cpp:23
friend class GNEChange_Attribute
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:233
const EdgeVector & getEdges() const
Returns all edges which participate in this node.
Definition: NBNode.h:256
const T getColor(const SUMOReal value) const
NBNode * getNBNode()
returns the internal NBNode
Definition: GNEJunction.h:153
NBTrafficLightLogic * getLogic()
Returns the internal logic.
GUIColorer junctionColorer
The junction colorer.
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
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:54
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:1638
NBNode & myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:227
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) ...
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.h:132
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:61
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
Definition: GNEUndoList.h:111
virtual ~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:92
Boundary myBoundary
The represented junction&#39;s boundary.
Definition: GNEJunction.h:236
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:203
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:76
GUIVisualizationSettings * getVisualisationSettings() const
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
#define SUMOReal
Definition: config.h:213
std::vector< GNECrossing * > myCrossings
the built crossing objects
Definition: GNEJunction.h:259
bool drawJunctionShape
whether the shape of the junction should be drawn
static const RGBColor selectionColor
Definition: GNENet.h:83
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
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
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:763
A window containing a gl-object&#39;s parameter.
NBEdge * getTurnDestination(bool possibleDestination=false) const
Definition: NBEdge.cpp:2157
static bool isTrafficLight(SumoXMLNodeType type)
return whether the given type is a traffic light
Definition: NBNode.cpp:2568
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.h:379
void updateBoundary()
Update the boundary of the junction.
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
FXApp * getApp()
Definition: GNENet.h:384
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
a junction