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-2025 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
25#include <netedit/GNENet.h>
26#include <netedit/GNESegment.h>
28#include <netedit/GNEUndoList.h>
33
34#include "GNERoute.h"
35#include "GNEVehicle.h"
36
37// ===========================================================================
38// FOX callback mapping
39// ===========================================================================
40
44
45// Object implementation
46FXIMPLEMENT(GNERoute::GNERoutePopupMenu, GUIGLObjectPopupMenu, GNERoutePopupMenuMap, ARRAYNUMBER(GNERoutePopupMenuMap))
47
48// ===========================================================================
49// GNERoute::GNERoutePopupMenu - methods
50// ===========================================================================
51
55
56
58
59
60long
62 GNERoute* route = static_cast<GNERoute*>(myObject);
63 GNEUndoList* undoList = route->myNet->getViewNet()->getUndoList();
64 undoList->begin(route, "apply distance along route");
65 double dist = (route->getParentEdges().size() > 0) ? route->getParentEdges().front()->getNBEdge()->getDistance() : 0;
66 for (GNEEdge* edge : route->getParentEdges()) {
68 dist += edge->getNBEdge()->getFinalLength();
69 }
70 undoList->end();
71 return 1;
72}
73
74// ===========================================================================
75// GNERoute - methods
76// ===========================================================================
77
81
82
84 GNEDemandElement(calibrator->getNet()->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE), calibrator->getNet(),
85 calibrator->getFilename(), SUMO_TAG_ROUTE, GNEPathElement::Options::DEMAND_ELEMENT | GNEPathElement::Options::ROUTE) {
86 // set parent edge
87 if (calibrator->getParentEdges().size() > 0) {
88 setParents<GNEEdge*>({calibrator->getParentEdges().front()});
89 } else if (calibrator->getParentLanes().size() > 0) {
90 setParents<GNEEdge*>({calibrator->getParentLanes().front()->getParentEdge()});
91 } else {
92 throw InvalidArgument("Calibrator parent requieres at least one edge or one lane");
93 }
94}
95
96
97GNERoute::GNERoute(const std::string& id, const GNEDemandElement* originalRoute) :
98 GNEDemandElement(id, originalRoute->getNet(), originalRoute->getFilename(), originalRoute->getTagProperty()->getTag(),
99 originalRoute->getPathElementOptions()),
100 Parameterised(originalRoute->getParameters()->getParametersMap()),
101 myRepeat(parse<int>(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
102 myCycleTime(string2time(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
103 myVClass(originalRoute->getVClass()) {
104 // set parents
105 setParents<GNEEdge*>(originalRoute->getParentEdges());
107}
108
109
110GNERoute::GNERoute(GNEVehicle* vehicleParent, const GNEDemandElement* originalRoute) :
111 GNEDemandElement(vehicleParent, originalRoute->getTagProperty()->getTag(), originalRoute->getPathElementOptions()),
112 Parameterised(originalRoute->getParameters()->getParametersMap()),
113 myRepeat(parse<int>(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
114 myCycleTime(string2time(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
115 myVClass(originalRoute->getVClass()) {
116 // set parents
117 setParents<GNEEdge*>(originalRoute->getParentEdges());
118 setParent<GNEDemandElement*>(vehicleParent);
120}
121
122
123GNERoute::GNERoute(const std::string& id, GNENet* net, const std::string& filename, SUMOVehicleClass vClass,
124 const std::vector<GNEEdge*>& edges, const RGBColor& color, const int repeat,
125 const SUMOTime cycleTime, const double probability, const Parameterised::Map& parameters) :
126 GNEDemandElement(id, net, filename, SUMO_TAG_ROUTE,
127 GNEPathElement::Options::DEMAND_ELEMENT | GNEPathElement::Options::ROUTE),
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 GNEPathElement::Options::DEMAND_ELEMENT | GNEPathElement::Options::ROUTE),
143 Parameterised(parameters),
144 myColor(color),
145 myRepeat(repeat),
146 myCycleTime(cycleTime),
147 myVClass(vehicleParent->getVClass()) {
148 // set parents
149 setParents<GNEEdge*>(edges);
150 setParent<GNEDemandElement*>(vehicleParent);
151}
152
153
155
156
158 return nullptr;
159}
160
161
164 return this;
165}
166
167
168const Parameterised*
170 return this;
171}
172
173
176 // create popup
177 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
178 // build common options
180 // show option to open demand element dialog
181 if (myTagProperty->hasDialog()) {
182 GUIDesigns::buildFXMenuCommand(ret, "Open " + getTagStr() + " Dialog", getACIcon(), &parent, MID_OPEN_ADDITIONAL_DIALOG);
183 new FXMenuSeparator(ret);
184 }
185 GUIDesigns::buildFXMenuCommand(ret, "Cursor position in view: " + toString(getPositionInView().x()) + "," + toString(getPositionInView().y()), nullptr, nullptr, 0);
186 new FXMenuSeparator(ret);
187 GUIDesigns::buildFXMenuCommand(ret, "Apply distance along route", nullptr, ret, MID_GNE_ROUTE_APPLY_DISTANCE);
188 // route length
191 // add reverse
193 }
194 return ret;
195}
196
197
198void
200 device.openTag(SUMO_TAG_ROUTE);
201 // write id only for non-embedded routes
203 device.writeAttr(SUMO_ATTR_ID, getID());
204 }
208 }
211 }
214 }
217 }
218 // write probability if we have exactly one routeRef
219 std::vector<GNEDemandElement*> refs;
220 for (const auto& routeChild : getChildDemandElements()) {
221 if (routeChild->getTagProperty()->getTag() == GNE_TAG_ROUTEREF) {
222 refs.push_back(routeChild);
223 }
224 }
225 // write sorted stops
227 // write stops
228 for (const auto& routeChild : getChildDemandElements()) {
229 if (routeChild->getTagProperty()->isVehicleStop()) {
230 routeChild->writeDemandElement(device);
231 }
232 }
233 }
234 // write parameters
235 writeParams(device);
236 // close tag
237 device.closeTag();
238}
239
240
243 // get sorted stops and check number
244 std::vector<GNEDemandElement*> stops;
245 for (const auto& routeChild : getChildDemandElements()) {
246 if (routeChild->getTagProperty()->isVehicleStop()) {
247 stops.push_back(routeChild);
248 }
249 }
250 // check stops
251 if (getInvalidStops().size() > 0) {
253 }
254 // check repeating
255 if (myRepeat > 0) {
256 // avoid repeat in routes with only one edge
257 if (getParentEdges().size() == 1) {
259 }
260 // check if front and last routes are connected
261 if (isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0) {
263 }
264 }
265 // check that exist a connection between every edge
266 if (isRouteValid(getParentEdges()).size() > 0) {
268 } else {
269 return Problem::OK;
270 }
271}
272
273
274std::string
276 // get sorted stops and check number
277 std::vector<GNEDemandElement*> stops;
278 for (const auto& routeChild : getChildDemandElements()) {
279 if (routeChild->getTagProperty()->isVehicleStop()) {
280 stops.push_back(routeChild);
281 }
282 }
283 const auto invalidStops = getInvalidStops();
284 if (invalidStops.size() > 0) {
285 return toString(invalidStops.size()) + " stops are outside of route (downstream)";
286 }
287 // check repeating
288 if (myRepeat > 0) {
289 // avoid repeat in routes with only one edge
290 if (getParentEdges().size() == 1) {
291 return TL("Cannot repeat in routes with only one edge");
292 }
293 // check if front and last routes is connected
294 if (isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0) {
295 return TL("Cannot repeat route; front and last edge aren't connected");
296 }
297 }
298 // return string with the problem obtained from isRouteValid
300}
301
302
303void
305 // currently the only solution is removing Route
306}
307
308
312 return getParentDemandElements().at(0)->getVClass();
313 } else {
314 return myVClass;
315 }
316}
317
318
319const RGBColor&
322 return myColor;
323 } else if ((getParentDemandElements().size() > 0) && (getParentDemandElements().front()->getColor() != RGBColor::INVISIBLE)) {
324 return getParentDemandElements().front()->getColor();
325 } else if ((getChildDemandElements().size() > 0) && (getChildDemandElements().front()->getColor() != RGBColor::INVISIBLE)) {
326 return getChildDemandElements().front()->getColor();
327 } else {
328 return RGBColor::YELLOW;
329 }
330}
331
332
333void
335 // compute geometry
337 // update child demand elements
338 for (const auto& demandElement : getChildDemandElements()) {
339 if (!demandElement->getTagProperty()->isVehicleStop()) {
340 demandElement->updateGeometry();
341 }
342 }
343}
344
345
350
351
352std::string
354 return getParentEdges().front()->getID();
355}
356
357
358double
362
363
366 Boundary routeBoundary;
367 // return the combination of all parent edges's boundaries
368 for (const auto& i : getParentEdges()) {
369 routeBoundary.add(i->getCenteringBoundary());
370 }
371 // check if is valid
372 if (routeBoundary.isInitialised()) {
373 return routeBoundary;
374 } else {
375 return Boundary(-0.1, -0.1, 0.1, 0.1);
376 }
377}
378
379
380void
381GNERoute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) {
382 // obtain new list of route edges
383 std::string newRouteEdges = getNewListOfParents(originalElement, newElement);
384 // update route edges
385 if (newRouteEdges.size() > 0) {
386 setAttribute(SUMO_ATTR_EDGES, newRouteEdges, undoList);
387 }
388}
389
390
391void
393 // Routes are drawn in drawLanePartialGL and drawJunctionPartialGL
394}
395
396
397void
399 // calculate path depending if is embedded
404 } else {
406 }
407 // if path is empty, then calculate path again using SVC_IGNORING
408 if (!myNet->getDemandPathManager()->isPathValid(this)) {
410 }
411}
412
413
414void
415GNERoute::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
416 // check conditions
421 // get exaggeration
422 const double exaggeration = getExaggeration(s);
423 // get detail level
424 const auto d = s.getDetailLevel(exaggeration);
425 // get embedded route flag
426 const bool embedded = (myTagProperty->getTag() == GNE_TAG_ROUTE_EMBEDDED);
427 // get route width
428 const double routeWidth = embedded ? s.widthSettings.embeddedRouteWidth : s.widthSettings.routeWidth;
429 // calculate startPos
430 const double geometryDepartPos = embedded ? (getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getParentDemandElements().at(0)->getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_LENGTH)) : -1;
431 // get endPos
432 const double geometryEndPos = embedded ? getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_ARRIVALPOS) : -1;
433 // declare path geometry
434 GUIGeometry routeGeometry;
435 // update pathGeometry depending of first and last segment
436 if (segment->isFirstSegment() && segment->isLastSegment()) {
437 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
438 geometryDepartPos,
440 geometryEndPos,
442 } else if (segment->isFirstSegment()) {
443 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
444 geometryDepartPos,
446 -1,
448 } else if (segment->isLastSegment()) {
449 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
450 -1,
452 geometryEndPos,
454 } else {
455 routeGeometry = segment->getLane()->getLaneGeometry();
456 }
457 // draw geometry only if we'rent in drawForObjectUnderCursor mode
459 // draw route partial lane
460 drawRoutePartialLane(s, d, segment, offsetFront, routeGeometry, exaggeration);
461 // draw name
464 }
465 // draw dotted contour
466 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
467 // show index over every edge
470 const double textSize = s.vehicleName.size / s.scale;
471 std::string label = toString(segment->getLaneIndex());
472 Position pos = segment->getLane()->getLaneShape().front() - Position(0, textSize * 1);
473 // use layer above all demand elements
475 }
476 }
477 // calculate contour
478 segment->getContour()->calculateContourExtrudedShape(s, d, this, routeGeometry.getShape(), getType(), routeWidth, exaggeration,
479 segment->isFirstSegment(), segment->isLastSegment(), 0, segment, segment->getLane()->getParentEdge());
480 // check if add this path element to redraw buffer
483 }
484 }
485}
486
487
488void
489GNERoute::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
490 // check conditions
495 // Obtain exaggeration of the draw
496 const double routeExaggeration = getExaggeration(s);
497 // get detail level
498 const auto d = s.getDetailLevel(routeExaggeration);
499 // get route width
501 // check if connection to next lane exist
502 const bool connectionExist = segment->getPreviousLane()->getLane2laneConnections().exist(segment->getNextLane());
503 // get geometry
504 const GUIGeometry& routeGeometry = connectionExist ? segment->getPreviousLane()->getLane2laneConnections().getLane2laneGeometry(segment->getNextLane()) :
505 GUIGeometry({segment->getPreviousLane()->getLaneShape().back(), segment->getNextLane()->getLaneShape().front()});
506 // draw geometry only if we'rent in drawForObjectUnderCursor mode
508 // draw route partial
509 drawRoutePartialJunction(s, d, offsetFront, routeGeometry, routeExaggeration);
510 // draw dotted contour
511 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
512 }
513 // calculate contour
514 segment->getContour()->calculateContourExtrudedShape(s, d, this, routeGeometry.getShape(), getType(), routeWidth, routeExaggeration,
515 false, false, 0, segment, segment->getJunction());
516 // check if add this path element to redraw buffer
519 }
520 }
521}
522
523
524GNELane*
527 return getParentEdges().front()->getLaneByAllowedVClass(SVC_PASSENGER);
528 } else {
529 return getParentDemandElements().at(0)->getFirstPathLane();
530 }
531}
532
533
534GNELane*
537 return getParentEdges().back()->getLaneByAllowedVClass(SVC_PASSENGER);
538 } else {
539 return getParentDemandElements().at(0)->getLastPathLane();
540 }
541}
542
543
544std::string
546 switch (key) {
547 case SUMO_ATTR_ID:
548 return getMicrosimID();
549 case SUMO_ATTR_EDGES:
550 return parseIDs(getParentEdges());
551 case SUMO_ATTR_COLOR:
553 return toString(myColor);
554 } else {
555 return "";
556 }
557 case SUMO_ATTR_REPEAT:
558 return toString(myRepeat);
560 return time2string(myCycleTime);
561 case SUMO_ATTR_PROB:
562 return toString(myProbability);
563 default:
564 return getCommonAttribute(key);
565 }
566}
567
568
569double
571 switch (key) {
573 return 0;
575 return getParentEdges().back()->getChildLanes().front()->getLaneShape().length2D();
576 case SUMO_ATTR_PROB:
577 return myProbability;
578 default:
579 return getCommonAttributeDouble(key);
580 }
581}
582
583
586 switch (key) {
588 return getParentEdges().front()->getChildLanes().front()->getLaneShape().front();
590 return getParentEdges().back()->getChildLanes().front()->getLaneShape().back();
591 default:
592 return getCommonAttributePosition(key);
593 }
594}
595
596
597void
598GNERoute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
599 if (value == getAttribute(key)) {
600 return; //avoid needless changes, later logic relies on the fact that attributes have changed
601 }
602 switch (key) {
603 case SUMO_ATTR_ID:
604 case SUMO_ATTR_COLOR:
605 case SUMO_ATTR_REPEAT:
607 case SUMO_ATTR_PROB:
608 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
609 break;
610 // special case due depart and arrival edge vehicles
611 case SUMO_ATTR_EDGES: {
612 // extract all vehicle childrens
613 std::vector<GNEDemandElement*> vehicles;
614 for (const auto& childDemandElement : getChildDemandElements()) {
615 if (childDemandElement->getTagProperty()->isVehicle()) {
616 vehicles.push_back(childDemandElement);
617 }
618 }
619 // check vehicles
620 if (vehicles.size() > 0) {
621 undoList->begin(this, "reset start and end edges");
622 for (const auto& vehicle : vehicles) {
625 }
626 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
627 undoList->end();
629 undoList->begin(this, "reset start and end edges");
632 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
633 undoList->end();
634 } else {
635 // just change edges
636 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
637 }
638 break;
639 }
640 default:
641 setCommonAttribute(key, value, undoList);
642 break;
643 }
644}
645
646
647bool
648GNERoute::isValid(SumoXMLAttr key, const std::string& value) {
649 switch (key) {
650 case SUMO_ATTR_ID:
651 return isValidDemandElementID(value);
652 case SUMO_ATTR_EDGES:
653 if (value.empty()) {
654 return false;
655 } else {
656 return canParse<std::vector<GNEEdge*> >(myNet, value, true);
657 }
658 case SUMO_ATTR_COLOR:
659 if (value.empty()) {
660 return true;
661 } else {
662 return canParse<RGBColor>(value);
663 }
664 case SUMO_ATTR_REPEAT:
665 return canParse<int>(value) && (parse<int>(value) >= 0);
667 if (canParse<SUMOTime>(value)) {
668 return (parse<SUMOTime>(value) >= 0);
669 } else {
670 return false;
671 }
672 case SUMO_ATTR_PROB:
673 if (canParse<double>(value)) {
674 return (parse<double>(value) >= 0);
675 } else {
676 return false;
677 }
678 default:
679 return isCommonAttributeValid(key, value);
680 }
681}
682
683
684std::string
686 return getTagStr();
687}
688
689
690std::string
692 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) ;
693}
694
695
696std::string
697GNERoute::isRouteValid(const std::vector<GNEEdge*>& edges) {
698 if (edges.size() == 0) {
699 // routes cannot be empty
700 return ("list of route edges cannot be empty");
701 } else if (edges.size() == 1) {
702 // routes with a single edge are valid, then return an empty string
703 return ("");
704 } else {
705 // iterate over edges to check that compounds a chain
706 auto it = edges.begin();
707 while (it != edges.end() - 1) {
708 const GNEEdge* currentEdge = *it;
709 const GNEEdge* nextEdge = *(it + 1);
710 // same consecutive edges aren't allowed
711 if (currentEdge->getID() == nextEdge->getID()) {
712 return ("consecutive duplicated edges (" + currentEdge->getID() + ") aren't allowed in a route");
713 }
714 // obtain outgoing edges of currentEdge
715 const std::vector<GNEEdge*>& outgoingEdges = currentEdge->getToJunction()->getGNEOutgoingEdges();
716 // check if nextEdge is in outgoingEdges
717 if (std::find(outgoingEdges.begin(), outgoingEdges.end(), nextEdge) == outgoingEdges.end()) {
718 return ("Edges '" + currentEdge->getID() + "' and '" + nextEdge->getID() + "' aren't consecutives");
719 }
720 it++;
721 }
722 // all edges consecutives, then return an empty string
723 return ("");
724 }
725}
726
728GNERoute::copyRoute(const GNERoute* originalRoute) {
729 // get net and undoList
730 const auto net = originalRoute->getNet();
731 auto undoList = net->getViewNet()->getUndoList();
732 // generate new route ID
733 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
734 // create new route
735 GNERoute* newRoute = new GNERoute(newRouteID, originalRoute);
736 // add new route using undo-list
737 undoList->begin(originalRoute, TLF("copy % '%'", originalRoute->getTagStr(), newRouteID));
738 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
739 undoList->end();
740 // return new route
741 return newRoute;
742}
743
744// ===========================================================================
745// private
746// ===========================================================================
747
748void
750 const GNESegment* segment, const double offsetFront,
751 const GUIGeometry& geometry, const double exaggeration) const {
752 // get route width
754 // push layer matrix
756 // Start with the drawing of the area traslating matrix to origin
757 glTranslated(0, 0, getType() + offsetFront);
758 // Set color
759 if (drawUsingSelectColor()) {
761 } else {
763 }
764 // draw geometry
765 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
766 // check if we have to draw a red line to the next segment
767 if (segment->getNextLane()) {
768 // push draw matrix
770 // Set red color
772 // get firstPosition (last position of current lane shape)
773 const Position firstPosition = segment->getLane()->getLaneShape().back();
774 // get lastPosition (first position of next lane shape)
775 const Position arrivalPos = segment->getNextLane()->getLaneShape().front();
776 // draw box line
777 GLHelper::drawBoxLine(arrivalPos,
778 RAD2DEG(firstPosition.angleTo2D(arrivalPos)) - 90,
779 firstPosition.distanceTo2D(arrivalPos), .05);
780 // pop draw matrix
782 }
783 // Pop layer matrix
785}
786
787
788void
790 const double offsetFront, const GUIGeometry& geometry, const double exaggeration) const {
791 const bool invalid = geometry.getShape().length() == 2;
792 // get route width
794 // Add a draw matrix
796 // Start with the drawing of the area traslating matrix to origin
797 glTranslated(0, 0, getType() + offsetFront);
798 // Set color of the base
799 if (drawUsingSelectColor()) {
801 } else if (invalid) {
803 } else {
805 }
806 // draw geometry
807 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
808 // Pop last matrix
810}
811
812
813void
814GNERoute::setAttribute(SumoXMLAttr key, const std::string& value) {
815 switch (key) {
816 case SUMO_ATTR_ID:
817 // update microsimID
818 setDemandElementID(value);
819 break;
820 case SUMO_ATTR_EDGES:
821 // replace parents
822 replaceParentEdges(value);
823 // compute route
825 // update all parent and child demand elements
826 for (const auto& element : getParentDemandElements()) {
827 element->updateGeometry();
828 }
829 for (const auto& element : getChildDemandElements()) {
830 element->updateGeometry();
831 }
832 break;
833 case SUMO_ATTR_COLOR:
834 if (value.empty()) {
836 } else {
837 myColor = parse<RGBColor>(value);
838 }
839 break;
840 case SUMO_ATTR_REPEAT:
841 if (value.empty()) {
843 } else {
844 myRepeat = parse<int>(value);
845 }
846 break;
848 if (value.empty()) {
850 } else {
851 myCycleTime = string2time(value);
852 }
853 break;
854 case SUMO_ATTR_PROB:
855 if (value.empty()) {
857 } else {
858 myProbability = parse<double>(value);
859 }
860 break;
861 default:
862 setCommonAttribute(key, value);
863 break;
864 }
865}
866
867
868bool
871 // this affect only to embedded routes
872 return true;
874 // only in demand mode
875 return true;
877 // only creating vehicles
878 return true;
879 } else {
880 // get current template AC
882 if (templateAC && templateAC->getTagProperty()->vehicleRoute()) {
883 // we're creating a vehicle over a route, then hidde all embedded routes
884 return false;
885 } else {
886 return true;
887 }
888 }
889}
890
891
892/****************************************************************************/
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:471
@ 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:304
#define TLF(string,...)
Definition MsgHandler.h:306
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:91
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:46
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:232
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:666
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition GNELane.cpp:337
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:226
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:214
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:174
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
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:57
long onCmdApplyDistance(FXObject *, FXSelector, void *)
Called to modify edge distance values along the route.
Definition GNERoute.cpp:61
bool isValid(SumoXMLAttr key, const std::string &value) override
Definition GNERoute.cpp:648
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this route
Definition GNERoute.cpp:157
GNELane * getLastPathLane() const override
get last path lane
Definition GNERoute.cpp:535
std::string getParentName() const override
Returns the name of the parent object.
Definition GNERoute.cpp:353
std::string getAttribute(SumoXMLAttr key) const override
inherited from GNEAttributeCarrier
Definition GNERoute.cpp:545
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:869
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNERoute.cpp:570
SUMOTime myCycleTime
cycleTime
Definition GNERoute.h:276
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNERoute.cpp:691
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:242
void writeDemandElement(OutputDevice &device) const override
write demand element element into a xml file
Definition GNERoute.cpp:199
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNERoute.cpp:175
void updateGeometry() override
update pre-computed geometry information
Definition GNERoute.cpp:334
Parameterised * getParameters() override
get parameters associated with this route
Definition GNERoute.cpp:163
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:789
void computePathElement() override
compute pathElement
Definition GNERoute.cpp:398
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition GNERoute.cpp:359
void fixDemandElementProblem() override
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition GNERoute.cpp:304
static GNEDemandElement * copyRoute(const GNERoute *originalRoute)
create a copy of the given route
Definition GNERoute.cpp:728
Position getAttributePosition(SumoXMLAttr key) const override
Definition GNERoute.cpp:585
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const override
Draws partial object over lane.
Definition GNERoute.cpp:415
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNERoute.cpp:392
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNERoute.cpp:685
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:275
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:749
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNERoute.cpp:381
const RGBColor & getColor() const override
get color
Definition GNERoute.cpp:320
GNERoute(SumoXMLTag tag, GNENet *net)
default constructor
Definition GNERoute.cpp:78
SUMOVehicleClass getVClass() const override
obtain VClass related with this demand element
Definition GNERoute.cpp:310
static std::string isRouteValid(const std::vector< GNEEdge * > &edges)
check if a route is valid
Definition GNERoute.cpp:697
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:489
GNELane * getFirstPathLane() const override
get first path lane
Definition GNERoute.cpp:525
RGBColor myColor
route color
Definition GNERoute.h:270
~GNERoute()
destructor
Definition GNERoute.cpp:154
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNERoute.cpp:365
Position getPositionInView() const override
Returns position of additional in view.
Definition GNERoute.cpp:347
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
Definition GNERoute.cpp:598
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
GNEViewParent * getViewParent() const
get the net object
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.
void buildPopUpMenuCommonOptions(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, GUISUMOAbstractView *parent, const SumoXMLTag tag, const bool selected, bool addSeparator=true)
virtual Position getCenter() const
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 & 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.
An upper class for objects with additional parameters.
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: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:191
static const RGBColor INVISIBLE
Definition RGBColor.h:198
static const RGBColor RED
named colors
Definition RGBColor.h:188
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