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-2017 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>
48 #include <utils/gui/div/GLHelper.h>
52 
53 #include "GNELane.h"
54 #include "GNEEdge.h"
55 #include "GNEJunction.h"
56 #include "GNETLSEditorFrame.h"
57 #include "GNEInternalLane.h"
58 #include "GNEUndoList.h"
59 #include "GNENet.h"
60 #include "GNEChange_Attribute.h"
61 #include "GNEViewNet.h"
62 #include "GNEViewParent.h"
63 #include "GNEConnection.h"
64 
65 // ===========================================================================
66 // FOX callback mapping
67 // ===========================================================================
68 
69 // Object implementation
70 FXIMPLEMENT(GNELane, FXDelegator, 0, 0)
71 
72 // ===========================================================================
73 // method definitions
74 // ===========================================================================
75 
76 GNELane::GNELane(GNEEdge& edge, const int index) :
77  GNENetElement(edge.getNet(), edge.getNBEdge()->getLaneID(index), GLO_LANE, SUMO_TAG_LANE, ICON_LANE),
78  myParentEdge(edge),
79  myIndex(index),
80  mySpecialColor(0),
81  myTLSEditor(0) {
82 }
83 
85  GNENetElement(NULL, "dummyConstructorGNELane", GLO_LANE, SUMO_TAG_LANE, ICON_LOCATEEDGE),
86  myParentEdge(*static_cast<GNEEdge*>(0)),
87  myIndex(-1),
88  mySpecialColor(0),
89  myTLSEditor(0) {
90 }
91 
92 
94 }
95 
96 
97 void
99  const std::vector<NBEdge::Connection>& cons = myParentEdge.getNBEdge()->getConnectionsFromLane(myIndex);
100  int noLinks = (int)cons.size();
101  if (noLinks == 0) {
102  return;
103  }
104  // draw all links
105  glPushMatrix();
106  glTranslated(0, 0, GLO_LANE + 0.1);
107  double w = myParentEdge.getNBEdge()->getLaneWidth(myIndex) / (double) noLinks;
108  double x1 = myParentEdge.getNBEdge()->getLaneWidth(myIndex) / 2;
109  const bool lefthand = OptionsCont::getOptions().getBool("lefthand");
110  for (int i = noLinks; --i >= 0;) {
111  double x2 = x1 - (double)(w / 2.);
113  cons[lefthand ? noLinks - 1 - i : i]);
115  x1 -= w;
116  }
117  glPopMatrix();
118 }
119 
120 
121 void
123  const std::vector<NBEdge::Connection>& cons = myParentEdge.getNBEdge()->getConnectionsFromLane(myIndex);
124  int noLinks = (int)cons.size();
125  if (noLinks == 0) {
126  return;
127  }
128  // draw all links
129  glPushMatrix();
130  glTranslated(0, 0, GLO_LANE + 0.1);
131  double w = myParentEdge.getNBEdge()->getLaneWidth(myIndex) / (double) noLinks;
132  double x1 = myParentEdge.getNBEdge()->getLaneWidth(myIndex) / 2;
133  const bool lefthand = OptionsCont::getOptions().getBool("lefthand");
134  for (int i = noLinks; --i >= 0;) {
135  double x2 = x1 - (double)(w / 2.);
136  int linkNo = cons[lefthand ? noLinks - 1 - i : i].tlLinkNo;
138  x1 -= w;
139  }
140  glPopMatrix();
141 }
142 
143 
144 void
146 }
147 
148 
149 void
151  const Position& end = getShape().back();
152  const Position& f = getShape()[-2];
153  double rot = (double) atan2((end.x() - f.x()), (f.y() - end.y())) * (double) 180.0 / (double)M_PI;
154  glPushMatrix();
155  glPushName(0);
156  glTranslated(0, 0, GLO_JUNCTION + .1); // must draw on top of junction shape
157  glColor3d(1, 1, 1);
158  glTranslated(end.x(), end.y(), 0);
159  glRotated(rot, 0, 0, 1);
160 
161  // draw all links
162  const std::vector<NBEdge::Connection>& edgeCons = myParentEdge.getNBEdge()->myConnections;
163  NBNode* dest = myParentEdge.getNBEdge()->myTo;
164  for (std::vector<NBEdge::Connection>::const_iterator i = edgeCons.begin(); i != edgeCons.end(); ++i) {
165  if ((*i).fromLane == myIndex) {
166  LinkDirection dir = dest->getDirection(myParentEdge.getNBEdge(), i->toEdge, OptionsCont::getOptions().getBool("lefthand"));
167  switch (dir) {
168  case LINKDIR_STRAIGHT:
169  GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
170  GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
171  break;
172  case LINKDIR_LEFT:
173  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
174  GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
175  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.5, 2.5), (double) 1, (double) .25);
176  break;
177  case LINKDIR_RIGHT:
178  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
179  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
180  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.5, 2.5), (double) 1, (double) .25);
181  break;
182  case LINKDIR_TURN:
183  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
184  GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .05);
185  GLHelper::drawBoxLine(Position(0.5, 2.5), 180, 1, .05);
186  GLHelper::drawTriangleAtEnd(Position(0.5, 2.5), Position(0.5, 4), (double) 1, (double) .25);
187  break;
189  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
190  GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
191  GLHelper::drawBoxLine(Position(-0.5, 2.5), -180, 1, .05);
192  GLHelper::drawTriangleAtEnd(Position(-0.5, 2.5), Position(-0.5, 4), (double) 1, (double) .25);
193  break;
194  case LINKDIR_PARTLEFT:
195  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
196  GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
197  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.2, 1.3), (double) 1, (double) .25);
198  break;
199  case LINKDIR_PARTRIGHT:
200  GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
201  GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
202  GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.2, 1.3), (double) 1, (double) .25);
203  break;
204  case LINKDIR_NODIR:
205  GLHelper::drawBoxLine(Position(1, 5.8), 245, 2, .05);
206  GLHelper::drawBoxLine(Position(-1, 5.8), 115, 2, .05);
207  glTranslated(0, 5, 0);
208  GLHelper::drawOutlineCircle(0.9, 0.8, 32);
209  glTranslated(0, -5, 0);
210  break;
211  }
212  }
213  }
214  glPopName();
215  glPopMatrix();
216 }
217 
218 
219 void
221  glPushMatrix();
222  glPushName(0);
223  glTranslated(0, 0, GLO_JUNCTION + .1); // must draw on top of junction shape
224  std::vector<NBEdge::Connection> connections = myParentEdge.getNBEdge()->getConnectionsFromLane(myIndex);
225  NBNode* node = myParentEdge.getNBEdge()->getToNode();
226  const Position& startPos = getShape()[-1];
227  for (std::vector<NBEdge::Connection>::iterator it = connections.begin(); it != connections.end(); it++) {
228  const LinkState state = node->getLinkState(
229  myParentEdge.getNBEdge(), it->toEdge, it->fromLane, it->toLane, it->mayDefinitelyPass, it->tlID);
230  switch (state) {
232  glColor3d(1, 1, 0);
233  break;
235  glColor3d(0, 1, 1);
236  break;
237  case LINKSTATE_MAJOR:
238  glColor3d(1, 1, 1);
239  break;
240  case LINKSTATE_MINOR:
241  glColor3d(.4, .4, .4);
242  break;
243  case LINKSTATE_STOP:
244  glColor3d(.7, .4, .4);
245  break;
246  case LINKSTATE_EQUAL:
247  glColor3d(.7, .7, .7);
248  break;
250  glColor3d(.7, .7, 1);
251  case LINKSTATE_ZIPPER:
252  glColor3d(.75, .5, 0.25);
253  break;
254  default:
255  throw ProcessError("Unexpected LinkState '" + toString(state) + "'");
256  }
257  const Position& endPos = it->toEdge->getLaneShape(it->toLane)[0];
258  glBegin(GL_LINES);
259  glVertex2d(startPos.x(), startPos.y());
260  glVertex2d(endPos.x(), endPos.y());
261  glEnd();
262  GLHelper::drawTriangleAtEnd(startPos, endPos, (double) 1.5, (double) .2);
263  }
264  glPopName();
265  glPopMatrix();
266 }
267 
268 
269 void
271  // Push draw matrix 1
272  glPushMatrix();
273  // Push name
274  glPushName(getGlID());
275  // Traslate to fromt
276  glTranslated(0, 0, getType());
277  // Check if edge parent or this lane is selected
278  const bool selectedEdge = gSelected.isSelected(myParentEdge.getType(), myParentEdge.getGlID());
279  const bool selected = gSelected.isSelected(getType(), getGlID());
280  // Set color
281  if (mySpecialColor != 0) {
282  // If special color is enabled, set it
284  } else if (selected && s.laneColorer.getActive() != 1) {
285  // override with special colors (unless the color scheme is based on selection)
287  } else if (selectedEdge && s.laneColorer.getActive() != 1) {
288  // override with special colors (unless the color scheme is based on selection)
290  } else {
291  // Get normal lane color
292  const GUIColorer& c = s.laneColorer;
293  if (!setFunctionalColor(c.getActive()) && !setMultiColor(c)) {
295  }
296  }
297 
298  // start drawing lane checking whether it is not too small
299  const double selectionScale = selected || selectedEdge ? s.selectionScale : 1;
300  double exaggeration = selectionScale * s.laneWidthExaggeration; // * s.laneScaler.getScheme().getColor(getScaleValue(s.laneScaler.getActive()));
301  // XXX apply usefull scale values
302  //exaggeration *= s.laneScaler.getScheme().getColor(getScaleValue(s.laneScaler.getActive()));
303 
304  // recognize full transparency and simply don't draw
305  GLfloat color[4];
306  glGetFloatv(GL_CURRENT_COLOR, color);
307  if (color[3] == 0 || s.scale * exaggeration < s.laneMinSize) {
308  // Pop draw matrix 1
309  glPopMatrix();
310  } else if (s.scale * exaggeration < 1.) {
311  // draw as lines, depending of myShapeColors
312  if (myShapeColors.size() > 0) {
314  } else {
316  }
317  // Pop draw matrix 1
318  glPopMatrix();
319  } else {
320  if (drawAsRailway(s)) {
321  // draw as railway
322  const double halfRailWidth = 0.725 * exaggeration;
323  // Draw box depending of myShapeColors
324  if (myShapeColors.size() > 0) {
326  } else {
328  }
329  // Save current color
330  RGBColor current = GLHelper::getColor();
331  // Set white color
332  glColor3d(1, 1, 1);
333  // Traslate matrix 1
334  glTranslated(0, 0, .1);
335  // Draw Box
337  // Set current color back
338  GLHelper::setColor(current);
339  // Draw crossties
340  drawCrossties(0.3 * exaggeration, 1 * exaggeration, 1 * exaggeration);
341  } else {
342  // Draw as a normal lane, and reduce width to make sure that a selected edge can still be seen
343  const double halfWidth = exaggeration * (myParentEdge.getNBEdge()->getLaneWidth(myIndex) / 2 - (selectedEdge ? .3 : 0));
344  if (myShapeColors.size() > 0) {
346  } else {
348  }
349  }
350  // Pop draw matrix 1
351  glPopMatrix();
352  // only draw details depending of the scale
353  if (s.scale >= 10) {
354  // if exaggeration is 1, draw drawMarkings
355  if (s.laneShowBorders && exaggeration == 1) {
356  drawMarkings(selectedEdge, exaggeration);
357  }
358  // draw ROWs only if target junction has a valid logic)
360  drawArrows();
361  }
362  // Draw direction indicators if the correspondient option is enabled
363  if (s.showLaneDirection) {
365  }
366  if (s.drawLinkJunctionIndex.show) {
367  drawLinkNo(s);
368  }
369  if (s.drawLinkTLIndex.show) {
370  drawTLSLinkNo(s);
371  }
372  }
373  // If there are texture of restricted lanes to draw, and draw lane icons is enabled in options
374  if ((OptionsCont::getOptions().getBool("disable-laneIcons") == false) && (myLaneRestrictedTexturePositions.size() > 0) && (s.scale >= 10)) {
375  // Declare default width of icon (3)
376  double iconWidth = 1;
377  // Obtain width of icon, if width of lane is different
379  iconWidth = myParentEdge.getNBEdge()->getLaneStruct(myIndex).width / 3;
380  }
381  // Draw list of icons
382  for (int i = 0; i < (int)myLaneRestrictedTexturePositions.size(); i++) {
383  // Push draw matrix 2
384  glPushMatrix();
385  // Set white color
386  glColor3d(1, 1, 1);
387  // Traslate matrix 2
388  glTranslated(myLaneRestrictedTexturePositions.at(i).x(), myLaneRestrictedTexturePositions.at(i).y(), getType() + 0.1);
389  // Rotate matrix 2
390  glRotated(myLaneRestrictedTextureRotations.at(i), 0, 0, -1);
391  glRotated(-90, 0, 0, 1);
392  // draw texture box depending of type of restriction
395  } else if (isRestricted(SVC_BICYCLE)) {
397  } else if (isRestricted(SVC_BUS)) {
399  }
400  // Pop draw matrix 2
401  glPopMatrix();
402  }
403  }
404  }
405  // Pop Name
406  glPopName();
407 }
408 
409 
410 void
411 GNELane::drawMarkings(const bool& selectedEdge, double scale) const {
412  glPushMatrix();
413  glTranslated(0, 0, GLO_EDGE);
414 
415  const double halfWidth = myParentEdge.getNBEdge()->getLaneWidth(myIndex) * 0.5;
416  // optionally draw inverse markings
418  double mw = (halfWidth + SUMO_const_laneOffset + .01) * scale;
419  int e = (int) getShape().size() - 1;
420  for (int i = 0; i < e; ++i) {
421  glPushMatrix();
422  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
423  glRotated(myShapeRotations[i], 0, 0, 1);
424  for (double t = 0; t < myShapeLengths[i]; t += 6) {
425  const double length = MIN2((double)3, myShapeLengths[i] - t);
426  glBegin(GL_QUADS);
427  glVertex2d(-mw, -t);
428  glVertex2d(-mw, -t - length);
429  glVertex2d(halfWidth * 0.5 * scale, -t - length);
430  glVertex2d(halfWidth * 0.5 * scale, -t);
431  glEnd();
432  }
433  glPopMatrix();
434  }
435  }
436 
437  // draw white boundings (and white markings) depending on selection
438  if (selectedEdge) {
439  glTranslated(0, 0, 0.2); // draw selection on top of regular markings
441  } else {
442  glColor3d(1, 1, 1);
443  }
444 
446  getShape(),
448  getShapeLengths(),
449  (halfWidth + SUMO_const_laneOffset) * scale);
450  glPopMatrix();
451 
452 }
453 
454 
457  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
458  buildPopupHeader(ret, app);
460  new FXMenuCommand(ret, ("Copy " + toString(SUMO_TAG_EDGE) + " name to clipboard").c_str(), 0, ret, MID_COPY_EDGE_NAME);
463  buildPositionCopyEntry(ret, false);
464  const int editMode = parent.getVisualisationSettings()->editMode;
465  myTLSEditor = 0;
466  if (editMode != GNE_MODE_CONNECT && editMode != GNE_MODE_TLS && editMode != GNE_MODE_CREATE_EDGE) {
467  // Get icons
468  FXIcon* pedestrianIcon = GUIIconSubSys::getIcon(ICON_LANEPEDESTRIAN);
469  FXIcon* bikeIcon = GUIIconSubSys::getIcon(ICON_LANEBIKE);
470  FXIcon* busIcon = GUIIconSubSys::getIcon(ICON_LANEBUS);
471  // Create basic commands
472  new FXMenuCommand(ret, ("Split " + toString(SUMO_TAG_EDGE) + " here").c_str(), 0, &parent, MID_GNE_EDGE_SPLIT);
473  new FXMenuCommand(ret, ("Split " + toString(SUMO_TAG_EDGE) + "s in both direction here").c_str(), 0, &parent, MID_GNE_EDGE_SPLIT_BIDI);
474  new FXMenuCommand(ret, ("Reverse " + toString(SUMO_TAG_EDGE)).c_str(), 0, &parent, MID_GNE_EDGE_REVERSE);
475  new FXMenuCommand(ret, "Add reverse direction", 0, &parent, MID_GNE_EDGE_ADD_REVERSE);
476  new FXMenuCommand(ret, "Set geometry endpoint here", 0, &parent, MID_GNE_EDGE_SET_ENDPOINT);
477  new FXMenuCommand(ret, "Restore geometry endpoint", 0, &parent, MID_GNE_EDGE_RESET_ENDPOINT);
479  new FXMenuCommand(ret, ("Straighten selected " + toString(SUMO_TAG_EDGE) + "s").c_str(), 0, &parent, MID_GNE_EDGE_STRAIGHTEN);
480  } else {
481  new FXMenuCommand(ret, ("Straighten " + toString(SUMO_TAG_EDGE)).c_str(), 0, &parent, MID_GNE_EDGE_STRAIGHTEN);
482  }
484  new FXMenuCommand(ret, ("Duplicate selected" + toString(SUMO_TAG_LANE) + "s").c_str(), 0, &parent, MID_GNE_LANE_DUPLICATE);
485  // Create panel for lane operations
486  FXMenuPane* addSpecialLanes = new FXMenuPane(ret);
487  ret->insertMenuPaneChild(addSpecialLanes);
488  FXMenuPane* removeSpecialLanes = new FXMenuPane(ret);
489  ret->insertMenuPaneChild(removeSpecialLanes);
490  FXMenuPane* transformSlanes = new FXMenuPane(ret);
491  ret->insertMenuPaneChild(transformSlanes);
492  // Create menu comands for all add special lanes
493  new FXMenuCommand(addSpecialLanes, "Sidewalks", pedestrianIcon, &parent, MID_GNE_LANE_ADD_SIDEWALK);
494  new FXMenuCommand(addSpecialLanes, "Bikelanes", bikeIcon, &parent, MID_GNE_LANE_ADD_BIKE);
495  new FXMenuCommand(addSpecialLanes, "Buslanes", busIcon, &parent, MID_GNE_LANE_ADD_BUS);
496  // Create menu comands for all remove special lanes and disable it
497  new FXMenuCommand(removeSpecialLanes, "Sidewalks", pedestrianIcon, &parent, MID_GNE_LANE_REMOVE_SIDEWALK);
498  new FXMenuCommand(removeSpecialLanes, "Bikelanes", bikeIcon, &parent, MID_GNE_LANE_REMOVE_BIKE);
499  new FXMenuCommand(removeSpecialLanes, "Buslanes", busIcon, &parent, MID_GNE_LANE_REMOVE_BUS);
500  // Create menu comands for all trasform special lanes and disable it
501  new FXMenuCommand(transformSlanes, "Sidewalks", pedestrianIcon, &parent, MID_GNE_LANE_TRANSFORM_SIDEWALK);
502  new FXMenuCommand(transformSlanes, "Bikelanes", bikeIcon, &parent, MID_GNE_LANE_TRANSFORM_BIKE);
503  new FXMenuCommand(transformSlanes, "Buslanes", busIcon, &parent, MID_GNE_LANE_TRANSFORM_BUS);
504  new FXMenuCommand(transformSlanes, "revert transformations", 0, &parent, MID_GNE_LANE_REVERT_TRANSFORMATION);
505  // add menuCascade for lane operations
506  new FXMenuCascade(ret, ("add special" + toString(SUMO_TAG_LANE) + "s").c_str(), 0, addSpecialLanes);
507  new FXMenuCascade(ret, ("remove special" + toString(SUMO_TAG_LANE) + "s").c_str(), 0, removeSpecialLanes);
508  new FXMenuCascade(ret, ("transform to special" + toString(SUMO_TAG_LANE) + "s").c_str(), 0, transformSlanes);
509  } else {
510  new FXMenuCommand(ret, ("Duplicate" + toString(SUMO_TAG_LANE)).c_str(), 0, &parent, MID_GNE_LANE_DUPLICATE);
511  // Declare flags
512  bool edgeHasSidewalk = myParentEdge.hasRestrictedLane(SVC_PEDESTRIAN);
513  bool edgeHasBikelane = myParentEdge.hasRestrictedLane(SVC_BICYCLE);
514  bool edgeHasBuslane = myParentEdge.hasRestrictedLane(SVC_BUS);
515  // Create panel for lane operations and insert it in ret
516  FXMenuPane* addSpecialLanes = new FXMenuPane(ret);
517  ret->insertMenuPaneChild(addSpecialLanes);
518  FXMenuPane* removeSpecialLanes = new FXMenuPane(ret);
519  ret->insertMenuPaneChild(removeSpecialLanes);
520  FXMenuPane* transformSlanes = new FXMenuPane(ret);
521  ret->insertMenuPaneChild(transformSlanes);
522  // Create menu comands for all add special lanes
523  FXMenuCommand* addSidewalk = new FXMenuCommand(addSpecialLanes, "Sidewalk", pedestrianIcon, &parent, MID_GNE_LANE_ADD_SIDEWALK);
524  FXMenuCommand* addBikelane = new FXMenuCommand(addSpecialLanes, "Bikelane", bikeIcon, &parent, MID_GNE_LANE_ADD_BIKE);
525  FXMenuCommand* addBuslane = new FXMenuCommand(addSpecialLanes, "Buslane", busIcon, &parent, MID_GNE_LANE_ADD_BUS);
526  // Create menu comands for all remove special lanes and disable it
527  FXMenuCommand* removeSidewalk = new FXMenuCommand(removeSpecialLanes, "Sidewalk", pedestrianIcon, &parent, MID_GNE_LANE_REMOVE_SIDEWALK);
528  removeSidewalk->disable();
529  FXMenuCommand* removeBikelane = new FXMenuCommand(removeSpecialLanes, "Bikelane", bikeIcon, &parent, MID_GNE_LANE_REMOVE_BIKE);
530  removeBikelane->disable();
531  FXMenuCommand* removeBuslane = new FXMenuCommand(removeSpecialLanes, "Buslane", busIcon, &parent, MID_GNE_LANE_REMOVE_BUS);
532  removeBuslane->disable();
533  // Create menu comands for all trasform special lanes and disable it
534  FXMenuCommand* transformLaneToSidewalk = new FXMenuCommand(transformSlanes, "Sidewalk", pedestrianIcon, &parent, MID_GNE_LANE_TRANSFORM_SIDEWALK);
535  FXMenuCommand* transformLaneToBikelane = new FXMenuCommand(transformSlanes, "Bikelane", bikeIcon, &parent, MID_GNE_LANE_TRANSFORM_BIKE);
536  FXMenuCommand* transformLaneToBuslane = new FXMenuCommand(transformSlanes, "Buslane", busIcon, &parent, MID_GNE_LANE_TRANSFORM_BUS);
537  FXMenuCommand* revertTransformation = new FXMenuCommand(transformSlanes, "revert transformation", 0, &parent, MID_GNE_LANE_REVERT_TRANSFORMATION);
538  // add menuCascade for lane operations
539  FXMenuCascade* cascadeAddSpecialLane = new FXMenuCascade(ret, ("add special" + toString(SUMO_TAG_LANE)).c_str(), 0, addSpecialLanes);
540  FXMenuCascade* cascadeRemoveSpecialLane = new FXMenuCascade(ret, ("remove special" + toString(SUMO_TAG_LANE)).c_str(), 0, removeSpecialLanes);
541  new FXMenuCascade(ret, ("transform to special" + toString(SUMO_TAG_LANE)).c_str(), 0, transformSlanes);
542  // Enable and disable options depending of current transform of the lane
543  if (edgeHasSidewalk) {
544  transformLaneToSidewalk->disable();
545  addSidewalk->disable();
546  removeSidewalk->enable();
547  }
548  if (edgeHasBikelane) {
549  transformLaneToBikelane->disable();
550  addBikelane->disable();
551  removeBikelane->enable();
552  }
553  if (edgeHasBuslane) {
554  transformLaneToBuslane->disable();
555  addBuslane->disable();
556  removeBuslane->enable();
557  }
558  // Check if cascade menus must be disabled
559  if (edgeHasSidewalk && edgeHasBikelane && edgeHasBuslane) {
560  cascadeAddSpecialLane->disable();
561  }
562  if (!edgeHasSidewalk && !edgeHasBikelane && !edgeHasBuslane) {
563  cascadeRemoveSpecialLane->disable();
564  }
565  // Enable or disable revert transformation
567  revertTransformation->enable();
568  } else {
569  revertTransformation->disable();
570  }
571  }
572  } else if (editMode == GNE_MODE_TLS) {
573  myTLSEditor = static_cast<GNEViewNet&>(parent).getViewParent()->getTLSEditorFrame();
575  new FXMenuCommand(ret, "Select state for all links from this edge:", 0, 0, 0);
576  const std::vector<std::string> names = GNEInternalLane::LinkStateNames.getStrings();
577  for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
578  FXuint state = GNEInternalLane::LinkStateNames.get(*it);
579  FXMenuRadio* mc = new FXMenuRadio(ret, (*it).c_str(), this, FXDataTarget::ID_OPTION + state);
580  mc->setSelBackColor(MFXUtils::getFXColor(GNEInternalLane::colorForLinksState(state)));
582  }
583  }
584  } else {
585  FXMenuCommand* mc = new FXMenuCommand(ret, "Additional options available in 'Inspect Mode'", 0, 0, 0);
586  mc->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), 0);
587  }
588  // buildShowParamsPopupEntry(ret, false);
589  new FXMenuSeparator(ret);
590  const double pos = getShape().nearest_offset_to_point2D(parent.getPositionInformation());
591  const double height = getShape().positionAtOffset2D(getShape().nearest_offset_to_point2D(parent.getPositionInformation())).z();
592  new FXMenuCommand(ret, ("Shape pos: " + toString(pos)).c_str(), 0, 0, 0);
593  new FXMenuCommand(ret, ("Length pos: " + toString(pos * getLaneParametricLength() / getLaneShapeLength())).c_str(), 0, 0, 0);
594  new FXMenuCommand(ret, ("Height: " + toString(height)).c_str(), 0, 0, 0);
595  // new FXMenuSeparator(ret);
596  // buildPositionCopyEntry(ret, false);
597 
598  // let the GNEViewNet store the popup position
599  (dynamic_cast<GNEViewNet&>(parent)).markPopupPosition();
600  return ret;
601 }
602 
603 
607  new GUIParameterTableWindow(app, *this, 2);
608  // add items
609  ret->mkItem("length [m]", false, myParentEdge.getNBEdge()->getLength());
610  // close building
611  ret->closeBuilding();
612  return ret;
613 }
614 
615 
616 Boundary
619  b.grow(10);
620  return b;
621 }
622 
623 
624 const PositionVector&
627 }
628 
629 
630 const std::vector<double>&
632  return myShapeRotations;
633 }
634 
635 
636 const std::vector<double>&
638  return myShapeLengths;
639 }
640 
641 
642 Boundary
645 }
646 
647 
648 void
650  // Clear containers
651  myShapeRotations.clear();
652  myShapeLengths.clear();
655  //double length = myParentEdge.getLength(); // @todo see ticket #448
656  // may be different from length
657 
658  // Obtain lane and shape rotations
659  int segments = (int) getShape().size() - 1;
660  if (segments >= 0) {
661  myShapeRotations.reserve(segments);
662  myShapeLengths.reserve(segments);
663  for (int i = 0; i < segments; ++i) {
664  const Position& f = getShape()[i];
665  const Position& s = getShape()[i + 1];
666  myShapeLengths.push_back(f.distanceTo2D(s));
667  myShapeRotations.push_back((double) atan2((s.x() - f.x()), (f.y() - s.y())) * (double) 180.0 / (double)M_PI);
668  }
669  }
670  // Update geometry of additionals vinculated with this lane
671  for (AdditionalVector::iterator i = myAdditionals.begin(); i != myAdditionals.end(); i++) {
672  (*i)->updateGeometry();
673  }
674  // In Move mode, connections aren't updated
676  // Update incoming connections of this lane
677  std::vector<GNEConnection*> incomingConnections = getGNEIncomingConnections();
678  for (std::vector<GNEConnection*>::iterator i = incomingConnections.begin(); i != incomingConnections.end(); i++) {
679  (*i)->updateGeometry();
680  }
681  // Update outgoings connections of this lane
682  std::vector<GNEConnection*> outGoingConnections = getGNEOutcomingConnections();
683  for (std::vector<GNEConnection*>::iterator i = outGoingConnections.begin(); i != outGoingConnections.end(); i++) {
684  (*i)->updateGeometry();
685  }
686  }
687  // If lane has enought length for show textures of restricted lanes
688  if ((getLaneShapeLength() > 4)) {
689  // if lane is restricted
691  // get values for position and rotation of icons
692  for (int i = 2; i < getLaneShapeLength() - 1; i += 15) {
693  myLaneRestrictedTexturePositions.push_back(getShape().positionAtOffset(i));
694  myLaneRestrictedTextureRotations.push_back(getShape().rotationDegreeAtOffset(i));
695  }
696  }
697  }
698 }
699 
700 int
702  return myIndex;
703 }
704 
705 void
706 GNELane::setIndex(int index) {
707  myIndex = index;
709 }
710 
711 
712 double
715 }
716 
717 
718 double
720  double laneParametricLenght = myParentEdge.getNBEdge()->getLoadedLength();
721  if (laneParametricLenght > 0) {
722  return laneParametricLenght;
723  } else {
724  throw ProcessError("Lane Parametric Lenght cannot be never 0");
725  }
726 }
727 
728 
729 double
731  return getShape().length();
732 }
733 
734 void
736  // Check if additional exist before remove
737  if (std::find(myAdditionals.begin(), myAdditionals.end(), additional) == myAdditionals.end()) {
738  myAdditionals.push_back(additional);
739  } else {
740  throw ProcessError(toString(getTag()) + " with ID='" + additional->getID() + "' was already inserted in lane with ID='" + getID() + "'");
741  }
742 }
743 
744 
745 void
747  AdditionalVector::iterator it = std::find(myAdditionals.begin(), myAdditionals.end(), additional);
748  // Check if additional exist before remove
749  if (it != myAdditionals.end()) {
750  myAdditionals.erase(it);
751  } else {
752  throw ProcessError(toString(getTag()) + " with ID='" + additional->getID() + "' doesn't exist in lane with ID='" + getID() + "'");
753  }
754 }
755 
756 
757 const std::vector<GNEAdditional*>&
759  return myAdditionals;
760 }
761 
762 
763 bool
765  return myParentEdge.getNBEdge()->getPermissions(myIndex) == vclass;
766 }
767 
768 
769 std::string
771  const NBEdge* edge = myParentEdge.getNBEdge();
772  switch (key) {
773  case SUMO_ATTR_ID:
774  return getMicrosimID();
775  case SUMO_ATTR_SPEED:
776  return toString(edge->getLaneSpeed(myIndex));
777  case SUMO_ATTR_ALLOW:
779  case SUMO_ATTR_DISALLOW:
781  case SUMO_ATTR_WIDTH:
783  return "default";
784  } else {
785  return toString(edge->getLaneStruct(myIndex).width);
786  }
787  case SUMO_ATTR_ENDOFFSET:
788  return toString(edge->getLaneStruct(myIndex).endOffset);
790  return toString(edge->getLaneStruct(myIndex).accelRamp);
792  return toString(edge->getLaneStruct(myIndex).customShape);
793  case SUMO_ATTR_INDEX:
794  return toString(myIndex);
795  default:
796  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
797  }
798 }
799 
800 std::string
802  std::string result = getAttribute(key);
803  if ((key == SUMO_ATTR_ALLOW || key == SUMO_ATTR_DISALLOW) && result.find("all") != std::string::npos) {
804  result += " " + getVehicleClassNames(SVCAll, true);
805  }
806  return result;
807 }
808 
809 
810 void
811 GNELane::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
812  switch (key) {
813  case SUMO_ATTR_ID:
814  throw InvalidArgument("Modifying attribute '" + toString(key) + "' of " + toString(getTag()) + " isn't allowed");
815  case SUMO_ATTR_SPEED:
816  case SUMO_ATTR_ALLOW:
817  case SUMO_ATTR_DISALLOW:
818  case SUMO_ATTR_WIDTH:
819  case SUMO_ATTR_ENDOFFSET:
822  case SUMO_ATTR_INDEX:
823  // no special handling
824  undoList->p_add(new GNEChange_Attribute(this, key, value));
825  break;
826  default:
827  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
828  }
829 }
830 
831 
832 bool
833 GNELane::isValid(SumoXMLAttr key, const std::string& value) {
834  switch (key) {
835  case SUMO_ATTR_ID:
836  return false;
837  case SUMO_ATTR_SPEED:
838  return canParse<double>(value);
839  case SUMO_ATTR_ALLOW:
840  case SUMO_ATTR_DISALLOW:
841  return canParseVehicleClasses(value);
842  case SUMO_ATTR_WIDTH:
843  if (value == "default") {
844  return true;
845  } else {
846  return canParse<double>(value) && (isPositive<double>(value) || parse<double>(value) == NBEdge::UNSPECIFIED_WIDTH);
847  }
848  case SUMO_ATTR_ENDOFFSET:
849  return canParse<double>(value);
851  return canParse<bool>(value);
852  case SUMO_ATTR_CUSTOMSHAPE: {
853  bool ok = true;
854  PositionVector shape = GeomConvHelper::parseShapeReporting(value, "user-supplied position", 0, ok, true);
855  return ok;
856  }
857  case SUMO_ATTR_INDEX:
858  return canParse<int>(value) && (parse<int>(value) == myIndex);
859  default:
860  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
861  }
862 }
863 
864 
865 void
867  mySpecialColor = color;
868 }
869 
870 // ===========================================================================
871 // private
872 // ===========================================================================
873 
874 void
875 GNELane::setAttribute(SumoXMLAttr key, const std::string& value) {
876  NBEdge* edge = myParentEdge.getNBEdge();
877  switch (key) {
878  case SUMO_ATTR_ID:
879  throw InvalidArgument("Modifying attribute '" + toString(key) + "' of " + toString(getTag()) + " isn't allowed");
880  case SUMO_ATTR_SPEED:
881  edge->setSpeed(myIndex, parse<double>(value));
882  break;
883  case SUMO_ATTR_ALLOW:
885  updateGeometry();
886  myNet->getViewNet()->update();
887  break;
888  case SUMO_ATTR_DISALLOW:
890  updateGeometry();
891  myNet->getViewNet()->update();
892  break;
893  case SUMO_ATTR_WIDTH:
894  if (value == "default") {
896  } else {
897  edge->setLaneWidth(myIndex, parse<double>(value));
898  }
899  updateGeometry();
900  myNet->getViewNet()->update();
901  break;
902  case SUMO_ATTR_ENDOFFSET:
903  edge->setEndOffset(myIndex, parse<double>(value));
904  break;
906  edge->setAcceleration(myIndex, parse<bool>(value));
907  break;
908  case SUMO_ATTR_CUSTOMSHAPE: {
909  bool ok;
910  edge->setLaneShape(myIndex, GeomConvHelper::parseShapeReporting(value, "user-supplied position", 0, ok, true));
911  break;
912  }
913  default:
914  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
915  }
916 }
917 
918 
919 bool
920 GNELane::setFunctionalColor(int activeScheme) const {
921  switch (activeScheme) {
922  case 6: {
923  double hue = GeomHelper::naviDegree(getShape().beginEndAngle()); // [0-360]
925  return true;
926  }
927  default:
928  return false;
929  }
930 }
931 
932 
933 bool
935  const int activeScheme = c.getActive();
936  myShapeColors.clear();
937  switch (activeScheme) {
938  case 9: // color by height at segment start
939  for (PositionVector::const_iterator ii = getShape().begin(); ii != getShape().end() - 1; ++ii) {
940  myShapeColors.push_back(c.getScheme().getColor(ii->z()));
941  }
942  return true;
943  case 11: // color by inclination at segment start
944  for (int ii = 1; ii < (int)getShape().size(); ++ii) {
945  const double inc = (getShape()[ii].z() - getShape()[ii - 1].z()) / MAX2(POSITION_EPS, getShape()[ii].distanceTo2D(getShape()[ii - 1]));
946  myShapeColors.push_back(c.getScheme().getColor(inc));
947  }
948  return true;
949  default:
950  return false;
951  }
952 }
953 
954 
955 double
956 GNELane::getColorValue(int activeScheme) const {
957  const SVCPermissions myPermissions = myParentEdge.getNBEdge()->getPermissions(myIndex);
958  switch (activeScheme) {
959  case 0:
960  switch (myPermissions) {
961  case SVC_PEDESTRIAN:
962  return 1;
963  case SVC_BICYCLE:
964  return 2;
965  case 0:
966  return 3;
967  case SVC_SHIP:
968  return 4;
969  default:
970  break;
971  }
972  if ((myPermissions & SVC_PASSENGER) != 0 || isRailway(myPermissions)) {
973  return 0;
974  } else {
975  return 5;
976  }
977  case 1:
978  return gSelected.isSelected(getType(), getGlID()) ||
979  gSelected.isSelected(GLO_EDGE, dynamic_cast<GNEEdge*>(&myParentEdge)->getGlID());
980  case 2:
981  return (double)myPermissions;
982  case 3:
984  case 4:
985  return myParentEdge.getNBEdge()->getNumLanes();
986  case 5: {
988  }
989  // case 6: by angle (functional)
990  case 7: {
991  return myParentEdge.getNBEdge()->getPriority();
992  }
993  case 8: {
994  // color by z of first shape point
995  return getShape()[0].z();
996  }
997  // case 9: by segment height
998  case 10: {
999  // color by incline
1000  return (getShape()[-1].z() - getShape()[0].z()) / myParentEdge.getNBEdge()->getLength();
1001  }
1002  }
1003  return 0;
1004 }
1005 
1006 
1007 bool
1010 }
1011 
1012 
1013 bool
1015  return isWaterway(myParentEdge.getNBEdge()->getPermissions(myIndex)) && s.showRails; // reusing the showRails setting
1016 }
1017 
1018 
1019 void
1020 GNELane::drawCrossties(double length, double spacing, double halfWidth) const {
1021  glPushMatrix();
1022  // draw on top of of the white area between the rails
1023  glTranslated(0, 0, 0.1);
1024  int e = (int) getShape().size() - 1;
1025  for (int i = 0; i < e; ++i) {
1026  glPushMatrix();
1027  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.0);
1028  glRotated(myShapeRotations[i], 0, 0, 1);
1029  for (double t = 0; t < myShapeLengths[i]; t += spacing) {
1030  glBegin(GL_QUADS);
1031  glVertex2d(-halfWidth, -t);
1032  glVertex2d(-halfWidth, -t - length);
1033  glVertex2d(halfWidth, -t - length);
1034  glVertex2d(halfWidth, -t);
1035  glEnd();
1036  }
1037  glPopMatrix();
1038  }
1039  glPopMatrix();
1040 }
1041 
1042 
1043 void
1045  const double width = myParentEdge.getNBEdge()->getLaneWidth(myIndex);
1046  glColor3d(0.3, 0.3, 0.3);
1047  glPushMatrix();
1048  glTranslated(0, 0, GLO_JUNCTION + 0.1);
1049  int e = (int) getShape().size() - 1;
1050  for (int i = 0; i < e; ++i) {
1051  glPushMatrix();
1052  glTranslated(getShape()[i].x(), getShape()[i].y(), 0.1);
1053  glRotated(myShapeRotations[i], 0, 0, 1);
1054  for (double t = 0; t < myShapeLengths[i]; t += width) {
1055  const double length = MIN2(width * 0.5, myShapeLengths[i] - t);
1056  glBegin(GL_TRIANGLES);
1057  glVertex2d(0, -t - length);
1058  glVertex2d(-width * 0.25, -t);
1059  glVertex2d(+width * 0.25, -t);
1060  glEnd();
1061  }
1062  glPopMatrix();
1063  }
1064  glPopMatrix();
1065 }
1066 
1067 
1068 
1069 const std::string&
1071  return myParentEdge.getMicrosimID();
1072 }
1073 
1074 
1075 long
1076 GNELane::onDefault(FXObject* obj, FXSelector sel, void* data) {
1077  if (myTLSEditor != 0) {
1078  myTLSEditor->handleMultiChange(this, obj, sel, data);
1079  }
1080  return 1;
1081 }
1082 
1083 
1084 GNEEdge&
1086  return myParentEdge;
1087 }
1088 
1089 
1090 std::vector<GNEConnection*>
1092  // Declare a vector to save incoming connections
1093  std::vector<GNEConnection*> incomingConnections;
1094  // Obtain incoming edges if junction source was already created
1095  GNEJunction* junctionSource = myParentEdge.getGNEJunctionSource();
1096  if (junctionSource) {
1097  // Iterate over incoming GNEEdges of junction
1098  for (std::vector<GNEEdge*>::const_iterator i = junctionSource->getGNEIncomingEdges().begin(); i != junctionSource->getGNEIncomingEdges().end(); i++) {
1099  // Iterate over connection of incoming edges
1100  for (std::vector<GNEConnection*>::const_iterator j = (*i)->getGNEConnections().begin(); j != (*i)->getGNEConnections().end(); j++) {
1101  if ((*j)->getNBEdgeConnection().fromLane == getIndex()) {
1102  incomingConnections.push_back(*j);
1103  }
1104  }
1105  }
1106  }
1107  return incomingConnections;
1108 }
1109 
1110 
1111 std::vector<GNEConnection*>
1113  // Obtain GNEConnection of edge parent
1114  const std::vector<GNEConnection*>& edgeConnections = myParentEdge.getGNEConnections();
1115  std::vector<GNEConnection*> outcomingConnections;
1116  // Obtain outgoing connections
1117  for (std::vector<GNEConnection*>::const_iterator i = edgeConnections.begin(); i != edgeConnections.end(); i++) {
1118  if ((*i)->getNBEdgeConnection().fromLane == getIndex()) {
1119  outcomingConnections.push_back(*i);
1120  }
1121  }
1122  return outcomingConnections;
1123 }
1124 
1125 
1126 void
1128  // update incoming connections of lane
1129  std::vector<GNEConnection*> incomingConnections = getGNEIncomingConnections();
1130  for (std::vector<GNEConnection*>::iterator i = incomingConnections.begin(); i != incomingConnections.end(); i++) {
1131  (*i)->updateID();
1132  }
1133  // update outocming connections of lane
1134  std::vector<GNEConnection*> outcomingConnections = getGNEOutcomingConnections();
1135  for (std::vector<GNEConnection*>::iterator i = outcomingConnections.begin(); i != outcomingConnections.end(); i++) {
1136  (*i)->updateID();
1137  }
1138 }
1139 
1140 /****************************************************************************/
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition: GNELane.cpp:1014
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
double getLaneShapeLength() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:730
EditMode getCurrentEditMode() const
get the current edit mode
The link is a partial left direction.
std::string getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a &#39; &#39;.
double z() const
Returns the z-position.
Definition: Position.h:73
std::vector< double > myShapeLengths
The lengths of the shape parts.
Definition: GNELane.h:221
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.
Definition: GNELane.cpp:1070
double scale
information about a lane&#39;s width (temporary, used for a single view)
double laneWidthExaggeration
The lane exaggeration (upscale thickness)
GNEJunction * getGNEJunctionSource() const
returns the source-junction
Definition: GNEEdge.cpp:194
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:250
PositionVector shape
The lane&#39;s shape.
Definition: NBEdge.h:127
whether a given shape is user-defined
GNENet * myNet
the net to inform about updates
is a pedestrian
mode for moving things
Definition: GNEViewNet.h:53
GNETLSEditorFrame * myTLSEditor
the tls-editor for setting multiple links in TLS-mode
Definition: GNELane.h:240
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:172
AdditionalVector myAdditionals
list with the additionals vinculated with this lane
Definition: GNELane.h:231
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
remove inner geometry
Definition: GUIAppEnum.h:654
begin/end of the description of a single lane
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNELane.cpp:456
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
NBNode * myTo
Definition: NBEdge.h:1360
void setEndOffset(int lane, double offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2913
const RGBColor * mySpecialColor
optional special color
Definition: GNELane.h:234
static const RGBColor selectedLaneColor
color of selected lane
Definition: GNENet.h:106
static void drawTextAtEnd(const std::string &text, const PositionVector &shape, double x, double size, RGBColor color)
draw text and the end of shape
Definition: GLHelper.cpp:513
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb.
Definition: RGBColor.cpp:302
std::vector< Connection > getConnectionsFromLane(int lane) const
Returns connections from a given lane.
Definition: NBEdge.cpp:1023
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn&#39;t set.
Definition: NBEdge.h:491
Copy edge name (for lanes only)
Definition: GUIAppEnum.h:237
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
int getConnectionIndex(const NBEdge *from, const NBEdge::Connection &con) const
return the index of the given connection
Definition: NBNode.cpp:2647
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2929
GUIColorer laneColorer
The lane colorer.
double x() const
Returns the x-position.
Definition: Position.h:63
Stores the information about how to visualize structures.
This is an uncontrolled, minor link, has to stop.
vehicle is a bicycle
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition: GNELane.cpp:764
const std::vector< GNEAdditional * > & getAdditionalChilds() const
get additional childs of lane
Definition: GNELane.cpp:758
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
void removeAdditionalChild(GNEAdditional *additional)
remove additional child to this lane
Definition: GNELane.cpp:746
std::string getAttributeForSelection(SumoXMLAttr key) const
method for getting the attribute in the context of object selection
Definition: GNELane.cpp:801
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:71
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
bool hasRestrictedLane(SUMOVehicleClass vclass) const
check if edge has a restricted lane
Definition: GNEEdge.cpp:1251
mode for editing tls
Definition: GNEViewNet.h:63
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
bool setFunctionalColor(int activeScheme) const
sets the color according to the current scheme index and some lane function
Definition: GNELane.cpp:920
T MAX2(T a, T b)
Definition: StdDefs.h:74
double getColorValue(int activeScheme) const
return value for lane coloring according to the given scheme
Definition: GNELane.cpp:956
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:2960
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)
remove bikelane
Definition: GUIAppEnum.h:684
bool showLaneDirection
Whether to show direction indicators for lanes.
bool setMultiColor(const GUIColorer &c) const
sets multiple colors according to the current scheme index and some lane function ...
Definition: GNELane.cpp:934
double endOffset
This lane&#39;s offset to the intersection begin.
Definition: NBEdge.h:139
bool laneShowBorders
Information whether lane borders shall be drawn.
GNELane()
FOX needs this.
Definition: GNELane.cpp:84
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition: GNELane.h:237
This is an uncontrolled, right-before-left link.
const double SUMO_const_laneOffset
Definition: StdDefs.h:53
const std::vector< GNEConnection * > & getGNEConnections()
returns a reference to the GNEConnection vector
Definition: GNEEdge.cpp:605
void handleMultiChange(GNELane *lane, FXObject *obj, FXSelector sel, void *data)
update phase definition for the current traffic light and phase
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
const SVCPermissions SVCAll
all VClasses are allowed
Lane & getLaneStruct(int lane)
Definition: NBEdge.h:1161
The link is controlled by a tls which is off, not blinking, may pass.
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:643
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:701
GUIGlID getGlID() const
Returns the numerical id of the object.
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:256
void setIndex(int index)
Definition: GNELane.cpp:706
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
int myIndex
The index of this lane.
Definition: GNELane.h:213
This is an uncontrolled, zipper-merge link.
The link is a (hard) left direction.
transform lane to sidewalk
Definition: GUIAppEnum.h:668
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
void setLaneShape(int lane, const PositionVector &shape)
sets a custom lane shape
Definition: NBEdge.cpp:2952
bool accelRamp
Whether this lane is an acceleration lane.
Definition: NBEdge.h:151
void setAcceleration(int lane, bool accelRamp)
marks one lane as acceleration lane
Definition: NBEdge.cpp:2944
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition: GNELane.h:227
SVCPermissions invertPermissions(SVCPermissions permissions)
negate the given permissions and ensure that only relevant bits are set
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.
double getSpeed() const
returns the current speed of lane
Definition: GNELane.cpp:713
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:1008
void drawDirectionIndicators() const
direction indicators for lanes
Definition: GNELane.cpp:1044
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
remove busLane
Definition: GUIAppEnum.h:686
static double naviDegree(const double angle)
Definition: GeomHelper.cpp:187
transform lane to busLane
Definition: GUIAppEnum.h:672
void drawLane2LaneConnections() const
draw lane to lane connections
Definition: GNELane.cpp:220
double getLaneWidth() const
Returns the default width of lanes of this edge.
Definition: NBEdge.h:524
void drawArrows() const
draw arrows
Definition: GNELane.cpp:150
int getPriority() const
Returns the priority of the edge.
Definition: NBEdge.h:421
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:438
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1085
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Definition: GNELane.cpp:811
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS Link Number
Definition: GNELane.cpp:122
set non-default geometry endpoint
Definition: GUIAppEnum.h:650
This is an uncontrolled, minor link, has to brake.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
const std::vector< double > & getShapeRotations() const
returns the vector with the shape rotations
Definition: GNELane.cpp:631
void addAdditionalChild(GNEAdditional *additional)
add additional child to this lane
Definition: GNELane.cpp:735
A list of positions.
bool isLogicValid()
whether this junction has a valid logic
bool isWaterway(SVCPermissions permissions)
Returns whether an edge with the given permission is a waterway edge.
std::vector< double > myShapeRotations
Definition: GNELane.h:218
friend class GNEChange_Attribute
declare friend class
double y() const
Returns the y-position.
Definition: Position.h:68
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1091
revert transformation
Definition: GUIAppEnum.h:674
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:414
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 double value) const
double length() const
Returns the length.
GUIVisualizationTextSettings drawLinkTLIndex
T MIN2(T a, T b)
Definition: StdDefs.h:68
static void drawOutlineCircle(double width, double iwidth, int steps=8)
Draws an unfilled circle around (0,0)
Definition: GLHelper.cpp:370
The link is a (hard) right direction.
#define POSITION_EPS
Definition: config.h:176
LinkState getLinkState(const NBEdge *incoming, NBEdge *outgoing, int fromLane, int toLane, bool mayDefinitelyPass, const std::string &tlID) const
get link state
Definition: NBNode.cpp:1606
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:302
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
void drawMarkings(const bool &selectedEdge, double scale) const
draw lane markings
Definition: GNELane.cpp:411
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:265
const std::string getID() const
function to support debugging
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition: GNELane.cpp:1112
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:1539
std::vector< Connection > myConnections
List of connections to following edges.
Definition: NBEdge.h:1381
double laneMinSize
The minimum visual lane width for drawing.
The link is a partial right direction.
double width
This lane&#39;s width.
Definition: NBEdge.h:142
vehicle is a passenger car (a "normal" car)
void updateGeometry()
update pre-computed geometry information
Definition: GNELane.cpp:649
is an arbitrary ship
begin/end of the description of an edge
duplicate a lane
Definition: GUIAppEnum.h:666
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
std::string getAttribute(SumoXMLAttr key) const
This functions has to be implemented in allGNEAttributeCarrier.
Definition: GNELane.cpp:770
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:58
reverse an edge
Definition: GUIAppEnum.h:642
const std::vector< double > & getShapeLengths() const
returns the vector with the shape lengths
Definition: GNELane.cpp:637
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition: NBEdge.cpp:2988
add reverse edge
Definition: GUIAppEnum.h:644
void drawLinkRules() const
draw link rules
Definition: GNELane.cpp:145
GNEEdge & myParentEdge
The Edge that to which this lane belongs.
Definition: GNELane.h:210
vehicle is a bus
add busLane
Definition: GUIAppEnum.h:680
double getLaneSpeed(int lane) const
get lane speed
Definition: NBEdge.cpp:1631
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:435
double getLength() const
Returns the computed length of the edge.
Definition: NBEdge.h:482
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:625
bool showLinkDecals
Information whether link textures (arrows) shall be drawn.
double selectionScale
the current selection scaling in NETEDIT (temporary)
void updateConnectionIDs()
Definition: GNELane.cpp:1127
long onDefault(FXObject *, FXSelector, void *)
multiplexes message to two targets
Definition: GNELane.cpp:1076
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
#define M_PI
Definition: odrSpiral.cpp:40
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:62
The link is controlled by a tls which is off and blinks, has to brake.
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition: GNELane.h:224
void setSpecialColor(const RGBColor *Color2)
Definition: GNELane.cpp:866
The popup menu of a globject.
an edge
transform lane to bikelane
Definition: GUIAppEnum.h:670
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:617
static const StringBijection< FXuint > LinkStateNames
long names for link states
split an edge
Definition: GUIAppEnum.h:638
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition: MFXUtils.cpp:121
Represents a single node (junction) during network building.
Definition: NBNode.h:75
add bikelane
Definition: GUIAppEnum.h:678
T get(const std::string &str) const
void insertMenuPaneChild(FXMenuPane *child)
Insert a sub-menu pane in this GUIGLObjectPopupMenu.
The link is a 180 degree turn (left-hand network)
SumoXMLTag getTag() const
get XML Tag assigned to this object
GUIVisualizationSettings * getVisualisationSettings() const
get visualitation settings
static void drawTriangleAtEnd(const Position &p1, const Position &p2, double tLength, double tWidth)
Draws a triangle at the end of the given line.
Definition: GLHelper.cpp:417
void drawCrossties(double length, double spacing, double halfWidth) const
draw crossties for railroads
Definition: GNELane.cpp:1020
std::string getLaneID(int lane) const
get Lane ID (Secure)
Definition: NBEdge.cpp:2746
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
static const RGBColor selectionColor
Definition: GNENet.h:103
mode for connecting lanes
Definition: GNEViewNet.h:61
mode for creating new edges
Definition: GNEViewNet.h:51
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:126
bool isValid(SumoXMLAttr key, const std::string &value)
Definition: GNELane.cpp:833
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:306
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition: GNELane.cpp:719
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:605
GUISelectedStorage gSelected
A global holder of selected objects.
PositionVector customShape
A custom shape for this lane set by the user.
Definition: NBEdge.h:158
A window containing a gl-object&#39;s parameter.
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1519
restore geometry endpoint to node position
Definition: GUIAppEnum.h:652
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
split an edge
Definition: GUIAppEnum.h:640
GUIVisualizationTextSettings drawLinkJunctionIndex
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
Definition: NBEdge.cpp:770
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNELane.cpp:270
static PositionVector parseShapeReporting(const std::string &shpdef, const std::string &objecttype, const char *objectid, bool &ok, bool allowEmpty, bool report=true)
Builds a PositionVector from a string representation, reporting occured errors.
~GNELane()
Destructor.
Definition: GNELane.cpp:93
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2874
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition: GNELane.cpp:98
The link has no direction (is a dead end link)
a junction
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:200
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:444