Eclipse SUMO - Simulation of Urban MObility
GNEConnection.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // A class for visualizing connections between lanes
19 /****************************************************************************/
20 #include <config.h>
21 
23 #include <netedit/GNENet.h>
24 #include <netedit/GNEUndoList.h>
25 #include <netedit/GNEViewNet.h>
28 #include <utils/gui/div/GLHelper.h>
35 
36 #include "GNEConnection.h"
37 #include "GNEInternalLane.h"
38 
39 
40 // ===========================================================================
41 // static member definitions
42 // ===========================================================================
43 static const int NUM_POINTS = 5;
44 
45 // ===========================================================================
46 // method definitions
47 // ===========================================================================
48 
50  GNENetworkElement(from->getNet(), "from" + from->getID() + "to" + to->getID(),
51  GLO_CONNECTION, SUMO_TAG_CONNECTION, GUIIconSubSys::getIcon(GUIIcon::CONNECTION), {}, {}, {}, {}, {}, {}),
52  myFromLane(from),
53  myToLane(to),
54  myLinkState(LINKSTATE_TL_OFF_NOSIGNAL),
55  mySpecialColor(nullptr),
56 myShapeDeprecated(true) {
57  // update centering boundary without updating grid
58  updateCenteringBoundary(false);
59 }
60 
61 
63 }
64 
65 
66 const PositionVector&
68  if (myConnectionGeometry.getShape().size() > 0) {
70  } else {
72  }
73 }
74 
75 
76 void
78  // Get shape of from and to lanes
79  const NBEdge::Connection& nbCon = getNBEdgeConnection();
80  if (myShapeDeprecated) {
81  // obtain lane shape from
82  PositionVector laneShapeFrom;
83  if ((int)getEdgeFrom()->getNBEdge()->getLanes().size() > nbCon.fromLane) {
84  laneShapeFrom = getEdgeFrom()->getNBEdge()->getLanes().at(nbCon.fromLane).shape;
85  } else {
86  return;
87  }
88  // obtain lane shape to
89  PositionVector laneShapeTo;
90  if ((int)nbCon.toEdge->getLanes().size() > nbCon.toLane) {
91  laneShapeTo = nbCon.toEdge->getLanes().at(nbCon.toLane).shape;
92  } else {
93  return;
94  }
95  // Calculate shape of connection depending of the size of Junction shape
96  // value obtained from GNEJunction::drawgl
97  if (nbCon.customShape.size() != 0) {
99  } else if (getEdgeFrom()->getNBEdge()->getToNode()->getShape().area() > 4) {
100  if (nbCon.shape.size() > 1) {
101  PositionVector connectionShape;
102  if (nbCon.shape.front() == nbCon.shape.back()) {
103  laneShapeFrom.move2side(0.7);
104  laneShapeTo.move2side(0.7);
105  connectionShape.push_back(laneShapeFrom.back());
106  connectionShape.push_back(laneShapeTo.front());
107  } else {
108  connectionShape = nbCon.shape;
109  }
110  // only append via shape if it exists
111  if (nbCon.haveVia) {
112  connectionShape.append(nbCon.viaShape);
113  }
114  myConnectionGeometry.updateGeometry(connectionShape);
115  } else {
116  // Calculate shape so something can be drawn immediately
117  myConnectionGeometry.updateGeometry(getEdgeFrom()->getNBEdge()->getToNode()->computeSmoothShape(
118  laneShapeFrom, laneShapeTo, NUM_POINTS,
119  getEdgeFrom()->getNBEdge()->getTurnDestination() == nbCon.toEdge,
120  (double) 5. * (double) getEdgeFrom()->getNBEdge()->getNumLanes(),
121  (double) 5. * (double) nbCon.toEdge->getNumLanes()));
122  }
123  } else {
124  myConnectionGeometry.updateGeometry({laneShapeFrom.positionAtOffset(MAX2(0.0, laneShapeFrom.length() - 1)),
125  laneShapeTo.positionAtOffset(MIN2(1.0, laneShapeFrom.length()))});
126  }
127  // check if internal junction marker must be calculated
128  if (nbCon.haveVia && (nbCon.shape.size() != 0)) {
129  // create marker for internal junction waiting position (contPos)
130  const double orthoLength = 0.5;
131  Position pos = nbCon.shape.back();
132  myInternalJunctionMarker = nbCon.shape.getOrthogonal(pos, 10, true, 0.1);
133  if (myInternalJunctionMarker.length() < orthoLength) {
135  }
136  } else {
137  myInternalJunctionMarker.clear();
138  }
139  // mark connection as non-deprecated
140  myShapeDeprecated = false;
141  }
142 }
143 
144 
145 Position
147  // currently unused
148  return Position(0, 0);
149 }
150 
151 
154  // edit depending if shape is being edited
155  if (isShapeEdited()) {
156  // get connection
157  const auto& connection = getNBEdgeConnection();
158  // calculate move shape operation
159  return calculateMoveShapeOperation(connection.customShape.size() > 0 ? connection.customShape : myConnectionGeometry.getShape(),
162  } else {
163  return nullptr;
164  }
165 }
166 
167 
168 void
169 GNEConnection::removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) {
170  // edit depending if shape is being edited
171  if (isShapeEdited()) {
172  // get connection
173  const auto& connection = getNBEdgeConnection();
174  // get original shape
175  PositionVector shape = connection.customShape.size() > 0 ? connection.customShape : connection.shape;
176  // check shape size
177  if (shape.size() > 2) {
178  // obtain index
179  int index = shape.indexOfClosest(clickedPosition);
180  // get snap radius
182  // check if we have to create a new index
183  if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
184  // remove geometry point
185  shape.erase(shape.begin() + index);
186  // commit new shape
187  undoList->begin(GUIIcon::CONNECTION, "remove geometry point of " + getTagStr());
189  undoList->end();
190  }
191  }
192  }
193 }
194 
195 
196 GNEEdge*
198  return myFromLane->getParentEdge();
199 }
200 
201 
202 GNEEdge*
204  return myToLane->getParentEdge();
205 }
206 
207 
208 GNELane*
210  return myFromLane;
211 }
212 
213 
214 GNELane*
216  return myToLane;
217 }
218 
219 
220 int
222  return myFromLane->getIndex();
223 }
224 
225 
226 int
228  return myToLane->getIndex();
229 }
230 
231 
235 }
236 
237 
241  return NBConnection(getEdgeFrom()->getNBEdge(), getFromLaneIndex(),
242  getEdgeTo()->getNBEdge(), getToLaneIndex(),
243  (int)c.tlLinkIndex, (int)c.tlLinkIndex2);
244 }
245 
246 
247 void
249  setMicrosimID(myFromLane->getID() + " -> " + myToLane->getID());
250 }
251 
252 
253 LinkState
255  return myLinkState;
256 }
257 
258 
259 void
261  myShapeDeprecated = true;
262 }
263 
264 
265 void
267  const NBEdge::Connection& nbCon = getNBEdgeConnection();
269  nbCon.toEdge,
270  nbCon.fromLane,
271  nbCon.toLane,
272  nbCon.mayDefinitelyPass,
273  nbCon.tlID);
274 }
275 
276 
277 void
279  auto shape = getConnectionShape();
280  shape = shape.bezier(5);
282 }
283 
284 
287  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
288  buildPopupHeader(ret, app);
291  // build selection and show parameters menu
294  // build position copy entry
295  buildPositionCopyEntry(ret, app);
296  // check if we're in supermode network
298  // create menu commands
299  FXMenuCommand* mcCustomShape = GUIDesigns::buildFXMenuCommand(ret, "Set custom connection shape", nullptr, &parent, MID_GNE_CONNECTION_EDIT_SHAPE);
300  GUIDesigns::buildFXMenuCommand(ret, "Smooth connection shape", nullptr, &parent, MID_GNE_CONNECTION_SMOOTH_SHAPE);
301  // check if menu commands has to be disabled
303  // check if we're in the correct edit mode
304  if ((editMode == NetworkEditMode::NETWORK_CONNECT) || (editMode == NetworkEditMode::NETWORK_TLS) || (editMode == NetworkEditMode::NETWORK_CREATE_EDGE)) {
305  mcCustomShape->disable();
306  }
307  }
308  return ret;
309 }
310 
311 
312 double
314  return s.addSize.getExaggeration(s, this);
315 }
316 
317 
318 void
319 GNEConnection::updateCenteringBoundary(const bool /*updateGrid*/) {
320  // calculate boundary
321  if (myConnectionGeometry.getShape().size() == 0) {
322  // we need to use the center of junction parent as boundary if shape is empty
323  const Position junctionParentPosition = myFromLane->getParentEdge()->getToJunction()->getPositionInView();
324  myBoundary = Boundary(junctionParentPosition.x() - 0.1, junctionParentPosition.y() - 0.1,
325  junctionParentPosition.x() + 0.1, junctionParentPosition.x() + 0.1);
326  } else {
328  }
329  // grow
330  myBoundary.grow(10);
331 }
332 
333 
334 void
336  // check if draw start und end
337  const bool drawExtremeSymbols = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
339  // get edited network element
341  // declare a flag to check if shape has to be draw
342  bool drawConnection = true;
343  // declare flag to check if push glID
344  bool pushGLID = true;
348  drawConnection = !myShapeDeprecated;
351  drawConnection = !myShapeDeprecated;
352  } else {
353  drawConnection = false;
354  }
355  } else {
356  drawConnection = false;
357  }
358  // check if we're editing this connection
359  if (editedNetworkElement && (editedNetworkElement->getTagProperty().getTag() == SUMO_TAG_CONNECTION)) {
360  if (editedNetworkElement->getAttribute(GNE_ATTR_PARENT) == getAttribute(GNE_ATTR_PARENT)) {
361  drawConnection = true;
362  }
363  if (editedNetworkElement != this) {
364  pushGLID = false;
365  }
366  }
367  // Check if connection must be drawed
368  if (drawConnection) {
369  // draw connection checking whether it is not too small if isn't being drawn for selecting
370  const double selectionScale = isAttributeCarrierSelected() ? s.selectorFrameScale : 1;
371  // get color
372  RGBColor connectionColor;
373  // first check if we're editing shape
374  if (myShapeEdited) {
375  connectionColor = s.colorSettings.editShapeColor;
376  } else if (drawUsingSelectColor()) {
377  // override with special colors (unless the color scheme is based on selection)
378  connectionColor = s.colorSettings.selectedConnectionColor;
379  } else if (mySpecialColor != nullptr) {
380  connectionColor = *mySpecialColor;
381  } else {
382  // Set color depending of the link state
384  }
385  // check if boundary has to be drawn
386  if (s.drawBoundaries) {
388  }
389  // Push name
390  if (pushGLID) {
392  }
393  // Push layer matrix
395  // translate to front
396  myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, GLO_CONNECTION, (editedNetworkElement == this) ? 1 : 0);
397  // Set color
398  GLHelper::setColor(connectionColor);
399  if ((s.scale * selectionScale < 5.) && !s.drawForRectangleSelection) {
400  // If it's small, draw a simple line
402  } else {
403  // draw connections geometry
404  const bool spreadSuperposed = s.scale >= 1 && s.spreadSuperposed && myFromLane->drawAsRailway(s) && getEdgeFrom()->getNBEdge()->isBidiRail();
405  PositionVector shapeSuperposed = myConnectionGeometry.getShape();
406  if (spreadSuperposed) {
407  shapeSuperposed.move2side(0.5);
408  }
410  glTranslated(0, 0, 0.1);
411  GLHelper::setColor(GLHelper::getColor().changedBrightness(51));
412  // draw arrows over connection
414  // check if internal junction marker has to be drawn
415  if (myInternalJunctionMarker.size() > 0) {
417  }
418  // draw shape points only in Network supemode
420  // color
421  const RGBColor darkerColor = connectionColor.changedBrightness(-32);
422  // draw geometry points
425  myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
426  // draw moving hint
430  }
431  }
432  // Pop layer matrix
434  // check if edge value has to be shown
435  if (s.edgeValue.show(this)) {
436  const NBEdge::Connection& nbCon = getNBEdgeConnection();
437  std::string value = nbCon.getParameter(s.edgeParam, "");
438  if (value != "") {
439  int shapeIndex = (int)myConnectionGeometry.getShape().size() / 2;
440  Position p = (myConnectionGeometry.getShape().size() == 2
441  ? (myConnectionGeometry.getShape().front() * 0.67 + myConnectionGeometry.getShape().back() * 0.33)
442  : myConnectionGeometry.getShape()[shapeIndex]);
443  GLHelper::drawTextSettings(s.edgeValue, value, p, s.scale, 0);
444  }
445  }
446  // Pop name
447  if (pushGLID) {
449  }
450  // draw lock icon
452  // check if mouse is over element
454  // inspect contour
456  // use drawDottedContourGeometry to draw it
458  }
459  // front contour
460  if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
461  // use drawDottedContourGeometry to draw it
463  }
464  // delete contour
465  if (myNet->getViewNet()->drawDeleteContour(this, this)) {
466  // use drawDottedContourGeometry to draw it
468  }
469  // select contour
470  if (myNet->getViewNet()->drawSelectContour(this, this)) {
471  // use drawDottedContourGeometry to draw it
473  }
474  }
475  }
476 }
477 
478 
479 void
482 }
483 
484 
485 void
487  updateGeometry();
488 }
489 
490 
491 void
493  mySpecialColor = color;
494 }
495 
496 
497 std::string
499  if (key == SUMO_ATTR_ID) {
500  // used by GNEReferenceCounter
501  // @note: may be called for connections without a valid nbCon reference
502  return getMicrosimID();
503  }
504  const NBEdge::Connection& nbCon = getNBEdgeConnection();
505  switch (key) {
506  case SUMO_ATTR_FROM:
507  return getEdgeFrom()->getID();
508  case SUMO_ATTR_TO:
509  return nbCon.toEdge->getID();
510  case SUMO_ATTR_FROM_LANE:
511  return toString(nbCon.fromLane);
512  case SUMO_ATTR_TO_LANE:
513  return toString(nbCon.toLane);
514  case SUMO_ATTR_PASS:
515  return toString(nbCon.mayDefinitelyPass);
516  case SUMO_ATTR_INDIRECT:
517  return toString(nbCon.indirectLeft);
518  case SUMO_ATTR_TYPE:
519  return toString(nbCon.edgeType);
521  return toString(nbCon.keepClear);
522  case SUMO_ATTR_CONTPOS:
523  return toString(nbCon.contPos);
525  return toString(nbCon.uncontrolled);
527  return toString(nbCon.visibility);
529  return toString(nbCon.tlLinkIndex);
531  return toString(nbCon.tlLinkIndex2);
532  case SUMO_ATTR_ALLOW:
533  if (nbCon.permissions == SVC_UNSPECIFIED) {
534  return getVehicleClassNames(nbCon.toEdge->getLanes()[nbCon.toLane].permissions);
535  } else {
536  return getVehicleClassNames(nbCon.permissions);
537  }
538  case SUMO_ATTR_DISALLOW:
539  if (nbCon.permissions == SVC_UNSPECIFIED) {
540  return getVehicleClassNames(invertPermissions(nbCon.toEdge->getLanes()[nbCon.toLane].permissions));
541  } else {
543  }
545  if (nbCon.changeLeft == SVC_UNSPECIFIED) {
546  return "all";
547  } else {
548  return getVehicleClassNames(nbCon.changeLeft);
549  }
551  if (nbCon.changeRight == SVC_UNSPECIFIED) {
552  return "all";
553  } else {
554  return getVehicleClassNames(nbCon.changeRight);
555  }
556  case SUMO_ATTR_SPEED:
557  if (nbCon.speed == NBEdge::UNSPECIFIED_SPEED) {
558  return "default";
559  } else {
560  return toString(nbCon.speed);
561  }
562  case SUMO_ATTR_LENGTH:
563  return toString(nbCon.customLength);
564  case SUMO_ATTR_DIR:
565  return toString(getEdgeFrom()->getNBEdge()->getToNode()->getDirection(
566  getEdgeFrom()->getNBEdge(), nbCon.toEdge, OptionsCont::getOptions().getBool("lefthand")));
567  case SUMO_ATTR_STATE:
568  return toString(getEdgeFrom()->getNBEdge()->getToNode()->getLinkState(
569  getEdgeFrom()->getNBEdge(), nbCon.toEdge, nbCon.fromLane, nbCon.toLane, nbCon.mayDefinitelyPass, nbCon.tlID));
571  return toString(nbCon.customShape);
572  case GNE_ATTR_SELECTED:
574  case GNE_ATTR_PARAMETERS:
575  return nbCon.getParametersStr();
576  case GNE_ATTR_PARENT:
577  return getEdgeFrom()->getToJunction()->getID();
578  default:
579  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
580  }
581 }
582 
583 
584 void
585 GNEConnection::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
587  switch (key) {
588  case SUMO_ATTR_FROM:
589  case SUMO_ATTR_TO:
590  case SUMO_ATTR_FROM_LANE:
591  case SUMO_ATTR_TO_LANE:
592  case SUMO_ATTR_PASS:
594  case SUMO_ATTR_CONTPOS:
597  case SUMO_ATTR_ALLOW:
598  case SUMO_ATTR_DISALLOW:
601  case SUMO_ATTR_SPEED:
602  case SUMO_ATTR_LENGTH:
604  case SUMO_ATTR_TYPE:
605  case GNE_ATTR_SELECTED:
606  case GNE_ATTR_PARAMETERS:
607  // no special handling
608  undoList->changeAttribute(new GNEChange_Attribute(this, key, value));
609  break;
611  if (isAttributeEnabled(SUMO_ATTR_TLLINKINDEX) && (value != getAttribute(key))) {
612  changeTLIndex(key, parse<int>(value), c.tlLinkIndex2, undoList);
613  }
614  break;
616  if (isAttributeEnabled(SUMO_ATTR_TLLINKINDEX) && (value != getAttribute(key))) {
617  changeTLIndex(key, c.tlLinkIndex, parse<int>(value), undoList);
618  }
619  break;
620  case SUMO_ATTR_INDIRECT:
621  undoList->begin(GUIIcon::CONNECTION, "change attribute indirect for connection");
622  if (isAttributeEnabled(SUMO_ATTR_TLLINKINDEX) && (value != getAttribute(key))) {
623  undoList->changeAttribute(new GNEChange_Attribute(this, key, value));
624  int linkIndex2 = -1;
625  if (parse<bool>(value)) {
626  // find straight connection with the same toEdge
627  std::set<NBTrafficLightDefinition*> defs = getEdgeFrom()->getNBEdge()->getToNode()->getControllingTLS();
628  NBEdge* from = getEdgeFrom()->getNBEdge();
629  for (NBTrafficLightDefinition* tlDef : defs) {
630  for (const NBConnection& c2 : tlDef->getControlledLinks()) {
631  if (c2.getTo() == c.toEdge && c2.getFrom() != from) {
632  LinkDirection dir = from->getToNode()->getDirection(c2.getFrom(), c2.getTo());
633  if (dir == LinkDirection::STRAIGHT) {
634  linkIndex2 = c2.getTLIndex();
635  break;
636  }
637  }
638  }
639  }
640  }
641  changeTLIndex(key, c.tlLinkIndex, linkIndex2, undoList);
642  }
643  undoList->end();
644  break;
645  case SUMO_ATTR_DIR:
646  throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified");
647  case SUMO_ATTR_STATE:
648  throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified");
649  default:
650  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
651  }
652 }
653 
654 
655 void
656 GNEConnection::changeTLIndex(SumoXMLAttr key, int tlIndex, int tlIndex2, GNEUndoList* undoList) {
657  // trigger GNEChange_TLS
658  undoList->begin(GUIIcon::CONNECTION, "change tls linkIndex for connection");
659  // make a copy
660  std::set<NBTrafficLightDefinition*> defs = getEdgeFrom()->getNBEdge()->getToNode()->getControllingTLS();
661  for (const auto &tlDef : defs) {
662  NBLoadedSUMOTLDef* sumoDef = dynamic_cast<NBLoadedSUMOTLDef*>(tlDef);
663  NBTrafficLightLogic* tllogic = sumoDef ? sumoDef->getLogic() : tlDef->compute(OptionsCont::getOptions());
664  if (tllogic != nullptr) {
665  NBLoadedSUMOTLDef* newDef = new NBLoadedSUMOTLDef(*tlDef, *tllogic);
666  newDef->addConnection(getEdgeFrom()->getNBEdge(), getEdgeTo()->getNBEdge(),
667  getLaneFrom()->getIndex(), getLaneTo()->getIndex(), tlIndex, tlIndex2, false);
668  // make a copy
669  std::vector<NBNode*> nodes = tlDef->getNodes();
670  for (const auto &node : nodes) {
671  GNEJunction* junction = getNet()->getAttributeCarriers()->retrieveJunction(node->getID());
672  undoList->add(new GNEChange_TLS(junction, tlDef, false), true);
673  undoList->add(new GNEChange_TLS(junction, newDef, true), true);
674  }
675  } else {
676  WRITE_ERROR("Could not set attribute '" + toString(key) + "' (tls is broken)");
677  }
678  }
679  undoList->end();
680 }
681 
682 
683 void
685  if (s.showLaneDirection) {
686  for (int i = 1; i < (int)myConnectionGeometry.getShape().size(); i++) {
687  const auto posA = myConnectionGeometry.getShape()[i-1];
688  const auto posB = myConnectionGeometry.getShape()[i];
689  GLHelper::drawTriangleAtEnd(posA, posB, (double) 1, (double) .2);
690  }
691  }
692 }
693 
694 
695 bool
696 GNEConnection::isValid(SumoXMLAttr key, const std::string& value) {
697  // Currently ignored before implementation to avoid warnings
698  switch (key) {
699  case SUMO_ATTR_FROM:
700  case SUMO_ATTR_TO:
701  case SUMO_ATTR_FROM_LANE:
702  case SUMO_ATTR_TO_LANE:
703  return false;
704  case SUMO_ATTR_PASS:
705  return canParse<bool>(value);
706  case SUMO_ATTR_INDIRECT:
707  return canParse<bool>(value);
708  case SUMO_ATTR_TYPE:
709  return true;
711  return canParse<bool>(value);
712  case SUMO_ATTR_CONTPOS:
713  return canParse<double>(value) && (parse<double>(value) >= -1);
715  return canParse<bool>(value);
717  return canParse<double>(value) && (parse<double>(value) >= -1);
721  (getNBEdgeConnection().uncontrolled == false) &&
722  (getEdgeFrom()->getNBEdge()->getToNode()->getControllingTLS().size() > 0) &&
723  canParse<int>(value) &&
724  (parse<int>(value) >= 0 || parse<int>(value) == -1)) {
725  // obtain Traffic light definition
727  return def->getMaxValidIndex() >= parse<int>(value);
728  } else {
729  return false;
730  }
731  case SUMO_ATTR_ALLOW:
732  case SUMO_ATTR_DISALLOW:
735  return canParseVehicleClasses(value);
736  case SUMO_ATTR_SPEED:
737  if (value.empty() || value == "default") {
738  return true;
739  } else {
740  return canParse<double>(value) && ((parse<double>(value) >= 0) || (parse<double>(value) == NBEdge::UNSPECIFIED_SPEED));
741  }
742  case SUMO_ATTR_LENGTH:
743  return canParse<double>(value) && (parse<double>(value) >= -1);
744  case SUMO_ATTR_CUSTOMSHAPE: {
745  // empty custom shapes are allowed
746  return canParse<PositionVector>(value);
747  }
748  case SUMO_ATTR_STATE:
749  return false;
750  case SUMO_ATTR_DIR:
751  return false;
752  case GNE_ATTR_SELECTED:
753  return canParse<bool>(value);
754  case GNE_ATTR_PARAMETERS:
755  return Parameterised::areParametersValid(value);
756  default:
757  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
758  }
759 }
760 
761 
762 bool
764  switch (key) {
765  case SUMO_ATTR_FROM:
766  case SUMO_ATTR_TO:
767  case SUMO_ATTR_FROM_LANE:
768  case SUMO_ATTR_TO_LANE:
769  case SUMO_ATTR_DIR:
770  case SUMO_ATTR_STATE:
771  // this attributes cannot be edited
772  return false;
775  // get Traffic Light definitions
776  if (getEdgeFrom()->getNBEdge()->getToNode()->isTLControlled()) {
778  NBLoadedSUMOTLDef* sumoDef = dynamic_cast<NBLoadedSUMOTLDef*>(tlDef);
779  NBTrafficLightLogic* tllogic = sumoDef != nullptr ? sumoDef->getLogic() : tlDef->compute(OptionsCont::getOptions());
780  if (tllogic != nullptr) {
781  return true;
782  } else {
783  return false;
784  }
785  }
786  return false;
787  default:
788  return true;
789  }
790 }
791 
792 
793 bool
795  switch (key) {
796  case SUMO_ATTR_SPEED:
798  default:
799  return false;
800  }
801 }
802 
803 
804 const Parameterised::Map&
807 }
808 
809 // ===========================================================================
810 // private
811 // ===========================================================================
812 
813 void
814 GNEConnection::setAttribute(SumoXMLAttr key, const std::string& value) {
816  switch (key) {
817  case SUMO_ATTR_PASS:
818  nbCon.mayDefinitelyPass = parse<bool>(value);
819  break;
820  case SUMO_ATTR_INDIRECT:
821  nbCon.indirectLeft = parse<bool>(value);
822  break;
824  nbCon.keepClear = parse<bool>(value) ? KEEPCLEAR_TRUE : KEEPCLEAR_FALSE;
825  break;
827  nbCon.uncontrolled = parse<bool>(value);
828  break;
829  case SUMO_ATTR_CONTPOS:
830  nbCon.contPos = parse<double>(value);
831  break;
833  nbCon.visibility = parse<double>(value);
834  break;
835  case SUMO_ATTR_SPEED:
836  if (value.empty() || (value == "default")) {
838  } else {
839  nbCon.speed = parse<double>(value);
840  }
841  break;
842  case SUMO_ATTR_LENGTH:
843  nbCon.customLength = parse<double>(value);
844  break;
845  case SUMO_ATTR_ALLOW: {
846  const SVCPermissions successorAllows = nbCon.toEdge->getLanes()[nbCon.toLane].permissions;
847  SVCPermissions customPermissions = parseVehicleClasses(value);
848  if (successorAllows != customPermissions) {
849  nbCon.permissions = customPermissions;
850  }
851  break;
852  }
853  case SUMO_ATTR_DISALLOW: {
854  const SVCPermissions successorDisallows = invertPermissions(nbCon.toEdge->getLanes()[nbCon.toLane].permissions);
855  SVCPermissions customPermissions = invertPermissions(parseVehicleClasses(value));
856  if (successorDisallows != customPermissions) {
857  nbCon.permissions = customPermissions;
858  }
859  break;
860  }
861  case SUMO_ATTR_CHANGE_LEFT: {
862  nbCon.changeLeft = value == "" ? SVC_UNSPECIFIED : parseVehicleClasses(value);
863  break;
864  }
865  case SUMO_ATTR_CHANGE_RIGHT: {
866  nbCon.changeRight = value == "" ? SVC_UNSPECIFIED : parseVehicleClasses(value);
867  break;
868  }
869  case SUMO_ATTR_STATE:
870  throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified");
871  case SUMO_ATTR_DIR:
872  throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified");
873  case SUMO_ATTR_CUSTOMSHAPE: {
874  nbCon.customShape = parse<PositionVector>(value);
875  // update centering boundary
877  break;
878  }
879  case SUMO_ATTR_TYPE: {
880  nbCon.edgeType = value;
881  break;
882  }
883  case GNE_ATTR_SELECTED:
884  if (parse<bool>(value)) {
886  } else {
888  }
889  break;
890  case GNE_ATTR_PARAMETERS:
891  nbCon.setParametersStr(value);
892  break;
893  default:
894  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
895  }
896  // Update Geometry after setting a new attribute (but avoided for certain attributes)
897  if ((key != SUMO_ATTR_ID) && (key != GNE_ATTR_PARAMETERS) && (key != GNE_ATTR_SELECTED)) {
899  updateGeometry();
900  }
901  // invalidate path calculator
903 }
904 
905 
906 void
908  // set custom shape
910  // mark junction as deprecated
911  myShapeDeprecated = true;
912  // update geometry
913  updateGeometry();
914 }
915 
916 
917 void
919  // commit new shape
920  undoList->begin(GUIIcon::CONNECTION, "moving " + toString(SUMO_ATTR_CUSTOMSHAPE) + " of " + getTagStr());
922  undoList->end();
923 }
924 
925 /****************************************************************************/
static const int NUM_POINTS
NetworkEditMode
@brie enum for network edit modes
@ NETWORK_MOVE
mode for moving network elements
@ NETWORK_CREATE_EDGE
mode for creating new edges
@ NETWORK_TLS
mode for editing tls
@ NETWORK_CONNECT
mode for connecting lanes
@ MID_GNE_CONNECTION_SMOOTH_SHAPE
@ brief smooth connection shape
Definition: GUIAppEnum.h:1203
@ MID_GNE_CONNECTION_EDIT_SHAPE
edit connection shape
Definition: GUIAppEnum.h:1201
@ GLO_CONNECTION
a connection
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:274
@ KEEPCLEAR_FALSE
Definition: NBCont.h:59
@ KEEPCLEAR_TRUE
Definition: NBCont.h:60
SVCPermissions invertPermissions(SVCPermissions permissions)
negate the given permissions and ensure that only relevant bits are set
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SUMO_TAG_CONNECTION
connectio between two lanes
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
@ STRAIGHT
The link is a straight direction.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
@ LINKSTATE_TL_OFF_NOSIGNAL
The link is controlled by a tls which is off, not blinking, may pass.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_TLLINKINDEX2
link: the index of the opposite direction link of a pedestrian crossing
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_INDIRECT
Whether this connection is an indirect (left) turn.
@ SUMO_ATTR_FROM_LANE
@ GNE_ATTR_PARENT
parent of an additional element
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_CUSTOMSHAPE
whether a given shape is user-defined
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_CHANGE_LEFT
@ SUMO_ATTR_PASS
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_CHANGE_RIGHT
@ SUMO_ATTR_TO_LANE
@ SUMO_ATTR_UNCONTROLLED
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ID
@ SUMO_ATTR_VISIBILITY_DISTANCE
foe visibility distance of a link
@ SUMO_ATTR_CONTPOS
@ SUMO_ATTR_DIR
The abstract direction of a link.
@ SUMO_ATTR_TLLINKINDEX
link: the index of the link within the traffic light
@ SUMO_ATTR_KEEP_CLEAR
Whether vehicles must keep the junction clear.
@ SUMO_ATTR_STATE
The state of a link.
T MIN2(T a, T b)
Definition: StdDefs.h:71
T MAX2(T a, T b)
Definition: StdDefs.h:77
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:300
static void drawBoundary(const Boundary &b)
Draw a boundary (used for debugging)
Definition: GLHelper.cpp:894
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:421
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:583
static void drawTriangleAtEnd(const Position &p1, const Position &p2, double tLength, double tWidth, const double extraOffset=0)
Draws a triangle at the end of the given line.
Definition: GLHelper.cpp:558
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
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:329
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:589
static void popName()
pop Name
Definition: GLHelper.cpp:148
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition: GLHelper.cpp:716
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
friend class GNEChange_Attribute
declare friend class
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
NBConnection getNBConnection() const
get NBConnection
Position getPositionInView() const
Returns position of hierarchical element in view.
GNELane * getLaneFrom() const
@briefthe get lane of the incoming lane
void smootShape()
smoothShape
const PositionVector & getConnectionShape() const
GNELane * getLaneTo() const
@briefthe get lane of the outgoing lane
GNELane * myFromLane
incoming lane of this connection
LinkState getLinkState() const
get LinkState
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
int getFromLaneIndex() const
@briefthe get lane index of the incoming lane
void deleteGLObject()
delete element
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
GUIGeometry myConnectionGeometry
connection geometry
GNELane * myToLane
outgoing lane of this connection
std::string getAttribute(SumoXMLAttr key) const
GNEEdge * getEdgeFrom() const
get the name of the edge the vehicles leave
bool isAttributeComputed(SumoXMLAttr key) const
void markConnectionGeometryDeprecated()
check that connection's Geometry has to be updated
GNEConnection(GNELane *from, GNELane *to)
GNEEdge * getEdgeTo() const
get the name of the edge the vehicles may reach when leaving "from"
NBEdge::Connection & getNBEdgeConnection() const
get Edge::Connection
void setSpecialColor(const RGBColor *Color2)
GNEMoveOperation * getMoveOperation()
get move operation
void updateGeometry()
update pre-computed geometry information
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
bool isValid(SumoXMLAttr key, const std::string &value)
const RGBColor * mySpecialColor
optional special color
~GNEConnection()
Destructor.
int getToLaneIndex() const
@briefthe get lane index of the outgoing lane
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
bool myShapeDeprecated
flag to indicate that connection's shape has to be updated
void updateLinkState()
recompute cached myLinkState
const Parameterised::Map & getACParametersMap() const
get parameters map
void drawConnectionArrows(const GUIVisualizationSettings &s) const
draw arrows over connections
PositionVector myInternalJunctionMarker
waiting position for internal junction
bool isAttributeEnabled(SumoXMLAttr key) const
LinkState myLinkState
Linkstate.
void updateGLObject()
update GLObject (geometry, ID, etc.)
void updateID()
update internal ID of Connection
void changeTLIndex(SumoXMLAttr key, int tlIndex, int tlIndex2, GNEUndoList *undoList)
manage change of tlLinkindices
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:481
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
Definition: GNEEdge.h:82
static RGBColor colorForLinksState(FXuint state)
return the color for each linkstate
Position getPositionInView() const
Returns position of hierarchical element in view.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:876
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:1484
GNEEdge * getParentEdge() const
get parent edge
Definition: GNELane.cpp:124
GNEMoveOperation * calculateMoveShapeOperation(const PositionVector originalShape, const Position mousePosition, const double snapRadius, const bool onlyContour)
calculate move shape operation
move operation
move result
PositionVector shapeToUpdate
shape to update (edited in moveElement)
GNEJunction * retrieveJunction(const std::string &id, bool hardFail=true) const
get junction by id
void deleteNetworkElement(GNENetworkElement *networkElement, GNEUndoList *undoList)
delete network element
Definition: GNENet.cpp:334
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:132
GNEPathManager * getPathManager()
get path manager
Definition: GNENet.cpp:138
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1987
virtual std::string getAttribute(SumoXMLAttr key) const =0
bool myShapeEdited
flag to check if element shape is being edited
bool isShapeEdited() const
check if shape is being edited
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Boundary myBoundary
object boundary
void invalidatePathCalculator()
invalidate pathCalculator
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:632
const GNEViewNetHelper::EditNetworkElementShapes & getEditNetworkElementShapes() const
get Edit Shape module
Definition: GNEViewNet.cpp:668
bool drawSelectContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw select contour
bool drawDeleteContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw delete contour
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:644
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
GNEUndoList * getUndoList() const
get the undoList object
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:474
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:42
static void drawDottedContourShape(const GUIVisualizationSettings &s, const DottedContourType type, const PositionVector &shape, const double width, const double exaggeration, const bool drawFirstExtrem, const bool drawLastExtrem)
draw dotted contour for the given shape (used by additionals)
The popup menu of a globject.
static void drawGeometryPoints(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const RGBColor &geometryPointColor, const RGBColor &textColor, const double radius, const double exaggeration, const bool editingElevation, const bool drawExtremeSymbols)
draw geometry points
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
Definition: GUIGeometry.cpp:58
static void drawMovingHint(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const RGBColor &hintColor, const double radius, const double exaggeration)
draw moving hint
const std::vector< double > & getShapeLengths() const
The lengths of the single shape parts.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void mouseWithinGeometry(const Position center, const double radius) const
check if mouse is within elements geometry (for circles)
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:154
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:141
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:102
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Stores the information about how to visualize structures.
bool drawBoundaries
enable or disable draw boundaries
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
GUIVisualizationDetailSettings detailSettings
detail settings
GUIVisualizationSizeSettings addSize
GUIVisualizationTextSettings edgeValue
bool drawMovingGeometryPoint(const double exaggeration, const double radius) const
check if moving geometry point can be draw
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationConnectionSettings connectionSettings
connection settings
double scale
information about a lane's width (temporary, used for a single view)
bool showLaneDirection
Whether to show direction indicators for lanes.
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
double selectorFrameScale
the current selection scaling in NETEDIT (set in SelectorFrame)
bool spreadSuperposed
Whether to improve visualisation of superposed (rail) edges.
std::string edgeParam
key for coloring by edge parameter
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
The representation of a single edge during network building.
Definition: NBEdge.h:92
Connection & getConnectionRef(int fromLane, const NBEdge *to, int toLane)
Returns reference to the specified connection This method goes through "myConnections" and returns th...
Definition: NBEdge.cpp:1267
bool isBidiRail(bool ignoreSpread=false) const
whether this edge is part of a bidirectional railway
Definition: NBEdge.cpp:762
const std::string & getID() const
Definition: NBEdge.h:1526
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:736
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:552
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:526
static const double UNSPECIFIED_SPEED
unspecified lane speed
Definition: NBEdge.h:363
A loaded (complete) traffic light logic.
void addConnection(NBEdge *from, NBEdge *to, int fromLane, int toLane, int linkIndex, int linkIndex2, bool reconstruct=true)
Adds a connection and immediately informs the edges.
NBTrafficLightLogic * getLogic()
Returns the internal logic.
LinkState getLinkState(const NBEdge *incoming, NBEdge *outgoing, int fromLane, int toLane, bool mayDefinitelyPass, const std::string &tlID) const
get link state
Definition: NBNode.cpp:2294
LinkDirection getDirection(const NBEdge *const incoming, const NBEdge *const outgoing, bool leftHand=false) const
Returns the representation of the described stream's direction.
Definition: NBNode.cpp:2229
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node)
Definition: NBNode.h:326
The base class for traffic light logic definitions.
NBTrafficLightLogic * compute(OptionsCont &oc)
Computes the traffic light logic.
virtual int getMaxValidIndex()
Returns the maximum index controlled by this traffic light.
A SUMO-compliant built logic for a traffic light.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:59
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
void setParametersStr(const std::string &paramsString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
double x() const
Returns the x-position.
Definition: Position.h:55
double y() const
Returns the y-position.
Definition: Position.h:60
A list of positions.
void append(const PositionVector &v, double sameThreshold=2.0)
double length() const
Returns the length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
PositionVector getOrthogonal(const Position &p, double extend, bool before, double length=1.0, double deg=90) const
return orthogonal through p (extending this vector if necessary)
int indexOfClosest(const Position &p, bool twoD=false) const
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
static const RGBColor BLACK
Definition: RGBColor.h:193
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:200
NetworkEditMode networkEditMode
the current Network edit mode
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
GNENetworkElement * getEditedNetworkElement() const
pointer to edited network element
static void drawLockIcon(const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position viewPosition, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool showConnections() const
check if select show connections checkbox is enabled
bool editingElevation() const
check if we're editing elevation
static const RGBColor editShapeColor
color for edited shapes (Junctions, crossings and connections)
RGBColor selectedConnectionColor
connection selection color
static const double connectionWidth
connection width
static const double connectionsDemandMode
draw connections in demand mode
static const double connectionGeometryPointRadius
moving connection geometry point radius
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool show(const GUIGlObject *o) const
whether to show the text
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:201
bool indirectLeft
Whether this connection is an indirect left turn.
Definition: NBEdge.h:278
int fromLane
The lane the connections starts at.
Definition: NBEdge.h:227
int toLane
The lane the connections yields in.
Definition: NBEdge.h:233
SVCPermissions permissions
List of vehicle types that are allowed on this connection.
Definition: NBEdge.h:269
double speed
custom speed for connection
Definition: NBEdge.h:257
NBEdge * toEdge
The edge the connections yields in.
Definition: NBEdge.h:230
KeepClear keepClear
whether the junction must be kept clear when using this connection
Definition: NBEdge.h:248
double customLength
custom length for connection
Definition: NBEdge.h:263
std::string edgeType
optional type of Connection
Definition: NBEdge.h:281
bool uncontrolled
check if Connection is uncontrolled
Definition: NBEdge.h:314
PositionVector customShape
custom shape for connection
Definition: NBEdge.h:266
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
Definition: NBEdge.h:245
SVCPermissions changeLeft
List of vehicle types that are allowed to change Left from this connections internal lane(s)
Definition: NBEdge.h:272
SVCPermissions changeRight
List of vehicle types that are allowed to change right from this connections internal lane(s)
Definition: NBEdge.h:275
PositionVector viaShape
shape of via
Definition: NBEdge.h:299
double contPos
custom position for internal junction on this connection
Definition: NBEdge.h:251
std::string tlID
The id of the traffic light that controls this connection.
Definition: NBEdge.h:236
double visibility
custom foe visiblity for connection
Definition: NBEdge.h:254
int tlLinkIndex2
The index of the internal junction within the controlling traffic light (optional)
Definition: NBEdge.h:242
PositionVector shape
shape of Connection
Definition: NBEdge.h:287
bool haveVia
check if Connection have a Via
Definition: NBEdge.h:293
int tlLinkIndex
The index of this connection within the controlling traffic light.
Definition: NBEdge.h:239