Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNEPathCreator.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// Frame for create paths
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
24#include <netedit/GNEViewNet.h>
31
32#include "GNEPathCreator.h"
33
34// ===========================================================================
35// FOX callback mapping
36// ===========================================================================
37
46
47// Object implementation
48FXIMPLEMENT(GNEPathCreator, MFXGroupBoxModule, PathCreatorMap, ARRAYNUMBER(PathCreatorMap))
49
50
51// ===========================================================================
52// method definitions
53// ===========================================================================
54
56 mySubPath({edge}),
57 myConflictVClass(false),
58myConflictDisconnected(false) {
59 // check if we have to change vClass flag
60 if (edge->getNBEdge()->getNumLanesThatAllow(vClass) == 0) {
61 myConflictVClass = true;
62 }
63}
64
65
66GNEPathCreator::Path::Path(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEEdge* edgeFrom, GNEEdge* edgeTo) :
67 myConflictVClass(false),
68 myConflictDisconnected(false) {
69 // calculate subpath
70 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(vClass, {edgeFrom, edgeTo});
71 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
72 if (mySubPath.empty()) {
73 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, {edgeFrom, edgeTo});
74 if (mySubPath.empty()) {
75 mySubPath = { edgeFrom, edgeTo };
77 } else {
78 myConflictVClass = true;
79 }
80 }
81}
82
83
84GNEPathCreator::Path::Path(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEJunction* junctionFrom, GNEJunction* junctionTo) :
85 myConflictVClass(false),
86 myConflictDisconnected(false) {
87 // calculate subpath
88 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(vClass, junctionFrom, junctionTo);
89 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
90 if (mySubPath.empty()) {
91 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, junctionFrom, junctionTo);
92 if (mySubPath.empty()) {
94 } else {
95 myConflictVClass = true;
96 }
97 }
98}
99
100
101const std::vector<GNEEdge*>&
103 return mySubPath;
104}
105
106
107bool
109 return myConflictVClass;
110}
111
112
113bool
115 return myConflictDisconnected;
116}
117
118
120 myConflictVClass(false),
121 myConflictDisconnected(false) {
122}
123
124
126 MFXGroupBoxModule(frameParent, TL("Route creator")),
127 myFrameParent(frameParent),
128 myPathManager(pathManager),
131 myRoute(nullptr) {
132 // create label for route info
133 myInfoRouteLabel = new FXLabel(getCollapsableFrame(), TL("No edges selected"), 0, GUIDesignLabelFrameInformation);
134 // create button for use last route
136 myUseLastRoute->disable();
137 // create button for finish route creation
139 myFinishCreationButton->disable();
140 // create button for abort route creation
142 myAbortCreationButton->disable();
143 // create button for remove last inserted edge
146 // create check button
147 myShowCandidateEdges = new FXCheckButton(getCollapsableFrame(), TL("Show candidate edges"), this, MID_GNE_PATHCREATOR_SHOWCANDIDATES, GUIDesignCheckButton);
148 myShowCandidateEdges->setCheck(TRUE);
149 // create shift label
150 myShiftLabel = new FXLabel(this,
151 TL("SHIFT-click: ignore vClass"),
153 // create control label
154 myControlLabel = new FXLabel(this,
155 TL("CTRL-click: force add"),
157 // create backspace label (always shown)
158 myBackSpaceLabel = new FXLabel(this,
159 TL("BACKSPACE: undo click"),
161}
162
163
165
166
167void
168GNEPathCreator::showPathCreatorModule(const GNETagProperties* tagProperty, const bool consecutives) {
169 // declare flag
170 bool showPathCreator = true;
171 // first abort creation
173 // hide use last inserted route
174 myUseLastRoute->hide();
175 // disable buttons
176 myFinishCreationButton->disable();
177 myAbortCreationButton->disable();
179 // show info label
180 myInfoRouteLabel->show();
181 myShowCandidateEdges->show();
182 myShiftLabel->show();
183 myControlLabel->show();
184 myBackSpaceLabel->show();
185 // reset creation mode
186 myCreationMode = 0;
187 // set consecutive or non consecuives
188 if (consecutives) {
190 } else {
192 }
193 // continue depending of tag
194 if (tagProperty->isRoute() || tagProperty->vehicleRouteEmbedded()) {
198 } else if (tagProperty->vehicleRoute()) {
200 // show use last inserted route
201 myUseLastRoute->show();
202 // disable other elements
204 myAbortCreationButton->hide();
206 myInfoRouteLabel->hide();
207 myShowCandidateEdges->hide();
208 myShiftLabel->hide();
209 myControlLabel->hide();
210 myBackSpaceLabel->hide();
211 } else if (tagProperty->vehicleEdges() || (tagProperty->getTag() == SUMO_TAG_EDGEREL)) {
215 } else if (tagProperty->vehicleJunctions()) {
220 } else if (tagProperty->vehicleTAZs()) {
224 } else {
225 showPathCreator = false;
226 }
227 // update colors
230 // check if show path creator
231 if (showPathCreator) {
232 // recalc before show (to avoid graphic problems)
233 recalc();
234 // show modul
235 show();
236 } else {
237 // hide modul
238 hide();
239 }
240}
241
242
243void
245 // clear path
246 clearPath();
247 // hide modul
248 hide();
249}
250
251
254 return myVClass;
255}
256
257
258void
260 myVClass = vClass;
261 // update edge colors
263}
264
265
266bool
268 // check if junctions are allowed
269 if (((myCreationMode & START_JUNCTION) == 0) && ((myCreationMode & END_JUNCTION) == 0)) {
270 return false;
271 }
272 // continue depending of number of selected edge
273 if (mySelectedJunctions.size() > 0) {
274 // check double junctions
275 if (mySelectedJunctions.back() == junction) {
276 // Write warning
277 WRITE_WARNING(TL("Double junctions aren't allowed"));
278 // abort add junction
279 return false;
280 }
281 }
282 // check number of junctions
284 // Write warning
285 WRITE_WARNING(TL("Only two junctions are allowed"));
286 // abort add junction
287 return false;
288 }
289 // All checks ok, then add it in selected elements
290 mySelectedJunctions.push_back(junction);
291 // enable abort route button
292 myAbortCreationButton->enable();
293 // enable finish button
294 myFinishCreationButton->enable();
295 // disable undo/redo
296 myFrameParent->getViewNet()->getViewParent()->getGNEAppWindows()->disableUndoRedoTemporally(TL("creation of path between junctions"));
297 // enable or disable remove last junction button
298 if (mySelectedJunctions.size() > 1) {
300 } else {
302 }
303 // recalculate path
305 // update info route label
307 // update junction colors
309 return true;
310}
311
312
313bool
315 // check if TAZs are allowed
316 if (((myCreationMode & START_TAZ) == 0) && ((myCreationMode & END_TAZ) == 0)) {
317 return false;
318 }
319 // continue depending of number of selected edge
320 if (mySelectedTAZs.size() > 0) {
321 // check double TAZs
322 if (mySelectedTAZs.back() == TAZ) {
323 // Write warning
324 WRITE_WARNING(TL("Double TAZs aren't allowed"));
325 // abort add TAZ
326 return false;
327 }
328 }
329 // check number of TAZs
330 if ((mySelectedTAZs.size() == 2) && (myCreationMode & Mode::ONLY_FROMTO)) {
331 // Write warning
332 WRITE_WARNING(TL("Only two TAZs are allowed"));
333 // abort add TAZ
334 return false;
335 }
336 // All checks ok, then add it in selected elements
337 mySelectedTAZs.push_back(TAZ);
338 // enable abort route button
339 myAbortCreationButton->enable();
340 // enable finish button
341 myFinishCreationButton->enable();
342 // disable undo/redo
343 myFrameParent->getViewNet()->getViewParent()->getGNEAppWindows()->disableUndoRedoTemporally(TL("creation of path between TAZs"));
344 // enable or disable remove last TAZ button
345 if (mySelectedTAZs.size() > 1) {
347 } else {
349 }
350 // update info route label
352 return true;
353}
354
355
356bool
357GNEPathCreator::addEdge(GNEEdge* edge, const bool shiftKeyPressed, const bool controlKeyPressed) {
358 // check if edges are allowed
359 if (((myCreationMode & START_EDGE) == 0) && ((myCreationMode & END_EDGE) == 0)) {
360 return false;
361 }
362 // continue depending of number of selected eges
363 if (mySelectedEdges.size() > 0) {
364 // check double edges
365 if (mySelectedEdges.back() == edge) {
366 // Write warning
367 WRITE_WARNING(TL("Double edges aren't allowed"));
368 // abort add edge
369 return false;
370 }
371 // check consecutive edges
373 // check that new edge is consecutive
374 const auto& outgoingEdges = mySelectedEdges.back()->getToJunction()->getGNEOutgoingEdges();
375 if (std::find(outgoingEdges.begin(), outgoingEdges.end(), edge) == outgoingEdges.end()) {
376 // Write warning
377 WRITE_WARNING(TL("Only consecutives edges are allowed"));
378 // abort add edge
379 return false;
380 }
381 }
382 }
383 // check number of edges
384 if (mySelectedEdges.size() == 2 && (myCreationMode & Mode::ONLY_FROMTO)) {
385 // Write warning
386 WRITE_WARNING(TL("Only two edges are allowed"));
387 // abort add edge
388 return false;
389 }
390 // check candidate edge
391 if ((myShowCandidateEdges->getCheck() == TRUE) && !edge->isPossibleCandidate()) {
392 if (edge->isSpecialCandidate()) {
393 if (!shiftKeyPressed) {
394 // Write warning
395 WRITE_WARNING(TL("Invalid edge (SHIFT + click to add an invalid vClass edge)"));
396 // abort add edge
397 return false;
398 }
399 } else if (edge->isConflictedCandidate()) {
400 if (!controlKeyPressed) {
401 // Write warning
402 WRITE_WARNING(TL("Invalid edge (CONTROL + click to add a disconnected edge)"));
403 // abort add edge
404 return false;
405 }
406 }
407 }
408 // All checks ok, then add it in selected elements
409 mySelectedEdges.push_back(edge);
410 // enable abort route button
411 myAbortCreationButton->enable();
412 // enable finish button
413 myFinishCreationButton->enable();
414 // disable undo/redo
415 myFrameParent->getViewNet()->getViewParent()->getGNEAppWindows()->disableUndoRedoTemporally(TL("creation of path between edges"));
416 // enable or disable remove last edge button
417 if (mySelectedEdges.size() > 1) {
419 } else {
421 }
422 // recalculate path
424 // update info route label
426 // update edge colors
428 // add edge ok, then return true
429 return true;
430}
431
432
433const std::vector<GNEEdge*>&
437
438
439const std::vector<GNEJunction*>&
443
444
445const std::vector<GNETAZ*>&
449
450
451bool
453 // check if routes aren allowed
454 if ((myCreationMode & ROUTE) == 0) {
455 return false;
456 }
457 // check if previously a route was added
458 if (myRoute) {
459 return false;
460 }
461 // set route and create path
462 myRoute = route;
463 createPath(false);
464 myRoute = nullptr;
465 // recalculate path
469 return true;
470}
471
472
475 return myRoute;
476}
477
478
479const std::vector<GNEPathCreator::Path>&
481 return myPath;
482}
483
484
485bool
487 return (myShowCandidateEdges->getCheck() == TRUE);
488}
489
490
491void
493 // clear junction colors
495 // check if show possible candidates
497 // set candidate flags
498 for (const auto& junction : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getJunctions()) {
499 junction.second->resetCandidateFlags();
500 junction.second->setPossibleCandidate(true);
501 }
502 }
503 // set selected junctions
504 if (mySelectedJunctions.size() > 0) {
505 // mark selected eges
506 for (const auto& junction : mySelectedJunctions) {
507 junction->resetCandidateFlags();
508 junction->setSourceCandidate(true);
509 }
510 // finally mark last selected element as target
511 mySelectedJunctions.back()->resetCandidateFlags();
512 mySelectedJunctions.back()->setTargetCandidate(true);
513 }
514 // update view net
516}
517
518
519void
521 // clear edge colors
523 // first check if show candidate edges
524 if (myShowCandidateEdges->getCheck() == TRUE && (myCreationMode & SHOW_CANDIDATE_EDGES)) {
525 // mark all edges that have at least one lane that allow given vClass
526 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
527 if (edge.second->getNBEdge()->getNumLanesThatAllow(myVClass) > 0) {
528 edge.second->setPossibleCandidate(true);
529 } else {
530 edge.second->setSpecialCandidate(true);
531 }
532 }
533 }
534 // set reachability
535 if (mySelectedEdges.size() > 0) {
536 // only coloring edges if checkbox "show candidate edges" is enabled
537 if ((myShowCandidateEdges->getCheck() == TRUE) && (myCreationMode & SHOW_CANDIDATE_EDGES)) {
538 // mark all edges as conflicted (to mark special candidates)
539 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
540 edge.second->resetCandidateFlags();
541 edge.second->setConflictedCandidate(true);
542 }
543 // set special candidates (Edges that are connected but aren't compatibles with current vClass
545 // mark again all edges as conflicted (to mark possible candidates)
546 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
547 edge.second->setConflictedCandidate(true);
548 }
549 // set possible candidates (Edges that are connected AND are compatibles with current vClass
551 }
552 // now mark selected eges
553 for (const auto& edge : mySelectedEdges) {
554 edge->resetCandidateFlags();
555 edge->setSourceCandidate(true);
556 }
557 // finally mark last selected element as target
558 mySelectedEdges.back()->resetCandidateFlags();
559 mySelectedEdges.back()->setTargetCandidate(true);
560 }
561 // update view net
563}
564
565
566void
568 // reset all junction flags
569 for (const auto& junction : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getJunctions()) {
570 junction.second->resetCandidateFlags();
571 }
572}
573
574
575void
577 // reset all junction flags
578 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
579 edge.second->resetCandidateFlags();
580 }
581}
582
583
584void
586 const double lineWidth = 0.35;
587 const double lineWidthin = 0.25;
588 // Add a draw matrix
590 // Start with the drawing of the area traslating matrix to origin
591 glTranslated(0, 0, GLO_MAX - 0.1);
592 // check if draw bewteen junction or edges
593 if (myPath.size() > 0) {
594 // set first color
596 // iterate over path
597 for (int i = 0; i < (int)myPath.size(); i++) {
598 // get path
599 const GNEPathCreator::Path& path = myPath.at(i);
600 // draw line over
601 for (int j = 0; j < (int)path.getSubPath().size(); j++) {
602 const GNELane* lane = path.getSubPath().at(j)->getChildLanes().back();
603 if (((i == 0) && (j == 0)) || (j > 0)) {
604 GLHelper::drawBoxLines(lane->getLaneShape(), lineWidth);
605 }
606 // draw connection between lanes
607 if ((j + 1) < (int)path.getSubPath().size()) {
608 const GNELane* nextLane = path.getSubPath().at(j + 1)->getChildLanes().back();
609 if (lane->getLane2laneConnections().exist(nextLane)) {
611 } else {
612 GLHelper::drawBoxLines({lane->getLaneShape().back(), nextLane->getLaneShape().front()}, lineWidth);
613 }
614 }
615 }
616 }
617 glTranslated(0, 0, 0.1);
618 // iterate over path again
619 for (int i = 0; i < (int)myPath.size(); i++) {
620 // get path
621 const GNEPathCreator::Path& path = myPath.at(i);
622 // set path color color
625 } else if (path.isConflictDisconnected()) {
627 } else if (path.isConflictVClass()) {
629 } else {
631 }
632 // draw line over
633 for (int j = 0; j < (int)path.getSubPath().size(); j++) {
634 const GNELane* lane = path.getSubPath().at(j)->getChildLanes().back();
635 if (((i == 0) && (j == 0)) || (j > 0)) {
636 GLHelper::drawBoxLines(lane->getLaneShape(), lineWidthin);
637 }
638 // draw connection between lanes
639 if ((j + 1) < (int)path.getSubPath().size()) {
640 const GNELane* nextLane = path.getSubPath().at(j + 1)->getChildLanes().back();
641 if (lane->getLane2laneConnections().exist(nextLane)) {
643 } else {
644 GLHelper::drawBoxLines({ lane->getLaneShape().back(), nextLane->getLaneShape().front() }, lineWidthin);
645 }
646 }
647 }
648 }
649 } else if (mySelectedJunctions.size() > 0) {
650 // set color
652 // draw line between junctions
653 for (int i = 0; i < (int)mySelectedJunctions.size() - 1; i++) {
654 // get two points
655 const Position posA = mySelectedJunctions.at(i)->getPositionInView();
656 const Position posB = mySelectedJunctions.at(i + 1)->getPositionInView();
657 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) 180.0 / (double)M_PI);
658 const double len = posA.distanceTo2D(posB);
659 // draw line
660 GLHelper::drawBoxLine(posA, rot, len, 0.25);
661 }
662 } else if (mySelectedTAZs.size() > 0) {
663 // set color
665 // draw line between TAZs
666 for (int i = 0; i < (int)mySelectedTAZs.size() - 1; i++) {
667 // get two points
668 const Position posA = mySelectedTAZs.at(i)->getPositionInView();
669 const Position posB = mySelectedTAZs.at(i + 1)->getPositionInView();
670 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) 180.0 / (double)M_PI);
671 const double len = posA.distanceTo2D(posB);
672 // draw line
673 GLHelper::drawBoxLine(posA, rot, len, 0.25);
674 }
675 }
676 // Pop last matrix
678}
679
680
681bool
682GNEPathCreator::createPath(const bool useLastRoute) {
683 // call create path implemented in frame parent
684 return myFrameParent->createPath(useLastRoute);
685}
686
687
688void
690 // first check that there is elements
691 if ((mySelectedJunctions.size() > 0) || (mySelectedTAZs.size() > 0) || (mySelectedEdges.size() > 0) || myRoute) {
692 // unblock undo/redo
694 // clear edges
695 clearPath();
696 // disable buttons
697 myFinishCreationButton->disable();
698 myAbortCreationButton->disable();
700 // update info route label
702 // update junction colors
704 // update edge colors
706 // update view (to see the new route)
708 }
709}
710
711
712void
714 if (mySelectedEdges.size() > 1) {
715 // remove special color of last selected edge
716 mySelectedEdges.back()->resetCandidateFlags();
717 // remove last edge
718 mySelectedEdges.pop_back();
719 // change last edge flag
720 if ((mySelectedEdges.size() > 0) && mySelectedEdges.back()->isSourceCandidate()) {
721 mySelectedEdges.back()->setSourceCandidate(false);
722 mySelectedEdges.back()->setTargetCandidate(true);
723 }
724 // enable or disable remove last edge button
725 if (mySelectedEdges.size() > 1) {
727 } else {
729 }
730 // recalculate path
732 // update info route label
734 // update junction colors
736 // update edge colors
738 // update view
740 }
741}
742
743
744long
745GNEPathCreator::onCmdCreatePath(FXObject*, FXSelector, void*) {
746 // call create path
747 return createPath(false);
748}
749
750
751long
752GNEPathCreator::onCmdUseLastRoute(FXObject*, FXSelector, void*) {
753 // call create path with useLastRoute = true
754 return createPath(true);
755}
756
757long
758GNEPathCreator::onUpdUseLastRoute(FXObject* sender, FXSelector, void*) {
760 return sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
761 } else {
762 return sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), nullptr);
763 }
764}
765
766long
767GNEPathCreator::onCmdAbortPathCreation(FXObject*, FXSelector, void*) {
768 // just call abort path creation
770 return 1;
771}
772
773
774long
775GNEPathCreator::onCmdRemoveLastElement(FXObject*, FXSelector, void*) {
776 // just call remove last element
778 return 1;
779}
780
781
782long
783GNEPathCreator::onCmdShowCandidateEdges(FXObject*, FXSelector, void*) {
784 // update labels
785 if (myShowCandidateEdges->getCheck() == TRUE) {
786 myShiftLabel->show();
787 myControlLabel->show();
788 } else {
789 myShiftLabel->hide();
790 myControlLabel->hide();
791 }
792 // recalc frame
793 recalc();
794 // update edge colors (view will be updated within function)
796 return 1;
797}
798
799
800void
802 if (myPath.size() > 0) {
803 // declare variables for route info
804 double length = 0;
805 double speed = 0;
806 int pathSize = 0;
807 for (const auto& path : myPath) {
808 for (const auto& edge : path.getSubPath()) {
809 length += edge->getNBEdge()->getLength();
810 speed += edge->getNBEdge()->getSpeed();
811 }
812 pathSize += (int)path.getSubPath().size();
813 }
814 // declare ostringstream for label and fill it
815 std::ostringstream information;
816 information
817 << TL("- Selected edges: ") << toString(mySelectedEdges.size()) << "\n"
818 << TL("- Path edges: ") << toString(pathSize) << "\n"
819 << TL("- Length: ") << toString(length) << "\n"
820 << TL("- Average speed: ") << toString(speed / pathSize);
821 // set new label
822 myInfoRouteLabel->setText(information.str().c_str());
823 } else {
824 myInfoRouteLabel->setText(TL("No edges selected"));
825 }
826}
827
828
829void
834 // clear junction, TAZs, edges, additionals and route
835 mySelectedJunctions.clear();
836 mySelectedTAZs.clear();
837 mySelectedEdges.clear();
838 myRoute = nullptr;
839 // clear path
840 myPath.clear();
841 // update info route label
843}
844
845
846void
848 // first clear path
849 myPath.clear();
850 // set edges
851 std::vector<GNEEdge*> edges;
852 // add route edges
853 if (myRoute) {
854 edges = myRoute->getParentEdges();
855 } else {
856 // add selected edges
857 for (const auto& edge : mySelectedEdges) {
858 edges.push_back(edge);
859 }
860 }
861 // fill paths
862 if (edges.size() == 1) {
863 myPath.push_back(Path(myVClass, edges.front()));
864 } else if (mySelectedJunctions.size() == 2) {
865 // add path between two junctions
867 } else {
868 // add every segment
869 for (int i = 1; i < (int)edges.size(); i++) {
870 myPath.push_back(Path(myPathManager, myVClass, edges.at(i - 1), edges.at(i)));
871 }
872 }
873}
874
875
876void
878 // first calculate reachability for pedestrians (we use it, because pedestran can walk in almost all edges)
880 // change flags
881 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
882 for (const auto& lane : edge.second->getChildLanes()) {
883 if (lane->getReachability() > 0) {
884 lane->getParentEdge()->resetCandidateFlags();
885 lane->getParentEdge()->setSpecialCandidate(true);
886 }
887 }
888 }
889}
890
891void
893 // first calculate reachability for pedestrians
895 // change flags
896 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
897 for (const auto& lane : edge.second->getChildLanes()) {
898 if (lane->getReachability() > 0) {
899 lane->getParentEdge()->resetCandidateFlags();
900 lane->getParentEdge()->setPossibleCandidate(true);
901 }
902 }
903 }
904}
905
906/****************************************************************************/
FXDEFMAP(GNEPathCreator) PathCreatorMap[]
@ MID_GNE_PATHCREATOR_FINISH
finish edge path creation
Definition GUIAppEnum.h:981
@ MID_GNE_PATHCREATOR_REMOVELAST
remove last inserted element in path
Definition GUIAppEnum.h:985
@ MID_GNE_PATHCREATOR_USELASTROUTE
use last inserted route
Definition GUIAppEnum.h:983
@ MID_GNE_PATHCREATOR_ABORT
abort edge path creation
Definition GUIAppEnum.h:979
@ MID_GNE_PATHCREATOR_SHOWCANDIDATES
enable or disable show path candidates
Definition GUIAppEnum.h:987
#define GUIDesignButton
Definition GUIDesigns.h:82
#define GUIDesignCheckButton
checkButton placed in left position
Definition GUIDesigns.h:192
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition GUIDesigns.h:279
@ GLO_MAX
empty max
#define WRITE_WARNING(msg)
Definition MsgHandler.h:283
#define TL(string)
Definition MsgHandler.h:301
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
@ SUMO_TAG_EDGEREL
a relation between two edges
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:649
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
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:348
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
void enableUndoRedoTemporally()
enable undo-redo temporally (for example, after creating an edge)
void disableUndoRedoTemporally(const std::string &reason)
disable undo-redo temporally giving a string with the reason (for example, if we're creating an edge)
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
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:154
virtual bool createPath(const bool useLastRoute)
create path between two elements
Definition GNEFrame.cpp:307
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
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
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:146
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
std::vector< GNEEdge * > mySubPath
sub path
Path()
default constructor
const std::vector< GNEEdge * > & getSubPath() const
get sub path
long onCmdCreatePath(FXObject *, FXSelector, void *)
std::vector< Path > myPath
vector with current path
FXButton * myAbortCreationButton
button for abort route creation
void updateEdgeColors()
update edge colors
long onCmdAbortPathCreation(FXObject *, FXSelector, void *)
Called when the user click over button "Abort route creation".
FXLabel * myControlLabel
label for control information
GNEFrame * myFrameParent
current frame parent
std::vector< GNEEdge * > mySelectedEdges
vector with selected edges
std::vector< GNETAZ * > mySelectedTAZs
vector with selected TAZs
GNEDemandElement * myRoute
route (usually a busStop)
const std::vector< GNETAZ * > & getSelectedTAZs() const
get current selected TAZs
bool addRoute(GNEDemandElement *route)
add route
void abortPathCreation()
abort path creation
void updateInfoRouteLabel()
update InfoRouteLabel
bool addTAZ(GNETAZ *taz)
add TAZ
FXCheckButton * myShowCandidateEdges
CheckBox for show candidate edges.
GNEPathCreator(GNEFrame *frameParent, GNEPathManager *pathManager)
default constructor
GNEPathManager * myPathManager
path manager
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 addJunction(GNEJunction *junction)
add junction
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
const std::vector< Path > & getPath() const
get path route
void clearJunctionColors()
clear junction colors
void hidePathCreatorModule()
show GNEPathCreator
void showPathCreatorModule(const GNETagProperties *tagProperty, 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
std::vector< GNEEdge * > calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector< GNEEdge * > &edges) const
calculate Dijkstra path between a list of edges (for example, from-via-to edges)
void calculateReachability(const SUMOVehicleClass vClass, GNEEdge *originEdge)
calculate reachability for given edge
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
bool isRoute() const
return true if tag correspond to a route element
bool vehicleJunctions() const
return true if tag correspond to a vehicle placed over from-to junctions
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool vehicleRouteEmbedded() const
return true if tag correspond to a vehicle placed over an embedded route
bool vehicleEdges() const
return true if tag correspond to a vehicle placed over from-to edges
bool vehicleTAZs() const
return true if tag correspond to a vehicle placed over from-to TAZs
bool vehicleRoute() const
plan parents
GNENet * getNet() const
get the net object
GNEDemandElement * getLastCreatedRoute() const
get last created route
GNEViewParent * getViewParent() const
get the net object
void updateViewNet(const bool ignoreViewUpdater=true) const
Mark the entire GNEViewNet to be repainted later.
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows
static FXButton * buildFXButton(FXComposite *p, const std::string &text, const std::string &tip, const std::string &help, FXIcon *ic, FXObject *tgt, FXSelector sel, FXuint opts=BUTTON_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
build button
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:273
double x() const
Returns the x-position.
Definition Position.h:52
double y() const
Returns the y-position.
Definition Position.h:57
static const RGBColor GREY
Definition RGBColor.h:197
static const RGBColor ORANGE
Definition RGBColor.h:194
#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)