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, segment->getLane()->getParentEdge());
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,
493 false, false, 0, segment, segment->getJunction());
494 // check if add this path element to redraw buffer
497 }
498 }
499}
500
501
502GNELane*
505 return getParentEdges().front()->getLaneByAllowedVClass(SVC_PASSENGER);
506 } else {
507 return getParentDemandElements().at(0)->getFirstPathLane();
508 }
509}
510
511
512GNELane*
515 return getParentEdges().back()->getLaneByAllowedVClass(SVC_PASSENGER);
516 } else {
517 return getParentDemandElements().at(0)->getLastPathLane();
518 }
519}
520
521
522std::string
524 switch (key) {
525 case SUMO_ATTR_ID:
526 return getMicrosimID();
527 case SUMO_ATTR_EDGES:
528 return parseIDs(getParentEdges());
529 case SUMO_ATTR_COLOR:
531 return toString(myColor);
532 } else {
533 return "";
534 }
535 case SUMO_ATTR_REPEAT:
536 return toString(myRepeat);
538 return time2string(myCycleTime);
540 return getParametersStr();
542 return getDistributionParents();
543 default:
544 return getCommonAttribute(key);
545 }
546}
547
548
549double
551 switch (key) {
553 return 0;
555 return getParentEdges().back()->getLanes().front()->getLaneShape().length2D();
556 default:
557 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
558 }
559}
560
561
564 switch (key) {
566 return getParentEdges().front()->getLanes().front()->getLaneShape().front();
568 return getParentEdges().back()->getLanes().front()->getLaneShape().back();
569 default:
570 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
571 }
572}
573
574
575bool
577 switch (key) {
579 return false;
580 default:
581 return true;
582 }
583}
584
585
586void
587GNERoute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
588 if (value == getAttribute(key)) {
589 return; //avoid needless changes, later logic relies on the fact that attributes have changed
590 }
591 switch (key) {
592 case SUMO_ATTR_ID:
593 case SUMO_ATTR_COLOR:
594 case SUMO_ATTR_REPEAT:
597 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
598 break;
599 // special case due depart and arrival edge vehicles
600 case SUMO_ATTR_EDGES: {
601 // extract all vehicle childrens
602 std::vector<GNEDemandElement*> vehicles;
603 for (const auto& childDemandElement : getChildDemandElements()) {
604 if (childDemandElement->getTagProperty().isVehicle()) {
605 vehicles.push_back(childDemandElement);
606 }
607 }
608 // check vehicles
609 if (vehicles.size() > 0) {
610 undoList->begin(this, "reset start and end edges");
611 for (const auto& vehicle : vehicles) {
614 }
615 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
616 undoList->end();
618 undoList->begin(this, "reset start and end edges");
621 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
622 undoList->end();
623 } else {
624 // just change edges
625 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
626 }
627 break;
628 }
629 default:
630 setCommonAttribute(key, value, undoList);
631 break;
632 }
633}
634
635
636bool
637GNERoute::isValid(SumoXMLAttr key, const std::string& value) {
638 switch (key) {
639 case SUMO_ATTR_ID:
640 return isValidDemandElementID(value);
641 case SUMO_ATTR_EDGES:
642 if (canParse<std::vector<GNEEdge*> >(myNet, value, false)) {
643 // all edges exist, then check if compounds a valid route
644 return isRouteValid(parse<std::vector<GNEEdge*> >(myNet, value)).empty();
645 } else {
646 return false;
647 }
648 case SUMO_ATTR_COLOR:
649 if (value.empty()) {
650 return true;
651 } else {
652 return canParse<RGBColor>(value);
653 }
654 case SUMO_ATTR_REPEAT:
655 return canParse<int>(value);
657 if (canParse<SUMOTime>(value)) {
658 return (parse<SUMOTime>(value) >= 0);
659 } else {
660 return false;
661 }
664 default:
665 return isCommonValid(key, value);
666 }
667}
668
669
670std::string
672 return getTagStr();
673}
674
675
676std::string
678 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) ;
679}
680
681
686
687
688std::string
689GNERoute::isRouteValid(const std::vector<GNEEdge*>& edges) {
690 if (edges.size() == 0) {
691 // routes cannot be empty
692 return ("list of route edges cannot be empty");
693 } else if (edges.size() == 1) {
694 // routes with a single edge are valid, then return an empty string
695 return ("");
696 } else {
697 // iterate over edges to check that compounds a chain
698 auto it = edges.begin();
699 while (it != edges.end() - 1) {
700 const GNEEdge* currentEdge = *it;
701 const GNEEdge* nextEdge = *(it + 1);
702 // same consecutive edges aren't allowed
703 if (currentEdge->getID() == nextEdge->getID()) {
704 return ("consecutive duplicated edges (" + currentEdge->getID() + ") aren't allowed in a route");
705 }
706 // obtain outgoing edges of currentEdge
707 const std::vector<GNEEdge*>& outgoingEdges = currentEdge->getToJunction()->getGNEOutgoingEdges();
708 // check if nextEdge is in outgoingEdges
709 if (std::find(outgoingEdges.begin(), outgoingEdges.end(), nextEdge) == outgoingEdges.end()) {
710 return ("Edges '" + currentEdge->getID() + "' and '" + nextEdge->getID() + "' aren't consecutives");
711 }
712 it++;
713 }
714 // all edges consecutives, then return an empty string
715 return ("");
716 }
717}
718
720GNERoute::copyRoute(const GNERoute* originalRoute) {
721 // get net and undoList
722 const auto net = originalRoute->getNet();
723 auto undoList = net->getViewNet()->getUndoList();
724 // generate new route ID
725 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
726 // create new route
727 GNERoute* newRoute = new GNERoute(net, newRouteID, originalRoute);
728 // add new route using undo-list
729 undoList->begin(originalRoute, TLF("copy % '%'", originalRoute->getTagStr(), newRouteID));
730 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
731 undoList->end();
732 // return new route
733 return newRoute;
734}
735
736// ===========================================================================
737// private
738// ===========================================================================
739
740void
742 const GNESegment* segment, const double offsetFront,
743 const GUIGeometry& geometry, const double exaggeration) const {
744 // get route width
746 // push layer matrix
748 // Start with the drawing of the area traslating matrix to origin
749 glTranslated(0, 0, getType() + offsetFront);
750 // Set color
751 if (drawUsingSelectColor()) {
753 } else {
755 }
756 // draw geometry
757 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
758 // check if we have to draw a red line to the next segment
759 if (segment->getNextLane()) {
760 // push draw matrix
762 // Set red color
764 // get firstPosition (last position of current lane shape)
765 const Position firstPosition = segment->getLane()->getLaneShape().back();
766 // get lastPosition (first position of next lane shape)
767 const Position arrivalPos = segment->getNextLane()->getLaneShape().front();
768 // draw box line
769 GLHelper::drawBoxLine(arrivalPos,
770 RAD2DEG(firstPosition.angleTo2D(arrivalPos)) - 90,
771 firstPosition.distanceTo2D(arrivalPos), .05);
772 // pop draw matrix
774 }
775 // Pop layer matrix
777}
778
779
780void
782 const double offsetFront, const GUIGeometry& geometry, const double exaggeration) const {
783 const bool invalid = geometry.getShape().length() == 2;
784 // get route width
786 // Add a draw matrix
788 // Start with the drawing of the area traslating matrix to origin
789 glTranslated(0, 0, getType() + offsetFront);
790 // Set color of the base
791 if (drawUsingSelectColor()) {
793 } else if (invalid) {
795 } else {
797 }
798 // draw geometry
799 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
800 // Pop last matrix
802}
803
804
805void
806GNERoute::setAttribute(SumoXMLAttr key, const std::string& value) {
807 switch (key) {
808 case SUMO_ATTR_ID:
809 // update microsimID
810 setDemandElementID(value);
811 break;
812 case SUMO_ATTR_EDGES:
814 // compute route
816 // update all parent and child demand elements
817 for (const auto& element : getParentDemandElements()) {
818 element->updateGeometry();
819 }
820 for (const auto& element : getChildDemandElements()) {
821 element->updateGeometry();
822 }
823 break;
824 case SUMO_ATTR_COLOR:
825 if (value.empty()) {
827 } else {
828 myColor = parse<RGBColor>(value);
829 }
830 break;
831 case SUMO_ATTR_REPEAT:
832 myRepeat = parse<int>(value);
833 break;
835 myCycleTime = string2time(value);
836 break;
838 setParametersStr(value);
839 break;
840 default:
841 setCommonAttribute(key, value);
842 break;
843 }
844}
845
846
847void
848GNERoute::setMoveShape(const GNEMoveResult& /*moveResult*/) {
849 // routes cannot be moved
850}
851
852
853void
854GNERoute::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
855 // routes cannot be moved
856}
857
858/****************************************************************************/
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
@ 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: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
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....
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.
bool isCommonValid(SumoXMLAttr key, const std::string &value)
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
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
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
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:196
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:2163
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:677
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:513
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:671
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition GNERoute.cpp:523
Position getAttributePosition(SumoXMLAttr key) const
Definition GNERoute.cpp:563
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:781
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:848
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition GNERoute.cpp:683
static GNEDemandElement * copyRoute(const GNERoute *originalRoute)
create a copy of the given route
Definition GNERoute.cpp:720
GNELane * getFirstPathLane() const
get first path lane
Definition GNERoute.cpp:503
double getAttributeDouble(SumoXMLAttr key) const
Definition GNERoute.cpp:550
GNEMoveOperation * getMoveOperation()
get move operation
Definition GNERoute.cpp:160
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition GNERoute.cpp:854
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:741
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:637
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:689
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:587
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:576
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 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
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