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->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
79 GNEDemandElement(net, tag) {
80}
81
82
84 GNEDemandElement(calibrator->getNet()->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE),
85 calibrator->getNet(), SUMO_TAG_ROUTE, calibrator->getFileBucket()) {
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->getTagProperty()->getTag(), originalRoute->getFileBucket()),
99 Parameterised(originalRoute->getParameters()->getParametersMap()),
100 myRepeat(parse<int>(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
101 myCycleTime(string2time(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
102 myVClass(originalRoute->getVClass()) {
103 // set parents
104 setParents<GNEEdge*>(originalRoute->getParentEdges());
106}
107
108
109GNERoute::GNERoute(GNEVehicle* vehicleParent, const GNEDemandElement* originalRoute) :
110 GNEDemandElement(vehicleParent, originalRoute->getTagProperty()->getTag()),
111 Parameterised(originalRoute->getParameters()->getParametersMap()),
112 myRepeat(parse<int>(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
113 myCycleTime(string2time(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
114 myVClass(originalRoute->getVClass()) {
115 // set parents
116 setParents<GNEEdge*>(originalRoute->getParentEdges());
117 setParent<GNEDemandElement*>(vehicleParent);
119}
120
121
122GNERoute::GNERoute(const std::string& id, GNENet* net, FileBucket* fileBucket, SUMOVehicleClass vClass,
123 const std::vector<GNEEdge*>& edges, const RGBColor& color, const int repeat,
124 const SUMOTime cycleTime, const double probability, const Parameterised::Map& parameters) :
125 GNEDemandElement(id, net, SUMO_TAG_ROUTE, fileBucket),
126 Parameterised(parameters),
127 myColor(color),
128 myRepeat(repeat),
129 myCycleTime(cycleTime),
130 myProbability(probability),
131 myVClass(vClass) {
132 // set parents
133 setParents<GNEEdge*>(edges);
134}
135
136
137GNERoute::GNERoute(GNEDemandElement* vehicleParent, const std::vector<GNEEdge*>& edges, const RGBColor& color,
138 const int repeat, const SUMOTime cycleTime, const Parameterised::Map& parameters) :
140 Parameterised(parameters),
141 myColor(color),
142 myRepeat(repeat),
143 myCycleTime(cycleTime),
144 myVClass(vehicleParent->getVClass()) {
145 // set parents
146 setParents<GNEEdge*>(edges);
147 setParent<GNEDemandElement*>(vehicleParent);
148}
149
150
152
153
155 return nullptr;
156}
157
158
161 return this;
162}
163
164
165const Parameterised*
167 return this;
168}
169
170
173 // create popup
174 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
175 // build common options
177 // show option to open demand element dialog
178 if (myTagProperty->hasDialog()) {
179 GUIDesigns::buildFXMenuCommand(ret, "Open " + getTagStr() + " Dialog", getACIcon(), &parent, MID_OPEN_ADDITIONAL_DIALOG);
180 new FXMenuSeparator(ret);
181 }
182 GUIDesigns::buildFXMenuCommand(ret, "Cursor position in view: " + toString(getPositionInView().x()) + "," + toString(getPositionInView().y()), nullptr, nullptr, 0);
183 new FXMenuSeparator(ret);
184 GUIDesigns::buildFXMenuCommand(ret, "Apply distance along route", nullptr, ret, MID_GNE_ROUTE_APPLY_DISTANCE);
185 // route length
188 // add reverse
190 }
191 return ret;
192}
193
194
195void
197 device.openTag(SUMO_TAG_ROUTE);
198 // write id only for non-embedded routes
200 device.writeAttr(SUMO_ATTR_ID, getID());
201 }
205 }
208 }
211 }
214 }
215 // write probability if we have exactly one routeRef
216 std::vector<GNEDemandElement*> refs;
217 for (const auto& routeChild : getChildDemandElements()) {
218 if (routeChild->getTagProperty()->getTag() == GNE_TAG_ROUTEREF) {
219 refs.push_back(routeChild);
220 }
221 }
222 // write sorted stops
224 // write stops
225 for (const auto& routeChild : getChildDemandElements()) {
226 if (routeChild->getTagProperty()->isVehicleStop()) {
227 routeChild->writeDemandElement(device);
228 }
229 }
230 }
231 // write parameters
232 writeParams(device);
233 // close tag
234 device.closeTag();
235}
236
237
240 // get sorted stops and check number
241 std::vector<GNEDemandElement*> stops;
242 for (const auto& routeChild : getChildDemandElements()) {
243 if (routeChild->getTagProperty()->isVehicleStop()) {
244 stops.push_back(routeChild);
245 }
246 }
247 // check stops
248 if (getInvalidStops().size() > 0) {
250 }
251 // check repeating
252 if (myRepeat > 0) {
253 // avoid repeat in routes with only one edge
254 if (getParentEdges().size() == 1) {
256 }
257 // check if front and last routes are connected
258 if (isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0) {
260 }
261 }
262 // check that exist a connection between every edge
263 if (isRouteValid(getParentEdges()).size() > 0) {
265 } else {
266 return Problem::OK;
267 }
268}
269
270
271std::string
273 // get sorted stops and check number
274 std::vector<GNEDemandElement*> stops;
275 for (const auto& routeChild : getChildDemandElements()) {
276 if (routeChild->getTagProperty()->isVehicleStop()) {
277 stops.push_back(routeChild);
278 }
279 }
280 const auto invalidStops = getInvalidStops();
281 if (invalidStops.size() > 0) {
282 return toString(invalidStops.size()) + " stops are outside of route (downstream)";
283 }
284 // check repeating
285 if (myRepeat > 0) {
286 // avoid repeat in routes with only one edge
287 if (getParentEdges().size() == 1) {
288 return TL("Cannot repeat in routes with only one edge");
289 }
290 // check if front and last routes is connected
291 if (isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0) {
292 return TL("Cannot repeat route; front and last edge aren't connected");
293 }
294 }
295 // return string with the problem obtained from isRouteValid
297}
298
299
300void
302 // currently the only solution is removing Route
303}
304
305
309 return getParentDemandElements().at(0)->getVClass();
310 } else {
311 return myVClass;
312 }
313}
314
315
316const RGBColor&
319 return myColor;
320 } else if ((getParentDemandElements().size() > 0) && (getParentDemandElements().front()->getColor() != RGBColor::INVISIBLE)) {
321 return getParentDemandElements().front()->getColor();
322 } else if ((getChildDemandElements().size() > 0) && (getChildDemandElements().front()->getColor() != RGBColor::INVISIBLE)) {
323 return getChildDemandElements().front()->getColor();
324 } else {
325 return RGBColor::YELLOW;
326 }
327}
328
329
330void
332 // compute geometry
334 // update child demand elements
335 for (const auto& demandElement : getChildDemandElements()) {
336 if (!demandElement->getTagProperty()->isVehicleStop()) {
337 demandElement->updateGeometry();
338 }
339 }
340}
341
342
347
348
349std::string
351 return getParentEdges().front()->getID();
352}
353
354
355double
359
360
363 Boundary routeBoundary;
364 // return the combination of all parent edges's boundaries
365 for (const auto& i : getParentEdges()) {
366 routeBoundary.add(i->getCenteringBoundary());
367 }
368 // check if is valid
369 if (routeBoundary.isInitialised()) {
370 return routeBoundary;
371 } else {
372 return Boundary(-0.1, -0.1, 0.1, 0.1);
373 }
374}
375
376
377void
378GNERoute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) {
379 // obtain new list of route edges
380 std::string newRouteEdges = getNewListOfParents(originalElement, newElement);
381 // update route edges
382 if (newRouteEdges.size() > 0) {
383 setAttribute(SUMO_ATTR_EDGES, newRouteEdges, undoList);
384 }
385}
386
387
388void
390 // Routes are drawn in drawLanePartialGL and drawJunctionPartialGL
391}
392
393
394void
396 // calculate path depending if is embedded
401 } else {
403 }
404 // if path is empty, then calculate path again using SVC_IGNORING
405 if (!myNet->getDemandPathManager()->isPathValid(this)) {
407 }
408}
409
410
411void
412GNERoute::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
413 // check conditions
418 // get exaggeration
419 const double exaggeration = getExaggeration(s);
420 // get detail level
421 const auto d = s.getDetailLevel(exaggeration);
422 // get embedded route flag
423 const bool embedded = (myTagProperty->getTag() == GNE_TAG_ROUTE_EMBEDDED);
424 // get route width
425 const double routeWidth = embedded ? s.widthSettings.embeddedRouteWidth : s.widthSettings.routeWidth;
426 // calculate startPos
427 const double geometryDepartPos = embedded ? (getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getParentDemandElements().at(0)->getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_LENGTH)) : -1;
428 // get endPos
429 const double geometryEndPos = embedded ? getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_ARRIVALPOS) : -1;
430 // declare path geometry
431 GUIGeometry routeGeometry;
432 // update pathGeometry depending of first and last segment
433 if (segment->isFirstSegment() && segment->isLastSegment()) {
434 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
435 geometryDepartPos,
437 geometryEndPos,
439 } else if (segment->isFirstSegment()) {
440 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
441 geometryDepartPos,
443 -1,
445 } else if (segment->isLastSegment()) {
446 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
447 -1,
449 geometryEndPos,
451 } else {
452 routeGeometry = segment->getLane()->getLaneGeometry();
453 }
454 // draw geometry only if we'rent in drawForObjectUnderCursor mode
456 // draw route partial lane
457 drawRoutePartialLane(s, d, segment, offsetFront, routeGeometry, exaggeration);
458 // draw name
461 }
462 // draw dotted contour
463 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
464 // show index over every edge
467 const double textSize = s.vehicleName.size / s.scale;
468 std::string label = toString(segment->getLaneIndex());
469 Position pos = segment->getLane()->getLaneShape().front() - Position(0, textSize * 1);
470 // use layer above all demand elements
472 }
473 }
474 // calculate contour
475 segment->getContour()->calculateContourExtrudedShape(s, d, this, routeGeometry.getShape(), getType(), routeWidth, exaggeration,
476 segment->isFirstSegment(), segment->isLastSegment(), 0, segment, segment->getLane()->getParentEdge());
477 // check if add this path element to redraw buffer
480 }
481 }
482}
483
484
485void
486GNERoute::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
487 // check conditions
492 // Obtain exaggeration of the draw
493 const double routeExaggeration = getExaggeration(s);
494 // get detail level
495 const auto d = s.getDetailLevel(routeExaggeration);
496 // get route width
498 // check if connection to next lane exist
499 const bool connectionExist = segment->getPreviousLane()->getLane2laneConnections().exist(segment->getNextLane());
500 // get geometry
501 const GUIGeometry& routeGeometry = connectionExist ? segment->getPreviousLane()->getLane2laneConnections().getLane2laneGeometry(segment->getNextLane()) :
502 GUIGeometry({segment->getPreviousLane()->getLaneShape().back(), segment->getNextLane()->getLaneShape().front()});
503 // draw geometry only if we'rent in drawForObjectUnderCursor mode
505 // draw route partial
506 drawRoutePartialJunction(s, d, offsetFront, routeGeometry, routeExaggeration);
507 // draw dotted contour
508 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
509 }
510 // calculate contour
511 segment->getContour()->calculateContourExtrudedShape(s, d, this, routeGeometry.getShape(), getType(), routeWidth, routeExaggeration,
512 false, false, 0, segment, segment->getJunction());
513 // check if add this path element to redraw buffer
516 }
517 }
518}
519
520
521GNELane*
524 return getParentEdges().front()->getLaneByAllowedVClass(SVC_PASSENGER);
525 } else {
526 return getParentDemandElements().at(0)->getFirstPathLane();
527 }
528}
529
530
531GNELane*
534 return getParentEdges().back()->getLaneByAllowedVClass(SVC_PASSENGER);
535 } else {
536 return getParentDemandElements().at(0)->getLastPathLane();
537 }
538}
539
540
541std::string
543 switch (key) {
544 case SUMO_ATTR_ID:
545 return getMicrosimID();
546 case SUMO_ATTR_EDGES:
547 return parseIDs(getParentEdges());
548 case SUMO_ATTR_COLOR:
550 return toString(myColor);
551 } else {
552 return "";
553 }
554 case SUMO_ATTR_REPEAT:
555 return toString(myRepeat);
557 return time2string(myCycleTime);
558 case SUMO_ATTR_PROB:
559 return toString(myProbability);
560 default:
561 return getCommonAttribute(key);
562 }
563}
564
565
566double
568 switch (key) {
570 return 0;
572 return getParentEdges().back()->getChildLanes().front()->getLaneShape().length2D();
573 case SUMO_ATTR_PROB:
574 return myProbability;
575 default:
576 return getCommonAttributeDouble(key);
577 }
578}
579
580
583 switch (key) {
585 return getParentEdges().front()->getChildLanes().front()->getLaneShape().front();
587 return getParentEdges().back()->getChildLanes().front()->getLaneShape().back();
588 default:
589 return getCommonAttributePosition(key);
590 }
591}
592
593
594void
595GNERoute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
596 if (value == getAttribute(key)) {
597 return; //avoid needless changes, later logic relies on the fact that attributes have changed
598 }
599 switch (key) {
600 case SUMO_ATTR_ID:
601 case SUMO_ATTR_COLOR:
602 case SUMO_ATTR_REPEAT:
604 case SUMO_ATTR_PROB:
605 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
606 break;
607 // special case due depart and arrival edge vehicles
608 case SUMO_ATTR_EDGES: {
609 // extract all vehicle childrens
610 std::vector<GNEDemandElement*> vehicles;
611 for (const auto& childDemandElement : getChildDemandElements()) {
612 if (childDemandElement->getTagProperty()->isVehicle()) {
613 vehicles.push_back(childDemandElement);
614 }
615 }
616 // check vehicles
617 if (vehicles.size() > 0) {
618 undoList->begin(this, "reset start and end edges");
619 for (const auto& vehicle : vehicles) {
622 }
623 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
624 undoList->end();
626 undoList->begin(this, "reset start and end edges");
629 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
630 undoList->end();
631 } else {
632 // just change edges
633 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
634 }
635 break;
636 }
637 default:
638 setCommonAttribute(key, value, undoList);
639 break;
640 }
641}
642
643
644bool
645GNERoute::isValid(SumoXMLAttr key, const std::string& value) {
646 switch (key) {
647 case SUMO_ATTR_ID:
648 return isValidDemandElementID(value);
649 case SUMO_ATTR_EDGES:
650 if (value.empty()) {
651 return false;
652 } else {
653 return canParse<std::vector<GNEEdge*> >(myNet, value, true);
654 }
655 case SUMO_ATTR_COLOR:
656 if (value.empty()) {
657 return true;
658 } else {
659 return canParse<RGBColor>(value);
660 }
661 case SUMO_ATTR_REPEAT:
662 return canParse<int>(value) && (parse<int>(value) >= 0);
664 if (canParse<SUMOTime>(value)) {
665 return (parse<SUMOTime>(value) >= 0);
666 } else {
667 return false;
668 }
669 case SUMO_ATTR_PROB:
670 if (canParse<double>(value)) {
671 return (parse<double>(value) >= 0);
672 } else {
673 return false;
674 }
675 default:
676 return isCommonAttributeValid(key, value);
677 }
678}
679
680
681std::string
683 return getTagStr();
684}
685
686
687std::string
689 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) ;
690}
691
692
693std::string
694GNERoute::isRouteValid(const std::vector<GNEEdge*>& edges) {
695 if (edges.size() == 0) {
696 // routes cannot be empty
697 return ("list of route edges cannot be empty");
698 } else if (edges.size() == 1) {
699 // routes with a single edge are valid, then return an empty string
700 return ("");
701 } else {
702 // iterate over edges to check that compounds a chain
703 auto it = edges.begin();
704 while (it != edges.end() - 1) {
705 const GNEEdge* currentEdge = *it;
706 const GNEEdge* nextEdge = *(it + 1);
707 // same consecutive edges aren't allowed
708 if (currentEdge->getID() == nextEdge->getID()) {
709 return ("consecutive duplicated edges (" + currentEdge->getID() + ") aren't allowed in a route");
710 }
711 // obtain outgoing edges of currentEdge
712 const std::vector<GNEEdge*>& outgoingEdges = currentEdge->getToJunction()->getGNEOutgoingEdges();
713 // check if nextEdge is in outgoingEdges
714 if (std::find(outgoingEdges.begin(), outgoingEdges.end(), nextEdge) == outgoingEdges.end()) {
715 return ("Edges '" + currentEdge->getID() + "' and '" + nextEdge->getID() + "' aren't consecutives");
716 }
717 it++;
718 }
719 // all edges consecutives, then return an empty string
720 return ("");
721 }
722}
723
725GNERoute::copyRoute(const GNERoute* originalRoute) {
726 // get net and undoList
727 const auto net = originalRoute->getNet();
728 auto undoList = net->getViewNet()->getUndoList();
729 // generate new route ID
730 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
731 // create new route
732 GNERoute* newRoute = new GNERoute(newRouteID, originalRoute);
733 // add new route using undo-list
734 undoList->begin(originalRoute, TLF("copy % '%'", originalRoute->getTagStr(), newRouteID));
735 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
736 undoList->end();
737 // return new route
738 return newRoute;
739}
740
741// ===========================================================================
742// private
743// ===========================================================================
744
745void
747 const GNESegment* segment, const double offsetFront,
748 const GUIGeometry& geometry, const double exaggeration) const {
749 // get route width
751 // push layer matrix
753 // Start with the drawing of the area traslating matrix to origin
754 glTranslated(0, 0, getType() + offsetFront);
755 // Set color
756 if (drawUsingSelectColor()) {
758 } else {
760 }
761 // draw geometry
762 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
763 // check if we have to draw a red line to the next segment
764 if (segment->getNextLane()) {
765 // push draw matrix
767 // Set red color
769 // get firstPosition (last position of current lane shape)
770 const Position firstPosition = segment->getLane()->getLaneShape().back();
771 // get lastPosition (first position of next lane shape)
772 const Position arrivalPos = segment->getNextLane()->getLaneShape().front();
773 // draw box line
774 GLHelper::drawBoxLine(arrivalPos,
775 RAD2DEG(firstPosition.angleTo2D(arrivalPos)) - 90,
776 firstPosition.distanceTo2D(arrivalPos), .05);
777 // pop draw matrix
779 }
780 // Pop layer matrix
782}
783
784
785void
787 const double offsetFront, const GUIGeometry& geometry, const double exaggeration) const {
788 const bool invalid = geometry.getShape().length() == 2;
789 // get route width
791 // Add a draw matrix
793 // Start with the drawing of the area traslating matrix to origin
794 glTranslated(0, 0, getType() + offsetFront);
795 // Set color of the base
796 if (drawUsingSelectColor()) {
798 } else if (invalid) {
800 } else {
802 }
803 // draw geometry
804 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
805 // Pop last matrix
807}
808
809
810void
811GNERoute::setAttribute(SumoXMLAttr key, const std::string& value) {
812 switch (key) {
813 case SUMO_ATTR_ID:
814 // update microsimID
815 setDemandElementID(value);
816 break;
817 case SUMO_ATTR_EDGES:
818 // replace parents
819 replaceParentEdges(value);
820 // compute route
822 // update all parent and child demand elements
823 for (const auto& element : getParentDemandElements()) {
824 element->updateGeometry();
825 }
826 for (const auto& element : getChildDemandElements()) {
827 element->updateGeometry();
828 }
829 break;
830 case SUMO_ATTR_COLOR:
831 if (value.empty()) {
833 } else {
834 myColor = parse<RGBColor>(value);
835 }
836 break;
837 case SUMO_ATTR_REPEAT:
838 if (value.empty()) {
840 } else {
841 myRepeat = parse<int>(value);
842 }
843 break;
845 if (value.empty()) {
847 } else {
848 myCycleTime = string2time(value);
849 }
850 break;
851 case SUMO_ATTR_PROB:
852 if (value.empty()) {
854 } else {
855 myProbability = parse<double>(value);
856 }
857 break;
858 default:
859 setCommonAttribute(key, value);
860 break;
861 }
862}
863
864
865bool
868 // this affect only to embedded routes
869 return true;
871 // only in demand mode
872 return true;
874 // only creating vehicles
875 return true;
876 } else {
877 // get current template AC
879 if (templateAC && templateAC->getTagProperty()->vehicleRoute()) {
880 // we're creating a vehicle over a route, then hidde all embedded routes
881 return false;
882 } else {
883 return true;
884 }
885 }
886}
887
888
889/****************************************************************************/
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
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: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:645
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this route
Definition GNERoute.cpp:154
GNELane * getLastPathLane() const override
get last path lane
Definition GNERoute.cpp:532
std::string getParentName() const override
Returns the name of the parent object.
Definition GNERoute.cpp:350
std::string getAttribute(SumoXMLAttr key) const override
inherited from GNEAttributeCarrier
Definition GNERoute.cpp:542
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:866
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNERoute.cpp:567
SUMOTime myCycleTime
cycleTime
Definition GNERoute.h:276
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
Definition GNERoute.cpp:688
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:239
void writeDemandElement(OutputDevice &device) const override
write demand element element into a xml file
Definition GNERoute.cpp:196
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNERoute.cpp:172
void updateGeometry() override
update pre-computed geometry information
Definition GNERoute.cpp:331
Parameterised * getParameters() override
get parameters associated with this route
Definition GNERoute.cpp:160
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:786
void computePathElement() override
compute pathElement
Definition GNERoute.cpp:395
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition GNERoute.cpp:356
void fixDemandElementProblem() override
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition GNERoute.cpp:301
static GNEDemandElement * copyRoute(const GNERoute *originalRoute)
create a copy of the given route
Definition GNERoute.cpp:725
Position getAttributePosition(SumoXMLAttr key) const override
Definition GNERoute.cpp:582
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const override
Draws partial object over lane.
Definition GNERoute.cpp:412
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNERoute.cpp:389
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
Definition GNERoute.cpp:682
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:272
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:746
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Definition GNERoute.cpp:378
const RGBColor & getColor() const override
get color
Definition GNERoute.cpp:317
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:307
static std::string isRouteValid(const std::vector< GNEEdge * > &edges)
check if a route is valid
Definition GNERoute.cpp:694
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:486
GNELane * getFirstPathLane() const override
get first path lane
Definition GNERoute.cpp:522
RGBColor myColor
route color
Definition GNERoute.h:270
~GNERoute()
destructor
Definition GNERoute.cpp:151
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNERoute.cpp:362
Position getPositionInView() const override
Returns position of additional in view.
Definition GNERoute.cpp:344
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
Definition GNERoute.cpp:595
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.
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