Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNERoute.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// A class for visualizing routes in Netedit
19/****************************************************************************/
20
21#include <netedit/GNENet.h>
22#include <netedit/GNESegment.h>
24#include <netedit/GNEUndoList.h>
25#include <netedit/GNEViewNet.h>
34
35#include "GNERoute.h"
36#include "GNEVehicle.h"
37
38// ===========================================================================
39// FOX callback mapping
40// ===========================================================================
41
45
46// Object implementation
47FXIMPLEMENT(GNERoute::GNERoutePopupMenu, GUIGLObjectPopupMenu, GNERoutePopupMenuMap, ARRAYNUMBER(GNERoutePopupMenuMap))
48
49// ===========================================================================
50// GNERoute::GNERoutePopupMenu - methods
51// ===========================================================================
52
56
57
59
60
61long
63 GNERoute* route = static_cast<GNERoute*>(myObject);
64 GNEUndoList* undoList = route->myNet->getViewNet()->getUndoList();
65 undoList->begin(route, "apply distance along route");
66 double dist = (route->getParentEdges().size() > 0) ? route->getParentEdges().front()->getNBEdge()->getDistance() : 0;
67 for (GNEEdge* edge : route->getParentEdges()) {
69 dist += edge->getNBEdge()->getFinalLength();
70 }
71 undoList->end();
72 return 1;
73}
74
75// ===========================================================================
76// GNERoute - methods
77// ===========================================================================
78
82
83
85 GNEDemandElement(net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE), net, "", SUMO_TAG_ROUTE,
86 GNEPathElement::Options::DEMAND_ELEMENT | GNEPathElement::Options::ROUTE) {
87}
88
89// copy
90GNERoute::GNERoute(const std::string& id, const GNEDemandElement* originalRoute) :
91 GNEDemandElement(id, originalRoute->getNet(), originalRoute->getFilename(), originalRoute->getTagProperty()->getTag(),
92 originalRoute->getPathElementOptions()),
93 Parameterised(originalRoute->getACParametersMap()),
94 myRepeat(parse<int>(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
95 myCycleTime(string2time(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
96 myVClass(originalRoute->getVClass()) {
97 // set parents
98 setParents<GNEEdge*>(originalRoute->getParentEdges());
100}
101
102// copy (embedded)
103GNERoute::GNERoute(GNEVehicle* vehicleParent, const GNEDemandElement* originalRoute) :
104 GNEDemandElement(vehicleParent, originalRoute->getTagProperty()->getTag(), originalRoute->getPathElementOptions()),
105 Parameterised(originalRoute->getACParametersMap()),
106 myRepeat(parse<int>(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
107 myCycleTime(string2time(originalRoute->getAttribute(SUMO_ATTR_REPEAT))),
108 myVClass(originalRoute->getVClass()) {
109 // set parents
110 setParents<GNEEdge*>(originalRoute->getParentEdges());
111 setParent<GNEDemandElement*>(vehicleParent);
113}
114
115// basic
116GNERoute::GNERoute(const std::string& id, GNENet* net, const std::string& filename, SUMOVehicleClass vClass,
117 const std::vector<GNEEdge*>& edges, const RGBColor& color, const int repeat,
118 const SUMOTime cycleTime, const Parameterised::Map& parameters) :
119 GNEDemandElement(id, net, filename, SUMO_TAG_ROUTE,
120 GNEPathElement::Options::DEMAND_ELEMENT | GNEPathElement::Options::ROUTE),
121 Parameterised(parameters),
122 myColor(color),
123 myRepeat(repeat),
124 myCycleTime(cycleTime),
125 myVClass(vClass) {
126 // set parents
127 setParents<GNEEdge*>(edges);
128}
129
130
131// embedded route
132GNERoute::GNERoute(GNEDemandElement* vehicleParent, const std::vector<GNEEdge*>& edges, const RGBColor& color,
133 const int repeat, const SUMOTime cycleTime, const Parameterised::Map& parameters) :
135 GNEPathElement::Options::DEMAND_ELEMENT | GNEPathElement::Options::ROUTE),
136 Parameterised(parameters),
137 myColor(color),
138 myRepeat(repeat),
139 myCycleTime(cycleTime),
140 myVClass(vehicleParent->getVClass()) {
141 // set parents
142 setParents<GNEEdge*>(edges);
143 setParent<GNEDemandElement*>(vehicleParent);
144}
145
146
148
149
152 return nullptr;
153}
154
155
158 // create popup
159 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
160 // build common options
162 // show option to open demand element dialog
163 if (myTagProperty->hasDialog()) {
164 GUIDesigns::buildFXMenuCommand(ret, "Open " + getTagStr() + " Dialog", getACIcon(), &parent, MID_OPEN_ADDITIONAL_DIALOG);
165 new FXMenuSeparator(ret);
166 }
167 GUIDesigns::buildFXMenuCommand(ret, "Cursor position in view: " + toString(getPositionInView().x()) + "," + toString(getPositionInView().y()), nullptr, nullptr, 0);
168 new FXMenuSeparator(ret);
169 GUIDesigns::buildFXMenuCommand(ret, "Apply distance along route", nullptr, ret, MID_GNE_ROUTE_APPLY_DISTANCE);
170 // route length
173 // add reverse
175 }
176 return ret;
177}
178
179
180void
182 device.openTag(SUMO_TAG_ROUTE);
183 // write id only for non-embedded routes
185 device.writeAttr(SUMO_ATTR_ID, getID());
186 }
190 }
193 }
196 }
197 // write probability if we have exactly one routeRef
198 std::vector<GNEDemandElement*> refs;
199 for (const auto& routeChild : getChildDemandElements()) {
200 if (routeChild->getTagProperty()->getTag() == GNE_TAG_ROUTEREF) {
201 refs.push_back(routeChild);
202 }
203 }
204 if (refs.size() == 1) {
205 device.writeAttr(SUMO_ATTR_PROB, refs.front()->getAttribute(SUMO_ATTR_PROB));
206 }
207 // write sorted stops
209 // write stops
210 for (const auto& routeChild : getChildDemandElements()) {
211 if (routeChild->getTagProperty()->isVehicleStop()) {
212 routeChild->writeDemandElement(device);
213 }
214 }
215 }
216 // write parameters
217 writeParams(device);
218 // close tag
219 device.closeTag();
220}
221
222
225 // get sorted stops and check number
226 std::vector<GNEDemandElement*> stops;
227 for (const auto& routeChild : getChildDemandElements()) {
228 if (routeChild->getTagProperty()->isVehicleStop()) {
229 stops.push_back(routeChild);
230 }
231 }
232 // check stops
233 if (getInvalidStops().size() > 0) {
235 }
236 // check repeating
237 if (myRepeat > 0) {
238 // avoid repeat in routes with only one edge
239 if (getParentEdges().size() == 1) {
241 }
242 // check if front and last routes are connected
243 if (isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0) {
245 }
246 }
247 // check that exist a connection between every edge
248 if (isRouteValid(getParentEdges()).size() > 0) {
250 } else {
251 return Problem::OK;
252 }
254}
255
256
257std::string
259 // get sorted stops and check number
260 std::vector<GNEDemandElement*> stops;
261 for (const auto& routeChild : getChildDemandElements()) {
262 if (routeChild->getTagProperty()->isVehicleStop()) {
263 stops.push_back(routeChild);
264 }
265 }
266 const auto invalidStops = getInvalidStops();
267 if (invalidStops.size() > 0) {
268 return toString(invalidStops.size()) + " stops are outside of route (downstream)";
269 }
270 // check repeating
271 if (myRepeat > 0) {
272 // avoid repeat in routes with only one edge
273 if (getParentEdges().size() == 1) {
274 return TL("Cannot repeat in routes with only one edge");
275 }
276 // check if front and last routes is connected
277 if (isRouteValid({getParentEdges().back(), getParentEdges().front()}).size() > 0) {
278 return TL("Cannot repeat route; front and last edge aren't connected");
279 }
280 }
281 // return string with the problem obtained from isRouteValid
283}
284
285
286void
288 // currently the only solution is removing Route
289}
290
291
295 return getParentDemandElements().at(0)->getVClass();
296 } else {
297 return myVClass;
298 }
299}
300
301
302const RGBColor&
305 return myColor;
306 } else if ((getParentDemandElements().size() > 0) && (getParentDemandElements().front()->getColor() != RGBColor::INVISIBLE)) {
307 return getParentDemandElements().front()->getColor();
308 } else if ((getChildDemandElements().size() > 0) && (getChildDemandElements().front()->getColor() != RGBColor::INVISIBLE)) {
309 return getChildDemandElements().front()->getColor();
310 } else {
311 return RGBColor::YELLOW;
312 }
313}
314
315
316void
318 // compute geometry
320 // update child demand elements
321 for (const auto& demandElement : getChildDemandElements()) {
322 if (!demandElement->getTagProperty()->isVehicleStop()) {
323 demandElement->updateGeometry();
324 }
325 }
326}
327
328
333
334
335std::string
337 return getParentEdges().front()->getID();
338}
339
340
341double
345
346
349 Boundary routeBoundary;
350 // return the combination of all parent edges's boundaries
351 for (const auto& i : getParentEdges()) {
352 routeBoundary.add(i->getCenteringBoundary());
353 }
354 // check if is valid
355 if (routeBoundary.isInitialised()) {
356 return routeBoundary;
357 } else {
358 return Boundary(-0.1, -0.1, 0.1, 0.1);
359 }
360}
361
362
363void
364GNERoute::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) {
365 // obtain new list of route edges
366 std::string newRouteEdges = getNewListOfParents(originalElement, newElement);
367 // update route edges
368 if (newRouteEdges.size() > 0) {
369 setAttribute(SUMO_ATTR_EDGES, newRouteEdges, undoList);
370 }
371}
372
373
374void
376 // Routes are drawn in drawJunctionPartialGL
377}
378
379
380void
382 // calculate path depending if is embedded
387 } else {
389 }
390 // if path is empty, then calculate path again using SVC_IGNORING
391 if (!myNet->getDemandPathManager()->isPathValid(this)) {
393 }
394}
395
396
397void
398GNERoute::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
399 // check conditions
403 // get exaggeration
404 const double exaggeration = getExaggeration(s);
405 // get detail level
406 const auto d = s.getDetailLevel(exaggeration);
407 // get embedded route flag
408 const bool embedded = (myTagProperty->getTag() == GNE_TAG_ROUTE_EMBEDDED);
409 // get route width
410 const double routeWidth = embedded ? s.widthSettings.embeddedRouteWidth : s.widthSettings.routeWidth;
411 // calculate startPos
412 const double geometryDepartPos = embedded ? (getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getParentDemandElements().at(0)->getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_LENGTH)) : -1;
413 // get endPos
414 const double geometryEndPos = embedded ? getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_ARRIVALPOS) : -1;
415 // declare path geometry
416 GUIGeometry routeGeometry;
417 // update pathGeometry depending of first and last segment
418 if (segment->isFirstSegment() && segment->isLastSegment()) {
419 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
420 geometryDepartPos,
422 geometryEndPos,
424 } else if (segment->isFirstSegment()) {
425 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
426 geometryDepartPos,
428 -1,
430 } else if (segment->isLastSegment()) {
431 routeGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
432 -1,
434 geometryEndPos,
436 } else {
437 routeGeometry = segment->getLane()->getLaneGeometry();
438 }
439 // draw geometry only if we'rent in drawForObjectUnderCursor mode
441 // draw route partial lane
442 drawRoutePartialLane(s, d, segment, offsetFront, routeGeometry, exaggeration);
443 // draw name
445 // draw dotted contour
446 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
447 }
448 // calculate contour
449 segment->getContour()->calculateContourExtrudedShape(s, d, this, routeGeometry.getShape(), getType(), routeWidth, exaggeration,
450 segment->isFirstSegment(), segment->isLastSegment(), 0, segment, segment->getLane()->getParentEdge());
451 // check if add this path element to redraw buffer
454 }
455 }
456}
457
458
459void
460GNERoute::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
461 // check conditions
465 // Obtain exaggeration of the draw
466 const double routeExaggeration = getExaggeration(s);
467 // get detail level
468 const auto d = s.getDetailLevel(routeExaggeration);
469 // get route width
471 // check if connection to next lane exist
472 const bool connectionExist = segment->getPreviousLane()->getLane2laneConnections().exist(segment->getNextLane());
473 // get geometry
474 const GUIGeometry& routeGeometry = connectionExist ? segment->getPreviousLane()->getLane2laneConnections().getLane2laneGeometry(segment->getNextLane()) :
475 GUIGeometry({segment->getPreviousLane()->getLaneShape().back(), segment->getNextLane()->getLaneShape().front()});
476 // draw geometry only if we'rent in drawForObjectUnderCursor mode
478 // draw route partial
479 drawRoutePartialJunction(s, d, offsetFront, routeGeometry, routeExaggeration);
480 // draw dotted contour
481 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
482 }
483 // calculate contour
484 segment->getContour()->calculateContourExtrudedShape(s, d, this, routeGeometry.getShape(), getType(), routeWidth, routeExaggeration,
485 false, false, 0, segment, segment->getJunction());
486 // check if add this path element to redraw buffer
489 }
490 }
491}
492
493
494GNELane*
497 return getParentEdges().front()->getLaneByAllowedVClass(SVC_PASSENGER);
498 } else {
499 return getParentDemandElements().at(0)->getFirstPathLane();
500 }
501}
502
503
504GNELane*
507 return getParentEdges().back()->getLaneByAllowedVClass(SVC_PASSENGER);
508 } else {
509 return getParentDemandElements().at(0)->getLastPathLane();
510 }
511}
512
513
514std::string
516 switch (key) {
517 case SUMO_ATTR_ID:
518 return getMicrosimID();
519 case SUMO_ATTR_EDGES:
520 return parseIDs(getParentEdges());
521 case SUMO_ATTR_COLOR:
523 return toString(myColor);
524 } else {
525 return "";
526 }
527 case SUMO_ATTR_REPEAT:
528 return toString(myRepeat);
530 return time2string(myCycleTime);
531 default:
532 return getCommonAttribute(this, key);
533 }
534}
535
536
537double
539 switch (key) {
541 return 0;
543 return getParentEdges().back()->getChildLanes().front()->getLaneShape().length2D();
544 default:
545 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
546 }
547}
548
549
552 switch (key) {
554 return getParentEdges().front()->getChildLanes().front()->getLaneShape().front();
556 return getParentEdges().back()->getChildLanes().front()->getLaneShape().back();
557 default:
558 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
559 }
560}
561
562
563bool
565 return true;
566}
567
568
569void
570GNERoute::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
571 if (value == getAttribute(key)) {
572 return; //avoid needless changes, later logic relies on the fact that attributes have changed
573 }
574 switch (key) {
575 case SUMO_ATTR_ID:
576 case SUMO_ATTR_COLOR:
577 case SUMO_ATTR_REPEAT:
579 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
580 break;
581 // special case due depart and arrival edge vehicles
582 case SUMO_ATTR_EDGES: {
583 // extract all vehicle childrens
584 std::vector<GNEDemandElement*> vehicles;
585 for (const auto& childDemandElement : getChildDemandElements()) {
586 if (childDemandElement->getTagProperty()->isVehicle()) {
587 vehicles.push_back(childDemandElement);
588 }
589 }
590 // check vehicles
591 if (vehicles.size() > 0) {
592 undoList->begin(this, "reset start and end edges");
593 for (const auto& vehicle : vehicles) {
596 }
597 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
598 undoList->end();
600 undoList->begin(this, "reset start and end edges");
603 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
604 undoList->end();
605 } else {
606 // just change edges
607 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
608 }
609 break;
610 }
611 default:
612 setCommonAttribute(key, value, undoList);
613 break;
614 }
615}
616
617
618bool
619GNERoute::isValid(SumoXMLAttr key, const std::string& value) {
620 switch (key) {
621 case SUMO_ATTR_ID:
622 return isValidDemandElementID(value);
623 case SUMO_ATTR_EDGES:
624 if (value.empty()) {
625 return false;
626 } else {
627 return canParse<std::vector<GNEEdge*> >(myNet, value, true);
628 }
629 case SUMO_ATTR_COLOR:
630 if (value.empty()) {
631 return true;
632 } else {
633 return canParse<RGBColor>(value);
634 }
635 case SUMO_ATTR_REPEAT:
636 return canParse<int>(value) && (parse<int>(value) >= 0);
638 if (canParse<SUMOTime>(value)) {
639 return (parse<SUMOTime>(value) >= 0);
640 } else {
641 return false;
642 }
643 default:
644 return isCommonValid(key, value);
645 }
646}
647
648
649std::string
651 return getTagStr();
652}
653
654
655std::string
657 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) ;
658}
659
660
665
666
667std::string
668GNERoute::isRouteValid(const std::vector<GNEEdge*>& edges) {
669 if (edges.size() == 0) {
670 // routes cannot be empty
671 return ("list of route edges cannot be empty");
672 } else if (edges.size() == 1) {
673 // routes with a single edge are valid, then return an empty string
674 return ("");
675 } else {
676 // iterate over edges to check that compounds a chain
677 auto it = edges.begin();
678 while (it != edges.end() - 1) {
679 const GNEEdge* currentEdge = *it;
680 const GNEEdge* nextEdge = *(it + 1);
681 // same consecutive edges aren't allowed
682 if (currentEdge->getID() == nextEdge->getID()) {
683 return ("consecutive duplicated edges (" + currentEdge->getID() + ") aren't allowed in a route");
684 }
685 // obtain outgoing edges of currentEdge
686 const std::vector<GNEEdge*>& outgoingEdges = currentEdge->getToJunction()->getGNEOutgoingEdges();
687 // check if nextEdge is in outgoingEdges
688 if (std::find(outgoingEdges.begin(), outgoingEdges.end(), nextEdge) == outgoingEdges.end()) {
689 return ("Edges '" + currentEdge->getID() + "' and '" + nextEdge->getID() + "' aren't consecutives");
690 }
691 it++;
692 }
693 // all edges consecutives, then return an empty string
694 return ("");
695 }
696}
697
699GNERoute::copyRoute(const GNERoute* originalRoute) {
700 // get net and undoList
701 const auto net = originalRoute->getNet();
702 auto undoList = net->getViewNet()->getUndoList();
703 // generate new route ID
704 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
705 // create new route
706 GNERoute* newRoute = new GNERoute(newRouteID, originalRoute);
707 // add new route using undo-list
708 undoList->begin(originalRoute, TLF("copy % '%'", originalRoute->getTagStr(), newRouteID));
709 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
710 undoList->end();
711 // return new route
712 return newRoute;
713}
714
715// ===========================================================================
716// private
717// ===========================================================================
718
719void
721 const GNESegment* segment, const double offsetFront,
722 const GUIGeometry& geometry, const double exaggeration) const {
723 // get route width
725 // push layer matrix
727 // Start with the drawing of the area traslating matrix to origin
728 glTranslated(0, 0, getType() + offsetFront);
729 // Set color
730 if (drawUsingSelectColor()) {
732 } else {
734 }
735 // draw geometry
736 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
737 // check if we have to draw a red line to the next segment
738 if (segment->getNextLane()) {
739 // push draw matrix
741 // Set red color
743 // get firstPosition (last position of current lane shape)
744 const Position firstPosition = segment->getLane()->getLaneShape().back();
745 // get lastPosition (first position of next lane shape)
746 const Position arrivalPos = segment->getNextLane()->getLaneShape().front();
747 // draw box line
748 GLHelper::drawBoxLine(arrivalPos,
749 RAD2DEG(firstPosition.angleTo2D(arrivalPos)) - 90,
750 firstPosition.distanceTo2D(arrivalPos), .05);
751 // pop draw matrix
753 }
754 // Pop layer matrix
756}
757
758
759void
761 const double offsetFront, const GUIGeometry& geometry, const double exaggeration) const {
762 const bool invalid = geometry.getShape().length() == 2;
763 // get route width
765 // Add a draw matrix
767 // Start with the drawing of the area traslating matrix to origin
768 glTranslated(0, 0, getType() + offsetFront);
769 // Set color of the base
770 if (drawUsingSelectColor()) {
772 } else if (invalid) {
774 } else {
776 }
777 // draw geometry
778 GUIGeometry::drawGeometry(d, geometry, routeWidth * exaggeration);
779 // Pop last matrix
781}
782
783
784void
785GNERoute::setAttribute(SumoXMLAttr key, const std::string& value) {
786 switch (key) {
787 case SUMO_ATTR_ID:
788 // update microsimID
789 setDemandElementID(value);
790 break;
791 case SUMO_ATTR_EDGES:
792 // replace parents
793 replaceParentEdges(value);
794 // compute route
796 // update all parent and child demand elements
797 for (const auto& element : getParentDemandElements()) {
798 element->updateGeometry();
799 }
800 for (const auto& element : getChildDemandElements()) {
801 element->updateGeometry();
802 }
803 break;
804 case SUMO_ATTR_COLOR:
805 if (value.empty()) {
807 } else {
808 myColor = parse<RGBColor>(value);
809 }
810 break;
811 case SUMO_ATTR_REPEAT:
812 if (value.empty()) {
814 } else {
815 myRepeat = parse<int>(value);
816 }
817 break;
819 if (value.empty()) {
821 } else {
822 myCycleTime = string2time(value);
823 }
824 break;
825 default:
826 setCommonAttribute(this, key, value);
827 break;
828 }
829}
830
831
832void
833GNERoute::setMoveShape(const GNEMoveResult& /*moveResult*/) {
834 // routes cannot be moved
835}
836
837
838void
839GNERoute::commitMoveShape(const GNEMoveResult& /*moveResult*/, GNEUndoList* /*undoList*/) {
840 // routes cannot be moved
841}
842
843/****************************************************************************/
FXDEFMAP(GNERoute::GNERoutePopupMenu) GNERoutePopupMenuMap[]
long long int SUMOTime
Definition GUI.h:36
@ MID_OPEN_ADDITIONAL_DIALOG
open additional dialog (used in netedit)
Definition GUIAppEnum.h:469
@ MID_GNE_ROUTE_APPLY_DISTANCE
apply distance
GUIViewObjectsHandler gViewObjectsHandler
#define RAD2DEG(x)
Definition GeomHelper.h:36
#define TL(string)
Definition MsgHandler.h:305
#define TLF(string,...)
Definition MsgHandler.h:307
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:91
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_ROUTE
description of a route
@ GNE_TAG_ROUTEREF
virtual element used to reference routes with distributions
@ GNE_TAG_ROUTE_EMBEDDED
embedded route
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_ARRIVALLANE
@ SUMO_ATTR_DEPARTEDGE
@ SUMO_ATTR_ARRIVALEDGE
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_DEPARTLANE
@ SUMO_ATTR_DISTANCE
@ SUMO_ATTR_PROB
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ SUMO_ATTR_REPEAT
@ SUMO_ATTR_CYCLETIME
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:75
bool isInitialised() const
check if Boundary is Initialised
Definition Boundary.cpp:256
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:653
static void popMatrix()
pop matrix
Definition GLHelper.cpp:135
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:300
static void pushMatrix()
push matrix
Definition GLHelper.cpp:122
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
bool mySelected
boolean to check if this AC is selected (more quickly as checking GUIGlObjectStorage)
std::string getCommonAttribute(const Parameterised *parameterised, SumoXMLAttr key) const
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.
GNENet * myNet
pointer to net
bool isCommonValid(SumoXMLAttr key, const std::string &value) const
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
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset, const GNESegment *segment, const GUIGlObject *boundaryParent, const bool addToSelectedObjects=true) const
calculate contour extruded (used in elements formed by a central shape)
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
bool checkDrawPathContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC) const
drawing contour functions
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
std::vector< GNEDemandElement * > getInvalidStops() const
get invalid stops
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
virtual std::string getAttribute(SumoXMLAttr key) const =0
void setDemandElementID(const std::string &newID)
set demand element id
void buildMenuAddReverse(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceParentEdges(const std::string &value)
all edges
Problem
enum class for demandElement problems
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:79
const GNEHierarchicalContainerParents< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
std::string getNewListOfParents(const GNENetworkElement *currentElement, const GNENetworkElement *newNextElement) const
if use edge/parent lanes as a list of consecutive elements, obtain a list of IDs of elements after in...
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given toLane
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
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:220
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:692
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition GNELane.cpp:325
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:214
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:202
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:177
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2195
bool checkDrawPathGeometry(const GUIVisualizationSettings &s, const GNELane *lane, const SumoXMLTag tag, const bool isPlan)
check if path element geometry must be drawn in the given lane
PathDraw * getPathDraw()
obtain instance of PathDraw
bool isPathValid(const GNEPathElement *pathElement) const
check if path element is valid
void calculateConsecutivePathEdges(GNEPathElement *pathElement, SUMOVehicleClass vClass, const std::vector< GNEEdge * > &edges, const int firstLaneIndex=-1, const int lastLaneIndex=-1)
calculate consecutive path edges
class used in GUIGLObjectPopupMenu for routes
Definition GNERoute.h:42
~GNERoutePopupMenu()
Destructor.
Definition GNERoute.cpp:58
long onCmdApplyDistance(FXObject *, FXSelector, void *)
Called to modify edge distance values along the route.
Definition GNERoute.cpp:62
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition GNERoute.cpp:656
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition GNERoute.cpp:287
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition GNERoute.cpp:342
GNELane * getLastPathLane() const
get last path lane
Definition GNERoute.cpp:505
Position getPositionInView() const
Returns position of additional in view.
Definition GNERoute.cpp:330
SUMOVehicleClass myVClass
SUMOVehicleClass (Only used for drawing)
Definition GNERoute.h:276
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
Definition GNERoute.cpp:460
std::string getParentName() const
Returns the name of the parent object.
Definition GNERoute.cpp:336
SUMOTime myCycleTime
cycleTime
Definition GNERoute.h:273
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition GNERoute.cpp:650
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition GNERoute.cpp:515
Position getAttributePosition(SumoXMLAttr key) const
Definition GNERoute.cpp:551
void updateGeometry()
update pre-computed geometry information
Definition GNERoute.cpp:317
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition GNERoute.cpp:157
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:760
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition GNERoute.cpp:364
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition GNERoute.cpp:833
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition GNERoute.cpp:662
static GNEDemandElement * copyRoute(const GNERoute *originalRoute)
create a copy of the given route
Definition GNERoute.cpp:699
GNELane * getFirstPathLane() const
get first path lane
Definition GNERoute.cpp:495
double getAttributeDouble(SumoXMLAttr key) const
Definition GNERoute.cpp:538
GNEMoveOperation * getMoveOperation()
get move operation
Definition GNERoute.cpp:151
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition GNERoute.cpp:839
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition GNERoute.cpp:293
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:720
GNERoute(SumoXMLTag tag, GNENet *net)
default constructor
Definition GNERoute.cpp:79
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNERoute.cpp:348
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition GNERoute.cpp:619
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition GNERoute.cpp:375
static std::string isRouteValid(const std::vector< GNEEdge * > &edges)
check if a route is valid
Definition GNERoute.cpp:668
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:570
int myRepeat
repeat
Definition GNERoute.h:270
void computePathElement()
compute pathElement
Definition GNERoute.cpp:381
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
Definition GNERoute.cpp:398
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition GNERoute.cpp:258
RGBColor myColor
route color
Definition GNERoute.h:267
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
Definition GNERoute.cpp:181
~GNERoute()
destructor
Definition GNERoute.cpp:147
bool isAttributeEnabled(SumoXMLAttr key) const
Definition GNERoute.cpp:564
const RGBColor & getColor() const
get color
Definition GNERoute.cpp:303
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
Definition GNERoute.cpp:224
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
const RGBColor & getDefaultColorValue(SumoXMLAttr attr) const
get default bool value
double getDefaultDoubleValue(SumoXMLAttr attr) const
get default double value
SUMOTime getDefaultTimeValue(SumoXMLAttr attr) const
get default time value
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool hasDialog() const
return true if tag correspond to an element that can be edited using a dialog
int getDefaultIntValue(SumoXMLAttr attr) const
get default int value
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
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.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildPopUpMenuCommonOptions(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, GUISUMOAbstractView *parent, const SumoXMLTag tag, const bool selected, bool addSeparator=true)
virtual Position getCenter() const
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
void addToRedrawPathElements(const GNEPathElement *pathElement)
add path element to redrawing set
bool isPathElementMarkForRedraw(const GNEPathElement *pathElement) const
check if the given path element has to be redraw again
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
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.
std::map< std::string, std::string > Map
parameters map
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:319
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:273
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition Position.h:283
double length() const
Returns the length.
static const RGBColor YELLOW
Definition RGBColor.h:191
static const RGBColor INVISIBLE
Definition RGBColor.h:198
static const RGBColor RED
named colors
Definition RGBColor.h:188
bool showDemandElements() const
check if show demand elements checkbox is enabled
bool showNonInspectedDemandElements(const GNEDemandElement *demandElement) const
check if non inspected element has to be hidden
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