Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNELaneAreaDetector.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18//
19/****************************************************************************/
20
21#include <netedit/GNENet.h>
22#include <netedit/GNESegment.h>
23#include <netedit/GNEUndoList.h>
24#include <netedit/GNEViewNet.h>
34
35#include "GNELaneAreaDetector.h"
37
38
39// ===========================================================================
40// member method definitions
41// ===========================================================================
42
44 GNEDetector("", net, GLO_E2DETECTOR, tag, GUIIconSubSys::getIcon(GUIIcon::E2),
45 0, 0, {}, "", {}, {}, "", "", false, Parameterised::Map()) {
46 // reset default values
47 resetDefaultValues();
48}
49
50
51GNELaneAreaDetector::GNELaneAreaDetector(const std::string& id, GNELane* lane, GNENet* net, double pos, double length, const SUMOTime freq,
52 const std::string& trafficLight, const std::string& filename, const std::vector<std::string>& vehicleTypes,
53 const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name, const SUMOTime timeThreshold,
54 double speedThreshold, const double jamThreshold, const bool friendlyPos, const bool show, const Parameterised::Map& parameters) :
56 pos, freq, {
57 lane
58}, filename, vehicleTypes, nextEdges, detectPersons, name, friendlyPos, parameters),
59myEndPositionOverLane(pos + length),
60myTimeThreshold(timeThreshold),
61mySpeedThreshold(speedThreshold),
62myJamThreshold(jamThreshold),
63myTrafficLight(trafficLight),
64myShow(show) {
65}
66
67
68GNELaneAreaDetector::GNELaneAreaDetector(const std::string& id, std::vector<GNELane*> lanes, GNENet* net, double pos, double endPos, const SUMOTime freq,
69 const std::string& trafficLight, const std::string& filename, const std::vector<std::string>& vehicleTypes,
70 const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name, const SUMOTime timeThreshold,
71 double speedThreshold, const double jamThreshold, const bool friendlyPos, const bool show, const Parameterised::Map& parameters) :
73 pos, freq, lanes, filename, vehicleTypes, nextEdges, detectPersons, name, friendlyPos, parameters),
74 myEndPositionOverLane(endPos),
75 myTimeThreshold(timeThreshold),
76 mySpeedThreshold(speedThreshold),
77 myJamThreshold(jamThreshold),
78 myTrafficLight(trafficLight),
79 myShow(show) {
80}
81
82
85
86
87void
90 device.writeAttr(SUMO_ATTR_ID, getID());
91 // continue depending of E2 type
93 device.writeAttr(SUMO_ATTR_LANE, getParentLanes().front()->getID());
96 } else {
100 }
101 // write common detector parameters
102 writeDetectorValues(device);
103 // write specific attributes
104 if (myTrafficLight.size() > 0) {
106 }
109 }
112 }
115 }
118 }
119 // write parameters (Always after children to avoid problems with additionals.xsd)
120 writeParams(device);
121 device.closeTag();
122}
123
124
125bool
127 if (getParentLanes().size() == 1) {
128 // with friendly position enabled position are "always fixed"
129 if (myFriendlyPosition) {
130 return true;
131 } else {
132 return (myPositionOverLane >= 0) && (myEndPositionOverLane <= getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength());
133 }
134 } else {
135 // first check if there is connection between all consecutive lanes
137 // with friendly position enabled position are "always fixed"
138 if (myFriendlyPosition) {
139 return true;
140 } else {
141 return (myPositionOverLane >= 0) &&
142 (myEndPositionOverLane >= 0) &&
143 (myPositionOverLane <= getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) &&
144 (myEndPositionOverLane <= getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
145 }
146 } else {
147 return false;
148 }
149 }
150}
151
152
153std::string
155 // declare variable for error position
156 std::string errorFirstLanePosition, separator, errorLastLanePosition;
157 if (getParentLanes().size() == 1) {
158 // check positions over lane
159 if (myPositionOverLane < 0) {
160 errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0");
161 }
162 if (myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
163 errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + TL(" > lanes's length"));
164 }
165 } else {
166 // abort if lanes aren't consecutives
168 return TL("lanes aren't consecutives");
169 }
170 // abort if lanes aren't connected
172 return TL("lanes aren't connected");
173 }
174 // check positions over first lane
175 if (myPositionOverLane < 0) {
176 errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + " < 0");
177 }
178 if (myPositionOverLane > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
179 errorFirstLanePosition = (toString(SUMO_ATTR_POSITION) + TL(" > lanes's length"));
180 }
181 // check positions over last lane
182 if (myEndPositionOverLane < 0) {
183 errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + " < 0");
184 }
185 if (myEndPositionOverLane > getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength()) {
186 errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + TL(" > lanes's length"));
187 }
188 }
189 // check separator
190 if ((errorFirstLanePosition.size() > 0) && (errorLastLanePosition.size() > 0)) {
191 separator = TL(" and ");
192 }
193 // return error message
194 return errorFirstLanePosition + separator + errorLastLanePosition;
195}
196
197
198void
200 if (getParentLanes().size() == 1) {
201 // obtain position and length
202 double newPositionOverLane = myPositionOverLane;
203 double newLength = (myEndPositionOverLane - myPositionOverLane);
204 // fix pos and length using fixE2DetectorPosition
205 GNEAdditionalHandler::fixLanePosition(newPositionOverLane, newLength, getParentLanes().at(0)->getParentEdge()->getNBEdge()->getFinalLength());
206 // set new position and length
209 } else {
211 // build connections between all consecutive lanes
212 bool foundConnection = true;
213 int i = 0;
214 // iterate over all lanes, and stop if myE2valid is false
215 while (i < ((int)getParentLanes().size() - 1)) {
216 // change foundConnection to false
217 foundConnection = false;
218 // if a connection between "from" lane and "to" lane of connection is found, change myE2valid to true again
219 for (const auto& connection : getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
220 if ((connection->getLaneFrom() == getParentLanes().at(i)) && (connection->getLaneTo() == getParentLanes().at(i + 1))) {
221 foundConnection = true;
222 }
223 }
224 // if connection wasn't found
225 if (!foundConnection) {
226 // create new connection manually
227 NBEdge::Connection newCon(getParentLanes().at(i)->getIndex(), getParentLanes().at(i + 1)->getParentEdge()->getNBEdge(), getParentLanes().at(i + 1)->getIndex());
228 // allow to undo creation of new lane
229 myNet->getViewNet()->getUndoList()->add(new GNEChange_Connection(getParentLanes().at(i)->getParentEdge(), newCon, false, true), true);
230 }
231 // update lane iterator
232 i++;
233 }
234 } else {
235 // declare new positions
236 double newPositionOverLane = myPositionOverLane;
237 double newEndPositionOverLane = myEndPositionOverLane;
238 // fix pos and length checkAndFixDetectorPosition
240 newPositionOverLane, getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(),
241 newEndPositionOverLane, getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
242 // set new position and endPosition
244 setAttribute(SUMO_ATTR_ENDPOS, toString(newEndPositionOverLane), myNet->getViewNet()->getUndoList());
245 }
246 }
247}
248
249
250void
252 // check E2 detector
254 // compute path
256 } else {
257 // Cut shape using as delimitators fixed start position and fixed end position
259 }
260}
261
262
263void
265 // check drawing conditions
269 // Obtain exaggeration of the draw
270 const double E2Exaggeration = getExaggeration(s);
271 // get detail level
272 const auto d = s.getDetailLevel(E2Exaggeration);
273 // draw geometry only if we'rent in drawForObjectUnderCursor mode
275 // draw E2
276 drawE2(s, d, E2Exaggeration);
277 // draw lock icon
279 // Draw additional ID
281 // draw additional name
283 // draw dotted contour
285 }
286 // calculate contour and draw dotted geometry
288 E2Exaggeration, true, true, 0, nullptr, getParentLanes().front()->getParentEdge());
289 }
290}
291
292
293void
298
299
300void
301GNELaneAreaDetector::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
302 // check if E2 can be drawn
305 const bool movingGeometryPoints = drawMovingGeometryPoints(false);
306 // Obtain exaggeration of the draw
307 const double E2Exaggeration = getExaggeration(s);
308 // get detail level
309 const auto d = s.getDetailLevel(E2Exaggeration);
310 // calculate startPos
311 const double geometryDepartPos = getAttributeDouble(SUMO_ATTR_POSITION);
312 // get endPos
313 const double geometryEndPos = getAttributeDouble(SUMO_ATTR_ENDPOS);
314 // declare path geometry
315 GUIGeometry E2Geometry;
316 // update pathGeometry depending of first and last segment
317 if (segment->isFirstSegment() && segment->isLastSegment()) {
318 E2Geometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
319 geometryDepartPos,
321 geometryEndPos,
323 } else if (segment->isFirstSegment()) {
324 E2Geometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
325 geometryDepartPos,
327 -1,
329 } else if (segment->isLastSegment()) {
330 E2Geometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
331 -1,
333 geometryEndPos,
335 } else {
336 E2Geometry = segment->getLane()->getLaneGeometry();
337 }
338 // draw geometry only if we'rent in drawForObjectUnderCursor mode
340 // draw E2 partial
341 drawE2PartialLane(s, d, segment, offsetFront, E2Geometry, E2Exaggeration, movingGeometryPoints);
342 // draw additional ID
343 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
344 // draw dotted contour
345 if (movingGeometryPoints) {
346 // get mouse position
347 const Position mousePosition = myNet->getViewNet()->getPositionInformation();
348 // get snap radius
350 if (segment->getFromContour() && E2Geometry.getShape().front().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
352 } else if (segment->getToContour() && E2Geometry.getShape().back().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
354 }
355 } else {
356 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
357 }
358 }
359 // calculate contour and draw dotted geometry
360 segment->getContour()->calculateContourExtrudedShape(s, d, this, E2Geometry.getShape(), getType(), s.detectorSettings.E2Width,
361 E2Exaggeration, segment->isFirstSegment(), segment->isLastSegment(), 0, segment, segment->getLane()->getParentEdge());
362 // check if create from-to contours
363 if (segment->getFromContour()) {
364 segment->getFromContour()->calculateContourCircleShape(s, d, this, E2Geometry.getShape().front(),
366 } else if (segment->getToContour()) {
367 segment->getToContour()->calculateContourCircleShape(s, d, this, E2Geometry.getShape().back(),
369 }
370 // check if add this path element to redraw buffer
373 }
374 }
375}
376
377
378void
379GNELaneAreaDetector::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
380 // check if E2 can be drawn
383 // Obtain exaggeration of the draw
384 const double E2Exaggeration = getExaggeration(s);
385 // get detail level
386 const auto d = s.getDetailLevel(E2Exaggeration);
387 // get flag for show only contour
389 // check if connection to next lane exist
390 const bool connectionExist = segment->getPreviousLane()->getLane2laneConnections().exist(segment->getNextLane());
391 // get geometry
392 const GUIGeometry& E2Geometry = connectionExist ? segment->getPreviousLane()->getLane2laneConnections().getLane2laneGeometry(segment->getNextLane()) :
393 GUIGeometry({segment->getPreviousLane()->getLaneShape().back(), segment->getNextLane()->getLaneShape().front()});
394 // draw geometry only if we'rent in drawForObjectUnderCursor mode
396 // draw E2 partial
397 drawE2PartialJunction(s, d, onlyContour, offsetFront, E2Geometry, E2Exaggeration);
398 // draw dotted contour
399 if (!drawMovingGeometryPoints(false)) {
400 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
401 }
402 }
403 // calculate contour
404 segment->getContour()->calculateContourExtrudedShape(s, d, this, E2Geometry.getShape(), getType(), s.detectorSettings.E2Width, E2Exaggeration,
405 false, false, 0, segment, segment->getJunction());
406 // check if add this path element to redraw buffer
409 }
410 }
411}
412
413
414std::string
439
440
441double
443 switch (key) {
444 case SUMO_ATTR_LENGTH:
446 case SUMO_ATTR_ENDPOS:
448 default:
449 return getDetectorAttributeDouble(key);
450 }
451}
452
453
454void
455GNELaneAreaDetector::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
456 switch (key) {
457 case SUMO_ATTR_LANES:
458 case SUMO_ATTR_ENDPOS:
459 case SUMO_ATTR_TLID:
460 case SUMO_ATTR_LENGTH:
465 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
466 break;
467 default:
468 setDetectorAttribute(key, value, undoList);
469 break;
470 }
471}
472
473
474bool
475GNELaneAreaDetector::isValid(SumoXMLAttr key, const std::string& value) {
476 switch (key) {
477 case SUMO_ATTR_LANES:
478 if (value.empty()) {
479 return false;
480 } else if (canParse<std::vector<GNELane*> >(myNet, value, false)) {
481 // check if lanes are consecutives
482 return lanesConsecutives(parse<std::vector<GNELane*> >(myNet, value));
483 } else {
484 return false;
485 }
486 case SUMO_ATTR_ENDPOS:
487 return canParse<double>(value);
488 case SUMO_ATTR_TLID:
489 // temporal
491 case SUMO_ATTR_LENGTH:
492 return (canParse<double>(value) && (parse<double>(value) >= 0));
494 return canParse<SUMOTime>(value);
496 return (canParse<double>(value) && (parse<double>(value) >= 0));
498 return (canParse<double>(value) && (parse<double>(value) >= 0));
500 return canParse<bool>(value);
501 default:
502 return isDetectorValid(key, value);
503 }
504}
505
506// ===========================================================================
507// private
508// ===========================================================================
509
510void
512 const double exaggeration) const {
513 // declare color
514 RGBColor E2Color, textColor;
515 // set color
516 if (drawUsingSelectColor()) {
518 textColor = E2Color.changedBrightness(-32);
519 } else if (areLaneConsecutives(getParentLanes())) {
520 E2Color = s.detectorSettings.E2Color;
521 textColor = RGBColor::BLACK;
522 }
523 // draw parent and child lines
525 // push layer matrix
527 // translate to front
529 // set color
530 GLHelper::setColor(E2Color);
531 // draw geometry
533 // draw arrow
534 if (myAdditionalGeometry.getShape().size() > 1) {
535 glTranslated(0, 0, 0.1);
537 }
538 // draw E2 Logo
539 drawE2DetectorLogo(s, d, exaggeration, "E2", textColor);
540 // draw geometry points
543 // pop layer matrix
545}
546
547
548void
550 const GNESegment* segment, const double offsetFront,
551 const GUIGeometry& geometry, const double exaggeration, const bool movingGeometryPoints) const {
552 // obtain color
554 // push layer matrix
556 // Start with the drawing of the area traslating matrix to origin
557 glTranslated(0, 0, getType() + offsetFront);
558 // Set color
559 GLHelper::setColor(E2Color);
560 // draw geometry
561 GUIGeometry::drawGeometry(d, geometry, s.detectorSettings.E2Width * exaggeration);
562 // check if draw moving geometry points
563 if (movingGeometryPoints) {
564 if (segment->isFirstSegment() && segment->isLastSegment()) {
565 drawLeftGeometryPoint(s, d, geometry.getShape().front(), geometry.getShapeRotations().front(), E2Color, true);
566 drawRightGeometryPoint(s, d, geometry.getShape().back(), geometry.getShapeRotations().back(), E2Color, true);
567 } else if (segment->isFirstSegment()) {
568 drawLeftGeometryPoint(s, d, geometry.getShape().front(), geometry.getShapeRotations().front(), E2Color, true);
569 } else if (segment->isLastSegment()) {
570 drawRightGeometryPoint(s, d, geometry.getShape().back(), geometry.getShapeRotations().back(), E2Color, true);
571 // draw arrow
572 if (geometry.getShape().size() > 1) {
573 glTranslated(0, 0, 0.1);
574 GLHelper::drawTriangleAtEnd(geometry.getShape()[-2], geometry.getShape()[-1], (double) 0.5, (double) 1, 0.5);
575 }
576 }
577 }
578 // Pop layer matrix
580 // check if this is the label segment
581 if (segment->isLabelSegment()) {
582 // calculate middle point
583 const double middlePoint = (geometry.getShape().length2D() * 0.5);
584 // calculate position
585 const Position pos = geometry.getShape().positionAtOffset2D(middlePoint);
586 // calculate rotation
587 const double rot = s.getTextAngle((geometry.getShape().rotationDegreeAtOffset(middlePoint) * -1) + 90);
588 // Start pushing matrix
590 // Traslate to position
591 glTranslated(pos.x(), pos.y(), getType() + offsetFront + 0.1);
592 // rotate
593 glRotated(rot, 0, 0, 1);
594 // move
595 glTranslated(-1, 0, 0);
596 // scale text
597 glScaled(exaggeration, exaggeration, 1);
598 // draw E1 logo
599 GLHelper::drawText("E2 Multilane", Position(), .1, 1.5, RGBColor::BLACK);
600 // pop matrix
602 }
603
604}
605
606
607void
609 const bool onlyContour, const double offsetFront, const GUIGeometry& geometry,
610 const double exaggeration) const {
611 const bool invalid = geometry.getShape().length() == 2;
612 const double width = s.detectorSettings.E2Width * exaggeration * (invalid ? 0.5 : 1);
613 // Add a draw matrix
615 // Start with the drawing of the area traslating matrix to origin
616 glTranslated(0, 0, getType() + offsetFront);
617 // Set color of the base
618 if (drawUsingSelectColor()) {
620 } else if (invalid) {
622 } else {
624 }
625 // check if draw only contour
626 if (onlyContour) {
627 GUIGeometry::drawContourGeometry(geometry, width);
628 } else {
629 GUIGeometry::drawGeometry(d, geometry, width);
630 }
631 // Pop last matrix
633}
634
635
636void
637GNELaneAreaDetector::setAttribute(SumoXMLAttr key, const std::string& value) {
638 switch (key) {
639 case SUMO_ATTR_LANES:
641 break;
642 case SUMO_ATTR_ENDPOS:
643 myEndPositionOverLane = parse<double>(value);
644 // update geometry (except for template)
645 if (getParentLanes().size() > 0) {
647 }
648 break;
649 case SUMO_ATTR_TLID:
650 myTrafficLight = value;
651 break;
652 case SUMO_ATTR_LENGTH:
653 myEndPositionOverLane = (myPositionOverLane + parse<double>(value));
654 // update geometry (except for template)
655 if (getParentLanes().size() > 0) {
657 }
658 break;
660 myTimeThreshold = TIME2STEPS(parse<double>(value));
661 break;
663 mySpeedThreshold = parse<double>(value);
664 break;
666 myJamThreshold = parse<double>(value);
667 break;
669 myShow = parse<bool>(value);
670 break;
671 default:
672 setDetectorAttribute(key, value);
673 break;
674 }
675}
676
677
678void
682 // change only start position
683 myPositionOverLane = moveResult.newFirstPos;
686 // change only end position
688 } else {
690 const auto difference = moveResult.newFirstPos - myPositionOverLane;
691 // change start position
692 myPositionOverLane = moveResult.newFirstPos;
693 myEndPositionOverLane += difference;
695 const auto difference = moveResult.newFirstPos - myEndPositionOverLane;
696 // change end position
697 myPositionOverLane += difference;
699 }
700 // end position over lane
701 if (myPositionOverLane < 0) {
703 } else if (myPositionOverLane > getParentLanes().front()->getLaneShapeLength()) {
704 myPositionOverLane = getParentLanes().front()->getLaneShapeLength();
705 }
706 // adjust position over lane
707 if (myEndPositionOverLane < 0) {
709 } else if (myEndPositionOverLane > getParentLanes().back()->getLaneShapeLength()) {
710 myEndPositionOverLane = getParentLanes().back()->getLaneShapeLength();
711 }
712 }
713 // update geometry
715}
716
717
718void
720 // begin change attribute
721 undoList->begin(this, "position of " + getTagStr());
722 // set attributes depending of operation type
725 // set only start position
726 setAttribute(SUMO_ATTR_POSITION, toString(moveResult.newFirstPos), undoList);
729 // set only end position
730 setAttribute(SUMO_ATTR_ENDPOS, toString(moveResult.newFirstPos), undoList);
731 } else {
732 double startPos = myPositionOverLane;
733 double endPos = myEndPositionOverLane;
734 // set positions
736 const auto difference = moveResult.newFirstPos - myPositionOverLane;
737 // change start position
738 startPos = moveResult.newFirstPos;
739 endPos += difference;
741 const auto difference = moveResult.newFirstPos - myEndPositionOverLane;
742 // change end position
743 startPos += difference;
744 endPos = moveResult.newFirstPos;
745 }
746 // end position over lane
747 if (startPos < 0) {
748 startPos = 0;
749 } else if (startPos > getParentLanes().front()->getLaneShapeLength()) {
750 startPos = getParentLanes().front()->getLaneShapeLength();
751 }
752 // adjust position over lane
753 if (endPos < 0) {
754 endPos = 0;
755 } else if (endPos > getParentLanes().back()->getLaneShapeLength()) {
756 endPos = getParentLanes().back()->getLaneShapeLength();
757 }
758 // set only end position
759 setAttribute(SUMO_ATTR_POSITION, toString(startPos), undoList);
760 setAttribute(SUMO_ATTR_ENDPOS, toString(endPos), undoList);
761 }
762 // end change attribute
763 undoList->end();
764}
765
766
767double
769 // get lane final and shape length
770 const double laneLength = getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
771 // get startPosition
772 double fixedPos = myPositionOverLane;
773 // adjust fixedPos
774 if (fixedPos < 0) {
775 fixedPos += laneLength;
776 }
777 fixedPos *= getParentLanes().front()->getLengthGeometryFactor();
778 // return depending of fixedPos
779 if (fixedPos < 0) {
780 return 0;
781 } else if (fixedPos > (getParentLanes().front()->getLaneShapeLength() - POSITION_EPS)) {
782 return (getParentLanes().front()->getLaneShapeLength() - POSITION_EPS);
783 } else {
784 return fixedPos;
785 }
786}
787
788
789double
791 // get lane final and shape length
792 const double laneLength = getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
793 // get endPosition
794 double fixedPos = myEndPositionOverLane;
795 // adjust fixedPos
796 if (fixedPos < 0) {
797 fixedPos += laneLength;
798 }
799 fixedPos *= getParentLanes().back()->getLengthGeometryFactor();
800 // return depending of fixedPos
801 if (fixedPos < POSITION_EPS) {
802 return POSITION_EPS;
803 } else if (fixedPos > getParentLanes().back()->getLaneShapeLength()) {
804 return getParentLanes().back()->getLaneShapeLength();
805 } else {
806 return fixedPos;
807 }
808}
809
810/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
@ GLO_E2DETECTOR
a E2 detector
GUIViewObjectsHandler gViewObjectsHandler
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define TL(string)
Definition MsgHandler.h:315
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:69
#define TIME2STEPS(x)
Definition SUMOTime.h:57
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_MULTI_LANE_AREA_DETECTOR
an e2 detector over multiple lanes (placed here due create Additional Frame)
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_LANE
@ SUMO_ATTR_JAM_DIST_THRESHOLD
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_HALTING_TIME_THRESHOLD
@ SUMO_ATTR_LANES
@ SUMO_ATTR_HALTING_SPEED_THRESHOLD
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_SHOW_DETECTOR
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ID
@ SUMO_ATTR_POSITION
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void drawTriangleAtEnd(const Position &p1, const Position &p2, double tLength, double tWidth, const double extraOffset=0)
Draws a triangle at the end of the given line.
Definition GLHelper.cpp:624
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
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, const int align=0, double width=-1)
Definition GLHelper.cpp:751
static void fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength)
fix the given positions over two lanes
static void fixLanePosition(double &pos, double &length, const double laneLength)
fix given position over lane
static bool areLaneConnected(const std::vector< GNELane * > &lanes)
check if the given lanes are connected
void drawRightGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw right geometry point
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
bool drawMovingGeometryPoints(const bool ignoreShift) const
check if draw additional extrem geometry points
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
void drawLeftGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw left geometry point
void drawParentChildLines(const GUIVisualizationSettings &s, const RGBColor &color, const bool onlySymbols=false) const
draw parent and child lines
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
const std::string & getTagStr() const
get tag assigned to this object in string format
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
static bool lanesConsecutives(const std::vector< GNELane * > &lanes)
check if lanes are consecutives
GNENet * myNet
pointer to net
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset, const GNESegment *segment, const GUIGlObject *boundaryParent, const bool addToSelectedObjects=true) const
calculate contour extruded (used in elements formed by a central shape)
void calculateContourCircleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, double radius, const double layer, const double scale, const GUIGlObject *boundaryParent) const
calculate contour (circle elements)
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
bool checkDrawPathContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC) const
drawing contour functions
void drawE2DetectorLogo(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration, const std::string &logo, const RGBColor &textColor) const
draw E2 detector Logo
double myPositionOverLane
position of detector over Lane
bool isDetectorValid(SumoXMLAttr key, const std::string &value)
void setDetectorAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
double getDetectorAttributeDouble(SumoXMLAttr key) const
void writeDetectorValues(OutputDevice &device) const
write additional element into a xml file
bool myFriendlyPosition
Flag for friendly position.
std::string getDetectorAttribute(SumoXMLAttr key) const
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given toLane
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void updateGeometry()
update pre-computed geometry information
double getAttributeDouble(SumoXMLAttr key) const
void fixAdditionalProblem()
fix additional problem
std::string getAttribute(SumoXMLAttr key) const
double myJamThreshold
The minimum distance to the next standing vehicle in order to make this vehicle count as a participan...
std::string myTrafficLight
Traffic light vinculated with this E2 Detector.
double myEndPositionOverLane
end position over lane (only for Multilane E2 detectors)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double getStartGeometryPositionOverLane() const
get start position over lane that is applicable to the shape
bool myShow
show or hidde detector in sumo-gui
bool isAdditionalValid() const
check if current additional is valid to be written into XML
void drawE2PartialLane(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNESegment *segment, const double offsetFront, const GUIGeometry &geometry, const double exaggeration, const bool movingGeometryPoints) const
draw E2 partial lane
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
void drawE2(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration) const
draw E2 detector
GNELaneAreaDetector(SumoXMLTag tag, GNENet *net)
default Constructor
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
double mySpeedThreshold
The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting.
std::string getAdditionalProblem() const
return a string with the current additional problem
double getEndGeometryPositionOverLane() const
get end position over lane that is applicable to the shape
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
SUMOTime myTimeThreshold
The time-based threshold that describes how much time has to pass until a vehicle is recognized as ha...
void computePathElement()
compute pathElement
void drawE2PartialJunction(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const bool onlyContour, const double offsetFront, const GUIGeometry &geometry, const double exaggeration) const
draw E2 partial junction
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:214
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:662
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:208
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:196
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
move result
double newFirstPos
new first position
const GNEMoveOperation::OperationType operationType
move operation
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEPathManager * getNetworkPathManager()
get network path manager
Definition GNENet.cpp:139
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2163
void calculateConsecutivePathLanes(GNEPathElement *pathElement, const std::vector< GNELane * > &lanes)
calculate consecutive path lanes
const GNELane * getLane() const
get lane associated with this segment
const GNEJunction * getJunction() const
get junction associated with this segment
const GNELane * getNextLane() const
get next lane
const GNELane * getPreviousLane() const
get previous lane
GNEContour * getFromContour() const
get from contour associated with segment (only if this is the first path segment)
bool isFirstSegment() const
check if segment is the first path's segment
GNEContour * getContour() const
bool isLastSegment() const
check if segment is the last path's segment
bool isLabelSegment() const
check if segment is label segment
GNEContour * getToContour() const
get to contour associated with segment (only if this is the last path segment)
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
GNEUndoList * getUndoList() const
get the undoList object
bool selectingDetectorsTLSMode() const
check if we're selecting detectors in TLS mode
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawContourGeometry(const GUIGeometry &geometry, const double width, const bool drawExtremes=false)
draw contour geometry
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
void addToRedrawPathElements(const GNEPathElement *pathElement)
add path element to redrawing set
bool isPathElementMarkForRedraw(const GNEPathElement *pathElement) const
check if the given path element has to be redraw again
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
bool checkDrawAdditional(Detail d, const bool selected) const
check if draw additionals
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
GUIVisualizationDetectorSettings detectorSettings
Detector settings.
double getTextAngle(double objectAngle) const
return an angle that is suitable for reading text aligned with the given angle (degrees)
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
std::map< std::string, std::string > Map
parameters map
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:322
double x() const
Returns the x-position.
Definition Position.h:55
double y() const
Returns the y-position.
Definition Position.h:60
double length2D() const
Returns the length.
double length() const
Returns the length.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static const RGBColor BLACK
Definition RGBColor.h:193
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:200
static const RGBColor RED
named colors
Definition RGBColor.h:185
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
bool showAdditionals() const
check if additionals has to be drawn
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool showConnections() const
check if select show connections checkbox is enabled
static const RGBColor connectionColor
connection color
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
static const RGBColor E2Color
color for E2 detectors
static const double E2Width
E2 detector widths.
static const double segmentWidthSmall
width of small dotted contour segments
static const double segmentWidth
width of dotted contour segments
static const double additionalGeometryPointRadius
moving additional geometry point radius
A structure which describes a connection between edges or lanes.
Definition NBEdge.h:201