Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNEPlanCreator.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>
23#include <netedit/GNEViewNet.h>
32
33#include "GNEPlanCreator.h"
34
35// ===========================================================================
36// FOX callback mapping
37// ===========================================================================
38
46
47// Object implementation
48FXIMPLEMENT(GNEPlanCreator, MFXGroupBoxModule, PathCreatorMap, ARRAYNUMBER(PathCreatorMap))
49
50// ===========================================================================
51// method definitions
52// ===========================================================================
53
54GNEPlanCreator::PlanPath::PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEEdge* fromEdge, GNEEdge* toEdge) :
55 myConflictVClass(false),
56 myConflictDisconnected(false) {
57 // calculate subpath using given vClass
58 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(vClass, fromEdge, toEdge);
59 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
60 if (mySubPath.empty()) {
61 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, fromEdge, toEdge);
62 if (mySubPath.empty()) {
63 mySubPath = {fromEdge, toEdge};
64 myConflictDisconnected = true;
65 } else {
66 myConflictVClass = true;
67 }
68 }
69}
70
71
72GNEPlanCreator::PlanPath::PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEEdge* fromEdge, GNEJunction* toJunction) :
73 myConflictVClass(false),
74 myConflictDisconnected(false) {
75 // calculate subpath using given vClass
76 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(vClass, fromEdge, toJunction);
77 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
78 if (mySubPath.empty()) {
79 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, fromEdge, toJunction);
80 if (mySubPath.empty()) {
81 mySubPath = {fromEdge};
83 } else {
84 myConflictVClass = true;
85 }
86 }
87
88}
89
90
91GNEPlanCreator::PlanPath::PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEJunction* fromJunction, GNEEdge* toEdge) :
92 myConflictVClass(false),
93 myConflictDisconnected(false) {
94 // calculate subpath using given vClass
95 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(vClass, fromJunction, toEdge);
96 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
97 if (mySubPath.empty()) {
98 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, fromJunction, toEdge);
99 if (mySubPath.empty()) {
100 mySubPath = {toEdge};
102 } else {
103 myConflictVClass = true;
104 }
105 }
106
107}
108
109
110GNEPlanCreator::PlanPath::PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEJunction* fromJunction, GNEJunction* toJunction) :
111 myConflictVClass(false),
112 myConflictDisconnected(false) {
113 // calculate subpath using the given vClass
114 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(vClass, fromJunction, toJunction);
115 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
116 if (mySubPath.empty()) {
117 if (mySubPath.empty()) {
119 } else {
120 myConflictVClass = true;
121 }
122 }
123
124}
125
126
127const std::vector<GNEEdge*>&
129 return mySubPath;
130}
131
132
133bool
135 return myConflictVClass;
136}
137
138
139bool
141 return myConflictDisconnected;
142}
143
144
146 myConflictVClass(false),
147 myConflictDisconnected(false) {
148}
149
150
152 MFXGroupBoxModule(frameParent, TL("Route creator")),
153 myFrameParent(frameParent),
154 myPathManager(pathManager),
156 myPlanParents(0) {
157 // create button for use last route
159 myUseLastRoute->disable();
160 // create button for finish route creation
162 myFinishCreationButton->disable();
163 // create button for abort route creation
165 myAbortCreationButton->disable();
166 // create button for remove last inserted edge
169 // create info label
170 myInfoLabel = new FXLabel(this, "", 0, GUIDesignLabelFrameInformation);
171}
172
173
175
176
177bool
179 if (planTemplate == nullptr) {
180 return false;
181 } else if (planTemplate->getTagProperty()->isPlanPersonTrip()) {
183 } else if (planTemplate->getTagProperty()->isPlanWalk()) {
185 } else if (planTemplate->getTagProperty()->isPlanRide()) {
187 } else if (planTemplate->getTagProperty()->isPlanTransport()) {
189 } else if (planTemplate->getTagProperty()->isPlanTranship()) {
191 } else if (planTemplate->getTagProperty()->isPlanStopPerson()) {
193 } else if (planTemplate->getTagProperty()->isPlanStopContainer()) {
195 } else {
196 return false;
197 }
198}
199
200
201void
203 // first abort creation
205 // hide creation buttons
207 // reset plan parents
208 myPlanParents = 0;
209 // set previous plan element
210 myPreviousPlanElement = previousPlan;
211 // get current plan template
212 const auto& planTagProperty = planSelector->getCurrentPlanTagProperties();
213 // continue depending of plan selector template
214 if (planTagProperty->planRoute()) {
216 // show use last inserted route
217 myUseLastRoute->show();
218 } else {
219 // hide use last inserted route
220 myUseLastRoute->hide();
221 }
222 if (planTagProperty->planEdge()) {
224 }
225 if (planTagProperty->planStoppingPlace()) {
227 }
228 if (planTagProperty->planConsecutiveEdges()) {
230 // show creation buttons
232 }
233 if (planTagProperty->planFromEdge() || planTagProperty->planToEdge()) {
236 // show creation buttons
238 }
239 if (planTagProperty->planFromJunction() || planTagProperty->planToJunction()) {
242 // show creation buttons
244 }
245 if (planTagProperty->planFromTAZ() || planTagProperty->planToTAZ()) {
248 // show creation buttons
250 }
251 if (planTagProperty->planFromStoppingPlace() || planTagProperty->planToStoppingPlace()) {
254 // show creation buttons
256 }
257 // update info label (after setting myPlanParents)
259 // check if add first element
260 if (myPreviousPlanElement && planTagProperty->planFromTo()) {
261 const auto previousTagProperty = myPreviousPlanElement->getTagProperty();
262 // add last element of previous plan
263 if (previousTagProperty->planToEdge() || previousTagProperty->planEdge()) {
265 } else if (previousTagProperty->planToJunction()) {
267 } else if (previousTagProperty->planToTAZ()) {
269 } else if (previousTagProperty->planToStoppingPlace() || previousTagProperty->planStoppingPlace()) {
271 }
272 }
273 // set vClass
274 if (planTagProperty->isPlanRide() || planTagProperty->isPlanContainer()) {
276 } else {
278 }
279 // recalc before show (to avoid graphic problems)
280 recalc();
281 // show modul
282 show();
283}
284
285
286void
288 // clear path
289 clearPath();
290 // hide modul
291 hide();
292}
293
294
295bool
297 // check if routes are allowed
298 if ((myPlanParents & ROUTE) == 0) {
299 return false;
300 }
301 // add edge
303 // create path
304 return myFrameParent->createPath(false);
305}
306
307
308bool
310 // continue depending of plan parent
312 return addConsecutiveEdge(lane->getParentEdge());
313 } else if (myPlanParents & EDGE) {
314 return addSingleEdge(lane);
315 } else if ((myPlanParents & START_EDGE) || (myPlanParents & END_EDGE)) {
316 return addFromToEdge(lane->getParentEdge());
317 } else {
318 return false;
319 }
320}
321
322
323bool
326 return addFromToJunction(junction);
327 } else {
328 return false;
329 }
330}
331
332
333bool
336 return addFromToTAZ(taz);
337 } else {
338 return false;
339 }
340}
341
342
343bool
346 return addSingleStoppingPlace(stoppingPlace);
348 return addFromToStoppingPlace(stoppingPlace);
349 } else {
350 return false;
351 }
352}
353
354
359
360
361double
365
366
367const std::vector<GNEPlanCreator::PlanPath>&
369 return myPath;
370}
371
372
373void
375 const auto& ACs = myFrameParent->getViewNet()->getNet()->getAttributeCarriers();
376 const double lineWidth = 0.35;
377 const double lineWidthin = 0.25;
378 // Add a draw matrix
380 // Start with the drawing of the area traslating matrix to origin
381 glTranslated(0, 0, GLO_MAX - 0.1);
382 // check if draw bewteen junction or edges
383 if (myPath.size() > 0) {
384 // set first color
386 // iterate over path
387 for (int i = 0; i < (int)myPath.size(); i++) {
388 // get path
389 const GNEPlanCreator::PlanPath& path = myPath.at(i);
390 // draw line over
391 for (int j = 0; j < (int)path.getSubPath().size(); j++) {
392 const GNELane* lane = path.getSubPath().at(j)->getChildLanes().back();
393 if (((i == 0) && (j == 0)) || (j > 0)) {
394 GLHelper::drawBoxLines(lane->getLaneShape(), lineWidth);
395 }
396 // draw connection between lanes
397 if ((j + 1) < (int)path.getSubPath().size()) {
398 const GNELane* nextLane = path.getSubPath().at(j + 1)->getChildLanes().back();
399 if (lane->getLane2laneConnections().exist(nextLane)) {
401 } else {
402 GLHelper::drawBoxLines({lane->getLaneShape().back(), nextLane->getLaneShape().front()}, lineWidth);
403 }
404 }
405 }
406 }
407 glTranslated(0, 0, 0.1);
408 // iterate over path again
409 for (int i = 0; i < (int)myPath.size(); i++) {
410 // get path
411 const GNEPlanCreator::PlanPath& path = myPath.at(i);
412 // set path color color
413 if (path.isConflictDisconnected()) {
415 } else if (path.isConflictVClass()) {
417 } else {
419 }
420 // draw line over
421 for (int j = 0; j < (int)path.getSubPath().size(); j++) {
422 const GNELane* lane = path.getSubPath().at(j)->getChildLanes().back();
423 if (((i == 0) && (j == 0)) || (j > 0)) {
424 GLHelper::drawBoxLines(lane->getLaneShape(), lineWidthin);
425 }
426 // draw connection between lanes
427 if ((j + 1) < (int)path.getSubPath().size()) {
428 const GNELane* nextLane = path.getSubPath().at(j + 1)->getChildLanes().back();
429 if (lane->getLane2laneConnections().exist(nextLane)) {
431 } else {
432 GLHelper::drawBoxLines({ lane->getLaneShape().back(), nextLane->getLaneShape().front() }, lineWidthin);
433 }
434 }
435 }
436 }
437 } else if (!myPlanParameteres.fromJunction.empty() && !myPlanParameteres.toJunction.empty()) {
438 // set color
440 // get two points
441 const Position posA = ACs->getJunctions().at(myPlanParameteres.fromJunction)->getPositionInView();
442 const Position posB = ACs->getJunctions().at(myPlanParameteres.toJunction)->getPositionInView();
443 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) 180.0 / (double)M_PI);
444 const double len = posA.distanceTo2D(posB);
445 // draw line
446 GLHelper::drawBoxLine(posA, rot, len, 0.25);
447 } else if (!myPlanParameteres.fromTAZ.empty() && !myPlanParameteres.toTAZ.empty()) {
448 // set color
450 // get two points
451 const Position posA = ACs->retrieveAdditional(SUMO_TAG_TAZ, myPlanParameteres.fromTAZ)->getPositionInView();
452 const Position posB = ACs->retrieveAdditional(SUMO_TAG_TAZ, myPlanParameteres.toTAZ)->getPositionInView();
453 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) 180.0 / (double)M_PI);
454 const double len = posA.distanceTo2D(posB);
455 // draw line
456 GLHelper::drawBoxLine(posA, rot, len, 0.25);
457 }
458 // Pop last matrix
460}
461
462
463void
465 // first check that there is elements
466 if (getNumberOfSelectedElements() > 0) {
467 // unblock undo/redo
469 // clear edges
470 clearPath();
471 // disable buttons
472 myFinishCreationButton->disable();
473 myAbortCreationButton->disable();
475 // update view (to see the new route)
477 }
478}
479
480
481void
483 if (myRemoveLastInsertedElement->isEnabled()) {
484 if (myPlanParameteres.consecutiveEdges.size() > 0) {
486 } else if (!myPlanParameteres.toEdge.empty()) {
488 } else if (!myPlanParameteres.toJunction.empty()) {
490 } else if (!myPlanParameteres.toTAZ.empty()) {
491 myPlanParameteres.toTAZ.clear();
492 } else if (!myPlanParameteres.toBusStop.empty()) {
494 } else if (!myPlanParameteres.toTrainStop.empty()) {
496 } else if (!myPlanParameteres.toContainerStop.empty()) {
498 } else if (!myPlanParameteres.toChargingStation.empty()) {
500 } else if (!myPlanParameteres.toParkingArea.empty()) {
502 } else if (!myPlanParameteres.fromEdge.empty()) {
504 } else if (!myPlanParameteres.fromJunction.empty()) {
506 } else if (!myPlanParameteres.fromTAZ.empty()) {
508 } else if (!myPlanParameteres.fromBusStop.empty()) {
510 } else if (!myPlanParameteres.fromTrainStop.empty()) {
512 } else if (!myPlanParameteres.fromContainerStop.empty()) {
514 } else if (!myPlanParameteres.fromChargingStation.empty()) {
516 } else if (!myPlanParameteres.fromParkingArea.empty()) {
518 }
519 // update remove last item button
521 // recalculate path
523 }
524}
525
526
527long
528GNEPlanCreator::onCmdCreatePath(FXObject*, FXSelector, void*) {
529 // call create path
530 return myFrameParent->createPath(false);
531}
532
533
534long
535GNEPlanCreator::onCmdUseLastRoute(FXObject*, FXSelector, void*) {
536 // call create path using last route
537 return myFrameParent->createPath(true);
538}
539
540
541long
542GNEPlanCreator::onUpdUseLastRoute(FXObject* sender, FXSelector, void*) {
544 return sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
545 } else {
546 return sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), nullptr);
547 }
548}
549
550long
551GNEPlanCreator::onCmdAbortPathCreation(FXObject*, FXSelector, void*) {
552 // just call abort path creation
554 return 1;
555}
556
557
558long
559GNEPlanCreator::onCmdRemoveLastElement(FXObject*, FXSelector, void*) {
560 // just call remove last element
562 return 1;
563}
564
565
566void
568 // clear all elements
571 // clear path
572 myPath.clear();
573}
574
575
576void
578 const auto& ACs = myFrameParent->getViewNet()->getNet()->getAttributeCarriers();
579 // first clear path
580 myPath.clear();
581 // continue depending of elements
582 if (myPlanParameteres.consecutiveEdges.size() > 0) {
583 // add every segment
584 for (int i = 1; i < (int)myPlanParameteres.consecutiveEdges.size(); i++) {
586 ACs->retrieveEdge(myPlanParameteres.consecutiveEdges.at(i - 1)),
587 ACs->retrieveEdge(myPlanParameteres.consecutiveEdges.at(i))));
588 }
589 } else {
590 // get from edge
591 GNEEdge* fromEdge = nullptr;
592 if (!myPlanParameteres.fromEdge.empty()) {
593 fromEdge = ACs->retrieveEdge(myPlanParameteres.fromEdge);
594 } else if (!myPlanParameteres.fromBusStop.empty()) {
595 fromEdge = ACs->retrieveAdditional(SUMO_TAG_BUS_STOP, myPlanParameteres.fromBusStop)->getParentLanes().front()->getParentEdge();
596 } else if (!myPlanParameteres.fromTrainStop.empty()) {
597 fromEdge = ACs->retrieveAdditional(SUMO_TAG_TRAIN_STOP, myPlanParameteres.fromTrainStop)->getParentLanes().front()->getParentEdge();
598 } else if (!myPlanParameteres.fromContainerStop.empty()) {
599 fromEdge = ACs->retrieveAdditional(SUMO_TAG_CONTAINER_STOP, myPlanParameteres.fromContainerStop)->getParentLanes().front()->getParentEdge();
600 } else if (!myPlanParameteres.fromChargingStation.empty()) {
601 fromEdge = ACs->retrieveAdditional(SUMO_TAG_CHARGING_STATION, myPlanParameteres.fromChargingStation)->getParentLanes().front()->getParentEdge();
602 } else if (!myPlanParameteres.fromParkingArea.empty()) {
603 fromEdge = ACs->retrieveAdditional(SUMO_TAG_PARKING_AREA, myPlanParameteres.fromParkingArea)->getParentLanes().front()->getParentEdge();
604 }
605 // get to edge
606 GNEEdge* toEdge = nullptr;
607 if (!myPlanParameteres.toEdge.empty()) {
608 toEdge = ACs->retrieveEdge(myPlanParameteres.toEdge);
609 } else if (!myPlanParameteres.toBusStop.empty()) {
610 toEdge = ACs->retrieveAdditional(SUMO_TAG_BUS_STOP, myPlanParameteres.toBusStop)->getParentLanes().front()->getParentEdge();
611 } else if (!myPlanParameteres.toTrainStop.empty()) {
612 toEdge = ACs->retrieveAdditional(SUMO_TAG_TRAIN_STOP, myPlanParameteres.toTrainStop)->getParentLanes().front()->getParentEdge();
613 } else if (!myPlanParameteres.toContainerStop.empty()) {
614 toEdge = ACs->retrieveAdditional(SUMO_TAG_CONTAINER_STOP, myPlanParameteres.toContainerStop)->getParentLanes().front()->getParentEdge();
615 } else if (!myPlanParameteres.toChargingStation.empty()) {
616 toEdge = ACs->retrieveAdditional(SUMO_TAG_CHARGING_STATION, myPlanParameteres.toChargingStation)->getParentLanes().front()->getParentEdge();
617 } else if (!myPlanParameteres.toParkingArea.empty()) {
618 toEdge = ACs->retrieveAdditional(SUMO_TAG_PARKING_AREA, myPlanParameteres.toParkingArea)->getParentLanes().front()->getParentEdge();
619 }
620 // continue depending of edges and junctions
621 if (fromEdge && toEdge) {
622 myPath.push_back(PlanPath(myPathManager, myVClass, fromEdge, toEdge));
623 } else if (fromEdge && !myPlanParameteres.toJunction.empty()) {
624 myPath.push_back(PlanPath(myPathManager, myVClass, fromEdge, ACs->getJunctions().at(myPlanParameteres.toJunction)));
625 } else if (!myPlanParameteres.fromJunction.empty() && toEdge) {
626 myPath.push_back(PlanPath(myPathManager, myVClass, ACs->getJunctions().at(myPlanParameteres.fromJunction), toEdge));
627 } else if (!myPlanParameteres.fromJunction.empty() && !myPlanParameteres.toJunction.empty()) {
629 ACs->getJunctions().at(myPlanParameteres.fromJunction),
630 ACs->getJunctions().at(myPlanParameteres.toJunction)));
631 }
632 }
633}
634
635
636int
640
641
642void
645 if (getNumberOfSelectedElements() == 2) {
647 } else {
649 }
650 } else {
651 if (getNumberOfSelectedElements() > 0) {
653 } else {
655 }
656 }
657}
658
659
660void
666
667
668void
674
675
676void
678 // declare booleans
679 const bool consecutiveEdges = (myPlanParents & CONSECUTIVE_EDGES);
680 const bool route = (myPlanParents & ROUTE);
681 const bool edges = (myPlanParents & EDGE) ||
684 const bool TAZs = (myPlanParents & START_TAZ) ||
686 const bool junctions = (myPlanParents & START_JUNCTION) ||
688 const bool stoppingPlace = (myPlanParents & STOPPINGPLACE) ||
691
692 // declare ostringstream for label and fill it
693 std::ostringstream information;
694 information
695 << TL("Click over:") << "\n"
696 << (consecutiveEdges ? "- Consecutive edges\n" : "")
697 << (route ? "- Routes\n" : "")
698 << (edges ? "- Edges\n" : "")
699 << (TAZs ? "- TAZs\n" : "")
700 << (junctions ? "- Junctions\n" : "")
701 << (stoppingPlace ? "- StoppingPlaces\n" : "");
702 // remove last \n
703 std::string informationStr = information.str();
704 informationStr.pop_back();
705 // set label text
706 myInfoLabel->setText(informationStr.c_str());
707}
708
709
710bool
712 // add edge
714 // set position over lane
715 const auto clickedPos = myFrameParent->getViewNet()->getPositionInformation();
717 // create path
718 return myFrameParent->createPath(false);
719}
720
721
722bool
724 // continue depending of stoppingPlace tag
725 switch (stoppingPlace->getTagProperty()->getTag()) {
727 myPlanParameteres.toBusStop = stoppingPlace->getID();
728 break;
730 myPlanParameteres.toTrainStop = stoppingPlace->getID();
731 break;
733 myPlanParameteres.toContainerStop = stoppingPlace->getID();
734 break;
736 myPlanParameteres.toChargingStation = stoppingPlace->getID();
737 break;
739 myPlanParameteres.toParkingArea = stoppingPlace->getID();
740 break;
741 default:
742 // abort creation
743 return false;
744 }
745 // create path
746 return myFrameParent->createPath(false);
747}
748
749
750bool
752 // check double edges
753 if ((myPlanParameteres.consecutiveEdges.size() > 0) && (myPlanParameteres.consecutiveEdges.back() == edge->getID())) {
754 // Write warning
755 WRITE_WARNING(TL("Double edges aren't allowed"));
756 // abort add edge
757 return false;
758 }
759 // All checks ok, then add it in selected elements
760 myPlanParameteres.consecutiveEdges.push_back(edge->getID());
761 // enable abort route button
762 myAbortCreationButton->enable();
763 // enable finish button
764 myFinishCreationButton->enable();
765 // update remove last item button
767 // recalculate path
769 // edge added, then return true
770 return true;
771}
772
773
774bool
776 // avoid double junctions
777 if (myPlanParameteres.fromJunction == junction->getID()) {
778 // Write warning
779 WRITE_WARNING(TL("Double junctions aren't allowed"));
780 // abort add junction
781 return false;
782 }
783 // check number of selected items
784 if (getNumberOfSelectedElements() == 2) {
785 // Write warning
786 WRITE_WARNING(TL("Only two from-to elements are allowed"));
787 // abort add function
788 return false;
789 }
790 // set junction
791 if (getNumberOfSelectedElements() == 0) {
793 } else {
794 myPlanParameteres.toJunction = junction->getID();
795 }
796 // enable abort route button
797 myAbortCreationButton->enable();
798 // enable finish button
799 myFinishCreationButton->enable();
800 // update remove last item button
802 // recalculate path
804 return true;
805}
806
807
808bool
810 // avoid double TAZs
811 if (myPlanParameteres.fromTAZ == TAZ->getID()) {
812 // Write warning
813 WRITE_WARNING(TL("Double TAZs aren't allowed"));
814 // abort add TAZ
815 return false;
816 }
817 // check number of selected items
818 if (getNumberOfSelectedElements() == 2) {
819 // Write warning
820 WRITE_WARNING(TL("Only two from-to elements are allowed"));
821 // abort add function
822 return false;
823 }
824 // set TAZ
825 if (getNumberOfSelectedElements() == 0) {
826 myPlanParameteres.fromTAZ = TAZ->getID();
827 } else {
828 myPlanParameteres.toTAZ = TAZ->getID();
829 }
830 // enable abort route button
831 myAbortCreationButton->enable();
832 // enable finish button
833 myFinishCreationButton->enable();
834 // update remove last item button
836 // recalculate path
838 return true;
839}
840
841
842bool
844 // check double edges
845 if (myPlanParameteres.fromEdge == edge->getID()) {
846 // Write warning
847 WRITE_WARNING(TL("Double edges aren't allowed"));
848 // abort add edge
849 return false;
850 }
851 // check number of selected items
852 if (getNumberOfSelectedElements() == 2) {
853 // Write warning
854 WRITE_WARNING(TL("Only two from-to elements are allowed"));
855 // abort add function
856 return false;
857 }
858 // set edge
859 if (getNumberOfSelectedElements() == 0) {
861 } else {
863 }
864 // enable abort route button
865 myAbortCreationButton->enable();
866 // enable finish button
867 myFinishCreationButton->enable();
868 // update remove last item button
870 // recalculate path
872 // edge added, then return true
873 return true;
874}
875
876
877bool
879 // check double stoppingPlaces
880 const auto stoppingPlaceID = stoppingPlace->getID();
881 if ((myPlanParameteres.toBusStop == stoppingPlaceID) ||
882 (myPlanParameteres.toTrainStop == stoppingPlaceID) ||
883 (myPlanParameteres.toContainerStop == stoppingPlaceID) ||
884 (myPlanParameteres.toChargingStation == stoppingPlaceID) ||
885 (myPlanParameteres.toParkingArea == stoppingPlaceID)) {
886 // Write warning
887 WRITE_WARNING(TL("Double stoppingPlaces aren't allowed"));
888 // abort add stopping place
889 return false;
890 }
891 // check number of selected items
892 if (getNumberOfSelectedElements() == 2) {
893 // Write warning
894 WRITE_WARNING(TL("Only two from-to elements are allowed"));
895 // abort add function
896 return false;
897 }
898 // add stoppingPlace
899 if (getNumberOfSelectedElements() == 0) {
900 // continue depending of stoppingPlace tag
901 switch (stoppingPlace->getTagProperty()->getTag()) {
903 myPlanParameteres.fromBusStop = stoppingPlaceID;
904 break;
906 myPlanParameteres.fromTrainStop = stoppingPlaceID;
907 break;
909 myPlanParameteres.fromContainerStop = stoppingPlaceID;
910 break;
912 myPlanParameteres.fromChargingStation = stoppingPlaceID;
913 break;
915 myPlanParameteres.fromParkingArea = stoppingPlaceID;
916 break;
917 default:
918 return false;
919 }
920 } else {
921 // continue depending of stoppingPlace tag
922 switch (stoppingPlace->getTagProperty()->getTag()) {
924 myPlanParameteres.toBusStop = stoppingPlaceID;
925 break;
927 myPlanParameteres.toTrainStop = stoppingPlaceID;
928 break;
930 myPlanParameteres.toContainerStop = stoppingPlaceID;
931 break;
933 myPlanParameteres.toChargingStation = stoppingPlaceID;
934 break;
936 myPlanParameteres.toParkingArea = stoppingPlaceID;
937 break;
938 default:
939 return false;
940 }
941 }
942 // enable abort route button
943 myAbortCreationButton->enable();
944 // enable finish button
945 myFinishCreationButton->enable();
946 // disable undo/redo
947 myFrameParent->getViewNet()->getViewParent()->getGNEAppWindows()->disableUndoRedoTemporally("creation of stoppingPlace path");
948 // enable or disable remove last item button
950 // recalculate path
952 // stopping place added, then return true
953 return true;
954}
955
956/****************************************************************************/
FXDEFMAP(GNEPlanCreator) 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
#define GUIDesignButton
Definition GUIDesigns.h:82
#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:287
#define TL(string)
Definition MsgHandler.h:305
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_TAZ
a traffic assignment zone
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_NOTHING
invalid tag, must be the last one
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
plan parameters (used for group all from-to parameters related with plans)
SumoXMLTag getPersonStopTag() const
get the person stop tag for the current combination of parameters
std::string fromJunction
from junction
SumoXMLTag getRideTag() const
get the ride tag for the current combination of parameters
std::string fromContainerStop
from containerStop
int getNumberOfDefinedParameters() const
get number of defined plans
std::string fromTrainStop
from trainStop
SumoXMLTag getPersonTripTag() const
get the personTrip tag for the current combination of parameters
SumoXMLTag getTransportTag() const
get the transport tag for the current combination of parameters
std::string toParkingArea
to parkingArea
std::vector< std::string > consecutiveEdges
consecutive edges
std::string fromChargingStation
from chargingStation
SumoXMLTag getContainerStopTag() const
get the container stop tag for the current combination of parameters
std::string toChargingStation
to chargingStation
std::string fromParkingArea
from parkingArea
std::string toContainerStop
to containerStop
SumoXMLTag getWalkTag() const
get the walk tag for the current combination of parameters
SumoXMLTag getTranshipTag() const
get the tranship tag for the current combination of parameters
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)
const std::string getID() const
get ID (all Attribute Carriers have one)
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:155
virtual bool createPath(const bool useLastRoute)
create path between two elements
Definition GNEFrame.cpp:308
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
const GNEHierarchicalContainerParents< GNEJunction * > & getParentJunctions() const
get parent junctions
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
const GNEHierarchicalContainerParents< GNEAdditional * > getParentStoppingPlaces() const
get parent stoppingPlaces (used by plans)
const GNEHierarchicalContainerParents< GNEAdditional * > getParentTAZs() const
get parent TAZs (used by plans)
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
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:202
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:147
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)
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
bool myConflictVClass
flag to mark this path as conflicted
bool isConflictDisconnected() const
check if current path is conflict due is disconnected
bool myConflictDisconnected
flag to mark this path as disconnected
const std::vector< GNEEdge * > & getSubPath() const
get sub path
PlanPath()
default constructor
std::vector< GNEEdge * > mySubPath
sub path
bool isConflictVClass() const
check if current path is conflict due vClass
bool addStoppingPlace(GNEAdditional *stoppingPlace)
add from to stoppingPlace
bool addConsecutiveEdge(GNEEdge *edge)
add consecutive edge
void removeLastElement()
remove path element
bool addRoute(GNEDemandElement *route)
add route
double myClickedPositionOverLane
clicked position over lane
const GNEDemandElement * myPreviousPlanElement
previous person plan element
double getClickedPositionOverLane() const
get clicked position over lane
bool addFromToJunction(GNEJunction *junction)
add junction
bool planCanBeCreated(const GNEDemandElement *planTemplate) const
check if plan can be created
long onUpdUseLastRoute(FXObject *, FXSelector, void *)
Called when update button "Use last route".
bool addSingleEdge(GNELane *lane)
add edge
GNEPlanCreator(GNEFrame *frameParent, GNEPathManager *pathManager)
default constructor
GNEFrame * myFrameParent
current frame parent
int myPlanParents
allowed plan parents
void hidePathCreatorModule()
show GNEPlanCreator
long onCmdCreatePath(FXObject *, FXSelector, void *)
void showCreationButtons()
show creation buttons
long onCmdUseLastRoute(FXObject *, FXSelector, void *)
Called when the user click over button "Use last route".
bool addTAZ(GNEAdditional *taz)
add TAZ
void updateRemoveLastItemButton() const
check if enable remove last item button
bool addJunction(GNEJunction *junction)
add junction
int getNumberOfSelectedElements() const
get number of selected elements
void recalculatePath()
recalculate path
CommonXMLStructure::PlanParameters myPlanParameteres
plan parameters
bool addEdge(GNELane *lane)
add edge (clicking over lanes)
SUMOVehicleClass myVClass
current vClass
bool addFromToEdge(GNEEdge *edge)
add from to edge
~GNEPlanCreator()
destructor
FXButton * myAbortCreationButton
button for abort route creation
GNEPathManager * myPathManager
path manager used in this plan creator
void abortPathCreation()
abort path creation
long onCmdAbortPathCreation(FXObject *, FXSelector, void *)
Called when the user click over button "Abort route creation".
void clearPath()
clear edges
FXButton * myFinishCreationButton
button for finish route creation
void drawTemporalRoute(const GUIVisualizationSettings &s) const
draw temporal route
bool addFromToTAZ(GNEAdditional *taz)
add TAZ
long onCmdRemoveLastElement(FXObject *, FXSelector, void *)
Called when the user click over button "Remove las inserted edge".
FXButton * myRemoveLastInsertedElement
button for removing last inserted element
std::vector< PlanPath > myPath
vector with current path
const std::vector< PlanPath > & getPath() const
get path route
FXButton * myUseLastRoute
button for use last inserted route
bool addFromToStoppingPlace(GNEAdditional *stoppingPlace)
add from to stoppingPlace
FXLabel * myInfoLabel
info label
void hideCreationButtons()
hide creation buttons
void showPlanCreatorModule(const GNEPlanSelector *planSelector, const GNEDemandElement *previousPlan)
show plan creator for the given tag property
const CommonXMLStructure::PlanParameters & getPlanParameteres() const
get plan parameters
void updateInfoLabel()
update info label
bool addSingleStoppingPlace(GNEAdditional *stoppingPlace)
add stoppingPlace
const GNETagProperties * getCurrentPlanTagProperties() const
get current plan tag properties
bool isPlanTransport() const
return true if tag correspond to a transport
bool isPlanStopContainer() const
return true if tag correspond to a container stop plan
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool isPlanPersonTrip() const
return true if tag correspond to a person trip plan
bool isPlanRide() const
return true if tag correspond to a ride plan
bool isPlanStopPerson() const
return true if tag correspond to a person stop plan
bool isPlanWalk() const
return true if tag correspond to a walk plan
bool isPlanTranship() const
return true if tag correspond to a tranship
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
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
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
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
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)