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-2015 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 // static member definitions
73 // ===========================================================================
74 
75 // ===========================================================================
76 // method definitions
77 // ===========================================================================
78 GNELane::GNELane(GNEEdge& edge, const unsigned int index) :
79  GUIGlObject(GLO_LANE, edge.getNBEdge()->getLaneID(index)),
81  myParentEdge(edge),
82  myIndex(index),
83  mySpecialColor(0),
84  myTLSEditor(0) {
85  updateGeometry();
86 }
87 
89  GUIGlObject(GLO_LANE, "dummyConstructorGNELane"),
91  myParentEdge(*static_cast<GNEEdge*>(0)),
92  myIndex(-1),
93  mySpecialColor(0),
94  myTLSEditor(0)
95 { }
96 
98 
99 
100 void
102 }
103 
104 
105 void
107 }
108 
109 
110 void
112 }
113 
114 
115 void
117  const Position& end = getShape().back();
118  const Position& f = getShape()[-2];
119  SUMOReal rot = (SUMOReal) atan2((end.x() - f.x()), (f.y() - end.y())) * (SUMOReal) 180.0 / (SUMOReal) PI;
120  glPushMatrix();
121  glPushName(0);
122  glTranslated(0, 0, GLO_JUNCTION + .1); // must draw on top of junction shape
123  glColor3d(1, 1, 1);
124  glTranslated(end.x(), end.y(), 0);
125  glRotated(rot, 0, 0, 1);
126 
127  // draw all links
128  const std::vector<NBEdge::Connection>& edgeCons = myParentEdge.getNBEdge()->myConnections;
129  NBNode* dest = myParentEdge.getNBEdge()->myTo;
130  for (std::vector<NBEdge::Connection>::const_iterator i = edgeCons.begin(); i != edgeCons.end(); ++i) {
131  if ((*i).fromLane == (int)myIndex) {
132  LinkDirection dir = dest->getDirection(myParentEdge.getNBEdge(), i->toEdge, OptionsCont::getOptions().getBool("lefthand"));
133  switch (dir) {
134  case LINKDIR_STRAIGHT:
135  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
137  break;
138  case LINKDIR_LEFT:
139  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
140  GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
141  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.5, 2.5), (SUMOReal) 1, (SUMOReal) .25);
142  break;
143  case LINKDIR_RIGHT:
144  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
145  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
146  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.5, 2.5), (SUMOReal) 1, (SUMOReal) .25);
147  break;
148  case LINKDIR_TURN:
149  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
150  GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .05);
151  GLHelper::drawBoxLine(Position(0.5, 2.5), 180, 1, .05);
152  GLHelper::drawTriangleAtEnd(Position(0.5, 2.5), Position(0.5, 4), (SUMOReal) 1, (SUMOReal) .25);
153  break;
155  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
156  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
157  GLHelper::drawBoxLine(Position(-0.5, 2.5), -180, 1, .05);
158  GLHelper::drawTriangleAtEnd(Position(-0.5, 2.5), Position(-0.5, 4), (SUMOReal) 1, (SUMOReal) .25);
159  break;
160  case LINKDIR_PARTLEFT:
161  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
162  GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
163  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.2, 1.3), (SUMOReal) 1, (SUMOReal) .25);
164  break;
165  case LINKDIR_PARTRIGHT:
166  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
167  GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
168  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.2, 1.3), (SUMOReal) 1, (SUMOReal) .25);
169  break;
170  case LINKDIR_NODIR:
171  GLHelper::drawBoxLine(Position(1, 5.8), 245, 2, .05);
172  GLHelper::drawBoxLine(Position(-1, 5.8), 115, 2, .05);
173  glTranslated(0, 5, 0);
174  GLHelper::drawOutlineCircle(0.9, 0.8, 32);
175  glTranslated(0, -5, 0);
176  break;
177  }
178  }
179  }
180  glPopName();
181  glPopMatrix();
182 }
183 
184 
185 void
187  glPushMatrix();
188  glPushName(0);
189  glTranslated(0, 0, GLO_JUNCTION + .1); // must draw on top of junction shape
190  std::vector<NBEdge::Connection> connections = myParentEdge.getNBEdge()->getConnectionsFromLane(myIndex);
191  NBNode* node = myParentEdge.getNBEdge()->getToNode();
192  const Position& startPos = getShape()[-1];
193  for (std::vector<NBEdge::Connection>::iterator it = connections.begin(); it != connections.end(); it++) {
194  const LinkState state = node->getLinkState(
195  myParentEdge.getNBEdge(), it->toEdge, it->fromLane, it->toLane, it->mayDefinitelyPass, it->tlID);
196  switch (state) {
198  glColor3d(1, 1, 0);
199  break;
201  glColor3d(0, 1, 1);
202  break;
203  case LINKSTATE_MAJOR:
204  glColor3d(1, 1, 1);
205  break;
206  case LINKSTATE_MINOR:
207  glColor3d(.4, .4, .4);
208  break;
209  case LINKSTATE_STOP:
210  glColor3d(.7, .4, .4);
211  break;
212  case LINKSTATE_EQUAL:
213  glColor3d(.7, .7, .7);
214  break;
216  glColor3d(.7, .7, 1);
217  case LINKSTATE_ZIPPER:
218  glColor3d(.75, .5, 0.25);
219  break;
220  default:
221  throw ProcessError("Unexpected LinkState '" + toString(state) + "'");
222  }
223  const Position& endPos = it->toEdge->getLaneShape(it->toLane)[0];
224  glBegin(GL_LINES);
225  glVertex2f(startPos.x(), startPos.y());
226  glVertex2f(endPos.x(), endPos.y());
227  glEnd();
228  GLHelper::drawTriangleAtEnd(startPos, endPos, (SUMOReal) 1.5, (SUMOReal) .2);
229  }
230  glPopName();
231  glPopMatrix();
232 }
233 
234 
235 void
237  glPushMatrix();
238  glPushName(getGlID());
239  glTranslated(0, 0, getType());
240  const bool selectedEdge = gSelected.isSelected(myParentEdge.getType(), myParentEdge.getGlID());
241  const bool selected = gSelected.isSelected(getType(), getGlID());
242  if (mySpecialColor != 0) {
244  } else if (selected) {
246  } else if (selectedEdge) {
248  } else {
249  const GUIColorer& c = s.laneColorer;
250  if (!setFunctionalColor(c.getActive()) && !setMultiColor(c)) {
252  }
253  };
254 
255  // draw lane
256  // check whether it is not too small
257  const SUMOReal selectionScale = selected || selectedEdge ? s.selectionScale : 1;
258  const SUMOReal exaggeration = selectionScale * s.laneWidthExaggeration; // * s.laneScaler.getScheme().getColor(getScaleValue(s.laneScaler.getActive()));
259  if (s.scale * exaggeration < 1.) {
260  if (myShapeColors.size() > 0) {
262  } else {
264  }
265  glPopMatrix();
266  } else {
267  if (drawAsRailway(s)) {
268  // draw as railway
269  const SUMOReal halfRailWidth = 0.725 * exaggeration;
270  if (myShapeColors.size() > 0) {
272  } else {
274  }
275  RGBColor current = GLHelper::getColor();
276  glColor3d(1, 1, 1);
277  glTranslated(0, 0, .1);
279  GLHelper::setColor(current);
280  drawCrossties(0.3 * exaggeration, 1 * exaggeration, 1 * exaggeration);
281  } else {
282  // the actual lane
283  // reduce lane width to make sure that a selected edge can still be seen
284  const SUMOReal halfWidth = selectionScale * (myParentEdge.getNBEdge()->getLaneWidth(myIndex) / 2 - (selectedEdge ? .3 : 0));
285  if (myShapeColors.size() > 0) {
287  } else {
289  }
290  }
291  glPopMatrix();
292  if (exaggeration == 1) {
293  drawMarkings(selectedEdge, exaggeration);
294  }
295 
296  // draw ROWs only if target junction has a valid logic)
297  if (myParentEdge.getDest()->isLogicValid() && s.scale > 3) {
298  drawArrows();
299  }
300 
301  }
302  glPopName();
303 }
304 
305 
306 void
307 GNELane::drawMarkings(const bool& selectedEdge, SUMOReal scale) const {
308  glPushMatrix();
309  glTranslated(0, 0, GLO_EDGE);
310 
311  const SUMOReal halfWidth = myParentEdge.getNBEdge()->getLaneWidth(myIndex) * 0.5;
312  // optionally draw inverse markings
314  SUMOReal mw = (halfWidth + SUMO_const_laneOffset + .01) * scale;
315  int e = (int) getShape().size() - 1;
316  for (int i = 0; i < e; ++i) {
317  glPushMatrix();
318  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
319  glRotated(myShapeRotations[i], 0, 0, 1);
320  for (SUMOReal t = 0; t < myShapeLengths[i]; t += 6) {
321  const SUMOReal length = MIN2((SUMOReal)3, myShapeLengths[i] - t);
322  glBegin(GL_QUADS);
323  glVertex2d(-mw, -t);
324  glVertex2d(-mw, -t - length);
325  glVertex2d(halfWidth * 0.5 * scale, -t - length);
326  glVertex2d(halfWidth * 0.5 * scale, -t);
327  glEnd();
328  }
329  glPopMatrix();
330  }
331  }
332 
333  // draw white boundings (and white markings) depending on selection
334  if (selectedEdge) {
335  glTranslated(0, 0, 0.2); // draw selection on top of regular markings
337  } else {
338  glColor3d(1, 1, 1);
339  }
340 
342  getShape(),
344  getShapeLengths(),
345  (halfWidth + SUMO_const_laneOffset) * scale);
346  glPopMatrix();
347 
348 }
349 
350 
353  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
354  buildPopupHeader(ret, app);
356  new FXMenuCommand(ret, "Copy edge name to clipboard", 0, ret, MID_COPY_EDGE_NAME);
359  buildPositionCopyEntry(ret, false);
360  const int editMode = parent.getVisualisationSettings()->editMode;
361  myTLSEditor = 0;
362  if (editMode != GNE_MODE_CONNECT && editMode != GNE_MODE_TLS && editMode != GNE_MODE_CREATE_EDGE) {
363  new FXMenuCommand(ret, "Split edge here", 0, &parent, MID_GNE_SPLIT_EDGE);
364  new FXMenuCommand(ret, "Split edges in both direction here", 0, &parent, MID_GNE_SPLIT_EDGE_BIDI);
365  new FXMenuCommand(ret, "Reverse edge", 0, &parent, MID_GNE_REVERSE_EDGE);
366  new FXMenuCommand(ret, "Add reverse direction", 0, &parent, MID_GNE_ADD_REVERSE_EDGE);
367  new FXMenuCommand(ret, "Set geometry endpoint here", 0, &parent, MID_GNE_SET_EDGE_ENDPOINT);
368  new FXMenuCommand(ret, "Restore geometry endpoint", 0, &parent, MID_GNE_RESET_EDGE_ENDPOINT);
370  new FXMenuCommand(ret, "Straighten selected Edges", 0, &parent, MID_GNE_STRAIGHTEN);
371  } else {
372  new FXMenuCommand(ret, "Straighten edge", 0, &parent, MID_GNE_STRAIGHTEN);
373  }
375  new FXMenuCommand(ret, "Duplicate selected lanes", 0, &parent, MID_GNE_DUPLICATE_LANE);
376  } else {
377  new FXMenuCommand(ret, "Duplicate lane", 0, &parent, MID_GNE_DUPLICATE_LANE);
378  }
379  } else if (editMode == GNE_MODE_TLS) {
380  myTLSEditor = static_cast<GNEViewNet&>(parent).getTLSEditor();
382  FXMenuCommand* mc = new FXMenuCommand(ret, "Select state for all links from this edge:", 0, 0, 0);
383  const std::vector<std::string> names = GNEInternalLane::LinkStateNames.getStrings();
384  for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
385  FXuint state = GNEInternalLane::LinkStateNames.get(*it);
386  FXMenuRadio* mc = new FXMenuRadio(ret, (*it).c_str(), this, FXDataTarget::ID_OPTION + state);
387  mc->setSelBackColor(MFXUtils::getFXColor(GNEInternalLane::colorForLinksState(state)));
389  }
390  }
391  } else {
392  FXMenuCommand* mc = new FXMenuCommand(ret, "Additional options available in 'Inspect Mode'", 0, 0, 0);
393  mc->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), 0);
394  }
395  // buildShowParamsPopupEntry(ret, false);
397  const SUMOReal height = getShape().positionAtOffset2D(getShape().nearest_offset_to_point2D(parent.getPositionInformation())).z();
398  new FXMenuCommand(ret, ("pos: " + toString(pos) + " height: " + toString(height)).c_str(), 0, 0, 0);
399  // new FXMenuSeparator(ret);
400  // buildPositionCopyEntry(ret, false);
401 
402  // let the GNEViewNet store the popup position
403  (dynamic_cast<GNEViewNet&>(parent)).markPopupPosition();
404  return ret;
405 }
406 
407 
412  new GUIParameterTableWindow(app, *this, 2);
413  // add items
414  ret->mkItem("length [m]", false, myParentEdge.getNBEdge()->getLength());
415  // close building
416  ret->closeBuilding();
417  return ret;
418 }
419 
420 
421 Boundary
424  b.grow(10);
425  return b;
426 }
427 
428 
429 const PositionVector&
432 }
433 
434 
435 const std::vector<SUMOReal>&
437  return myShapeRotations;
438 }
439 
440 
441 const std::vector<SUMOReal>&
443  return myShapeLengths;
444 }
445 
446 
447 Boundary
450 }
451 
452 
453 void
455  myShapeRotations.clear();
456  myShapeLengths.clear();
457  //SUMOReal length = myParentEdge.getLength(); // @todo see ticket #448
458  // may be different from length
459  int segments = (int) getShape().size() - 1;
460  if (segments >= 0) {
461  myShapeRotations.reserve(segments);
462  myShapeLengths.reserve(segments);
463  for (int i = 0; i < segments; ++i) {
464  const Position& f = getShape()[i];
465  const Position& s = getShape()[i + 1];
466  myShapeLengths.push_back(f.distanceTo2D(s));
467  myShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI);
468  }
469  }
470 }
471 
472 void
473 GNELane::setIndex(unsigned int index) {
474  myIndex = index;
476 }
477 
478 
479 std::string
481  const NBEdge* edge = myParentEdge.getNBEdge();
482  switch (key) {
483  case SUMO_ATTR_ID:
484  return getMicrosimID();
485  case SUMO_ATTR_SPEED:
486  return toString(edge->getLaneSpeed(myIndex));
487  case SUMO_ATTR_ALLOW:
488  // return all allowed classes (may differ from the written attributes)
490  case SUMO_ATTR_DISALLOW:
491  // return all disallowed classes (may differ from the written attributes)
492  return getVehicleClassNames(~(edge->getPermissions(myIndex)));
493  case SUMO_ATTR_WIDTH:
494  return toString(edge->getLaneStruct(myIndex).width);
495  case SUMO_ATTR_ENDOFFSET:
496  return toString(edge->getLaneStruct(myIndex).endOffset);
497  case SUMO_ATTR_INDEX:
498  return toString(myIndex);
499  default:
500  throw InvalidArgument("lane attribute '" + toString(key) + "' not allowed");
501  }
502 }
503 
504 
505 void
506 GNELane::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
507  switch (key) {
508  case SUMO_ATTR_ID:
509  throw InvalidArgument("modifying lane attribute '" + toString(key) + "' not allowed");
510  case SUMO_ATTR_SPEED:
511  case SUMO_ATTR_ALLOW:
512  case SUMO_ATTR_DISALLOW:
513  case SUMO_ATTR_WIDTH:
514  case SUMO_ATTR_ENDOFFSET:
515  case SUMO_ATTR_INDEX:
516  // no special handling
517  undoList->p_add(new GNEChange_Attribute(this, key, value));
518  break;
519  default:
520  throw InvalidArgument("lane attribute '" + toString(key) + "' not allowed");
521  }
522 }
523 
524 
525 bool
526 GNELane::isValid(SumoXMLAttr key, const std::string& value) {
527  switch (key) {
528  case SUMO_ATTR_ID:
529  return false;
530  case SUMO_ATTR_SPEED:
531  return canParse<SUMOReal>(value);
532  case SUMO_ATTR_ALLOW:
533  case SUMO_ATTR_DISALLOW:
534  return canParseVehicleClasses(value);
535  case SUMO_ATTR_WIDTH:
536  return isPositive<SUMOReal>(value) || parse<SUMOReal>(value) == NBEdge::UNSPECIFIED_WIDTH;
537  case SUMO_ATTR_ENDOFFSET:
538  return canParse<SUMOReal>(value);
539  case SUMO_ATTR_INDEX:
540  return value == toString(myIndex);
541  default:
542  throw InvalidArgument("lane attribute '" + toString(key) + "' not allowed");
543 
544  }
545 }
546 
547 // ===========================================================================
548 // private
549 // ===========================================================================
550 
551 void
552 GNELane::setAttribute(SumoXMLAttr key, const std::string& value) {
553  NBEdge* edge = myParentEdge.getNBEdge();
554  switch (key) {
555  case SUMO_ATTR_ID:
556  throw InvalidArgument("modifying lane attribute '" + toString(key) + "' not allowed");
557  case SUMO_ATTR_SPEED:
558  edge->setSpeed(myIndex, parse<SUMOReal>(value));
559  break;
560  case SUMO_ATTR_ALLOW:
562  break;
563  case SUMO_ATTR_DISALLOW:
564  edge->setPermissions(~parseVehicleClasses(value), myIndex); // negation yields allowed
565  break;
566  case SUMO_ATTR_WIDTH:
567  edge->setLaneWidth(myIndex, parse<SUMOReal>(value));
568  break;
569  case SUMO_ATTR_ENDOFFSET:
570  edge->setEndOffset(myIndex, parse<SUMOReal>(value));
571  break;
572  default:
573  throw InvalidArgument("lane attribute '" + toString(key) + "' not allowed");
574  }
575 }
576 
577 
578 bool
579 GNELane::setFunctionalColor(size_t activeScheme) const {
580  switch (activeScheme) {
581  case 6: {
582  SUMOReal hue = GeomHelper::naviDegree(getShape().beginEndAngle()); // [0-360]
584  return true;
585  }
586  default:
587  return false;
588  }
589 }
590 
591 
592 bool
594  const size_t activeScheme = c.getActive();
595  myShapeColors.clear();
596  switch (activeScheme) {
597  case 9: // color by height at segment start
598  for (PositionVector::const_iterator ii = getShape().begin(); ii != getShape().end() - 1; ++ii) {
599  myShapeColors.push_back(c.getScheme().getColor(ii->z()));
600  }
601  return true;
602  case 11: // color by inclination at segment start
603  for (int ii = 1; ii < (int)getShape().size(); ++ii) {
604  const SUMOReal inc = (getShape()[ii].z() - getShape()[ii - 1].z()) / MAX2(POSITION_EPS, getShape()[ii].distanceTo2D(getShape()[ii - 1]));
605  myShapeColors.push_back(c.getScheme().getColor(inc));
606  }
607  return true;
608  default:
609  return false;
610  }
611 }
612 
613 
614 SUMOReal
615 GNELane::getColorValue(size_t activeScheme) const {
616  const SVCPermissions myPermissions = myParentEdge.getNBEdge()->getPermissions(myIndex);
617  switch (activeScheme) {
618  case 0:
619  switch (myPermissions) {
620  case SVC_PEDESTRIAN:
621  return 1;
622  case SVC_BICYCLE:
623  return 2;
624  case 0:
625  return 3;
626  case SVC_SHIP:
627  return 4;
628  default:
629  break;
630  }
631  if ((myPermissions & SVC_PASSENGER) != 0 || isRailway(myPermissions)) {
632  return 0;
633  } else {
634  return 5;
635  }
636  case 1:
637  return gSelected.isSelected(getType(), getGlID()) ||
638  gSelected.isSelected(GLO_EDGE, dynamic_cast<GNEEdge*>(&myParentEdge)->getGlID());
639  case 2:
640  return (SUMOReal)myPermissions;
641  case 3:
643  case 4:
644  return myParentEdge.getNBEdge()->getNumLanes();
645  case 5: {
647  }
648  // case 6: by angle (functional)
649  case 7: {
650  return myParentEdge.getNBEdge()->getPriority();
651  }
652  case 8: {
653  // color by z of first shape point
654  return getShape()[0].z();
655  }
656  // case 9: by segment height
657  case 10: {
658  // color by incline
659  return (getShape()[-1].z() - getShape()[0].z()) / myParentEdge.getNBEdge()->getLength();
660  }
661  }
662  return 0;
663 }
664 
665 
666 bool
669 }
670 
671 
672 bool
674  return isWaterway(myParentEdge.getNBEdge()->getPermissions(myIndex)) && s.showRails; // reusing the showRails setting
675 }
676 
677 
678 void
679 GNELane::drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const {
680  glPushMatrix();
681  // draw on top of of the white area between the rails
682  glTranslated(0, 0, 0.1);
683  int e = (int) getShape().size() - 1;
684  for (int i = 0; i < e; ++i) {
685  glPushMatrix();
686  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.0);
687  glRotated(myShapeRotations[i], 0, 0, 1);
688  for (SUMOReal t = 0; t < myShapeLengths[i]; t += spacing) {
689  glBegin(GL_QUADS);
690  glVertex2d(-halfWidth, -t);
691  glVertex2d(-halfWidth, -t - length);
692  glVertex2d(halfWidth, -t - length);
693  glVertex2d(halfWidth, -t);
694  glEnd();
695  }
696  glPopMatrix();
697  }
698  glPopMatrix();
699 }
700 
701 
702 const std::string&
704  return myParentEdge.getMicrosimID();
705 }
706 
707 
708 long
709 GNELane::onDefault(FXObject* obj, FXSelector sel, void* data) {
710  if (myTLSEditor != 0) {
711  myTLSEditor->handleMultiChange(this, obj, sel, data);
712  }
713  return 1;
714 }
715 
716 
717 
718 /****************************************************************************/
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:673
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:532
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:703
const std::vector< SUMOReal > & getShapeRotations() const
Definition: GNELane.cpp:436
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
GUIVisualizationSettings * getVisualisationSettings()
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:352
NBNode * myTo
Definition: NBEdge.h:1264
void drawMarkings(const bool &selectedEdge, SUMOReal scale) const
Definition: GNELane.cpp:307
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:2263
void setSpeed(int lane, SUMOReal speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2318
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:154
T MAX2(T a, T b)
Definition: StdDefs.h:79
SUMOReal getLaneWidth() const
Returns the default width of lanes of this edge.
Definition: NBEdge.h:447
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:2334
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:593
GNELane()
FOX needs this.
Definition: GNELane.cpp:88
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:106
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:779
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:448
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
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:667
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:167
#define PI
Definition: polyfonts.c:61
SUMOReal selectionScale
the current selection scaling in NETEDIT (temporary)
void drawLane2LaneConnections() const
Definition: GNELane.cpp:186
void drawArrows() const
Definition: GNELane.cpp:116
int getPriority() const
Returns the priority of the edge.
Definition: NBEdge.h:353
std::string getLaneID(unsigned int lane) const
Definition: NBEdge.cpp:2135
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:506
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:579
A list of positions.
bool isLogicValid()
Definition: GNEJunction.h:210
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:73
The link is a (hard) right direction.
#define POSITION_EPS
Definition: config.h:188
LinkState getLinkState(const NBEdge *incoming, NBEdge *outgoing, int fromLane, int toLane, bool mayDefinitelyPass, const std::string &tlID) const
Definition: NBNode.cpp:1491
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:1427
std::vector< Connection > myConnections
List of connections to following edges.
Definition: NBEdge.h:1283
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
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:454
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:679
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:480
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:2362
void drawLinkRules() const
Definition: GNELane.cpp:111
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:430
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:709
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:442
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:422
GNEJunction * getDest() const
returns the destination-junction
Definition: GNEEdge.cpp:135
SUMOReal getLaneSpeed(unsigned int lane) const
Definition: NBEdge.cpp:1317
static const StringBijection< FXuint > LinkStateNames
long names for link states
unsigned int myIndex
The index of this lane.
Definition: GNELane.h:172
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:1065
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
void setEndOffset(int lane, SUMOReal offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2302
#define SUMOReal
Definition: config.h:214
static const RGBColor selectionColor
Definition: GNENet.h:83
void setIndex(unsigned int index)
Definition: GNELane.cpp:473
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:526
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
void drawLinkNo() const
Definition: GNELane.cpp:101
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:409
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:236
virtual ~GNELane()
Destructor.
Definition: GNELane.cpp:97
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:615
The link has no direction (is a dead end link)
a junction
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:449