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 /****************************************************************************/
15 //
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 
22 #include <netedit/GNENet.h>
23 #include <netedit/GNEUndoList.h>
24 #include <netedit/GNEViewNet.h>
30 #include <utils/gui/div/GLHelper.h>
32 
33 #include "GNEDetectorE2.h"
34 #include "GNEAdditionalHandler.h"
35 
36 
37 // ===========================================================================
38 // member method definitions
39 // ===========================================================================
40 
41 GNEDetectorE2::GNEDetectorE2(const std::string& id, GNELane* lane, GNEViewNet* viewNet, double pos, double length, SUMOTime freq, const std::string& filename, const std::string& vehicleTypes,
42  const std::string& name, SUMOTime timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement) :
43  GNEDetector(id, viewNet, GLO_E2DETECTOR, SUMO_TAG_E2DETECTOR, pos, freq, filename, vehicleTypes, name, friendlyPos, blockMovement, {
44  lane
45 }),
46 myLength(length),
47 myEndPositionOverLane(0.),
48 myTimeThreshold(timeThreshold),
49 mySpeedThreshold(speedThreshold),
50 myJamThreshold(jamThreshold),
51 myE2valid(true) {
52 }
53 
54 
55 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,
56  const std::string& name, SUMOTime timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement) :
57  GNEDetector(id, viewNet, GLO_E2DETECTOR, SUMO_TAG_E2DETECTOR_MULTILANE, pos, freq, filename, vehicleTypes, name, friendlyPos, blockMovement, lanes),
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 (getLaneParents().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) <= getLaneParents().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) <= getLaneParents().back()->getParentEdge().getNBEdge()->getFinalLength() &&
87  myEndPositionOverLane >= 0) && ((myEndPositionOverLane) <= getLaneParents().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 (getLaneParents().size() == 1) {
101  // check positions over lane
102  if (myPositionOverLane < 0) {
103  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0");
104  }
105  if (myPositionOverLane > getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength()) {
106  errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " > lanes's length");
107  }
108  if ((myPositionOverLane + myLength) > getLaneParents().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 > getLaneParents().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 > getLaneParents().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 (getLaneParents().size() == 1) {
143  // obtain position and lenght
144  double newPositionOverLane = myPositionOverLane;
145  double newLength = myLength;
146  // fix pos and lenght using fixE2DetectorPosition
147  GNEAdditionalHandler::fixE2DetectorPosition(newPositionOverLane, newLength, getLaneParents().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)getLaneParents().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 : getLaneParents().at(i)->getParentEdge().getGNEConnections()) {
162  if (j->getLaneFrom() == getLaneParents().at(i) && j->getLaneTo() == getLaneParents().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(getLaneParents().at(i)->getIndex(), getLaneParents().at(i + 1)->getParentEdge().getNBEdge(), getLaneParents().at(i + 1)->getIndex());
170  // allow to undo creation of new lane
171  myViewNet->getUndoList()->add(new GNEChange_Connection(&getLaneParents().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 lenght checkAndFixDetectorPosition
180  GNEAdditionalHandler::checkAndFixDetectorPosition(newPositionOverLane, getLaneParents().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 lenght checkAndFixDetectorPosition
186  GNEAdditionalHandler::checkAndFixDetectorPosition(newEndPositionOverLane, getLaneParents().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 = getLaneParents().front()->getGeometry().shape.nearest_offset_to_point2D(newPosition, false) - getLaneParents().front()->getGeometry().shape.nearest_offset_to_point2D(myMove.originalViewPosition, false);
202  // move geometry depending of number of lanes
203  if (getLaneParents().size() == 1) {
204  // calculate new position over lane
205  double newPositionOverLane = parse<double>(myMove.firstOriginalLanePosition) + offsetLane;
206  // obtain lane length
207  double laneLenght = getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength() * getLane()->getLengthGeometryFactor();
208  if (newPositionOverLane < 0) {
209  myPositionOverLane = 0;
210  } else if (newPositionOverLane + myLength > laneLenght) {
211  myPositionOverLane = laneLenght - 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 <= getLaneParents().front()->getLaneShapeLength()) &&
221  (newEndPosition >= 0) && (newEndPosition <= getLaneParents().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 (getLaneParents().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  // Clear all containers
252 
253  // declare variables for start and end positions
254  double startPosFixed, endPosFixed;
255 
256  // calculate start and end positions dependin of number of lanes
257  if (getLaneParents().size() == 1) {
258  // set shape lane as detector shape
259  myGeometry.shape = getLaneParents().front()->getGeometry().shape;
260 
261  // set start position
262  if (myPositionOverLane < 0) {
263  startPosFixed = 0;
264  } else if (myPositionOverLane > getLaneParents().back()->getParentEdge().getNBEdge()->getFinalLength()) {
265  startPosFixed = getLaneParents().back()->getParentEdge().getNBEdge()->getFinalLength();
266  } else {
267  startPosFixed = myPositionOverLane;
268  }
269 
270  // set end position
271  if ((myPositionOverLane + myLength) < 0) {
272  endPosFixed = 0;
273  } else if ((myPositionOverLane + myLength) > getLaneParents().back()->getParentEdge().getNBEdge()->getFinalLength()) {
274  endPosFixed = getLaneParents().back()->getParentEdge().getNBEdge()->getFinalLength();
275  } else {
276  endPosFixed = (myPositionOverLane + myLength);
277  }
278 
279  // Cut shape using as delimitators fixed start position and fixed end position
280  myGeometry.shape = myGeometry.shape.getSubpart(startPosFixed * getLaneParents().front()->getLengthGeometryFactor(), endPosFixed * getLaneParents().back()->getLengthGeometryFactor());
281 
282  // Get calculate lenghts and rotations
284 
285  // Set block icon position
287 
288  } else if (getLaneParents().size() > 1) {
289  // start with the first lane shape
290  myGeometry.multiShape.push_back(getLaneParents().front()->getGeometry().shape);
291 
292  // set start position
293  if (myPositionOverLane < 0) {
294  startPosFixed = 0;
295  } else if (myPositionOverLane > getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength()) {
296  startPosFixed = getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength();
297  } else {
298  startPosFixed = myPositionOverLane;
299  }
300  // Cut shape using as delimitators fixed start position and fixed end position
301  myGeometry.multiShape[0] = myGeometry.multiShape[0].getSubpart(startPosFixed * getLaneParents().front()->getLengthGeometryFactor(), getLaneParents().front()->getParentEdge().getNBEdge()->getFinalLength());
302 
303  // declare last shape
304  PositionVector lastShape = getLaneParents().back()->getGeometry().shape;
305 
306  // set end position
307  if (myEndPositionOverLane < 0) {
308  endPosFixed = 0;
309  } else if (myEndPositionOverLane > getLaneParents().back()->getParentEdge().getNBEdge()->getFinalLength()) {
310  endPosFixed = getLaneParents().back()->getParentEdge().getNBEdge()->getFinalLength();
311  } else {
312  endPosFixed = myEndPositionOverLane;
313  }
314 
315  // Cut shape using as delimitators fixed start position and fixed end position
316  lastShape = lastShape.getSubpart(0, endPosFixed * getLaneParents().back()->getLengthGeometryFactor());
317 
318  // add first shape connection (if exist, in other case leave it empty)
319  myGeometry.multiShape.push_back(PositionVector{getLaneParents().at(0)->getGeometry().shape.back(), getLaneParents().at(1)->getGeometry().shape.front()});
320  for (auto j : getLaneParents().at(0)->getParentEdge().getGNEConnections()) {
321  if (j->getLaneTo() == getLaneParents().at(1)) {
322  myGeometry.multiShape.back() = j->getGeometry().shape;
323  }
324  }
325 
326  // append shapes of intermediate lanes AND connections (if exist)
327  for (int i = 1; i < ((int)getLaneParents().size() - 1); i++) {
328  // add lane shape
329  myGeometry.multiShape.push_back(getLaneParents().at(i)->getGeometry().shape);
330  // add empty shape for connection
331  myGeometry.multiShape.push_back(PositionVector{getLaneParents().at(i)->getGeometry().shape.back(), getLaneParents().at(i + 1)->getGeometry().shape.front()});
332  // set connection shape (if exist). In other case, insert an empty shape
333  for (auto j : getLaneParents().at(i)->getParentEdge().getGNEConnections()) {
334  if (j->getLaneTo() == getLaneParents().at(i + 1)) {
335  myGeometry.multiShape.back() = j->getGeometry().shape;
336  }
337  }
338  }
339 
340  // append last shape
341  myGeometry.multiShape.push_back(lastShape);
342 
343  // calculate multi shape rotation and lengths
345 
346  // calculate unified shape
348 
349  // Set block icon position
350  myBlockIcon.position = myGeometry.multiShape.front().getLineCenter();
351 
352  // check integrity
354  }
355 
356  // Set offset of the block icon
357  myBlockIcon.offset = Position(-0.75, 0);
358 
359  // Set block icon rotation, and using their rotation for draw logo
361 }
362 
363 
364 double
366  return myLength;
367 }
368 
369 
370 void
372  // we assume that E2 is valid
373  myE2valid = true;
374  int i = 0;
375  // iterate over all lanes, and stop if myE2valid is false
376  while (i < ((int)getLaneParents().size() - 1) && myE2valid) {
377  // set myE2valid to false
378  myE2valid = false;
379  // if a connection betwen "from" lane and "to" lane of connection is found, change myE2valid to true again
380  for (auto j : getLaneParents().at(i)->getParentEdge().getGNEConnections()) {
381  if (j->getLaneFrom() == getLaneParents().at(i) && j->getLaneTo() == getLaneParents().at(i + 1)) {
382  myE2valid = true;
383  }
384  }
385  // update iterator
386  i++;
387  }
388 }
389 
390 
391 void
393  // Start drawing adding an gl identificator
394  glPushName(getGlID());
395 
396  // Add a draw matrix
397  glPushMatrix();
398 
399  // Start with the drawing of the area traslating matrix to origin
400  glTranslated(0, 0, getType());
401 
402  // Set color of the base
403  if (drawUsingSelectColor()) {
405  } else {
406  // set color depending if is or isn't valid
407  if (myE2valid) {
409  } else {
411  }
412  }
413 
414  // Obtain exaggeration of the draw
415  const double exaggeration = s.addSize.getExaggeration(s, this);
416 
417  // check if we have to drawn a E2 single lane or a E2 multiLane
418  if (myGeometry.shape.size() > 0) {
419  // Draw the area using shape, shapeRotations, shapeLengths and value of exaggeration
421  } else {
422  // iterate over multishapes
423  for (int i = 0; i < (int)myGeometry.multiShape.size(); i++) {
424  // don't draw shapes over connections if "show connections" is enabled
425  if (!myViewNet->getNetworkViewOptions().showConnections() || (i % 2 == 0)) {
427  }
428  }
429  }
430 
431  // Pop last matrix
432  glPopMatrix();
433 
434  // Check if the distance is enougth to draw details and isn't being drawn for selecting
435  if ((s.drawDetail(s.detailSettings.detectorDetails, exaggeration)) && !s.drawForSelecting) {
436  // draw logo depending if this is an Multilane E2 detector
438  // Push matrix
439  glPushMatrix();
440  // Traslate to center of detector
441  glTranslated(myGeometry.shape.getLineCenter().x(), myGeometry.shape.getLineCenter().y(), getType() + 0.1);
442  // Rotate depending of myBlockIcon.rotation
443  glRotated(myBlockIcon.rotation, 0, 0, -1);
444  //move to logo position
445  glTranslated(-0.75, 0, 0);
446  // draw E2 logo
447  if (drawUsingSelectColor()) {
449  } else {
450  GLHelper::drawText("E2", Position(), .1, 1.5, RGBColor::BLACK);
451  }
452  } else {
453  // Push matrix
454  glPushMatrix();
455  // Traslate to center of detector
456  glTranslated(myBlockIcon.position.x(), myBlockIcon.position.y(), getType() + 0.1);
457  // Rotate depending of myBlockIcon.rotation
458  glRotated(myBlockIcon.rotation, 0, 0, -1);
459  //move to logo position
460  glTranslated(-1.5, 0, 0);
461  // draw E2 logo
462  if (drawUsingSelectColor()) {
464  } else {
465  GLHelper::drawText("E2", Position(), .1, 1.5, RGBColor::BLACK);
466  }
467  //move to logo position
468  glTranslated(1.2, 0, 0);
469  // Rotate depending of myBlockIcon.rotation
470  glRotated(90, 0, 0, 1);
471  if (drawUsingSelectColor()) {
473  } else {
474  GLHelper::drawText("multi", Position(), .1, 0.9, RGBColor::BLACK);
475  }
476  }
477  // pop matrix
478  glPopMatrix();
479  // Show Lock icon depending of the Edit mode
480  myBlockIcon.drawIcon(s, exaggeration);
481  }
482 
483  // Draw name if isn't being drawn for selecting
484  if (!s.drawForSelecting) {
486  }
487  // check if dotted contour has to be drawn
488  if (myViewNet->getDottedAC() == this) {
489  if (myGeometry.shape.size() > 0) {
491  } else {
493  }
494  }
495  // Pop name
496  glPopName();
497 }
498 
499 
500 std::string
502  switch (key) {
503  case SUMO_ATTR_ID:
504  return getAdditionalID();
505  case SUMO_ATTR_LANE:
506  case SUMO_ATTR_LANES:
507  return parseIDs(getLaneParents());
508  case SUMO_ATTR_POSITION:
510  case SUMO_ATTR_ENDPOS:
512  case SUMO_ATTR_FREQUENCY:
513  return time2string(myFreq);
514  case SUMO_ATTR_LENGTH:
515  return toString(myLength);
516  case SUMO_ATTR_NAME:
517  return myAdditionalName;
518  case SUMO_ATTR_FILE:
519  return myFilename;
520  case SUMO_ATTR_VTYPES:
521  return myVehicleTypes;
525  return toString(mySpeedThreshold);
527  return toString(myJamThreshold);
531  return toString(myBlockMovement);
532  case GNE_ATTR_SELECTED:
534  case GNE_ATTR_GENERIC:
535  return getGenericParametersStr();
536  default:
537  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
538  }
539 }
540 
541 
542 void
543 GNEDetectorE2::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
544  if (value == getAttribute(key)) {
545  return; //avoid needless changes, later logic relies on the fact that attributes have changed
546  }
547  switch (key) {
548  case SUMO_ATTR_ID:
549  case SUMO_ATTR_LANE:
550  case SUMO_ATTR_LANES:
551  case SUMO_ATTR_POSITION:
552  case SUMO_ATTR_ENDPOS:
553  case SUMO_ATTR_FREQUENCY:
554  case SUMO_ATTR_LENGTH:
555  case SUMO_ATTR_NAME:
556  case SUMO_ATTR_FILE:
557  case SUMO_ATTR_VTYPES:
563  case GNE_ATTR_SELECTED:
564  case GNE_ATTR_GENERIC:
565  undoList->p_add(new GNEChange_Attribute(this, myViewNet->getNet(), key, value));
566  break;
567  default:
568  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
569  }
570 }
571 
572 
573 bool
574 GNEDetectorE2::isValid(SumoXMLAttr key, const std::string& value) {
575  switch (key) {
576  case SUMO_ATTR_ID:
577  return isValidDetectorID(value);
578  case SUMO_ATTR_LANE:
579  if (value.empty()) {
580  return false;
581  } else {
582  return canParse<std::vector<GNELane*> >(myViewNet->getNet(), value, false);
583  }
584  case SUMO_ATTR_LANES:
585  if (value.empty()) {
586  return false;
587  } else if (canParse<std::vector<GNELane*> >(myViewNet->getNet(), value, false)) {
588  // check if lanes are consecutives
589  return lanesConsecutives(parse<std::vector<GNELane*> >(myViewNet->getNet(), value));
590  } else {
591  return false;
592  }
593  case SUMO_ATTR_POSITION:
594  return canParse<double>(value);
595  case SUMO_ATTR_ENDPOS:
596  return canParse<double>(value);
597  case SUMO_ATTR_FREQUENCY:
598  return (canParse<double>(value) && (parse<double>(value) >= 0));
599  case SUMO_ATTR_LENGTH:
600  return (canParse<double>(value) && (parse<double>(value) >= 0));
601  case SUMO_ATTR_NAME:
603  case SUMO_ATTR_FILE:
605  case SUMO_ATTR_VTYPES:
606  if (value.empty()) {
607  return true;
608  } else {
610  }
612  return canParse<SUMOTime>(value);
614  return (canParse<double>(value) && (parse<double>(value) >= 0));
616  return (canParse<double>(value) && (parse<double>(value) >= 0));
618  return canParse<bool>(value);
620  return canParse<bool>(value);
621  case GNE_ATTR_SELECTED:
622  return canParse<bool>(value);
623  case GNE_ATTR_GENERIC:
624  return isGenericParametersValid(value);
625  default:
626  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
627  }
628 }
629 
630 // ===========================================================================
631 // private
632 // ===========================================================================
633 
634 void
635 GNEDetectorE2::setAttribute(SumoXMLAttr key, const std::string& value) {
636  switch (key) {
637  case SUMO_ATTR_ID:
638  changeAdditionalID(value);
639  break;
640  case SUMO_ATTR_LANE:
641  case SUMO_ATTR_LANES:
642  changeLaneParents(this, value);
644  break;
645  case SUMO_ATTR_POSITION:
646  myPositionOverLane = parse<double>(value);
647  break;
648  case SUMO_ATTR_ENDPOS:
649  myEndPositionOverLane = parse<double>(value);
650  break;
651  case SUMO_ATTR_FREQUENCY:
652  myFreq = parse<SUMOTime>(value);
653  break;
654  case SUMO_ATTR_LENGTH:
655  myLength = parse<double>(value);
656  break;
657  case SUMO_ATTR_NAME:
658  myAdditionalName = value;
659  break;
660  case SUMO_ATTR_FILE:
661  myFilename = value;
662  break;
663  case SUMO_ATTR_VTYPES:
664  myVehicleTypes = value;
665  break;
667  myTimeThreshold = parse<SUMOTime>(value);
668  break;
670  mySpeedThreshold = parse<double>(value);
671  break;
673  myJamThreshold = parse<double>(value);
674  break;
676  myFriendlyPosition = parse<bool>(value);
677  break;
679  myBlockMovement = parse<bool>(value);
680  break;
681  case GNE_ATTR_SELECTED:
682  if (parse<bool>(value)) {
684  } else {
686  }
687  break;
688  case GNE_ATTR_GENERIC:
690  break;
691  default:
692  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
693  }
694 }
695 
696 /****************************************************************************/
GUIGlObject::getType
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.cpp:181
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:988
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:991
GNEAdditional::BlockIcon::position
Position position
position of the block icon
Definition: GNEAdditional.h:351
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:371
SUMO_ATTR_HALTING_SPEED_THRESHOLD
Definition: SUMOXMLDefinitions.h:748
GNEAdditional::setGenericParametersStr
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
Definition: GNEAdditional.cpp:704
GNEAdditional::getAdditionalID
const std::string & getAdditionalID() const
Definition: GNEAdditional.cpp:578
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:147
GNEAdditional::AdditionalGeometry::calculateMultiShapeRotationsAndLengths
void calculateMultiShapeRotationsAndLengths()
calculate multi shape rotations and lenghts
Definition: GNEAdditional.cpp:98
SUMO_ATTR_LENGTH
Definition: SUMOXMLDefinitions.h:394
GNEAdditional::AdditionalGeometry::shape
PositionVector shape
The shape of the additional element.
Definition: GNEAdditional.h:68
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:994
GNEAdditional::BlockIcon::setRotation
void setRotation(GNELane *additionalLane=nullptr)
set Rotation of block Icon (must be called in updateGeometry() function)
Definition: GNEAdditional.cpp:502
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:355
GNEDetectorE2::getAttribute
std::string getAttribute(SumoXMLAttr key) const
Definition: GNEDetectorE2.cpp:501
RGBColor::BLACK
static const RGBColor BLACK
Definition: RGBColor.h:198
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:80
GNEAttributeCarrier::parseIDs
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
GLHelper::drawBoxLines
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:182
GNEAdditional::AdditionalGeometry::multiShapeRotations
std::vector< std::vector< double > > multiShapeRotations
The rotations of the multi-shape parts.
Definition: GNEAdditional.h:80
PositionVector::getSubpart
PositionVector getSubpart(double beginOffset, double endOffset) const
get subpart of a position vector
Definition: PositionVector.cpp:698
GUIVisualizationColorSettings::E2
static const RGBColor E2
color for E2 detectors
Definition: GUIVisualizationSettings.h:214
GNEDetector::getPositionInView
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEDetector.cpp:74
GNEAdditional::AdditionalGeometry::shapeRotations
std::vector< double > shapeRotations
The rotations of the single shape parts.
Definition: GNEAdditional.h:74
GNEAdditional::AdditionalGeometry::calculateMultiShapeUnified
void calculateMultiShapeUnified()
calculate multi shape unified
Definition: GNEAdditional.cpp:65
GNEAttributeCarrier::isGenericParametersValid
static bool isGenericParametersValid(const std::string &value)
check if given string can be parsed to a map/list of generic parameters
Definition: GNEAttributeCarrier.cpp:1354
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
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:153
GNEDetectorE2::fixAdditionalProblem
void fixAdditionalProblem()
fix additional problem
Definition: GNEDetectorE2.cpp:141
GNEViewNet
Definition: GNEViewNet.h:43
SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:379
GLHelper.h
SUMO_ATTR_LANE
Definition: SUMOXMLDefinitions.h:635
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:795
GNEAdditional::changeAdditionalID
void changeAdditionalID(const std::string &newID)
change ID of additional
Definition: GNEAdditional.cpp:604
GNEDetector::myPositionOverLane
double myPositionOverLane
position of detector over Lane
Definition: GNEDetector.h:161
PositionVector
A list of positions.
Definition: PositionVector.h:46
GNEAdditional::unselectAttributeCarrier
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Definition: GNEAdditional.cpp:634
GNEAdditional::AdditionalGeometry::multiShape
std::vector< PositionVector > multiShape
The multi-shape of the additional element (used by certain additionals)
Definition: GNEAdditional.h:71
GNEAdditional::AdditionalMove::secondOriginalPosition
std::string secondOriginalPosition
value for saving second original position over lane before moving
Definition: GNEAdditional.h:335
GNEAdditional::myBlockIcon
BlockIcon myBlockIcon
variable BlockIcon
Definition: GNEAdditional.h:380
GLHelper::setColor
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:616
GNEDetector::myFriendlyPosition
bool myFriendlyPosition
Flag for friendly position.
Definition: GNEDetector.h:173
SUMO_ATTR_FILE
Definition: SUMOXMLDefinitions.h:662
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:194
GUIVisualizationDetailSettings::detectorDetails
static const double detectorDetails
details for detectors
Definition: GUIVisualizationSettings.h:305
GNEAttributeCarrier::TagProperties::getTag
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
Definition: GNEAttributeCarrier.cpp:521
GNEAdditional::myMove
AdditionalMove myMove
variable AdditionalMove
Definition: GNEAdditional.h:371
GNEAdditional::myViewNet
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
Definition: GNEAdditional.h:365
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:159
GNEAttributeCarrier::GNEChange_Attribute
friend class GNEChange_Attribute
declare friend class
Definition: GNEAttributeCarrier.h:57
GNEHierarchicalElementParents::getLaneParents
const std::vector< GNELane * > & getLaneParents() const
get lanes of VSS
Definition: GNEHierarchicalElementParents.cpp:182
GNEUndoList::p_add
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
Definition: GNEUndoList.cpp:132
GNEViewNet::getNet
GNENet * getNet() const
get the net object
Definition: GNEViewNet.cpp:927
GNEAdditional::isAttributeCarrierSelected
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
Definition: GNEAdditional.cpp:650
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:668
GUIVisualizationSettings::addName
GUIVisualizationTextSettings addName
Definition: GUIVisualizationSettings.h:582
GNEDetectorE2::getLength
double getLength() const
get length of E2 Detector
Definition: GNEDetectorE2.cpp:365
GNEAdditional::isValidDetectorID
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
Definition: GNEAdditional.cpp:594
GUIVisualizationSettings::detailSettings
GUIVisualizationDetailSettings detailSettings
detail settings
Definition: GUIVisualizationSettings.h:655
GNEDetector::myVehicleTypes
std::string myVehicleTypes
attribute vehicle types
Definition: GNEDetector.h:170
GNEAttributeCarrier::lanesConsecutives
static bool lanesConsecutives(const std::vector< GNELane * > &lanes)
check if lanes are consecutives
Definition: GNEAttributeCarrier.cpp:1128
GUIVisualizationColorSettings::selectedAdditionalColor
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
Definition: GUIVisualizationSettings.h:148
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:162
GNEAdditional::selectAttributeCarrier
void selectAttributeCarrier(bool changeFlag=true)
Definition: GNEAdditional.cpp:619
GNEViewNet::getNetworkViewOptions
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:411
GNEViewNet.h
GNEAdditionalHandler.h
GNELane::getLengthGeometryFactor
double getLengthGeometryFactor() const
get length geometry factor
Definition: GNELane.cpp:1355
GUIGlObject::getGlID
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.cpp:150
GNEViewNet::getDottedAC
const GNEAttributeCarrier * getDottedAC() const
get AttributeCarrier under cursor
Definition: GNEViewNet.cpp:939
GUIVisualizationSettings::scale
double scale
information about a lane's width (temporary, used for a single view)
Definition: GUIVisualizationSettings.h:623
GNEAdditional::AdditionalGeometry::clearGeometry
void clearGeometry()
reset geometry
Definition: GNEAdditional.cpp:53
GNEDetector::getLane
GNELane * getLane() const
get lane
Definition: GNEDetector.cpp:68
GNEDetector
Definition: GNEDetector.h:34
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
Position::x
double x() const
Returns the x-position.
Definition: Position.h:57
GNEEdge.h
GNEAttributeCarrier::myTagProperty
const TagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
Definition: GNEAttributeCarrier.h:792
time2string
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:65
GNEViewNet::getUndoList
GNEUndoList * getUndoList() const
get the undoList object
Definition: GNEViewNet.cpp:933
GNEAdditional::myAdditionalName
std::string myAdditionalName
name of additional
Definition: GNEAdditional.h:374
RGBColor::RED
static const RGBColor RED
named colors
Definition: RGBColor.h:190
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:156
GNEChange_Connection
Definition: GNEChange_Connection.h:45
GNEViewNetHelper::NetworkViewOptions::showConnections
bool showConnections() const
check if select show connections checkbox is enabled
Definition: GNEViewNetHelper.cpp:1637
GNEDetectorE2.h
GNEAdditional::myBlockMovement
bool myBlockMovement
boolean to check if additional element is blocked (i.e. cannot be moved with mouse)
Definition: GNEAdditional.h:377
GNEAdditional::BlockIcon::rotation
double rotation
The rotation of the block icon.
Definition: GNEAdditional.h:357
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:574
SUMO_ATTR_FRIENDLY_POS
Definition: SUMOXMLDefinitions.h:762
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:645
SUMO_ATTR_FREQUENCY
Definition: SUMOXMLDefinitions.h:660
SUMO_ATTR_POSITION
Definition: SUMOXMLDefinitions.h:658
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:543
SUMO_TAG_E2DETECTOR_MULTILANE
an e2 detector over multiple lanes (used by Netedit)
Definition: SUMOXMLDefinitions.h:70
GUIVisualizationSettings::colorSettings
GUIVisualizationColorSettings colorSettings
color settings
Definition: GUIVisualizationSettings.h:649
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:636
GUIVisualizationColorSettings::selectionColor
RGBColor selectionColor
basic selection color
Definition: GUIVisualizationSettings.h:130
GLIncludes.h
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
GNE_ATTR_GENERIC
generic attribute
Definition: SUMOXMLDefinitions.h:986
GNEAdditional::BlockIcon::drawIcon
void drawIcon(const GUIVisualizationSettings &s, const double exaggeration, const double size=0.5) const
draw lock icon
Definition: GNEAdditional.cpp:518
Position::y
double y() const
Returns the y-position.
Definition: Position.h:62
SUMO_ATTR_HALTING_TIME_THRESHOLD
Definition: SUMOXMLDefinitions.h:747
SUMO_ATTR_VTYPES
Definition: SUMOXMLDefinitions.h:630
InvalidArgument
Definition: UtilExceptions.h:57
GNEAdditional::getGenericParametersStr
std::string getGenericParametersStr() const
return generic parameters in string format
Definition: GNEAdditional.cpp:678
GNE_ATTR_BLOCK_MOVEMENT
block movement of a graphic element
Definition: SUMOXMLDefinitions.h:978
GNEDetectorE2::myEndPositionOverLane
double myEndPositionOverLane
end position over lane (only for Multilane E2 detectors)
Definition: GNEDetectorE2.h:150
GNEDetector::myFilename
std::string myFilename
The path to the output file.
Definition: GNEDetector.h:167
GNEAdditional::drawUsingSelectColor
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
Definition: GNEAdditional.cpp:656
GNEDetectorE2::getAdditionalProblem
std::string getAdditionalProblem() const
return a string with the current additional problem
Definition: GNEDetectorE2.cpp:97
GNEHierarchicalElementParents::changeLaneParents
void changeLaneParents(GNEShape *elementChild, const std::string &newLaneIDs)
change edge parents of a shape
Definition: GNEHierarchicalElementParents.cpp:460
GNEAdditional::myGeometry
AdditionalGeometry myGeometry
geometry to be precomputed in updateGeometry(...)
Definition: GNEAdditional.h:368
GNEDetector::myFreq
SUMOTime myFreq
The aggregation period the values the detector collects shall be summed up.
Definition: GNEDetector.h:164
SUMO_ATTR_JAM_DIST_THRESHOLD
Definition: SUMOXMLDefinitions.h:749
GUIVisualizationSettings::addSize
GUIVisualizationSizeSettings addSize
Definition: GUIVisualizationSettings.h:580
GNEDetectorE2::drawGL
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEDetectorE2.cpp:392
Position::add
void add(const Position &pos)
Adds the given position to this one.
Definition: Position.h:127
GNE_ATTR_SELECTED
element is selected
Definition: SUMOXMLDefinitions.h:968
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:1621
GNEAdditional::AdditionalGeometry::shapeLengths
std::vector< double > shapeLengths
The lengths of the single shape parts.
Definition: GNEAdditional.h:77
GNEAttributeCarrier::getTagStr
const std::string & getTagStr() const
get tag assigned to this object in string format
Definition: GNEAttributeCarrier.cpp:1165
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:1017
SUMO_ATTR_NAME
Definition: SUMOXMLDefinitions.h:381
GNEUndoList
Definition: GNEUndoList.h:49
GNEAdditional::AdditionalGeometry::multiShapeUnified
PositionVector multiShapeUnified
multi shape unified
Definition: GNEAdditional.h:86
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
GNEAdditional::AdditionalGeometry::multiShapeLengths
std::vector< std::vector< double > > multiShapeLengths
The lengths of the multi-shape shape parts.
Definition: GNEAdditional.h:83
PositionVector::getLineCenter
Position getLineCenter() const
get line center
Definition: PositionVector.cpp:466
GNEDetectorE2::~GNEDetectorE2
~GNEDetectorE2()
Destructor.
Definition: GNEDetectorE2.cpp:66
NBEdge::Connection
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:184
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:73
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:373
GNEAdditional::AdditionalMove::originalViewPosition
Position originalViewPosition
value for saving first original position over lane before moving
Definition: GNEAdditional.h:329
SUMO_TAG_E2DETECTOR
an e2 detector
Definition: SUMOXMLDefinitions.h:68
GNEAdditional::AdditionalMove::firstOriginalLanePosition
std::string firstOriginalLanePosition
value for saving first original position over lane before moving
Definition: GNEAdditional.h:332
GNELane
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
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:977
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:78
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:354
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:41
GNEChange_Connection.h
GNEAdditional::AdditionalGeometry::calculateShapeRotationsAndLengths
void calculateShapeRotationsAndLengths()
calculate shape rotations and lenghts
Definition: GNEAdditional.cpp:74
GUIVisualizationSettings::drawForSelecting
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
Definition: GUIVisualizationSettings.h:635
GNEConnection.h