SUMO - Simulation of Urban MObility
GNELane.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A class for visualizing Lane geometry (adapted from GNELaneWrapper)
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <string>
32 #include <iostream>
33 #include <utility>
39 #include <utils/common/ToString.h>
40 #include <utils/geom/GeomHelper.h>
47 #include <utils/gui/div/GLHelper.h>
50 
51 #include "GNELane.h"
52 #include "GNEEdge.h"
53 #include "GNEJunction.h"
54 #include "GNETLSEditor.h"
55 #include "GNEInternalLane.h"
56 #include "GNEUndoList.h"
57 #include "GNENet.h"
58 #include "GNEChange_Attribute.h"
59 #include "GNEViewNet.h"
60 
61 #ifdef CHECK_MEMORY_LEAKS
62 #include <foreign/nvwa/debug_new.h>
63 #endif // CHECK_MEMORY_LEAKS
64 
65 // ===========================================================================
66 // FOX callback mapping
67 // ===========================================================================
68 // Object implementation
69 FXIMPLEMENT(GNELane, FXDelegator, 0, 0)
70 
71 
72 // ===========================================================================
73 // method definitions
74 // ===========================================================================
75 GNELane::GNELane(GNEEdge& edge, const int index) :
76  GUIGlObject(GLO_LANE, edge.getNBEdge()->getLaneID(index)),
78  myParentEdge(edge),
79  myIndex(index),
80  mySpecialColor(0),
81  myTLSEditor(0) {
82  updateGeometry();
83 }
84 
86  GUIGlObject(GLO_LANE, "dummyConstructorGNELane"),
88  myParentEdge(*static_cast<GNEEdge*>(0)),
89  myIndex(-1),
90  mySpecialColor(0),
91  myTLSEditor(0) {
92 }
93 
95 
96 
97 void
99 }
100 
101 
102 void
104 }
105 
106 
107 void
109 }
110 
111 
112 void
114  const Position& end = getShape().back();
115  const Position& f = getShape()[-2];
116  SUMOReal rot = (SUMOReal) atan2((end.x() - f.x()), (f.y() - end.y())) * (SUMOReal) 180.0 / (SUMOReal) PI;
117  glPushMatrix();
118  glPushName(0);
119  glTranslated(0, 0, GLO_JUNCTION + .1); // must draw on top of junction shape
120  glColor3d(1, 1, 1);
121  glTranslated(end.x(), end.y(), 0);
122  glRotated(rot, 0, 0, 1);
123 
124  // draw all links
125  const std::vector<NBEdge::Connection>& edgeCons = myParentEdge.getNBEdge()->myConnections;
126  NBNode* dest = myParentEdge.getNBEdge()->myTo;
127  for (std::vector<NBEdge::Connection>::const_iterator i = edgeCons.begin(); i != edgeCons.end(); ++i) {
128  if ((*i).fromLane == myIndex) {
129  LinkDirection dir = dest->getDirection(myParentEdge.getNBEdge(), i->toEdge, OptionsCont::getOptions().getBool("lefthand"));
130  switch (dir) {
131  case LINKDIR_STRAIGHT:
132  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
134  break;
135  case LINKDIR_LEFT:
136  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
137  GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
138  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.5, 2.5), (SUMOReal) 1, (SUMOReal) .25);
139  break;
140  case LINKDIR_RIGHT:
141  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
142  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
143  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.5, 2.5), (SUMOReal) 1, (SUMOReal) .25);
144  break;
145  case LINKDIR_TURN:
146  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
147  GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .05);
148  GLHelper::drawBoxLine(Position(0.5, 2.5), 180, 1, .05);
149  GLHelper::drawTriangleAtEnd(Position(0.5, 2.5), Position(0.5, 4), (SUMOReal) 1, (SUMOReal) .25);
150  break;
152  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
153  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
154  GLHelper::drawBoxLine(Position(-0.5, 2.5), -180, 1, .05);
155  GLHelper::drawTriangleAtEnd(Position(-0.5, 2.5), Position(-0.5, 4), (SUMOReal) 1, (SUMOReal) .25);
156  break;
157  case LINKDIR_PARTLEFT:
158  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
159  GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
160  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.2, 1.3), (SUMOReal) 1, (SUMOReal) .25);
161  break;
162  case LINKDIR_PARTRIGHT:
163  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
164  GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
165  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.2, 1.3), (SUMOReal) 1, (SUMOReal) .25);
166  break;
167  case LINKDIR_NODIR:
168  GLHelper::drawBoxLine(Position(1, 5.8), 245, 2, .05);
169  GLHelper::drawBoxLine(Position(-1, 5.8), 115, 2, .05);
170  glTranslated(0, 5, 0);
171  GLHelper::drawOutlineCircle(0.9, 0.8, 32);
172  glTranslated(0, -5, 0);
173  break;
174  }
175  }
176  }
177  glPopName();
178  glPopMatrix();
179 }
180 
181 
182 void
184  glPushMatrix();
185  glPushName(0);
186  glTranslated(0, 0, GLO_JUNCTION + .1); // must draw on top of junction shape
187  std::vector<NBEdge::Connection> connections = myParentEdge.getNBEdge()->getConnectionsFromLane(myIndex);
188  NBNode* node = myParentEdge.getNBEdge()->getToNode();
189  const Position& startPos = getShape()[-1];
190  for (std::vector<NBEdge::Connection>::iterator it = connections.begin(); it != connections.end(); it++) {
191  const LinkState state = node->getLinkState(
192  myParentEdge.getNBEdge(), it->toEdge, it->fromLane, it->toLane, it->mayDefinitelyPass, it->tlID);
193  switch (state) {
195  glColor3d(1, 1, 0);
196  break;
198  glColor3d(0, 1, 1);
199  break;
200  case LINKSTATE_MAJOR:
201  glColor3d(1, 1, 1);
202  break;
203  case LINKSTATE_MINOR:
204  glColor3d(.4, .4, .4);
205  break;
206  case LINKSTATE_STOP:
207  glColor3d(.7, .4, .4);
208  break;
209  case LINKSTATE_EQUAL:
210  glColor3d(.7, .7, .7);
211  break;
213  glColor3d(.7, .7, 1);
214  case LINKSTATE_ZIPPER:
215  glColor3d(.75, .5, 0.25);
216  break;
217  default:
218  throw ProcessError("Unexpected LinkState '" + toString(state) + "'");
219  }
220  const Position& endPos = it->toEdge->getLaneShape(it->toLane)[0];
221  glBegin(GL_LINES);
222  glVertex2f(startPos.x(), startPos.y());
223  glVertex2f(endPos.x(), endPos.y());
224  glEnd();
225  GLHelper::drawTriangleAtEnd(startPos, endPos, (SUMOReal) 1.5, (SUMOReal) .2);
226  }
227  glPopName();
228  glPopMatrix();
229 }
230 
231 
232 void
234  glPushMatrix();
235  glPushName(getGlID());
236  glTranslated(0, 0, getType());
237  const bool selectedEdge = gSelected.isSelected(myParentEdge.getType(), myParentEdge.getGlID());
238  const bool selected = gSelected.isSelected(getType(), getGlID());
239  if (mySpecialColor != 0) {
241  } else if (selected) {
243  } else if (selectedEdge) {
245  } else {
246  const GUIColorer& c = s.laneColorer;
247  if (!setFunctionalColor(c.getActive()) && !setMultiColor(c)) {
249  }
250  };
251 
252  // draw lane
253  // check whether it is not too small
254  const SUMOReal selectionScale = selected || selectedEdge ? s.selectionScale : 1;
255  const SUMOReal exaggeration = selectionScale * s.laneWidthExaggeration; // * s.laneScaler.getScheme().getColor(getScaleValue(s.laneScaler.getActive()));
256  if (s.scale * exaggeration < 1.) {
257  if (myShapeColors.size() > 0) {
259  } else {
261  }
262  glPopMatrix();
263  } else {
264  if (drawAsRailway(s)) {
265  // draw as railway
266  const SUMOReal halfRailWidth = 0.725 * exaggeration;
267  if (myShapeColors.size() > 0) {
269  } else {
271  }
272  RGBColor current = GLHelper::getColor();
273  glColor3d(1, 1, 1);
274  glTranslated(0, 0, .1);
276  GLHelper::setColor(current);
277  drawCrossties(0.3 * exaggeration, 1 * exaggeration, 1 * exaggeration);
278  } else {
279  // the actual lane
280  // reduce lane width to make sure that a selected edge can still be seen
281  const SUMOReal halfWidth = selectionScale * (myParentEdge.getNBEdge()->getLaneWidth(myIndex) / 2 - (selectedEdge ? .3 : 0));
282  if (myShapeColors.size() > 0) {
284  } else {
286  }
287  }
288  glPopMatrix();
289  if (exaggeration == 1) {
290  drawMarkings(selectedEdge, exaggeration);
291  }
292 
293  // draw ROWs only if target junction has a valid logic)
294  if (myParentEdge.getDest()->isLogicValid() && s.scale > 3) {
295  drawArrows();
296  }
297 
298  }
299  glPopName();
300 }
301 
302 
303 void
304 GNELane::drawMarkings(const bool& selectedEdge, SUMOReal scale) const {
305  glPushMatrix();
306  glTranslated(0, 0, GLO_EDGE);
307 
308  const SUMOReal halfWidth = myParentEdge.getNBEdge()->getLaneWidth(myIndex) * 0.5;
309  // optionally draw inverse markings
311  SUMOReal mw = (halfWidth + SUMO_const_laneOffset + .01) * scale;
312  int e = (int) getShape().size() - 1;
313  for (int i = 0; i < e; ++i) {
314  glPushMatrix();
315  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
316  glRotated(myShapeRotations[i], 0, 0, 1);
317  for (SUMOReal t = 0; t < myShapeLengths[i]; t += 6) {
318  const SUMOReal length = MIN2((SUMOReal)3, myShapeLengths[i] - t);
319  glBegin(GL_QUADS);
320  glVertex2d(-mw, -t);
321  glVertex2d(-mw, -t - length);
322  glVertex2d(halfWidth * 0.5 * scale, -t - length);
323  glVertex2d(halfWidth * 0.5 * scale, -t);
324  glEnd();
325  }
326  glPopMatrix();
327  }
328  }
329 
330  // draw white boundings (and white markings) depending on selection
331  if (selectedEdge) {
332  glTranslated(0, 0, 0.2); // draw selection on top of regular markings
334  } else {
335  glColor3d(1, 1, 1);
336  }
337 
339  getShape(),
341  getShapeLengths(),
342  (halfWidth + SUMO_const_laneOffset) * scale);
343  glPopMatrix();
344 
345 }
346 
347 
350  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
351  buildPopupHeader(ret, app);
353  new FXMenuCommand(ret, "Copy edge name to clipboard", 0, ret, MID_COPY_EDGE_NAME);
356  buildPositionCopyEntry(ret, false);
357  const int editMode = parent.getVisualisationSettings()->editMode;
358  myTLSEditor = 0;
359  if (editMode != GNE_MODE_CONNECT && editMode != GNE_MODE_TLS && editMode != GNE_MODE_CREATE_EDGE) {
360  new FXMenuCommand(ret, "Split edge here", 0, &parent, MID_GNE_SPLIT_EDGE);
361  new FXMenuCommand(ret, "Split edges in both direction here", 0, &parent, MID_GNE_SPLIT_EDGE_BIDI);
362  new FXMenuCommand(ret, "Reverse edge", 0, &parent, MID_GNE_REVERSE_EDGE);
363  new FXMenuCommand(ret, "Add reverse direction", 0, &parent, MID_GNE_ADD_REVERSE_EDGE);
364  new FXMenuCommand(ret, "Set geometry endpoint here", 0, &parent, MID_GNE_SET_EDGE_ENDPOINT);
365  new FXMenuCommand(ret, "Restore geometry endpoint", 0, &parent, MID_GNE_RESET_EDGE_ENDPOINT);
367  new FXMenuCommand(ret, "Straighten selected Edges", 0, &parent, MID_GNE_STRAIGHTEN);
368  } else {
369  new FXMenuCommand(ret, "Straighten edge", 0, &parent, MID_GNE_STRAIGHTEN);
370  }
372  new FXMenuCommand(ret, "Duplicate selected lanes", 0, &parent, MID_GNE_DUPLICATE_LANE);
373  } else {
374  new FXMenuCommand(ret, "Duplicate lane", 0, &parent, MID_GNE_DUPLICATE_LANE);
375  }
376  } else if (editMode == GNE_MODE_TLS) {
377  myTLSEditor = static_cast<GNEViewNet&>(parent).getTLSEditor();
379  new FXMenuCommand(ret, "Select state for all links from this edge:", 0, 0, 0);
380  const std::vector<std::string> names = GNEInternalLane::LinkStateNames.getStrings();
381  for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
382  FXuint state = GNEInternalLane::LinkStateNames.get(*it);
383  FXMenuRadio* mc = new FXMenuRadio(ret, (*it).c_str(), this, FXDataTarget::ID_OPTION + state);
384  mc->setSelBackColor(MFXUtils::getFXColor(GNEInternalLane::colorForLinksState(state)));
386  }
387  }
388  } else {
389  FXMenuCommand* mc = new FXMenuCommand(ret, "Additional options available in 'Inspect Mode'", 0, 0, 0);
390  mc->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), 0);
391  }
392  // buildShowParamsPopupEntry(ret, false);
394  const SUMOReal height = getShape().positionAtOffset2D(getShape().nearest_offset_to_point2D(parent.getPositionInformation())).z();
395  new FXMenuCommand(ret, ("pos: " + toString(pos) + " height: " + toString(height)).c_str(), 0, 0, 0);
396  // new FXMenuSeparator(ret);
397  // buildPositionCopyEntry(ret, false);
398 
399  // let the GNEViewNet store the popup position
400  (dynamic_cast<GNEViewNet&>(parent)).markPopupPosition();
401  return ret;
402 }
403 
404 
409  new GUIParameterTableWindow(app, *this, 2);
410  // add items
411  ret->mkItem("length [m]", false, myParentEdge.getNBEdge()->getLength());
412  // close building
413  ret->closeBuilding();
414  return ret;
415 }
416 
417 
418 Boundary
421  b.grow(10);
422  return b;
423 }
424 
425 
426 const PositionVector&
429 }
430 
431 
432 const std::vector<SUMOReal>&
434  return myShapeRotations;
435 }
436 
437 
438 const std::vector<SUMOReal>&
440  return myShapeLengths;
441 }
442 
443 
444 Boundary
447 }
448 
449 
450 void
452  myShapeRotations.clear();
453  myShapeLengths.clear();
454  //SUMOReal length = myParentEdge.getLength(); // @todo see ticket #448
455  // may be different from length
456  int segments = (int) getShape().size() - 1;
457  if (segments >= 0) {
458  myShapeRotations.reserve(segments);
459  myShapeLengths.reserve(segments);
460  for (int i = 0; i < segments; ++i) {
461  const Position& f = getShape()[i];
462  const Position& s = getShape()[i + 1];
463  myShapeLengths.push_back(f.distanceTo2D(s));
464  myShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI);
465  }
466  }
467 }
468 
469 void
470 GNELane::setIndex(unsigned int index) {
471  myIndex = index;
473 }
474 
475 
476 std::string
478  const NBEdge* edge = myParentEdge.getNBEdge();
479  switch (key) {
480  case SUMO_ATTR_ID:
481  return getMicrosimID();
482  case SUMO_ATTR_SPEED:
483  return toString(edge->getLaneSpeed(myIndex));
484  case SUMO_ATTR_ALLOW:
485  // return all allowed classes (may differ from the written attributes)
487  case SUMO_ATTR_DISALLOW:
488  // return all disallowed classes (may differ from the written attributes)
489  return getVehicleClassNames(~(edge->getPermissions(myIndex)));
490  case SUMO_ATTR_WIDTH:
491  return toString(edge->getLaneStruct(myIndex).width);
492  case SUMO_ATTR_ENDOFFSET:
493  return toString(edge->getLaneStruct(myIndex).endOffset);
494  case SUMO_ATTR_INDEX:
495  return toString(myIndex);
496  default:
497  throw InvalidArgument("lane attribute '" + toString(key) + "' not allowed");
498  }
499 }
500 
501 
502 void
503 GNELane::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
504  switch (key) {
505  case SUMO_ATTR_ID:
506  throw InvalidArgument("modifying lane attribute '" + toString(key) + "' not allowed");
507  case SUMO_ATTR_SPEED:
508  case SUMO_ATTR_ALLOW:
509  case SUMO_ATTR_DISALLOW:
510  case SUMO_ATTR_WIDTH:
511  case SUMO_ATTR_ENDOFFSET:
512  case SUMO_ATTR_INDEX:
513  // no special handling
514  undoList->p_add(new GNEChange_Attribute(this, key, value));
515  break;
516  default:
517  throw InvalidArgument("lane attribute '" + toString(key) + "' not allowed");
518  }
519 }
520 
521 
522 bool
523 GNELane::isValid(SumoXMLAttr key, const std::string& value) {
524  switch (key) {
525  case SUMO_ATTR_ID:
526  return false;
527  case SUMO_ATTR_SPEED:
528  return canParse<SUMOReal>(value);
529  case SUMO_ATTR_ALLOW:
530  case SUMO_ATTR_DISALLOW:
531  return canParseVehicleClasses(value);
532  case SUMO_ATTR_WIDTH:
533  return isPositive<SUMOReal>(value) || parse<SUMOReal>(value) == NBEdge::UNSPECIFIED_WIDTH;
534  case SUMO_ATTR_ENDOFFSET:
535  return canParse<SUMOReal>(value);
536  case SUMO_ATTR_INDEX:
537  return value == toString(myIndex);
538  default:
539  throw InvalidArgument("lane attribute '" + toString(key) + "' not allowed");
540 
541  }
542 }
543 
544 // ===========================================================================
545 // private
546 // ===========================================================================
547 
548 void
549 GNELane::setAttribute(SumoXMLAttr key, const std::string& value) {
550  NBEdge* edge = myParentEdge.getNBEdge();
551  switch (key) {
552  case SUMO_ATTR_ID:
553  throw InvalidArgument("modifying lane attribute '" + toString(key) + "' not allowed");
554  case SUMO_ATTR_SPEED:
555  edge->setSpeed(myIndex, parse<SUMOReal>(value));
556  break;
557  case SUMO_ATTR_ALLOW:
559  break;
560  case SUMO_ATTR_DISALLOW:
561  edge->setPermissions(~parseVehicleClasses(value), myIndex); // negation yields allowed
562  break;
563  case SUMO_ATTR_WIDTH:
564  edge->setLaneWidth(myIndex, parse<SUMOReal>(value));
565  break;
566  case SUMO_ATTR_ENDOFFSET:
567  edge->setEndOffset(myIndex, parse<SUMOReal>(value));
568  break;
569  default:
570  throw InvalidArgument("lane attribute '" + toString(key) + "' not allowed");
571  }
572 }
573 
574 
575 bool
576 GNELane::setFunctionalColor(size_t activeScheme) const {
577  switch (activeScheme) {
578  case 6: {
579  SUMOReal hue = GeomHelper::naviDegree(getShape().beginEndAngle()); // [0-360]
581  return true;
582  }
583  default:
584  return false;
585  }
586 }
587 
588 
589 bool
591  const size_t activeScheme = c.getActive();
592  myShapeColors.clear();
593  switch (activeScheme) {
594  case 9: // color by height at segment start
595  for (PositionVector::const_iterator ii = getShape().begin(); ii != getShape().end() - 1; ++ii) {
596  myShapeColors.push_back(c.getScheme().getColor(ii->z()));
597  }
598  return true;
599  case 11: // color by inclination at segment start
600  for (int ii = 1; ii < (int)getShape().size(); ++ii) {
601  const SUMOReal inc = (getShape()[ii].z() - getShape()[ii - 1].z()) / MAX2(POSITION_EPS, getShape()[ii].distanceTo2D(getShape()[ii - 1]));
602  myShapeColors.push_back(c.getScheme().getColor(inc));
603  }
604  return true;
605  default:
606  return false;
607  }
608 }
609 
610 
611 SUMOReal
612 GNELane::getColorValue(size_t activeScheme) const {
613  const SVCPermissions myPermissions = myParentEdge.getNBEdge()->getPermissions(myIndex);
614  switch (activeScheme) {
615  case 0:
616  switch (myPermissions) {
617  case SVC_PEDESTRIAN:
618  return 1;
619  case SVC_BICYCLE:
620  return 2;
621  case 0:
622  return 3;
623  case SVC_SHIP:
624  return 4;
625  default:
626  break;
627  }
628  if ((myPermissions & SVC_PASSENGER) != 0 || isRailway(myPermissions)) {
629  return 0;
630  } else {
631  return 5;
632  }
633  case 1:
634  return gSelected.isSelected(getType(), getGlID()) ||
635  gSelected.isSelected(GLO_EDGE, dynamic_cast<GNEEdge*>(&myParentEdge)->getGlID());
636  case 2:
637  return (SUMOReal)myPermissions;
638  case 3:
640  case 4:
641  return myParentEdge.getNBEdge()->getNumLanes();
642  case 5: {
644  }
645  // case 6: by angle (functional)
646  case 7: {
647  return myParentEdge.getNBEdge()->getPriority();
648  }
649  case 8: {
650  // color by z of first shape point
651  return getShape()[0].z();
652  }
653  // case 9: by segment height
654  case 10: {
655  // color by incline
656  return (getShape()[-1].z() - getShape()[0].z()) / myParentEdge.getNBEdge()->getLength();
657  }
658  }
659  return 0;
660 }
661 
662 
663 bool
666 }
667 
668 
669 bool
671  return isWaterway(myParentEdge.getNBEdge()->getPermissions(myIndex)) && s.showRails; // reusing the showRails setting
672 }
673 
674 
675 void
676 GNELane::drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const {
677  glPushMatrix();
678  // draw on top of of the white area between the rails
679  glTranslated(0, 0, 0.1);
680  int e = (int) getShape().size() - 1;
681  for (int i = 0; i < e; ++i) {
682  glPushMatrix();
683  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.0);
684  glRotated(myShapeRotations[i], 0, 0, 1);
685  for (SUMOReal t = 0; t < myShapeLengths[i]; t += spacing) {
686  glBegin(GL_QUADS);
687  glVertex2d(-halfWidth, -t);
688  glVertex2d(-halfWidth, -t - length);
689  glVertex2d(halfWidth, -t - length);
690  glVertex2d(halfWidth, -t);
691  glEnd();
692  }
693  glPopMatrix();
694  }
695  glPopMatrix();
696 }
697 
698 
699 const std::string&
701  return myParentEdge.getMicrosimID();
702 }
703 
704 
705 long
706 GNELane::onDefault(FXObject* obj, FXSelector sel, void* data) {
707  if (myTLSEditor != 0) {
708  myTLSEditor->handleMultiChange(this, obj, sel, data);
709  }
710  return 1;
711 }
712 
713 
714 
715 /****************************************************************************/
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:670
The link is a partial left direction.
bool controlsEdge(GNEEdge &edge) const
whether the given edge is controlled by the currently edited tlDef
const PositionVector & getLaneShape(unsigned int i) const
Returns the shape of the nth lane.
Definition: NBEdge.cpp:541
SUMOReal endOffset
This lane&#39;s offset to the intersection begin.
Definition: NBEdge.h:136
const std::string & getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:700
const std::vector< SUMOReal > & getShapeRotations() const
Definition: GNELane.cpp:433
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:201
float laneWidthExaggeration
The lane exaggeration (upscale thickness)
PositionVector shape
The lane&#39;s shape.
Definition: NBEdge.h:128
is a pedestrian
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
static RGBColor fromHSV(SUMOReal h, SUMOReal s, SUMOReal v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:294
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:349
NBNode * myTo
Definition: NBEdge.h:1266
void drawMarkings(const bool &selectedEdge, SUMOReal scale) const
Definition: GNELane.cpp:304
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:184
static const RGBColor selectedLaneColor
Definition: GNENet.h:84
Copy edge name (for lanes only)
Definition: GUIAppEnum.h:223
void setLaneWidth(int lane, SUMOReal width)
set lane specific width (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2294
void setSpeed(int lane, SUMOReal speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2349
GUIColorer laneColorer
The lane colorer.
void handleMultiChange(GNELane *lane, FXObject *obj, FXSelector sel, void *data)
update phase definition for the current traffic light and phase
Stores the information about how to visualize structures.
This is an uncontrolled, minor link, has to stop.
vehicle is a bicycle
int SVCPermissions
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
Definition: NBEdge.h:70
static void drawOutlineCircle(SUMOReal width, SUMOReal iwidth, int steps=8)
Draws an unfilled circle around (0,0)
Definition: GLHelper.cpp:375
bool showRails
Information whether rails shall be drawn.
The link is a 180 degree turn.
static RGBColor colorForLinksState(FXuint state)
static void drawBoxLines(const PositionVector &geom, const std::vector< SUMOReal > &rots, const std::vector< SUMOReal > &lengths, SUMOReal width, int cornerDetail=0, SUMOReal offset=0)
Draws thick lines.
Definition: GLHelper.cpp:176
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
T MAX2(T a, T b)
Definition: StdDefs.h:75
SUMOReal getLaneWidth() const
Returns the default width of lanes of this edge.
Definition: NBEdge.h:449
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.
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
Definition: NBEdge.cpp:2365
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:56
int editMode
the current NETEDIT mode (temporary)
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and some lane function ...
Definition: GNELane.cpp:590
GNELane()
FOX needs this.
Definition: GNELane.cpp:85
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:226
This is an uncontrolled, right-before-left link.
void drawTLSLinkNo() const
Definition: GNELane.cpp:103
const SUMOReal SUMO_const_laneOffset
Definition: StdDefs.h:52
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
The link is controlled by a tls which is off, not blinking, may pass.
std::vector< Connection > getConnectionsFromLane(unsigned int lane) const
Returns connections from a given lane.
Definition: NBEdge.cpp:785
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
This is an uncontrolled, all-way stop link.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used, also builds an entry for copying the geo-position.
Boundary getBoundary() const
returns the boundry (including lanes)
Definition: GNELane.cpp:445
Position positionAtOffset2D(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:123
static void drawTriangleAtEnd(const Position &p1, const Position &p2, SUMOReal tLength, SUMOReal tWidth)
Draws a triangle at the end of the given line.
Definition: GLHelper.cpp:422
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
int myIndex
The index of this lane.
Definition: GNELane.h:172
This is an uncontrolled, zipper-merge link.
The link is a (hard) left direction.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
SUMOReal scale
information about a lane&#39;s width (temporary, used for a single view)
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
std::vector< std::string > getStrings() const
The link is a straight direction.
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:664
SUMOReal getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn&#39;t set.
Definition: NBEdge.h:413
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:180
#define PI
Definition: polyfonts.c:61
SUMOReal selectionScale
the current selection scaling in NETEDIT (temporary)
void drawLane2LaneConnections() const
Definition: GNELane.cpp:183
void drawArrows() const
Definition: GNELane.cpp:113
int getPriority() const
Returns the priority of the edge.
Definition: NBEdge.h:353
std::string getLaneID(unsigned int lane) const
Definition: NBEdge.cpp:2166
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:443
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:503
This is an uncontrolled, minor link, has to brake.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
bool setFunctionalColor(size_t activeScheme) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:576
A list of positions.
bool isLogicValid()
Definition: GNEJunction.h:214
std::vector< SUMOReal > myShapeRotations
The rotations of the shape parts.
Definition: GNELane.h:177
bool isWaterway(SVCPermissions permissions)
Returns whether an edge with the given permission is a waterway edge.
friend class GNEChange_Attribute
unsigned int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:345
SUMOReal z() const
Returns the z-position.
Definition: Position.h:73
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
const T getColor(const SUMOReal value) const
T MIN2(T a, T b)
Definition: StdDefs.h:69
The link is a (hard) right direction.
#define POSITION_EPS
Definition: config.h:187
LinkState getLinkState(const NBEdge *incoming, NBEdge *outgoing, int fromLane, int toLane, bool mayDefinitelyPass, const std::string &tlID) const
Definition: NBNode.cpp:1535
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
LinkDirection getDirection(const NBEdge *const incoming, const NBEdge *const outgoing, bool leftHand=false) const
Returns the representation of the described stream&#39;s direction.
Definition: NBNode.cpp:1471
std::vector< Connection > myConnections
List of connections to following edges.
Definition: NBEdge.h:1285
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:54
The link is a partial right direction.
std::string getVehicleClassNames(SVCPermissions permissions)
Returns the ids of the given classes, divided using a &#39; &#39;.
vehicle is a passenger car (a "normal" car)
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:451
static SUMOReal naviDegree(const SUMOReal angle)
Definition: GeomHelper.cpp:191
is an arbitrary ship
void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const
Definition: GNELane.cpp:676
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.h:132
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:477
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:61
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition: NBEdge.cpp:2393
void drawLinkRules() const
Definition: GNELane.cpp:108
GNEEdge & myParentEdge
The Edge that to which this lane belongs.
Definition: GNELane.h:169
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:201
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:369
const PositionVector & getShape() const
Definition: GNELane.cpp:427
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:706
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object (happens in NETEDIT)
The link is controlled by a tls which is off and blinks, has to brake.
std::vector< SUMOReal > myShapeLengths
The lengths of the shape parts.
Definition: GNELane.h:180
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
The popup menu of a globject.
an edge
const std::vector< SUMOReal > & getShapeLengths() const
Definition: GNELane.cpp:439
This is an uncontrolled, major link, may pass.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNELane.cpp:419
GNEJunction * getDest() const
returns the destination-junction
Definition: GNEEdge.cpp:135
SUMOReal getLaneSpeed(unsigned int lane) const
Definition: NBEdge.cpp:1323
static const StringBijection< FXuint > LinkStateNames
long names for link states
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:125
Represents a single node (junction) during network building.
Definition: NBNode.h:74
T get(const std::string &str) const
Lane & getLaneStruct(unsigned int lane)
Definition: NBEdge.h:1067
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:232
The link is a 180 degree turn (left-hand network)
static void drawLine(const Position &beg, SUMOReal rot, SUMOReal visLength)
Draws a thin line.
Definition: GLHelper.cpp:269
GUIVisualizationSettings * getVisualisationSettings() const
void setEndOffset(int lane, SUMOReal offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2333
#define SUMOReal
Definition: config.h:213
static const RGBColor selectionColor
Definition: GNENet.h:83
void setIndex(unsigned int index)
Definition: GNELane.cpp:470
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:523
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
void drawLinkNo() const
Definition: GNELane.cpp:98
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
void mkItem(const char *name, bool dynamic, ValueSource< unsigned > *src)
Adds a row which obtains its value from an unsigned-ValueSource.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GNELane.cpp:406
GUISelectedStorage gSelected
A global holder of selected objects.
void closeBuilding()
Closes the building of the table.
A window containing a gl-object&#39;s parameter.
GNETLSEditor * myTLSEditor
the tls-editor for setting multiple links in TLS-mode
Definition: GNELane.h:229
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:233
virtual ~GNELane()
Destructor.
Definition: GNELane.cpp:94
SUMOReal width
This lane&#39;s width.
Definition: NBEdge.h:138
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
SUMOReal getLength() const
Returns the computed length of the edge.
Definition: NBEdge.h:404
SUMOReal getColorValue(size_t activeScheme) const
Definition: GNELane.cpp:612
The link has no direction (is a dead end link)
a junction
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:449