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.dev/sumo
3 // Copyright (C) 2001-2024 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
79  // Get shape of from and to lanes
80  const NBEdge::Connection& nbCon = getNBEdgeConnection();
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 
152 bool
154  return false;
155 }
156 
157 
158 bool
160  return false;
161 }
162 
163 
164 bool
166  return false;
167 }
168 
169 
170 bool
172  return false;
173 }
174 
175 
176 bool
178  // get edit modes
179  const auto& editModes = myNet->getViewNet()->getEditModes();
180  // check if we're in delete mode
181  if (editModes.isCurrentSupermodeNetwork() && (editModes.networkEditMode == NetworkEditMode::NETWORK_DELETE)) {
183  } else {
184  return false;
185  }
186 }
187 
188 
189 bool
191  // get edit modes
192  const auto& editModes = myNet->getViewNet()->getEditModes();
193  // check if we're in select mode
194  if (editModes.isCurrentSupermodeNetwork() && (editModes.networkEditMode == NetworkEditMode::NETWORK_SELECT)) {
196  } else {
197  return false;
198  }
199 }
200 
201 
202 bool
204  // get edit modes
205  const auto& editModes = myNet->getViewNet()->getEditModes();
206  // check if we're in move mode
207  if (!myNet->getViewNet()->isMovingElement() && editModes.isCurrentSupermodeNetwork() &&
208  (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE) && myNet->getViewNet()->checkOverLockedElement(this, mySelected)) {
209  // only move the first element
211  } else {
212  return false;
213  }
214 }
215 
216 
219  // edit depending if shape is being edited
220  if (isShapeEdited()) {
221  // get connection
222  const auto& connection = getNBEdgeConnection();
223  // calculate move shape operation
224  return calculateMoveShapeOperation(this, connection.customShape.size() > 0 ? connection.customShape : myConnectionGeometry.getShape(), false);
225  } else {
226  return nullptr;
227  }
228 }
229 
230 
231 void
232 GNEConnection::removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) {
233  // edit depending if shape is being edited
234  if (isShapeEdited()) {
235  // get connection
236  const auto& connection = getNBEdgeConnection();
237  // get original shape
238  PositionVector shape = connection.customShape.size() > 0 ? connection.customShape : connection.shape;
239  // check shape size
240  if (shape.size() > 2) {
241  // obtain index
242  int index = shape.indexOfClosest(clickedPosition);
243  // get snap radius
245  // check if we have to create a new index
246  if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
247  // remove geometry point
248  shape.erase(shape.begin() + index);
249  // commit new shape
250  undoList->begin(this, "remove geometry point of " + getTagStr());
252  undoList->end();
253  }
254  }
255  }
256 }
257 
258 
259 GNEEdge*
261  return myFromLane->getParentEdge();
262 }
263 
264 
265 GNEEdge*
267  return myToLane->getParentEdge();
268 }
269 
270 
271 GNELane*
273  return myFromLane;
274 }
275 
276 
277 GNELane*
279  return myToLane;
280 }
281 
282 
283 int
285  return myFromLane->getIndex();
286 }
287 
288 
289 int
291  return myToLane->getIndex();
292 }
293 
294 
298 }
299 
300 
304  return NBConnection(getEdgeFrom()->getNBEdge(), getFromLaneIndex(),
305  getEdgeTo()->getNBEdge(), getToLaneIndex(),
306  (int)c.tlLinkIndex, (int)c.tlLinkIndex2);
307 }
308 
309 
310 void
313 }
314 
315 
316 LinkState
318  return myLinkState;
319 }
320 
321 
322 void
324  myShapeDeprecated = true;
325 }
326 
327 
328 void
330  const NBEdge::Connection& nbCon = getNBEdgeConnection();
332  nbCon.toEdge,
333  nbCon.fromLane,
334  nbCon.toLane,
335  nbCon.mayDefinitelyPass,
336  nbCon.tlID);
337 }
338 
339 
340 void
342  auto shape = getConnectionShape();
343  shape = shape.bezier(5);
345 }
346 
347 
350  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
351  buildPopupHeader(ret, app);
354  // build selection and show parameters menu
357  // build position copy entry
358  buildPositionCopyEntry(ret, app);
359  // check if we're in supermode network
361  // create menu commands
362  FXMenuCommand* mcCustomShape = GUIDesigns::buildFXMenuCommand(ret, "Set custom connection shape", nullptr, &parent, MID_GNE_CONNECTION_EDIT_SHAPE);
363  GUIDesigns::buildFXMenuCommand(ret, "Smooth connection shape", nullptr, &parent, MID_GNE_CONNECTION_SMOOTH_SHAPE);
364  // check if menu commands has to be disabled
366  // check if we're in the correct edit mode
367  if ((editMode == NetworkEditMode::NETWORK_CONNECT) || (editMode == NetworkEditMode::NETWORK_TLS) || (editMode == NetworkEditMode::NETWORK_CREATE_EDGE)) {
368  mcCustomShape->disable();
369  }
370  }
371  return ret;
372 }
373 
374 
375 double
377  return s.addSize.getExaggeration(s, this);
378 }
379 
380 
381 Boundary
384 }
385 
386 
387 void
388 GNEConnection::updateCenteringBoundary(const bool /*updateGrid*/) {
389  // nothing to update
390 }
391 
392 
393 void
395  // Check if connection must be drawed
396  if (checkDrawConnection()) {
397  // get connection exaggeration
398  const double connectionExaggeration = isAttributeCarrierSelected() ? s.selectorFrameScale : 1;
399  // get detail level
400  const auto d = s.getDetailLevel(connectionExaggeration);
401  // check if draw shape superposed (used in train lanes)
402  PositionVector shapeSuperposed = myConnectionGeometry.getShape();
404  shapeSuperposed.move2side(0.5);
405  }
406  // draw geometry only if we'rent in drawForObjectUnderCursor mode
407  if (!s.drawForViewObjectsHandler) {
408  // draw connection
409  drawConnection(s, d, shapeSuperposed, connectionExaggeration);
410  // draw lock icon
412  // draw dotted contour
414  }
415  // calculate contour
416  calculateConnectionContour(s, d, shapeSuperposed, connectionExaggeration);
417  }
418 }
419 
420 
421 void
424 }
425 
426 
427 void
429  updateGeometry();
430 }
431 
432 
433 void
435  mySpecialColor = color;
436 }
437 
438 
439 std::string
441  // first get attributes in which nbConnection reference can be invalid
442  switch (key) {
443  case SUMO_ATTR_ID:
444  return getMicrosimID();
445  case SUMO_ATTR_FROM:
446  return myFromLane->getParentEdge()->getID();
447  case SUMO_ATTR_TO:
448  return myToLane->getParentEdge()->getID();
449  case SUMO_ATTR_FROM_LANE:
452  return myFromLane->getID();
453  case SUMO_ATTR_TO_LANE:
455  case GNE_ATTR_TO_LANEID:
456  return myToLane->getID();
457  case GNE_ATTR_SELECTED:
459  case GNE_ATTR_PARENT:
460  return getEdgeFrom()->getToJunction()->getID();
461  default:
462  break;
463  }
464  // now continue with attributes that needs a nbConnection reference
465  const NBEdge::Connection& nbCon = getNBEdgeConnection();
466  switch (key) {
467  case SUMO_ATTR_PASS:
468  return toString(nbCon.mayDefinitelyPass);
469  case SUMO_ATTR_INDIRECT:
470  return toString(nbCon.indirectLeft);
471  case SUMO_ATTR_TYPE:
472  return toString(nbCon.edgeType);
474  return toString(nbCon.keepClear);
475  case SUMO_ATTR_CONTPOS:
476  return toString(nbCon.contPos);
478  return toString(nbCon.uncontrolled);
480  return toString(nbCon.visibility);
482  return toString(nbCon.tlLinkIndex);
484  return toString(nbCon.tlLinkIndex2);
485  case SUMO_ATTR_ALLOW:
486  if (nbCon.permissions == SVC_UNSPECIFIED) {
487  return getVehicleClassNames(nbCon.toEdge->getLanes()[nbCon.toLane].permissions);
488  } else {
489  return getVehicleClassNames(nbCon.permissions);
490  }
491  case SUMO_ATTR_DISALLOW:
492  if (nbCon.permissions == SVC_UNSPECIFIED) {
493  return getVehicleClassNames(invertPermissions(nbCon.toEdge->getLanes()[nbCon.toLane].permissions));
494  } else {
496  }
498  if (nbCon.changeLeft == SVC_UNSPECIFIED) {
499  return "all";
500  } else {
501  return getVehicleClassNames(nbCon.changeLeft);
502  }
504  if (nbCon.changeRight == SVC_UNSPECIFIED) {
505  return "all";
506  } else {
507  return getVehicleClassNames(nbCon.changeRight);
508  }
509  case SUMO_ATTR_SPEED:
510  if (nbCon.speed == NBEdge::UNSPECIFIED_SPEED) {
511  return "default";
512  } else {
513  return toString(nbCon.speed);
514  }
515  case SUMO_ATTR_LENGTH:
516  return toString(nbCon.customLength);
517  case SUMO_ATTR_DIR:
518  return toString(getEdgeFrom()->getNBEdge()->getToNode()->getDirection(
519  getEdgeFrom()->getNBEdge(), nbCon.toEdge, OptionsCont::getOptions().getBool("lefthand")));
520  case SUMO_ATTR_STATE:
521  return toString(getEdgeFrom()->getNBEdge()->getToNode()->getLinkState(
522  getEdgeFrom()->getNBEdge(), nbCon.toEdge, nbCon.fromLane, nbCon.toLane, nbCon.mayDefinitelyPass, nbCon.tlID));
524  return toString(nbCon.customShape);
525  case GNE_ATTR_PARAMETERS:
526  return nbCon.getParametersStr();
527  default:
528  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
529  }
530 }
531 
532 
533 void
534 GNEConnection::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
536  switch (key) {
537  case SUMO_ATTR_FROM:
538  case SUMO_ATTR_TO:
539  case SUMO_ATTR_FROM_LANE:
540  case SUMO_ATTR_TO_LANE:
541  case SUMO_ATTR_PASS:
543  case SUMO_ATTR_CONTPOS:
546  case SUMO_ATTR_ALLOW:
547  case SUMO_ATTR_DISALLOW:
550  case SUMO_ATTR_SPEED:
551  case SUMO_ATTR_LENGTH:
553  case SUMO_ATTR_TYPE:
554  case GNE_ATTR_SELECTED:
555  case GNE_ATTR_PARAMETERS:
556  // no special handling
557  GNEChange_Attribute::changeAttribute(this, key, value, undoList);
558  break;
560  if (isAttributeEnabled(SUMO_ATTR_TLLINKINDEX) && (value != getAttribute(key))) {
561  changeTLIndex(key, parse<int>(value), c.tlLinkIndex2, undoList);
562  }
563  break;
565  if (isAttributeEnabled(SUMO_ATTR_TLLINKINDEX) && (value != getAttribute(key))) {
566  changeTLIndex(key, c.tlLinkIndex, parse<int>(value), undoList);
567  }
568  break;
569  case SUMO_ATTR_INDIRECT:
570  undoList->begin(this, "change attribute indirect for connection");
571  if (isAttributeEnabled(SUMO_ATTR_TLLINKINDEX) && (value != getAttribute(key))) {
572  GNEChange_Attribute::changeAttribute(this, key, value, undoList);
573  int linkIndex2 = -1;
574  if (parse<bool>(value)) {
575  // find straight connection with the same toEdge
576  std::set<NBTrafficLightDefinition*> defs = getEdgeFrom()->getNBEdge()->getToNode()->getControllingTLS();
577  NBEdge* from = getEdgeFrom()->getNBEdge();
578  for (NBTrafficLightDefinition* tlDef : defs) {
579  for (const NBConnection& c2 : tlDef->getControlledLinks()) {
580  if (c2.getTo() == c.toEdge && c2.getFrom() != from) {
581  LinkDirection dir = from->getToNode()->getDirection(c2.getFrom(), c2.getTo());
582  if (dir == LinkDirection::STRAIGHT) {
583  linkIndex2 = c2.getTLIndex();
584  break;
585  }
586  }
587  }
588  }
589  }
590  changeTLIndex(key, c.tlLinkIndex, linkIndex2, undoList);
591  }
592  undoList->end();
593  break;
594  case SUMO_ATTR_DIR:
595  throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified");
596  case SUMO_ATTR_STATE:
597  throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified");
598  default:
599  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
600  }
601 }
602 
603 
604 void
605 GNEConnection::changeTLIndex(SumoXMLAttr key, int tlIndex, int tlIndex2, GNEUndoList* undoList) {
606  // trigger GNEChange_TLS
607  undoList->begin(this, "change tls linkIndex for connection");
608  // make a copy
609  std::set<NBTrafficLightDefinition*> defs = getEdgeFrom()->getNBEdge()->getToNode()->getControllingTLS();
610  for (const auto& tlDef : defs) {
611  NBLoadedSUMOTLDef* sumoDef = dynamic_cast<NBLoadedSUMOTLDef*>(tlDef);
612  NBTrafficLightLogic* tllogic = sumoDef ? sumoDef->getLogic() : tlDef->compute(OptionsCont::getOptions());
613  if (tllogic != nullptr) {
614  NBLoadedSUMOTLDef* newDef = new NBLoadedSUMOTLDef(*tlDef, *tllogic);
615  newDef->addConnection(getEdgeFrom()->getNBEdge(), getEdgeTo()->getNBEdge(),
616  getLaneFrom()->getIndex(), getLaneTo()->getIndex(), tlIndex, tlIndex2, false);
617  // make a copy
618  std::vector<NBNode*> nodes = tlDef->getNodes();
619  for (const auto& node : nodes) {
620  GNEJunction* junction = getNet()->getAttributeCarriers()->retrieveJunction(node->getID());
621  undoList->add(new GNEChange_TLS(junction, tlDef, false), true);
622  undoList->add(new GNEChange_TLS(junction, newDef, true), true);
623  }
624  } else {
625  WRITE_ERRORF(TL("Could not set attribute '%' (tls is broken)"), toString(key));
626  }
627  }
628  undoList->end();
629 }
630 
631 
632 bool
634  return getEdgeFrom()->getNBEdge()->getConnectionsFromLane(getFromLaneIndex(), getEdgeTo()->getNBEdge(), getToLaneIndex()).size() > 0;
635 }
636 
637 
638 bool
640  // declare a flag to check if shape has to be draw (by deafult false)
641  bool drawConnection = false;
642  // only draw connections if shape isn't deprecated
648  } else {
649  drawConnection = false;
650  }
651  } else {
652  drawConnection = false;
653  }
654  // check if we're editing this connection
656  if (editedNetworkElement && (editedNetworkElement->getTagProperty().getTag() == SUMO_TAG_CONNECTION)) {
657  if (editedNetworkElement->getAttribute(GNE_ATTR_PARENT) == getAttribute(GNE_ATTR_PARENT)) {
658  drawConnection = true;
659  }
660  }
661  return drawConnection;
662 }
663 
664 
665 RGBColor
667  // check conditions
668  if (myShapeEdited) {
669  // return shape edit color
670  return s.colorSettings.editShapeColor;
671  } else if (drawUsingSelectColor()) {
672  // override with special colors (unless the color scheme is based on selection)
674  } else if (mySpecialColor != nullptr) {
675  // return special color
676  return *mySpecialColor;
677  } else {
678  // Set color depending of the link state
680  }
681 }
682 
683 
684 void
686  const PositionVector& shape, const double exaggeration) const {
687  // get color
688  RGBColor connectionColor = getConnectionColor(s);
689  // Push layer matrix
691  // translate to front
694  } else {
696  }
697  // Set color
698  GLHelper::setColor(connectionColor);
699  // continue depending of detail level
701  // draw geometry
703  s.connectionSettings.connectionWidth * exaggeration);
704  // draw arrows over connection
705  drawConnectionArrows(s, connectionColor);
706  // check if internal junction marker has to be drawn
707  if (myInternalJunctionMarker.size() > 0) {
709  }
710  // draw edge values
711  drawEdgeValues(s, shape);
712  // draw shape points only in Network supemode
714  // draw geometry points
718  }
719  } else {
721  }
722  // Pop layer matrix
724 }
725 
726 
727 void
729  if (s.showLaneDirection) {
730  // Push matrix
732  // move front
733  glTranslated(0, 0, 0.1);
734  // change color
736  // draw triangles
737  for (int i = 1; i < (int)myConnectionGeometry.getShape().size(); i++) {
738  const auto posA = myConnectionGeometry.getShape()[i - 1];
739  const auto posB = myConnectionGeometry.getShape()[i];
740  GLHelper::drawTriangleAtEnd(posA, posB, (double) 1, (double) .2);
741  }
742  // Pop matrix
744  }
745 }
746 
747 
748 void
750  // check if edge value has to be shown
751  if (s.edgeValue.show(this)) {
752  const NBEdge::Connection& nbCon = getNBEdgeConnection();
753  const std::string value = nbCon.getParameter(s.edgeParam, "");
754  if (value != "") {
755  int shapeIndex = (int)shape.size() / 2;
756  const Position p = (myConnectionGeometry.getShape().size() == 2) ? (shape.front() * 0.67 + shape.back() * 0.33) : shape[shapeIndex];
757  GLHelper::drawTextSettings(s.edgeValue, value, p, s.scale, 0);
758  }
759  }
760 }
761 
762 
763 void
765  const PositionVector& shape, const double exaggeration) const {
766  // first check if junction parent was inserted with full boundary
768  // calculate connection shape contour
769  myNetworkElementContour.calculateContourExtrudedShape(s, d, this, shape, s.connectionSettings.connectionWidth, exaggeration, true, true, 0);
770  // calculate geometry points contour if we're editing shape
771  if (myShapeEdited) {
773  exaggeration, true);
774  }
775  }
776 }
777 
778 
779 bool
780 GNEConnection::isValid(SumoXMLAttr key, const std::string& value) {
781  // Currently ignored before implementation to avoid warnings
782  switch (key) {
783  case SUMO_ATTR_FROM:
784  case SUMO_ATTR_TO:
785  case SUMO_ATTR_FROM_LANE:
786  case SUMO_ATTR_TO_LANE:
787  return false;
788  case SUMO_ATTR_PASS:
789  return canParse<bool>(value);
790  case SUMO_ATTR_INDIRECT:
791  return canParse<bool>(value);
792  case SUMO_ATTR_TYPE:
793  return true;
795  return canParse<bool>(value);
796  case SUMO_ATTR_CONTPOS:
797  return canParse<double>(value) && (parse<double>(value) >= -1);
799  return canParse<bool>(value);
801  return canParse<double>(value) && (parse<double>(value) >= -1);
806  (getEdgeFrom()->getNBEdge()->getToNode()->getControllingTLS().size() > 0) &&
807  canParse<int>(value) &&
808  (parse<int>(value) >= 0 || parse<int>(value) == -1)) {
809  // obtain Traffic light definition
811  return def->getMaxValidIndex() >= parse<int>(value);
812  } else {
813  return false;
814  }
815  case SUMO_ATTR_ALLOW:
816  case SUMO_ATTR_DISALLOW:
819  return canParseVehicleClasses(value);
820  case SUMO_ATTR_SPEED:
821  if (value.empty() || value == "default") {
822  return true;
823  } else {
824  return canParse<double>(value) && ((parse<double>(value) >= 0) || (parse<double>(value) == NBEdge::UNSPECIFIED_SPEED));
825  }
826  case SUMO_ATTR_LENGTH:
827  return canParse<double>(value) && (parse<double>(value) >= -1);
828  case SUMO_ATTR_CUSTOMSHAPE: {
829  // empty custom shapes are allowed
830  return canParse<PositionVector>(value);
831  }
832  case SUMO_ATTR_STATE:
833  return false;
834  case SUMO_ATTR_DIR:
835  return false;
836  case GNE_ATTR_SELECTED:
837  return canParse<bool>(value);
838  case GNE_ATTR_PARAMETERS:
839  return Parameterised::areParametersValid(value);
840  default:
841  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
842  }
843 }
844 
845 
846 bool
848  switch (key) {
849  case SUMO_ATTR_FROM:
850  case SUMO_ATTR_TO:
851  case SUMO_ATTR_FROM_LANE:
852  case SUMO_ATTR_TO_LANE:
853  case SUMO_ATTR_DIR:
854  case SUMO_ATTR_STATE:
855  // this attributes cannot be edited
856  return false;
859  // get Traffic Light definitions
860  if (getEdgeFrom()->getNBEdge()->getToNode()->isTLControlled()) {
862  NBLoadedSUMOTLDef* sumoDef = dynamic_cast<NBLoadedSUMOTLDef*>(tlDef);
863  NBTrafficLightLogic* tllogic = sumoDef != nullptr ? sumoDef->getLogic() : tlDef->compute(OptionsCont::getOptions());
864  if (tllogic != nullptr) {
865  return true;
866  } else {
867  return false;
868  }
869  }
870  return false;
871  default:
872  return true;
873  }
874 }
875 
876 
877 bool
879  switch (key) {
880  case SUMO_ATTR_SPEED:
882  default:
883  return false;
884  }
885 }
886 
887 
888 const Parameterised::Map&
891 }
892 
893 // ===========================================================================
894 // private
895 // ===========================================================================
896 
897 void
898 GNEConnection::setAttribute(SumoXMLAttr key, const std::string& value) {
900  switch (key) {
901  case SUMO_ATTR_PASS:
902  nbCon.mayDefinitelyPass = parse<bool>(value);
903  break;
904  case SUMO_ATTR_INDIRECT:
905  nbCon.indirectLeft = parse<bool>(value);
906  break;
908  nbCon.keepClear = parse<bool>(value) ? KEEPCLEAR_TRUE : KEEPCLEAR_FALSE;
909  break;
911  nbCon.uncontrolled = parse<bool>(value);
912  break;
913  case SUMO_ATTR_CONTPOS:
914  nbCon.contPos = parse<double>(value);
915  break;
917  nbCon.visibility = parse<double>(value);
918  break;
919  case SUMO_ATTR_SPEED:
920  if (value.empty() || (value == "default")) {
922  } else {
923  nbCon.speed = parse<double>(value);
924  }
925  break;
926  case SUMO_ATTR_LENGTH:
927  nbCon.customLength = parse<double>(value);
928  break;
929  case SUMO_ATTR_ALLOW: {
930  nbCon.permissions = parseVehicleClasses(value);
931  break;
932  }
933  case SUMO_ATTR_DISALLOW: {
935  break;
936  }
937  case SUMO_ATTR_CHANGE_LEFT: {
938  nbCon.changeLeft = value == "" ? SVC_UNSPECIFIED : parseVehicleClasses(value);
939  break;
940  }
941  case SUMO_ATTR_CHANGE_RIGHT: {
942  nbCon.changeRight = value == "" ? SVC_UNSPECIFIED : parseVehicleClasses(value);
943  break;
944  }
945  case SUMO_ATTR_STATE:
946  throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified");
947  case SUMO_ATTR_DIR:
948  throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified");
949  case SUMO_ATTR_CUSTOMSHAPE: {
950  nbCon.customShape = parse<PositionVector>(value);
951  // update centering boundary
953  break;
954  }
955  case SUMO_ATTR_TYPE: {
956  nbCon.edgeType = value;
957  break;
958  }
959  case GNE_ATTR_SELECTED:
960  if (parse<bool>(value)) {
962  } else {
964  }
965  break;
966  case GNE_ATTR_PARAMETERS:
967  nbCon.setParametersStr(value);
968  break;
969  default:
970  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
971  }
972  // Update Geometry after setting a new attribute (but avoided for certain attributes)
973  if ((key != SUMO_ATTR_ID) && (key != GNE_ATTR_PARAMETERS) && (key != GNE_ATTR_SELECTED)) {
975  updateGeometry();
976  }
977  // invalidate path calculator
979 }
980 
981 
982 void
984  // set custom shape
986  // mark junction as deprecated
987  myShapeDeprecated = true;
988  // update geometry
989  updateGeometry();
990 }
991 
992 
993 void
995  // commit new shape
996  undoList->begin(this, "moving " + toString(SUMO_ATTR_CUSTOMSHAPE) + " of " + getTagStr());
998  undoList->end();
999 }
1000 
1001 /****************************************************************************/
static const int NUM_POINTS
NetworkEditMode
@brie enum for network edit modes
@ NETWORK_DELETE
mode for deleting network elements
@ NETWORK_MOVE
mode for moving network elements
@ NETWORK_CREATE_EDGE
mode for creating new edges
@ NETWORK_TLS
mode for editing tls
@ NETWORK_SELECT
mode for selecting network elements
@ NETWORK_CONNECT
mode for connecting lanes
@ MID_GNE_CONNECTION_SMOOTH_SHAPE
@ brief smooth connection shape
Definition: GUIAppEnum.h:1280
@ MID_GNE_CONNECTION_EDIT_SHAPE
edit connection shape
Definition: GUIAppEnum.h:1278
@ GLO_CONNECTION
a connection
GUIViewObjectsHandler gViewObjectsHandler
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
#define WRITE_ERRORF(...)
Definition: MsgHandler.h:305
#define TL(string)
Definition: MsgHandler.h:315
@ 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.
@ SUMO_TAG_CONNECTION
connectioon 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"
@ GNE_ATTR_FROM_LANEID
from lane ID (used in GNEConnection)
@ SUMO_ATTR_CHANGE_LEFT
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_PASS
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ GNE_ATTR_TO_LANEID
to lane ID (used in GNEConnection)
@ 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:76
T MAX2(T a, T b)
Definition: StdDefs.h:82
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
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:438
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:654
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:629
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:347
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:787
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
bool mySelected
boolean to check if this AC is selected (instead of GUIGlObjectStorage)
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
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void updateConnectionID()
update internal ID of Connection
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
get connection shape
bool checkDrawSelectContour() const
check if draw select contour (blue)
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
bool checkDrawOverContour() const
check if draw over contour (orange)
void drawEdgeValues(const GUIVisualizationSettings &s, const PositionVector &shape) const
draw edge value
bool checkDrawFromContour() const
check if draw from contour (green)
bool existNBEdgeConnection() const
check if the edgeConnection vinculated with this connection exists
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)
void drawConnection(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const PositionVector &shape, const double exaggeration) const
draw connection
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)
void drawConnectionArrows(const GUIVisualizationSettings &s, const RGBColor &color) const
draw arrows over connections
GNEMoveOperation * getMoveOperation()
get move operation for the given shapeOffset (can be nullptr)
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.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show 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 calculateConnectionContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const PositionVector &shape, const double exaggeration) const
calculate connection contour
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
void updateLinkState()
recompute cached myLinkState
const Parameterised::Map & getACParametersMap() const
get parameters map
bool checkDrawConnection() const
check if draw connection
PositionVector myInternalJunctionMarker
waiting position for internal junction
RGBColor getConnectionColor(const GUIVisualizationSettings &s) const
get connection color
bool checkDrawMoveContour() const
check if draw move contour (red)
bool isAttributeEnabled(SumoXMLAttr key) const
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
LinkState myLinkState
Linkstate.
void updateGLObject()
update GLObject (geometry, ID, etc.)
bool checkDrawToContour() const
check if draw from contour (magenta)
void changeTLIndex(SumoXMLAttr key, int tlIndex, int tlIndex2, GNEUndoList *undoList)
manage change of tlLinkindices
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset) const
calculate contour extruded (used in elements formed by a central shape)
Definition: GNEContour.cpp:88
void calculateContourAllGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double radius, const double scale, const bool calculatePosOverShape) const
calculate contour for all geometry points
Definition: GNEContour.cpp:192
void drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
drawing contour functions
Definition: GNEContour.cpp:265
Boundary getContourBoundary() const
get contour boundary
Definition: GNEContour.cpp:59
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:683
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
bool drawSuperposed() const
draw superposed
Definition: GNELane.cpp:154
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
std::string getAttribute(SumoXMLAttr key) const
Definition: GNELane.cpp:690
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:642
const DrawingConstants * getDrawingConstants() const
get lane drawing constants (previously calculated in drawGL())
Definition: GNELane.cpp:236
GNEEdge * getParentEdge() const
get parent edge
Definition: GNELane.cpp:196
GNEMoveOperation * calculateMoveShapeOperation(const GUIGlObject *obj, const PositionVector originalShape, const bool maintainShapeClosed)
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:328
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:122
GNEPathManager * getPathManager()
get path manager
Definition: GNENet.cpp:134
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2055
virtual std::string getAttribute(SumoXMLAttr key) const =0
GNEContour myNetworkElementContour
network element contour
bool myShapeEdited
flag to check if element shape is being edited
void setNetworkElementID(const std::string &newID)
set network element id
bool isShapeEdited() const
check if shape is being edited
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...
const GUIGlObject * getGUIGlObjectFront() const
get front attribute carrier or a pointer to nullptr
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:703
const GNEViewNetHelper::EditNetworkElementShapes & getEditNetworkElementShapes() const
get Edit Shape module
Definition: GNEViewNet.cpp:739
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:715
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
bool isMovingElement() const
check if an element is being moved
bool checkOverLockedElement(const GUIGlObject *GLObject, const bool isSelected) const
check if given element is locked (used for drawing select and delete contour)
GNEUndoList * getUndoList() const
get the undoList object
const GNEViewNetHelper::ViewObjectsSelector & getViewObjectsSelector() const
get objects under cursor
Definition: GNEViewNet.cpp:468
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:538
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
Definition: GUIDesigns.cpp:42
The popup menu of a globject.
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawGeometryPoints(const GUIVisualizationSettings::Detail d, const PositionVector &shape, const RGBColor &color, const double radius, const double exaggeration, const bool editingElevation)
draw geometry points
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
Definition: GUIGeometry.cpp:59
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.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
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:156
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:143
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
bool checkBoundaryParentElement(const GUIGlObject *GLObject, const GUIGlObject *parent)
check boundary parent element
Stores the information about how to visualize structures.
GUIVisualizationSizeSettings addSize
GUIVisualizationTextSettings edgeValue
Detail getDetailLevel(const double exaggeration) const
return the detail level
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
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour 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 drawForViewObjectsHandler
whether drawing is performed for the purpose of selecting objects in view using ViewObjectsHandler
double selectorFrameScale
the current selection scaling in netedit (set in SelectorFrame)
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:1278
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:726
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:542
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:516
std::vector< Connection > getConnectionsFromLane(int lane, const NBEdge *to=nullptr, int toLane=-1) const
Returns connections from a given lane.
Definition: NBEdge.cpp:1252
static const double UNSPECIFIED_SPEED
unspecified lane speed
Definition: NBEdge.h:348
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.
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:2349
LinkState getLinkState(const NBEdge *incoming, const NBEdge *outgoing, int fromLane, int toLane, bool mayDefinitelyPass, const std::string &tlID) const
get link state
Definition: NBNode.cpp:2432
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:336
The base class for traffic light logic definitions.
NBTrafficLightLogic * compute(const 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:60
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
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 amount
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
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 GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, 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 segmentWidth
width of dotted contour segments
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:261
int fromLane
The lane the connections starts at.
Definition: NBEdge.h:210
int toLane
The lane the connections yields in.
Definition: NBEdge.h:216
SVCPermissions permissions
List of vehicle types that are allowed on this connection.
Definition: NBEdge.h:252
double speed
custom speed for connection
Definition: NBEdge.h:240
NBEdge * toEdge
The edge the connections yields in.
Definition: NBEdge.h:213
KeepClear keepClear
whether the junction must be kept clear when using this connection
Definition: NBEdge.h:231
double customLength
custom length for connection
Definition: NBEdge.h:246
std::string edgeType
optional type of Connection
Definition: NBEdge.h:264
bool uncontrolled
check if Connection is uncontrolled
Definition: NBEdge.h:297
PositionVector customShape
custom shape for connection
Definition: NBEdge.h:249
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
Definition: NBEdge.h:228
SVCPermissions changeLeft
List of vehicle types that are allowed to change Left from this connections internal lane(s)
Definition: NBEdge.h:255
SVCPermissions changeRight
List of vehicle types that are allowed to change right from this connections internal lane(s)
Definition: NBEdge.h:258
PositionVector viaShape
shape of via
Definition: NBEdge.h:282
double contPos
custom position for internal junction on this connection
Definition: NBEdge.h:234
std::string tlID
The id of the traffic light that controls this connection.
Definition: NBEdge.h:219
double visibility
custom foe visiblity for connection
Definition: NBEdge.h:237
int tlLinkIndex2
The index of the internal junction within the controlling traffic light (optional)
Definition: NBEdge.h:225
PositionVector shape
shape of Connection
Definition: NBEdge.h:270
bool haveVia
check if Connection have a Via
Definition: NBEdge.h:276
int tlLinkIndex
The index of this connection within the controlling traffic light.
Definition: NBEdge.h:222