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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A class for visualizing connections between lanes
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #include <string>
25 #include <iostream>
26 #include <utility>
27 #include <time.h>
34 #include <utils/common/ToString.h>
37 #include <utils/gui/div/GLHelper.h>
42 #include <netedit/GNENet.h>
43 #include <netedit/GNEUndoList.h>
44 #include <netedit/GNEViewNet.h>
45 #include <netedit/GNEViewParent.h>
46 
47 #include "GNEConnection.h"
48 #include "GNEJunction.h"
49 #include "GNEEdge.h"
50 #include "GNELane.h"
51 #include "GNEInternalLane.h"
52 
53 
54 // ===========================================================================
55 // static member definitions
56 // ===========================================================================
57 int NUM_POINTS = 5;
58 
59 // ===========================================================================
60 // method definitions
61 // ===========================================================================
62 
64  GNENetElement(from->getNet(), "from" + from->getMicrosimID() + "to" + to->getMicrosimID(),
66  myFromLane(from),
67  myToLane(to),
68  myLinkState(LINKSTATE_TL_OFF_NOSIGNAL),
69  mySpecialColor(0),
70  myShapeDeprecated(true) {
71 }
72 
73 
75 }
76 
77 
78 void
80  // Get shape of from and to lanes
82  if (myShapeDeprecated) {
83  // first check if object has to be removed from grid (SUMOTree)
84  if (updateGrid) {
86  }
87  // Clear containers
88  myShape.clear();
89  myShapeRotations.clear();
90  myShapeLengths.clear();
91 
92  PositionVector laneShapeFrom;
93  if ((int)getEdgeFrom()->getNBEdge()->getLanes().size() > nbCon.fromLane) {
94  laneShapeFrom = getEdgeFrom()->getNBEdge()->getLanes().at(nbCon.fromLane).shape;
95  } else {
96  return;
97  }
98  PositionVector laneShapeTo;
99  if ((int)nbCon.toEdge->getLanes().size() > nbCon.toLane) {
100  laneShapeTo = nbCon.toEdge->getLanes().at(nbCon.toLane).shape;
101  } else {
102  return;
103  }
104  // Calculate shape of connection depending of the size of Junction shape
105  // value obtanied from GNEJunction::drawgl
106  if (nbCon.customShape.size() != 0) {
107  myShape = nbCon.customShape;
108  } else if (getEdgeFrom()->getNBEdge()->getToNode()->getShape().area() > 4) {
109  if (nbCon.shape.size() != 0) {
110  myShape = nbCon.shape;
111  // only append via shape if it exists
112  if (nbCon.haveVia) {
113  myShape.append(nbCon.viaShape);
114  }
115  } else {
116  // Calculate shape so something can be drawn immidiately
118  laneShapeFrom,
119  laneShapeTo,
120  NUM_POINTS, getEdgeFrom()->getNBEdge()->getTurnDestination() == nbCon.toEdge,
121  (double) 5. * (double) getEdgeFrom()->getNBEdge()->getNumLanes(),
122  (double) 5. * (double) nbCon.toEdge->getNumLanes());
123  }
124  } else {
125  myShape.clear();
126  myShape.push_back(laneShapeFrom.positionAtOffset(MAX2(0.0, laneShapeFrom.length() - 1)));
127  myShape.push_back(laneShapeTo.positionAtOffset(MIN2(1.0, laneShapeFrom.length())));
128  }
129  // check if internal junction marker must be calculated
130  if (nbCon.haveVia && (nbCon.shape.size() != 0)) {
131  // create marker for interal junction waiting position (contPos)
132  const double orthoLength = 0.5;
133  Position pos = nbCon.shape.back();
134  myInternalJunctionMarker = nbCon.shape.getOrthogonal(pos, 10, true, 0.1);
135  if (myInternalJunctionMarker.length() < orthoLength) {
137  }
138  } else {
139  myInternalJunctionMarker.clear();
140  }
141  // Obtain lengths and shape rotations
142  int segments = (int) myShape.size() - 1;
143  if (segments >= 0) {
144  myShapeRotations.reserve(segments);
145  myShapeLengths.reserve(segments);
146  for (int i = 0; i < segments; ++i) {
147  const Position& f = myShape[i];
148  const Position& s = myShape[i + 1];
149  myShapeLengths.push_back(f.distanceTo2D(s));
150  myShapeRotations.push_back((double) atan2((s.x() - f.x()), (f.y() - s.y())) * (double) 180.0 / (double)M_PI);
151  }
152  }
153 
154  // mark connection as non-deprecated
155  myShapeDeprecated = false;
156 
157  // last step is to check if object has to be added into grid (SUMOTree) again
158  if (updateGrid) {
159  myNet->addGLObjectIntoGrid(this);
160  }
161  }
162 }
163 
164 
165 Boundary
167  if (myShape.size() == 0) {
168  // we need to use the center of junction parent as boundary if shape is empty
170  return Boundary(junctionParentPosition.x() - 0.1, junctionParentPosition.y() - 0.1,
171  junctionParentPosition.x() + 0.1, junctionParentPosition.x() + 0.1);
172  } else {
173  return myShape.getBoxBoundary();
174  }
175 }
176 
177 
178 GNEEdge*
180  return &(myFromLane->getParentEdge());
181 }
182 
183 
184 GNEEdge*
186  return &(myToLane->getParentEdge());
187 }
188 
189 
190 GNELane*
192  return myFromLane;
193 }
194 
195 
196 GNELane*
198  return myToLane;
199 }
200 
201 
202 int
204  return myFromLane->getIndex();
205 }
206 
207 
208 int
210  return myToLane->getIndex();
211 }
212 
213 
217 }
218 
219 
222  return NBConnection(getEdgeFrom()->getNBEdge(), getFromLaneIndex(),
223  getEdgeTo()->getNBEdge(), getToLaneIndex(),
224  (int)getNBEdgeConnection().tlLinkIndex);
225 }
226 
227 
228 void
231 }
232 
233 
234 LinkState
236  return myLinkState;
237 }
238 
239 
240 const PositionVector&
242  if (myShape.size() > 0) {
243  return myShape;
244  } else {
246  }
247 }
248 
249 
250 void
252  myShapeDeprecated = true;
253 }
254 
255 
256 void
260  nbCon.toEdge,
261  nbCon.fromLane,
262  nbCon.toLane,
263  nbCon.mayDefinitelyPass,
264  nbCon.tlID);
265 }
266 
267 
270  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
271  buildPopupHeader(ret, app);
274  // build selection and show parameters menu
277  // build position copy entry
278  buildPositionCopyEntry(ret, false);
279  // create menu commands
280  FXMenuCommand* mcCustomShape = new FXMenuCommand(ret, "Set custom connection shape", 0, &parent, MID_GNE_CONNECTION_EDIT_SHAPE);
281  // check if menu commands has to be disabled
282  EditMode editMode = myNet->getViewNet()->getCurrentEditMode();
283  const bool wrongMode = (editMode == GNE_MODE_CONNECT || editMode == GNE_MODE_TLS || editMode == GNE_MODE_CREATE_EDGE);
284  if (wrongMode) {
285  mcCustomShape->disable();
286  }
287  return ret;
288 }
289 
290 
291 Boundary
293  Boundary b = getBoundary();
294  b.grow(20);
295  return b;
296 }
297 
298 
299 void
301  // Check if connection must be drawed
303  // Push draw matrix 1
304  glPushMatrix();
305  // Push name
306  glPushName(getGlID());
307  // Traslate matrix
308  glTranslated(0, 0, GLO_JUNCTION + 0.1); // must draw on top of junction
309  // Set color
311  // override with special colors (unless the color scheme is based on selection)
313  } else if (mySpecialColor != 0) {
315  } else {
316  // Set color depending of the link state
318  }
319  // draw connection checking whether it is not too small if isn't being drawn for selecting
320  if ((s.scale < 1.) && !s.drawForSelecting) {
321  // If it's small, dra a simple line
323  } else {
324  // draw a list of lines
326  glTranslated(0, 0, 0.1);
327  GLHelper::setColor(GLHelper::getColor().changedBrightness(51));
328  // check if internal junction marker has to be drawn
329  if (myInternalJunctionMarker.size() > 0) {
331  }
332  }
333  // check if dotted contour has to be drawn
334  if (!s.drawForSelecting && (myNet->getViewNet()->getACUnderCursor() == this)) {
336  }
337  // Pop name
338  glPopName();
339  // Pop draw matrix 1
340  glPopMatrix();
341  }
342 }
343 
344 
345 void
347  mySpecialColor = color;
348 }
349 
350 std::string
352  if (key == SUMO_ATTR_ID) {
353  // used by GNEReferenceCounter
354  // @note: may be called for connections without a valid nbCon reference
355  return getMicrosimID();
356  }
358  switch (key) {
359  case SUMO_ATTR_FROM:
360  return getEdgeFrom()->getID();
361  case SUMO_ATTR_TO:
362  return nbCon.toEdge->getID();
363  case SUMO_ATTR_FROM_LANE:
364  return toString(nbCon.toLane);
365  case SUMO_ATTR_TO_LANE:
366  return toString(nbCon.toLane);
367  case SUMO_ATTR_PASS:
368  return toString(nbCon.mayDefinitelyPass);
370  return toString(nbCon.keepClear);
371  case SUMO_ATTR_CONTPOS:
372  return toString(nbCon.contPos);
374  return toString(nbCon.uncontrolled);
376  return toString(nbCon.visibility);
378  return toString(nbCon.tlLinkIndex);
379  case SUMO_ATTR_SPEED:
380  return toString(nbCon.speed);
382  return toString(nbCon.customShape);
383  case GNE_ATTR_SELECTED:
385  case GNE_ATTR_GENERIC:
386  return getGenericParametersStr();
387  default:
388  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
389  }
390 }
391 
392 
393 void
394 GNEConnection::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
395  switch (key) {
396  case SUMO_ATTR_FROM:
397  case SUMO_ATTR_TO:
398  case SUMO_ATTR_FROM_LANE:
399  case SUMO_ATTR_TO_LANE:
400  case SUMO_ATTR_PASS:
402  case SUMO_ATTR_CONTPOS:
405  case SUMO_ATTR_SPEED:
407  case GNE_ATTR_SELECTED:
408  case GNE_ATTR_GENERIC:
409  // no special handling
410  undoList->p_add(new GNEChange_Attribute(this, key, value));
411  break;
413  if (value != getAttribute(key)) {
414  // trigger GNEChange_TLS
415  undoList->p_begin("change tls linkIndex for connection");
416  // make a copy
417  std::set<NBTrafficLightDefinition*> defs = getEdgeFrom()->getNBEdge()->getToNode()->getControllingTLS();
418  for (NBTrafficLightDefinition* tlDef : defs) {
419  NBLoadedSUMOTLDef* sumoDef = dynamic_cast<NBLoadedSUMOTLDef*>(tlDef);
420  NBTrafficLightLogic* tllogic = sumoDef ? sumoDef->getLogic() : tlDef->compute(OptionsCont::getOptions());
421  if (tllogic != 0) {
422  NBLoadedSUMOTLDef* newDef = new NBLoadedSUMOTLDef(tlDef, tllogic);
423  newDef->addConnection(getEdgeFrom()->getNBEdge(), getEdgeTo()->getNBEdge(),
424  getLaneFrom()->getIndex(), getLaneTo()->getIndex(), parse<int>(value), false);
425  std::vector<NBNode*> nodes = tlDef->getNodes();
426  for (NBNode* node : nodes) {
427  GNEJunction* junction = getNet()->retrieveJunction(node->getID());
428  undoList->add(new GNEChange_TLS(junction, tlDef, false), true);
429  undoList->add(new GNEChange_TLS(junction, newDef, true), true);
430  }
431  } else {
432  WRITE_ERROR("Could not set attribute '" + toString(key) + "' (tls is broken)");
433  }
434  }
435  undoList->p_end();
436  }
437  break;
438  default:
439  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
440  }
441 }
442 
443 
444 bool
445 GNEConnection::isValid(SumoXMLAttr key, const std::string& value) {
446  // Currently ignored before implementation to avoid warnings
447  switch (key) {
448  case SUMO_ATTR_FROM:
449  case SUMO_ATTR_TO:
450  case SUMO_ATTR_FROM_LANE:
451  case SUMO_ATTR_TO_LANE:
452  return false;
453  case SUMO_ATTR_PASS:
454  return canParse<bool>(value);
456  return canParse<bool>(value);
457  case SUMO_ATTR_CONTPOS:
458  return canParse<double>(value);
460  return canParse<bool>(value);
462  return canParse<double>(value) && (parse<double>(value) > 0);
464  if (getNBEdgeConnection().uncontrolled == false
465  && getEdgeFrom()->getNBEdge()->getToNode()->getControllingTLS().size() > 0
466  && canParse<int>(value)
467  && parse<int>(value) >= 0) {
469  return def->getMaxValidIndex() >= parse<int>(value);
470  } else {
471  return false;
472  }
473  case SUMO_ATTR_SPEED:
474  return canParse<double>(value) && (parse<double>(value) > 0);
475  case SUMO_ATTR_CUSTOMSHAPE: {
476  bool ok = true;
477  PositionVector shape = GeomConvHelper::parseShapeReporting(value, "user-supplied shape", 0, ok, true);
478  return ok;
479  }
480  case GNE_ATTR_SELECTED:
481  return canParse<bool>(value);
482  case GNE_ATTR_GENERIC:
483  return isGenericParametersValid(value);
484  default:
485  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
486  }
487 }
488 
489 
490 bool
491 GNEConnection::addGenericParameter(const std::string& key, const std::string& value) {
492  if (!getNBEdgeConnection().knowsParameter(key)) {
493  getNBEdgeConnection().setParameter(key, value);
494  return true;
495  } else {
496  return false;
497  }
498 }
499 
500 
501 bool
502 GNEConnection::removeGenericParameter(const std::string& key) {
503  if (getNBEdgeConnection().knowsParameter(key)) {
505  return true;
506  } else {
507  return false;
508  }
509 }
510 
511 
512 bool
513 GNEConnection::updateGenericParameter(const std::string& oldKey, const std::string& newKey) {
514  if (getNBEdgeConnection().knowsParameter(oldKey) && !getNBEdgeConnection().knowsParameter(newKey)) {
515  std::string value = getNBEdgeConnection().getParameter(oldKey);
517  getNBEdgeConnection().setParameter(newKey, value);
518  return true;
519  } else {
520  return false;
521  }
522 }
523 
524 
525 bool
526 GNEConnection::updateGenericParameterValue(const std::string& key, const std::string& newValue) {
527  if (getNBEdgeConnection().knowsParameter(key)) {
528  getNBEdgeConnection().setParameter(key, newValue);
529  return true;
530  } else {
531  return false;
532  }
533 }
534 
535 
536 std::string
538  std::string result;
539  // Generate an string using the following structure: "key1=value1|key2=value2|...
540  for (auto i : getNBEdgeConnection().getParametersMap()) {
541  result += i.first + "=" + i.second + "|";
542  }
543  // remove the last "|"
544  if (!result.empty()) {
545  result.pop_back();
546  }
547  return result;
548 }
549 
550 
551 std::vector<std::pair<std::string, std::string> >
553  std::vector<std::pair<std::string, std::string> > result;
554  // iterate over parameters map and fill result
555  for (auto i : getNBEdgeConnection().getParametersMap()) {
556  result.push_back(std::make_pair(i.first, i.second));
557  }
558  return result;
559 }
560 
561 
562 void
563 GNEConnection::setGenericParametersStr(const std::string& value) {
564  // clear parameters
566  // separate value in a vector of string using | as separator
567  std::vector<std::string> parsedValues;
568  StringTokenizer stValues(value, "|", true);
569  while (stValues.hasNext()) {
570  parsedValues.push_back(stValues.next());
571  }
572  // check that parsed values (A=B)can be parsed in generic parameters
573  for (auto i : parsedValues) {
574  std::vector<std::string> parsedParameters;
575  StringTokenizer stParam(i, "=", true);
576  while (stParam.hasNext()) {
577  parsedParameters.push_back(stParam.next());
578  }
579  // Check that parsed parameters are exactly two and contains valid chracters
580  if (parsedParameters.size() == 2 && SUMOXMLDefinitions::isValidGenericParameterKey(parsedParameters.front()) && SUMOXMLDefinitions::isValidGenericParameterValue(parsedParameters.back())) {
581  getNBEdgeConnection().setParameter(parsedParameters.front(), parsedParameters.back());
582  }
583  }
584 }
585 
586 // ===========================================================================
587 // private
588 // ===========================================================================
589 
590 void
591 GNEConnection::setAttribute(SumoXMLAttr key, const std::string& value) {
593  switch (key) {
594  case SUMO_ATTR_PASS:
595  nbCon.mayDefinitelyPass = parse<bool>(value);
596  break;
598  nbCon.keepClear = parse<bool>(value);
599  break;
601  nbCon.uncontrolled = parse<bool>(value);
602  break;
603  case SUMO_ATTR_CONTPOS:
604  nbCon.contPos = parse<double>(value);
605  break;
607  nbCon.visibility = parse<double>(value);
608  break;
609  case SUMO_ATTR_SPEED:
610  nbCon.speed = parse<double>(value);
611  break;
612  case SUMO_ATTR_CUSTOMSHAPE: {
613  bool ok;
614  const bool init = (myShape.size() == 0);
615  if (!init) {
616  // first remove object from net grid
618  }
619  nbCon.customShape = GeomConvHelper::parseShapeReporting(value, "user-supplied shape", 0, ok, true);
620  if (!init) {
621  // add object into net again
622  myNet->addGLObjectIntoGrid(this);
623  }
624  break;
625  }
626  case GNE_ATTR_SELECTED:
627  if (parse<bool>(value)) {
629  } else {
631  }
632  break;
633  case GNE_ATTR_GENERIC:
635  break;
636  default:
637  throw InvalidArgument(toString(getTag()) + " doesn't have an attribute of type '" + toString(key) + "'");
638  }
639  // After setting attribute always update Geometry
640  updateGeometry(true);
641 }
642 
643 
644 void
646 }
647 
648 
649 /****************************************************************************/
int NUM_POINTS
bool updateGenericParameter(const std::string &oldKey, const std::string &newKey)
update generic parameter
const GNEAttributeCarrier * getACUnderCursor() const
get AttributeCarrier under cursor
Position getPositionInView() const
Return current position.
std::vector< double > myShapeLengths
The lengths of the shape parts.
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:160
LinkState getLinkState(const NBEdge *incoming, NBEdge *outgoing, int fromLane, int toLane, bool mayDefinitelyPass, const std::string &tlID) const
get link state
Definition: NBNode.cpp:1787
int toLane
The lane the connections yields in.
Definition: NBEdge.h:188
double scale
information about a lane&#39;s width (temporary, used for a single view)
bool isValid(SumoXMLAttr key, const std::string &value)
Whether vehicles must keep the junction clear.
whether a given shape is user-defined
GNENet * myNet
the net to inform about updates
std::string next()
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:178
void append(const PositionVector &v, double sameThreshold=2.0)
PositionVector getOrthogonal(const Position &p, double extend, bool before, double length=1.0) const
return orthogonal through p (extending this vector if necessary)
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
NBEdge * toEdge
The edge the connections yields in.
Definition: NBEdge.h:185
GNENet * getNet() const
get Net in which this element is placed
bool updateGenericParameterValue(const std::string &key, const std::string &newValue)
update value generic parameter
A loaded (complete) traffic light logic.
LinkState getLinkState() const
get LinkState
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:243
A SUMO-compliant built logic for a traffic light.
Stores the information about how to visualize structures.
connectio between two lanes
a connection
double y() const
Returns the y-position.
Definition: Position.h:61
foe visibility distance of a link
void unsetParameter(const std::string &key)
Removes a parameter.
static RGBColor colorForLinksState(FXuint state)
return the color for each linkstate
double x() const
Returns the x-position.
Definition: Position.h:56
mode for editing tls
Definition: GNEViewNet.h:58
The base class for traffic light logic definitions.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
T MAX2(T a, T b)
Definition: StdDefs.h:76
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:47
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:78
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:587
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
Definition: NBEdge.h:197
GNELane * myFromLane
incoming lane of this connection
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
double visibility
custom foe visiblity for connection
Definition: NBEdge.h:206
const std::string & getID() const
Returns the id.
Definition: Named.h:69
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
The link is controlled by a tls which is off, not blinking, may pass.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
static bool isValidGenericParameterKey(const std::string &value)
whether the given string is a valid key for a generic parameter
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used, also builds an entry for copying the geo-position.
generic attribute
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
void setSpecialColor(const RGBColor *Color2)
bool removeGenericParameter(const std::string &key)
remove generic parameter
PositionVector customShape
custom shape for connection
Definition: NBEdge.h:212
GNEEdge * getEdgeTo() const
get the name of the edge the vehicles may reach when leaving "from"
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
void mouseOverObject(const GUIVisualizationSettings &s) const
method for check if mouse is over objects
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
GNELane * getLaneFrom() const
get lane of the incoming lane
double area() const
Returns the area (0 for non-closed)
PositionVector shape
shape of Connection
Definition: NBEdge.h:218
bool keepClear
whether the junction must be kept clear when using this connection
Definition: NBEdge.h:200
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
NBEdge::Connection & getNBEdgeConnection() const
get Edge::Connection
bool myShapeDeprecated
flag to indicate that connection&#39;s shape has to be updated
int getFromLaneIndex() const
get lane index of the incoming lane
int getToLaneIndex() const
get lane index of the outgoing lane
PositionVector myShape
the shape of the connection
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:767
static bool isValidGenericParameterValue(const std::string &value)
whether the given string is a valid value for a generic parameter
double speed
custom speed for connection
Definition: NBEdge.h:209
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void updateID()
update internal ID of Connection
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:573
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1298
std::vector< double > myShapeRotations
LinkState myLinkState
Linkstate.
std::string tlID
The id of the traffic light that controls this connection.
Definition: NBEdge.h:191
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:418
int fromLane
The lane the connections starts at.
Definition: NBEdge.h:182
GNEConnection(GNELane *from, GNELane *to)
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
Definition: GNEUndoList.cpp:85
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GNEJunction * retrieveJunction(const std::string &id, bool failHard=true)
get junction by id
Definition: GNENet.cpp:902
GNELane * getLaneTo() const
get lane of the outgoing lane
A list of positions.
GNEEdge * getEdgeFrom() const
get the name of the edge the vehicles leave
static bool isGenericParametersValid(const std::string &value)
check if given string can be parsed to a map/list of generic parameters
void removeGLObjectFromGrid(GUIGlObject *o)
add GL Object into net
Definition: GNENet.cpp:1175
void addConnection(NBEdge *from, NBEdge *to, int fromLane, int toLane, int linkIndex, bool reconstruct=true)
Adds a connection and immediately informs the edges.
friend class GNEChange_Attribute
declare friend class
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:453
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
Boundary getBoundary() const
Returns the street&#39;s geometry.
T MIN2(T a, T b)
Definition: StdDefs.h:70
GNELane * myToLane
outgoing lane of this connection
NBTrafficLightLogic * getLogic()
Returns the internal logic.
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
~GNEConnection()
Destructor.
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
GUIColorer junctionColorer
The junction colorer.
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
const std::string getID() const
function to support debugging
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:270
EditMode
Definition: GNEViewNet.h:42
void selectAttributeCarrier(bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
int tlLinkIndex
The index of this connection within the controlling traffic light.
Definition: NBEdge.h:194
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
EditMode getCurrentEditMode() const
get the current edit mode
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:1911
std::vector< std::pair< std::string, std::string > > getGenericParameters() const
return generic parameters as vector of pairs format
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:248
void updateGeometry(bool updateGrid)
update pre-computed geometry information
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:263
double length() const
Returns the length.
PositionVector viaShape
shape of via
Definition: NBEdge.h:230
NBConnection getNBConnection() const
get NBConnection
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
#define M_PI
Definition: odrSpiral.cpp:40
static void drawShapeDottedContour(const int type, const PositionVector &shape, const double width)
draw a dotted contour around the given Non closed shape with certain width
Definition: GLHelper.cpp:471
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:302
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
bool showConnections()
show connections over junctions
Definition: GNEViewNet.cpp:343
static const RGBColor selectedConnectionColor
color of selected connection
Definition: GNENet.h:102
bool addGenericParameter(const std::string &key, const std::string &value)
add generic parameter
PositionVector myInternalJunctionMarker
waiting position for internal junction
double contPos
custom position for internal junction on this connection
Definition: NBEdge.h:203
element is selected
bool uncontrolled
check if Connection is uncontrolled
Definition: NBEdge.h:242
void markConnectionGeometryDeprecated()
check that connection&#39;s Geometry has to be updated
The popup menu of a globject.
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
std::string getAttribute(SumoXMLAttr key) const
Represents a single node (junction) during network building.
Definition: NBNode.h:68
GUIGlID getGlID() const
Returns the numerical id of the object.
void updateLinkState()
recompute cached myLinkState
link: the index of the link within the traffic light
edit junction shape
Definition: GUIAppEnum.h:734
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
virtual int getMaxValidIndex()
Returns the maximum index controlled by this traffic light.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
mode for connecting lanes
Definition: GNEViewNet.h:56
mode for creating new edges
Definition: GNEViewNet.h:46
NBEdge * getNBEdge()
returns the internal NBEdge
Definition: GNEEdge.cpp:586
const PositionVector & getShape() const
get Position vector calculated in updateGeometry(bool updateGrid)
bool haveVia
check if Connection have a Via
Definition: NBEdge.h:224
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
PositionVector computeSmoothShape(const PositionVector &begShape, const PositionVector &endShape, int numPoints, bool isTurnaround, double extrapolateBeg, double extrapolateEnd, NBNode *recordError=0, int shapeFlag=0) const
Compute a smooth curve between the given geometries.
Definition: NBNode.cpp:474
void addGLObjectIntoGrid(GUIGlObject *o)
add GL Object into net
Definition: GNENet.cpp:1168
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
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:1111
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:439
static PositionVector parseShapeReporting(const std::string &shpdef, const std::string &objecttype, const char *objectid, bool &ok, bool allowEmpty, bool report=true)
Builds a PositionVector from a string representation, reporting occurred errors.
std::string getGenericParametersStr() const
return generic parameters in string format
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
const RGBColor * mySpecialColor
optional special color
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1745
void clearParameter()
Clears the parameter map.
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
a junction
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:579
SumoXMLTag getTag() const
get XML Tag assigned to this object