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-2019 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 
27 #include <utils/gui/div/GLHelper.h>
32 #include <netedit/GNENet.h>
33 #include <netedit/GNEUndoList.h>
34 #include <netedit/GNEViewNet.h>
36 
37 #include "GNEConnection.h"
38 #include "GNEJunction.h"
39 #include "GNEEdge.h"
40 #include "GNELane.h"
41 #include "GNEInternalLane.h"
42 
43 
44 // ===========================================================================
45 // static member definitions
46 // ===========================================================================
47 int NUM_POINTS = 5;
48 
49 // ===========================================================================
50 // method definitions
51 // ===========================================================================
52 
54  GNENetElement(from->getNet(), "from" + from->getMicrosimID() + "to" + to->getMicrosimID(),
56  myFromLane(from),
57  myToLane(to),
58  myLinkState(LINKSTATE_TL_OFF_NOSIGNAL),
59  mySpecialColor(nullptr),
60  myShapeDeprecated(true) {
61 }
62 
63 
65 }
66 
67 
68 std::string
70  // currently unused
71  return "";
72 }
73 
74 
75 void
77  // Get shape of from and to lanes
79  if (myShapeDeprecated) {
80  // Clear geometry
82  // obtain lane shape from
83  PositionVector laneShapeFrom;
84  if ((int)getEdgeFrom()->getNBEdge()->getLanes().size() > nbCon.fromLane) {
85  laneShapeFrom = getEdgeFrom()->getNBEdge()->getLanes().at(nbCon.fromLane).shape;
86  } else {
87  return;
88  }
89  // obtain lane shape to
90  PositionVector laneShapeTo;
91  if ((int)nbCon.toEdge->getLanes().size() > nbCon.toLane) {
92  laneShapeTo = nbCon.toEdge->getLanes().at(nbCon.toLane).shape;
93  } else {
94  return;
95  }
96  // Calculate shape of connection depending of the size of Junction shape
97  // value obtanied from GNEJunction::drawgl
98  if (nbCon.customShape.size() != 0) {
100  } else if (getEdgeFrom()->getNBEdge()->getToNode()->getShape().area() > 4) {
101  if (nbCon.shape.size() != 0) {
102  myGeometry.shape = nbCon.shape;
103  // only append via shape if it exists
104  if (nbCon.haveVia) {
106  }
107  } else {
108  // Calculate shape so something can be drawn immidiately
110  laneShapeFrom,
111  laneShapeTo,
112  NUM_POINTS, getEdgeFrom()->getNBEdge()->getTurnDestination() == nbCon.toEdge,
113  (double) 5. * (double) getEdgeFrom()->getNBEdge()->getNumLanes(),
114  (double) 5. * (double) nbCon.toEdge->getNumLanes());
115  }
116  } else {
117  myGeometry.shape.push_back(laneShapeFrom.positionAtOffset(MAX2(0.0, laneShapeFrom.length() - 1)));
118  myGeometry.shape.push_back(laneShapeTo.positionAtOffset(MIN2(1.0, laneShapeFrom.length())));
119  }
120  // check if internal junction marker must be calculated
121  if (nbCon.haveVia && (nbCon.shape.size() != 0)) {
122  // create marker for interal junction waiting position (contPos)
123  const double orthoLength = 0.5;
124  Position pos = nbCon.shape.back();
125  myInternalJunctionMarker = nbCon.shape.getOrthogonal(pos, 10, true, 0.1);
126  if (myInternalJunctionMarker.length() < orthoLength) {
128  }
129  } else {
130  myInternalJunctionMarker.clear();
131  }
132  // Obtain lengths and shape rotations
134  // mark connection as non-deprecated
135  myShapeDeprecated = false;
136  }
137 }
138 
139 
140 Position
142  // currently unused
143  return Position(0, 0);
144 }
145 
146 
147 Boundary
149  if (myGeometry.shape.size() == 0) {
150  // we need to use the center of junction parent as boundary if shape is empty
152  return Boundary(junctionParentPosition.x() - 0.1, junctionParentPosition.y() - 0.1,
153  junctionParentPosition.x() + 0.1, junctionParentPosition.x() + 0.1);
154  } else {
156  }
157 }
158 
159 
160 GNEEdge*
162  return &(myFromLane->getParentEdge());
163 }
164 
165 
166 GNEEdge*
168  return &(myToLane->getParentEdge());
169 }
170 
171 
172 GNELane*
174  return myFromLane;
175 }
176 
177 
178 GNELane*
180  return myToLane;
181 }
182 
183 
184 int
186  return myFromLane->getIndex();
187 }
188 
189 
190 int
192  return myToLane->getIndex();
193 }
194 
195 
199 }
200 
201 
204  return NBConnection(getEdgeFrom()->getNBEdge(), getFromLaneIndex(),
205  getEdgeTo()->getNBEdge(), getToLaneIndex(),
206  (int)getNBEdgeConnection().tlLinkIndex);
207 }
208 
209 
210 void
213 }
214 
215 
216 LinkState
218  return myLinkState;
219 }
220 
221 
222 const PositionVector&
224  if (myGeometry.shape.size() > 0) {
225  return myGeometry.shape;
226  } else {
228  }
229 }
230 
231 
232 void
234  myShapeDeprecated = true;
235 }
236 
237 
238 void
242  nbCon.toEdge,
243  nbCon.fromLane,
244  nbCon.toLane,
245  nbCon.mayDefinitelyPass,
246  nbCon.tlID);
247 }
248 
249 
252  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
253  buildPopupHeader(ret, app);
256  // build selection and show parameters menu
259  // build position copy entry
260  buildPositionCopyEntry(ret, false);
261  // create menu commands
262  FXMenuCommand* mcCustomShape = new FXMenuCommand(ret, "Set custom connection shape", nullptr, &parent, MID_GNE_CONNECTION_EDIT_SHAPE);
263  // check if menu commands has to be disabled
265  const bool wrongMode = (editMode == GNE_NMODE_CONNECT || editMode == GNE_NMODE_TLS || editMode == GNE_NMODE_CREATE_EDGE);
266  if (wrongMode) {
267  mcCustomShape->disable();
268  }
269  return ret;
270 }
271 
272 
273 Boundary
275  Boundary b = getBoundary();
276  b.grow(20);
277  return b;
278 }
279 
280 
281 void
283  // declare a flag to check if shape has to be draw
284  bool drawConnection = true;
287  drawConnection = !myShapeDeprecated;
290  drawConnection = !myShapeDeprecated;
291  } else {
292  drawConnection = false;
293  }
294  // Check if connection must be drawed
295  if (drawConnection) {
296  // check if boundary has to be drawn
297  if (s.drawBoundaries) {
299  }
300  // Push draw matrix 1
301  glPushMatrix();
302  // Push name
303  glPushName(getGlID());
304  // Traslate matrix
305  glTranslated(0, 0, GLO_JUNCTION + 0.1); // must draw on top of junction
306  // Set color
307  if (drawUsingSelectColor()) {
308  // override with special colors (unless the color scheme is based on selection)
310  } else if (mySpecialColor != nullptr) {
312  } else {
313  // Set color depending of the link state
315  }
316  // draw connection checking whether it is not too small if isn't being drawn for selecting
317  const double selectionScale = isAttributeCarrierSelected() ? s.selectionScale : 1;
318  if ((s.scale * selectionScale < 5.) && !s.drawForSelecting) {
319  // If it's small, draw a simple line
321  } else {
322  // draw a list of lines
323  const bool spreadSuperposed = s.scale >= 1 && s.spreadSuperposed && myFromLane->drawAsRailway(s) && getEdgeFrom()->getNBEdge()->isBidiRail();
324  PositionVector shapeSuperposed = myGeometry.shape;
325  if (spreadSuperposed) {
326  shapeSuperposed.move2side(0.5);
327  }
328  GLHelper::drawBoxLines(shapeSuperposed, myGeometry.shapeRotations, myGeometry.shapeLengths, 0.2 * selectionScale);
329  glTranslated(0, 0, 0.1);
330  GLHelper::setColor(GLHelper::getColor().changedBrightness(51));
331  // check if internal junction marker has to be drawn
332  if (myInternalJunctionMarker.size() > 0) {
334  }
335  // check if dotted contour has to be drawn (not useful at high zoom)
336  if (myNet->getViewNet()->getDottedAC() == this) {
337  GLHelper::drawShapeDottedContourAroundShape(s, getType(), shapeSuperposed, 0.25);
338  }
339  }
340  // Pop name
341  glPopName();
342  // Pop draw matrix 1
343  glPopMatrix();
344  }
345 }
346 
347 
348 void
350  mySpecialColor = color;
351 }
352 
353 std::string
355  if (key == SUMO_ATTR_ID) {
356  // used by GNEReferenceCounter
357  // @note: may be called for connections without a valid nbCon reference
358  return getMicrosimID();
359  }
361  switch (key) {
362  case SUMO_ATTR_FROM:
363  return getEdgeFrom()->getID();
364  case SUMO_ATTR_TO:
365  return nbCon.toEdge->getID();
366  case SUMO_ATTR_FROM_LANE:
367  return toString(nbCon.toLane);
368  case SUMO_ATTR_TO_LANE:
369  return toString(nbCon.toLane);
370  case SUMO_ATTR_PASS:
371  return toString(nbCon.mayDefinitelyPass);
373  return toString(nbCon.keepClear);
374  case SUMO_ATTR_CONTPOS:
375  return toString(nbCon.contPos);
377  return toString(nbCon.uncontrolled);
379  return toString(nbCon.visibility);
381  return toString(nbCon.tlLinkIndex);
382  case SUMO_ATTR_SPEED:
383  return toString(nbCon.speed);
384  case SUMO_ATTR_DIR:
385  return toString(getEdgeFrom()->getNBEdge()->getToNode()->getDirection(
386  getEdgeFrom()->getNBEdge(), nbCon.toEdge, OptionsCont::getOptions().getBool("lefthand")));
387  case SUMO_ATTR_STATE:
388  return toString(getEdgeFrom()->getNBEdge()->getToNode()->getLinkState(
389  getEdgeFrom()->getNBEdge(), nbCon.toEdge, nbCon.fromLane, nbCon.toLane, nbCon.mayDefinitelyPass, nbCon.tlID));
391  return toString(nbCon.customShape);
392  case GNE_ATTR_SELECTED:
394  case GNE_ATTR_GENERIC:
395  return getGenericParametersStr();
396  default:
397  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
398  }
399 }
400 
401 
402 void
403 GNEConnection::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
404  switch (key) {
405  case SUMO_ATTR_FROM:
406  case SUMO_ATTR_TO:
407  case SUMO_ATTR_FROM_LANE:
408  case SUMO_ATTR_TO_LANE:
409  case SUMO_ATTR_PASS:
411  case SUMO_ATTR_CONTPOS:
414  case SUMO_ATTR_SPEED:
416  case GNE_ATTR_SELECTED:
417  case GNE_ATTR_GENERIC:
418  // no special handling
419  undoList->p_add(new GNEChange_Attribute(this, myNet, key, value));
420  break;
422  if (value != getAttribute(key)) {
423  // trigger GNEChange_TLS
424  undoList->p_begin("change tls linkIndex for connection");
425  // make a copy
426  std::set<NBTrafficLightDefinition*> defs = getEdgeFrom()->getNBEdge()->getToNode()->getControllingTLS();
427  for (NBTrafficLightDefinition* tlDef : defs) {
428  NBLoadedSUMOTLDef* sumoDef = dynamic_cast<NBLoadedSUMOTLDef*>(tlDef);
429  NBTrafficLightLogic* tllogic = sumoDef ? sumoDef->getLogic() : tlDef->compute(OptionsCont::getOptions());
430  if (tllogic != nullptr) {
431  NBLoadedSUMOTLDef* newDef = new NBLoadedSUMOTLDef(tlDef, tllogic);
432  newDef->addConnection(getEdgeFrom()->getNBEdge(), getEdgeTo()->getNBEdge(),
433  getLaneFrom()->getIndex(), getLaneTo()->getIndex(), parse<int>(value), false);
434  std::vector<NBNode*> nodes = tlDef->getNodes();
435  for (NBNode* node : nodes) {
436  GNEJunction* junction = getNet()->retrieveJunction(node->getID());
437  undoList->add(new GNEChange_TLS(junction, tlDef, false), true);
438  undoList->add(new GNEChange_TLS(junction, newDef, true), true);
439  }
440  } else {
441  WRITE_ERROR("Could not set attribute '" + toString(key) + "' (tls is broken)");
442  }
443  }
444  undoList->p_end();
445  }
446  break;
447  case SUMO_ATTR_DIR:
448  throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified");
449  case SUMO_ATTR_STATE:
450  throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified");
451  default:
452  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
453  }
454 }
455 
456 
457 bool
458 GNEConnection::isValid(SumoXMLAttr key, const std::string& value) {
459  // Currently ignored before implementation to avoid warnings
460  switch (key) {
461  case SUMO_ATTR_FROM:
462  case SUMO_ATTR_TO:
463  case SUMO_ATTR_FROM_LANE:
464  case SUMO_ATTR_TO_LANE:
465  return false;
466  case SUMO_ATTR_PASS:
467  return canParse<bool>(value);
469  return canParse<bool>(value);
470  case SUMO_ATTR_CONTPOS:
471  return canParse<double>(value) && (parse<double>(value) >= -1);
473  return canParse<bool>(value);
475  return canParse<double>(value) && (parse<double>(value) >= -1);
477  if (getNBEdgeConnection().uncontrolled == false
478  && getEdgeFrom()->getNBEdge()->getToNode()->getControllingTLS().size() > 0
479  && canParse<int>(value)
480  && parse<int>(value) >= 0) {
482  return def->getMaxValidIndex() >= parse<int>(value);
483  } else {
484  return false;
485  }
486  case SUMO_ATTR_SPEED:
487  return canParse<double>(value) && (parse<double>(value) >= -1);
488  case SUMO_ATTR_CUSTOMSHAPE: {
489  // empty custom shapes are allowed
490  return canParse<PositionVector>(value);
491  }
492  case SUMO_ATTR_STATE:
493  return false;
494  case SUMO_ATTR_DIR:
495  return false;
496  case GNE_ATTR_SELECTED:
497  return canParse<bool>(value);
498  case GNE_ATTR_GENERIC:
499  return isGenericParametersValid(value);
500  default:
501  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
502  }
503 }
504 
505 
506 std::string
508  std::string result;
509  // Generate an string using the following structure: "key1=value1|key2=value2|...
510  for (auto i : getNBEdgeConnection().getParametersMap()) {
511  result += i.first + "=" + i.second + "|";
512  }
513  // remove the last "|"
514  if (!result.empty()) {
515  result.pop_back();
516  }
517  return result;
518 }
519 
520 
521 std::vector<std::pair<std::string, std::string> >
523  std::vector<std::pair<std::string, std::string> > result;
524  // iterate over parameters map and fill result
525  for (auto i : getNBEdgeConnection().getParametersMap()) {
526  result.push_back(std::make_pair(i.first, i.second));
527  }
528  return result;
529 }
530 
531 
532 void
533 GNEConnection::setGenericParametersStr(const std::string& value) {
534  // clear parameters
536  // separate value in a vector of string using | as separator
537  std::vector<std::string> parsedValues;
538  StringTokenizer stValues(value, "|", true);
539  while (stValues.hasNext()) {
540  parsedValues.push_back(stValues.next());
541  }
542  // check that parsed values (A=B)can be parsed in generic parameters
543  for (auto i : parsedValues) {
544  std::vector<std::string> parsedParameters;
545  StringTokenizer stParam(i, "=", true);
546  while (stParam.hasNext()) {
547  parsedParameters.push_back(stParam.next());
548  }
549  // Check that parsed parameters are exactly two and contains valid chracters
550  if (parsedParameters.size() == 2 && SUMOXMLDefinitions::isValidGenericParameterKey(parsedParameters.front()) && SUMOXMLDefinitions::isValidGenericParameterValue(parsedParameters.back())) {
551  getNBEdgeConnection().setParameter(parsedParameters.front(), parsedParameters.back());
552  }
553  }
554 }
555 
556 // ===========================================================================
557 // private
558 // ===========================================================================
559 
560 void
561 GNEConnection::setAttribute(SumoXMLAttr key, const std::string& value) {
563  switch (key) {
564  case SUMO_ATTR_PASS:
565  nbCon.mayDefinitelyPass = parse<bool>(value);
566  break;
568  nbCon.keepClear = parse<bool>(value);
569  break;
571  nbCon.uncontrolled = parse<bool>(value);
572  break;
573  case SUMO_ATTR_CONTPOS:
574  nbCon.contPos = parse<double>(value);
575  break;
577  nbCon.visibility = parse<double>(value);
578  break;
579  case SUMO_ATTR_SPEED:
580  nbCon.speed = parse<double>(value);
581  break;
582  case SUMO_ATTR_STATE:
583  throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified");
584  case SUMO_ATTR_DIR:
585  throw InvalidArgument("Attribute of '" + toString(key) + "' cannot be modified");
586  case SUMO_ATTR_CUSTOMSHAPE: {
587  nbCon.customShape = parse<PositionVector>(value);
588  break;
589  }
590  case GNE_ATTR_SELECTED:
591  if (parse<bool>(value)) {
593  } else {
595  }
596  break;
597  case GNE_ATTR_GENERIC:
599  break;
600  default:
601  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
602  }
603  // Update Geometry after setting a new attribute (but avoided for certain attributes)
604  if ((key != SUMO_ATTR_ID) && (key != GNE_ATTR_GENERIC) && (key != GNE_ATTR_SELECTED)) {
606  updateGeometry();
607  }
608 }
609 
610 /****************************************************************************/
int NUM_POINTS
void updateGeometry()
update pre-computed geometry information
Position getPositionInView() const
Returns position of hierarchical element in view.
SumoXMLTag
Numbers representing SUMO-XML - element names.
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:184
LinkState getLinkState(const NBEdge *incoming, NBEdge *outgoing, int fromLane, int toLane, bool mayDefinitelyPass, const std::string &tlID) const
get link state
Definition: NBNode.cpp:2014
int toLane
The lane the connections yields in.
Definition: NBEdge.h:209
double scale
information about a lane&#39;s width (temporary, used for a single view)
bool isValid(SumoXMLAttr key, const std::string &value)
PositionVector shape
The shape of the netElement element.
Definition: GNENetElement.h:57
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()
returns the next substring when it exists. Otherwise the behaviour is undefined
bool showConnections() const
check if select show connections checkbox is enabled
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:182
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:206
GNENet * getNet() const
get Net in which this element is placed
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
A loaded (complete) traffic light logic.
NetworkEditMode
enum for network edit modes
LinkState getLinkState() const
get LinkState
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:62
foe visibility distance of a link
static RGBColor colorForLinksState(FXuint state)
return the color for each linkstate
double x() const
Returns the x-position.
Definition: Position.h:57
bool isBidiRail(bool ignoreSpread=false) const
whether this edge is part of a bidirectional railway
Definition: NBEdge.cpp:683
NetElementGeometry myGeometry
netElement geometry
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.
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
T MAX2(T a, T b)
Definition: StdDefs.h:80
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
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:73
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:644
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
Definition: NBEdge.h:218
GNELane * myFromLane
incoming lane of this connection
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
double visibility
custom foe visiblity for connection
Definition: NBEdge.h:227
bool drawAsRailway(const GUIVisualizationSettings &s) const
whether to draw this lane as a railway
Definition: GNELane.cpp:1147
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
bool hasNext()
returns the information whether further substrings exist
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.
std::string generateChildID(SumoXMLTag childTag)
gererate a new ID for an element child
generic attribute
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
void setSpecialColor(const RGBColor *Color2)
PositionVector customShape
custom shape for connection
Definition: NBEdge.h:233
mode for editing tls
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
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:239
The state of a link.
bool keepClear
whether the junction must be kept clear when using this connection
Definition: NBEdge.h:221
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
static void drawBoundary(const Boundary &b)
Draw a boundary (used for debugging)
Definition: GLHelper.cpp:812
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:625
NBEdge::Connection & getNBEdgeConnection() const
get Edge::Connection
bool myShapeDeprecated
flag to indicate that connection&#39;s shape has to be updated
GUIVisualizationSizeSettings addSize
int getFromLaneIndex() const
get lane index of the incoming lane
int getToLaneIndex() const
get lane index of the outgoing lane
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:733
std::vector< double > shapeRotations
The rotations of the single shape parts.
Definition: GNENetElement.h:60
RGBColor selectedConnectionColor
connection selection color
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:230
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
static const double connectionsDemandMode
draw connections in demand mode
void updateID()
update internal ID of Connection
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:616
GNEEdge & getParentEdge()
Returns underlying parent edge.
Definition: GNELane.cpp:1292
LinkState myLinkState
Linkstate.
std::string tlID
The id of the traffic light that controls this connection.
Definition: NBEdge.h:212
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:465
int fromLane
The lane the connections starts at.
Definition: NBEdge.h:203
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:80
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:1001
GNELane * getLaneTo() const
get lane of the outgoing lane
A list of positions.
Supermode currentSupermode
the current supermode
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 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
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
mode for creating new edges
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
Definition: GNEEdge.cpp:505
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
const std::string & getID() const
Definition: NBEdge.h:1364
Boundary getBoundary() const
Returns the street&#39;s geometry.
T MIN2(T a, T b)
Definition: StdDefs.h:74
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
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:274
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:215
std::vector< double > shapeLengths
The lengths of the single shape parts.
Definition: GNENetElement.h:63
static void drawShapeDottedContourAroundShape(const GUIVisualizationSettings &s, 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:461
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:411
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:2143
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:245
GUIVisualizationDetailSettings detailSettings
detail settings
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
double selectionScale
the current selection scaling in NETEDIT (temporary)
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:331
double length() const
Returns the length.
PositionVector viaShape
shape of via
Definition: NBEdge.h:251
NBConnection getNBConnection() const
get NBConnection
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
const GNEAttributeCarrier * getDottedAC() const
get AttributeCarrier under cursor
Definition: GNEViewNet.cpp:939
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:322
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
const std::string & getTagStr() const
get tag assigned to this object in string format
Demanding mode (Routes, Vehicles etc..)
PositionVector myInternalJunctionMarker
waiting position for internal junction
double contPos
custom position for internal junction on this connection
Definition: NBEdge.h:224
element is selected
bool uncontrolled
check if Connection is uncontrolled
Definition: NBEdge.h:263
void markConnectionGeometryDeprecated()
check that connection&#39;s Geometry has to be updated
The popup menu of a globject.
The abstract direction of a link.
std::string getAttribute(SumoXMLAttr key) const
Represents a single node (junction) during network building.
Definition: NBNode.h:68
mode for connecting lanes
GUIGlID getGlID() const
Returns the numerical id of the object.
void updateLinkState()
recompute cached myLinkState
void calculateShapeRotationsAndLengths()
calculate shape rotations and lengths
NetworkEditMode networkEditMode
the current Network edit mode
link: the index of the link within the traffic light
GUIVisualizationColorSettings colorSettings
color settings
edit junction shape
Definition: GUIAppEnum.h:857
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.
const PositionVector & getShape() const
get Position vector calculated in updateGeometry()
bool haveVia
check if Connection have a Via
Definition: NBEdge.h:245
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:399
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool spreadSuperposed
Whether to improve visualisation of superposed (rail) edges.
Network mode (Edges, junctions, etc..)
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:504
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
void clearGeometry()
reset geometry
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:1155
bool drawBoundaries
enable or disable draw boundaries
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:486
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:2067
Position getPositionInView() const
Returns position of hierarchical element in view.
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:622