Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// 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
47
48// Object implementation
49FXIMPLEMENT(GNEPathCreator, MFXGroupBoxModule, PathCreatorMap, ARRAYNUMBER(PathCreatorMap))
50
51
52// ===========================================================================
53// method definitions
54// ===========================================================================
55
57 mySubPath({edge}),
58 myConflictVClass(false),
59myConflictDisconnected(false) {
60 // check if we have to change vClass flag
61 if (edge->getNBEdge()->getNumLanesThatAllow(vClass) == 0) {
62 myConflictVClass = true;
63 }
64}
65
66
67GNEPathCreator::Path::Path(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEEdge* edgeFrom, GNEEdge* edgeTo) :
68 myConflictVClass(false),
69 myConflictDisconnected(false) {
70 // calculate subpath
71 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(vClass, {edgeFrom, edgeTo});
72 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
73 if (mySubPath.empty()) {
74 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, {edgeFrom, edgeTo});
75 if (mySubPath.empty()) {
76 mySubPath = { edgeFrom, edgeTo };
78 } else {
79 myConflictVClass = true;
80 }
81 }
82}
83
84
85GNEPathCreator::Path::Path(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEJunction* junctionFrom, GNEJunction* junctionTo) :
86 myConflictVClass(false),
87 myConflictDisconnected(false) {
88 // calculate subpath
89 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(vClass, junctionFrom, junctionTo);
90 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
91 if (mySubPath.empty()) {
92 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, junctionFrom, junctionTo);
93 if (mySubPath.empty()) {
95 } else {
96 myConflictVClass = true;
97 }
98 }
99}
100
101
102const std::vector<GNEEdge*>&
104 return mySubPath;
105}
106
107
108bool
110 return myConflictVClass;
111}
112
113
114bool
116 return myConflictDisconnected;
117}
118
119
121 myConflictVClass(false),
122 myConflictDisconnected(false) {
123}
124
125
127 MFXGroupBoxModule(frameParent, TL("Route creator")),
128 myFrameParent(frameParent),
129 myPathManager(pathManager),
132 myRoute(nullptr) {
133 // create label for route info
134 myInfoRouteLabel = new FXLabel(getCollapsableFrame(), TL("No edges selected"), 0, GUIDesignLabelFrameInformation);
135 // create button for use last route
137 myUseLastRoute->disable();
138 // create button for finish route creation
140 myFinishCreationButton->disable();
141 // create button for abort route creation
143 myAbortCreationButton->disable();
144 // create button for remove last inserted edge
147 // create check button
148 myShowCandidateEdges = new FXCheckButton(getCollapsableFrame(), TL("Show candidate edges"), this, MID_GNE_PATHCREATOR_SHOWCANDIDATES, GUIDesignCheckButton);
149 myShowCandidateEdges->setCheck(TRUE);
150 // create shift label
151 myShiftLabel = new FXLabel(this,
152 TL("SHIFT-click: ignore vClass"),
154 // create control label
155 myControlLabel = new FXLabel(this,
156 TL("CTRL-click: force add"),
158 // create backspace label (always shown)
159 myBackSpaceLabel = new FXLabel(this,
160 TL("BACKSPACE: undo click"),
162}
163
164
166
167
168void
169GNEPathCreator::showPathCreatorModule(const GNETagProperties& tagProperty, const bool consecutives) {
170 // declare flag
171 bool showPathCreator = true;
172 // first abort creation
174 // hide use last inserted route
175 myUseLastRoute->hide();
176 // disable buttons
177 myFinishCreationButton->disable();
178 myAbortCreationButton->disable();
180 // show info label
181 myInfoRouteLabel->show();
182 myShowCandidateEdges->show();
183 myShiftLabel->show();
184 myControlLabel->show();
185 myBackSpaceLabel->show();
186 // reset creation mode
187 myCreationMode = 0;
188 // set consecutive or non consecuives
189 if (consecutives) {
191 } else {
193 }
194 // continue depending of tag
195 if (tagProperty.isRoute() || tagProperty.vehicleRouteEmbedded()) {
199 } else if (tagProperty.vehicleRoute()) {
201 // show use last inserted route
202 myUseLastRoute->show();
203 // disable other elements
205 myAbortCreationButton->hide();
207 myInfoRouteLabel->hide();
208 myShowCandidateEdges->hide();
209 myShiftLabel->hide();
210 myControlLabel->hide();
211 myBackSpaceLabel->hide();
212 } else if (tagProperty.vehicleEdges() || (tagProperty.getTag() == SUMO_TAG_EDGEREL)) {
216 } else if (tagProperty.vehicleJunctions()) {
221 } else if (tagProperty.vehicleTAZs()) {
225 } else {
226 showPathCreator = false;
227 }
228 // update colors
231 // check if show path creator
232 if (showPathCreator) {
233 // recalc before show (to avoid graphic problems)
234 recalc();
235 // show modul
236 show();
237 } else {
238 // hide modul
239 hide();
240 }
241}
242
243
244void
246 // clear path
247 clearPath();
248 // hide modul
249 hide();
250}
251
252
255 return myVClass;
256}
257
258
259void
261 myVClass = vClass;
262 // update edge colors
264}
265
266
267bool
269 // check if junctions are allowed
270 if (((myCreationMode & START_JUNCTION) == 0) && ((myCreationMode & END_JUNCTION) == 0)) {
271 return false;
272 }
273 // continue depending of number of selected edge
274 if (mySelectedJunctions.size() > 0) {
275 // check double junctions
276 if (mySelectedJunctions.back() == junction) {
277 // Write warning
278 WRITE_WARNING(TL("Double junctions aren't allowed"));
279 // abort add junction
280 return false;
281 }
282 }
283 // check number of junctions
285 // Write warning
286 WRITE_WARNING(TL("Only two junctions are allowed"));
287 // abort add junction
288 return false;
289 }
290 // All checks ok, then add it in selected elements
291 mySelectedJunctions.push_back(junction);
292 // enable abort route button
293 myAbortCreationButton->enable();
294 // enable finish button
295 myFinishCreationButton->enable();
296 // disable undo/redo
297 myFrameParent->getViewNet()->getViewParent()->getGNEAppWindows()->disableUndoRedoTemporally(TL("creation of path between junctions"));
298 // enable or disable remove last junction button
299 if (mySelectedJunctions.size() > 1) {
301 } else {
303 }
304 // recalculate path
306 // update info route label
308 // update junction colors
310 return true;
311}
312
313
314bool
316 // check if TAZs are allowed
317 if (((myCreationMode & START_TAZ) == 0) && ((myCreationMode & END_TAZ) == 0)) {
318 return false;
319 }
320 // continue depending of number of selected edge
321 if (mySelectedTAZs.size() > 0) {
322 // check double TAZs
323 if (mySelectedTAZs.back() == TAZ) {
324 // Write warning
325 WRITE_WARNING(TL("Double TAZs aren't allowed"));
326 // abort add TAZ
327 return false;
328 }
329 }
330 // check number of TAZs
331 if ((mySelectedTAZs.size() == 2) && (myCreationMode & Mode::ONLY_FROMTO)) {
332 // Write warning
333 WRITE_WARNING(TL("Only two TAZs are allowed"));
334 // abort add TAZ
335 return false;
336 }
337 // All checks ok, then add it in selected elements
338 mySelectedTAZs.push_back(TAZ);
339 // enable abort route button
340 myAbortCreationButton->enable();
341 // enable finish button
342 myFinishCreationButton->enable();
343 // disable undo/redo
344 myFrameParent->getViewNet()->getViewParent()->getGNEAppWindows()->disableUndoRedoTemporally(TL("creation of path between TAZs"));
345 // enable or disable remove last TAZ button
346 if (mySelectedTAZs.size() > 1) {
348 } else {
350 }
351 // update info route label
353 return true;
354}
355
356
357bool
358GNEPathCreator::addEdge(GNEEdge* edge, const bool shiftKeyPressed, const bool controlKeyPressed) {
359 // check if edges are allowed
360 if (((myCreationMode & START_EDGE) == 0) && ((myCreationMode & END_EDGE) == 0)) {
361 return false;
362 }
363 // continue depending of number of selected eges
364 if (mySelectedEdges.size() > 0) {
365 // check double edges
366 if (mySelectedEdges.back() == edge) {
367 // Write warning
368 WRITE_WARNING(TL("Double edges aren't allowed"));
369 // abort add edge
370 return false;
371 }
372 // check consecutive edges
374 // check that new edge is consecutive
375 const auto& outgoingEdges = mySelectedEdges.back()->getToJunction()->getGNEOutgoingEdges();
376 if (std::find(outgoingEdges.begin(), outgoingEdges.end(), edge) == outgoingEdges.end()) {
377 // Write warning
378 WRITE_WARNING(TL("Only consecutives edges are allowed"));
379 // abort add edge
380 return false;
381 }
382 }
383 }
384 // check number of edges
385 if (mySelectedEdges.size() == 2 && (myCreationMode & Mode::ONLY_FROMTO)) {
386 // Write warning
387 WRITE_WARNING(TL("Only two edges are allowed"));
388 // abort add edge
389 return false;
390 }
391 // check candidate edge
392 if ((myShowCandidateEdges->getCheck() == TRUE) && !edge->isPossibleCandidate()) {
393 if (edge->isSpecialCandidate()) {
394 if (!shiftKeyPressed) {
395 // Write warning
396 WRITE_WARNING(TL("Invalid edge (SHIFT + click to add an invalid vClass edge)"));
397 // abort add edge
398 return false;
399 }
400 } else if (edge->isConflictedCandidate()) {
401 if (!controlKeyPressed) {
402 // Write warning
403 WRITE_WARNING(TL("Invalid edge (CONTROL + click to add a disconnected edge)"));
404 // abort add edge
405 return false;
406 }
407 }
408 }
409 // All checks ok, then add it in selected elements
410 mySelectedEdges.push_back(edge);
411 // enable abort route button
412 myAbortCreationButton->enable();
413 // enable finish button
414 myFinishCreationButton->enable();
415 // disable undo/redo
416 myFrameParent->getViewNet()->getViewParent()->getGNEAppWindows()->disableUndoRedoTemporally(TL("creation of path between edges"));
417 // enable or disable remove last edge button
418 if (mySelectedEdges.size() > 1) {
420 } else {
422 }
423 // recalculate path
425 // update info route label
427 // update edge colors
429 // add edge ok, then return true
430 return true;
431}
432
433
434const std::vector<GNEEdge*>&
438
439
440const std::vector<GNEJunction*>&
444
445
446const std::vector<GNETAZ*>&
450
451
452bool
454 // check if routes aren allowed
455 if ((myCreationMode & ROUTE) == 0) {
456 return false;
457 }
458 // check if previously a route was added
459 if (myRoute) {
460 return false;
461 }
462 // set route and create path
463 myRoute = route;
464 createPath(false);
465 myRoute = nullptr;
466 // recalculate path
470 return true;
471}
472
473
476 return myRoute;
477}
478
479
480const std::vector<GNEPathCreator::Path>&
482 return myPath;
483}
484
485
486bool
488 return (myShowCandidateEdges->getCheck() == TRUE);
489}
490
491
492void
494 // clear junction colors
496 // check if show possible candidates
498 // set candidate flags
499 for (const auto& junction : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getJunctions()) {
500 junction.second->resetCandidateFlags();
501 junction.second->setPossibleCandidate(true);
502 }
503 }
504 // set selected junctions
505 if (mySelectedJunctions.size() > 0) {
506 // mark selected eges
507 for (const auto& junction : mySelectedJunctions) {
508 junction->resetCandidateFlags();
509 junction->setSourceCandidate(true);
510 }
511 // finally mark last selected element as target
512 mySelectedJunctions.back()->resetCandidateFlags();
513 mySelectedJunctions.back()->setTargetCandidate(true);
514 }
515 // update view net
517}
518
519
520void
522 // clear edge colors
524 // first check if show candidate edges
525 if (myShowCandidateEdges->getCheck() == TRUE && (myCreationMode & SHOW_CANDIDATE_EDGES)) {
526 // mark all edges that have at least one lane that allow given vClass
527 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
528 if (edge.second->getNBEdge()->getNumLanesThatAllow(myVClass) > 0) {
529 edge.second->setPossibleCandidate(true);
530 } else {
531 edge.second->setSpecialCandidate(true);
532 }
533 }
534 }
535 // set reachability
536 if (mySelectedEdges.size() > 0) {
537 // only coloring edges if checkbox "show candidate edges" is enabled
538 if ((myShowCandidateEdges->getCheck() == TRUE) && (myCreationMode & SHOW_CANDIDATE_EDGES)) {
539 // mark all edges as conflicted (to mark special candidates)
540 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
541 edge.second->resetCandidateFlags();
542 edge.second->setConflictedCandidate(true);
543 }
544 // set special candidates (Edges that are connected but aren't compatibles with current vClass
546 // mark again all edges as conflicted (to mark possible candidates)
547 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
548 edge.second->setConflictedCandidate(true);
549 }
550 // set possible candidates (Edges that are connected AND are compatibles with current vClass
552 }
553 // now mark selected eges
554 for (const auto& edge : mySelectedEdges) {
555 edge->resetCandidateFlags();
556 edge->setSourceCandidate(true);
557 }
558 // finally mark last selected element as target
559 mySelectedEdges.back()->resetCandidateFlags();
560 mySelectedEdges.back()->setTargetCandidate(true);
561 }
562 // update view net
564}
565
566
567void
569 // reset all junction flags
570 for (const auto& junction : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getJunctions()) {
571 junction.second->resetCandidateFlags();
572 }
573}
574
575
576void
578 // reset all junction flags
579 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
580 edge.second->resetCandidateFlags();
581 }
582}
583
584
585void
587 const double lineWidth = 0.35;
588 const double lineWidthin = 0.25;
589 // Add a draw matrix
591 // Start with the drawing of the area traslating matrix to origin
592 glTranslated(0, 0, GLO_MAX - 0.1);
593 // check if draw bewteen junction or edges
594 if (myPath.size() > 0) {
595 // set first color
597 // iterate over path
598 for (int i = 0; i < (int)myPath.size(); i++) {
599 // get path
600 const GNEPathCreator::Path& path = myPath.at(i);
601 // draw line over
602 for (int j = 0; j < (int)path.getSubPath().size(); j++) {
603 const GNELane* lane = path.getSubPath().at(j)->getLanes().back();
604 if (((i == 0) && (j == 0)) || (j > 0)) {
605 GLHelper::drawBoxLines(lane->getLaneShape(), lineWidth);
606 }
607 // draw connection between lanes
608 if ((j + 1) < (int)path.getSubPath().size()) {
609 const GNELane* nextLane = path.getSubPath().at(j + 1)->getLanes().back();
610 if (lane->getLane2laneConnections().exist(nextLane)) {
612 } else {
613 GLHelper::drawBoxLines({lane->getLaneShape().back(), nextLane->getLaneShape().front()}, lineWidth);
614 }
615 }
616 }
617 }
618 glTranslated(0, 0, 0.1);
619 // iterate over path again
620 for (int i = 0; i < (int)myPath.size(); i++) {
621 // get path
622 const GNEPathCreator::Path& path = myPath.at(i);
623 // set path color color
626 } else if (path.isConflictDisconnected()) {
628 } else if (path.isConflictVClass()) {
630 } else {
632 }
633 // draw line over
634 for (int j = 0; j < (int)path.getSubPath().size(); j++) {
635 const GNELane* lane = path.getSubPath().at(j)->getLanes().back();
636 if (((i == 0) && (j == 0)) || (j > 0)) {
637 GLHelper::drawBoxLines(lane->getLaneShape(), lineWidthin);
638 }
639 // draw connection between lanes
640 if ((j + 1) < (int)path.getSubPath().size()) {
641 const GNELane* nextLane = path.getSubPath().at(j + 1)->getLanes().back();
642 if (lane->getLane2laneConnections().exist(nextLane)) {
644 } else {
645 GLHelper::drawBoxLines({ lane->getLaneShape().back(), nextLane->getLaneShape().front() }, lineWidthin);
646 }
647 }
648 }
649 }
650 } else if (mySelectedJunctions.size() > 0) {
651 // set color
653 // draw line between junctions
654 for (int i = 0; i < (int)mySelectedJunctions.size() - 1; i++) {
655 // get two points
656 const Position posA = mySelectedJunctions.at(i)->getPositionInView();
657 const Position posB = mySelectedJunctions.at(i + 1)->getPositionInView();
658 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) 180.0 / (double)M_PI);
659 const double len = posA.distanceTo2D(posB);
660 // draw line
661 GLHelper::drawBoxLine(posA, rot, len, 0.25);
662 }
663 } else if (mySelectedTAZs.size() > 0) {
664 // set color
666 // draw line between TAZs
667 for (int i = 0; i < (int)mySelectedTAZs.size() - 1; i++) {
668 // get two points
669 const Position posA = mySelectedTAZs.at(i)->getPositionInView();
670 const Position posB = mySelectedTAZs.at(i + 1)->getPositionInView();
671 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) 180.0 / (double)M_PI);
672 const double len = posA.distanceTo2D(posB);
673 // draw line
674 GLHelper::drawBoxLine(posA, rot, len, 0.25);
675 }
676 }
677 // Pop last matrix
679}
680
681
682bool
683GNEPathCreator::createPath(const bool useLastRoute) {
684 // call create path implemented in frame parent
685 return myFrameParent->createPath(useLastRoute);
686}
687
688
689void
691 // first check that there is elements
692 if ((mySelectedJunctions.size() > 0) || (mySelectedTAZs.size() > 0) || (mySelectedEdges.size() > 0) || myRoute) {
693 // unblock undo/redo
695 // clear edges
696 clearPath();
697 // disable buttons
698 myFinishCreationButton->disable();
699 myAbortCreationButton->disable();
701 // update info route label
703 // update junction colors
705 // update edge colors
707 // update view (to see the new route)
709 }
710}
711
712
713void
715 if (mySelectedEdges.size() > 1) {
716 // remove special color of last selected edge
717 mySelectedEdges.back()->resetCandidateFlags();
718 // remove last edge
719 mySelectedEdges.pop_back();
720 // change last edge flag
721 if ((mySelectedEdges.size() > 0) && mySelectedEdges.back()->isSourceCandidate()) {
722 mySelectedEdges.back()->setSourceCandidate(false);
723 mySelectedEdges.back()->setTargetCandidate(true);
724 }
725 // enable or disable remove last edge button
726 if (mySelectedEdges.size() > 1) {
728 } else {
730 }
731 // recalculate path
733 // update info route label
735 // update junction colors
737 // update edge colors
739 // update view
741 }
742}
743
744
745long
746GNEPathCreator::onCmdCreatePath(FXObject*, FXSelector, void*) {
747 // call create path
748 return createPath(false);
749}
750
751
752long
753GNEPathCreator::onCmdUseLastRoute(FXObject*, FXSelector, void*) {
754 // call create path with useLastRoute = true
755 return createPath(true);
756}
757
758long
759GNEPathCreator::onUpdUseLastRoute(FXObject* sender, FXSelector, void*) {
761 return sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
762 } else {
763 return sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), nullptr);
764 }
765}
766
767long
768GNEPathCreator::onCmdAbortPathCreation(FXObject*, FXSelector, void*) {
769 // just call abort path creation
771 return 1;
772}
773
774
775long
776GNEPathCreator::onCmdRemoveLastElement(FXObject*, FXSelector, void*) {
777 // just call remove last element
779 return 1;
780}
781
782
783long
784GNEPathCreator::onCmdShowCandidateEdges(FXObject*, FXSelector, void*) {
785 // update labels
786 if (myShowCandidateEdges->getCheck() == TRUE) {
787 myShiftLabel->show();
788 myControlLabel->show();
789 } else {
790 myShiftLabel->hide();
791 myControlLabel->hide();
792 }
793 // recalc frame
794 recalc();
795 // update edge colors (view will be updated within function)
797 return 1;
798}
799
800
801void
803 if (myPath.size() > 0) {
804 // declare variables for route info
805 double length = 0;
806 double speed = 0;
807 int pathSize = 0;
808 for (const auto& path : myPath) {
809 for (const auto& edge : path.getSubPath()) {
810 length += edge->getNBEdge()->getLength();
811 speed += edge->getNBEdge()->getSpeed();
812 }
813 pathSize += (int)path.getSubPath().size();
814 }
815 // declare ostringstream for label and fill it
816 std::ostringstream information;
817 information
818 << TL("- Selected edges: ") << toString(mySelectedEdges.size()) << "\n"
819 << TL("- Path edges: ") << toString(pathSize) << "\n"
820 << TL("- Length: ") << toString(length) << "\n"
821 << TL("- Average speed: ") << toString(speed / pathSize);
822 // set new label
823 myInfoRouteLabel->setText(information.str().c_str());
824 } else {
825 myInfoRouteLabel->setText(TL("No edges selected"));
826 }
827}
828
829
830void
835 // clear junction, TAZs, edges, additionals and route
836 mySelectedJunctions.clear();
837 mySelectedTAZs.clear();
838 mySelectedEdges.clear();
839 myRoute = nullptr;
840 // clear path
841 myPath.clear();
842 // update info route label
844}
845
846
847void
849 // first clear path
850 myPath.clear();
851 // set edges
852 std::vector<GNEEdge*> edges;
853 // add route edges
854 if (myRoute) {
855 edges = myRoute->getParentEdges();
856 } else {
857 // add selected edges
858 for (const auto& edge : mySelectedEdges) {
859 edges.push_back(edge);
860 }
861 }
862 // fill paths
863 if (edges.size() == 1) {
864 myPath.push_back(Path(myVClass, edges.front()));
865 } else if (mySelectedJunctions.size() == 2) {
866 // add path between two junctions
868 } else {
869 // add every segment
870 for (int i = 1; i < (int)edges.size(); i++) {
871 myPath.push_back(Path(myPathManager, myVClass, edges.at(i - 1), edges.at(i)));
872 }
873 }
874}
875
876
877void
879 // first calculate reachability for pedestrians (we use it, because pedestran can walk in almost all edges)
881 // change flags
882 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
883 for (const auto& lane : edge.second->getLanes()) {
884 if (lane->getReachability() > 0) {
885 lane->getParentEdge()->resetCandidateFlags();
886 lane->getParentEdge()->setSpecialCandidate(true);
887 }
888 }
889 }
890}
891
892void
894 // first calculate reachability for pedestrians
896 // change flags
897 for (const auto& edge : myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getEdges()) {
898 for (const auto& lane : edge.second->getLanes()) {
899 if (lane->getReachability() > 0) {
900 lane->getParentEdge()->resetCandidateFlags();
901 lane->getParentEdge()->setPossibleCandidate(true);
902 }
903 }
904 }
905}
906
907/****************************************************************************/
FXDEFMAP(GNEPathCreator) PathCreatorMap[]
@ MID_GNE_PATHCREATOR_FINISH
finish edge path creation
Definition GUIAppEnum.h:989
@ MID_GNE_PATHCREATOR_REMOVELAST
remove last inserted element in path
Definition GUIAppEnum.h:993
@ MID_GNE_PATHCREATOR_USELASTROUTE
use last inserted route
Definition GUIAppEnum.h:991
@ MID_GNE_PATHCREATOR_ABORT
abort edge path creation
Definition GUIAppEnum.h:987
@ MID_GNE_PATHCREATOR_SHOWCANDIDATES
enable or disable show path candidates
Definition GUIAppEnum.h:995
#define GUIDesignButton
Definition GUIDesigns.h:88
#define GUIDesignCheckButton
checkButton placed in left position
Definition GUIDesigns.h:198
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition GUIDesigns.h:285
@ GLO_MAX
empty max
#define WRITE_WARNING(msg)
Definition MsgHandler.h:295
#define TL(string)
Definition MsgHandler.h:315
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:654
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:347
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:295
static void pushMatrix()
push matrix
Definition GLHelper.cpp:117
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:150
virtual bool createPath(const bool useLastRoute)
create path between two elements
Definition GNEFrame.cpp:304
const std::vector< 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:214
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:664
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:125
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)
void showPathCreatorModule(const GNETagProperties &tagProperty, const bool consecutives)
show GNEPathCreator for the given tag
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
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:276
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)