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-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// A class for visualizing routes in Netedit
19/****************************************************************************/
20
21#include <netedit/GNENet.h>
22#include <netedit/GNEUndoList.h>
23#include <netedit/GNEViewNet.h>
32
33#include "GNERoute.h"
34#include "GNEVehicle.h"
35
36// ===========================================================================
37// FOX callback mapping
38// ===========================================================================
42
43// Object implementation
44FXIMPLEMENT(GNERoute::GNERoutePopupMenu, GUIGLObjectPopupMenu, GNERoutePopupMenuMap, ARRAYNUMBER(GNERoutePopupMenuMap))
45
46// ===========================================================================
47// GNERoute::GNERoutePopupMenu - methods
48// ===========================================================================
49
53
54
56
57
58long
60 GNERoute* route = static_cast<GNERoute*>(myObject);
61 GNEUndoList* undoList = route->myNet->getViewNet()->getUndoList();
62 undoList->begin(route, "apply distance along route");
63 double dist = (route->getParentEdges().size() > 0) ? route->getParentEdges().front()->getNBEdge()->getDistance() : 0;
64 for (GNEEdge* edge : route->getParentEdges()) {
66 dist += edge->getNBEdge()->getFinalLength();
67 }
68 undoList->end();
69 return 1;
70}
71
72// ===========================================================================
73// GNERoute - methods
74// ===========================================================================
75
77 GNEDemandElement("", net, GLO_ROUTE, tag, GUIIconSubSys::getIcon(GUIIcon::ROUTE),
79{}, {}, {}, {}, {}, {}),
81myColor(RGBColor::YELLOW),
82myRepeat(0),
83myCycleTime(0),
84myVClass(SVC_PASSENGER) {
85 // reset default values
86 resetDefaultValues();
87}
88
89
91 GNEDemandElement(net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE), net, GLO_ROUTE, SUMO_TAG_ROUTE,
92 GUIIconSubSys::getIcon(GUIIcon::ROUTE),
93 GNEPathManager::PathElement::Options::DEMAND_ELEMENT | GNEPathManager::PathElement::Options::ROUTE,
94{}, {}, {}, {}, {}, {}),
96myColor(RGBColor::YELLOW),
97myRepeat(0),
98myCycleTime(0),
99myVClass(SVC_PASSENGER) {
100 // reset default values
101 resetDefaultValues();
102}
103
104
105GNERoute::GNERoute(GNENet* net, const std::string& id, const GNEDemandElement* originalRoute) :
107 GNEPathManager::PathElement::Options::DEMAND_ELEMENT | GNEPathManager::PathElement::Options::ROUTE,
108{}, originalRoute->getParentEdges(), {}, {}, {}, {}),
109Parameterised(originalRoute->getACParametersMap()),
110myRepeat(parse<int>(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
111myCycleTime(string2time(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
112myVClass(originalRoute->getVClass()) {
113 setAttribute(SUMO_ATTR_COLOR, originalRoute->getAttribute(SUMO_ATTR_COLOR));
114}
115
116
117GNERoute::GNERoute(GNENet* net, GNEVehicle* vehicleParent, const GNEDemandElement* originalRoute) :
119 GNEPathManager::PathElement::Options::DEMAND_ELEMENT | GNEPathManager::PathElement::Options::ROUTE,
120{}, originalRoute->getParentEdges(), {}, {}, {vehicleParent}, {}),
121Parameterised(originalRoute->getACParametersMap()),
122myRepeat(parse<int>(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
123myCycleTime(string2time(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
124myVClass(originalRoute->getVClass()) {
125 setAttribute(SUMO_ATTR_COLOR, originalRoute->getAttribute(SUMO_ATTR_COLOR));
126}
127
128
129GNERoute::GNERoute(GNENet* net, const std::string& id, SUMOVehicleClass vClass, const std::vector<GNEEdge*>& edges,
130 const RGBColor& color, const int repeat, const SUMOTime cycleTime, const Parameterised::Map& parameters) :
132 GNEPathManager::PathElement::Options::DEMAND_ELEMENT | GNEPathManager::PathElement::Options::ROUTE,
133{}, edges, {}, {}, {}, {}),
134Parameterised(parameters),
135myColor(color),
136myRepeat(repeat),
137myCycleTime(cycleTime),
138myVClass(vClass) {
139}
140
141
142GNERoute::GNERoute(GNENet* net, GNEDemandElement* vehicleParent, const std::vector<GNEEdge*>& edges,
143 const RGBColor& color, const int repeat, const SUMOTime cycleTime, const Parameterised::Map& parameters) :
145 GNEPathManager::PathElement::Options::DEMAND_ELEMENT | GNEPathManager::PathElement::Options::ROUTE,
146{}, edges, {}, {}, {vehicleParent}, {}),
147Parameterised(parameters),
148myColor(color),
149myRepeat(repeat),
150myCycleTime(cycleTime),
151myVClass(vehicleParent->getVClass()) {
152}
153
154
156
157
160 return nullptr;
161}
162
163
166 GUIGLObjectPopupMenu* ret = new GNERoutePopupMenu(app, parent, *this);
167 // build header
168 buildPopupHeader(ret, app);
169 // build menu command for center button and copy cursor position to clipboard
171 buildPositionCopyEntry(ret, app);
172 // build menu commands for names
173 GUIDesigns::buildFXMenuCommand(ret, "Copy " + getTagStr() + " name to clipboard", nullptr, ret, MID_COPY_NAME);
174 GUIDesigns::buildFXMenuCommand(ret, "Copy " + getTagStr() + " typed name to clipboard", nullptr, ret, MID_COPY_TYPED_NAME);
175 new FXMenuSeparator(ret);
176 // build selection and show parameters menu
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 }
208 if (myRepeat != 0) {
210 }
211 if (myCycleTime != 0) {
213 }
214 // write sorted stops
216 // write stops
217 for (const auto& demandElement : getChildDemandElements()) {
218 if (demandElement->getTagProperty().isVehicleStop()) {
219 demandElement->writeDemandElement(device);
220 }
221 }
222 }
223 // write parameters
224 writeParams(device);
225 // close tag
226 device.closeTag();
227}
228
229
232 // get sorted stops and check number
233 std::vector<GNEDemandElement*> stops;
234 for (const auto& routeChild : getChildDemandElements()) {
235 if (routeChild->getTagProperty().isVehicleStop()) {
236 stops.push_back(routeChild);
237 }
238 }
239 // check stops
240 if (getInvalidStops().size() > 0) {
242 }
243 // check repeating
244 if (myRepeat > 0) {
245 // avoid repeat in routes with only one edge
246 if (getParentEdges().size() == 1) {
248 }
249 // check if front and last routes are connected
250 if (isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0) {
252 }
253 }
254 // check that exist a connection between every edge
255 if (isRouteValid(getParentEdges()).size() > 0) {
257 } else {
258 return Problem::OK;
259 }
261}
262
263
264std::string
266 // get sorted stops and check number
267 std::vector<GNEDemandElement*> stops;
268 for (const auto& routeChild : getChildDemandElements()) {
269 if (routeChild->getTagProperty().isVehicleStop()) {
270 stops.push_back(routeChild);
271 }
272 }
273 const auto invalidStops = getInvalidStops();
274 if (invalidStops.size() > 0) {
275 return toString(invalidStops.size()) + " stops are outside of route (downstream)";
276 }
277 // check repeating
278 if (myRepeat > 0) {
279 // avoid repeat in routes with only one edge
280 if (getParentEdges().size() == 1) {
281 return TL("Cannot repeat in routes with only one edge");
282 }
283 // check if front and last routes is connected
284 if (isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0) {
285 return TL("Cannot repeat route; front and last edge aren't connected");
286 }
287 }
288 // return string with the problem obtained from isRouteValid
290}
291
292
293void
295 // currently the only solution is removing Route
296}
297
298
302 return getParentDemandElements().at(0)->getVClass();
303 } else {
304 return myVClass;
305 }
306}
307
308
309const RGBColor&
312 return myColor;
313 } else if ((getParentDemandElements().size() > 0) && (getParentDemandElements().front()->getColor() != RGBColor::INVISIBLE)) {
314 return getParentDemandElements().front()->getColor();
315 } else if ((getChildDemandElements().size() > 0) && (getChildDemandElements().front()->getColor() != RGBColor::INVISIBLE)) {
316 return getChildDemandElements().front()->getColor();
317 } else {
318 return RGBColor::YELLOW;
319 }
320}
321
322
323void
325 // compute geometry
327 // update child demand elements
328 for (const auto& demandElement : getChildDemandElements()) {
329 if (!demandElement->getTagProperty().isVehicleStop()) {
330 demandElement->updateGeometry();
331 }
332 }
333}
334
335
340
341
342std::string
344 return getParentEdges().front()->getID();
345}
346
347
348double
352
353
356 Boundary routeBoundary;
357 // return the combination of all parent edges's boundaries
358 for (const auto& i : getParentEdges()) {
359 routeBoundary.add(i->getCenteringBoundary());
360 }
361 // check if is valid
362 if (routeBoundary.isInitialised()) {
363 return routeBoundary;
364 } else {
365 return Boundary(-0.1, -0.1, 0.1, 0.1);
366 }
367}
368
369
370void
371GNERoute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) {
372 // obtain new list of route edges
373 std::string newRouteEdges = getNewListOfParents(originalElement, newElement);
374 // update route edges
375 if (newRouteEdges.size() > 0) {
376 setAttribute(SUMO_ATTR_EDGES, newRouteEdges, undoList);
377 }
378}
379
380
381void
383 // Routes are drawn in drawJunctionPartialGL
384}
385
386
387void
389 // calculate path depending if is embedded
394 } else {
396 }
397 // if path is empty, then calculate path again using SVC_IGNORING
398 if (!myNet->getDemandPathManager()->isPathValid(this)) {
400 }
401}
402
403
404void
405GNERoute::drawLanePartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const {
406 // check conditions
410 // get exaggeration
411 const double exaggeration = getExaggeration(s);
412 // get detail level
413 const auto d = s.getDetailLevel(exaggeration);
414 // get embedded route flag
415 const bool embedded = (myTagProperty.getTag() == GNE_TAG_ROUTE_EMBEDDED);
416 // get route width
417 const double routeWidth = embedded ? s.widthSettings.embeddedRouteWidth : s.widthSettings.routeWidth;
418 // calculate startPos
419 const double geometryDepartPos = embedded ? (getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getParentDemandElements().at(0)->getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_LENGTH)) : -1;
420 // get endPos
421 const double geometryEndPos = embedded ? getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_ARRIVALPOS) : -1;
422 // declare path geometry
423 GUIGeometry routeGeometry;
424 // update pathGeometry depending of first and last segment
425 if (segment->isFirstSegment() && segment->isLastSegment()) {
426 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
427 geometryDepartPos,
429 geometryEndPos,
431 } else if (segment->isFirstSegment()) {
432 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
433 geometryDepartPos,
435 -1,
437 } else if (segment->isLastSegment()) {
438 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
439 -1,
441 geometryEndPos,
443 } else {
444 routeGeometry = segment->getLane()->getLaneGeometry();
445 }
446 // draw geometry only if we'rent in drawForObjectUnderCursor mode
448 // draw route partial lane
449 drawRoutePartialLane(s, d, segment, offsetFront, routeGeometry, exaggeration);
450 // draw name
451 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
452 // draw dotted contour
453 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
454 }
455 // calculate contour
456 segment->getContour()->calculateContourExtrudedShape(s, d, this, routeGeometry.getShape(), getType(), routeWidth, exaggeration,
457 segment->isFirstSegment(), segment->isLastSegment(), 0);
458 }
459}
460
461
462void
463GNERoute::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const {
464 // check conditions
468 // Obtain exaggeration of the draw
469 const double routeExaggeration = getExaggeration(s);
470 // get detail level
471 const auto d = s.getDetailLevel(routeExaggeration);
472 // get route width
474 // check if connection to next lane exist
475 const bool connectionExist = segment->getPreviousLane()->getLane2laneConnections().exist(segment->getNextLane());
476 // get geometry
477 const GUIGeometry& routeGeometry = connectionExist ? segment->getPreviousLane()->getLane2laneConnections().getLane2laneGeometry(segment->getNextLane()) :
478 GUIGeometry({segment->getPreviousLane()->getLaneShape().back(), segment->getNextLane()->getLaneShape().front()});
479 // draw geometry only if we'rent in drawForObjectUnderCursor mode
481 // draw route partial
482 drawRoutePartialJunction(s, d, offsetFront, routeGeometry, routeExaggeration);
483 // draw dotted contour
484 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
485 }
486 // calculate contour
487 segment->getContour()->calculateContourExtrudedShape(s, d, this, routeGeometry.getShape(), getType(), routeWidth, routeExaggeration, false, false, 0);
488 }
489}
490
491
492GNELane*
495 return getParentEdges().front()->getLaneByAllowedVClass(SVC_PASSENGER);
496 } else {
497 return getParentDemandElements().at(0)->getFirstPathLane();
498 }
499}
500
501
502GNELane*
505 return getParentEdges().back()->getLaneByAllowedVClass(SVC_PASSENGER);
506 } else {
507 return getParentDemandElements().at(0)->getLastPathLane();
508 }
509}
510
511
512std::string
514 switch (key) {
515 case SUMO_ATTR_ID:
516 return getMicrosimID();
517 case SUMO_ATTR_EDGES:
518 return parseIDs(getParentEdges());
519 case SUMO_ATTR_COLOR:
521 return toString(myColor);
522 } else {
523 return "";
524 }
525 case SUMO_ATTR_REPEAT:
526 return toString(myRepeat);
528 return time2string(myCycleTime);
529
533 return getParametersStr();
535 return getDistributionParents();
536 default:
537 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
538 }
539}
540
541
542double
544 switch (key) {
546 return 0;
548 return getParentEdges().back()->getLanes().front()->getLaneShape().length2D();
549 default:
550 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
551 }
552}
553
554
557 switch (key) {
559 return getParentEdges().front()->getLanes().front()->getLaneShape().front();
561 return getParentEdges().back()->getLanes().front()->getLaneShape().back();
562 default:
563 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
564 }
565}
566
567
568bool
570 switch (key) {
572 return false;
573 default:
574 return true;
575 }
576}
577
578
579void
580GNERoute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
581 if (value == getAttribute(key)) {
582 return; //avoid needless changes, later logic relies on the fact that attributes have changed
583 }
584 switch (key) {
585 case SUMO_ATTR_ID:
586 case SUMO_ATTR_COLOR:
587 case SUMO_ATTR_REPEAT:
591 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
592 break;
593 // special case due depart and arrival edge vehicles
594 case SUMO_ATTR_EDGES: {
595 // extract all vehicle childrens
596 std::vector<GNEDemandElement*> vehicles;
597 for (const auto& childDemandElement : getChildDemandElements()) {
598 if (childDemandElement->getTagProperty().isVehicle()) {
599 vehicles.push_back(childDemandElement);
600 }
601 }
602 // check vehicles
603 if (vehicles.size() > 0) {
604 undoList->begin(this, "reset start and end edges");
605 for (const auto& vehicle : vehicles) {
608 }
609 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
610 undoList->end();
612 undoList->begin(this, "reset start and end edges");
615 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
616 undoList->end();
617 } else {
618 // just change edges
619 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
620 }
621 break;
622 }
623 default:
624 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
625 }
626}
627
628
629bool
630GNERoute::isValid(SumoXMLAttr key, const std::string& value) {
631 switch (key) {
632 case SUMO_ATTR_ID:
633 return isValidDemandElementID(value);
634 case SUMO_ATTR_EDGES:
635 if (canParse<std::vector<GNEEdge*> >(myNet, value, false)) {
636 // all edges exist, then check if compounds a valid route
637 return isRouteValid(parse<std::vector<GNEEdge*> >(myNet, value)).empty();
638 } else {
639 return false;
640 }
641 case SUMO_ATTR_COLOR:
642 if (value.empty()) {
643 return true;
644 } else {
645 return canParse<RGBColor>(value);
646 }
647 case SUMO_ATTR_REPEAT:
648 return canParse<int>(value);
650 if (canParse<SUMOTime>(value)) {
651 return (parse<SUMOTime>(value) >= 0);
652 } else {
653 return false;
654 }
656 return canParse<bool>(value);
659 default:
660 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
661 }
662}
663
664
665std::string
667 return getTagStr();
668}
669
670
671std::string
673 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) ;
674}
675
676
681
682
683std::string
684GNERoute::isRouteValid(const std::vector<GNEEdge*>& edges) {
685 if (edges.size() == 0) {
686 // routes cannot be empty
687 return ("list of route edges cannot be empty");
688 } else if (edges.size() == 1) {
689 // routes with a single edge are valid, then return an empty string
690 return ("");
691 } else {
692 // iterate over edges to check that compounds a chain
693 auto it = edges.begin();
694 while (it != edges.end() - 1) {
695 const GNEEdge* currentEdge = *it;
696 const GNEEdge* nextEdge = *(it + 1);
697 // same consecutive edges aren't allowed
698 if (currentEdge->getID() == nextEdge->getID()) {
699 return ("consecutive duplicated edges (" + currentEdge->getID() + ") aren't allowed in a route");
700 }
701 // obtain outgoing edges of currentEdge
702 const std::vector<GNEEdge*>& outgoingEdges = currentEdge->getToJunction()->getGNEOutgoingEdges();
703 // check if nextEdge is in outgoingEdges
704 if (std::find(outgoingEdges.begin(), outgoingEdges.end(), nextEdge) == outgoingEdges.end()) {
705 return ("Edges '" + currentEdge->getID() + "' and '" + nextEdge->getID() + "' aren't consecutives");
706 }
707 it++;
708 }
709 // all edges consecutives, then return an empty string
710 return ("");
711 }
712}
713
715GNERoute::copyRoute(const GNERoute* originalRoute) {
716 // get net and undoList
717 const auto net = originalRoute->getNet();
718 auto undoList = net->getViewNet()->getUndoList();
719 // generate new route ID
720 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
721 // create new route
722 GNERoute* newRoute = new GNERoute(net, newRouteID, originalRoute);
723 // add new route using undo-list
724 undoList->begin(originalRoute, TLF("copy % '%'", originalRoute->getTagStr(), newRouteID));
725 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
726 undoList->end();
727 // return new route
728 return newRoute;
729}
730
731// ===========================================================================
732// private
733// ===========================================================================
734
735void
737 const GNEPathManager::Segment* segment, const double offsetFront,
738 const GUIGeometry& geometry, const double exaggeration) const {
739 // get route width
741 // push layer matrix
743 // Start with the drawing of the area traslating matrix to origin
744 glTranslated(0, 0, getType() + offsetFront);
745 // Set color
746 if (drawUsingSelectColor()) {
748 } else {
750 }
751 // draw geometry
752 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
753 // check if we have to draw a red line to the next segment
754 if (segment->getNextLane()) {
755 // push draw matrix
757 // Set red color
759 // get firstPosition (last position of current lane shape)
760 const Position firstPosition = segment->getLane()->getLaneShape().back();
761 // get lastPosition (first position of next lane shape)
762 const Position arrivalPos = segment->getNextLane()->getLaneShape().front();
763 // draw box line
764 GLHelper::drawBoxLine(arrivalPos,
765 RAD2DEG(firstPosition.angleTo2D(arrivalPos)) - 90,
766 firstPosition.distanceTo2D(arrivalPos), .05);
767 // pop draw matrix
769 }
770 // Pop layer matrix
772}
773
774
775void
777 const double offsetFront, const GUIGeometry& geometry, const double exaggeration) const {
778 const bool invalid = geometry.getShape().length() == 2;
779 // get route width
781 // Add a draw matrix
783 // Start with the drawing of the area traslating matrix to origin
784 glTranslated(0, 0, getType() + offsetFront);
785 // Set color of the base
786 if (drawUsingSelectColor()) {
788 } else if (invalid) {
790 } else {
792 }
793 // draw geometry
794 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
795 // Pop last matrix
797}
798
799
800void
801GNERoute::setAttribute(SumoXMLAttr key, const std::string& value) {
802 switch (key) {
803 case SUMO_ATTR_ID:
804 // update microsimID
805 setDemandElementID(value);
806 break;
807 case SUMO_ATTR_EDGES:
809 // compute route
811 // update all parent and child demand elements
812 for (const auto& element : getParentDemandElements()) {
813 element->updateGeometry();
814 }
815 for (const auto& element : getChildDemandElements()) {
816 element->updateGeometry();
817 }
818 break;
819 case SUMO_ATTR_COLOR:
820 if (value.empty()) {
822 } else {
823 myColor = parse<RGBColor>(value);
824 }
825 break;
826 case SUMO_ATTR_REPEAT:
827 myRepeat = parse<int>(value);
828 break;
830 myCycleTime = string2time(value);
831 break;
833 if (parse<bool>(value)) {
835 } else {
837 }
838 break;
840 setParametersStr(value);
841 break;
842 default:
843 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
844 }
845}
846
847
848void
849GNERoute::setMoveShape(const GNEMoveResult& /*moveResult*/) {
850 // routes cannot be moved
851}
852
853
854void
855GNERoute::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
856 // routes cannot be moved
857}
858
859/****************************************************************************/
FXDEFMAP(GNERoute::GNERoutePopupMenu) GNERoutePopupMenuMap[]
long long int SUMOTime
Definition GUI.h:36
@ MID_COPY_TYPED_NAME
Copy typed object name - popup entry.
Definition GUIAppEnum.h:455
@ MID_OPEN_ADDITIONAL_DIALOG
open additional dialog (used in netedit)
Definition GUIAppEnum.h:469
@ MID_COPY_NAME
Copy object name - popup entry.
Definition GUIAppEnum.h:453
@ MID_GNE_ROUTE_APPLY_DISTANCE
apply distance
@ GLO_ROUTE_EMBEDDED
a route
@ GLO_ROUTE
a route
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define RAD2DEG(x)
Definition GeomHelper.h:36
#define TL(string)
Definition MsgHandler.h:315
#define TLF(string,...)
Definition MsgHandler.h:317
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:69
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
begin/end of the description of a route
@ GNE_TAG_ROUTE_EMBEDDED
embedded route
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_ARRIVALLANE
@ SUMO_ATTR_DEPARTEDGE
@ SUMO_ATTR_ARRIVALEDGE
@ SUMO_ATTR_ARRIVALPOS
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_EDGES
the edges of a route
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_DEPARTLANE
@ SUMO_ATTR_DISTANCE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ GNE_ATTR_ROUTE_DISTRIBUTION
route distribution
@ 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:78
bool isInitialised() const
check if Boundary is Initialised
Definition Boundary.cpp:259
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:654
static void popMatrix()
pop matrix
Definition GLHelper.cpp:130
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:295
static void pushMatrix()
push matrix
Definition GLHelper.cpp:117
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
FXIcon * getACIcon() const
get FXIcon associated to this AC
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
const std::string & getTagStr() const
get tag assigned to this object in string format
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
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
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
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
calculate contour extruded (used in elements formed by a central shape)
void drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceDemandParentEdges(const std::string &value)
replace demand parent edges
std::vector< GNEDemandElement * > getInvalidStops() const
get invalid stops
std::string getDistributionParents() const
get distribution in which the given element is part
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
Problem
enum class for demandElement problems
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
Definition GNEEdge.h:82
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
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
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:214
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:664
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition GNELane.cpp:319
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:208
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:142
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2147
bool checkDrawPathGeometry(const GUIVisualizationSettings &s, const GNELane *lane, SumoXMLTag tag)
check if path element geometry must be drawn in the given lane
PathElement()=delete
invalidate default constructor
const GNELane * getPreviousLane() const
get previous lane
GNEContour * getContour() const
getcontour associated with segment
const GNELane * getNextLane() const
get next lane
const GNELane * getLane() const
get lane associated with this segment
bool isLastSegment() const
check if segment is the last path's segment
bool isFirstSegment() const
check if segment is the first path's segment
PathDraw * getPathDraw()
obtain instance of PathDraw
void calculateConsecutivePathEdges(PathElement *pathElement, SUMOVehicleClass vClass, const std::vector< GNEEdge * > &edges, const int firstLaneIndex=-1, const int lastLaneIndex=-1)
calculate consecutive path edges
bool isPathValid(const PathElement *pathElement) const
check if path element is valid
class used in GUIGLObjectPopupMenu for routes
Definition GNERoute.h:45
~GNERoutePopupMenu()
Destructor.
Definition GNERoute.cpp:55
long onCmdApplyDistance(FXObject *, FXSelector, void *)
Called to modify edge distance values along the route.
Definition GNERoute.cpp:59
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition GNERoute.cpp:672
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition GNERoute.cpp:294
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition GNERoute.cpp:349
GNELane * getLastPathLane() const
get last path lane
Definition GNERoute.cpp:503
Position getPositionInView() const
Returns position of additional in view.
Definition GNERoute.cpp:337
SUMOVehicleClass myVClass
SUMOVehicleClass (Only used for drawing)
Definition GNERoute.h:279
std::string getParentName() const
Returns the name of the parent object.
Definition GNERoute.cpp:343
SUMOTime myCycleTime
cycleTime
Definition GNERoute.h:276
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition GNERoute.cpp:666
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition GNERoute.cpp:513
Position getAttributePosition(SumoXMLAttr key) const
Definition GNERoute.cpp:556
void updateGeometry()
update pre-computed geometry information
Definition GNERoute.cpp:324
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition GNERoute.cpp:165
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over lane.
Definition GNERoute.cpp:405
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:776
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition GNERoute.cpp:371
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition GNERoute.cpp:849
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition GNERoute.cpp:678
static GNEDemandElement * copyRoute(const GNERoute *originalRoute)
create a copy of the given route
Definition GNERoute.cpp:715
GNELane * getFirstPathLane() const
get first path lane
Definition GNERoute.cpp:493
void drawRoutePartialLane(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEPathManager::Segment *segment, const double offsetFront, const GUIGeometry &geometry, const double exaggeration) const
draw route partial lane
Definition GNERoute.cpp:736
double getAttributeDouble(SumoXMLAttr key) const
Definition GNERoute.cpp:543
GNEMoveOperation * getMoveOperation()
get move operation
Definition GNERoute.cpp:159
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition GNERoute.cpp:855
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition GNERoute.cpp:300
GNERoute(SumoXMLTag tag, GNENet *net)
default constructor
Definition GNERoute.cpp:76
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNERoute.cpp:355
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition GNERoute.cpp:630
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition GNERoute.cpp:382
static std::string isRouteValid(const std::vector< GNEEdge * > &edges)
check if a route is valid
Definition GNERoute.cpp:684
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
Definition GNERoute.cpp:580
int myRepeat
repeat
Definition GNERoute.h:273
void computePathElement()
compute pathElement
Definition GNERoute.cpp:388
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition GNERoute.cpp:265
RGBColor myColor
route color
Definition GNERoute.h:270
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
Definition GNERoute.cpp:198
~GNERoute()
destructor
Definition GNERoute.cpp:155
bool isAttributeEnabled(SumoXMLAttr key) const
Definition GNERoute.cpp:569
const RGBColor & getColor() const
get color
Definition GNERoute.cpp:310
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over junction.
Definition GNERoute.cpp:463
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
Definition GNERoute.cpp:231
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
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...
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
GNEUndoList * getUndoList() const
get the undoList object
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
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.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
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)
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.
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
std::map< std::string, std::string > Map
parameters map
void setParametersStr(const std::string &paramsString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:322
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:276
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:286
double length() const
Returns the length.
static const RGBColor YELLOW
Definition RGBColor.h:188
static const RGBColor INVISIBLE
Definition RGBColor.h:195
static const RGBColor RED
named colors
Definition RGBColor.h:185
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
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