Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-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>
33
34#include "GNEPlanCreator.h"
35
36
37// ===========================================================================
38// FOX callback mapping
39// ===========================================================================
40
48
49// Object implementation
50FXIMPLEMENT(GNEPlanCreator, MFXGroupBoxModule, PathCreatorMap, ARRAYNUMBER(PathCreatorMap))
51
52
53// ===========================================================================
54// method definitions
55// ===========================================================================
56
57
58GNEPlanCreator::PlanPath::PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEEdge* fromEdge, GNEEdge* toEdge) :
59 myConflictVClass(false),
60 myConflictDisconnected(false) {
61 // calculate subpath using given vClass
62 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(vClass, fromEdge, toEdge);
63 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
64 if (mySubPath.empty()) {
65 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, fromEdge, toEdge);
66 if (mySubPath.empty()) {
67 mySubPath = {fromEdge, toEdge};
68 myConflictDisconnected = true;
69 } else {
70 myConflictVClass = true;
71 }
72 }
73}
74
75
76GNEPlanCreator::PlanPath::PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEEdge* fromEdge, GNEJunction* toJunction) :
77 myConflictVClass(false),
78 myConflictDisconnected(false) {
79 // calculate subpath using given vClass
80 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(vClass, fromEdge, toJunction);
81 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
82 if (mySubPath.empty()) {
83 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, fromEdge, toJunction);
84 if (mySubPath.empty()) {
85 mySubPath = {fromEdge};
87 } else {
88 myConflictVClass = true;
89 }
90 }
91
92}
93
94
95GNEPlanCreator::PlanPath::PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEJunction* fromJunction, GNEEdge* toEdge) :
96 myConflictVClass(false),
97 myConflictDisconnected(false) {
98 // calculate subpath using given vClass
99 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(vClass, fromJunction, toEdge);
100 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
101 if (mySubPath.empty()) {
102 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, fromJunction, toEdge);
103 if (mySubPath.empty()) {
104 mySubPath = {toEdge};
106 } else {
107 myConflictVClass = true;
108 }
109 }
110
111}
112
113
114GNEPlanCreator::PlanPath::PlanPath(GNEPathManager* pathManager, const SUMOVehicleClass vClass, GNEJunction* fromJunction, GNEJunction* toJunction) :
115 myConflictVClass(false),
116 myConflictDisconnected(false) {
117 // calculate subpath using the given vClass
118 mySubPath = pathManager->getPathCalculator()->calculateDijkstraPath(vClass, fromJunction, toJunction);
119 // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
120 if (mySubPath.empty()) {
121 if (mySubPath.empty()) {
123 } else {
124 myConflictVClass = true;
125 }
126 }
127
128}
129
130
131const std::vector<GNEEdge*>&
133 return mySubPath;
134}
135
136
137bool
139 return myConflictVClass;
140}
141
142
143bool
145 return myConflictDisconnected;
146}
147
148
150 myConflictVClass(false),
151 myConflictDisconnected(false) {
152}
153
154
156 MFXGroupBoxModule(frameParent, TL("Route creator")),
157 myFrameParent(frameParent),
158 myPathManager(pathManager),
160 myPlanParents(0) {
161 // create button for use last route
163 myUseLastRoute->disable();
164 // create button for finish route creation
166 myFinishCreationButton->disable();
167 // create button for abort route creation
169 myAbortCreationButton->disable();
170 // create button for remove last inserted edge
173 // create info label
174 myInfoLabel = new FXLabel(this, "", 0, GUIDesignLabelFrameInformation);
175}
176
177
179
180
181bool
183 if (planTemplate == nullptr) {
184 return false;
185 } else if (planTemplate->getTagProperty().isPlanPersonTrip()) {
187 } else if (planTemplate->getTagProperty().isPlanWalk()) {
189 } else if (planTemplate->getTagProperty().isPlanRide()) {
191 } else if (planTemplate->getTagProperty().isPlanTransport()) {
193 } else if (planTemplate->getTagProperty().isPlanTranship()) {
195 } else if (planTemplate->getTagProperty().isPlanStopPerson()) {
197 } else if (planTemplate->getTagProperty().isPlanStopContainer()) {
199 } else {
200 return false;
201 }
202}
203
204
205void
207 // first abort creation
209 // hide creation buttons
211 // reset plan parents
212 myPlanParents = 0;
213 // set previous plan element
214 myPreviousPlanElement = previousPlan;
215 // get current plan template
216 const auto& planTagProperties = planSelector->getCurrentPlanTagProperties();
217 // continue depending of plan selector template
218 if (planTagProperties.planRoute()) {
220 // show use last inserted route
221 myUseLastRoute->show();
222 } else {
223 // hide use last inserted route
224 myUseLastRoute->hide();
225 }
226 if (planTagProperties.planEdge()) {
228 }
229 if (planTagProperties.planStoppingPlace()) {
231 }
232 if (planTagProperties.planConsecutiveEdges()) {
234 // show creation buttons
236 }
237 if (planTagProperties.planFromEdge() || planTagProperties.planToEdge()) {
240 // show creation buttons
242 }
243 if (planTagProperties.planFromJunction() || planTagProperties.planToJunction()) {
246 // show creation buttons
248 }
249 if (planTagProperties.planFromTAZ() || planTagProperties.planToTAZ()) {
252 // show creation buttons
254 }
255 if (planTagProperties.planFromStoppingPlace() || planTagProperties.planToStoppingPlace()) {
258 // show creation buttons
260 }
261 // update info label (after setting myPlanParents)
263 // check if add first element
264 if (myPreviousPlanElement && planTagProperties.planFromTo()) {
265 const auto previousTagProperty = myPreviousPlanElement->getTagProperty();
266 // add last element of previous plan
267 if (previousTagProperty.planToEdge() || previousTagProperty.planEdge()) {
269 } else if (previousTagProperty.planToJunction()) {
271 } else if (previousTagProperty.planToTAZ()) {
273 } else if (previousTagProperty.planToStoppingPlace() || previousTagProperty.planStoppingPlace()) {
275 }
276 }
277 // set vClass
278 if (planTagProperties.isPlanRide() || planTagProperties.isPlanContainer()) {
280 } else {
282 }
283 // recalc before show (to avoid graphic problems)
284 recalc();
285 // show modul
286 show();
287}
288
289
290void
292 // clear path
293 clearPath();
294 // hide modul
295 hide();
296}
297
298
299bool
301 // check if routes are allowed
302 if ((myPlanParents & ROUTE) == 0) {
303 return false;
304 }
305 // add edge
307 // create path
308 return myFrameParent->createPath(false);
309}
310
311
312bool
314 // continue depending of plan parent
316 return addConsecutiveEdge(lane->getParentEdge());
317 } else if (myPlanParents & EDGE) {
318 return addSingleEdge(lane);
319 } else if ((myPlanParents & START_EDGE) || (myPlanParents & END_EDGE)) {
320 return addFromToEdge(lane->getParentEdge());
321 } else {
322 return false;
323 }
324}
325
326
327bool
330 return addFromToJunction(junction);
331 } else {
332 return false;
333 }
334}
335
336
337bool
340 return addFromToTAZ(taz);
341 } else {
342 return false;
343 }
344}
345
346
347bool
350 return addSingleStoppingPlace(stoppingPlace);
352 return addFromToStoppingPlace(stoppingPlace);
353 } else {
354 return false;
355 }
356}
357
358
363
364
365double
369
370
371const std::vector<GNEPlanCreator::PlanPath>&
373 return myPath;
374}
375
376
377void
379 const auto& ACs = myFrameParent->getViewNet()->getNet()->getAttributeCarriers();
380 const double lineWidth = 0.35;
381 const double lineWidthin = 0.25;
382 // Add a draw matrix
384 // Start with the drawing of the area traslating matrix to origin
385 glTranslated(0, 0, GLO_MAX - 0.1);
386 // check if draw bewteen junction or edges
387 if (myPath.size() > 0) {
388 // set first color
390 // iterate over path
391 for (int i = 0; i < (int)myPath.size(); i++) {
392 // get path
393 const GNEPlanCreator::PlanPath& path = myPath.at(i);
394 // draw line over
395 for (int j = 0; j < (int)path.getSubPath().size(); j++) {
396 const GNELane* lane = path.getSubPath().at(j)->getLanes().back();
397 if (((i == 0) && (j == 0)) || (j > 0)) {
398 GLHelper::drawBoxLines(lane->getLaneShape(), lineWidth);
399 }
400 // draw connection between lanes
401 if ((j + 1) < (int)path.getSubPath().size()) {
402 const GNELane* nextLane = path.getSubPath().at(j + 1)->getLanes().back();
403 if (lane->getLane2laneConnections().exist(nextLane)) {
405 } else {
406 GLHelper::drawBoxLines({lane->getLaneShape().back(), nextLane->getLaneShape().front()}, lineWidth);
407 }
408 }
409 }
410 }
411 glTranslated(0, 0, 0.1);
412 // iterate over path again
413 for (int i = 0; i < (int)myPath.size(); i++) {
414 // get path
415 const GNEPlanCreator::PlanPath& path = myPath.at(i);
416 // set path color color
417 if (path.isConflictDisconnected()) {
419 } else if (path.isConflictVClass()) {
421 } else {
423 }
424 // draw line over
425 for (int j = 0; j < (int)path.getSubPath().size(); j++) {
426 const GNELane* lane = path.getSubPath().at(j)->getLanes().back();
427 if (((i == 0) && (j == 0)) || (j > 0)) {
428 GLHelper::drawBoxLines(lane->getLaneShape(), lineWidthin);
429 }
430 // draw connection between lanes
431 if ((j + 1) < (int)path.getSubPath().size()) {
432 const GNELane* nextLane = path.getSubPath().at(j + 1)->getLanes().back();
433 if (lane->getLane2laneConnections().exist(nextLane)) {
435 } else {
436 GLHelper::drawBoxLines({ lane->getLaneShape().back(), nextLane->getLaneShape().front() }, lineWidthin);
437 }
438 }
439 }
440 }
441 } else if (!myPlanParameteres.fromJunction.empty() && !myPlanParameteres.toJunction.empty()) {
442 // set color
444 // get two points
445 const Position posA = ACs->getJunctions().at(myPlanParameteres.fromJunction)->getPositionInView();
446 const Position posB = ACs->getJunctions().at(myPlanParameteres.toJunction)->getPositionInView();
447 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) 180.0 / (double)M_PI);
448 const double len = posA.distanceTo2D(posB);
449 // draw line
450 GLHelper::drawBoxLine(posA, rot, len, 0.25);
451 } else if (!myPlanParameteres.fromTAZ.empty() && !myPlanParameteres.toTAZ.empty()) {
452 // set color
454 // get two points
455 const Position posA = ACs->retrieveAdditional(SUMO_TAG_TAZ, myPlanParameteres.fromTAZ)->getPositionInView();
456 const Position posB = ACs->retrieveAdditional(SUMO_TAG_TAZ, myPlanParameteres.toTAZ)->getPositionInView();
457 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) 180.0 / (double)M_PI);
458 const double len = posA.distanceTo2D(posB);
459 // draw line
460 GLHelper::drawBoxLine(posA, rot, len, 0.25);
461 }
462 // Pop last matrix
464}
465
466
467void
469 // first check that there is elements
470 if (getNumberOfSelectedElements() > 0) {
471 // unblock undo/redo
473 // clear edges
474 clearPath();
475 // disable buttons
476 myFinishCreationButton->disable();
477 myAbortCreationButton->disable();
479 // update view (to see the new route)
481 }
482}
483
484
485void
487 if (myRemoveLastInsertedElement->isEnabled()) {
488 if (myPlanParameteres.consecutiveEdges.size() > 0) {
490 } else if (!myPlanParameteres.toEdge.empty()) {
492 } else if (!myPlanParameteres.toJunction.empty()) {
494 } else if (!myPlanParameteres.toTAZ.empty()) {
495 myPlanParameteres.toTAZ.clear();
496 } else if (!myPlanParameteres.toBusStop.empty()) {
498 } else if (!myPlanParameteres.toTrainStop.empty()) {
500 } else if (!myPlanParameteres.toContainerStop.empty()) {
502 } else if (!myPlanParameteres.toChargingStation.empty()) {
504 } else if (!myPlanParameteres.toParkingArea.empty()) {
506 } else if (!myPlanParameteres.fromEdge.empty()) {
508 } else if (!myPlanParameteres.fromJunction.empty()) {
510 } else if (!myPlanParameteres.fromTAZ.empty()) {
512 } else if (!myPlanParameteres.fromBusStop.empty()) {
514 } else if (!myPlanParameteres.fromTrainStop.empty()) {
516 } else if (!myPlanParameteres.fromContainerStop.empty()) {
518 } else if (!myPlanParameteres.fromChargingStation.empty()) {
520 } else if (!myPlanParameteres.fromParkingArea.empty()) {
522 }
523 // update remove last item button
525 // recalculate path
527 }
528}
529
530
531long
532GNEPlanCreator::onCmdCreatePath(FXObject*, FXSelector, void*) {
533 // call create path
534 return myFrameParent->createPath(false);
535}
536
537
538long
539GNEPlanCreator::onCmdUseLastRoute(FXObject*, FXSelector, void*) {
540 // call create path using last route
541 return myFrameParent->createPath(true);
542}
543
544
545long
546GNEPlanCreator::onUpdUseLastRoute(FXObject* sender, FXSelector, void*) {
548 return sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
549 } else {
550 return sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), nullptr);
551 }
552}
553
554long
555GNEPlanCreator::onCmdAbortPathCreation(FXObject*, FXSelector, void*) {
556 // just call abort path creation
558 return 1;
559}
560
561
562long
563GNEPlanCreator::onCmdRemoveLastElement(FXObject*, FXSelector, void*) {
564 // just call remove last element
566 return 1;
567}
568
569
570void
572 // clear all elements
575 // clear path
576 myPath.clear();
577}
578
579
580void
582 const auto& ACs = myFrameParent->getViewNet()->getNet()->getAttributeCarriers();
583 // first clear path
584 myPath.clear();
585 // continue depending of elements
586 if (myPlanParameteres.consecutiveEdges.size() > 0) {
587 // add every segment
588 for (int i = 1; i < (int)myPlanParameteres.consecutiveEdges.size(); i++) {
590 ACs->retrieveEdge(myPlanParameteres.consecutiveEdges.at(i - 1)),
591 ACs->retrieveEdge(myPlanParameteres.consecutiveEdges.at(i))));
592 }
593 } else {
594 // get from edge
595 GNEEdge* fromEdge = nullptr;
596 if (!myPlanParameteres.fromEdge.empty()) {
597 fromEdge = ACs->retrieveEdge(myPlanParameteres.fromEdge);
598 } else if (!myPlanParameteres.fromBusStop.empty()) {
599 fromEdge = ACs->retrieveAdditional(SUMO_TAG_BUS_STOP, myPlanParameteres.fromBusStop)->getParentLanes().front()->getParentEdge();
600 } else if (!myPlanParameteres.fromTrainStop.empty()) {
601 fromEdge = ACs->retrieveAdditional(SUMO_TAG_TRAIN_STOP, myPlanParameteres.fromTrainStop)->getParentLanes().front()->getParentEdge();
602 } else if (!myPlanParameteres.fromContainerStop.empty()) {
603 fromEdge = ACs->retrieveAdditional(SUMO_TAG_CONTAINER_STOP, myPlanParameteres.fromContainerStop)->getParentLanes().front()->getParentEdge();
604 } else if (!myPlanParameteres.fromChargingStation.empty()) {
605 fromEdge = ACs->retrieveAdditional(SUMO_TAG_CHARGING_STATION, myPlanParameteres.fromChargingStation)->getParentLanes().front()->getParentEdge();
606 } else if (!myPlanParameteres.fromParkingArea.empty()) {
607 fromEdge = ACs->retrieveAdditional(SUMO_TAG_PARKING_AREA, myPlanParameteres.fromParkingArea)->getParentLanes().front()->getParentEdge();
608 }
609 // get to edge
610 GNEEdge* toEdge = nullptr;
611 if (!myPlanParameteres.toEdge.empty()) {
612 toEdge = ACs->retrieveEdge(myPlanParameteres.toEdge);
613 } else if (!myPlanParameteres.toBusStop.empty()) {
614 toEdge = ACs->retrieveAdditional(SUMO_TAG_BUS_STOP, myPlanParameteres.toBusStop)->getParentLanes().front()->getParentEdge();
615 } else if (!myPlanParameteres.toTrainStop.empty()) {
616 toEdge = ACs->retrieveAdditional(SUMO_TAG_TRAIN_STOP, myPlanParameteres.toTrainStop)->getParentLanes().front()->getParentEdge();
617 } else if (!myPlanParameteres.toContainerStop.empty()) {
618 toEdge = ACs->retrieveAdditional(SUMO_TAG_CONTAINER_STOP, myPlanParameteres.toContainerStop)->getParentLanes().front()->getParentEdge();
619 } else if (!myPlanParameteres.toChargingStation.empty()) {
620 toEdge = ACs->retrieveAdditional(SUMO_TAG_CHARGING_STATION, myPlanParameteres.toChargingStation)->getParentLanes().front()->getParentEdge();
621 } else if (!myPlanParameteres.toParkingArea.empty()) {
622 toEdge = ACs->retrieveAdditional(SUMO_TAG_PARKING_AREA, myPlanParameteres.toParkingArea)->getParentLanes().front()->getParentEdge();
623 }
624 // continue depending of edges and junctions
625 if (fromEdge && toEdge) {
626 myPath.push_back(PlanPath(myPathManager, myVClass, fromEdge, toEdge));
627 } else if (fromEdge && !myPlanParameteres.toJunction.empty()) {
628 myPath.push_back(PlanPath(myPathManager, myVClass, fromEdge, ACs->getJunctions().at(myPlanParameteres.toJunction)));
629 } else if (!myPlanParameteres.fromJunction.empty() && toEdge) {
630 myPath.push_back(PlanPath(myPathManager, myVClass, ACs->getJunctions().at(myPlanParameteres.fromJunction), toEdge));
631 } else if (!myPlanParameteres.fromJunction.empty() && !myPlanParameteres.toJunction.empty()) {
633 ACs->getJunctions().at(myPlanParameteres.fromJunction),
634 ACs->getJunctions().at(myPlanParameteres.toJunction)));
635 }
636 }
637}
638
639
640int
644
645
646void
649 if (getNumberOfSelectedElements() == 2) {
651 } else {
653 }
654 } else {
655 if (getNumberOfSelectedElements() > 0) {
657 } else {
659 }
660 }
661}
662
663
664void
670
671
672void
678
679
680void
682 // declare booleans
683 const bool consecutiveEdges = (myPlanParents & CONSECUTIVE_EDGES);
684 const bool route = (myPlanParents & ROUTE);
685 const bool edges = (myPlanParents & EDGE) ||
688 const bool TAZs = (myPlanParents & START_TAZ) ||
690 const bool junctions = (myPlanParents & START_JUNCTION) ||
692 const bool stoppingPlace = (myPlanParents & STOPPINGPLACE) ||
695
696 // declare ostringstream for label and fill it
697 std::ostringstream information;
698 information
699 << TL("Click over:") << "\n"
700 << (consecutiveEdges ? "- Consecutive edges\n" : "")
701 << (route ? "- Routes\n" : "")
702 << (edges ? "- Edges\n" : "")
703 << (TAZs ? "- TAZs\n" : "")
704 << (junctions ? "- Junctions\n" : "")
705 << (stoppingPlace ? "- StoppingPlaces\n" : "");
706 // remove last \n
707 std::string informationStr = information.str();
708 informationStr.pop_back();
709 // set label text
710 myInfoLabel->setText(informationStr.c_str());
711}
712
713
714bool
716 // add edge
718 // set position over lane
719 const auto clickedPos = myFrameParent->getViewNet()->getPositionInformation();
721 // create path
722 return myFrameParent->createPath(false);
723}
724
725
726bool
728 // continue depending of stoppingPlace tag
729 switch (stoppingPlace->getTagProperty().getTag()) {
731 myPlanParameteres.toBusStop = stoppingPlace->getID();
732 break;
734 myPlanParameteres.toTrainStop = stoppingPlace->getID();
735 break;
737 myPlanParameteres.toContainerStop = stoppingPlace->getID();
738 break;
740 myPlanParameteres.toChargingStation = stoppingPlace->getID();
741 break;
743 myPlanParameteres.toParkingArea = stoppingPlace->getID();
744 break;
745 default:
746 // abort creation
747 return false;
748 }
749 // create path
750 return myFrameParent->createPath(false);
751}
752
753
754bool
756 // check double edges
757 if ((myPlanParameteres.consecutiveEdges.size() > 0) && (myPlanParameteres.consecutiveEdges.back() == edge->getID())) {
758 // Write warning
759 WRITE_WARNING(TL("Double edges aren't allowed"));
760 // abort add edge
761 return false;
762 }
763 // All checks ok, then add it in selected elements
764 myPlanParameteres.consecutiveEdges.push_back(edge->getID());
765 // enable abort route button
766 myAbortCreationButton->enable();
767 // enable finish button
768 myFinishCreationButton->enable();
769 // update remove last item button
771 // recalculate path
773 // edge added, then return true
774 return true;
775}
776
777
778bool
780 // avoid double junctions
781 if (myPlanParameteres.fromJunction == junction->getID()) {
782 // Write warning
783 WRITE_WARNING(TL("Double junctions aren't allowed"));
784 // abort add junction
785 return false;
786 }
787 // check number of selected items
788 if (getNumberOfSelectedElements() == 2) {
789 // Write warning
790 WRITE_WARNING(TL("Only two from-to elements are allowed"));
791 // abort add function
792 return false;
793 }
794 // set junction
795 if (getNumberOfSelectedElements() == 0) {
797 } else {
798 myPlanParameteres.toJunction = junction->getID();
799 }
800 // enable abort route button
801 myAbortCreationButton->enable();
802 // enable finish button
803 myFinishCreationButton->enable();
804 // update remove last item button
806 // recalculate path
808 return true;
809}
810
811
812bool
814 // avoid double TAZs
815 if (myPlanParameteres.fromTAZ == TAZ->getID()) {
816 // Write warning
817 WRITE_WARNING(TL("Double TAZs aren't allowed"));
818 // abort add TAZ
819 return false;
820 }
821 // check number of selected items
822 if (getNumberOfSelectedElements() == 2) {
823 // Write warning
824 WRITE_WARNING(TL("Only two from-to elements are allowed"));
825 // abort add function
826 return false;
827 }
828 // set TAZ
829 if (getNumberOfSelectedElements() == 0) {
830 myPlanParameteres.fromTAZ = TAZ->getID();
831 } else {
832 myPlanParameteres.toTAZ = TAZ->getID();
833 }
834 // enable abort route button
835 myAbortCreationButton->enable();
836 // enable finish button
837 myFinishCreationButton->enable();
838 // update remove last item button
840 // recalculate path
842 return true;
843}
844
845
846bool
848 // check double edges
849 if (myPlanParameteres.fromEdge == edge->getID()) {
850 // Write warning
851 WRITE_WARNING(TL("Double edges aren't allowed"));
852 // abort add edge
853 return false;
854 }
855 // check number of selected items
856 if (getNumberOfSelectedElements() == 2) {
857 // Write warning
858 WRITE_WARNING(TL("Only two from-to elements are allowed"));
859 // abort add function
860 return false;
861 }
862 // set edge
863 if (getNumberOfSelectedElements() == 0) {
865 } else {
867 }
868 // enable abort route button
869 myAbortCreationButton->enable();
870 // enable finish button
871 myFinishCreationButton->enable();
872 // update remove last item button
874 // recalculate path
876 // edge added, then return true
877 return true;
878}
879
880
881bool
883 // check double stoppingPlaces
884 const auto stoppingPlaceID = stoppingPlace->getID();
885 if ((myPlanParameteres.toBusStop == stoppingPlaceID) ||
886 (myPlanParameteres.toTrainStop == stoppingPlaceID) ||
887 (myPlanParameteres.toContainerStop == stoppingPlaceID) ||
888 (myPlanParameteres.toChargingStation == stoppingPlaceID) ||
889 (myPlanParameteres.toParkingArea == stoppingPlaceID)) {
890 // Write warning
891 WRITE_WARNING(TL("Double stoppingPlaces aren't allowed"));
892 // abort add stopping place
893 return false;
894 }
895 // check number of selected items
896 if (getNumberOfSelectedElements() == 2) {
897 // Write warning
898 WRITE_WARNING(TL("Only two from-to elements are allowed"));
899 // abort add function
900 return false;
901 }
902 // add stoppingPlace
903 if (getNumberOfSelectedElements() == 0) {
904 // continue depending of stoppingPlace tag
905 switch (stoppingPlace->getTagProperty().getTag()) {
907 myPlanParameteres.fromBusStop = stoppingPlaceID;
908 break;
910 myPlanParameteres.fromTrainStop = stoppingPlaceID;
911 break;
913 myPlanParameteres.fromContainerStop = stoppingPlaceID;
914 break;
916 myPlanParameteres.fromChargingStation = stoppingPlaceID;
917 break;
919 myPlanParameteres.fromParkingArea = stoppingPlaceID;
920 break;
921 default:
922 return false;
923 }
924 } else {
925 // continue depending of stoppingPlace tag
926 switch (stoppingPlace->getTagProperty().getTag()) {
928 myPlanParameteres.toBusStop = stoppingPlaceID;
929 break;
931 myPlanParameteres.toTrainStop = stoppingPlaceID;
932 break;
934 myPlanParameteres.toContainerStop = stoppingPlaceID;
935 break;
937 myPlanParameteres.toChargingStation = stoppingPlaceID;
938 break;
940 myPlanParameteres.toParkingArea = stoppingPlaceID;
941 break;
942 default:
943 return false;
944 }
945 }
946 // enable abort route button
947 myAbortCreationButton->enable();
948 // enable finish button
949 myFinishCreationButton->enable();
950 // disable undo/redo
951 myFrameParent->getViewNet()->getViewParent()->getGNEAppWindows()->disableUndoRedoTemporally("creation of stoppingPlace path");
952 // enable or disable remove last item button
954 // recalculate path
956 // stopping place added, then return true
957 return true;
958}
959
960/****************************************************************************/
FXDEFMAP(GNEPlanCreator) 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
#define GUIDesignButton
Definition GUIDesigns.h:88
#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_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)
std::string fromJunction
from junction
std::string fromContainerStop
from containerStop
int getNumberOfDefinedParameters() const
get number of defined plans
std::string fromTrainStop
from trainStop
std::string toParkingArea
to parkingArea
std::vector< std::string > consecutiveEdges
consecutive edges
std::string fromChargingStation
from chargingStation
std::string toChargingStation
to chargingStation
std::string fromParkingArea
from parkingArea
std::string toContainerStop
to containerStop
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
An Element which don't belong to GNENet but has influence in the simulation.
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
static std::pair< SumoXMLTag, GUIIcon > getPersonTripTagIcon(const CommonXMLStructure::PlanParameters &planParameters)
get the personTrip tag and icon for the combination
static std::pair< SumoXMLTag, GUIIcon > getContainerStopTagIcon(const CommonXMLStructure::PlanParameters &planParameters)
get the container stop tag and icon for the combination
static std::pair< SumoXMLTag, GUIIcon > getRideTagIcon(const CommonXMLStructure::PlanParameters &planParameters)
get the ride tag and icon for the combination
static std::pair< SumoXMLTag, GUIIcon > getPersonStopTagIcon(const CommonXMLStructure::PlanParameters &planParameters)
get the person stop tag and icon for the combination
static std::pair< SumoXMLTag, GUIIcon > getWalkTagIcon(const CommonXMLStructure::PlanParameters &planParameters)
get the walk tag and icon for the combination
static std::pair< SumoXMLTag, GUIIcon > getTranshipTagIcon(const CommonXMLStructure::PlanParameters &planParameters)
get the tranship tag and icon for the combination
static std::pair< SumoXMLTag, GUIIcon > getTransportTagIcon(const CommonXMLStructure::PlanParameters &planParameters)
get the transport tag and icon for the combination
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< GNEJunction * > & getParentJunctions() const
get parent junctions
const std::vector< GNEAdditional * > getParentStoppingPlaces() const
get parent stoppingPlaces (used by plans)
const std::vector< GNEAdditional * > getParentTAZs() const
get parent TAZs (used by plans)
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given toLane
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:214
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:662
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:196
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:127
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:276
double x() const
Returns the x-position.
Definition Position.h:55
double y() const
Returns the y-position.
Definition Position.h:60
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: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)