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 "GNETLSEditorFrame.h"
55 #include "GNEInternalLane.h"
56 #include "GNEUndoList.h"
57 #include "GNENet.h"
58 #include "GNEChange_Attribute.h"
59 #include "GNEViewNet.h"
60 #include "GNEViewParent.h"
61 
62 #ifdef CHECK_MEMORY_LEAKS
63 #include <foreign/nvwa/debug_new.h>
64 #endif // CHECK_MEMORY_LEAKS
65 
66 // ===========================================================================
67 // FOX callback mapping
68 // ===========================================================================
69 
70 // Object implementation
71 FXIMPLEMENT(GNELane, FXDelegator, 0, 0)
72 
73 // ===========================================================================
74 // method definitions
75 // ===========================================================================
76 
77 GNELane::GNELane(GNEEdge& edge, const int index) :
78  GNENetElement(edge.getNet(), edge.getNBEdge()->getLaneID(index), GLO_LANE, SUMO_TAG_LANE),
79  myParentEdge(edge),
80  myIndex(index),
81  mySpecialColor(0),
82  myTLSEditor(0) {
83  updateGeometry();
84 }
85 
87  GNENetElement(NULL, "dummyConstructorGNELane", GLO_LANE, SUMO_TAG_LANE),
88  myParentEdge(*static_cast<GNEEdge*>(0)),
89  myIndex(-1),
90  mySpecialColor(0),
91  myTLSEditor(0) {
92 }
93 
94 
96  // Remove all references to this lane in their additionals
97  for (AdditionalVector::iterator i = myAdditionals.begin(); i != myAdditionals.end(); i++) {
98  (*i)->removeLaneReference();
99  }
100 }
101 
102 
103 void
105 }
106 
107 
108 void
110 }
111 
112 
113 void
115 }
116 
117 
118 void
120  const Position& end = getShape().back();
121  const Position& f = getShape()[-2];
122  SUMOReal rot = (SUMOReal) atan2((end.x() - f.x()), (f.y() - end.y())) * (SUMOReal) 180.0 / (SUMOReal) PI;
123  glPushMatrix();
124  glPushName(0);
125  glTranslated(0, 0, GLO_JUNCTION + .1); // must draw on top of junction shape
126  glColor3d(1, 1, 1);
127  glTranslated(end.x(), end.y(), 0);
128  glRotated(rot, 0, 0, 1);
129 
130  // draw all links
131  const std::vector<NBEdge::Connection>& edgeCons = myParentEdge.getNBEdge()->myConnections;
132  NBNode* dest = myParentEdge.getNBEdge()->myTo;
133  for (std::vector<NBEdge::Connection>::const_iterator i = edgeCons.begin(); i != edgeCons.end(); ++i) {
134  if ((*i).fromLane == myIndex) {
135  LinkDirection dir = dest->getDirection(myParentEdge.getNBEdge(), i->toEdge, OptionsCont::getOptions().getBool("lefthand"));
136  switch (dir) {
137  case LINKDIR_STRAIGHT:
138  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
140  break;
141  case LINKDIR_LEFT:
142  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
143  GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
144  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.5, 2.5), (SUMOReal) 1, (SUMOReal) .25);
145  break;
146  case LINKDIR_RIGHT:
147  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
148  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
149  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.5, 2.5), (SUMOReal) 1, (SUMOReal) .25);
150  break;
151  case LINKDIR_TURN:
152  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
153  GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .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;
158  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
159  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
160  GLHelper::drawBoxLine(Position(-0.5, 2.5), -180, 1, .05);
161  GLHelper::drawTriangleAtEnd(Position(-0.5, 2.5), Position(-0.5, 4), (SUMOReal) 1, (SUMOReal) .25);
162  break;
163  case LINKDIR_PARTLEFT:
164  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
165  GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
166  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.2, 1.3), (SUMOReal) 1, (SUMOReal) .25);
167  break;
168  case LINKDIR_PARTRIGHT:
169  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
170  GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
171  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.2, 1.3), (SUMOReal) 1, (SUMOReal) .25);
172  break;
173  case LINKDIR_NODIR:
174  GLHelper::drawBoxLine(Position(1, 5.8), 245, 2, .05);
175  GLHelper::drawBoxLine(Position(-1, 5.8), 115, 2, .05);
176  glTranslated(0, 5, 0);
177  GLHelper::drawOutlineCircle(0.9, 0.8, 32);
178  glTranslated(0, -5, 0);
179  break;
180  }
181  }
182  }
183  glPopName();
184  glPopMatrix();
185 }
186 
187 
188 void
190  glPushMatrix();
191  glPushName(0);
192  glTranslated(0, 0, GLO_JUNCTION + .1); // must draw on top of junction shape
193  std::vector<NBEdge::Connection> connections = myParentEdge.getNBEdge()->getConnectionsFromLane(myIndex);
194  NBNode* node = myParentEdge.getNBEdge()->getToNode();
195  const Position& startPos = getShape()[-1];
196  for (std::vector<NBEdge::Connection>::iterator it = connections.begin(); it != connections.end(); it++) {
197  const LinkState state = node->getLinkState(
198  myParentEdge.getNBEdge(), it->toEdge, it->fromLane, it->toLane, it->mayDefinitelyPass, it->tlID);
199  switch (state) {
201  glColor3d(1, 1, 0);
202  break;
204  glColor3d(0, 1, 1);
205  break;
206  case LINKSTATE_MAJOR:
207  glColor3d(1, 1, 1);
208  break;
209  case LINKSTATE_MINOR:
210  glColor3d(.4, .4, .4);
211  break;
212  case LINKSTATE_STOP:
213  glColor3d(.7, .4, .4);
214  break;
215  case LINKSTATE_EQUAL:
216  glColor3d(.7, .7, .7);
217  break;
219  glColor3d(.7, .7, 1);
220  case LINKSTATE_ZIPPER:
221  glColor3d(.75, .5, 0.25);
222  break;
223  default:
224  throw ProcessError("Unexpected LinkState '" + toString(state) + "'");
225  }
226  const Position& endPos = it->toEdge->getLaneShape(it->toLane)[0];
227  glBegin(GL_LINES);
228  glVertex2f(startPos.x(), startPos.y());
229  glVertex2f(endPos.x(), endPos.y());
230  glEnd();
231  GLHelper::drawTriangleAtEnd(startPos, endPos, (SUMOReal) 1.5, (SUMOReal) .2);
232  }
233  glPopName();
234  glPopMatrix();
235 }
236 
237 void
239  glPushMatrix();
240  glPushName(getGlID());
241  glTranslated(0, 0, getType());
242  const bool selectedEdge = gSelected.isSelected(myParentEdge.getType(), myParentEdge.getGlID());
243  const bool selected = gSelected.isSelected(getType(), getGlID());
244  if (mySpecialColor != 0) {
246  } else if (selected) {
248  } else if (selectedEdge) {
250  } else {
251  const GUIColorer& c = s.laneColorer;
252  if (!setFunctionalColor(c.getActive()) && !setMultiColor(c)) {
254  }
255  };
256 
257  // draw lane
258  // check whether it is not too small
259  const SUMOReal selectionScale = selected || selectedEdge ? s.selectionScale : 1;
260  const SUMOReal exaggeration = selectionScale * s.laneWidthExaggeration; // * s.laneScaler.getScheme().getColor(getScaleValue(s.laneScaler.getActive()));
261  if (s.scale * exaggeration < 1.) {
262  if (myShapeColors.size() > 0) {
264  } else {
266  }
267  glPopMatrix();
268  } else {
269  if (drawAsRailway(s)) {
270  // draw as railway
271  const SUMOReal halfRailWidth = 0.725 * exaggeration;
272  if (myShapeColors.size() > 0) {
274  } else {
276  }
277  RGBColor current = GLHelper::getColor();
278  glColor3d(1, 1, 1);
279  glTranslated(0, 0, .1);
281  GLHelper::setColor(current);
282  drawCrossties(0.3 * exaggeration, 1 * exaggeration, 1 * exaggeration);
283  } else {
284  // the actual lane
285  // reduce lane width to make sure that a selected edge can still be seen
286  const SUMOReal halfWidth = selectionScale * (myParentEdge.getNBEdge()->getLaneWidth(myIndex) / 2 - (selectedEdge ? .3 : 0));
287  if (myShapeColors.size() > 0) {
289  } else {
291  }
292  }
293  glPopMatrix();
294  if (exaggeration == 1) {
295  drawMarkings(selectedEdge, exaggeration);
296  }
297 
298  // draw ROWs only if target junction has a valid logic)
299  if (myParentEdge.getDest()->isLogicValid() && s.scale > 3) {
300  drawArrows();
301  }
302  }
303 
304  glPopName();
305 }
306 
307 
308 void
309 GNELane::drawMarkings(const bool& selectedEdge, SUMOReal scale) const {
310  glPushMatrix();
311  glTranslated(0, 0, GLO_EDGE);
312 
313  const SUMOReal halfWidth = myParentEdge.getNBEdge()->getLaneWidth(myIndex) * 0.5;
314  // optionally draw inverse markings
316  SUMOReal mw = (halfWidth + SUMO_const_laneOffset + .01) * scale;
317  int e = (int) getShape().size() - 1;
318  for (int i = 0; i < e; ++i) {
319  glPushMatrix();
320  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
321  glRotated(myShapeRotations[i], 0, 0, 1);
322  for (SUMOReal t = 0; t < myShapeLengths[i]; t += 6) {
323  const SUMOReal length = MIN2((SUMOReal)3, myShapeLengths[i] - t);
324  glBegin(GL_QUADS);
325  glVertex2d(-mw, -t);
326  glVertex2d(-mw, -t - length);
327  glVertex2d(halfWidth * 0.5 * scale, -t - length);
328  glVertex2d(halfWidth * 0.5 * scale, -t);
329  glEnd();
330  }
331  glPopMatrix();
332  }
333  }
334 
335  // draw white boundings (and white markings) depending on selection
336  if (selectedEdge) {
337  glTranslated(0, 0, 0.2); // draw selection on top of regular markings
339  } else {
340  glColor3d(1, 1, 1);
341  }
342 
344  getShape(),
346  getShapeLengths(),
347  (halfWidth + SUMO_const_laneOffset) * scale);
348  glPopMatrix();
349 
350 }
351 
352 
355  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
356  buildPopupHeader(ret, app);
358  new FXMenuCommand(ret, "Copy edge name to clipboard", 0, ret, MID_COPY_EDGE_NAME);
361  buildPositionCopyEntry(ret, false);
362  const int editMode = parent.getVisualisationSettings()->editMode;
363  myTLSEditor = 0;
364  if (editMode != GNE_MODE_CONNECT && editMode != GNE_MODE_TLS && editMode != GNE_MODE_CREATE_EDGE) {
365  new FXMenuCommand(ret, "Split edge here", 0, &parent, MID_GNE_SPLIT_EDGE);
366  new FXMenuCommand(ret, "Split edges in both direction here", 0, &parent, MID_GNE_SPLIT_EDGE_BIDI);
367  new FXMenuCommand(ret, "Reverse edge", 0, &parent, MID_GNE_REVERSE_EDGE);
368  new FXMenuCommand(ret, "Add reverse direction", 0, &parent, MID_GNE_ADD_REVERSE_EDGE);
369  new FXMenuCommand(ret, "Set geometry endpoint here", 0, &parent, MID_GNE_SET_EDGE_ENDPOINT);
370  new FXMenuCommand(ret, "Restore geometry endpoint", 0, &parent, MID_GNE_RESET_EDGE_ENDPOINT);
372  new FXMenuCommand(ret, "Straighten selected Edges", 0, &parent, MID_GNE_STRAIGHTEN);
373  } else {
374  new FXMenuCommand(ret, "Straighten edge", 0, &parent, MID_GNE_STRAIGHTEN);
375  }
377  new FXMenuCommand(ret, "Duplicate selected lanes", 0, &parent, MID_GNE_DUPLICATE_LANE);
378  } else {
379  new FXMenuCommand(ret, "Duplicate lane", 0, &parent, MID_GNE_DUPLICATE_LANE);
380  }
381  } else if (editMode == GNE_MODE_TLS) {
382  myTLSEditor = static_cast<GNEViewNet&>(parent).getViewParent()->getTLSEditorFrame();
384  new FXMenuCommand(ret, "Select state for all links from this edge:", 0, 0, 0);
385  const std::vector<std::string> names = GNEInternalLane::LinkStateNames.getStrings();
386  for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
387  FXuint state = GNEInternalLane::LinkStateNames.get(*it);
388  FXMenuRadio* mc = new FXMenuRadio(ret, (*it).c_str(), this, FXDataTarget::ID_OPTION + state);
389  mc->setSelBackColor(MFXUtils::getFXColor(GNEInternalLane::colorForLinksState(state)));
391  }
392  }
393  } else {
394  FXMenuCommand* mc = new FXMenuCommand(ret, "Additional options available in 'Inspect Mode'", 0, 0, 0);
395  mc->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), 0);
396  }
397  // buildShowParamsPopupEntry(ret, false);
398  new FXMenuSeparator(ret);
400  const SUMOReal height = getShape().positionAtOffset2D(getShape().nearest_offset_to_point2D(parent.getPositionInformation())).z();
401  new FXMenuCommand(ret, ("Shape pos: " + toString(pos)).c_str(), 0, 0, 0);
402  new FXMenuCommand(ret, ("Length pos: " + toString(getPositionRelativeToShapeLenght(pos))).c_str(), 0, 0, 0);
403  new FXMenuCommand(ret, ("Height: " + toString(height)).c_str(), 0, 0, 0);
404  // new FXMenuSeparator(ret);
405  // buildPositionCopyEntry(ret, false);
406 
407  // let the GNEViewNet store the popup position
408  (dynamic_cast<GNEViewNet&>(parent)).markPopupPosition();
409  return ret;
410 }
411 
412 
416  new GUIParameterTableWindow(app, *this, 2);
417  // add items
418  ret->mkItem("length [m]", false, myParentEdge.getNBEdge()->getLength());
419  // close building
420  ret->closeBuilding();
421  return ret;
422 }
423 
424 
425 Boundary
428  b.grow(10);
429  return b;
430 }
431 
432 
433 const PositionVector&
436 }
437 
438 
439 const std::vector<SUMOReal>&
441  return myShapeRotations;
442 }
443 
444 
445 const std::vector<SUMOReal>&
447  return myShapeLengths;
448 }
449 
450 
451 Boundary
454 }
455 
456 
457 void
459  myShapeRotations.clear();
460  myShapeLengths.clear();
461  //SUMOReal length = myParentEdge.getLength(); // @todo see ticket #448
462  // may be different from length
463  int segments = (int) getShape().size() - 1;
464  if (segments >= 0) {
465  myShapeRotations.reserve(segments);
466  myShapeLengths.reserve(segments);
467  for (int i = 0; i < segments; ++i) {
468  const Position& f = getShape()[i];
469  const Position& s = getShape()[i + 1];
470  myShapeLengths.push_back(f.distanceTo2D(s));
471  myShapeRotations.push_back((SUMOReal) atan2((s.x() - f.x()), (f.y() - s.y())) * (SUMOReal) 180.0 / (SUMOReal) PI);
472  }
473  }
474  // Update geometry of additionals vinculated with this lane
475  for (AdditionalVector::iterator i = myAdditionals.begin(); i != myAdditionals.end(); i++) {
476  (*i)->updateGeometry();
477  }
478  // Update geometry of additionalSets vinculated to this lane
479  for (AdditionalSetVector::iterator i = myAdditionalSets.begin(); i != myAdditionalSets.end(); ++i) {
480  (*i)->updateGeometry();
481  }
482 }
483 
484 unsigned int
486  return myIndex;
487 }
488 
489 void
490 GNELane::setIndex(unsigned int index) {
491  myIndex = index;
493 }
494 
495 
496 SUMOReal
499 }
500 
501 
502 SUMOReal
505 }
506 
507 
508 SUMOReal
510  return getShape().length();
511 }
512 
513 
514 SUMOReal
516  return (position * getLaneShapeLenght()) / getLaneParametricLenght();
517 }
518 
519 
520 SUMOReal
522  return (position * getLaneParametricLenght()) / getLaneShapeLenght();
523 }
524 
525 
526 void
528  myAdditionals.push_back(additional);
529 }
530 
531 
532 bool
534  // Find and remove stoppingPlace
535  for (AdditionalVector::iterator i = myAdditionals.begin(); i != myAdditionals.end(); i++) {
536  if (*i == additional) {
537  myAdditionals.erase(i);
538  return true;
539  }
540  }
541  return false;
542 }
543 
544 
545 const std::vector<GNEAdditional*>&
547  return myAdditionals;
548 }
549 
550 
551 bool
553  // Check if additionalSet already exists before insertion
554  for (AdditionalSetVector::iterator i = myAdditionalSets.begin(); i != myAdditionalSets.end(); i++) {
555  if ((*i) == additionalSet) {
556  return false;
557  }
558  }
559  // Insert it and retur true
560  myAdditionalSets.push_back(additionalSet);
561  return true;
562 }
563 
564 
565 bool
567  // search additionalSet and remove it
568  for (AdditionalSetVector::iterator i = myAdditionalSets.begin(); i != myAdditionalSets.end(); i++) {
569  if ((*i) == additionalSet) {
570  myAdditionalSets.erase(i);
571  return true;
572  }
573  }
574  // If additionalSet wasn't found, return false
575  return false;
576 }
577 
578 
579 const std::vector<GNEAdditionalSet*>&
581  return myAdditionalSets;
582 }
583 
584 
585 std::string
587  const NBEdge* edge = myParentEdge.getNBEdge();
588  switch (key) {
589  case SUMO_ATTR_ID:
590  return getMicrosimID();
591  case SUMO_ATTR_SPEED:
592  return toString(edge->getLaneSpeed(myIndex));
593  case SUMO_ATTR_ALLOW:
594  // return all allowed classes (may differ from the written attributes)
596  case SUMO_ATTR_DISALLOW:
597  // return all disallowed classes (may differ from the written attributes)
598  return getVehicleClassNames(~(edge->getPermissions(myIndex)));
599  case SUMO_ATTR_WIDTH:
600  return toString(edge->getLaneStruct(myIndex).width);
601  case SUMO_ATTR_ENDOFFSET:
602  return toString(edge->getLaneStruct(myIndex).endOffset);
603  case SUMO_ATTR_INDEX:
604  return toString(myIndex);
605  default:
606  throw InvalidArgument("lane attribute '" + toString(key) + "' not allowed");
607  }
608 }
609 
610 
611 void
612 GNELane::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
613  switch (key) {
614  case SUMO_ATTR_ID:
615  throw InvalidArgument("modifying lane attribute '" + toString(key) + "' not allowed");
616  case SUMO_ATTR_SPEED:
617  case SUMO_ATTR_ALLOW:
618  case SUMO_ATTR_DISALLOW:
619  case SUMO_ATTR_WIDTH:
620  case SUMO_ATTR_ENDOFFSET:
621  case SUMO_ATTR_INDEX:
622  // no special handling
623  undoList->p_add(new GNEChange_Attribute(this, key, value));
624  break;
625  default:
626  throw InvalidArgument("lane attribute '" + toString(key) + "' not allowed");
627  }
628 }
629 
630 
631 bool
632 GNELane::isValid(SumoXMLAttr key, const std::string& value) {
633  switch (key) {
634  case SUMO_ATTR_ID:
635  return false;
636  case SUMO_ATTR_SPEED:
637  return canParse<SUMOReal>(value);
638  case SUMO_ATTR_ALLOW:
639  case SUMO_ATTR_DISALLOW:
640  return canParseVehicleClasses(value);
641  case SUMO_ATTR_WIDTH:
642  return canParse<SUMOReal>(value) && (isPositive<SUMOReal>(value) || parse<SUMOReal>(value) == NBEdge::UNSPECIFIED_WIDTH);
643  case SUMO_ATTR_ENDOFFSET:
644  return canParse<SUMOReal>(value);
645  case SUMO_ATTR_INDEX:
646  return value == toString(myIndex);
647  default:
648  throw InvalidArgument("lane attribute '" + toString(key) + "' not allowed");
649  }
650 }
651 
652 
653 void
655  mySpecialColor = color;
656 }
657 
658 // ===========================================================================
659 // private
660 // ===========================================================================
661 
662 void
663 GNELane::setAttribute(SumoXMLAttr key, const std::string& value) {
664  NBEdge* edge = myParentEdge.getNBEdge();
665  switch (key) {
666  case SUMO_ATTR_ID:
667  throw InvalidArgument("modifying lane attribute '" + toString(key) + "' not allowed");
668  case SUMO_ATTR_SPEED:
669  edge->setSpeed(myIndex, parse<SUMOReal>(value));
670  break;
671  case SUMO_ATTR_ALLOW:
673  break;
674  case SUMO_ATTR_DISALLOW:
675  edge->setPermissions(~parseVehicleClasses(value), myIndex); // negation yields allowed
676  break;
677  case SUMO_ATTR_WIDTH:
678  edge->setLaneWidth(myIndex, parse<SUMOReal>(value));
679  break;
680  case SUMO_ATTR_ENDOFFSET:
681  edge->setEndOffset(myIndex, parse<SUMOReal>(value));
682  break;
683  default:
684  throw InvalidArgument("lane attribute '" + toString(key) + "' not allowed");
685  }
686 }
687 
688 
689 bool
690 GNELane::setFunctionalColor(size_t activeScheme) const {
691  switch (activeScheme) {
692  case 6: {
693  SUMOReal hue = GeomHelper::naviDegree(getShape().beginEndAngle()); // [0-360]
695  return true;
696  }
697  default:
698  return false;
699  }
700 }
701 
702 
703 bool
705  const size_t activeScheme = c.getActive();
706  myShapeColors.clear();
707  switch (activeScheme) {
708  case 9: // color by height at segment start
709  for (PositionVector::const_iterator ii = getShape().begin(); ii != getShape().end() - 1; ++ii) {
710  myShapeColors.push_back(c.getScheme().getColor(ii->z()));
711  }
712  return true;
713  case 11: // color by inclination at segment start
714  for (int ii = 1; ii < (int)getShape().size(); ++ii) {
715  const SUMOReal inc = (getShape()[ii].z() - getShape()[ii - 1].z()) / MAX2(POSITION_EPS, getShape()[ii].distanceTo2D(getShape()[ii - 1]));
716  myShapeColors.push_back(c.getScheme().getColor(inc));
717  }
718  return true;
719  default:
720  return false;
721  }
722 }
723 
724 
725 SUMOReal
726 GNELane::getColorValue(size_t activeScheme) const {
727  const SVCPermissions myPermissions = myParentEdge.getNBEdge()->getPermissions(myIndex);
728  switch (activeScheme) {
729  case 0:
730  switch (myPermissions) {
731  case SVC_PEDESTRIAN:
732  return 1;
733  case SVC_BICYCLE:
734  return 2;
735  case 0:
736  return 3;
737  case SVC_SHIP:
738  return 4;
739  default:
740  break;
741  }
742  if ((myPermissions & SVC_PASSENGER) != 0 || isRailway(myPermissions)) {
743  return 0;
744  } else {
745  return 5;
746  }
747  case 1:
748  return gSelected.isSelected(getType(), getGlID()) ||
749  gSelected.isSelected(GLO_EDGE, dynamic_cast<GNEEdge*>(&myParentEdge)->getGlID());
750  case 2:
751  return (SUMOReal)myPermissions;
752  case 3:
754  case 4:
755  return myParentEdge.getNBEdge()->getNumLanes();
756  case 5: {
758  }
759  // case 6: by angle (functional)
760  case 7: {
761  return myParentEdge.getNBEdge()->getPriority();
762  }
763  case 8: {
764  // color by z of first shape point
765  return getShape()[0].z();
766  }
767  // case 9: by segment height
768  case 10: {
769  // color by incline
770  return (getShape()[-1].z() - getShape()[0].z()) / myParentEdge.getNBEdge()->getLength();
771  }
772  }
773  return 0;
774 }
775 
776 
777 bool
780 }
781 
782 
783 bool
785  return isWaterway(myParentEdge.getNBEdge()->getPermissions(myIndex)) && s.showRails; // reusing the showRails setting
786 }
787 
788 
789 void
790 GNELane::drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const {
791  glPushMatrix();
792  // draw on top of of the white area between the rails
793  glTranslated(0, 0, 0.1);
794  int e = (int) getShape().size() - 1;
795  for (int i = 0; i < e; ++i) {
796  glPushMatrix();
797  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.0);
798  glRotated(myShapeRotations[i], 0, 0, 1);
799  for (SUMOReal t = 0; t < myShapeLengths[i]; t += spacing) {
800  glBegin(GL_QUADS);
801  glVertex2d(-halfWidth, -t);
802  glVertex2d(-halfWidth, -t - length);
803  glVertex2d(halfWidth, -t - length);
804  glVertex2d(halfWidth, -t);
805  glEnd();
806  }
807  glPopMatrix();
808  }
809  glPopMatrix();
810 }
811 
812 
813 const std::string&
815  return myParentEdge.getMicrosimID();
816 }
817 
818 
819 long
820 GNELane::onDefault(FXObject* obj, FXSelector sel, void* data) {
821  if (myTLSEditor != 0) {
822  myTLSEditor->handleMultiChange(this, obj, sel, data);
823  }
824  return 1;
825 }
826 
827 GNEEdge&
829  return myParentEdge;
830 };
831 
832 /****************************************************************************/
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:784
The link is a partial left direction.
const PositionVector & getLaneShape(unsigned int i) const
Returns the shape of the nth lane.
Definition: NBEdge.cpp:553
SUMOReal endOffset
This lane&#39;s offset to the intersection begin.
Definition: NBEdge.h:136
bool controlsEdge(GNEEdge &edge) const
whether the given edge is controlled by the currently edited tlDef
const std::string & getParentName() const
Returns the name of the parent object (if any)
Definition: GNELane.cpp:814
const std::vector< SUMOReal > & getShapeRotations() const
returns the vector with the shape rotations
Definition: GNELane.cpp:440
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:203
float laneWidthExaggeration
The lane exaggeration (upscale thickness)
PositionVector shape
The lane&#39;s shape.
Definition: NBEdge.h:128
is a pedestrian
Copy edge name (for lanes only)
Definition: GUIAppEnum.h:235
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
GNETLSEditorFrame * myTLSEditor
the tls-editor for setting multiple links in TLS-mode
Definition: GNELane.h:252
static RGBColor fromHSV(SUMOReal h, SUMOReal s, SUMOReal v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:294
AdditionalVector myAdditionals
list with the additonals vinculated with this lane
Definition: GNELane.h:240
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:354
NBNode * myTo
Definition: NBEdge.h:1292
void drawMarkings(const bool &selectedEdge, SUMOReal scale) const
draw lane markings
Definition: GNELane.cpp:309
SUMOReal getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:497
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:246
static const RGBColor selectedLaneColor
color of selected lane
Definition: GNENet.h:97
std::vector< Connection > getConnectionsFromLane(int lane) const
Returns connections from a given lane.
Definition: NBEdge.cpp:797
void setLaneWidth(int lane, SUMOReal width)
set lane specific width (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2478
SUMOReal getPositionRelativeToShapeLenght(SUMOReal position) const
Definition: GNELane.cpp:521
void setSpeed(int lane, SUMOReal speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2533
GUIColorer laneColorer
The lane colorer.
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)
return the color for each linkstate
mode for editing tls
Definition: GNEViewNet.h:62
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.
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:469
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:2549
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:54
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:704
GNELane()
FOX needs this.
Definition: GNELane.cpp:86
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:249
This is an uncontrolled, right-before-left link.
void drawTLSLinkNo() const
draw TLS Link Number
Definition: GNELane.cpp:109
void handleMultiChange(GNELane *lane, FXObject *obj, FXSelector sel, void *data)
update phase definition for the current traffic light and phase
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.
unsigned int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:485
An Element wich group additionalSet elements.
The link is controlled by a tls which is off, not blinking, may pass.
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:452
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.
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:228
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.
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
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:778
SUMOReal getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn&#39;t set.
Definition: NBEdge.h:433
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
#define PI
Definition: polyfonts.c:61
SUMOReal selectionScale
the current selection scaling in NETEDIT (temporary)
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:189
void drawArrows() const
draw arrows
Definition: GNELane.cpp:119
int getPriority() const
Returns the priority of the edge.
Definition: NBEdge.h:355
std::string getLaneID(unsigned int lane) const
Definition: NBEdge.cpp:2350
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:443
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:828
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:612
SUMOReal getLaneParametricLenght() const
returns the parameteric length of the lane
Definition: GNELane.cpp:503
SUMOReal getPositionRelativeToParametricLenght(SUMOReal position) const
Definition: GNELane.cpp:515
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:690
A list of positions.
bool isLogicValid()
whether this junction has a valid logic
std::vector< SUMOReal > myShapeRotations
Definition: GNELane.h:233
bool isWaterway(SVCPermissions permissions)
Returns whether an edge with the given permission is a waterway edge.
friend class GNEChange_Attribute
declare friend class
AdditionalSetVector myAdditionalSets
list with the additonalSets vinculated with this lane
Definition: GNELane.h:243
SUMOReal z() const
Returns the z-position.
Definition: Position.h:73
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:347
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:188
LinkState getLinkState(const NBEdge *incoming, NBEdge *outgoing, int fromLane, int toLane, bool mayDefinitelyPass, const std::string &tlID) const
Definition: NBNode.cpp:1539
bool removeAdditionalSet(GNEAdditionalSet *additionalSet)
remove GNEAdditionalSet from this lane
Definition: GNELane.cpp:566
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
bool removeAdditional(GNEAdditional *additional)
Definition: GNELane.cpp:533
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:1475
std::vector< Connection > myConnections
List of connections to following edges.
Definition: NBEdge.h:1311
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
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:458
static SUMOReal naviDegree(const SUMOReal angle)
Definition: GeomHelper.cpp:191
is an arbitrary ship
void drawCrossties(SUMOReal length, SUMOReal spacing, SUMOReal halfWidth) const
draw crossties for railroads
Definition: GNELane.cpp:790
bool addAdditionalSet(GNEAdditionalSet *additionalSet)
add GNEAdditionalSet to this lane
Definition: GNELane.cpp:552
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:586
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:54
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition: NBEdge.cpp:2577
void drawLinkRules() const
draw link rules
Definition: GNELane.cpp:114
GNEEdge & myParentEdge
The Edge that to which this lane belongs.
Definition: GNELane.h:225
SUMOReal length() const
Returns the length.
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:371
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:434
SUMOReal getLaneShapeLenght() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:509
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:820
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:63
The link is controlled by a tls which is off and blinks, has to brake.
const std::vector< GNEAdditional * > & getAdditionals() const
method to obtain a list of additional elements associated to this lane
Definition: GNELane.cpp:546
std::vector< SUMOReal > myShapeLengths
The lengths of the shape parts.
Definition: GNELane.h:236
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
void setSpecialColor(const RGBColor *Color2)
Definition: GNELane.cpp:654
The popup menu of a globject.
an edge
const std::vector< SUMOReal > & getShapeLengths() const
returns the vector with the shape lengths
Definition: GNELane.cpp:446
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:426
GNEJunction * getDest() const
returns the destination-junction
Definition: GNEEdge.cpp:144
SUMOReal getLaneSpeed(unsigned int lane) const
Definition: NBEdge.cpp:1335
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:1090
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
get visualitation settings
void setEndOffset(int lane, SUMOReal offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2517
#define SUMOReal
Definition: config.h:214
void addAdditional(GNEAdditional *additional)
Definition: GNELane.cpp:527
static const RGBColor selectionColor
color of selection
Definition: GNENet.h:94
mode for connecting lanes
Definition: GNEViewNet.h:60
void setIndex(unsigned int index)
Definition: GNELane.cpp:490
const std::vector< GNEAdditionalSet * > & getAdditionalSets()
return list of additionalSets associated with this lane
Definition: GNELane.cpp:580
mode for creating new edges
Definition: GNEViewNet.h:50
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:632
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:225
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
void drawLinkNo() const
draw link Number
Definition: GNELane.cpp:104
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:414
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.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:238
~GNELane()
Destructor.
Definition: GNELane.cpp:95
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:424
SUMOReal getColorValue(size_t activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:726
The link has no direction (is a dead end link)
a junction
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:449