Eclipse SUMO - Simulation of Urban MObility
GNEPathCreator.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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// Frame for create paths
19/****************************************************************************/
20#include <config.h>
21
23#include <netedit/GNENet.h>
24#include <netedit/GNEViewNet.h>
31
32#include "GNEPathCreator.h"
33
34
35// ===========================================================================
36// FOX callback mapping
37// ===========================================================================
38
39FXDEFMAP(GNEPathCreator) PathCreatorMap[] = {
46};
47
48// Object implementation
49FXIMPLEMENT(GNEPathCreator, MFXGroupBoxModule, PathCreatorMap, ARRAYNUMBER(PathCreatorMap))
50
51
52// ===========================================================================
53// method definitions
54// ===========================================================================
55
57 mySubPath({edge}),
58 myFromBusStop(nullptr),
59 myToBusStop(nullptr),
60 myConflictVClass(false),
61myConflictDisconnected(false) {
62 // check if we have to change vClass flag
63 if (edge->getNBEdge()->getNumLanesThatAllow(vClass) == 0) {
64 myConflictVClass = true;
65 }
66}
67
68
69GNEPathCreator::Path::Path(GNEViewNet* viewNet, const SUMOVehicleClass vClass, GNEEdge* edgeFrom, GNEEdge* edgeTo) :
70 myFromBusStop(nullptr),
71 myToBusStop(nullptr),
72 myConflictVClass(false),
73 myConflictDisconnected(false) {
74 // calculate subpath
75 mySubPath = viewNet->getNet()->getPathManager()->getPathCalculator()->calculateDijkstraPath(vClass, {edgeFrom, edgeTo});
76 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
77 if (mySubPath.empty()) {
79 if (mySubPath.empty()) {
80 mySubPath = { edgeFrom, edgeTo };
82 } else {
83 myConflictVClass = true;
84 }
85 }
86}
87
88
89GNEPathCreator::Path::Path(GNEViewNet* viewNet, const SUMOVehicleClass vClass, GNEJunction* junctionFrom, GNEJunction* junctionTo) :
90 myFromBusStop(nullptr),
91 myToBusStop(nullptr),
92 myConflictVClass(false),
93 myConflictDisconnected(false) {
94 // calculate subpath
95 mySubPath = viewNet->getNet()->getPathManager()->getPathCalculator()->calculateDijkstraPath(vClass, junctionFrom, junctionTo);
96 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
97 if (mySubPath.empty()) {
98 mySubPath = viewNet->getNet()->getPathManager()->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, junctionFrom, junctionTo);
99 if (mySubPath.empty()) {
101 } else {
102 myConflictVClass = true;
103 }
104 }
105}
106
107
108const std::vector<GNEEdge*>&
110 return mySubPath;
111}
112
113
115 return myFromBusStop;
116}
117
118
120 return myToBusStop;
121}
122
123
124bool
126 return myConflictVClass;
127}
128
129
130bool
132 return myConflictDisconnected;
133}
134
135
137 myFromBusStop(nullptr),
138 myToBusStop(nullptr),
139 myConflictVClass(false),
140 myConflictDisconnected(false) {
141}
142
143
145 MFXGroupBoxModule(frameParent, TL("Route creator")),
146 myFrameParent(frameParent),
149 myToStoppingPlace(nullptr),
150 myRoute(nullptr) {
151 // create label for route info
152 myInfoRouteLabel = new FXLabel(getCollapsableFrame(), "No edges selected", 0, GUIDesignLabelFrameThicked);
153 // create button for use last route
155 myUseLastRoute->disable();
156 // create button for finish route creation
157 myFinishCreationButton = new FXButton(getCollapsableFrame(), TL("Finish route creation"), nullptr, this, MID_GNE_PATHCREATOR_FINISH, GUIDesignButton);
158 myFinishCreationButton->disable();
159 // create button for abort route creation
160 myAbortCreationButton = new FXButton(getCollapsableFrame(), TL("Abort route creation"), nullptr, this, MID_GNE_PATHCREATOR_ABORT, GUIDesignButton);
161 myAbortCreationButton->disable();
162 // create button for remove last inserted edge
163 myRemoveLastInsertedElement = new FXButton(getCollapsableFrame(), TL("Remove last edge"), nullptr, this, MID_GNE_PATHCREATOR_REMOVELAST, GUIDesignButton);
165 // create check button
166 myShowCandidateEdges = new FXCheckButton(getCollapsableFrame(), TL("Show candidate edges"), this, MID_GNE_PATHCREATOR_SHOWCANDIDATES, GUIDesignCheckButton);
167 myShowCandidateEdges->setCheck(TRUE);
168 // create shift label
169 myShiftLabel = new FXLabel(this,
170 "SHIFT-click: ignore vClass",
172 // create control label
173 myControlLabel = new FXLabel(this,
174 "CTRL-click: force add",
176 // create backspace label (always shown)
177 myBackSpaceLabel = new FXLabel(this,
178 "BACKSPACE: undo click",
180}
181
182
184
185
186void
187GNEPathCreator::showPathCreatorModule(SumoXMLTag element, const bool firstElement, const bool consecutives) {
188 // declare flag
189 bool showPathCreator = true;
190 // first abort creation
192 // hide use last inserted route
193 myUseLastRoute->hide();
194 // disable buttons
195 myFinishCreationButton->disable();
196 myAbortCreationButton->disable();
198 // show info label
199 myInfoRouteLabel->show();
200 myShowCandidateEdges->show();
201 myShiftLabel->show();
202 myControlLabel->show();
203 myBackSpaceLabel->show();
204 // reset creation mode
205 myCreationMode = 0;
206 // set first element
207 if (firstElement) {
209 }
210 // set consecutive or non consecuives
211 if (consecutives) {
213 } else {
215 }
216 // set specific mode depending of tag
217 switch (element) {
218 // routes
219 case SUMO_TAG_ROUTE:
224 break;
225 // vehicles
226 case SUMO_TAG_VEHICLE:
230 // show use last inserted route
231 myUseLastRoute->show();
232 // disable other elements
234 myAbortCreationButton->hide();
236 myInfoRouteLabel->hide();
237 myShowCandidateEdges->hide();
238 myShiftLabel->hide();
239 myControlLabel->hide();
240 myBackSpaceLabel->hide();
241 break;
242 case SUMO_TAG_TRIP:
243 case SUMO_TAG_FLOW:
249 break;
256 break;
257 // edges
263 break;
264 // edge->edge
274 break;
275 // edge->busStop
283 break;
284 // edge->containerStop
291 break;
292 // junction->junction
299 break;
300 // stops (person and containers)
304 break;
308 break;
313 break;
314 // generic datas
315 case SUMO_TAG_EDGEREL:
319 break;
320 default:
321 showPathCreator = false;
322 break;
323 }
324 // update colors
327 // check if show path creator
328 if (showPathCreator) {
329 // recalc before show (to avoid graphic problems)
330 recalc();
331 // show modul
332 show();
333 } else {
334 // hide modul
335 hide();
336 }
337}
338
339
340void
342 // clear path
343 clearPath();
344 // hide modul
345 hide();
346}
347
348
351 return myVClass;
352}
353
354
355void
357 myVClass = vClass;
358 // update edge colors
360}
361
362
363bool
364GNEPathCreator::addJunction(GNEJunction* junction, const bool /* shiftKeyPressed */, const bool /* controlKeyPressed */) {
365 // check if junctions are allowed
366 if (((myCreationMode & START_JUNCTION) == 0) && ((myCreationMode & END_JUNCTION) == 0)) {
367 return false;
368 }
369 // continue depending of number of selected edge
370 if (mySelectedJunctions.size() > 0) {
371 // check double junctions
372 if (mySelectedJunctions.back() == junction) {
373 // Write warning
374 WRITE_WARNING(TL("Double junctions aren't allowed"));
375 // abort add junction
376 return false;
377 }
378 }
379 // check number of junctions
380 if (mySelectedJunctions.size() == 2 && (myCreationMode & Mode::ONLY_FROMTO)) {
381 // Write warning
382 WRITE_WARNING(TL("Only two junctions are allowed"));
383 // abort add junction
384 return false;
385 }
386 // All checks ok, then add it in selected elements
387 mySelectedJunctions.push_back(junction);
388 // enable abort route button
389 myAbortCreationButton->enable();
390 // enable finish button
391 myFinishCreationButton->enable();
392 // disable undo/redo
394 // enable or disable remove last junction button
395 if (mySelectedJunctions.size() > 1) {
397 } else {
399 }
400 // recalculate path
402 // update info route label
404 // update junction colors
406 return true;
407}
408
409
410bool
411GNEPathCreator::addEdge(GNEEdge* edge, const bool shiftKeyPressed, const bool controlKeyPressed) {
412 // check if edges are allowed
413 if (((myCreationMode & START_EDGE) == 0) && ((myCreationMode & END_EDGE) == 0)) {
414 return false;
415 }
416 // continue depending of number of selected eges
417 if (mySelectedEdges.size() > 0) {
418 // check double edges
419 if (mySelectedEdges.back() == edge) {
420 // Write warning
421 WRITE_WARNING(TL("Double edges aren't allowed"));
422 // abort add edge
423 return false;
424 }
425 // check consecutive edges
426 if (myCreationMode & Mode::CONSECUTIVE_EDGES) {
427 // check that new edge is consecutive
428 const auto& outgoingEdges = mySelectedEdges.back()->getToJunction()->getGNEOutgoingEdges();
429 if (std::find(outgoingEdges.begin(), outgoingEdges.end(), edge) == outgoingEdges.end()) {
430 // Write warning
431 WRITE_WARNING(TL("Only consecutives edges are allowed"));
432 // abort add edge
433 return false;
434 }
435 }
436 }
437 // check number of edges
438 if (mySelectedEdges.size() == 2 && (myCreationMode & Mode::ONLY_FROMTO)) {
439 // Write warning
440 WRITE_WARNING(TL("Only two edges are allowed"));
441 // abort add edge
442 return false;
443 }
444 // check candidate edge
445 if ((myShowCandidateEdges->getCheck() == TRUE) && !edge->isPossibleCandidate()) {
446 if (edge->isSpecialCandidate()) {
447 if (!shiftKeyPressed) {
448 // Write warning
449 WRITE_WARNING("Invalid edge (SHIFT + click to add an invalid vClass edge)");
450 // abort add edge
451 return false;
452 }
453 } else if (edge->isConflictedCandidate()) {
454 if (!controlKeyPressed) {
455 // Write warning
456 WRITE_WARNING("Invalid edge (CONTROL + click to add a disconnected edge)");
457 // abort add edge
458 return false;
459 }
460 }
461 }
462 // All checks ok, then add it in selected elements
463 mySelectedEdges.push_back(edge);
464 // enable abort route button
465 myAbortCreationButton->enable();
466 // enable finish button
467 myFinishCreationButton->enable();
468 // disable undo/redo
470 // enable or disable remove last edge button
471 if (mySelectedEdges.size() > 1) {
473 } else {
475 }
476 // recalculate path
478 // update info route label
480 // update edge colors
482 // if is a stop, create inmediately
483 if (myCreationMode & STOP) {
484 if (createPath(false)) {
485 return true;
486 } else {
487 mySelectedEdges.pop_back();
488 // recalculate path again
490 // update info route label
492 // update edge colors
494 return false;
495 }
496 } else {
497 return true;
498 }
499}
500
501
502const std::vector<GNEEdge*>&
504 return mySelectedEdges;
505}
506
507
508const std::vector<GNEJunction*>&
510 return mySelectedJunctions;
511}
512
513
514bool
515GNEPathCreator::addStoppingPlace(GNEAdditional* stoppingPlace, const bool /*shiftKeyPressed*/, const bool /*controlKeyPressed*/) {
516 if (stoppingPlace == nullptr) {
517 return false;
518 }
519 // check if stoppingPlaces aren allowed
520 if (((myCreationMode & END_BUSSTOP) == 0) && ((myCreationMode & END_CONTAINERSTOP) == 0)) {
521 return false;
522 }
523 if (((myCreationMode & END_BUSSTOP) != 0) && (stoppingPlace->getTagProperty().getTag() != SUMO_TAG_BUS_STOP)) {
524 return false;
525 }
526 if (((myCreationMode & END_CONTAINERSTOP) != 0) && (stoppingPlace->getTagProperty().getTag() != SUMO_TAG_CONTAINER_STOP)) {
527 return false;
528 }
529 // avoid select first an stopping place
530 if (((myCreationMode & START_EDGE) != 0) && mySelectedEdges.empty()) {
531 WRITE_WARNING(TL("first select an edge"));
532 return false;
533 }
534 // check if previously stopping place from was set
535 if (myToStoppingPlace) {
536 return false;
537 } else {
538 myToStoppingPlace = stoppingPlace;
539 }
540 // enable abort route button
541 myAbortCreationButton->enable();
542 // enable finish button
543 myFinishCreationButton->enable();
544 // disable undo/redo
546 // enable or disable remove last stoppingPlace button
547 if (myToStoppingPlace) {
549 } else {
551 }
552 // recalculate path
554 // update info route label
556 // update stoppingPlace colors
558 // if is a stop, create inmediately
559 if (myCreationMode & STOP) {
560 if (createPath(false)) {
561 return true;
562 } else {
563 myToStoppingPlace = nullptr;
564 // recalculate path again
566 // update info route label
568 // update stoppingPlace colors
570 return false;
571 }
572 } else {
573 return true;
574 }
575}
576
577
580 if (myToStoppingPlace && (myToStoppingPlace->getTagProperty().getTag() == expectedTag)) {
581 return myToStoppingPlace;
582 } else {
583 return nullptr;
584 }
585}
586
587
588bool
589GNEPathCreator::addRoute(GNEDemandElement* route, const bool /*shiftKeyPressed*/, const bool /*controlKeyPressed*/) {
590 // check if routes aren allowed
591 if ((myCreationMode & ROUTE) == 0) {
592 return false;
593 }
594 // check if previously a route was added
595 if (myRoute) {
596 return false;
597 }
598 // set route and create path
599 myRoute = route;
600 createPath(false);
601 myRoute = nullptr;
602 // recalculate path
606 return true;
607}
608
609
612 return myRoute;
613}
614
615
616const std::vector<GNEPathCreator::Path>&
618 return myPath;
619}
620
621
622bool
624 return (myShowCandidateEdges->getCheck() == TRUE);
625}
626
627
628void
630 // clear junction colors
632 // check if show possible candidates
634 // set candidate flags
635 for (const auto& junction : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getJunctions()) {
636 junction.second->resetCandidateFlags();
637 junction.second->setPossibleCandidate(true);
638 }
639 }
640 // set selected junctions
641 if (mySelectedJunctions.size() > 0) {
642 // mark selected eges
643 for (const auto& junction : mySelectedJunctions) {
644 junction->resetCandidateFlags();
645 junction->setSourceCandidate(true);
646 }
647 // finally mark last selected element as target
648 mySelectedJunctions.back()->resetCandidateFlags();
649 mySelectedJunctions.back()->setTargetCandidate(true);
650 }
651 // update view net
653}
654
655
656void
658 // clear edge colors
660 // first check if show candidate edges
661 if (myShowCandidateEdges->getCheck() == TRUE && (myCreationMode & SHOW_CANDIDATE_EDGES)) {
662 // mark all edges that have at least one lane that allow given vClass
663 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
664 if (edge.second->getNBEdge()->getNumLanesThatAllow(myVClass) > 0) {
665 edge.second->setPossibleCandidate(true);
666 } else {
667 edge.second->setSpecialCandidate(true);
668 }
669 }
670 }
671 // set reachability
672 if (mySelectedEdges.size() > 0) {
673 // only coloring edges if checkbox "show candidate edges" is enabled
674 if ((myShowCandidateEdges->getCheck() == TRUE) && (myCreationMode & SHOW_CANDIDATE_EDGES)) {
675 // mark all edges as conflicted (to mark special candidates)
676 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
677 edge.second->resetCandidateFlags();
678 edge.second->setConflictedCandidate(true);
679 }
680 // set special candidates (Edges that are connected but aren't compatibles with current vClass
682 // mark again all edges as conflicted (to mark possible candidates)
683 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
684 edge.second->setConflictedCandidate(true);
685 }
686 // set possible candidates (Edges that are connected AND are compatibles with current vClass
688 }
689 // now mark selected eges
690 for (const auto& edge : mySelectedEdges) {
691 edge->resetCandidateFlags();
692 edge->setSourceCandidate(true);
693 }
694 // finally mark last selected element as target
695 mySelectedEdges.back()->resetCandidateFlags();
696 mySelectedEdges.back()->setTargetCandidate(true);
697 }
698 // update view net
700}
701
702
703void
705 // reset all junction flags
706 for (const auto& junction : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getJunctions()) {
707 junction.second->resetCandidateFlags();
708 }
709}
710
711
712void
714 // reset all junction flags
715 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
716 edge.second->resetCandidateFlags();
717 }
718}
719
720
721void
723 const double lineWidth = 0.35;
724 const double lineWidthin = 0.25;
725 // Add a draw matrix
727 // Start with the drawing of the area traslating matrix to origin
728 glTranslated(0, 0, GLO_MAX - 0.1);
729 // check if draw bewteen junction or edges
730 if (myPath.size() > 0) {
731 // set first color
733 // iterate over path
734 for (int i = 0; i < (int)myPath.size(); i++) {
735 // get path
736 const GNEPathCreator::Path& path = myPath.at(i);
737 // draw line over
738 for (int j = 0; j < (int)path.getSubPath().size(); j++) {
739 const GNELane* lane = path.getSubPath().at(j)->getLanes().back();
740 if (((i == 0) && (j == 0)) || (j > 0)) {
741 GLHelper::drawBoxLines(lane->getLaneShape(), lineWidth);
742 }
743 // draw connection between lanes
744 if ((j + 1) < (int)path.getSubPath().size()) {
745 const GNELane* nextLane = path.getSubPath().at(j + 1)->getLanes().back();
746 if (lane->getLane2laneConnections().exist(nextLane)) {
748 } else {
749 GLHelper::drawBoxLines({lane->getLaneShape().back(), nextLane->getLaneShape().front()}, lineWidth);
750 }
751 }
752 }
753 }
754 glTranslated(0, 0, 0.1);
755 // iterate over path again
756 for (int i = 0; i < (int)myPath.size(); i++) {
757 // get path
758 const GNEPathCreator::Path& path = myPath.at(i);
759 // set path color color
762 } else if (path.isConflictDisconnected()) {
764 } else if (path.isConflictVClass()) {
766 } else {
768 }
769 // draw line over
770 for (int j = 0; j < (int)path.getSubPath().size(); j++) {
771 const GNELane* lane = path.getSubPath().at(j)->getLanes().back();
772 if (((i == 0) && (j == 0)) || (j > 0)) {
773 GLHelper::drawBoxLines(lane->getLaneShape(), lineWidthin);
774 }
775 // draw connection between lanes
776 if ((j + 1) < (int)path.getSubPath().size()) {
777 const GNELane* nextLane = path.getSubPath().at(j + 1)->getLanes().back();
778 if (lane->getLane2laneConnections().exist(nextLane)) {
780 } else {
781 GLHelper::drawBoxLines({ lane->getLaneShape().back(), nextLane->getLaneShape().front() }, lineWidthin);
782 }
783 }
784 }
785 }
786 } else if (mySelectedJunctions.size() > 0) {
787 // set color
789 // draw line between junctions
790 for (int i = 0; i < (int)mySelectedJunctions.size() - 1; i++) {
791 // get two points
792 const Position posA = mySelectedJunctions.at(i)->getPositionInView();
793 const Position posB = mySelectedJunctions.at(i + 1)->getPositionInView();
794 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) 180.0 / (double)M_PI);
795 const double len = posA.distanceTo2D(posB);
796 // draw line
797 GLHelper::drawBoxLine(posA, rot, len, 0.25);
798 }
799 }
800 // Pop last matrix
802}
803
804
805bool
806GNEPathCreator::createPath(const bool useLastRoute) {
807 // call create path implemented in frame parent
808 return myFrameParent->createPath(useLastRoute);
809}
810
811
812void
814 // first check that there is elements
815 if ((mySelectedJunctions.size() > 0) || (mySelectedEdges.size() > 0) || myToStoppingPlace || myRoute) {
816 // unblock undo/redo
818 // clear edges
819 clearPath();
820 // disable buttons
821 myFinishCreationButton->disable();
822 myAbortCreationButton->disable();
824 // update info route label
826 // update junction colors
828 // update edge colors
830 // update view (to see the new route)
832 }
833}
834
835
836void
838 if (mySelectedEdges.size() > 1) {
839 // remove special color of last selected edge
840 mySelectedEdges.back()->resetCandidateFlags();
841 // remove last edge
842 mySelectedEdges.pop_back();
843 // change last edge flag
844 if ((mySelectedEdges.size() > 0) && mySelectedEdges.back()->isSourceCandidate()) {
845 mySelectedEdges.back()->setSourceCandidate(false);
846 mySelectedEdges.back()->setTargetCandidate(true);
847 }
848 // enable or disable remove last edge button
849 if (mySelectedEdges.size() > 1) {
851 } else {
853 }
854 // recalculate path
856 // update info route label
858 // update junction colors
860 // update edge colors
862 // update view
864 }
865}
866
867
868long
869GNEPathCreator::onCmdCreatePath(FXObject*, FXSelector, void*) {
870 // call create path
871 return createPath(false);
872}
873
874
875long
876GNEPathCreator::onCmdUseLastRoute(FXObject*, FXSelector, void*) {
877 // call create path with useLastRoute = true
878 return createPath(true);
879}
880
881long
882GNEPathCreator::onUpdUseLastRoute(FXObject* sender, FXSelector, void*) {
884 return sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
885 } else {
886 return sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), nullptr);
887 }
888}
889
890long
891GNEPathCreator::onCmdAbortPathCreation(FXObject*, FXSelector, void*) {
892 // just call abort path creation
894 return 1;
895}
896
897
898long
899GNEPathCreator::onCmdRemoveLastElement(FXObject*, FXSelector, void*) {
900 // just call remove last element
902 return 1;
903}
904
905
906long
907GNEPathCreator::onCmdShowCandidateEdges(FXObject*, FXSelector, void*) {
908 // update labels
909 if (myShowCandidateEdges->getCheck() == TRUE) {
910 myShiftLabel->show();
911 myControlLabel->show();
912 } else {
913 myShiftLabel->hide();
914 myControlLabel->hide();
915 }
916 // recalc frame
917 recalc();
918 // update edge colors (view will be updated within function)
920 return 1;
921}
922
923
924void
926 if (myPath.size() > 0) {
927 // declare variables for route info
928 double length = 0;
929 double speed = 0;
930 int pathSize = 0;
931 for (const auto& path : myPath) {
932 for (const auto& edge : path.getSubPath()) {
933 length += edge->getNBEdge()->getLength();
934 speed += edge->getNBEdge()->getSpeed();
935 }
936 pathSize += (int)path.getSubPath().size();
937 }
938 // declare ostringstream for label and fill it
939 std::ostringstream information;
940 information
941 << TL("- Selected edges: ") << toString(mySelectedEdges.size()) << "\n"
942 << TL("- Path edges: ") << toString(pathSize) << "\n"
943 << TL("- Length: ") << toString(length) << "\n"
944 << TL("- Average speed: ") << toString(speed / pathSize);
945 // set new label
946 myInfoRouteLabel->setText(information.str().c_str());
947 } else {
948 myInfoRouteLabel->setText(TL("No edges selected"));
949 }
950}
951
952
953void
958 // clear junction, edges, additionals and route
959 mySelectedJunctions.clear();
960 mySelectedEdges.clear();
961 myToStoppingPlace = nullptr;
962 myRoute = nullptr;
963 // clear path
964 myPath.clear();
965 // update info route label
967}
968
969
970void
972 // first clear path
973 myPath.clear();
974 // set edges
975 std::vector<GNEEdge*> edges;
976 // add route edges
977 if (myRoute) {
978 edges = myRoute->getParentEdges();
979 } else {
980 // add selected edges
981 for (const auto& edge : mySelectedEdges) {
982 edges.push_back(edge);
983 }
984 // add to stopping place edge
985 if (myToStoppingPlace) {
986 edges.push_back(myToStoppingPlace->getParentLanes().front()->getParentEdge());
987 }
988 }
989 // fill paths
990 if (edges.size() == 1) {
991 myPath.push_back(Path(myVClass, edges.front()));
992 } else if (mySelectedJunctions.size() == 2) {
993 // add path between two junctions
995 } else {
996 // add every segment
997 for (int i = 1; i < (int)edges.size(); i++) {
998 myPath.push_back(Path(myFrameParent->getViewNet(), myVClass, edges.at(i - 1), edges.at(i)));
999 }
1000 }
1001}
1002
1003
1004void
1006 // first calculate reachability for pedestrians (we use it, because pedestran can walk in almost all edges)
1008 // change flags
1009 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
1010 for (const auto& lane : edge.second->getLanes()) {
1011 if (lane->getReachability() > 0) {
1012 lane->getParentEdge()->resetCandidateFlags();
1013 lane->getParentEdge()->setSpecialCandidate(true);
1014 }
1015 }
1016 }
1017}
1018
1019void
1021 // first calculate reachability for pedestrians
1023 // change flags
1024 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
1025 for (const auto& lane : edge.second->getLanes()) {
1026 if (lane->getReachability() > 0) {
1027 lane->getParentEdge()->resetCandidateFlags();
1028 lane->getParentEdge()->setPossibleCandidate(true);
1029 }
1030 }
1031 }
1032}
1033
1034/****************************************************************************/
FXDEFMAP(GNEPathCreator) PathCreatorMap[]
@ MID_GNE_PATHCREATOR_FINISH
finish edge path creation
Definition: GUIAppEnum.h:914
@ MID_GNE_PATHCREATOR_REMOVELAST
remove last inserted element in path
Definition: GUIAppEnum.h:918
@ MID_GNE_PATHCREATOR_USELASTROUTE
use last inserted route
Definition: GUIAppEnum.h:916
@ MID_GNE_PATHCREATOR_ABORT
abort edge path creation
Definition: GUIAppEnum.h:912
@ MID_GNE_PATHCREATOR_SHOWCANDIDATES
enable or disable show path candidates
Definition: GUIAppEnum.h:920
#define GUIDesignButton
Definition: GUIDesigns.h:77
#define GUIDesignLabelFrameThicked
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:274
#define GUIDesignCheckButton
checkButton placed in left position
Definition: GUIDesigns.h:169
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:271
@ GLO_MAX
empty max
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:265
#define TL(string)
Definition: MsgHandler.h:282
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_PEDESTRIAN
pedestrian
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_TRIP_JUNCTIONS
a trip between junctions (used in NETEDIT)
@ GNE_TAG_PERSONTRIP_JUNCTIONS
@ SUMO_TAG_EDGEREL
a relation between two edges
@ GNE_TAG_TRANSPORT_CONTAINERSTOP
@ GNE_TAG_PERSONTRIP_BUSSTOP
@ GNE_TAG_WALK_EDGES
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ GNE_TAG_STOPCONTAINER_EDGE
@ SUMO_TAG_BUS_STOP
A bus stop.
@ GNE_TAG_STOPPERSON_BUSSTOP
@ SUMO_TAG_VEHICLE
description of a vehicle
@ GNE_TAG_FLOW_ROUTE
a flow definition using a route instead of a from-to edges route (used in NETEDIT)
@ GNE_TAG_FLOW_JUNCTIONS
a flow between junctions (used in NETEDIT)
@ GNE_TAG_TRANSHIP_EDGES
@ GNE_TAG_STOPCONTAINER_CONTAINERSTOP
@ GNE_TAG_FLOW_WITHROUTE
description of a vehicle with an embedded route (used in NETEDIT)
@ SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
@ GNE_TAG_WALK_BUSSTOP
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ GNE_TAG_RIDE_EDGE
@ GNE_TAG_TRANSHIP_EDGE
@ GNE_TAG_WALK_JUNCTIONS
@ GNE_TAG_VEHICLE_WITHROUTE
description of a vehicle with an embedded route (used in NETEDIT)
@ GNE_TAG_WALK_EDGE
@ GNE_TAG_PERSONTRIP_EDGE
@ GNE_TAG_ROUTE_EMBEDDED
embedded route (used in NETEDIT)
@ GNE_TAG_RIDE_BUSSTOP
@ GNE_TAG_STOPPERSON_EDGE
@ GNE_TAG_WALK_ROUTE
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ GNE_TAG_TRANSHIP_CONTAINERSTOP
@ GNE_TAG_TRANSPORT_EDGE
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:583
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:329
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:277
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:48
void disableUndoRedo(const std::string &reason)
disable undo-redo giving a string with the reason
void enableUndoRedo()
disable undo-redo
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
bool isSpecialCandidate() const
check if this element is a special candidate
bool isPossibleCandidate() const
check if this element is a possible candidate
bool isConflictedCandidate() const
check if this element is a conflicted candidate
An Element which don't belong to GNENet but has influence in the simulation.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
GNEViewNet * getViewNet() const
get view net
Definition: GNEFrame.cpp:150
virtual bool createPath(const bool useLastRoute)
create path between two elements
Definition: GNEFrame.cpp:303
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
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:142
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:917
const std::map< std::string, GNEEdge * > & getEdges() const
map with the ID and pointer to edges of net
const std::map< std::string, GNEJunction * > & getJunctions() const
get junctions
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:132
GNEPathManager * getPathManager()
get path manager
Definition: GNENet.cpp:138
FOX-declaration.
bool isConflictVClass() const
check if current path is conflict due vClass
bool myConflictDisconnected
flag to mark this path as disconnected
bool myConflictVClass
flag to mark this path as conflicted
bool isConflictDisconnected() const
check if current path is conflict due is disconnected
GNEAdditional * getToBusStop() const
to additional
std::vector< GNEEdge * > mySubPath
sub path
Path()
default constructor
const std::vector< GNEEdge * > & getSubPath() const
get sub path
GNEAdditional * getFromBusStop() const
get from additional
long onCmdCreatePath(FXObject *, FXSelector, void *)
GNEAdditional * getToStoppingPlace(SumoXMLTag expectedTag) const
get to stoppingPlace
std::vector< Path > myPath
vector with current path
FXButton * myAbortCreationButton
button for abort route creation
bool addStoppingPlace(GNEAdditional *stoppingPlace, const bool shiftKeyPressed, const bool controlKeyPressed)
add stoppingPlace
void updateEdgeColors()
update edge colors
long onCmdAbortPathCreation(FXObject *, FXSelector, void *)
Called when the user click over button "Abort route creation".
bool addRoute(GNEDemandElement *route, const bool shiftKeyPressed, const bool controlKeyPressed)
add route
GNEAdditional * myToStoppingPlace
to additional (usually a busStop)
FXLabel * myControlLabel
label for control information
GNEFrame * myFrameParent
current frame parent
std::vector< GNEEdge * > mySelectedEdges
vector with selected edges
GNEDemandElement * myRoute
route (usually a busStop)
void abortPathCreation()
abort path creation
void updateInfoRouteLabel()
update InfoRouteLabel
FXCheckButton * myShowCandidateEdges
CheckBox for show candidate edges.
long onCmdShowCandidateEdges(FXObject *, FXSelector, void *)
Called when the user click over check button "show candidate edges".
~GNEPathCreator()
destructor
const std::vector< GNEJunction * > & getSelectedJunctions() const
get current selected junctions
void clearPath()
clear edges (and restore colors)
SUMOVehicleClass myVClass
current vClass
const std::vector< GNEEdge * > & getSelectedEdges() const
get current selected edges
void setPossibleCandidates(GNEEdge *originEdge, const SUMOVehicleClass vClass)
set edgereachability (This function will be called recursively)
long onCmdUseLastRoute(FXObject *, FXSelector, void *)
Called when the user click over button "Use last route".
void clearEdgeColors()
clear edge colors
bool addEdge(GNEEdge *edge, const bool shiftKeyPressed, const bool controlKeyPressed)
add edge
GNEDemandElement * getRoute() const
get route
void removeLastElement()
remove path element
bool createPath(const bool useLastRoute)
create path
void setVClass(SUMOVehicleClass vClass)
set vClass
void updateJunctionColors()
update junction colors
void drawTemporalRoute(const GUIVisualizationSettings &s) const
draw temporal route
SUMOVehicleClass getVClass() const
get vClass
FXButton * myRemoveLastInsertedElement
button for removing last inserted element
long onCmdRemoveLastElement(FXObject *, FXSelector, void *)
Called when the user click over button "Remove las inserted edge".
int myCreationMode
current creation mode
FXLabel * myInfoRouteLabel
label with route info
FXLabel * myBackSpaceLabel
label for backSpace information
bool drawCandidateEdgesWithSpecialColor() const
draw candidate edges with special color (Only for candidates, special and conflicted)
void setSpecialCandidates(GNEEdge *originEdge)
set special candidates (This function will be called recursively)
FXButton * myFinishCreationButton
button for finish route creation
long onUpdUseLastRoute(FXObject *, FXSelector, void *)
Called when update button "Use last route".
FXLabel * myShiftLabel
label for shift information
void recalculatePath()
recalculate path
GNEPathCreator(GNEFrame *frameParent)
default constructor
const std::vector< Path > & getPath() const
get path route
void clearJunctionColors()
clear junction colors
void hidePathCreatorModule()
show GNEPathCreator
void showPathCreatorModule(SumoXMLTag element, const bool firstElement, const bool consecutives)
show GNEPathCreator for the given tag
FXButton * myUseLastRoute
button for use last inserted route
std::vector< GNEJunction * > mySelectedJunctions
vector with selected junctions
bool addJunction(GNEJunction *junction, const bool shiftKeyPressed, const bool controlKeyPressed)
add junction
void calculateReachability(const SUMOVehicleClass vClass, GNEEdge *originEdge)
calculate reachability for given edge
std::vector< GNEEdge * > calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector< GNEEdge * > &partialEdges) const
calculate Dijkstra path between a list of partial edges
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
GNENet * getNet() const
get the net object
GNEDemandElement * getLastCreatedRoute() const
get last created route
GNEViewParent * getViewParent() const
get the net object
void updateViewNet() const
Mark the entire GNEViewNet to be repainted later.
Definition: GNEViewNet.cpp:414
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows
const PositionVector & getShape() const
The shape of the additional element.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
Stores the information about how to visualize structures.
GUIVisualizationCandidateColorSettings candidateColorSettings
candidate color settings
MFXGroupBoxModule (based on FXGroupBox)
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toggled)
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:252
double x() const
Returns the x-position.
Definition: Position.h:55
double y() const
Returns the y-position.
Definition: Position.h:60
static const RGBColor GREY
Definition: RGBColor.h:194
static const RGBColor ORANGE
Definition: RGBColor.h:191
#define M_PI
Definition: odrSpiral.cpp:45
static const RGBColor special
color for selected special candidate element (Usually selected using shift+click)
static const RGBColor conflict
color for selected conflict candidate element (Usually selected using ctrl+click)