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-2022 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 
38  GNEDetector("", net, GLO_E2DETECTOR, tag, 0, 0, {}, "", {}, "", false, std::map<std::string, std::string>()),
39  myEndPositionOverLane(0),
40  myTimeThreshold(0),
41  mySpeedThreshold(0),
42 myJamThreshold(0) {
43  // reset default values
44  resetDefaultValues();
45 }
46 
47 
48 GNEDetectorE2::GNEDetectorE2(const std::string& id, GNELane* lane, GNENet* net, double pos, double length, const SUMOTime freq,
49  const std::string& trafficLight, const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::string& name,
50  SUMOTime timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos,
51  const std::map<std::string, std::string>& parameters) :
52  GNEDetector(id, net, GLO_E2DETECTOR, SUMO_TAG_E2DETECTOR, pos, freq, {
53  lane
54 }, filename, vehicleTypes, name, friendlyPos, parameters),
55 myEndPositionOverLane(pos + length),
56 myTimeThreshold(timeThreshold),
57 mySpeedThreshold(speedThreshold),
58 myJamThreshold(jamThreshold),
59 myTrafficLight(trafficLight) {
60  // update centering boundary without updating grid
61  updateCenteringBoundary(false);
62 }
63 
64 
65 GNEDetectorE2::GNEDetectorE2(const std::string& id, std::vector<GNELane*> lanes, GNENet* net, double pos, double endPos, const SUMOTime freq,
66  const std::string& trafficLight, const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::string& name, SUMOTime timeThreshold,
67  double speedThreshold, double jamThreshold, bool friendlyPos, const std::map<std::string, std::string>& parameters) :
68  GNEDetector(id, net, GLO_E2DETECTOR, GNE_TAG_E2DETECTOR_MULTILANE, pos, freq, lanes, filename, vehicleTypes, name, friendlyPos, parameters),
69  myEndPositionOverLane(endPos),
70  myTimeThreshold(timeThreshold),
71  mySpeedThreshold(speedThreshold),
72  myJamThreshold(jamThreshold),
73  myTrafficLight(trafficLight) {
74  // update centering boundary without updating grid
76 }
77 
78 
80 }
81 
82 
83 void
86  device.writeAttr(SUMO_ATTR_ID, getID());
87  if (!myAdditionalName.empty()) {
89  }
90  // continue depending of E2 type
92  device.writeAttr(SUMO_ATTR_LANE, getParentLanes().front()->getID());
95  } else {
99  }
100  if (myTrafficLight.size() > 0) {
102  } else {
104  }
105  if (myFilename.size() > 0) {
107  }
108  if (myVehicleTypes.size() > 0) {
110  }
113  }
116  }
119  }
120  if (myFriendlyPosition) {
121  device.writeAttr(SUMO_ATTR_FRIENDLY_POS, true);
122  }
123  // write parameters (Always after children to avoid problems with additionals.xsd)
124  writeParams(device);
125  device.closeTag();
126 }
127 
128 
129 bool
131  if (getParentLanes().size() == 1) {
132  // with friendly position enabled position are "always fixed"
133  if (myFriendlyPosition) {
134  return true;
135  } else {
136  return (myPositionOverLane >= 0) && (myEndPositionOverLane <= getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength());
137  }
138  } else {
139  // first check if there is connection between all consecutive lanes
140  if (areLaneConsecutives()) {
141  // with friendly position enabled position are "always fixed"
142  if (myFriendlyPosition) {
143  return true;
144  } else {
145  return (myPositionOverLane >= 0) && ((myPositionOverLane) <= getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength() &&
146  myEndPositionOverLane >= 0) && ((myEndPositionOverLane) <= getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
147  }
148  } else {
149  return false;
150  }
151  }
152 }
153 
154 
155 std::string
157  // declare variable for error position
158  std::string errorFirstLanePosition, separator, errorLastLanePosition;
159  if (getParentLanes().size() == 1) {
160  // check positions over lane
161  if (myPositionOverLane < 0) {
162  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0");
163  }
164  if (myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
165  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " > lanes's length");
166  }
167  if ((myEndPositionOverLane) > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
168  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " + " + toString(SUMO_ATTR_LENGTH) + " > lanes's length");
169  }
170  } else {
171  // abort if lanes aren't consecutives
172  if (!areLaneConsecutives()) {
173  return "lanes aren't consecutives";
174  }
175  // check positions over first lane
176  if (myPositionOverLane < 0) {
177  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0");
178  }
179  if (myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
180  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " > lanes's length");
181  }
182  // check positions over last lane
183  if (myEndPositionOverLane < 0) {
184  errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + " < 0");
185  }
186  if (myEndPositionOverLane > getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength()) {
187  errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + " > lanes's length");
188  }
189  }
190  // check separator
191  if ((errorFirstLanePosition.size() > 0) && (errorLastLanePosition.size() > 0)) {
192  separator = " and ";
193  }
194  // return error message
195  return errorFirstLanePosition + separator + errorLastLanePosition;
196 }
197 
198 
199 void
201  if (getParentLanes().size() == 1) {
202  // obtain position and length
203  double newPositionOverLane = myPositionOverLane;
204  double newLength = (myEndPositionOverLane - myPositionOverLane);
205  // fix pos and length using fixE2DetectorPosition
206  GNEAdditionalHandler::fixE2SingleLanePosition(newPositionOverLane, newLength, getParentLanes().at(0)->getParentEdge()->getNBEdge()->getFinalLength());
207  // set new position and length
208  setAttribute(SUMO_ATTR_POSITION, toString(newPositionOverLane), myNet->getViewNet()->getUndoList());
210  } else {
211  if (!areLaneConsecutives()) {
212  // build connections between all consecutive lanes
213  bool foundConnection = true;
214  int i = 0;
215  // iterate over all lanes, and stop if myE2valid is false
216  while (i < ((int)getParentLanes().size() - 1)) {
217  // change foundConnection to false
218  foundConnection = false;
219  // if a connection betwen "from" lane and "to" lane of connection is found, change myE2valid to true again
220  for (const auto& connection : getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
221  if ((connection->getLaneFrom() == getParentLanes().at(i)) && (connection->getLaneTo() == getParentLanes().at(i + 1))) {
222  foundConnection = true;
223  }
224  }
225  // if connection wasn't found
226  if (!foundConnection) {
227  // create new connection manually
228  NBEdge::Connection newCon(getParentLanes().at(i)->getIndex(), getParentLanes().at(i + 1)->getParentEdge()->getNBEdge(), getParentLanes().at(i + 1)->getIndex());
229  // allow to undo creation of new lane
230  myNet->getViewNet()->getUndoList()->add(new GNEChange_Connection(getParentLanes().at(i)->getParentEdge(), newCon, false, true), true);
231  }
232  // update lane iterator
233  i++;
234  }
235  } else {
236  // declare new positions
237  double newPositionOverLane = myPositionOverLane;
238  double newEndPositionOverLane = myEndPositionOverLane;
239  // fix pos and length checkAndFixDetectorPosition
241  newPositionOverLane, getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(),
242  newEndPositionOverLane, getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
243  // set new position and endPosition
244  setAttribute(SUMO_ATTR_POSITION, toString(newPositionOverLane), myNet->getViewNet()->getUndoList());
245  setAttribute(SUMO_ATTR_ENDPOS, toString(newEndPositionOverLane), myNet->getViewNet()->getUndoList());
246  }
247  }
248 }
249 
250 
251 void
253  // check E2 detector
255  // compute path
257  } else {
258  // Cut shape using as delimitators fixed start position and fixed end position
260  // update centering boundary without updating grid
262  }
263 }
264 
265 
266 void
268  // Obtain exaggeration of the draw
269  const double E2Exaggeration = getExaggeration(s);
270  // first check if additional has to be drawn
272  // check exaggeration
273  if (s.drawAdditionals(E2Exaggeration)) {
274  // declare color
275  RGBColor E2Color, textColor;
276  // set color
277  if (drawUsingSelectColor()) {
279  textColor = E2Color.changedBrightness(-32);
280  } else if (areLaneConsecutives()) {
281  E2Color = s.detectorSettings.E2Color;
282  textColor = RGBColor::BLACK;
283  }
284  // draw parent and child lines
286  // Start drawing adding an gl identificator
288  // push layer matrix
290  // translate to front
292  // set color
293  GLHelper::setColor(E2Color);
294  // draw geometry
296  // Check if the distance is enought to draw details
297  if (s.drawDetail(s.detailSettings.detectorDetails, E2Exaggeration)) {
298  // draw E2 Logo
299  drawDetectorLogo(s, E2Exaggeration, "E2", textColor);
300  }
301  // draw geometry points
304  // pop layer matrix
306  // Pop name
308  // draw lock icon
310  // check if dotted contours has to be drawn
313  E2Exaggeration, true, true);
314  }
315  if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
317  E2Exaggeration, true, true);
318  }
319  }
320  // Draw additional ID
321  drawAdditionalID(s);
322  // draw additional name
324  }
325 }
326 
327 
328 std::string
330  switch (key) {
331  case SUMO_ATTR_ID:
332  return getID();
333  case SUMO_ATTR_LANE:
334  case SUMO_ATTR_LANES:
335  return parseIDs(getParentLanes());
336  case SUMO_ATTR_POSITION:
338  case SUMO_ATTR_ENDPOS:
340  case SUMO_ATTR_FREQUENCY:
341  return time2string(myFreq);
342  case SUMO_ATTR_TLID:
343  return myTrafficLight;
344  case SUMO_ATTR_LENGTH:
346  case SUMO_ATTR_NAME:
347  return myAdditionalName;
348  case SUMO_ATTR_FILE:
349  return myFilename;
350  case SUMO_ATTR_VTYPES:
351  return toString(myVehicleTypes);
355  return toString(mySpeedThreshold);
357  return toString(myJamThreshold);
360  case GNE_ATTR_SELECTED:
362  case GNE_ATTR_PARAMETERS:
363  return getParametersStr();
365  return "";
366  default:
367  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
368  }
369 }
370 
371 
372 double
374  switch (key) {
375  case SUMO_ATTR_POSITION:
376  return myPositionOverLane;
377  case SUMO_ATTR_LENGTH:
379  case SUMO_ATTR_ENDPOS:
380  return myEndPositionOverLane;
381  default:
382  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
383  }
384 }
385 
386 
387 void
388 GNEDetectorE2::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
389  switch (key) {
390  case SUMO_ATTR_ID:
391  case SUMO_ATTR_LANE:
392  case SUMO_ATTR_LANES:
393  case SUMO_ATTR_POSITION:
394  case SUMO_ATTR_ENDPOS:
395  case SUMO_ATTR_FREQUENCY:
396  case SUMO_ATTR_TLID:
397  case SUMO_ATTR_LENGTH:
398  case SUMO_ATTR_NAME:
399  case SUMO_ATTR_FILE:
400  case SUMO_ATTR_VTYPES:
405  case GNE_ATTR_SELECTED:
406  case GNE_ATTR_PARAMETERS:
408  undoList->changeAttribute(new GNEChange_Attribute(this, key, value));
409  break;
410  default:
411  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
412  }
413 }
414 
415 
416 bool
417 GNEDetectorE2::isValid(SumoXMLAttr key, const std::string& value) {
418  switch (key) {
419  case SUMO_ATTR_ID:
420  if (isValidDetectorID(value)) {
422  return (myNet->getAttributeCarriers()->retrieveAdditional(GNE_TAG_E2DETECTOR_MULTILANE, value, false) == nullptr);
423  } else {
424  return (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_E2DETECTOR, value, false) == nullptr);
425  }
426  } else {
427  return false;
428  }
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);
473  case GNE_ATTR_SELECTED:
474  return canParse<bool>(value);
475  case GNE_ATTR_PARAMETERS:
476  return Parameterised::areParametersValid(value);
477  default:
478  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
479  }
480 }
481 
482 
483 bool
485  return true;
486 }
487 
488 // ===========================================================================
489 // private
490 // ===========================================================================
491 
492 void
493 GNEDetectorE2::setAttribute(SumoXMLAttr key, const std::string& value) {
494  switch (key) {
495  case SUMO_ATTR_ID:
496  // update microsimID
497  setMicrosimID(value);
498  break;
499  case SUMO_ATTR_LANE:
500  case SUMO_ATTR_LANES:
502  break;
503  case SUMO_ATTR_POSITION:
504  myPositionOverLane = parse<double>(value);
505  // update geometry (except for template)
506  if (getParentLanes().size() > 0) {
507  updateGeometry();
508  }
509  break;
510  case SUMO_ATTR_ENDPOS:
511  myEndPositionOverLane = parse<double>(value);
512  // update geometry (except for template)
513  if (getParentLanes().size() > 0) {
514  updateGeometry();
515  }
516  break;
517  case SUMO_ATTR_FREQUENCY:
518  myFreq = string2time(value);
519  break;
520  case SUMO_ATTR_TLID:
521  myTrafficLight = value;
522  break;
523  case SUMO_ATTR_LENGTH:
524  myEndPositionOverLane = (myPositionOverLane + parse<double>(value));
525  // update geometry (except for template)
526  if (getParentLanes().size() > 0) {
527  updateGeometry();
528  }
529  break;
530  case SUMO_ATTR_NAME:
531  myAdditionalName = value;
532  break;
533  case SUMO_ATTR_FILE:
534  myFilename = value;
535  break;
536  case SUMO_ATTR_VTYPES:
537  myVehicleTypes = parse<std::vector<std::string> >(value);
538  break;
540  myTimeThreshold = TIME2STEPS(parse<double>(value));
541  break;
543  mySpeedThreshold = parse<double>(value);
544  break;
546  myJamThreshold = parse<double>(value);
547  break;
549  myFriendlyPosition = parse<bool>(value);
550  break;
551  case GNE_ATTR_SELECTED:
552  if (parse<bool>(value)) {
554  } else {
556  }
557  break;
558  case GNE_ATTR_PARAMETERS:
559  setParametersStr(value);
560  break;
562  shiftLaneIndex();
563  break;
564  default:
565  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
566  }
567 }
568 
569 
570 void
574  // change only start position
575  myPositionOverLane = moveResult.newFirstPos;
578  // change only end position
579  myEndPositionOverLane = moveResult.newFirstPos;
580  } else {
581  // change both position
582  myPositionOverLane = moveResult.newFirstPos;
583  myEndPositionOverLane = moveResult.newSecondPos;
584  // set lateral offset
586  }
587  // update geometry
588  updateGeometry();
589 }
590 
591 
592 void
594  // begin change attribute
595  undoList->begin(myTagProperty.getGUIIcon(), "position of " + getTagStr());
596  // set attributes depending of operation type
599  // set only start position
600  setAttribute(SUMO_ATTR_POSITION, toString(moveResult.newFirstPos), undoList);
603  // set only end position
604  setAttribute(SUMO_ATTR_ENDPOS, toString(moveResult.newFirstPos), undoList);
605  } else {
606  // set both
607  setAttribute(SUMO_ATTR_POSITION, toString(moveResult.newFirstPos), undoList);
608  setAttribute(SUMO_ATTR_ENDPOS, toString(moveResult.newSecondPos), undoList);
609  // check if lane has to be changed
610  if (moveResult.newFirstLane) {
611  // set new lane
612  setAttribute(SUMO_ATTR_LANE, moveResult.newFirstLane->getID(), undoList);
613  }
614  }
615  // end change attribute
616  undoList->end();
617 }
618 
619 
620 bool
622  // declare lane iterator
623  int i = 0;
624  // iterate over all lanes, and stop if myE2valid is false
625  while (i < ((int)getParentLanes().size() - 1)) {
626  // we assume that E2 is invalid
627  bool connectionFound = false;
628  // if there is a connection betwen "from" lane and "to" lane of connection, change connectionFound to true
629  for (auto j : getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
630  if (j->getLaneFrom() == getParentLanes().at(i) && j->getLaneTo() == getParentLanes().at(i + 1)) {
631  connectionFound = true;
632  }
633  }
634  // abort if connectionFound is false
635  if (!connectionFound) {
636  return false;
637  }
638  // update iterator
639  i++;
640  }
641  // there are connections between all lanes, then return true
642  return true;
643 }
644 
645 
646 double
648  // get lane final and shape length
649  const double laneLength = getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
650  // get startPosition
651  double fixedPos = myPositionOverLane;
652  // adjust fixedPos
653  if (fixedPos < 0) {
654  fixedPos += laneLength;
655  }
656  fixedPos *= getParentLanes().front()->getLengthGeometryFactor();
657  // return depending of fixedPos
658  if (fixedPos < 0) {
659  return 0;
660  } else if (fixedPos > (getParentLanes().front()->getLaneShapeLength() - POSITION_EPS)) {
661  return (getParentLanes().front()->getLaneShapeLength() - POSITION_EPS);
662  } else {
663  return fixedPos;
664  }
665 }
666 
667 
668 double
670  // get lane final and shape length
671  const double laneLength = getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
672  // get endPosition
673  double fixedPos = myEndPositionOverLane;
674  // adjust fixedPos
675  if (fixedPos < 0) {
676  fixedPos += laneLength;
677  }
678  fixedPos *= getParentLanes().back()->getLengthGeometryFactor();
679  // return depending of fixedPos
680  if (fixedPos < POSITION_EPS) {
681  return POSITION_EPS;
682  } else if (fixedPos > getParentLanes().back()->getLaneShapeLength()) {
683  return getParentLanes().back()->getLaneShapeLength();
684  } else {
685  return fixedPos;
686  }
687 }
688 
689 /****************************************************************************/
@ GLO_E2DETECTOR
a E2 detector
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:32
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_E2DETECTOR
an e2 detector
@ GNE_TAG_E2DETECTOR_MULTILANE
an e2 detector over multiple lanes (placed here due create Additional Frame)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LANE
@ SUMO_ATTR_FILE
@ SUMO_ATTR_JAM_DIST_THRESHOLD
@ 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
@ GNE_ATTR_SHIFTLANEINDEX
shift lane index (only used by elements over lanes)
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:507
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:132
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:123
static void popName()
pop Name
Definition: GLHelper.cpp:141
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:114
static void fixE2MultiLanePosition(double &pos, const double fromLaneLength, double &to, const double TolaneLength)
fix the given positions over lane
static void fixE2SingleLanePosition(double &pos, double &length, const double laneLength)
fix the given positions over lane
static void drawRightGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor)
draw right geometry point
const std::string & getID() const
get ID
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
void shiftLaneIndex()
shift lane index
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
std::string myAdditionalName
name of additional
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
void computePathElement()
compute pathElement
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
void drawParentChildLines(const GUIVisualizationSettings &s, const RGBColor &color, const bool onlySymbols=false) const
draw parent and child lines
static void drawLeftGeometryPoint(const GNEViewNet *viewNet, const Position &pos, const double rot, const RGBColor &baseColor)
draw left geometry point
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
reference to tagProperty associated with this attribute carrier
double getEndGeometryPositionOverLane() const
get end position over lane that is applicable to the shape
void updateGeometry()
update pre-computed geometry information
std::string getAttribute(SumoXMLAttr key) const
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
bool isAdditionalValid() const
check if current additional is valid to be writed into XML
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
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...
void writeAdditional(OutputDevice &device) const
writte additional element into a xml file
bool areLaneConsecutives() const
check if lanes are consecutives
void fixAdditionalProblem()
fix additional problem
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...
double getStartGeometryPositionOverLane() const
get start position over lane that is applicable to the shape
bool isAttributeEnabled(SumoXMLAttr key) const
std::string myTrafficLight
Traffic light vinculated with this E2 Detector.
double getAttributeDouble(SumoXMLAttr key) const
~GNEDetectorE2()
Destructor.
GNEDetectorE2(SumoXMLTag tag, GNENet *net)
default Constructor
std::string getAdditionalProblem() const
return a string with the current additional problem
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
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:180
double myPositionOverLane
position of detector over Lane
Definition: GNEDetector.h:174
SUMOTime myFreq
The aggregation period the values the detector collects shall be summed up.
Definition: GNEDetector.h:177
bool myFriendlyPosition
Flag for friendly position.
Definition: GNEDetector.h:186
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)
std::vector< std::string > myVehicleTypes
attribute vehicle types
Definition: GNEDetector.h:183
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:46
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
move result
const GNELane * newFirstLane
new first Lane
double newFirstPos
new first position
const GNEMoveOperation::OperationType operationType
move operation
double firstLaneOffset
lane offset
double newSecondPos
new second position
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:125
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1964
const std::string & getID() const
get ID
GUIIcon getGUIIcon() const
get GUI icon associated to this Tag
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...
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:537
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
GNEUndoList * getUndoList() const
get the undoList object
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
static void drawDottedContourShape(const DottedContourType type, const GUIVisualizationSettings &s, const PositionVector &shape, const double width, const double exaggeration, const bool drawFirstExtrem, const bool drawLastExtrem, const double lineWidth=-1)
draw dotted contour for the given shape (used by additionals)
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawGeometry(const GUIVisualizationSettings &s, const Position &mousePos, 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:58
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GUIGlID getGlID() const
Returns the numerical id of the object.
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Stores the information about how to visualize structures.
GUIVisualizationDetailSettings detailSettings
detail settings
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...
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
GUIVisualizationDetectorSettings detectorSettings
Detector settings.
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:248
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
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"
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
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".
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
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:197
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)
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
bool showAdditionals() const
check if additionals has to be drawn
static void drawLockIcon(const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position viewPosition, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
static const RGBColor connectionColor
connection color
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.
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:197