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
287 myAdditionalContour.calculateContourExtrudedShape(s, d, this, myAdditionalGeometry.getShape(), getType(), s.detectorSettings.E2Width, E2Exaggeration, true, true, 0, nullptr);
288 }
289}
290
291
292void
297
298
299void
300GNELaneAreaDetector::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
301 // check if E2 can be drawn
304 const bool movingGeometryPoints = drawMovingGeometryPoints(false);
305 // Obtain exaggeration of the draw
306 const double E2Exaggeration = getExaggeration(s);
307 // get detail level
308 const auto d = s.getDetailLevel(E2Exaggeration);
309 // calculate startPos
310 const double geometryDepartPos = getAttributeDouble(SUMO_ATTR_POSITION);
311 // get endPos
312 const double geometryEndPos = getAttributeDouble(SUMO_ATTR_ENDPOS);
313 // declare path geometry
314 GUIGeometry E2Geometry;
315 // update pathGeometry depending of first and last segment
316 if (segment->isFirstSegment() && segment->isLastSegment()) {
317 E2Geometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
318 geometryDepartPos,
320 geometryEndPos,
322 } else if (segment->isFirstSegment()) {
323 E2Geometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
324 geometryDepartPos,
326 -1,
328 } else if (segment->isLastSegment()) {
329 E2Geometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
330 -1,
332 geometryEndPos,
334 } else {
335 E2Geometry = segment->getLane()->getLaneGeometry();
336 }
337 // draw geometry only if we'rent in drawForObjectUnderCursor mode
339 // draw E2 partial
340 drawE2PartialLane(s, d, segment, offsetFront, E2Geometry, E2Exaggeration, movingGeometryPoints);
341 // draw additional ID
342 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
343 // draw dotted contour
344 if (movingGeometryPoints) {
345 // get mouse position
346 const Position mousePosition = myNet->getViewNet()->getPositionInformation();
347 // get snap radius
349 if (segment->getFromContour() && E2Geometry.getShape().front().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
351 } else if (segment->getToContour() && E2Geometry.getShape().back().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
353 }
354 } else {
355 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
356 }
357 }
358 // calculate contour and draw dotted geometry
359 segment->getContour()->calculateContourExtrudedShape(s, d, this, E2Geometry.getShape(), getType(), s.detectorSettings.E2Width, E2Exaggeration,
360 segment->isFirstSegment(), segment->isLastSegment(), 0, segment);
361 // check if create from-to contours
362 if (segment->getFromContour()) {
363 segment->getFromContour()->calculateContourCircleShape(s, d, this, E2Geometry.getShape().front(),
365 } else if (segment->getToContour()) {
366 segment->getToContour()->calculateContourCircleShape(s, d, this, E2Geometry.getShape().back(),
368 }
369 // check if add this path element to redraw buffer
372 }
373 }
374}
375
376
377void
378GNELaneAreaDetector::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
379 // check if E2 can be drawn
382 // Obtain exaggeration of the draw
383 const double E2Exaggeration = getExaggeration(s);
384 // get detail level
385 const auto d = s.getDetailLevel(E2Exaggeration);
386 // get flag for show only contour
388 // check if connection to next lane exist
389 const bool connectionExist = segment->getPreviousLane()->getLane2laneConnections().exist(segment->getNextLane());
390 // get geometry
391 const GUIGeometry& E2Geometry = connectionExist ? segment->getPreviousLane()->getLane2laneConnections().getLane2laneGeometry(segment->getNextLane()) :
392 GUIGeometry({segment->getPreviousLane()->getLaneShape().back(), segment->getNextLane()->getLaneShape().front()});
393 // draw geometry only if we'rent in drawForObjectUnderCursor mode
395 // draw E2 partial
396 drawE2PartialJunction(s, d, onlyContour, offsetFront, E2Geometry, E2Exaggeration);
397 // draw dotted contour
398 if (!drawMovingGeometryPoints(false)) {
399 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
400 }
401 }
402 // calculate contour
403 segment->getContour()->calculateContourExtrudedShape(s, d, this, E2Geometry.getShape(), getType(), s.detectorSettings.E2Width, E2Exaggeration, false, false, 0, segment);
404 // check if add this path element to redraw buffer
407 }
408 }
409}
410
411
412std::string
437
438
439double
441 switch (key) {
442 case SUMO_ATTR_LENGTH:
444 case SUMO_ATTR_ENDPOS:
446 default:
447 return getDetectorAttributeDouble(key);
448 }
449}
450
451
452void
453GNELaneAreaDetector::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
454 switch (key) {
455 case SUMO_ATTR_LANES:
456 case SUMO_ATTR_ENDPOS:
457 case SUMO_ATTR_TLID:
458 case SUMO_ATTR_LENGTH:
463 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
464 break;
465 default:
466 setDetectorAttribute(key, value, undoList);
467 break;
468 }
469}
470
471
472bool
473GNELaneAreaDetector::isValid(SumoXMLAttr key, const std::string& value) {
474 switch (key) {
475 case SUMO_ATTR_LANES:
476 if (value.empty()) {
477 return false;
478 } else if (canParse<std::vector<GNELane*> >(myNet, value, false)) {
479 // check if lanes are consecutives
480 return lanesConsecutives(parse<std::vector<GNELane*> >(myNet, value));
481 } else {
482 return false;
483 }
484 case SUMO_ATTR_ENDPOS:
485 return canParse<double>(value);
486 case SUMO_ATTR_TLID:
487 // temporal
489 case SUMO_ATTR_LENGTH:
490 return (canParse<double>(value) && (parse<double>(value) >= 0));
492 return canParse<SUMOTime>(value);
494 return (canParse<double>(value) && (parse<double>(value) >= 0));
496 return (canParse<double>(value) && (parse<double>(value) >= 0));
498 return canParse<bool>(value);
499 default:
500 return isDetectorValid(key, value);
501 }
502}
503
504// ===========================================================================
505// private
506// ===========================================================================
507
508void
510 const double exaggeration) const {
511 // declare color
512 RGBColor E2Color, textColor;
513 // set color
514 if (drawUsingSelectColor()) {
516 textColor = E2Color.changedBrightness(-32);
517 } else if (areLaneConsecutives(getParentLanes())) {
518 E2Color = s.detectorSettings.E2Color;
519 textColor = RGBColor::BLACK;
520 }
521 // draw parent and child lines
523 // push layer matrix
525 // translate to front
527 // set color
528 GLHelper::setColor(E2Color);
529 // draw geometry
531 // draw arrow
532 if (myAdditionalGeometry.getShape().size() > 1) {
533 glTranslated(0, 0, 0.1);
535 }
536 // draw E2 Logo
537 drawE2DetectorLogo(s, d, exaggeration, "E2", textColor);
538 // draw geometry points
541 // pop layer matrix
543}
544
545
546void
548 const GNESegment* segment, const double offsetFront,
549 const GUIGeometry& geometry, const double exaggeration, const bool movingGeometryPoints) const {
550 // obtain color
552 // push layer matrix
554 // Start with the drawing of the area traslating matrix to origin
555 glTranslated(0, 0, getType() + offsetFront);
556 // Set color
557 GLHelper::setColor(E2Color);
558 // draw geometry
559 GUIGeometry::drawGeometry(d, geometry, s.detectorSettings.E2Width * exaggeration);
560 // check if draw moving geometry points
561 if (movingGeometryPoints) {
562 if (segment->isFirstSegment() && segment->isLastSegment()) {
563 drawLeftGeometryPoint(s, d, geometry.getShape().front(), geometry.getShapeRotations().front(), E2Color, true);
564 drawRightGeometryPoint(s, d, geometry.getShape().back(), geometry.getShapeRotations().back(), E2Color, true);
565 } else if (segment->isFirstSegment()) {
566 drawLeftGeometryPoint(s, d, geometry.getShape().front(), geometry.getShapeRotations().front(), E2Color, true);
567 } else if (segment->isLastSegment()) {
568 drawRightGeometryPoint(s, d, geometry.getShape().back(), geometry.getShapeRotations().back(), E2Color, true);
569 // draw arrow
570 if (geometry.getShape().size() > 1) {
571 glTranslated(0, 0, 0.1);
572 GLHelper::drawTriangleAtEnd(geometry.getShape()[-2], geometry.getShape()[-1], (double) 0.5, (double) 1, 0.5);
573 }
574 }
575 }
576 // Pop layer matrix
578 // check if this is the label segment
579 if (segment->isLabelSegment() && !s.drawForRectangleSelection) {
580 // calculate middle point
581 const double middlePoint = (geometry.getShape().length2D() * 0.5);
582 // calculate position
583 const Position pos = geometry.getShape().positionAtOffset2D(middlePoint);
584 // calculate rotation
585 const double rot = s.getTextAngle((geometry.getShape().rotationDegreeAtOffset(middlePoint) * -1) + 90);
586 // Start pushing matrix
588 // Traslate to position
589 glTranslated(pos.x(), pos.y(), getType() + offsetFront + 0.1);
590 // rotate
591 glRotated(rot, 0, 0, 1);
592 // move
593 glTranslated(-1, 0, 0);
594 // scale text
595 glScaled(exaggeration, exaggeration, 1);
596 // draw E1 logo
597 GLHelper::drawText("E2 Multilane", Position(), .1, 1.5, RGBColor::BLACK);
598 // pop matrix
600 }
601
602}
603
604
605void
607 const bool onlyContour, const double offsetFront, const GUIGeometry& geometry,
608 const double exaggeration) const {
609 const bool invalid = geometry.getShape().length() == 2;
610 const double width = s.detectorSettings.E2Width * exaggeration * (invalid ? 0.5 : 1);
611 // Add a draw matrix
613 // Start with the drawing of the area traslating matrix to origin
614 glTranslated(0, 0, getType() + offsetFront);
615 // Set color of the base
616 if (drawUsingSelectColor()) {
618 } else if (invalid) {
620 } else {
622 }
623 // check if draw only contour
624 if (onlyContour) {
625 GUIGeometry::drawContourGeometry(geometry, width);
626 } else {
627 GUIGeometry::drawGeometry(d, geometry, width);
628 }
629 // Pop last matrix
631}
632
633
634void
635GNELaneAreaDetector::setAttribute(SumoXMLAttr key, const std::string& value) {
636 switch (key) {
637 case SUMO_ATTR_LANES:
639 break;
640 case SUMO_ATTR_ENDPOS:
641 myEndPositionOverLane = parse<double>(value);
642 // update geometry (except for template)
643 if (getParentLanes().size() > 0) {
645 }
646 break;
647 case SUMO_ATTR_TLID:
648 myTrafficLight = value;
649 break;
650 case SUMO_ATTR_LENGTH:
651 myEndPositionOverLane = (myPositionOverLane + parse<double>(value));
652 // update geometry (except for template)
653 if (getParentLanes().size() > 0) {
655 }
656 break;
658 myTimeThreshold = TIME2STEPS(parse<double>(value));
659 break;
661 mySpeedThreshold = parse<double>(value);
662 break;
664 myJamThreshold = parse<double>(value);
665 break;
667 myShow = parse<bool>(value);
668 break;
669 default:
670 setDetectorAttribute(key, value);
671 break;
672 }
673}
674
675
676void
680 // change only start position
681 myPositionOverLane = moveResult.newFirstPos;
684 // change only end position
686 } else {
688 const auto difference = moveResult.newFirstPos - myPositionOverLane;
689 // change start position
690 myPositionOverLane = moveResult.newFirstPos;
691 myEndPositionOverLane += difference;
693 const auto difference = moveResult.newFirstPos - myEndPositionOverLane;
694 // change end position
695 myPositionOverLane += difference;
697 }
698 // end position over lane
699 if (myPositionOverLane < 0) {
701 } else if (myPositionOverLane > getParentLanes().front()->getLaneShapeLength()) {
702 myPositionOverLane = getParentLanes().front()->getLaneShapeLength();
703 }
704 // adjust position over lane
705 if (myEndPositionOverLane < 0) {
707 } else if (myEndPositionOverLane > getParentLanes().back()->getLaneShapeLength()) {
708 myEndPositionOverLane = getParentLanes().back()->getLaneShapeLength();
709 }
710 }
711 // update geometry
713}
714
715
716void
718 // begin change attribute
719 undoList->begin(this, "position of " + getTagStr());
720 // set attributes depending of operation type
723 // set only start position
724 setAttribute(SUMO_ATTR_POSITION, toString(moveResult.newFirstPos), undoList);
727 // set only end position
728 setAttribute(SUMO_ATTR_ENDPOS, toString(moveResult.newFirstPos), undoList);
729 } else {
730 double startPos = myPositionOverLane;
731 double endPos = myEndPositionOverLane;
732 // set positions
734 const auto difference = moveResult.newFirstPos - myPositionOverLane;
735 // change start position
736 startPos = moveResult.newFirstPos;
737 endPos += difference;
739 const auto difference = moveResult.newFirstPos - myEndPositionOverLane;
740 // change end position
741 startPos += difference;
742 endPos = moveResult.newFirstPos;
743 }
744 // end position over lane
745 if (startPos < 0) {
746 startPos = 0;
747 } else if (startPos > getParentLanes().front()->getLaneShapeLength()) {
748 startPos = getParentLanes().front()->getLaneShapeLength();
749 }
750 // adjust position over lane
751 if (endPos < 0) {
752 endPos = 0;
753 } else if (endPos > getParentLanes().back()->getLaneShapeLength()) {
754 endPos = getParentLanes().back()->getLaneShapeLength();
755 }
756 // set only end position
757 setAttribute(SUMO_ATTR_POSITION, toString(startPos), undoList);
758 setAttribute(SUMO_ATTR_ENDPOS, toString(endPos), undoList);
759 }
760 // end change attribute
761 undoList->end();
762}
763
764
765double
767 // get lane final and shape length
768 const double laneLength = getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
769 // get startPosition
770 double fixedPos = myPositionOverLane;
771 // adjust fixedPos
772 if (fixedPos < 0) {
773 fixedPos += laneLength;
774 }
775 fixedPos *= getParentLanes().front()->getLengthGeometryFactor();
776 // return depending of fixedPos
777 if (fixedPos < 0) {
778 return 0;
779 } else if (fixedPos > (getParentLanes().front()->getLaneShapeLength() - POSITION_EPS)) {
780 return (getParentLanes().front()->getLaneShapeLength() - POSITION_EPS);
781 } else {
782 return fixedPos;
783 }
784}
785
786
787double
789 // get lane final and shape length
790 const double laneLength = getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
791 // get endPosition
792 double fixedPos = myEndPositionOverLane;
793 // adjust fixedPos
794 if (fixedPos < 0) {
795 fixedPos += laneLength;
796 }
797 fixedPos *= getParentLanes().back()->getLengthGeometryFactor();
798 // return depending of fixedPos
799 if (fixedPos < POSITION_EPS) {
800 return POSITION_EPS;
801 } else if (fixedPos > getParentLanes().back()->getLaneShapeLength()) {
802 return getParentLanes().back()->getLaneShapeLength();
803 } else {
804 return fixedPos;
805 }
806}
807
808/****************************************************************************/
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:654
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:629
static void popMatrix()
pop matrix
Definition GLHelper.cpp:130
static void pushMatrix()
push matrix
Definition GLHelper.cpp:117
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:756
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.
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 calculateContourCircleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, double radius, const double layer, const double scale) const
calculate contour (circle elements)
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
calculate contour extruded (used in elements formed by a central shape)
void 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
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:2155
void calculateConsecutivePathLanes(GNEPathElement *pathElement, const std::vector< GNELane * > &lanes)
calculate consecutive path lanes
const GNELane * getLane() const
get lane 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
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
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 drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
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