Eclipse SUMO - Simulation of Urban MObility
GNELaneAreaDetector.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 //
19 /****************************************************************************/
20 
21 #include <netedit/GNENet.h>
22 #include <netedit/GNEUndoList.h>
23 #include <netedit/GNEViewNet.h>
24 #include <netedit/GNEViewParent.h>
29 #include <utils/gui/div/GLHelper.h>
32 #include <utils/xml/NamespaceIDs.h>
33 
34 #include "GNELaneAreaDetector.h"
35 #include "GNEAdditionalHandler.h"
36 
37 
38 // ===========================================================================
39 // member method definitions
40 // ===========================================================================
41 
43  GNEDetector("", net, GLO_E2DETECTOR, tag, GUIIconSubSys::getIcon(GUIIcon::E2),
44  0, 0, {}, "", {}, {}, "", "", false, Parameterised::Map()) {
45  // reset default values
46  resetDefaultValues();
47 }
48 
49 
50 GNELaneAreaDetector::GNELaneAreaDetector(const std::string& id, GNELane* lane, GNENet* net, double pos, double length, const SUMOTime freq,
51  const std::string& trafficLight, const std::string& filename, const std::vector<std::string>& vehicleTypes,
52  const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name, const SUMOTime timeThreshold,
53  double speedThreshold, const double jamThreshold, const bool friendlyPos, const bool show, const Parameterised::Map& parameters) :
55  pos, freq, {
56  lane
57 }, filename, vehicleTypes, nextEdges, detectPersons, name, friendlyPos, parameters),
58 myEndPositionOverLane(pos + length),
59 myTimeThreshold(timeThreshold),
60 mySpeedThreshold(speedThreshold),
61 myJamThreshold(jamThreshold),
62 myTrafficLight(trafficLight),
63 myShow(show) {
64 }
65 
66 
67 GNELaneAreaDetector::GNELaneAreaDetector(const std::string& id, std::vector<GNELane*> lanes, GNENet* net, double pos, double endPos, const SUMOTime freq,
68  const std::string& trafficLight, const std::string& filename, const std::vector<std::string>& vehicleTypes,
69  const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name, const SUMOTime timeThreshold,
70  double speedThreshold, const double jamThreshold, const bool friendlyPos, const bool show, const Parameterised::Map& parameters) :
72  pos, freq, lanes, filename, vehicleTypes, nextEdges, detectPersons, name, friendlyPos, parameters),
73  myEndPositionOverLane(endPos),
74  myTimeThreshold(timeThreshold),
75  mySpeedThreshold(speedThreshold),
76  myJamThreshold(jamThreshold),
77  myTrafficLight(trafficLight),
78  myShow(show) {
79 }
80 
81 
83 }
84 
85 
86 void
89  device.writeAttr(SUMO_ATTR_ID, getID());
90  // continue depending of E2 type
92  device.writeAttr(SUMO_ATTR_LANE, getParentLanes().front()->getID());
95  } else {
99  }
100  // write common detector parameters
101  writeDetectorValues(device);
102  // write specific attributes
103  if (myTrafficLight.size() > 0) {
105  }
108  }
111  }
114  }
117  }
118  // write parameters (Always after children to avoid problems with additionals.xsd)
119  writeParams(device);
120  device.closeTag();
121 }
122 
123 
124 bool
126  if (getParentLanes().size() == 1) {
127  // with friendly position enabled position are "always fixed"
128  if (myFriendlyPosition) {
129  return true;
130  } else {
131  return (myPositionOverLane >= 0) && (myEndPositionOverLane <= getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength());
132  }
133  } else {
134  // first check if there is connection between all consecutive lanes
136  // with friendly position enabled position are "always fixed"
137  if (myFriendlyPosition) {
138  return true;
139  } else {
140  return (myPositionOverLane >= 0) &&
141  (myEndPositionOverLane >= 0) &&
142  (myPositionOverLane <= getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) &&
143  (myEndPositionOverLane <= getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
144  }
145  } else {
146  return false;
147  }
148  }
149 }
150 
151 
152 std::string
154  // declare variable for error position
155  std::string errorFirstLanePosition, separator, errorLastLanePosition;
156  if (getParentLanes().size() == 1) {
157  // check positions over lane
158  if (myPositionOverLane < 0) {
159  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0");
160  }
161  if (myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
162  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + TL(" > lanes's length"));
163  }
164  } else {
165  // abort if lanes aren't consecutives
167  return TL("lanes aren't consecutives");
168  }
169  // abort if lanes aren't connected
171  return TL("lanes aren't connected");
172  }
173  // check positions over first lane
174  if (myPositionOverLane < 0) {
175  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0");
176  }
177  if (myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
178  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + TL(" > lanes's length"));
179  }
180  // check positions over last lane
181  if (myEndPositionOverLane < 0) {
182  errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + " < 0");
183  }
184  if (myEndPositionOverLane > getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength()) {
185  errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + TL(" > lanes's length"));
186  }
187  }
188  // check separator
189  if ((errorFirstLanePosition.size() > 0) && (errorLastLanePosition.size() > 0)) {
190  separator = TL(" and ");
191  }
192  // return error message
193  return errorFirstLanePosition + separator + errorLastLanePosition;
194 }
195 
196 
197 void
199  if (getParentLanes().size() == 1) {
200  // obtain position and length
201  double newPositionOverLane = myPositionOverLane;
202  double newLength = (myEndPositionOverLane - myPositionOverLane);
203  // fix pos and length using fixE2DetectorPosition
204  GNEAdditionalHandler::fixLanePosition(newPositionOverLane, newLength, getParentLanes().at(0)->getParentEdge()->getNBEdge()->getFinalLength());
205  // set new position and length
206  setAttribute(SUMO_ATTR_POSITION, toString(newPositionOverLane), myNet->getViewNet()->getUndoList());
208  } else {
210  // build connections between all consecutive lanes
211  bool foundConnection = true;
212  int i = 0;
213  // iterate over all lanes, and stop if myE2valid is false
214  while (i < ((int)getParentLanes().size() - 1)) {
215  // change foundConnection to false
216  foundConnection = false;
217  // if a connection between "from" lane and "to" lane of connection is found, change myE2valid to true again
218  for (const auto& connection : getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
219  if ((connection->getLaneFrom() == getParentLanes().at(i)) && (connection->getLaneTo() == getParentLanes().at(i + 1))) {
220  foundConnection = true;
221  }
222  }
223  // if connection wasn't found
224  if (!foundConnection) {
225  // create new connection manually
226  NBEdge::Connection newCon(getParentLanes().at(i)->getIndex(), getParentLanes().at(i + 1)->getParentEdge()->getNBEdge(), getParentLanes().at(i + 1)->getIndex());
227  // allow to undo creation of new lane
228  myNet->getViewNet()->getUndoList()->add(new GNEChange_Connection(getParentLanes().at(i)->getParentEdge(), newCon, false, true), true);
229  }
230  // update lane iterator
231  i++;
232  }
233  } else {
234  // declare new positions
235  double newPositionOverLane = myPositionOverLane;
236  double newEndPositionOverLane = myEndPositionOverLane;
237  // fix pos and length checkAndFixDetectorPosition
239  newPositionOverLane, getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(),
240  newEndPositionOverLane, getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
241  // set new position and endPosition
242  setAttribute(SUMO_ATTR_POSITION, toString(newPositionOverLane), myNet->getViewNet()->getUndoList());
243  setAttribute(SUMO_ATTR_ENDPOS, toString(newEndPositionOverLane), myNet->getViewNet()->getUndoList());
244  }
245  }
246 }
247 
248 
249 void
251  // check E2 detector
253  // compute path
255  } else {
256  // Cut shape using as delimitators fixed start position and fixed end position
258  }
259 }
260 
261 
262 void
264  // check drawing conditions
268  // Obtain exaggeration of the draw
269  const double E2Exaggeration = getExaggeration(s);
270  // get detail level
271  const auto d = s.getDetailLevel(E2Exaggeration);
272  // draw geometry only if we'rent in drawForObjectUnderCursor mode
274  // draw E2
275  drawE2(s, d, E2Exaggeration);
276  // draw lock icon
278  // Draw additional ID
279  drawAdditionalID(s);
280  // draw additional name
282  // draw dotted contour
284  }
285  // calculate contour and draw dotted geometry
287  }
288 }
289 
290 
291 void
293  // calculate path
295 }
296 
297 
298 void
299 GNELaneAreaDetector::drawLanePartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const {
300  // check if E2 can be drawn
303  // Obtain exaggeration of the draw
304  const double E2Exaggeration = getExaggeration(s);
305  // get detail level
306  const auto d = s.getDetailLevel(E2Exaggeration);
307  // calculate startPos
308  const double geometryDepartPos = getAttributeDouble(SUMO_ATTR_POSITION);
309  // get endPos
310  const double geometryEndPos = getAttributeDouble(SUMO_ATTR_ENDPOS);
311  // declare path geometry
312  GUIGeometry E2Geometry;
313  // update pathGeometry depending of first and last segment
314  if (segment->isFirstSegment() && segment->isLastSegment()) {
315  E2Geometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
316  geometryDepartPos,
318  geometryEndPos,
320  } else if (segment->isFirstSegment()) {
321  E2Geometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
322  geometryDepartPos,
324  -1,
326  } else if (segment->isLastSegment()) {
327  E2Geometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
328  -1,
330  geometryEndPos,
332  } else {
333  E2Geometry = segment->getLane()->getLaneGeometry();
334  }
335  // draw geometry only if we'rent in drawForObjectUnderCursor mode
337  // draw E2 partial
338  drawE2PartialLane(s, d, segment, offsetFront, E2Geometry, E2Exaggeration);
339  // draw additional ID
340  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
341  // draw dotted contour
343  }
344  // calculate contour and draw dotted geometry
345  myAdditionalContour.calculateContourExtrudedShape(s, d, this, E2Geometry.getShape(), s.detectorSettings.E2Width, E2Exaggeration,
346  segment->isFirstSegment(), segment->isLastSegment(), 0);
347  }
348 }
349 
350 
351 void
352 GNELaneAreaDetector::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const {
353  // check if E2 can be drawn
354  if ((myTagProperty.getTag() == GNE_TAG_MULTI_LANE_AREA_DETECTOR) && segment->getPreviousLane() && segment->getNextLane() &&
356  // Obtain exaggeration of the draw
357  const double E2Exaggeration = getExaggeration(s);
358  // get detail level
359  const auto d = s.getDetailLevel(E2Exaggeration);
360  // get flag for show only contour
362  // check if connection to next lane exist
363  const bool connectionExist = segment->getPreviousLane()->getLane2laneConnections().exist(segment->getNextLane());
364  // get geometry
365  const GUIGeometry& E2Geometry = connectionExist ? segment->getPreviousLane()->getLane2laneConnections().getLane2laneGeometry(segment->getNextLane()) :
366  GUIGeometry({segment->getPreviousLane()->getLaneShape().back(), segment->getNextLane()->getLaneShape().front()});
367  // draw geometry only if we'rent in drawForObjectUnderCursor mode
369  // draw E2 partial
370  drawE2PartialJunction(s, d, onlyContour, offsetFront, E2Geometry, E2Exaggeration);
371  // draw dotted contour
373  }
374  // calculate contour
375  myAdditionalContour.calculateContourExtrudedShape(s, d, this, E2Geometry.getShape(), s.detectorSettings.E2Width, E2Exaggeration, false, false, 0);
376  }
377 }
378 
379 
380 std::string
382  switch (key) {
383  case SUMO_ATTR_LANES:
384  return parseIDs(getParentLanes());
385  case SUMO_ATTR_STARTPOS:
387  case SUMO_ATTR_ENDPOS:
389  case SUMO_ATTR_TLID:
390  return myTrafficLight;
391  case SUMO_ATTR_LENGTH:
396  return toString(mySpeedThreshold);
398  return toString(myJamThreshold);
400  return toString(myShow);
401  default:
402  return getDetectorAttribute(key);
403  }
404 }
405 
406 
407 double
409  switch (key) {
410  case SUMO_ATTR_LENGTH:
412  case SUMO_ATTR_ENDPOS:
413  return myEndPositionOverLane;
414  default:
415  return getDetectorAttributeDouble(key);
416  }
417 }
418 
419 
420 void
421 GNELaneAreaDetector::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
422  switch (key) {
423  case SUMO_ATTR_LANES:
424  case SUMO_ATTR_ENDPOS:
425  case SUMO_ATTR_TLID:
426  case SUMO_ATTR_LENGTH:
431  GNEChange_Attribute::changeAttribute(this, key, value, undoList);
432  break;
433  default:
434  setDetectorAttribute(key, value, undoList);
435  break;
436  }
437 }
438 
439 
440 bool
441 GNELaneAreaDetector::isValid(SumoXMLAttr key, const std::string& value) {
442  switch (key) {
443  case SUMO_ATTR_LANES:
444  if (value.empty()) {
445  return false;
446  } else if (canParse<std::vector<GNELane*> >(myNet, value, false)) {
447  // check if lanes are consecutives
448  return lanesConsecutives(parse<std::vector<GNELane*> >(myNet, value));
449  } else {
450  return false;
451  }
452  case SUMO_ATTR_ENDPOS:
453  return canParse<double>(value);
454  case SUMO_ATTR_TLID:
455  // temporal
456  return SUMOXMLDefinitions::isValidNetID(value);
457  case SUMO_ATTR_LENGTH:
458  return (canParse<double>(value) && (parse<double>(value) >= 0));
460  return canParse<SUMOTime>(value);
462  return (canParse<double>(value) && (parse<double>(value) >= 0));
464  return (canParse<double>(value) && (parse<double>(value) >= 0));
466  return canParse<bool>(value);
467  default:
468  return isDetectorValid(key, value);
469  }
470 }
471 
472 // ===========================================================================
473 // private
474 // ===========================================================================
475 
476 void
478  const double exaggeration) const {
479  // declare color
480  RGBColor E2Color, textColor;
481  // set color
482  if (drawUsingSelectColor()) {
484  textColor = E2Color.changedBrightness(-32);
485  } else if (areLaneConsecutives(getParentLanes())) {
486  E2Color = s.detectorSettings.E2Color;
487  textColor = RGBColor::BLACK;
488  }
489  // draw parent and child lines
491  // push layer matrix
493  // translate to front
495  // set color
496  GLHelper::setColor(E2Color);
497  // draw geometry
499  // draw arrow
500  if (myAdditionalGeometry.getShape().size() > 1) {
501  glTranslated(0, 0, 0.1);
502  GLHelper::drawTriangleAtEnd(myAdditionalGeometry.getShape()[-2], myAdditionalGeometry.getShape()[-1], (double) 0.5, (double) 1, 0.5);
503  }
504  // draw E2 Logo
505  drawE2DetectorLogo(s, d, exaggeration, "E2", textColor);
506  // draw geometry points
509  // pop layer matrix
511 }
512 
513 
514 void
516  const GNEPathManager::Segment* segment, const double offsetFront,
517  const GUIGeometry& geometry, const double exaggeration) const {
518  // obtain color
520  // push layer matrix
522  // Start with the drawing of the area traslating matrix to origin
523  glTranslated(0, 0, getType() + offsetFront);
524  // Set color
525  GLHelper::setColor(E2Color);
526  // draw geometry
527  GUIGeometry::drawGeometry(d, geometry, s.detectorSettings.E2Width * exaggeration);
528  // draw geometry points
529  if (segment->isFirstSegment() && segment->isLastSegment()) {
530  drawLeftGeometryPoint(s, d, geometry.getShape().front(), geometry.getShapeRotations().front(), E2Color, true);
531  drawRightGeometryPoint(s, d, geometry.getShape().back(), geometry.getShapeRotations().back(), E2Color, true);
532  } else if (segment->isFirstSegment()) {
533  drawLeftGeometryPoint(s, d, geometry.getShape().front(), geometry.getShapeRotations().front(), E2Color, true);
534  } else if (segment->isLastSegment()) {
535  drawRightGeometryPoint(s, d, geometry.getShape().back(), geometry.getShapeRotations().back(), E2Color, true);
536  // draw arrow
537  if (geometry.getShape().size() > 1) {
538  glTranslated(0, 0, 0.1);
539  GLHelper::drawTriangleAtEnd(geometry.getShape()[-2], geometry.getShape()[-1], (double) 0.5, (double) 1, 0.5);
540  }
541  }
542  // Pop layer matrix
544  // check if this is the label segment
545  if (segment->isLabelSegment() && !s.drawForRectangleSelection) {
546  // calculate middle point
547  const double middlePoint = (geometry.getShape().length2D() * 0.5);
548  // calculate position
549  const Position pos = geometry.getShape().positionAtOffset2D(middlePoint);
550  // calculate rotation
551  const double rot = s.getTextAngle((geometry.getShape().rotationDegreeAtOffset(middlePoint) * -1) + 90);
552  // Start pushing matrix
554  // Traslate to position
555  glTranslated(pos.x(), pos.y(), getType() + offsetFront + 0.1);
556  // rotate
557  glRotated(rot, 0, 0, 1);
558  // move
559  glTranslated(-1, 0, 0);
560  // scale text
561  glScaled(exaggeration, exaggeration, 1);
562  // draw E1 logo
563  GLHelper::drawText("E2 Multilane", Position(), .1, 1.5, RGBColor::BLACK);
564  // pop matrix
566  }
567 
568 }
569 
570 
571 void
573  const bool onlyContour, const double offsetFront, const GUIGeometry& geometry,
574  const double exaggeration) const {
575  const bool invalid = geometry.getShape().length() == 2;
576  const double width = s.detectorSettings.E2Width * exaggeration * (invalid ? 0.5 : 1);
577  // Add a draw matrix
579  // Start with the drawing of the area traslating matrix to origin
580  glTranslated(0, 0, getType() + offsetFront);
581  // Set color of the base
582  if (drawUsingSelectColor()) {
584  } else if (invalid) {
586  } else {
588  }
589  // check if draw only contour
590  if (onlyContour) {
591  GUIGeometry::drawContourGeometry(geometry, width);
592  } else {
593  GUIGeometry::drawGeometry(d, geometry, width);
594  }
595  // Pop last matrix
597 }
598 
599 
600 void
601 GNELaneAreaDetector::setAttribute(SumoXMLAttr key, const std::string& value) {
602  switch (key) {
603  case SUMO_ATTR_LANES:
605  break;
606  case SUMO_ATTR_ENDPOS:
607  myEndPositionOverLane = parse<double>(value);
608  // update geometry (except for template)
609  if (getParentLanes().size() > 0) {
610  updateGeometry();
611  }
612  break;
613  case SUMO_ATTR_TLID:
614  myTrafficLight = value;
615  break;
616  case SUMO_ATTR_LENGTH:
617  myEndPositionOverLane = (myPositionOverLane + parse<double>(value));
618  // update geometry (except for template)
619  if (getParentLanes().size() > 0) {
620  updateGeometry();
621  }
622  break;
624  myTimeThreshold = TIME2STEPS(parse<double>(value));
625  break;
627  mySpeedThreshold = parse<double>(value);
628  break;
630  myJamThreshold = parse<double>(value);
631  break;
633  myShow = parse<bool>(value);
634  break;
635  default:
636  setDetectorAttribute(key, value);
637  break;
638  }
639 }
640 
641 
642 void
646  // change only start position
647  myPositionOverLane = moveResult.newFirstPos;
650  // change only end position
651  myEndPositionOverLane = moveResult.newFirstPos;
652  } else {
653  // change both position
654  myPositionOverLane = moveResult.newFirstPos;
655  myEndPositionOverLane = moveResult.newSecondPos;
656  }
657  // update geometry
658  updateGeometry();
659 }
660 
661 
662 void
664  // begin change attribute
665  undoList->begin(this, "position of " + getTagStr());
666  // set attributes depending of operation type
669  // set only start position
670  setAttribute(SUMO_ATTR_POSITION, toString(moveResult.newFirstPos), undoList);
673  // set only end position
674  setAttribute(SUMO_ATTR_ENDPOS, toString(moveResult.newFirstPos), undoList);
675  } else {
676  // set both positions
677  setAttribute(SUMO_ATTR_POSITION, toString(moveResult.newFirstPos), undoList);
678  setAttribute(SUMO_ATTR_ENDPOS, toString(moveResult.newSecondPos), undoList);
679  }
680  // end change attribute
681  undoList->end();
682 }
683 
684 
685 double
687  // get lane final and shape length
688  const double laneLength = getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
689  // get startPosition
690  double fixedPos = myPositionOverLane;
691  // adjust fixedPos
692  if (fixedPos < 0) {
693  fixedPos += laneLength;
694  }
695  fixedPos *= getParentLanes().front()->getLengthGeometryFactor();
696  // return depending of fixedPos
697  if (fixedPos < 0) {
698  return 0;
699  } else if (fixedPos > (getParentLanes().front()->getLaneShapeLength() - POSITION_EPS)) {
700  return (getParentLanes().front()->getLaneShapeLength() - POSITION_EPS);
701  } else {
702  return fixedPos;
703  }
704 }
705 
706 
707 double
709  // get lane final and shape length
710  const double laneLength = getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
711  // get endPosition
712  double fixedPos = myEndPositionOverLane;
713  // adjust fixedPos
714  if (fixedPos < 0) {
715  fixedPos += laneLength;
716  }
717  fixedPos *= getParentLanes().back()->getLengthGeometryFactor();
718  // return depending of fixedPos
719  if (fixedPos < POSITION_EPS) {
720  return POSITION_EPS;
721  } else if (fixedPos > getParentLanes().back()->getLaneShapeLength()) {
722  return getParentLanes().back()->getLaneShapeLength();
723  } else {
724  return fixedPos;
725  }
726 }
727 
728 /****************************************************************************/
long long int SUMOTime
Definition: GUI.h:35
@ GLO_E2DETECTOR
a E2 detector
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
#define TL(string)
Definition: MsgHandler.h:315
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition: SUMOTime.cpp:69
#define TIME2STEPS(x)
Definition: SUMOTime.h:57
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_MULTI_LANE_AREA_DETECTOR
an e2 detector over multiple lanes (placed here due create Additional Frame)
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_LANE
@ SUMO_ATTR_JAM_DIST_THRESHOLD
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_HALTING_TIME_THRESHOLD
@ SUMO_ATTR_LANES
@ SUMO_ATTR_HALTING_SPEED_THRESHOLD
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_SHOW_DETECTOR
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ID
@ SUMO_ATTR_POSITION
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
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 pushMatrix()
push matrix
Definition: GLHelper.cpp:117
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
Definition: GLHelper.cpp:756
static void fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength)
fix the given positions over two lanes
static void fixLanePosition(double &pos, double &length, const double laneLength)
fix given position over lane
static bool areLaneConnected(const std::vector< GNELane * > &lanes)
check if the given lanes are connected
void drawRightGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw right geometry point
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
void drawLeftGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw left geometry point
void drawParentChildLines(const GUIVisualizationSettings &s, const RGBColor &color, const bool onlySymbols=false) const
draw parent and child lines
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
const std::string & getTagStr() const
get tag assigned to this object in string format
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
static bool lanesConsecutives(const std::vector< GNELane * > &lanes)
check if lanes are consecutives
GNENet * myNet
pointer to net
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
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 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
void drawE2DetectorLogo(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration, const std::string &logo, const RGBColor &textColor) const
draw E2 detector Logo
double myPositionOverLane
position of detector over Lane
Definition: GNEDetector.h:191
bool isDetectorValid(SumoXMLAttr key, const std::string &value)
void setDetectorAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
double getDetectorAttributeDouble(SumoXMLAttr key) const
void writeDetectorValues(OutputDevice &device) const
write additional element into a xml file
bool myFriendlyPosition
Flag for friendly position.
Definition: GNEDetector.h:209
std::string getDetectorAttribute(SumoXMLAttr key) const
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given toLane
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
void drawE2PartialLane(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEPathManager::Segment *segment, const double offsetFront, const GUIGeometry &geometry, const double exaggeration) const
draw E2 partial lane
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over junction.
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void updateGeometry()
update pre-computed geometry information
double getAttributeDouble(SumoXMLAttr key) const
void fixAdditionalProblem()
fix additional problem
std::string getAttribute(SumoXMLAttr key) const
double myJamThreshold
The minimum distance to the next standing vehicle in order to make this vehicle count as a participan...
std::string myTrafficLight
Traffic light vinculated with this E2 Detector.
~GNELaneAreaDetector()
Destructor.
double myEndPositionOverLane
end position over lane (only for Multilane E2 detectors)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double getStartGeometryPositionOverLane() const
get start position over lane that is applicable to the shape
bool myShow
show or hidde detector in sumo-gui
bool isAdditionalValid() const
check if current additional is valid to be written into XML
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over lane.
void drawE2(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration) const
draw E2 detector
GNELaneAreaDetector(SumoXMLTag tag, GNENet *net)
default Constructor
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
double mySpeedThreshold
The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting.
std::string getAdditionalProblem() const
return a string with the current additional problem
double getEndGeometryPositionOverLane() const
get end position over lane that is applicable to the shape
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
SUMOTime myTimeThreshold
The time-based threshold that describes how much time has to pass until a vehicle is recognized as ha...
void computePathElement()
compute pathElement
void drawE2PartialJunction(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const bool onlyContour, const double offsetFront, const GUIGeometry &geometry, const double exaggeration) const
draw E2 partial junction
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
const PositionVector & getLaneShape() const
get elements shape
Definition: GNELane.cpp:214
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:657
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition: GNELane.cpp:208
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
move result
double newFirstPos
new first position
const GNEMoveOperation::OperationType operationType
move operation
double newSecondPos
new second position
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
GNEPathManager * getPathManager()
get path manager
Definition: GNENet.cpp:135
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2136
const GNELane * getPreviousLane() const
get previous lane
const GNELane * getNextLane() const
get next lane
bool isLabelSegment() const
check if segment is label segment
const GNELane * getLane() const
get lane associated with this segment
bool isLastSegment() const
check if segment is the last path's segment
bool isFirstSegment() const
check if segment is the first path's segment
void calculateConsecutivePathLanes(PathElement *pathElement, const std::vector< GNELane * > lanes)
calculate consecutive path lanes
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
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 GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:747
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:723
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:735
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
GNEUndoList * getUndoList() const
get the undoList object
bool selectingDetectorsTLSMode() const
check if we're selecting detectors in TLS mode
Definition: GNEViewNet.cpp:940
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawContourGeometry(const GUIGeometry &geometry, const double width, const bool drawExtremes=false)
draw contour geometry
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
Definition: GUIGeometry.cpp:59
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:156
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
bool checkDrawAdditional(Detail d, const bool selected) const
check if draw additionals
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
GUIVisualizationDetectorSettings detectorSettings
Detector settings.
double getTextAngle(double objectAngle) const
return an angle that is suitable for reading text aligned with the given angle (degrees)
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:254
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:322
double x() const
Returns the x-position.
Definition: Position.h:55
double y() const
Returns the y-position.
Definition: Position.h:60
double length2D() const
Returns the length.
double length() const
Returns the length.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static const RGBColor BLACK
Definition: RGBColor.h:193
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:200
static const RGBColor RED
named colors
Definition: RGBColor.h:185
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
bool showAdditionals() const
check if additionals has to be drawn
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
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
static const RGBColor connectionColor
connection color
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
static const RGBColor E2Color
color for E2 detectors
static const double E2Width
E2 detector widths.
static const double segmentWidth
width of dotted contour segments
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:201