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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 //
15 /****************************************************************************/
16 
17 // ===========================================================================
18 // included modules
19 // ===========================================================================
20 
21 #include <netedit/GNENet.h>
22 #include <netedit/GNEUndoList.h>
23 #include <netedit/GNEViewNet.h>
29 #include <utils/gui/div/GLHelper.h>
31 
32 #include "GNEDetectorE2.h"
33 #include "GNEAdditionalHandler.h"
34 
35 
36 // ===========================================================================
37 // member method definitions
38 // ===========================================================================
39 
40 GNEDetectorE2::GNEDetectorE2(const std::string& id, GNELane* lane, GNEViewNet* viewNet, double pos, double length, SUMOTime freq, const std::string& filename, const std::string& vehicleTypes,
41  const std::string& name, SUMOTime timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement) :
42  GNEDetector(id, viewNet, GLO_E2DETECTOR, SUMO_TAG_E2DETECTOR, pos, freq, filename, vehicleTypes, name, friendlyPos, blockMovement, {
43  lane
44 }),
45 myLength(length),
46 myEndPositionOverLane(0.),
47 myTimeThreshold(timeThreshold),
48 mySpeedThreshold(speedThreshold),
49 myJamThreshold(jamThreshold),
50 myE2valid(true) {
51 }
52 
53 
54 GNEDetectorE2::GNEDetectorE2(const std::string& id, std::vector<GNELane*> lanes, GNEViewNet* viewNet, double pos, double endPos, SUMOTime freq, const std::string& filename, const std::string& vehicleTypes,
55  const std::string& name, SUMOTime timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement) :
56  GNEDetector(id, viewNet, GLO_E2DETECTOR, SUMO_TAG_E2DETECTOR_MULTILANE, pos, freq, filename, vehicleTypes, name, friendlyPos, blockMovement, lanes),
57  myLength(0),
58  myEndPositionOverLane(endPos),
59  myTimeThreshold(timeThreshold),
60  mySpeedThreshold(speedThreshold),
61  myJamThreshold(jamThreshold),
62  myE2valid(true) {
63 }
64 
65 
67 }
68 
69 
70 bool
72  if (getParentLanes().size() == 1) {
73  // with friendly position enabled position are "always fixed"
74  if (myFriendlyPosition) {
75  return true;
76  } else {
77  return (myPositionOverLane >= 0) && ((myPositionOverLane + myLength) <= getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength());
78  }
79  } else {
80  // first check if there is connection between all consecutive lanes
81  if (myE2valid) {
82  // with friendly position enabled position are "always fixed"
83  if (myFriendlyPosition) {
84  return true;
85  } else {
86  return (myPositionOverLane >= 0) && ((myPositionOverLane) <= getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength() &&
87  myEndPositionOverLane >= 0) && ((myEndPositionOverLane) <= getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
88  }
89  } else {
90  return false;
91  }
92  }
93 }
94 
95 
96 std::string
98  // declare variable for error position
99  std::string errorFirstLanePosition, separator, errorLastLanePosition;
100  if (getParentLanes().size() == 1) {
101  // check positions over lane
102  if (myPositionOverLane < 0) {
103  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0");
104  }
105  if (myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
106  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " > lanes's length");
107  }
108  if ((myPositionOverLane + myLength) > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
109  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " + " + toString(SUMO_ATTR_LENGTH) + " > lanes's length");
110  }
111  } else {
112  if (myE2valid) {
113  // check positions over first lane
114  if (myPositionOverLane < 0) {
115  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0");
116  }
117  if (myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
118  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " > lanes's length");
119  }
120  // check positions over last lane
121  if (myEndPositionOverLane < 0) {
122  errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + " < 0");
123  }
124  if (myEndPositionOverLane > getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength()) {
125  errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + " > lanes's length");
126  }
127  } else {
128  errorFirstLanePosition = "lanes aren't consecutives";
129  }
130  }
131  // check separator
132  if ((errorFirstLanePosition.size() > 0) && (errorLastLanePosition.size() > 0)) {
133  separator = " and ";
134  }
135  // return error message
136  return errorFirstLanePosition + separator + errorLastLanePosition;
137 }
138 
139 
140 void
142  if (getParentLanes().size() == 1) {
143  // obtain position and length
144  double newPositionOverLane = myPositionOverLane;
145  double newLength = myLength;
146  // fix pos and length using fixE2DetectorPosition
147  GNEAdditionalHandler::fixE2DetectorPosition(newPositionOverLane, newLength, getParentLanes().at(0)->getParentEdge()->getNBEdge()->getFinalLength(), true);
148  // set new position and length
149  setAttribute(SUMO_ATTR_POSITION, toString(newPositionOverLane), myViewNet->getUndoList());
151  } else {
152  if (!myE2valid) {
153  // build connections between all consecutive lanes
154  bool foundConnection = true;
155  int i = 0;
156  // iterate over all lanes, and stop if myE2valid is false
157  while (i < ((int)getParentLanes().size() - 1)) {
158  // change foundConnection to false
159  foundConnection = false;
160  // if a connection betwen "from" lane and "to" lane of connection is found, change myE2valid to true again
161  for (auto j : getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
162  if (j->getLaneFrom() == getParentLanes().at(i) && j->getLaneTo() == getParentLanes().at(i + 1)) {
163  foundConnection = true;
164  }
165  }
166  // if connection wasn't found
167  if (!foundConnection) {
168  // create new connection manually
169  NBEdge::Connection newCon(getParentLanes().at(i)->getIndex(), getParentLanes().at(i + 1)->getParentEdge()->getNBEdge(), getParentLanes().at(i + 1)->getIndex());
170  // allow to undo creation of new lane
171  myViewNet->getUndoList()->add(new GNEChange_Connection(getParentLanes().at(i)->getParentEdge(), newCon, false, true), true);
172  }
173  // update lane iterator
174  i++;
175  }
176  } else {
177  // declare new position
178  double newPositionOverLane = myPositionOverLane;
179  // fix pos and length checkAndFixDetectorPosition
180  GNEAdditionalHandler::checkAndFixDetectorPosition(newPositionOverLane, getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(), true);
181  // set new position
182  setAttribute(SUMO_ATTR_POSITION, toString(newPositionOverLane), myViewNet->getUndoList());
183  // declare new end position
184  double newEndPositionOverLane = myEndPositionOverLane;
185  // fix pos and length checkAndFixDetectorPosition
186  GNEAdditionalHandler::checkAndFixDetectorPosition(newEndPositionOverLane, getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength(), true);
187  // set new position
188  setAttribute(SUMO_ATTR_ENDPOS, toString(newEndPositionOverLane), myViewNet->getUndoList());
189  }
190  }
191 }
192 
193 
194 void
196  // Calculate new position using old position
197  Position newPosition = myMove.originalViewPosition;
198  newPosition.add(offset);
199  // filtern position using snap to active grid
200  newPosition = myViewNet->snapToActiveGrid(newPosition);
201  double offsetLane = getParentLanes().front()->getLaneShape().nearest_offset_to_point2D(newPosition, false) - getParentLanes().front()->getLaneShape().nearest_offset_to_point2D(myMove.originalViewPosition, false);
202  // move geometry depending of number of lanes
203  if (getParentLanes().size() == 1) {
204  // calculate new position over lane
205  double newPositionOverLane = parse<double>(myMove.firstOriginalLanePosition) + offsetLane;
206  // obtain lane length
207  double laneLength = getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength() * getLane()->getLengthGeometryFactor();
208  if (newPositionOverLane < 0) {
209  myPositionOverLane = 0;
210  } else if (newPositionOverLane + myLength > laneLength) {
211  myPositionOverLane = laneLength - myLength;
212  } else {
213  myPositionOverLane = newPositionOverLane;
214  }
215  } else {
216  // calculate new start and end positions
217  double newStartPosition = parse<double>(myMove.firstOriginalLanePosition) + offsetLane;
218  double newEndPosition = parse<double>(myMove.secondOriginalPosition) + offsetLane;
219  // change start and end position of E2 detector ONLY if both extremes aren't overpassed
220  if ((newStartPosition >= 0) && (newStartPosition <= getParentLanes().front()->getLaneShapeLength()) &&
221  (newEndPosition >= 0) && (newEndPosition <= getParentLanes().back()->getLaneShapeLength())) {
222  myPositionOverLane = newStartPosition;
223  myEndPositionOverLane = newEndPosition;
224  }
225  }
226  // Update geometry
227  updateGeometry();
228 }
229 
230 
231 void
233  // commit geometry moving depending of number of lanes
234  if (getParentLanes().size() == 1) {
235  // commit new position allowing undo/redo
236  undoList->p_begin("position of " + getTagStr());
238  undoList->p_end();
239  } else {
240  undoList->p_begin("position of " + getTagStr());
243  undoList->p_end();
244  }
245 }
246 
247 
248 void
250  // declare variables for start and end positions
251  double startPosFixed, endPosFixed;
252 
253  // calculate start and end positions dependin of number of lanes
254  if (getParentLanes().size() == 1) {
255 
256  // set start position
257  if (myPositionOverLane < 0) {
258  startPosFixed = 0;
259  } else if (myPositionOverLane > getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength()) {
260  startPosFixed = getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
261  } else {
262  startPosFixed = myPositionOverLane;
263  }
264 
265  // set end position
266  if ((myPositionOverLane + myLength) < 0) {
267  endPosFixed = 0;
268  } else if ((myPositionOverLane + myLength) > getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength()) {
269  endPosFixed = getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
270  } else {
271  endPosFixed = (myPositionOverLane + myLength);
272  }
273 
274  // Cut shape using as delimitators fixed start position and fixed end position
275  myAdditionalGeometry.updateGeometryShape(getParentLanes().front()->getLaneShape(), startPosFixed * getParentLanes().front()->getLengthGeometryFactor(), endPosFixed * getParentLanes().back()->getLengthGeometryFactor());
276 
277  // Set block icon position
279 
280  } else if (getParentLanes().size() > 1) {
282  /*
283  // Set block icon position
284  myBlockIcon.position = myAdditionalGeometry.multiShape.front().getLineCenter();
285 
286  // check integrity
287  checkE2MultilaneIntegrity();
288  */
289  }
290 
291  // Set offset of the block icon
292  myBlockIcon.offset = Position(-0.75, 0);
293 
294  // Set block icon rotation, and using their rotation for draw logo
296 }
297 
298 
299 double
301  return myLength;
302 }
303 
304 
305 void
307  // we assume that E2 is valid
308  myE2valid = true;
309  int i = 0;
310  // iterate over all lanes, and stop if myE2valid is false
311  while (i < ((int)getParentLanes().size() - 1) && myE2valid) {
312  // set myE2valid to false
313  myE2valid = false;
314  // if a connection betwen "from" lane and "to" lane of connection is found, change myE2valid to true again
315  for (auto j : getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
316  if (j->getLaneFrom() == getParentLanes().at(i) && j->getLaneTo() == getParentLanes().at(i + 1)) {
317  myE2valid = true;
318  }
319  }
320  // update iterator
321  i++;
322  }
323 }
324 
325 
326 void
328  // Obtain exaggeration of the draw
329  const double exaggeration = s.addSize.getExaggeration(s, this);
330  // first check if additional has to be drawn
331  if ((myTagProperty.getTag() == SUMO_TAG_E2DETECTOR) && s.drawAdditionals(exaggeration)) {
332  // Start drawing adding an gl identificator
333  glPushName(getGlID());
334  // Add a draw matrix
335  glPushMatrix();
336  // Start with the drawing of the area traslating matrix to origin
337  glTranslated(0, 0, getType());
338  // Set color of the base
339  if (drawUsingSelectColor()) {
341  } else {
342  // set color depending if is or isn't valid
343  if (myE2valid) {
345  } else {
347  }
348  }
349  // check if we have to drawn a E2 single lane or a E2 multiLane
350  if (myAdditionalGeometry.getShape().size() > 0) {
351  // Draw the area using shape, shapeRotations, shapeLengths and value of exaggeration
353  } else {
354  /*
355  // iterate over multishapes
356  for (int i = 0; i < (int)myAdditionalGeometry.multiShape.size(); i++) {
357  // don't draw shapes over connections if "show connections" is enabled
358  if (!myViewNet->getNetworkViewOptions().showConnections() || (i % 2 == 0)) {
359  GLHelper::drawBoxLines(myAdditionalGeometry.multiShape.at(i), myAdditionalGeometry.multiShapeRotations.at(i), myAdditionalGeometry.multiShapeLengths.at(i), exaggeration);
360  }
361  }
362  */
363  }
364  // Pop last matrix
365  glPopMatrix();
366  // Check if the distance is enougth to draw details and isn't being drawn for selecting
367  if ((s.drawDetail(s.detailSettings.detectorDetails, exaggeration)) && !s.drawForRectangleSelection) {
368  // draw logo depending if this is an Multilane E2 detector
370  // Push matrix
371  glPushMatrix();
372  // Traslate to center of detector
374  // Rotate depending of myBlockIcon.rotation
375  glRotated(myBlockIcon.rotation, 0, 0, -1);
376  // move to logo position
377  glTranslated(-0.75, 0, 0);
378  // scale text
379  glScaled(exaggeration, exaggeration, 1);
380  // draw E2 logo
381  if (drawUsingSelectColor()) {
383  } else {
384  GLHelper::drawText("E2", Position(), .1, 1.5, RGBColor::BLACK);
385  }
386  } else {
387  // Push matrix
388  glPushMatrix();
389  // Traslate to center of detector
390  glTranslated(myBlockIcon.position.x(), myBlockIcon.position.y(), getType() + 0.1);
391  // Rotate depending of myBlockIcon.rotation
392  glRotated(myBlockIcon.rotation, 0, 0, -1);
393  //move to logo position
394  glTranslated(-1.5, 0, 0);
395  // scale text
396  glScaled(exaggeration, exaggeration, 1);
397  // draw E2 logo
398  if (drawUsingSelectColor()) {
400  } else {
401  GLHelper::drawText("E2", Position(), .1, 1.5, RGBColor::BLACK);
402  }
403  //move to logo position
404  glTranslated(1.2, 0, 0);
405  // Rotate depending of myBlockIcon.rotation
406  glRotated(90, 0, 0, 1);
407  if (drawUsingSelectColor()) {
409  } else {
410  GLHelper::drawText("multi", Position(), .1, 0.9, RGBColor::BLACK);
411  }
412  }
413  // pop matrix
414  glPopMatrix();
415  // Show Lock icon depending of the Edit mode
416  myBlockIcon.drawIcon(s, exaggeration);
417  }
418  // Draw name if isn't being drawn for selecting
419  if (!s.drawForRectangleSelection) {
421  }
422  // check if dotted contour has to be drawn
423  if (myViewNet->getDottedAC() == this) {
424  if (myAdditionalGeometry.getShape().size() > 0) {
426  } else {
427  /*
428  GLHelper::drawShapeDottedContourAroundShape(s, getType(), myAdditionalGeometry.multiShapeUnified, exaggeration);
429  */
430  }
431  }
432  // Pop name
433  glPopName();
434  }
435 }
436 
437 
438 std::string
440  switch (key) {
441  case SUMO_ATTR_ID:
442  return getAdditionalID();
443  case SUMO_ATTR_LANE:
444  case SUMO_ATTR_LANES:
445  return parseIDs(getParentLanes());
446  case SUMO_ATTR_POSITION:
448  case SUMO_ATTR_ENDPOS:
450  case SUMO_ATTR_FREQUENCY:
451  return time2string(myFreq);
452  case SUMO_ATTR_LENGTH:
453  return toString(myLength);
454  case SUMO_ATTR_NAME:
455  return myAdditionalName;
456  case SUMO_ATTR_FILE:
457  return myFilename;
458  case SUMO_ATTR_VTYPES:
459  return myVehicleTypes;
463  return toString(mySpeedThreshold);
465  return toString(myJamThreshold);
469  return toString(myBlockMovement);
470  case GNE_ATTR_SELECTED:
472  case GNE_ATTR_PARAMETERS:
473  return getParametersStr();
474  default:
475  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
476  }
477 }
478 
479 
480 void
481 GNEDetectorE2::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
482  if (value == getAttribute(key)) {
483  return; //avoid needless changes, later logic relies on the fact that attributes have changed
484  }
485  switch (key) {
486  case SUMO_ATTR_ID:
487  case SUMO_ATTR_LANE:
488  case SUMO_ATTR_LANES:
489  case SUMO_ATTR_POSITION:
490  case SUMO_ATTR_ENDPOS:
491  case SUMO_ATTR_FREQUENCY:
492  case SUMO_ATTR_LENGTH:
493  case SUMO_ATTR_NAME:
494  case SUMO_ATTR_FILE:
495  case SUMO_ATTR_VTYPES:
501  case GNE_ATTR_SELECTED:
502  case GNE_ATTR_PARAMETERS:
503  undoList->p_add(new GNEChange_Attribute(this, myViewNet->getNet(), key, value));
504  break;
505  default:
506  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
507  }
508 }
509 
510 
511 bool
512 GNEDetectorE2::isValid(SumoXMLAttr key, const std::string& value) {
513  switch (key) {
514  case SUMO_ATTR_ID:
515  return isValidDetectorID(value);
516  case SUMO_ATTR_LANE:
517  if (value.empty()) {
518  return false;
519  } else {
520  return canParse<std::vector<GNELane*> >(myViewNet->getNet(), value, false);
521  }
522  case SUMO_ATTR_LANES:
523  if (value.empty()) {
524  return false;
525  } else if (canParse<std::vector<GNELane*> >(myViewNet->getNet(), value, false)) {
526  // check if lanes are consecutives
527  return lanesConsecutives(parse<std::vector<GNELane*> >(myViewNet->getNet(), value));
528  } else {
529  return false;
530  }
531  case SUMO_ATTR_POSITION:
532  return canParse<double>(value);
533  case SUMO_ATTR_ENDPOS:
534  return canParse<double>(value);
535  case SUMO_ATTR_FREQUENCY:
536  return (canParse<double>(value) && (parse<double>(value) >= 0));
537  case SUMO_ATTR_LENGTH:
538  return (canParse<double>(value) && (parse<double>(value) >= 0));
539  case SUMO_ATTR_NAME:
541  case SUMO_ATTR_FILE:
543  case SUMO_ATTR_VTYPES:
544  if (value.empty()) {
545  return true;
546  } else {
548  }
550  return canParse<SUMOTime>(value);
552  return (canParse<double>(value) && (parse<double>(value) >= 0));
554  return (canParse<double>(value) && (parse<double>(value) >= 0));
556  return canParse<bool>(value);
558  return canParse<bool>(value);
559  case GNE_ATTR_SELECTED:
560  return canParse<bool>(value);
561  case GNE_ATTR_PARAMETERS:
562  return Parameterised::areParametersValid(value);
563  default:
564  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
565  }
566 }
567 
568 
569 bool
571  return true;
572 }
573 
574 // ===========================================================================
575 // private
576 // ===========================================================================
577 
578 void
579 GNEDetectorE2::setAttribute(SumoXMLAttr key, const std::string& value) {
580  switch (key) {
581  case SUMO_ATTR_ID:
582  changeAdditionalID(value);
583  break;
584  case SUMO_ATTR_LANE:
585  case SUMO_ATTR_LANES:
586  replaceParentLanes(this, value);
588  break;
589  case SUMO_ATTR_POSITION:
590  myPositionOverLane = parse<double>(value);
591  break;
592  case SUMO_ATTR_ENDPOS:
593  myEndPositionOverLane = parse<double>(value);
594  break;
595  case SUMO_ATTR_FREQUENCY:
596  myFreq = parse<SUMOTime>(value);
597  break;
598  case SUMO_ATTR_LENGTH:
599  myLength = parse<double>(value);
600  break;
601  case SUMO_ATTR_NAME:
602  myAdditionalName = value;
603  break;
604  case SUMO_ATTR_FILE:
605  myFilename = value;
606  break;
607  case SUMO_ATTR_VTYPES:
608  myVehicleTypes = value;
609  break;
611  myTimeThreshold = parse<SUMOTime>(value);
612  break;
614  mySpeedThreshold = parse<double>(value);
615  break;
617  myJamThreshold = parse<double>(value);
618  break;
620  myFriendlyPosition = parse<bool>(value);
621  break;
623  myBlockMovement = parse<bool>(value);
624  break;
625  case GNE_ATTR_SELECTED:
626  if (parse<bool>(value)) {
628  } else {
630  }
631  break;
632  case GNE_ATTR_PARAMETERS:
633  setParametersStr(value);
634  break;
635  default:
636  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
637  }
638 }
639 
640 /****************************************************************************/
GUIGlObject::getType
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.cpp:180
SUMOXMLDefinitions::isValidAttribute
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name)
Definition: SUMOXMLDefinitions.cpp:995
GNEAdditionalHandler::fixE2DetectorPosition
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
Definition: GNEAdditionalHandler.cpp:1001
GNEAdditional::BlockIcon::position
Position position
position of the block icon
Definition: GNEAdditional.h:318
GNEDetectorE2::checkE2MultilaneIntegrity
void checkE2MultilaneIntegrity()
check if E2 is valid (all of their lanes are connected, it must called after every operation which in...
Definition: GNEDetectorE2.cpp:306
SUMO_ATTR_HALTING_SPEED_THRESHOLD
Definition: SUMOXMLDefinitions.h:751
Parameterised::getParametersStr
std::string getParametersStr() const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
Definition: Parameterised.cpp:112
GNEAdditional::getAdditionalID
const std::string & getAdditionalID() const
Definition: GNEAdditional.cpp:476
GNEDetectorE2::isAdditionalValid
bool isAdditionalValid() const
check if current additional is valid to be writed into XML (by default true, can be reimplemented in ...
Definition: GNEDetectorE2.cpp:71
GNEDetectorE2::myLength
double myLength
E2 detector length.
Definition: GNEDetectorE2.h:151
GNEGeometry::Geometry::updateGeometryShape
void updateGeometryShape(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:48
SUMO_ATTR_LENGTH
Definition: SUMOXMLDefinitions.h:393
SUMOXMLDefinitions::isValidFilename
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name)
Definition: SUMOXMLDefinitions.cpp:1001
GNEAdditional::BlockIcon::setRotation
void setRotation(GNELane *additionalLane=nullptr)
set Rotation of block Icon (must be called in updateGeometry() function)
Definition: GNEAdditional.cpp:400
GUIGlObject::drawName
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
Definition: GUIGlObject.cpp:354
GNEDetectorE2::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEDetectorE2.cpp:439
RGBColor::BLACK
static const RGBColor BLACK
Definition: RGBColor.h:197
GNEUndoList::p_end
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
Definition: GNEUndoList.cpp:79
GUIVisualizationSettings::drawForRectangleSelection
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
Definition: GUIVisualizationSettings.h:647
GNEAttributeCarrier::parseIDs
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
GUIVisualizationColorSettings::E2
static const RGBColor E2
color for E2 detectors
Definition: GUIVisualizationSettings.h:213
GNEDetector::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEDetector.cpp:72
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
GNEDetectorE2::myTimeThreshold
SUMOTime myTimeThreshold
The time-based threshold that describes how much time has to pass until a vehicle is recognized as ha...
Definition: GNEDetectorE2.h:157
GNEHierarchicalParentElements::getParentLanes
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
Definition: GNEHierarchicalParentElements.cpp:235
GNEDetectorE2::fixAdditionalProblem
void fixAdditionalProblem()
fix additional problem
Definition: GNEDetectorE2.cpp:141
GNEViewNet
Definition: GNEViewNet.h:42
SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:378
GLHelper.h
SUMO_ATTR_LANE
Definition: SUMOXMLDefinitions.h:637
GNEDetectorE2::commitGeometryMoving
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
Definition: GNEDetectorE2.cpp:232
SUMO_ATTR_ENDPOS
Definition: SUMOXMLDefinitions.h:798
GNEAdditional::changeAdditionalID
void changeAdditionalID(const std::string &newID)
change ID of additional
Definition: GNEAdditional.cpp:502
GNEDetector::myPositionOverLane
double myPositionOverLane
position of detector over Lane
Definition: GNEDetector.h:174
GNEAdditional::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNEAdditional.cpp:532
GNEAdditional::AdditionalMove::secondOriginalPosition
std::string secondOriginalPosition
value for saving second original position over lane before moving
Definition: GNEAdditional.h:297
GNEAdditional::myBlockIcon
BlockIcon myBlockIcon
variable BlockIcon
Definition: GNEAdditional.h:353
GLHelper::setColor
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:621
GNEDetector::myFriendlyPosition
bool myFriendlyPosition
Flag for friendly position.
Definition: GNEDetector.h:186
SUMO_ATTR_FILE
Definition: SUMOXMLDefinitions.h:664
GUISUMOAbstractView::snapToActiveGrid
Position snapToActiveGrid(const Position &pos, bool snapXY=true) const
Returns a position that is mapped to the closest grid point if the grid is active.
Definition: GUISUMOAbstractView.cpp:196
GUIVisualizationDetailSettings::detectorDetails
static const double detectorDetails
details for detectors
Definition: GUIVisualizationSettings.h:304
GNEAttributeCarrier::TagProperties::getTag
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
Definition: GNEAttributeCarrier.cpp:523
GNEAdditional::myMove
AdditionalMove myMove
variable AdditionalMove
Definition: GNEAdditional.h:344
GNEAdditional::myViewNet
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
Definition: GNEAdditional.h:335
GNEDetectorE2::myJamThreshold
double myJamThreshold
The minimum distance to the next standing vehicle in order to make this vehicle count as a participan...
Definition: GNEDetectorE2.h:163
GNEAttributeCarrier::GNEChange_Attribute
friend class GNEChange_Attribute
declare friend class
Definition: GNEAttributeCarrier.h:57
GNEUndoList::p_add
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
Definition: GNEUndoList.cpp:131
GNEViewNet::getNet
GNENet * getNet() const
get the net object
Definition: GNEViewNet.cpp:1014
GNEAdditional::isAttributeCarrierSelected
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
Definition: GNEAdditional.cpp:548
GLHelper::drawText
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, int align=0, double width=-1)
Definition: GLHelper.cpp:673
GUIVisualizationSettings::addName
GUIVisualizationTextSettings addName
Definition: GUIVisualizationSettings.h:591
GNEDetectorE2::getLength
double getLength() const
get length of E2 Detector
Definition: GNEDetectorE2.cpp:300
GNEAdditional::isValidDetectorID
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
Definition: GNEAdditional.cpp:492
GUIVisualizationSettings::detailSettings
GUIVisualizationDetailSettings detailSettings
detail settings
Definition: GUIVisualizationSettings.h:683
GNEDetector::myVehicleTypes
std::string myVehicleTypes
attribute vehicle types
Definition: GNEDetector.h:183
GNEAttributeCarrier::lanesConsecutives
static bool lanesConsecutives(const std::vector< GNELane * > &lanes)
check if lanes are consecutives
Definition: GNEAttributeCarrier.cpp:1136
GUIVisualizationColorSettings::selectedAdditionalColor
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
Definition: GUIVisualizationSettings.h:147
GNEGeometry::Geometry::getShape
const PositionVector & getShape() const
The shape of the additional element.
Definition: GNEGeometry.cpp:147
GNEDetectorE2::updateGeometry
void updateGeometry()
update pre-computed geometry information
Definition: GNEDetectorE2.cpp:249
GNEDetectorE2::myE2valid
bool myE2valid
flag to check if E2 multilane is valid or invalid
Definition: GNEDetectorE2.h:166
GNEAdditional::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
Definition: GNEAdditional.cpp:517
GNEViewNet.h
GNEAdditionalHandler.h
GNELane::getLengthGeometryFactor
double getLengthGeometryFactor() const
get length geometry factor
Definition: GNELane.cpp:1428
GUIGlObject::getGlID
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.cpp:149
GNEViewNet::getDottedAC
const GNEAttributeCarrier * getDottedAC() const
get AttributeCarrier under cursor
Definition: GNEViewNet.cpp:1026
GNEHierarchicalParentElements::replaceParentLanes
void replaceParentLanes(GNEShape *elementChild, const std::string &newLaneIDs)
replace the parent edges of a shape
Definition: GNEHierarchicalParentElements.cpp:469
GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
Definition: SUMOXMLDefinitions.h:989
GNEGeometry::drawGeometry
static void drawGeometry(const GNEViewNet *viewNet, const Geometry &geometry, const double width)
draw geometry
Definition: GNEGeometry.cpp:795
GNEDetectorE2::isAttributeEnabled
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEDetectorE2.cpp:570
GUIVisualizationSettings::scale
double scale
information about a lane's width (temporary, used for a single view)
Definition: GUIVisualizationSettings.h:632
GNEDetector::getLane
GNELane * getLane() const
get lane
Definition: GNEDetector.cpp:66
GNEDetector
Definition: GNEDetector.h:33
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
Position::x
double x() const
Returns the x-position.
Definition: Position.h:56
GNEEdge.h
GNEAttributeCarrier::myTagProperty
const TagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
Definition: GNEAttributeCarrier.h:785
time2string
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:67
GNEViewNet::getUndoList
GNEUndoList * getUndoList() const
get the undoList object
Definition: GNEViewNet.cpp:1020
GNEAdditional::myAdditionalGeometry
GNEGeometry::Geometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
Definition: GNEAdditional.h:338
GNEAdditional::myAdditionalName
std::string myAdditionalName
name of additional
Definition: GNEAdditional.h:347
RGBColor::RED
static const RGBColor RED
named colors
Definition: RGBColor.h:189
GNEDetectorE2::mySpeedThreshold
double mySpeedThreshold
The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting.
Definition: GNEDetectorE2.h:160
GNEChange_Connection
Definition: GNEChange_Connection.h:44
GNEDetectorE2.h
GNEAdditional::myBlockMovement
bool myBlockMovement
boolean to check if additional element is blocked (i.e. cannot be moved with mouse)
Definition: GNEAdditional.h:350
GNEAdditional::BlockIcon::rotation
double rotation
The rotation of the block icon.
Definition: GNEAdditional.h:324
GLHelper::drawShapeDottedContourAroundShape
static void drawShapeDottedContourAroundShape(const GUIVisualizationSettings &s, const int type, const PositionVector &shape, const double width)
draw a dotted contour around the given Non closed shape with certain width
Definition: GLHelper.cpp:461
GNEDetectorE2::isValid
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEDetectorE2.cpp:512
SUMO_ATTR_FRIENDLY_POS
Definition: SUMOXMLDefinitions.h:765
GNELane.h
GNEAttributeCarrier::canParse
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
Definition: GNEAttributeCarrier.h:636
SUMO_ATTR_FREQUENCY
Definition: SUMOXMLDefinitions.h:662
SUMO_ATTR_POSITION
Definition: SUMOXMLDefinitions.h:660
GNEDetectorE2::setAttribute
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
Definition: GNEDetectorE2.cpp:481
SUMO_TAG_E2DETECTOR_MULTILANE
an e2 detector over multiple lanes (used by Netedit)
Definition: SUMOXMLDefinitions.h:69
GUIVisualizationSettings::colorSettings
GUIVisualizationColorSettings colorSettings
color settings
Definition: GUIVisualizationSettings.h:677
GNEAttributeCarrier::parse
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
SUMO_ATTR_LANES
Definition: SUMOXMLDefinitions.h:638
GUIVisualizationColorSettings::selectionColor
RGBColor selectionColor
basic selection color
Definition: GUIVisualizationSettings.h:129
Parameterised::setParametersStr
void setParametersStr(const std::string &paramsString)
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
Definition: Parameterised.cpp:139
GLIncludes.h
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
GNEAdditional::BlockIcon::drawIcon
void drawIcon(const GUIVisualizationSettings &s, const double exaggeration, const double size=0.5) const
draw lock icon
Definition: GNEAdditional.cpp:416
Position::y
double y() const
Returns the y-position.
Definition: Position.h:61
SUMO_ATTR_HALTING_TIME_THRESHOLD
Definition: SUMOXMLDefinitions.h:750
Parameterised::areParametersValid
static bool areParametersValid(const std::string &value, bool report=false)
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
Definition: Parameterised.cpp:166
SUMO_ATTR_VTYPES
Definition: SUMOXMLDefinitions.h:632
InvalidArgument
Definition: UtilExceptions.h:56
GNE_ATTR_BLOCK_MOVEMENT
block movement of a graphic element
Definition: SUMOXMLDefinitions.h:981
GNEDetectorE2::myEndPositionOverLane
double myEndPositionOverLane
end position over lane (only for Multilane E2 detectors)
Definition: GNEDetectorE2.h:154
GNEDetector::myFilename
std::string myFilename
The path to the output file.
Definition: GNEDetector.h:180
GUIVisualizationSettings::drawAdditionals
bool drawAdditionals(const double exaggeration) const
check if additionals must be drawn
Definition: GUIVisualizationSettings.cpp:1663
GNEAdditional::drawUsingSelectColor
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
Definition: GNEAdditional.cpp:554
GNEDetectorE2::getAdditionalProblem
std::string getAdditionalProblem() const
return a string with the current additional problem
Definition: GNEDetectorE2.cpp:97
GNEGeometry::calculateLaneGeometricPath
static void calculateLaneGeometricPath(const GNEAttributeCarrier *AC, GNEGeometry::SegmentGeometry &segmentGeometry, const std::vector< GNELane * > &lanes, double startPos=-1, double endPos=-1, const Position &extraFirstPosition=Position::INVALID, const Position &extraLastPosition=Position::INVALID)
calculate route between lanes
Definition: GNEGeometry.cpp:640
GNEDetector::myFreq
SUMOTime myFreq
The aggregation period the values the detector collects shall be summed up.
Definition: GNEDetector.h:177
SUMO_ATTR_JAM_DIST_THRESHOLD
Definition: SUMOXMLDefinitions.h:752
GUIVisualizationSettings::addSize
GUIVisualizationSizeSettings addSize
Definition: GUIVisualizationSettings.h:589
GNEDetectorE2::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEDetectorE2.cpp:327
Position::add
void add(const Position &pos)
Adds the given position to this one.
Definition: Position.h:126
GNE_ATTR_SELECTED
element is selected
Definition: SUMOXMLDefinitions.h:971
GUIVisualizationSettings::drawDetail
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
Definition: GUIVisualizationSettings.cpp:1669
GNEAttributeCarrier::getTagStr
const std::string & getTagStr() const
get tag assigned to this object in string format
Definition: GNEAttributeCarrier.cpp:1267
SUMOXMLDefinitions::isValidListOfTypeID
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)
Definition: SUMOXMLDefinitions.cpp:1024
SUMO_ATTR_NAME
Definition: SUMOXMLDefinitions.h:380
GNEUndoList
Definition: GNEUndoList.h:48
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
PositionVector::getLineCenter
Position getLineCenter() const
get line center
Definition: PositionVector.cpp:474
GNEDetectorE2::~GNEDetectorE2
~GNEDetectorE2()
Destructor.
Definition: GNEDetectorE2.cpp:66
GNEAdditional::mySegmentGeometry
GNEGeometry::SegmentGeometry mySegmentGeometry
segment geometry to be precomputed in updateGeometry(...) (used by E2Multilane)
Definition: GNEAdditional.h:341
NBEdge::Connection
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:189
GNEUndoList::p_begin
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:72
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
GNEAdditional::AdditionalMove::originalViewPosition
Position originalViewPosition
value for saving first original position over lane before moving
Definition: GNEAdditional.h:291
SUMO_TAG_E2DETECTOR
an e2 detector
Definition: SUMOXMLDefinitions.h:67
GNEAdditional::AdditionalMove::firstOriginalLanePosition
std::string firstOriginalLanePosition
value for saving first original position over lane before moving
Definition: GNEAdditional.h:294
GNELane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
GNEAdditionalHandler::checkAndFixDetectorPosition
static bool checkAndFixDetectorPosition(double &pos, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
Definition: GNEAdditionalHandler.cpp:987
GNEDetectorE2::moveGeometry
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
Definition: GNEDetectorE2.cpp:195
GLO_E2DETECTOR
a E2 detector
Definition: GUIGlObjectTypes.h:77
GNEChange_Attribute.h
GNENet.h
GUIVisualizationSizeSettings::getExaggeration
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
Definition: GUIVisualizationSettings.cpp:212
GNEAdditional::BlockIcon::offset
Position offset
The offSet of the block icon.
Definition: GNEAdditional.h:321
GNEUndoList.h
GNEDetectorE2::GNEDetectorE2
GNEDetectorE2(const std::string &id, GNELane *lane, GNEViewNet *viewNet, double pos, double length, SUMOTime freq, 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.
Definition: GNEDetectorE2.cpp:40
GNEChange_Connection.h
GNEConnection.h