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),
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 /****************************************************************************/
const TagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:184
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.
long long int SUMOTime
Definition: SUMOTime.h:35
double scale
information about a lane&#39;s width (temporary, used for a single view)
PositionVector multiShapeUnified
multi shape unified
Definition: GNEAdditional.h:86
void calculateMultiShapeRotationsAndLengths()
calculate multi shape rotations and lenghts
static bool checkAndFixDetectorPosition(double &pos, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
bool showConnections() const
check if select show connections checkbox is enabled
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name) ...
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
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&#39;t allowed) ...
GUIVisualizationTextSettings addName
std::vector< double > shapeRotations
The rotations of the single shape parts.
Definition: GNEAdditional.h:74
a E2 detector
void add(const Position &pos)
Adds the given position to this one.
Definition: Position.h:127
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(...)
const std::string & getAdditionalID() const
std::string secondOriginalPosition
value for saving second original position over lane before moving
an e2 detector over multiple lanes (used by Netedit)
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.
Stores the information about how to visualize structures.
Position offset
The offSet of the block icon.
double y() const
Returns the y-position.
Definition: Position.h:62
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:65
double x() const
Returns the x-position.
Definition: Position.h:57
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
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Position position
position of the block icon
BlockIcon myBlockIcon
variable BlockIcon
void clearGeometry()
reset geometry
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes ...
Position originalViewPosition
value for saving first original position over lane before moving
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
double myEndPositionOverLane
end position over lane (only for Multilane E2 detectors)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
void updateGeometry()
update pre-computed geometry information
static const RGBColor BLACK
Definition: RGBColor.h:198
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
void changeAdditionalID(const std::string &newID)
change ID of additional
generic attribute
Position getLineCenter() const
get line center
double rotation
The rotation of the block icon.
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
~GNEDetectorE2()
Destructor.
std::vector< std::vector< double > > multiShapeRotations
The rotations of the multi-shape parts.
Definition: GNEAdditional.h:80
SUMOTime myTimeThreshold
The time-based threshold that describes how much time has to pass until a vehicle is recognized as ha...
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
AdditionalMove myMove
variable AdditionalMove
double mySpeedThreshold
The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting...
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
GUIVisualizationSizeSettings addSize
GNEUndoList * getUndoList() const
get the undoList object
Definition: GNEViewNet.cpp:933
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:616
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
Definition: GNEUndoList.cpp:80
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
PositionVector shape
The shape of the additional element.
Definition: GNEAdditional.h:68
RGBColor selectionColor
basic selection color
static bool lanesConsecutives(const std::vector< GNELane *> &lanes)
check if lanes are consecutives
Position getPositionInView() const
Returns position of additional in view.
Definition: GNEDetector.cpp:74
A list of positions.
std::string myAdditionalName
name of additional
static bool isGenericParametersValid(const std::string &value)
check if given string can be parsed to a map/list of generic parameters
bool isAdditionalValid() const
check if current additional is valid to be writed into XML (by default true, can be reimplemented in ...
void checkE2MultilaneIntegrity()
check if E2 is valid (all of their lanes are connected, it must called after every operation which in...
friend class GNEChange_Attribute
declare friend class
void selectAttributeCarrier(bool changeFlag=true)
const std::vector< GNELane * > & getLaneParents() const
get lanes of VSS
block movement of a graphic element
std::string myVehicleTypes
attribute vehicle types
Definition: GNEDetector.h:170
std::vector< std::vector< double > > multiShapeLengths
The lengths of the multi-shape shape parts.
Definition: GNEAdditional.h:83
bool myE2valid
flag to check if E2 multilane is valid or invalid
double getLengthGeometryFactor() const
get length geometry factor
Definition: GNELane.cpp:1355
static const double detectorDetails
details for detectors
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
double myLength
E2 detector length.
PositionVector getSubpart(double beginOffset, double endOffset) const
get subpart of a position vector
std::vector< PositionVector > multiShape
The multi-shape of the additional element (used by certain additionals)
Definition: GNEAdditional.h:71
void fixAdditionalProblem()
fix additional problem
bool myFriendlyPosition
Flag for friendly position.
Definition: GNEDetector.h:173
std::string myFilename
The path to the output file.
Definition: GNEDetector.h:167
bool myBlockMovement
boolean to check if additional element is blocked (i.e. cannot be moved with mouse) ...
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
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:411
void calculateShapeRotationsAndLengths()
calculate shape rotations and lenghts
std::string getAttribute(SumoXMLAttr key) const
std::vector< double > shapeLengths
The lengths of the single shape parts.
Definition: GNEAdditional.h:77
double getLength() const
get length of E2 Detector
GUIVisualizationDetailSettings detailSettings
detail settings
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
SUMOTime myFreq
The aggregation period the values the detector collects shall be summed up.
Definition: GNEDetector.h:164
void changeLaneParents(GNEShape *elementChild, const std::string &newLaneIDs)
change edge parents of a shape
static const RGBColor RED
named colors
Definition: RGBColor.h:190
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
const GNEAttributeCarrier * getDottedAC() const
get AttributeCarrier under cursor
Definition: GNEViewNet.cpp:939
AdditionalGeometry myGeometry
geometry to be precomputed in updateGeometry(...)
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
const std::string & getTagStr() const
get tag assigned to this object in string format
element is selected
std::string getGenericParametersStr() const
return generic parameters in string format
GNENet * getNet() const
get the net object
Definition: GNEViewNet.cpp:927
GUIGlID getGlID() const
Returns the numerical id of the object.
GNELane * getLane() const
get lane
Definition: GNEDetector.cpp:68
GUIVisualizationColorSettings colorSettings
color settings
double myJamThreshold
The minimum distance to the next standing vehicle in order to make this vehicle count as a participan...
std::string firstOriginalLanePosition
value for saving first original position over lane before moving
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
std::string getAdditionalProblem() const
return a string with the current additional problem
void drawIcon(const GUIVisualizationSettings &s, const double exaggeration, const double size=0.5) const
draw lock icon
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name) ...
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc.)
static const RGBColor E2
color for E2 detectors
void setRotation(GNELane *additionalLane=nullptr)
set Rotation of block Icon (must be called in updateGeometry() function)
double myPositionOverLane
position of detector over Lane
Definition: GNEDetector.h:161
void calculateMultiShapeUnified()
calculate multi shape unified