Eclipse SUMO - Simulation of Urban MObility
GNEDetectorE2.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-2020 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 #include <netedit/GNENet.h>
21 #include <netedit/GNEUndoList.h>
22 #include <netedit/GNEViewNet.h>
26 #include <utils/gui/div/GLHelper.h>
28 
29 #include "GNEDetectorE2.h"
30 #include "GNEAdditionalHandler.h"
31 
32 
33 // ===========================================================================
34 // member method definitions
35 // ===========================================================================
36 
37 GNEDetectorE2::GNEDetectorE2(const std::string& id, GNELane* lane, GNENet* net, double pos, double length, const std::string& freq, const std::string& trafficLight, const std::string& filename,
38  const std::string& vehicleTypes, const std::string& name, SUMOTime timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement) :
39  GNEDetector(id, net, GLO_E2DETECTOR, SUMO_TAG_E2DETECTOR, pos, freq, filename, vehicleTypes, name, friendlyPos, blockMovement, {
40  lane
41 }),
42 myLength(length),
43 myEndPositionOverLane(0.),
44 myTimeThreshold(timeThreshold),
45 mySpeedThreshold(speedThreshold),
46 myJamThreshold(jamThreshold),
47 myTrafficLight(trafficLight) {
48  // update centering boundary without updating grid
49  updateCenteringBoundary(false);
50 }
51 
52 
53 GNEDetectorE2::GNEDetectorE2(const std::string& id, std::vector<GNELane*> lanes, GNENet* net, double pos, double endPos, const std::string& freq, const std::string& trafficLight, const std::string& filename,
54  const std::string& vehicleTypes, const std::string& name, SUMOTime timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement) :
55  GNEDetector(id, net, GLO_E2DETECTOR, SUMO_TAG_E2DETECTOR_MULTILANE, pos, freq, filename, vehicleTypes, name, friendlyPos, blockMovement, lanes),
56  myLength(0),
57  myEndPositionOverLane(endPos),
58  myTimeThreshold(timeThreshold),
59  mySpeedThreshold(speedThreshold),
60  myJamThreshold(jamThreshold),
61  myTrafficLight(trafficLight) {
62  // update centering boundary without updating grid
64 }
65 
66 
68 }
69 
70 
71 bool
73  if (getParentLanes().size() == 1) {
74  // with friendly position enabled position are "always fixed"
75  if (myFriendlyPosition) {
76  return true;
77  } else {
78  return (myPositionOverLane >= 0) && ((myPositionOverLane + myLength) <= getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength());
79  }
80  } else {
81  // first check if there is connection between all consecutive lanes
82  if (areLaneConsecutives()) {
83  // with friendly position enabled position are "always fixed"
84  if (myFriendlyPosition) {
85  return true;
86  } else {
87  return (myPositionOverLane >= 0) && ((myPositionOverLane) <= getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength() &&
88  myEndPositionOverLane >= 0) && ((myEndPositionOverLane) <= getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
89  }
90  } else {
91  return false;
92  }
93  }
94 }
95 
96 
97 std::string
99  // declare variable for error position
100  std::string errorFirstLanePosition, separator, errorLastLanePosition;
101  if (getParentLanes().size() == 1) {
102  // check positions over lane
103  if (myPositionOverLane < 0) {
104  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0");
105  }
106  if (myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
107  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " > lanes's length");
108  }
109  if ((myPositionOverLane + myLength) > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
110  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " + " + toString(SUMO_ATTR_LENGTH) + " > lanes's length");
111  }
112  } else {
113  // abort if lanes aren't consecutives
114  if (!areLaneConsecutives()) {
115  return "lanes aren't consecutives";
116  }
117  // check positions over first lane
118  if (myPositionOverLane < 0) {
119  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0");
120  }
121  if (myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
122  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " > lanes's length");
123  }
124  // check positions over last lane
125  if (myEndPositionOverLane < 0) {
126  errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + " < 0");
127  }
128  if (myEndPositionOverLane > getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength()) {
129  errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + " > lanes's length");
130  }
131  }
132  // check separator
133  if ((errorFirstLanePosition.size() > 0) && (errorLastLanePosition.size() > 0)) {
134  separator = " and ";
135  }
136  // return error message
137  return errorFirstLanePosition + separator + errorLastLanePosition;
138 }
139 
140 
141 void
143  if (getParentLanes().size() == 1) {
144  // obtain position and length
145  double newPositionOverLane = myPositionOverLane;
146  double newLength = myLength;
147  // fix pos and length using fixE2DetectorPosition
148  GNEAdditionalHandler::fixE2DetectorPosition(newPositionOverLane, newLength, getParentLanes().at(0)->getParentEdge()->getNBEdge()->getFinalLength(), true);
149  // set new position and length
150  setAttribute(SUMO_ATTR_POSITION, toString(newPositionOverLane), myNet->getViewNet()->getUndoList());
152  } else {
153  if (!areLaneConsecutives()) {
154  // build connections between all consecutive lanes
155  bool foundConnection = true;
156  int i = 0;
157  // iterate over all lanes, and stop if myE2valid is false
158  while (i < ((int)getParentLanes().size() - 1)) {
159  // change foundConnection to false
160  foundConnection = false;
161  // if a connection betwen "from" lane and "to" lane of connection is found, change myE2valid to true again
162  for (auto j : getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
163  if (j->getLaneFrom() == getParentLanes().at(i) && j->getLaneTo() == getParentLanes().at(i + 1)) {
164  foundConnection = true;
165  }
166  }
167  // if connection wasn't found
168  if (!foundConnection) {
169  // create new connection manually
170  NBEdge::Connection newCon(getParentLanes().at(i)->getIndex(), getParentLanes().at(i + 1)->getParentEdge()->getNBEdge(), getParentLanes().at(i + 1)->getIndex());
171  // allow to undo creation of new lane
172  myNet->getViewNet()->getUndoList()->add(new GNEChange_Connection(getParentLanes().at(i)->getParentEdge(), newCon, false, true), true);
173  }
174  // update lane iterator
175  i++;
176  }
177  } else {
178  // declare new position
179  double newPositionOverLane = myPositionOverLane;
180  // fix pos and length checkAndFixDetectorPosition
181  GNEAdditionalHandler::checkAndFixDetectorPosition(newPositionOverLane, getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(), true);
182  // set new position
183  setAttribute(SUMO_ATTR_POSITION, toString(newPositionOverLane), myNet->getViewNet()->getUndoList());
184  // declare new end position
185  double newEndPositionOverLane = myEndPositionOverLane;
186  // fix pos and length checkAndFixDetectorPosition
187  GNEAdditionalHandler::checkAndFixDetectorPosition(newEndPositionOverLane, getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength(), true);
188  // set new position
189  setAttribute(SUMO_ATTR_ENDPOS, toString(newEndPositionOverLane), myNet->getViewNet()->getUndoList());
190  }
191  }
192 }
193 
194 /*
195 void
196 GNEDetectorE2::mov eGeometry(const Position& offset) {
197  // Calculate new position using old position
198  Position newPosition = myMove.originalViewPosition;
199  newPosition.add(offset);
200  // filtern position using snap to active grid
201  newPosition = myNet->getViewNet()->snapToActiveGrid(newPosition);
202  double offsetLane = getParentLanes().front()->getLaneShape().nearest_offset_to_point2D(newPosition, false) - getParentLanes().front()->getLaneShape().nearest_offset_to_point2D(myMove.originalViewPosition, false);
203  // move geometry depending of number of lanes
204  if (getParentLanes().size() == 1) {
205  // calculate new position over lane
206  double newPositionOverLane = parse<double>(myMove.firstOriginalLanePosition) + offsetLane;
207  // obtain lane length
208  double laneLength = getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength() * getLane()->getLengthGeometryFactor();
209  if (newPositionOverLane < 0) {
210  myPositionOverLane = 0;
211  } else if (newPositionOverLane + myLength > laneLength) {
212  myPositionOverLane = laneLength - myLength;
213  } else {
214  myPositionOverLane = newPositionOverLane;
215  }
216  } else {
217  // calculate new start and end positions
218  double newStartPosition = parse<double>(myMove.firstOriginalLanePosition) + offsetLane;
219  double newEndPosition = parse<double>(myMove.secondOriginalPosition) + offsetLane;
220  // change start and end position of E2 detector ONLY if both extremes aren't overpassed
221  if ((newStartPosition >= 0) && (newStartPosition <= getParentLanes().front()->getLaneShapeLength()) &&
222  (newEndPosition >= 0) && (newEndPosition <= getParentLanes().back()->getLaneShapeLength())) {
223  myPositionOverLane = newStartPosition;
224  myEndPositionOverLane = newEndPosition;
225  }
226  }
227  // Update geometry
228  updateGeometry();
229 }
230 
231 
232 void
233 GNEDetectorE2::commitGeometryMoving(GNEUndoList* undoList) {
234  // commit geometry moving depending of number of lanes
235  if (getParentLanes().size() == 1) {
236  // commit new position allowing undo/redo
237  undoList->p_begin("position of " + getTagStr());
238  undoList->p_add(new GNEChange_Attribute(this, SUMO_ATTR_POSITION, toString(myPositionOverLane), myMove.firstOriginalLanePosition));
239  undoList->p_end();
240  } else {
241  undoList->p_begin("position of " + getTagStr());
242  undoList->p_add(new GNEChange_Attribute(this, SUMO_ATTR_POSITION, toString(myPositionOverLane), myMove.firstOriginalLanePosition));
243  undoList->p_add(new GNEChange_Attribute(this, SUMO_ATTR_ENDPOS, toString(myEndPositionOverLane), myMove.secondOriginalPosition));
244  undoList->p_end();
245  }
246 }
247 */
248 
249 void
251  // declare variables for start and end positions
252  double startPosFixed = myPositionOverLane;
253  double endPosFixed = myEndPositionOverLane;
254  // adjust start and end pos
255  if (startPosFixed < 0) {
256  startPosFixed += myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
257  }
258  if (endPosFixed < 0) {
259  endPosFixed += myPositionOverLane > getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
260  }
261  // set start position
262  if (myPositionOverLane < 0) {
263  startPosFixed = 0;
264  } else if (myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
265  startPosFixed = getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
266  }
267  // set end position
268  if ((myPositionOverLane + myLength) < 0) {
269  endPosFixed = 0;
270  } else if ((myPositionOverLane + myLength) > getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength()) {
271  endPosFixed = getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
272  }
274  // declare extreme geometry
275  GNEGeometry::ExtremeGeometry extremeGeometry;
276  // set extremes
277  extremeGeometry.laneStartPosition = startPosFixed;
278  extremeGeometry.laneEndPosition = endPosFixed;
279  // calculate consecutive path using parent lanes
281  // calculate edge geometry path using path
283  } else {
284  // Cut shape using as delimitators fixed start position and fixed end position
285  myAdditionalGeometry.updateGeometry(getParentLanes().front()->getLaneShape(), startPosFixed * getParentLanes().front()->getLengthGeometryFactor(), endPosFixed * getParentLanes().back()->getLengthGeometryFactor());
286  }
287 }
288 
289 
290 double
292  return myLength;
293 }
294 
295 
296 void
298  // Obtain exaggeration of the draw
299  const double E2Exaggeration = s.addSize.getExaggeration(s, this);
300  // first check if additional has to be drawn
302  // declare color
303  RGBColor E2Color, textColor;
304  // set color
305  if (drawUsingSelectColor()) {
307  textColor = E2Color.changedBrightness(-32);
308  } else if (areLaneConsecutives()) {
309  E2Color = s.detectorSettings.E2Color;
310  textColor = RGBColor::BLACK;
311  }
312  // Start drawing adding an gl identificator
313  glPushName(getGlID());
314  // push layer matrix
315  glPushMatrix();
316  // translate to front
318  // set color
319  GLHelper::setColor(E2Color);
320  // draw geometry
322  // Check if the distance is enought to draw details
323  if (s.drawDetail(s.detailSettings.detectorDetails, E2Exaggeration)) {
324  // draw E2 Logo
325  drawDetectorLogo(s, E2Exaggeration, "E2", textColor);
326  // draw lock icon
327  GNEViewNetHelper::LockIcon::drawLockIcon(this, myAdditionalGeometry, E2Exaggeration, 1, 0, true);
328  }
329  // pop layer matrix
330  glPopMatrix();
331  // Pop name
332  glPopName();
333  // Draw additional ID
334  drawAdditionalID(s);
335  // draw additional name
337  // check if dotted contours has to be drawn
340  }
341  if (s.drawDottedContour() || myNet->getViewNet()->getFrontAttributeCarrier() == this) {
343  }
344  }
345 }
346 
347 
348 std::string
350  switch (key) {
351  case SUMO_ATTR_ID:
352  return getID();
353  case SUMO_ATTR_LANE:
354  case SUMO_ATTR_LANES:
355  return parseIDs(getParentLanes());
356  case SUMO_ATTR_POSITION:
358  case SUMO_ATTR_ENDPOS:
360  case SUMO_ATTR_FREQUENCY:
361  return myFreq;
362  case SUMO_ATTR_TLID:
363  return myTrafficLight;
364  case SUMO_ATTR_LENGTH:
365  return toString(myLength);
366  case SUMO_ATTR_NAME:
367  return myAdditionalName;
368  case SUMO_ATTR_FILE:
369  return myFilename;
370  case SUMO_ATTR_VTYPES:
371  return myVehicleTypes;
375  return toString(mySpeedThreshold);
377  return toString(myJamThreshold);
381  return toString(myBlockMovement);
382  case GNE_ATTR_SELECTED:
384  case GNE_ATTR_PARAMETERS:
385  return getParametersStr();
386  default:
387  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
388  }
389 }
390 
391 
392 void
393 GNEDetectorE2::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
394  if (value == getAttribute(key)) {
395  return; //avoid needless changes, later logic relies on the fact that attributes have changed
396  }
397  switch (key) {
398  case SUMO_ATTR_ID:
399  case SUMO_ATTR_LANE:
400  case SUMO_ATTR_LANES:
401  case SUMO_ATTR_POSITION:
402  case SUMO_ATTR_ENDPOS:
403  case SUMO_ATTR_FREQUENCY:
404  case SUMO_ATTR_TLID:
405  case SUMO_ATTR_LENGTH:
406  case SUMO_ATTR_NAME:
407  case SUMO_ATTR_FILE:
408  case SUMO_ATTR_VTYPES:
414  case GNE_ATTR_SELECTED:
415  case GNE_ATTR_PARAMETERS:
416  undoList->p_add(new GNEChange_Attribute(this, key, value));
417  break;
418  default:
419  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
420  }
421 }
422 
423 
424 bool
425 GNEDetectorE2::isValid(SumoXMLAttr key, const std::string& value) {
426  switch (key) {
427  case SUMO_ATTR_ID:
428  return isValidDetectorID(value);
429  case SUMO_ATTR_LANE:
430  if (value.empty()) {
431  return false;
432  } else {
433  return canParse<std::vector<GNELane*> >(myNet, value, false);
434  }
435  case SUMO_ATTR_LANES:
436  if (value.empty()) {
437  return false;
438  } else if (canParse<std::vector<GNELane*> >(myNet, value, false)) {
439  // check if lanes are consecutives
440  return lanesConsecutives(parse<std::vector<GNELane*> >(myNet, value));
441  } else {
442  return false;
443  }
444  case SUMO_ATTR_POSITION:
445  return canParse<double>(value);
446  case SUMO_ATTR_ENDPOS:
447  return canParse<double>(value);
448  case SUMO_ATTR_FREQUENCY:
449  return value.empty() || (canParse<double>(value) && (parse<double>(value) >= 0));
450  case SUMO_ATTR_TLID:
451  /* temporal */
452  return true;
453  case SUMO_ATTR_LENGTH:
454  return (canParse<double>(value) && (parse<double>(value) >= 0));
455  case SUMO_ATTR_NAME:
457  case SUMO_ATTR_FILE:
459  case SUMO_ATTR_VTYPES:
460  if (value.empty()) {
461  return true;
462  } else {
464  }
466  return canParse<SUMOTime>(value);
468  return (canParse<double>(value) && (parse<double>(value) >= 0));
470  return (canParse<double>(value) && (parse<double>(value) >= 0));
472  return canParse<bool>(value);
474  return canParse<bool>(value);
475  case GNE_ATTR_SELECTED:
476  return canParse<bool>(value);
477  case GNE_ATTR_PARAMETERS:
478  return Parameterised::areParametersValid(value);
479  default:
480  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
481  }
482 }
483 
484 
485 bool
487  return true;
488 }
489 
490 // ===========================================================================
491 // private
492 // ===========================================================================
493 
494 void
495 GNEDetectorE2::setAttribute(SumoXMLAttr key, const std::string& value) {
496  switch (key) {
497  case SUMO_ATTR_ID:
498  myNet->getAttributeCarriers()->updateID(this, value);
499  break;
500  case SUMO_ATTR_LANE:
501  case SUMO_ATTR_LANES:
503  break;
504  case SUMO_ATTR_POSITION:
505  myPositionOverLane = parse<double>(value);
506  break;
507  case SUMO_ATTR_ENDPOS:
508  myEndPositionOverLane = parse<double>(value);
509  break;
510  case SUMO_ATTR_FREQUENCY:
511  myFreq = value;
512  break;
513  case SUMO_ATTR_TLID:
514  myTrafficLight = value;
515  break;
516  case SUMO_ATTR_LENGTH:
517  myLength = parse<double>(value);
518  break;
519  case SUMO_ATTR_NAME:
520  myAdditionalName = value;
521  break;
522  case SUMO_ATTR_FILE:
523  myFilename = value;
524  break;
525  case SUMO_ATTR_VTYPES:
526  myVehicleTypes = value;
527  break;
529  myTimeThreshold = parse<SUMOTime>(value);
530  break;
532  mySpeedThreshold = parse<double>(value);
533  break;
535  myJamThreshold = parse<double>(value);
536  break;
538  myFriendlyPosition = parse<bool>(value);
539  break;
541  myBlockMovement = parse<bool>(value);
542  break;
543  case GNE_ATTR_SELECTED:
544  if (parse<bool>(value)) {
546  } else {
548  }
549  break;
550  case GNE_ATTR_PARAMETERS:
551  setParametersStr(value);
552  break;
553  default:
554  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
555  }
556 }
557 
558 
559 bool
561  // declare lane iterator
562  int i = 0;
563  // iterate over all lanes, and stop if myE2valid is false
564  while (i < ((int)getParentLanes().size() - 1)) {
565  // we assume that E2 is invalid
566  bool connectionFound = false;
567  // if there is a connection betwen "from" lane and "to" lane of connection, change connectionFound to true
568  for (auto j : getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
569  if (j->getLaneFrom() == getParentLanes().at(i) && j->getLaneTo() == getParentLanes().at(i + 1)) {
570  connectionFound = true;
571  }
572  }
573  // abort if connectionFound is false
574  if (!connectionFound) {
575  return false;
576  }
577  // update iterator
578  i++;
579  }
580  // there are connections between all lanes, then return true
581  return true;
582 }
583 
584 
585 /****************************************************************************/
@ GLO_E2DETECTOR
a E2 detector
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
long long int SUMOTime
Definition: SUMOTime.h:31
@ SUMO_TAG_E2DETECTOR
an e2 detector
@ SUMO_TAG_E2DETECTOR_MULTILANE
an e2 detector over multiple lanes (used by Netedit)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LANE
@ SUMO_ATTR_FILE
@ SUMO_ATTR_JAM_DIST_THRESHOLD
@ GNE_ATTR_BLOCK_MOVEMENT
block movement of a graphic element
@ SUMO_ATTR_ENDPOS
@ GNE_ATTR_SELECTED
element is selected
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_HALTING_TIME_THRESHOLD
@ SUMO_ATTR_LANES
@ SUMO_ATTR_VTYPES
@ SUMO_ATTR_NAME
@ SUMO_ATTR_HALTING_SPEED_THRESHOLD
@ SUMO_ATTR_FREQUENCY
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_FRIENDLY_POS
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ID
@ SUMO_ATTR_POSITION
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:446
static bool checkAndFixDetectorPosition(double &pos, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
static bool fixE2DetectorPosition(double &pos, double &length, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
const std::string & getID() const
get ID
GNEGeometry::Geometry 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
bool myBlockMovement
boolean to check if additional element is blocked (i.e. cannot be moved with mouse)
std::string myAdditionalName
name of additional
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
GNEGeometry::SegmentGeometry myAdditionalSegmentGeometry
segment geometry to be precomputed in updateGeometry(...) (used by E2Multilane)
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
friend class GNEChange_Attribute
declare friend class
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
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
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
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
const GNETagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
void updateGeometry()
update pre-computed geometry information
std::string getAttribute(SumoXMLAttr key) const
bool isAdditionalValid() const
check if current additional is valid to be writed into XML (by default true, can be reimplemented in ...
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
GNEDetectorE2(const std::string &id, GNELane *lane, GNENet *net, double pos, double length, const std::string &freq, const std::string &trafficLight, const std::string &filename, const std::string &vehicleTypes, const std::string &name, SUMOTime timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement)
Constructor for Single-Lane E2 detectors.
double mySpeedThreshold
The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting.
double myJamThreshold
The minimum distance to the next standing vehicle in order to make this vehicle count as a participan...
bool areLaneConsecutives() const
check if lanes are consecutives
void fixAdditionalProblem()
fix additional problem
double myLength
E2 detector length.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
SUMOTime myTimeThreshold
The time-based threshold that describes how much time has to pass until a vehicle is recognized as ha...
bool isAttributeEnabled(SumoXMLAttr key) const
std::string myTrafficLight
Traffic light vinculated with this E2 Detector.
~GNEDetectorE2()
Destructor.
double getLength() const
get length of E2 Detector
std::string getAdditionalProblem() const
return a string with the current additional problem
double myEndPositionOverLane
end position over lane (only for Multilane E2 detectors)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
std::string myFilename
The path to the output file.
Definition: GNEDetector.h:169
std::string myFreq
The aggregation period the values the detector collects shall be summed up.
Definition: GNEDetector.h:166
double myPositionOverLane
position of detector over Lane
Definition: GNEDetector.h:163
std::string myVehicleTypes
attribute vehicle types
Definition: GNEDetector.h:172
bool myFriendlyPosition
Flag for friendly position.
Definition: GNEDetector.h:175
void drawDetectorLogo(const GUIVisualizationSettings &s, const double exaggeration, const std::string &logo, const RGBColor &textColor) const
draw detector Logo
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition: GNEDetector.cpp:88
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape, double startPos=-1, double endPos=-1, const Position &extraFirstPosition=Position::INVALID, const Position &extraLastPosition=Position::INVALID)
update geometry shape
Definition: GNEGeometry.cpp:81
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
void updateID(GNEAttributeCarrier *AC, const std::string newID)
update ID
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
retrieve all attribute carriers of Net
Definition: GNENet.cpp:130
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2245
void calculateConsecutivePathLanes(SUMOVehicleClass vClass, const bool allowedVClass, const std::vector< GNEEdge * > &edges)
calculate consecutive path lanes (used by routes)
const std::vector< GNEPathElements::PathElement > & getPath() const
get path edges
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:491
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
GNEUndoList * getUndoList() const
get the undoList object
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, GUIGlObjectType objectType, const double extraOffset=0)
draw front attributeCarrier
GUIGlID getGlID() const
Returns the numerical id of the object.
Stores the information about how to visualize structures.
GUIVisualizationDetailSettings detailSettings
detail settings
GUIVisualizationSizeSettings addSize
bool drawDottedContour() const
check if dotted contour can be drawn
bool drawAdditionals(const double exaggeration) const
check if additionals must be drawn
GUIVisualizationColorSettings colorSettings
color settings
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
GUIVisualizationDetectorSettings detectorSettings
Detector settings.
static bool areParametersValid(const std::string &value, bool report=false, ParameterisedAttrType attrType=ParameterisedAttrType::STRING, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
void setParametersStr(const std::string &paramsString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
static const RGBColor BLACK
Definition: RGBColor.h:188
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:145
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name)
static bool isValidListOfTypeID(const std::string &value)
whether the given string is a valid list of ids for an edge or vehicle type (empty aren't allowed)
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name)
struct for variables used in Geometry extremes
Definition: GNEGeometry.h:58
double laneEndPosition
arrival position over lane
Definition: GNEGeometry.h:66
double laneStartPosition
depart position over lane
Definition: GNEGeometry.h:63
static void drawDottedContourShape(const DottedContourType type, const GUIVisualizationSettings &s, const PositionVector &shape, const double width, const double exaggeration)
draw dotted contour for the given shape (used by additionals)
static void calculateLaneGeometricPath(GNEGeometry::SegmentGeometry &segmentGeometry, const std::vector< GNEPathElements::PathElement > &path, GNEGeometry::ExtremeGeometry &extremeGeometry)
calculate route between lanes
static void drawGeometry(const GNEViewNet *viewNet, const Geometry &geometry, const double width)
draw geometry
bool showAdditionals() const
check if additionals has to be drawn
static void drawLockIcon(const GNEAttributeCarrier *AC, const GNEGeometry::Geometry &geometry, const double exaggeration, const double offsetx, const double offsety, const bool overlane, const double size=0.5)
draw lock icon
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
static const double detectorDetails
details for detectors
static const RGBColor E2Color
color for E2 detectors
static const double E2Width
E2 detector widths.
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:188