Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNERoute.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-2026 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// A class for visualizing routes in Netedit
19/****************************************************************************/
20
22
27#include <netedit/GNENet.h>
28#include <netedit/GNESegment.h>
30#include <netedit/GNEUndoList.h>
35
36#include "GNERoute.h"
37#include "GNEVehicle.h"
38
39// ===========================================================================
40// FOX callback mapping
41// ===========================================================================
42
46
47// Object implementation
48FXIMPLEMENT(GNERoute::GNERoutePopupMenu, GUIGLObjectPopupMenu, GNERoutePopupMenuMap, ARRAYNUMBER(GNERoutePopupMenuMap))
49
50// ===========================================================================
51// GNERoute::GNERoutePopupMenu - methods
52// ===========================================================================
53
57
58
60
61
62long
64 GNERoute* route = static_cast<GNERoute*>(myObject);
65 GNEUndoList* undoList = route->myNet->getUndoList();
66 undoList->begin(route, "apply distance along route");
67 double dist = (route->getParentEdges().size() > 0) ? route->getParentEdges().front()->getNBEdge()->getDistance() : 0;
68 for (GNEEdge* edge : route->getParentEdges()) {
70 dist += edge->getNBEdge()->getFinalLength();
71 }
72 undoList->end();
73 return 1;
74}
75
76// ===========================================================================
77// GNERoute - methods
78// ===========================================================================
79
81 GNEDemandElement(net, tag) {
82}
83
84
86 GNEDemandElement(calibrator->getNet()->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE),
87 calibrator->getNet(), SUMO_TAG_ROUTE, calibrator->getFileBucket()) {
88 // set parent edge
89 if (calibrator->getParentEdges().size() > 0) {
90 setParents<GNEEdge*>({calibrator->getParentEdges().front()});
91 } else if (calibrator->getParentLanes().size() > 0) {
92 setParents<GNEEdge*>({calibrator->getParentLanes().front()->getParentEdge()});
93 } else {
94 throw InvalidArgument("Calibrator parent requieres at least one edge or one lane");
95 }
96}
97
98
99GNERoute::GNERoute(const std::string& id, const GNEDemandElement* originalRoute) :
100 GNEDemandElement(id, originalRoute->getNet(), originalRoute->getTagProperty()->getTag(), originalRoute->getFileBucket()),
101 Parameterised(originalRoute->getParameters()->getParametersMap()),
102 myRepeat(parse<int>(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
103 myCycleTime(string2time(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
104 myVClass(originalRoute->getVClass()) {
105 // set parents
106 setParents<GNEEdge*>(originalRoute->getParentEdges());
108}
109
110
111GNERoute::GNERoute(GNEVehicle* vehicleParent, const GNEDemandElement* originalRoute) :
112 GNEDemandElement(vehicleParent, originalRoute->getTagProperty()->getTag()),
113 Parameterised(originalRoute->getParameters()->getParametersMap()),
114 myRepeat(parse<int>(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
115 myCycleTime(string2time(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
116 myVClass(originalRoute->getVClass()) {
117 // set parents
118 setParents<GNEEdge*>(originalRoute->getParentEdges());
119 setParent<GNEDemandElement*>(vehicleParent);
121}
122
123
124GNERoute::GNERoute(const std::string& id, GNENet* net, FileBucket* fileBucket, SUMOVehicleClass vClass,
125 const std::vector<GNEEdge*>& edges, const RGBColor& color, const int repeat,
126 const SUMOTime cycleTime, const double probability, const Parameterised::Map& parameters) :
127 GNEDemandElement(id, net, SUMO_TAG_ROUTE, fileBucket),
128 Parameterised(parameters),
129 myColor(color),
130 myRepeat(repeat),
131 myCycleTime(cycleTime),
132 myProbability(probability),
133 myVClass(vClass) {
134 // set parents
135 setParents<GNEEdge*>(edges);
136}
137
138
139GNERoute::GNERoute(GNEDemandElement* vehicleParent, const std::vector<GNEEdge*>& edges, const RGBColor& color,
140 const int repeat, const SUMOTime cycleTime, const Parameterised::Map& parameters) :
142 Parameterised(parameters),
143 myColor(color),
144 myRepeat(repeat),
145 myCycleTime(cycleTime),
146 myVClass(vehicleParent->getVClass()) {
147 // set parents
148 setParents<GNEEdge*>(edges);
149 setParent<GNEDemandElement*>(vehicleParent);
150}
151
152
154
155
157 return nullptr;
158}
159
160
163 return this;
164}
165
166
167const Parameterised*
169 return this;
170}
171
172
175 // create popup
176 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
177 // build common options
179 // show option to open demand element dialog
180 if (myTagProperty->hasDialog()) {
181 GUIDesigns::buildFXMenuCommand(ret, "Open " + getTagStr() + " Dialog", getACIcon(), &parent, MID_OPEN_ADDITIONAL_DIALOG);
182 new FXMenuSeparator(ret);
183 }
184 GUIDesigns::buildFXMenuCommand(ret, "Cursor position in view: " + toString(getPositionInView().x()) + "," + toString(getPositionInView().y()), nullptr, nullptr, 0);
185 new FXMenuSeparator(ret);
186 GUIDesigns::buildFXMenuCommand(ret, "Apply distance along route", nullptr, ret, MID_GNE_ROUTE_APPLY_DISTANCE);
187 // route length
190 // add reverse
192 }
193 return ret;
194}
195
196
197void
199 device.openTag(SUMO_TAG_ROUTE);
200 // write id only for non-embedded routes
202 device.writeAttr(SUMO_ATTR_ID, getID());
203 }
207 }
210 }
213 }
216 }
217 // write probability if we have exactly one routeRef
218 std::vector<GNEDemandElement*> refs;
219 for (const auto& routeChild : getChildDemandElements()) {
220 if (routeChild->getTagProperty()->getTag() == GNE_TAG_ROUTEREF) {
221 refs.push_back(routeChild);
222 }
223 }
224 // write sorted stops
226 // write stops
227 for (const auto& routeChild : getChildDemandElements()) {
228 if (routeChild->getTagProperty()->isVehicleStop()) {
229 routeChild->writeDemandElement(device);
230 }
231 }
232 }
233 // write parameters
234 XMLHelpers::writeParams(device, *this);
235 // close tag
236 device.closeTag();
237}
238
239
242 // get sorted stops and check number
243 std::vector<GNEDemandElement*> stops;
244 for (const auto& routeChild : getChildDemandElements()) {
245 if (routeChild->getTagProperty()->isVehicleStop()) {
246 stops.push_back(routeChild);
247 }
248 }
249 // check stops
250 if (getInvalidStops().size() > 0) {
252 }
253 // check repeating
254 if (myRepeat > 0) {
255 // avoid repeat in routes with only one edge
256 if (getParentEdges().size() == 1) {
258 }
259 // check if front and last routes are connected
260 if (isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0) {
262 }
263 }
264 // check that exist a connection between every edge
265 if (isRouteValid(getParentEdges()).size() > 0) {
267 } else {
268 return Problem::OK;
269 }
270}
271
272
273std::string
275 // get sorted stops and check number
276 std::vector<GNEDemandElement*> stops;
277 for (const auto& routeChild : getChildDemandElements()) {
278 if (routeChild->getTagProperty()->isVehicleStop()) {
279 stops.push_back(routeChild);
280 }
281 }
282 const auto invalidStops = getInvalidStops();
283 if (invalidStops.size() > 0) {
284 return toString(invalidStops.size()) + " stops are outside of route (downstream)";
285 }
286 // check repeating
287 if (myRepeat > 0) {
288 // avoid repeat in routes with only one edge
289 if (getParentEdges().size() == 1) {
290 return TL("Cannot repeat in routes with only one edge");
291 }
292 // check if front and last routes is connected
293 if (isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0) {
294 return TL("Cannot repeat route; front and last edge aren't connected");
295 }
296 }
297 // return string with the problem obtained from isRouteValid
299}
300
301
302void
304 // currently the only solution is removing Route
305}
306
307
311 return getParentDemandElements().at(0)->getVClass();
312 } else {
313 return myVClass;
314 }
315}
316
317
318const RGBColor&
321 return myColor;
322 } else if ((getParentDemandElements().size() > 0) && (getParentDemandElements().front()->getColor() != RGBColor::INVISIBLE)) {
323 return getParentDemandElements().front()->getColor();
324 } else if ((getChildDemandElements().size() > 0) && (getChildDemandElements().front()->getColor() != RGBColor::INVISIBLE)) {
325 return getChildDemandElements().front()->getColor();
326 } else {
327 return RGBColor::YELLOW;
328 }
329}
330
331
332void
334 // compute geometry
336 // update child demand elements
337 for (const auto& demandElement : getChildDemandElements()) {
338 if (!demandElement->getTagProperty()->isVehicleStop()) {
339 demandElement->updateGeometry();
340 }
341 }
342}
343
344
349
350
351std::string
353 return getParentEdges().front()->getID();
354}
355
356
357double
361
362
365 Boundary routeBoundary;
366 // return the combination of all parent edges's boundaries
367 for (const auto& i : getParentEdges()) {
368 routeBoundary.add(i->getCenteringBoundary());
369 }
370 // check if is valid
371 if (routeBoundary.isInitialised()) {
372 return routeBoundary;
373 } else {
374 return Boundary(-0.1, -0.1, 0.1, 0.1);
375 }
376}
377
378
379void
380GNERoute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) {
381 // obtain new list of route edges
382 std::string newRouteEdges = getNewListOfParents(originalElement, newElement);
383 // update route edges
384 if (newRouteEdges.size() > 0) {
385 setAttribute(SUMO_ATTR_EDGES, newRouteEdges, undoList);
386 }
387}
388
389
390void
392 // Routes are drawn in drawLanePartialGL and drawJunctionPartialGL
393}
394
395
396void
398 // calculate path depending if is embedded
403 } else {
405 }
406 // if path is empty, then calculate path again using SVC_IGNORING
407 if (!myNet->getDemandPathManager()->isPathValid(this)) {
409 }
410}
411
412
413void
414GNERoute::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
415 // check conditions
420 // get exaggeration
421 const double exaggeration = getExaggeration(s);
422 // get detail level
423 const auto d = s.getDetailLevel(exaggeration);
424 // get embedded route flag
425 const bool embedded = (myTagProperty->getTag() == GNE_TAG_ROUTE_EMBEDDED);
426 // get route width
427 const double routeWidth = embedded ? s.widthSettings.embeddedRouteWidth : s.widthSettings.routeWidth;
428 // calculate startPos
429 const double geometryDepartPos = embedded ? (getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getParentDemandElements().at(0)->getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_LENGTH)) : -1;
430 // get endPos
431 const double geometryEndPos = embedded ? getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_ARRIVALPOS) : -1;
432 // declare path geometry
433 GUIGeometry routeGeometry;
434 // update pathGeometry depending of first and last segment
435 if (segment->isFirstSegment() && segment->isLastSegment()) {
436 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
437 geometryDepartPos,
439 geometryEndPos,
441 } else if (segment->isFirstSegment()) {
442 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
443 geometryDepartPos,
445 -1,
447 } else if (segment->isLastSegment()) {
448 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
449 -1,
451 geometryEndPos,
453 } else {
454 routeGeometry = segment->getLane()->getLaneGeometry();
455 }
456 // draw geometry only if we'rent in drawForObjectUnderCursor mode
458 // draw route partial lane
459 drawRoutePartialLane(s, d, segment, offsetFront, routeGeometry, exaggeration);
460 // draw name
463 }
464 // draw dotted contour
465 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
466 // show index over every edge
469 const double textSize = s.vehicleName.size / s.scale;
470 std::string label = toString(segment->getLaneIndex());
471 Position pos = segment->getLane()->getLaneShape().front() - Position(0, textSize * 1);
472 // use layer above all demand elements
474 }
475 }
476 // calculate contour
477 segment->getContour()->calculateContourExtrudedShape(s, d, this, routeGeometry.getShape(), getType(), routeWidth, exaggeration,
478 segment->isFirstSegment(), segment->isLastSegment(), 0, segment, segment->getLane()->getParentEdge());
479 // check if add this path element to redraw buffer
482 }
483 }
484}
485
486
487void
488GNERoute::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
489 // check conditions
494 // Obtain exaggeration of the draw
495 const double routeExaggeration = getExaggeration(s);
496 // get detail level
497 const auto d = s.getDetailLevel(routeExaggeration);
498 // get route width
500 // check if connection to next lane exist
501 const bool connectionExist = segment->getPreviousLane()->getLane2laneConnections().exist(segment->getNextLane());
502 // get geometry
503 const GUIGeometry& routeGeometry = connectionExist ? segment->getPreviousLane()->getLane2laneConnections().getLane2laneGeometry(segment->getNextLane()) :
504 GUIGeometry({segment->getPreviousLane()->getLaneShape().back(), segment->getNextLane()->getLaneShape().front()});
505 // draw geometry only if we'rent in drawForObjectUnderCursor mode
507 // draw route partial
508 drawRoutePartialJunction(s, d, offsetFront, routeGeometry, routeExaggeration);
509 // draw dotted contour
510 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
511 }
512 // calculate contour
513 segment->getContour()->calculateContourExtrudedShape(s, d, this, routeGeometry.getShape(), getType(), routeWidth, routeExaggeration,
514 false, false, 0, segment, segment->getJunction());
515 // check if add this path element to redraw buffer
518 }
519 }
520}
521
522
523GNELane*
526 return getParentEdges().front()->getLaneByAllowedVClass(SVC_PASSENGER);
527 } else {
528 return getParentDemandElements().at(0)->getFirstPathLane();
529 }
530}
531
532
533GNELane*
536 return getParentEdges().back()->getLaneByAllowedVClass(SVC_PASSENGER);
537 } else {
538 return getParentDemandElements().at(0)->getLastPathLane();
539 }
540}
541
542
543std::string
545 switch (key) {
546 case SUMO_ATTR_ID:
547 return getMicrosimID();
548 case SUMO_ATTR_EDGES:
549 return parseIDs(getParentEdges());
550 case SUMO_ATTR_COLOR:
552 return toString(myColor);
553 } else {
554 return "";
555 }
556 case SUMO_ATTR_REPEAT:
557 return toString(myRepeat);
559 return time2string(myCycleTime);
560 case SUMO_ATTR_PROB:
561 return toString(myProbability);
562 default:
563 return getCommonAttribute(key);
564 }
565}
566
567
568double
570 switch (key) {
572 return 0;
574 return getParentEdges().back()->getChildLanes().front()->getLaneShape().length2D();
575 case SUMO_ATTR_PROB:
576 return myProbability;
577 default:
578 return getCommonAttributeDouble(key);
579 }
580}
581
582
585 switch (key) {
587 return getParentEdges().front()->getChildLanes().front()->getLaneShape().front();
589 return getParentEdges().back()->getChildLanes().front()->getLaneShape().back();
590 default:
591 return getCommonAttributePosition(key);
592 }
593}
594
595
596void
597GNERoute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
598 if (value == getAttribute(key)) {
599 return; //avoid needless changes, later logic relies on the fact that attributes have changed
600 }
601 switch (key) {
602 case SUMO_ATTR_ID:
603 case SUMO_ATTR_COLOR:
604 case SUMO_ATTR_REPEAT:
606 case SUMO_ATTR_PROB:
607 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
608 break;
609 // special case due depart and arrival edge vehicles
610 case SUMO_ATTR_EDGES: {
611 // extract all vehicle childrens
612 std::vector<GNEDemandElement*> vehicles;
613 for (const auto& childDemandElement : getChildDemandElements()) {
614 if (childDemandElement->getTagProperty()->isVehicle()) {
615 vehicles.push_back(childDemandElement);
616 }
617 }
618 // check vehicles
619 if (vehicles.size() > 0) {
620 undoList->begin(this, "reset start and end edges");
621 for (const auto& vehicle : vehicles) {
624 }
625 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
626 undoList->end();
628 undoList->begin(this, "reset start and end edges");
631 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
632 undoList->end();
633 } else {
634 // just change edges
635 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
636 }
637 break;
638 }
639 default:
640 setCommonAttribute(key, value, undoList);
641 break;
642 }
643}
644
645
646bool
647GNERoute::isValid(SumoXMLAttr key, const std::string& value) {
648 switch (key) {
649 case SUMO_ATTR_ID:
650 return isValidDemandElementID(value);
651 case SUMO_ATTR_EDGES:
652 if (value.empty()) {
653 return false;
654 } else {
655 return canParse<std::vector<GNEEdge*> >(myNet, value, true);
656 }
657 case SUMO_ATTR_COLOR:
658 if (value.empty()) {
659 return true;
660 } else {
661 return canParse<RGBColor>(value);
662 }
663 case SUMO_ATTR_REPEAT:
664 return canParse<int>(value) && (parse<int>(value) >= 0);
666 if (canParse<SUMOTime>(value)) {
667 return (parse<SUMOTime>(value) >= 0);
668 } else {
669 return false;
670 }
671 case SUMO_ATTR_PROB:
672 if (canParse<double>(value)) {
673 return (parse<double>(value) >= 0);
674 } else {
675 return false;
676 }
677 default:
678 return isCommonAttributeValid(key, value);
679 }
680}
681
682
683std::string
685 return getTagStr();
686}
687
688
689std::string
691 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) ;
692}
693
694
695std::string
696GNERoute::isRouteValid(const std::vector<GNEEdge*>& edges) {
697 if (edges.size() == 0) {
698 // routes cannot be empty
699 return ("list of route edges cannot be empty");
700 } else if (edges.size() == 1) {
701 // routes with a single edge are valid, then return an empty string
702 return ("");
703 } else {
704 // iterate over edges to check that compounds a chain
705 auto it = edges.begin();
706 while (it != edges.end() - 1) {
707 const GNEEdge* currentEdge = *it;
708 const GNEEdge* nextEdge = *(it + 1);
709 // same consecutive edges aren't allowed
710 if (currentEdge->getID() == nextEdge->getID()) {
711 return ("consecutive duplicated edges (" + currentEdge->getID() + ") aren't allowed in a route");
712 }
713 // obtain outgoing edges of currentEdge
714 const std::vector<GNEEdge*>& outgoingEdges = currentEdge->getToJunction()->getGNEOutgoingEdges();
715 // check if nextEdge is in outgoingEdges
716 if (std::find(outgoingEdges.begin(), outgoingEdges.end(), nextEdge) == outgoingEdges.end()) {
717 return ("Edges '" + currentEdge->getID() + "' and '" + nextEdge->getID() + "' aren't consecutives");
718 }
719 it++;
720 }
721 // all edges consecutives, then return an empty string
722 return ("");
723 }
724}
725
727GNERoute::copyRoute(const GNERoute* originalRoute) {
728 // get net and undoList
729 const auto net = originalRoute->getNet();
730 auto undoList = net->getViewNet()->getUndoList();
731 // generate new route ID
732 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
733 // create new route
734 GNERoute* newRoute = new GNERoute(newRouteID, originalRoute);
735 // add new route using undo-list
736 undoList->begin(originalRoute, TLF("copy % '%'", originalRoute->getTagStr(), newRouteID));
737 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
738 undoList->end();
739 // return new route
740 return newRoute;
741}
742
743// ===========================================================================
744// private
745// ===========================================================================
746
747void
749 const GNESegment* segment, const double offsetFront,
750 const GUIGeometry& geometry, const double exaggeration) const {
751 // get route width
753 // push layer matrix
755 // Start with the drawing of the area translating matrix to origin
756 glTranslated(0, 0, getType() + offsetFront);
757 // Set color
758 if (drawUsingSelectColor()) {
760 } else {
762 }
763 // draw geometry
764 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
765 // check if we have to draw a red line to the next segment
766 if (segment->getNextLane()) {
767 // push draw matrix
769 // Set red color
771 // get firstPosition (last position of current lane shape)
772 const Position firstPosition = segment->getLane()->getLaneShape().back();
773 // get lastPosition (first position of next lane shape)
774 const Position arrivalPos = segment->getNextLane()->getLaneShape().front();
775 // draw box line
776 GLHelper::drawBoxLine(arrivalPos,
777 RAD2DEG(firstPosition.angleTo2D(arrivalPos)) - 90,
778 firstPosition.distanceTo2D(arrivalPos), .05);
779 // pop draw matrix
781 }
782 // Pop layer matrix
784}
785
786
787void
789 const double offsetFront, const GUIGeometry& geometry, const double exaggeration) const {
790 const bool invalid = geometry.getShape().length() == 2;
791 // get route width
793 // Add a draw matrix
795 // Start with the drawing of the area translating matrix to origin
796 glTranslated(0, 0, getType() + offsetFront);
797 // Set color of the base
798 if (drawUsingSelectColor()) {
800 } else if (invalid) {
802 } else {
804 }
805 // draw geometry
806 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
807 // Pop last matrix
809}
810
811
812void
813GNERoute::setAttribute(SumoXMLAttr key, const std::string& value) {
814 switch (key) {
815 case SUMO_ATTR_ID:
816 // update microsimID
817 setDemandElementID(value);
818 break;
819 case SUMO_ATTR_EDGES:
820 // replace parents
821 replaceParentEdges(value);
822 // compute route
824 // update all parent and child demand elements
825 for (const auto& element : getParentDemandElements()) {
826 element->updateGeometry();
827 }
828 for (const auto& element : getChildDemandElements()) {
829 element->updateGeometry();
830 }
831 break;
832 case SUMO_ATTR_COLOR:
833 if (value.empty()) {
835 } else {
836 myColor = parse<RGBColor>(value);
837 }
838 break;
839 case SUMO_ATTR_REPEAT:
840 if (value.empty()) {
842 } else {
843 myRepeat = parse<int>(value);
844 }
845 break;
847 if (value.empty()) {
849 } else {
850 myCycleTime = string2time(value);
851 }
852 break;
853 case SUMO_ATTR_PROB:
854 if (value.empty()) {
856 } else {
857 myProbability = parse<double>(value);
858 }
859 break;
860 default:
861 setCommonAttribute(key, value);
862 break;
863 }
864}
865
866
867bool
870 // this affect only to embedded routes
871 return true;
873 // only in demand mode
874 return true;
876 // only creating vehicles
877 return true;
878 } else {
879 // get current template AC
881 if (templateAC && templateAC->getTagProperty()->vehicleRoute()) {
882 // we're creating a vehicle over a route, then hidde all embedded routes
883 return false;
884 } else {
885 return true;
886 }
887 }
888}
889
890
891/****************************************************************************/
FXDEFMAP(GNERoute::GNERoutePopupMenu) GNERoutePopupMenuMap[]
@ DEMAND_VEHICLE
Mode for editing vehicles.
long long int SUMOTime
Definition GUI.h:36
@ MID_OPEN_ADDITIONAL_DIALOG
open additional dialog (used in netedit)
Definition GUIAppEnum.h:477
@ MID_GNE_ROUTE_APPLY_DISTANCE
apply distance
@ GLO_VEHICLELABELS
stack and flow labels (used in netedit)
GUIViewObjectsHandler gViewObjectsHandler
#define RAD2DEG(x)
Definition GeomHelper.h:36
#define TL(string)
Definition MsgHandler.h:316
#define TLF(string,...)
Definition MsgHandler.h:318
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:47
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:107
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_ROUTE
description of a route
@ GNE_TAG_ROUTEREF
virtual element used to reference routes with distributions
@ GNE_TAG_ROUTE_EMBEDDED
embedded route
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_ARRIVALLANE
@ SUMO_ATTR_DEPARTEDGE
@ SUMO_ATTR_ARRIVALEDGE
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_DEPARTLANE
@ SUMO_ATTR_DISTANCE
@ SUMO_ATTR_PROB
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ SUMO_ATTR_REPEAT
@ SUMO_ATTR_CYCLETIME
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:57
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:75
bool isInitialised() const
check if Boundary is Initialised
Definition Boundary.cpp:256
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:296
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition GLHelper.cpp:773
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
double getCommonAttributeDouble(SumoXMLAttr key) const
FXIcon * getACIcon() const
get FXIcon associated to this AC
bool mySelected
boolean to check if this AC is selected (more quickly as checking GUIGlObjectStorage)
const std::string getID() const override
get ID (all Attribute Carriers have one)
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
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.
Position getCommonAttributePosition(SumoXMLAttr key) const
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
bool isCommonAttributeValid(SumoXMLAttr key, const std::string &value) const
virtual std::string getAttribute(SumoXMLAttr key) const =0
std::string getCommonAttribute(SumoXMLAttr key) const
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)
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 buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
std::vector< GNEDemandElement * > getInvalidStops() const
get invalid stops
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
void setDemandElementID(const std::string &newID)
set demand element id
void buildMenuAddReverse(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceParentEdges(const std::string &value)
all edges
Problem
enum class for demandElement problems
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
Definition GNEEdge.h:92
const GNEHierarchicalContainerParents< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
std::string getNewListOfParents(const GNENetworkElement *currentElement, const GNENetworkElement *newNextElement) const
if use edge/parent lanes as a list of consecutive elements, obtain a list of IDs of elements after in...
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
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
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:234
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:683
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition GNELane.cpp:340
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:228
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:216
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:198
GNEViewParent * getViewParent() const
get view parent (used for simplify code)
Definition GNENet.cpp:150
GNEUndoList * getUndoList() const
get undo list(used for simplify code)
Definition GNENet.cpp:156
GNEViewNet * getViewNet() const
get view net (used for simplify code)
Definition GNENet.cpp:144
bool checkDrawPathGeometry(const GUIVisualizationSettings &s, const GNELane *lane, const SumoXMLTag tag, const bool isPlan)
check if path element geometry must be drawn in the given lane
PathDraw * getPathDraw()
obtain instance of PathDraw
bool isPathValid(const GNEPathElement *pathElement) const
check if path element is valid
void calculateConsecutivePathEdges(GNEPathElement *pathElement, SUMOVehicleClass vClass, const std::vector< GNEEdge * > &edges, const int firstLaneIndex=-1, const int lastLaneIndex=-1)
calculate consecutive path edges
class used in GUIGLObjectPopupMenu for routes
Definition GNERoute.h:42
~GNERoutePopupMenu()
Destructor.
Definition GNERoute.cpp:59
long onCmdApplyDistance(FXObject *, FXSelector, void *)
Called to modify edge distance values along the route.
Definition GNERoute.cpp:63
bool isValid(SumoXMLAttr key, const std::string &value) override
Definition GNERoute.cpp:647
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this route
Definition GNERoute.cpp:156
GNELane * getLastPathLane() const override
get last path lane
Definition GNERoute.cpp:534
std::string getParentName() const override
Returns the name of the parent object.
Definition GNERoute.cpp:352
std::string getAttribute(SumoXMLAttr key) const override
inherited from GNEAttributeCarrier
Definition GNERoute.cpp:544
SUMOVehicleClass myVClass
SUMOVehicleClass (Only used for drawing)
Definition GNERoute.h:282
bool checkCreatingVehicleOverRoute() const
check if we're creating a vehicle or flow over route
Definition GNERoute.cpp:868
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNERoute.cpp:569
SUMOTime myCycleTime
cycleTime
Definition GNERoute.h:276
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNERoute.cpp:690
Problem isDemandElementValid() const override
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
Definition GNERoute.cpp:241
void writeDemandElement(OutputDevice &device) const override
write demand element element into a xml file
Definition GNERoute.cpp:198
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNERoute.cpp:174
void updateGeometry() override
update pre-computed geometry information
Definition GNERoute.cpp:333
Parameterised * getParameters() override
get parameters associated with this route
Definition GNERoute.cpp:162
void drawRoutePartialJunction(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double offsetFront, const GUIGeometry &geometry, const double exaggeration) const
draw route partial junction
Definition GNERoute.cpp:788
void computePathElement() override
compute pathElement
Definition GNERoute.cpp:397
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition GNERoute.cpp:358
void fixDemandElementProblem() override
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition GNERoute.cpp:303
static GNEDemandElement * copyRoute(const GNERoute *originalRoute)
create a copy of the given route
Definition GNERoute.cpp:727
Position getAttributePosition(SumoXMLAttr key) const override
Definition GNERoute.cpp:584
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const override
Draws partial object over lane.
Definition GNERoute.cpp:414
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNERoute.cpp:391
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNERoute.cpp:684
std::string getDemandElementProblem() const override
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition GNERoute.cpp:274
void drawRoutePartialLane(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNESegment *segment, const double offsetFront, const GUIGeometry &geometry, const double exaggeration) const
draw route partial lane
Definition GNERoute.cpp:748
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNERoute.cpp:380
const RGBColor & getColor() const override
get color
Definition GNERoute.cpp:319
GNERoute(SumoXMLTag tag, GNENet *net)
default constructor
Definition GNERoute.cpp:80
SUMOVehicleClass getVClass() const override
obtain VClass related with this demand element
Definition GNERoute.cpp:309
static std::string isRouteValid(const std::vector< GNEEdge * > &edges)
check if a route is valid
Definition GNERoute.cpp:696
int myRepeat
repeat
Definition GNERoute.h:273
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const override
Draws partial object over junction.
Definition GNERoute.cpp:488
GNELane * getFirstPathLane() const override
get first path lane
Definition GNERoute.cpp:524
RGBColor myColor
route color
Definition GNERoute.h:270
~GNERoute()
destructor
Definition GNERoute.cpp:153
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNERoute.cpp:364
Position getPositionInView() const override
Returns position of additional in view.
Definition GNERoute.cpp:346
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
Definition GNERoute.cpp:597
double myProbability
probability
Definition GNERoute.h:279
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
bool isFirstSegment() const
check if segment is the first path's segment
GNEContour * getContour() const
int getLaneIndex() const
get lane index
bool isLastSegment() const
check if segment is the last path's segment
const RGBColor & getDefaultColorValue(SumoXMLAttr attr) const
get default bool value
double getDefaultDoubleValue(SumoXMLAttr attr) const
get default double value
SUMOTime getDefaultTimeValue(SumoXMLAttr attr) const
get default time value
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool hasDialog() const
return true if tag correspond to an element that can be edited using a dialog
int getDefaultIntValue(SumoXMLAttr attr) const
get default int value
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute "attr"
GNEAttributeCarrier * getCurrentTemplateAC() const
get current templateAC
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...
GNETagSelector * getVehicleTagSelector() const
get vehicle tag selector (needed for transform vehicles)
bool isACInspected(GNEAttributeCarrier *AC) const
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
GNEViewNetHelper::InspectedElements & getInspectedElements()
get inspected elements
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
GNEUndoList * getUndoList() const
get the undoList object
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
GNEVehicleFrame * getVehicleFrame() const
get frame for DEMAND_VEHICLE
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
The popup menu of a globject.
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
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
virtual Position getCenter() const
void buildPopUpMenuCommonOptions(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, GUISUMOAbstractView *parent, const SumoXMLTag tag, const bool selected, const bool allowDelete, const bool addSeparator)
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
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
GUIVisualizationTextSettings vehicleName
GUIVisualizationSizeSettings vehicleSize
GUIVisualizationWidthSettings widthSettings
width settings
bool checkDrawVehicle(Detail d, const bool selected) const
check if draw vehicle
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)
bool showRouteIndex
Information whether the route index should be shown.
double angle
The current view rotation angle.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false, const bool escape=false)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
An upper class for objects with additional parameters.
std::map< std::string, std::string > Map
parameters map
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:323
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:273
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition Position.h:283
double length() const
Returns the length.
static const RGBColor YELLOW
Definition RGBColor.h:207
static const RGBColor INVISIBLE
Definition RGBColor.h:214
static const RGBColor RED
named colors
Definition RGBColor.h:204
static OutputDevice & writeParams(OutputDevice &device, const Parameterised &params)
write the parameters of the given object as param tags
bool showDemandElements() const
check if show demand elements checkbox is enabled
bool showNonInspectedDemandElements(const GNEDemandElement *demandElement) const
check if non inspected element has to be hidden
DemandEditMode demandEditMode
the current Demand edit mode
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
bool showDemandElements() const
check if show demand elements checkbox is enabled
RGBColor selectedRouteColor
route selection color (used for routes and vehicle stops)
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
static const double segmentWidth
width of dotted contour segments
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
static const double embeddedRouteWidth
width for embeddedroutes
static const double routeWidth
width for routes