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/GNESegment.h>
23#include <netedit/GNEUndoList.h>
24#include <netedit/GNEViewNet.h>
33
34#include "GNERoute.h"
35#include "GNEVehicle.h"
36
37// ===========================================================================
38// FOX callback mapping
39// ===========================================================================
43
44// Object implementation
45FXIMPLEMENT(GNERoute::GNERoutePopupMenu, GUIGLObjectPopupMenu, GNERoutePopupMenuMap, ARRAYNUMBER(GNERoutePopupMenuMap))
46
47// ===========================================================================
48// GNERoute::GNERoutePopupMenu - methods
49// ===========================================================================
50
54
55
57
58
59long
61 GNERoute* route = static_cast<GNERoute*>(myObject);
62 GNEUndoList* undoList = route->myNet->getViewNet()->getUndoList();
63 undoList->begin(route, "apply distance along route");
64 double dist = (route->getParentEdges().size() > 0) ? route->getParentEdges().front()->getNBEdge()->getDistance() : 0;
65 for (GNEEdge* edge : route->getParentEdges()) {
67 dist += edge->getNBEdge()->getFinalLength();
68 }
69 undoList->end();
70 return 1;
71}
72
73// ===========================================================================
74// GNERoute - methods
75// ===========================================================================
76
78 GNEDemandElement("", net, GLO_ROUTE, tag, GUIIconSubSys::getIcon(GUIIcon::ROUTE),
80{}, {}, {}, {}, {}, {}),
82myColor(RGBColor::YELLOW),
83myRepeat(0),
84myCycleTime(0),
85myVClass(SVC_PASSENGER) {
86 // reset default values
87 resetDefaultValues();
88}
89
90
92 GNEDemandElement(net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE), net, GLO_ROUTE, SUMO_TAG_ROUTE,
93 GUIIconSubSys::getIcon(GUIIcon::ROUTE),
95{}, {}, {}, {}, {}, {}),
97myColor(RGBColor::YELLOW),
98myRepeat(0),
99myCycleTime(0),
100myVClass(SVC_PASSENGER) {
101 // reset default values
102 resetDefaultValues();
103}
104
105
106GNERoute::GNERoute(GNENet* net, const std::string& id, const GNEDemandElement* originalRoute) :
109{}, originalRoute->getParentEdges(), {}, {}, {}, {}),
110Parameterised(originalRoute->getACParametersMap()),
111myRepeat(parse<int>(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
112myCycleTime(string2time(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
113myVClass(originalRoute->getVClass()) {
114 setAttribute(SUMO_ATTR_COLOR, originalRoute->getAttribute(SUMO_ATTR_COLOR));
115}
116
117
118GNERoute::GNERoute(GNENet* net, GNEVehicle* vehicleParent, const GNEDemandElement* originalRoute) :
121{}, originalRoute->getParentEdges(), {}, {}, {vehicleParent}, {}),
122Parameterised(originalRoute->getACParametersMap()),
123myRepeat(parse<int>(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
124myCycleTime(string2time(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
125myVClass(originalRoute->getVClass()) {
126 setAttribute(SUMO_ATTR_COLOR, originalRoute->getAttribute(SUMO_ATTR_COLOR));
127}
128
129
130GNERoute::GNERoute(GNENet* net, const std::string& id, SUMOVehicleClass vClass, const std::vector<GNEEdge*>& edges,
131 const RGBColor& color, const int repeat, const SUMOTime cycleTime, const Parameterised::Map& parameters) :
134{}, edges, {}, {}, {}, {}),
135Parameterised(parameters),
136myColor(color),
137myRepeat(repeat),
138myCycleTime(cycleTime),
139myVClass(vClass) {
140}
141
142
143GNERoute::GNERoute(GNENet* net, GNEDemandElement* vehicleParent, const std::vector<GNEEdge*>& edges,
144 const RGBColor& color, const int repeat, const SUMOTime cycleTime, const Parameterised::Map& parameters) :
147{}, edges, {}, {}, {vehicleParent}, {}),
148Parameterised(parameters),
149myColor(color),
150myRepeat(repeat),
151myCycleTime(cycleTime),
152myVClass(vehicleParent->getVClass()) {
153}
154
155
157
158
161 return nullptr;
162}
163
164
167 GUIGLObjectPopupMenu* ret = new GNERoutePopupMenu(app, parent, *this);
168 // build header
169 buildPopupHeader(ret, app);
170 // build menu command for center button and copy cursor position to clipboard
172 buildPositionCopyEntry(ret, app);
173 // build menu commands for names
174 GUIDesigns::buildFXMenuCommand(ret, "Copy " + getTagStr() + " name to clipboard", nullptr, ret, MID_COPY_NAME);
175 GUIDesigns::buildFXMenuCommand(ret, "Copy " + getTagStr() + " typed name to clipboard", nullptr, ret, MID_COPY_TYPED_NAME);
176 new FXMenuSeparator(ret);
177 // build selection and show parameters menu
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 }
209 if (myRepeat != 0) {
211 }
212 if (myCycleTime != 0) {
214 }
215 // write sorted stops
217 // write stops
218 for (const auto& demandElement : getChildDemandElements()) {
219 if (demandElement->getTagProperty().isVehicleStop()) {
220 demandElement->writeDemandElement(device);
221 }
222 }
223 }
224 // write parameters
225 writeParams(device);
226 // close tag
227 device.closeTag();
228}
229
230
233 // get sorted stops and check number
234 std::vector<GNEDemandElement*> stops;
235 for (const auto& routeChild : getChildDemandElements()) {
236 if (routeChild->getTagProperty().isVehicleStop()) {
237 stops.push_back(routeChild);
238 }
239 }
240 // check stops
241 if (getInvalidStops().size() > 0) {
243 }
244 // check repeating
245 if (myRepeat > 0) {
246 // avoid repeat in routes with only one edge
247 if (getParentEdges().size() == 1) {
249 }
250 // check if front and last routes are connected
251 if (isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0) {
253 }
254 }
255 // check that exist a connection between every edge
256 if (isRouteValid(getParentEdges()).size() > 0) {
258 } else {
259 return Problem::OK;
260 }
262}
263
264
265std::string
267 // get sorted stops and check number
268 std::vector<GNEDemandElement*> stops;
269 for (const auto& routeChild : getChildDemandElements()) {
270 if (routeChild->getTagProperty().isVehicleStop()) {
271 stops.push_back(routeChild);
272 }
273 }
274 const auto invalidStops = getInvalidStops();
275 if (invalidStops.size() > 0) {
276 return toString(invalidStops.size()) + " stops are outside of route (downstream)";
277 }
278 // check repeating
279 if (myRepeat > 0) {
280 // avoid repeat in routes with only one edge
281 if (getParentEdges().size() == 1) {
282 return TL("Cannot repeat in routes with only one edge");
283 }
284 // check if front and last routes is connected
285 if (isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0) {
286 return TL("Cannot repeat route; front and last edge aren't connected");
287 }
288 }
289 // return string with the problem obtained from isRouteValid
291}
292
293
294void
296 // currently the only solution is removing Route
297}
298
299
303 return getParentDemandElements().at(0)->getVClass();
304 } else {
305 return myVClass;
306 }
307}
308
309
310const RGBColor&
313 return myColor;
314 } else if ((getParentDemandElements().size() > 0) && (getParentDemandElements().front()->getColor() != RGBColor::INVISIBLE)) {
315 return getParentDemandElements().front()->getColor();
316 } else if ((getChildDemandElements().size() > 0) && (getChildDemandElements().front()->getColor() != RGBColor::INVISIBLE)) {
317 return getChildDemandElements().front()->getColor();
318 } else {
319 return RGBColor::YELLOW;
320 }
321}
322
323
324void
326 // compute geometry
328 // update child demand elements
329 for (const auto& demandElement : getChildDemandElements()) {
330 if (!demandElement->getTagProperty().isVehicleStop()) {
331 demandElement->updateGeometry();
332 }
333 }
334}
335
336
341
342
343std::string
345 return getParentEdges().front()->getID();
346}
347
348
349double
353
354
357 Boundary routeBoundary;
358 // return the combination of all parent edges's boundaries
359 for (const auto& i : getParentEdges()) {
360 routeBoundary.add(i->getCenteringBoundary());
361 }
362 // check if is valid
363 if (routeBoundary.isInitialised()) {
364 return routeBoundary;
365 } else {
366 return Boundary(-0.1, -0.1, 0.1, 0.1);
367 }
368}
369
370
371void
372GNERoute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) {
373 // obtain new list of route edges
374 std::string newRouteEdges = getNewListOfParents(originalElement, newElement);
375 // update route edges
376 if (newRouteEdges.size() > 0) {
377 setAttribute(SUMO_ATTR_EDGES, newRouteEdges, undoList);
378 }
379}
380
381
382void
384 // Routes are drawn in drawJunctionPartialGL
385}
386
387
388void
390 // calculate path depending if is embedded
395 } else {
397 }
398 // if path is empty, then calculate path again using SVC_IGNORING
399 if (!myNet->getDemandPathManager()->isPathValid(this)) {
401 }
402}
403
404
405void
406GNERoute::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
407 // check conditions
411 // get exaggeration
412 const double exaggeration = getExaggeration(s);
413 // get detail level
414 const auto d = s.getDetailLevel(exaggeration);
415 // get embedded route flag
416 const bool embedded = (myTagProperty.getTag() == GNE_TAG_ROUTE_EMBEDDED);
417 // get route width
418 const double routeWidth = embedded ? s.widthSettings.embeddedRouteWidth : s.widthSettings.routeWidth;
419 // calculate startPos
420 const double geometryDepartPos = embedded ? (getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getParentDemandElements().at(0)->getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_LENGTH)) : -1;
421 // get endPos
422 const double geometryEndPos = embedded ? getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_ARRIVALPOS) : -1;
423 // declare path geometry
424 GUIGeometry routeGeometry;
425 // update pathGeometry depending of first and last segment
426 if (segment->isFirstSegment() && segment->isLastSegment()) {
427 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
428 geometryDepartPos,
430 geometryEndPos,
432 } else if (segment->isFirstSegment()) {
433 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
434 geometryDepartPos,
436 -1,
438 } else if (segment->isLastSegment()) {
439 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
440 -1,
442 geometryEndPos,
444 } else {
445 routeGeometry = segment->getLane()->getLaneGeometry();
446 }
447 // draw geometry only if we'rent in drawForObjectUnderCursor mode
449 // draw route partial lane
450 drawRoutePartialLane(s, d, segment, offsetFront, routeGeometry, exaggeration);
451 // draw name
452 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
453 // draw dotted contour
454 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
455 }
456 // calculate contour
457 segment->getContour()->calculateContourExtrudedShape(s, d, this, routeGeometry.getShape(), getType(), routeWidth, exaggeration,
458 segment->isFirstSegment(), segment->isLastSegment(), 0, segment);
459 // check if add this path element to redraw buffer
462 }
463 }
464}
465
466
467void
468GNERoute::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
469 // check conditions
473 // Obtain exaggeration of the draw
474 const double routeExaggeration = getExaggeration(s);
475 // get detail level
476 const auto d = s.getDetailLevel(routeExaggeration);
477 // get route width
479 // check if connection to next lane exist
480 const bool connectionExist = segment->getPreviousLane()->getLane2laneConnections().exist(segment->getNextLane());
481 // get geometry
482 const GUIGeometry& routeGeometry = connectionExist ? segment->getPreviousLane()->getLane2laneConnections().getLane2laneGeometry(segment->getNextLane()) :
483 GUIGeometry({segment->getPreviousLane()->getLaneShape().back(), segment->getNextLane()->getLaneShape().front()});
484 // draw geometry only if we'rent in drawForObjectUnderCursor mode
486 // draw route partial
487 drawRoutePartialJunction(s, d, offsetFront, routeGeometry, routeExaggeration);
488 // draw dotted contour
489 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
490 }
491 // calculate contour
492 segment->getContour()->calculateContourExtrudedShape(s, d, this, routeGeometry.getShape(), getType(), routeWidth, routeExaggeration, false, false, 0, segment);
493 // check if add this path element to redraw buffer
496 }
497 }
498}
499
500
501GNELane*
504 return getParentEdges().front()->getLaneByAllowedVClass(SVC_PASSENGER);
505 } else {
506 return getParentDemandElements().at(0)->getFirstPathLane();
507 }
508}
509
510
511GNELane*
514 return getParentEdges().back()->getLaneByAllowedVClass(SVC_PASSENGER);
515 } else {
516 return getParentDemandElements().at(0)->getLastPathLane();
517 }
518}
519
520
521std::string
523 switch (key) {
524 case SUMO_ATTR_ID:
525 return getMicrosimID();
526 case SUMO_ATTR_EDGES:
527 return parseIDs(getParentEdges());
528 case SUMO_ATTR_COLOR:
530 return toString(myColor);
531 } else {
532 return "";
533 }
534 case SUMO_ATTR_REPEAT:
535 return toString(myRepeat);
537 return time2string(myCycleTime);
538
542 return getParametersStr();
544 return getDistributionParents();
545 default:
546 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
547 }
548}
549
550
551double
553 switch (key) {
555 return 0;
557 return getParentEdges().back()->getLanes().front()->getLaneShape().length2D();
558 default:
559 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
560 }
561}
562
563
566 switch (key) {
568 return getParentEdges().front()->getLanes().front()->getLaneShape().front();
570 return getParentEdges().back()->getLanes().front()->getLaneShape().back();
571 default:
572 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
573 }
574}
575
576
577bool
579 switch (key) {
581 return false;
582 default:
583 return true;
584 }
585}
586
587
588void
589GNERoute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
590 if (value == getAttribute(key)) {
591 return; //avoid needless changes, later logic relies on the fact that attributes have changed
592 }
593 switch (key) {
594 case SUMO_ATTR_ID:
595 case SUMO_ATTR_COLOR:
596 case SUMO_ATTR_REPEAT:
600 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
601 break;
602 // special case due depart and arrival edge vehicles
603 case SUMO_ATTR_EDGES: {
604 // extract all vehicle childrens
605 std::vector<GNEDemandElement*> vehicles;
606 for (const auto& childDemandElement : getChildDemandElements()) {
607 if (childDemandElement->getTagProperty().isVehicle()) {
608 vehicles.push_back(childDemandElement);
609 }
610 }
611 // check vehicles
612 if (vehicles.size() > 0) {
613 undoList->begin(this, "reset start and end edges");
614 for (const auto& vehicle : vehicles) {
617 }
618 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
619 undoList->end();
621 undoList->begin(this, "reset start and end edges");
624 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
625 undoList->end();
626 } else {
627 // just change edges
628 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
629 }
630 break;
631 }
632 default:
633 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
634 }
635}
636
637
638bool
639GNERoute::isValid(SumoXMLAttr key, const std::string& value) {
640 switch (key) {
641 case SUMO_ATTR_ID:
642 return isValidDemandElementID(value);
643 case SUMO_ATTR_EDGES:
644 if (canParse<std::vector<GNEEdge*> >(myNet, value, false)) {
645 // all edges exist, then check if compounds a valid route
646 return isRouteValid(parse<std::vector<GNEEdge*> >(myNet, value)).empty();
647 } else {
648 return false;
649 }
650 case SUMO_ATTR_COLOR:
651 if (value.empty()) {
652 return true;
653 } else {
654 return canParse<RGBColor>(value);
655 }
656 case SUMO_ATTR_REPEAT:
657 return canParse<int>(value);
659 if (canParse<SUMOTime>(value)) {
660 return (parse<SUMOTime>(value) >= 0);
661 } else {
662 return false;
663 }
665 return canParse<bool>(value);
668 default:
669 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
670 }
671}
672
673
674std::string
676 return getTagStr();
677}
678
679
680std::string
682 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) ;
683}
684
685
690
691
692std::string
693GNERoute::isRouteValid(const std::vector<GNEEdge*>& edges) {
694 if (edges.size() == 0) {
695 // routes cannot be empty
696 return ("list of route edges cannot be empty");
697 } else if (edges.size() == 1) {
698 // routes with a single edge are valid, then return an empty string
699 return ("");
700 } else {
701 // iterate over edges to check that compounds a chain
702 auto it = edges.begin();
703 while (it != edges.end() - 1) {
704 const GNEEdge* currentEdge = *it;
705 const GNEEdge* nextEdge = *(it + 1);
706 // same consecutive edges aren't allowed
707 if (currentEdge->getID() == nextEdge->getID()) {
708 return ("consecutive duplicated edges (" + currentEdge->getID() + ") aren't allowed in a route");
709 }
710 // obtain outgoing edges of currentEdge
711 const std::vector<GNEEdge*>& outgoingEdges = currentEdge->getToJunction()->getGNEOutgoingEdges();
712 // check if nextEdge is in outgoingEdges
713 if (std::find(outgoingEdges.begin(), outgoingEdges.end(), nextEdge) == outgoingEdges.end()) {
714 return ("Edges '" + currentEdge->getID() + "' and '" + nextEdge->getID() + "' aren't consecutives");
715 }
716 it++;
717 }
718 // all edges consecutives, then return an empty string
719 return ("");
720 }
721}
722
724GNERoute::copyRoute(const GNERoute* originalRoute) {
725 // get net and undoList
726 const auto net = originalRoute->getNet();
727 auto undoList = net->getViewNet()->getUndoList();
728 // generate new route ID
729 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
730 // create new route
731 GNERoute* newRoute = new GNERoute(net, newRouteID, originalRoute);
732 // add new route using undo-list
733 undoList->begin(originalRoute, TLF("copy % '%'", originalRoute->getTagStr(), newRouteID));
734 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
735 undoList->end();
736 // return new route
737 return newRoute;
738}
739
740// ===========================================================================
741// private
742// ===========================================================================
743
744void
746 const GNESegment* segment, const double offsetFront,
747 const GUIGeometry& geometry, const double exaggeration) const {
748 // get route width
750 // push layer matrix
752 // Start with the drawing of the area traslating matrix to origin
753 glTranslated(0, 0, getType() + offsetFront);
754 // Set color
755 if (drawUsingSelectColor()) {
757 } else {
759 }
760 // draw geometry
761 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
762 // check if we have to draw a red line to the next segment
763 if (segment->getNextLane()) {
764 // push draw matrix
766 // Set red color
768 // get firstPosition (last position of current lane shape)
769 const Position firstPosition = segment->getLane()->getLaneShape().back();
770 // get lastPosition (first position of next lane shape)
771 const Position arrivalPos = segment->getNextLane()->getLaneShape().front();
772 // draw box line
773 GLHelper::drawBoxLine(arrivalPos,
774 RAD2DEG(firstPosition.angleTo2D(arrivalPos)) - 90,
775 firstPosition.distanceTo2D(arrivalPos), .05);
776 // pop draw matrix
778 }
779 // Pop layer matrix
781}
782
783
784void
786 const double offsetFront, const GUIGeometry& geometry, const double exaggeration) const {
787 const bool invalid = geometry.getShape().length() == 2;
788 // get route width
790 // Add a draw matrix
792 // Start with the drawing of the area traslating matrix to origin
793 glTranslated(0, 0, getType() + offsetFront);
794 // Set color of the base
795 if (drawUsingSelectColor()) {
797 } else if (invalid) {
799 } else {
801 }
802 // draw geometry
803 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
804 // Pop last matrix
806}
807
808
809void
810GNERoute::setAttribute(SumoXMLAttr key, const std::string& value) {
811 switch (key) {
812 case SUMO_ATTR_ID:
813 // update microsimID
814 setDemandElementID(value);
815 break;
816 case SUMO_ATTR_EDGES:
818 // compute route
820 // update all parent and child demand elements
821 for (const auto& element : getParentDemandElements()) {
822 element->updateGeometry();
823 }
824 for (const auto& element : getChildDemandElements()) {
825 element->updateGeometry();
826 }
827 break;
828 case SUMO_ATTR_COLOR:
829 if (value.empty()) {
831 } else {
832 myColor = parse<RGBColor>(value);
833 }
834 break;
835 case SUMO_ATTR_REPEAT:
836 myRepeat = parse<int>(value);
837 break;
839 myCycleTime = string2time(value);
840 break;
842 if (parse<bool>(value)) {
844 } else {
846 }
847 break;
849 setParametersStr(value);
850 break;
851 default:
852 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
853 }
854}
855
856
857void
858GNERoute::setMoveShape(const GNEMoveResult& /*moveResult*/) {
859 // routes cannot be moved
860}
861
862
863void
864GNERoute::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
865 // routes cannot be moved
866}
867
868/****************************************************************************/
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
GUIViewObjectsHandler gViewObjectsHandler
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 GNESegment *segment) const
calculate contour extruded (used in elements formed by a central shape)
void drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
bool checkDrawPathContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC) const
drawing contour functions
void 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:662
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:145
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2155
bool checkDrawPathGeometry(const GUIVisualizationSettings &s, const GNELane *lane, SumoXMLTag tag)
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:45
~GNERoutePopupMenu()
Destructor.
Definition GNERoute.cpp:56
long onCmdApplyDistance(FXObject *, FXSelector, void *)
Called to modify edge distance values along the route.
Definition GNERoute.cpp:60
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition GNERoute.cpp:681
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition GNERoute.cpp:295
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition GNERoute.cpp:350
GNELane * getLastPathLane() const
get last path lane
Definition GNERoute.cpp:512
Position getPositionInView() const
Returns position of additional in view.
Definition GNERoute.cpp:338
SUMOVehicleClass myVClass
SUMOVehicleClass (Only used for drawing)
Definition GNERoute.h:279
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
Definition GNERoute.cpp:468
std::string getParentName() const
Returns the name of the parent object.
Definition GNERoute.cpp:344
SUMOTime myCycleTime
cycleTime
Definition GNERoute.h:276
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition GNERoute.cpp:675
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition GNERoute.cpp:522
Position getAttributePosition(SumoXMLAttr key) const
Definition GNERoute.cpp:565
void updateGeometry()
update pre-computed geometry information
Definition GNERoute.cpp:325
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition GNERoute.cpp:166
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:785
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition GNERoute.cpp:372
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition GNERoute.cpp:858
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition GNERoute.cpp:687
static GNEDemandElement * copyRoute(const GNERoute *originalRoute)
create a copy of the given route
Definition GNERoute.cpp:724
GNELane * getFirstPathLane() const
get first path lane
Definition GNERoute.cpp:502
double getAttributeDouble(SumoXMLAttr key) const
Definition GNERoute.cpp:552
GNEMoveOperation * getMoveOperation()
get move operation
Definition GNERoute.cpp:160
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition GNERoute.cpp:864
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition GNERoute.cpp:301
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:745
GNERoute(SumoXMLTag tag, GNENet *net)
default constructor
Definition GNERoute.cpp:77
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNERoute.cpp:356
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition GNERoute.cpp:639
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition GNERoute.cpp:383
static std::string isRouteValid(const std::vector< GNEEdge * > &edges)
check if a route is valid
Definition GNERoute.cpp:693
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:589
int myRepeat
repeat
Definition GNERoute.h:273
void computePathElement()
compute pathElement
Definition GNERoute.cpp:389
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
Definition GNERoute.cpp:406
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition GNERoute.cpp:266
RGBColor myColor
route color
Definition GNERoute.h:270
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
Definition GNERoute.cpp:199
~GNERoute()
destructor
Definition GNERoute.cpp:156
bool isAttributeEnabled(SumoXMLAttr key) const
Definition GNERoute.cpp:578
const RGBColor & getColor() const
get color
Definition GNERoute.cpp:311
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
Definition GNERoute.cpp:232
const GNELane * getLane() const
get lane 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
bool isLastSegment() const
check if segment is the last path's segment
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
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
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