Eclipse SUMO - Simulation of Urban MObility
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>
25 #include <netedit/GNEViewParent.h>
29 #include <utils/gui/div/GLHelper.h>
32 
33 #include "GNEPlanCreator.h"
34 
35 
36 // ===========================================================================
37 // FOX callback mapping
38 // ===========================================================================
39 
40 FXDEFMAP(GNEPlanCreator) PathCreatorMap[] = {
46 };
47 
48 // Object implementation
49 FXIMPLEMENT(GNEPlanCreator, MFXGroupBoxModule, PathCreatorMap, ARRAYNUMBER(PathCreatorMap))
50 
51 
52 // ===========================================================================
53 // method definitions
54 // ===========================================================================
55 
56 
57 GNEPlanCreator::PlanPath::PlanPath(GNEViewNet* viewNet, const SUMOVehicleClass vClass, GNEEdge* fromEdge, GNEEdge* toEdge) :
58  myConflictVClass(false),
59  myConflictDisconnected(false) {
60  // calculate subpath using given vClass
61  mySubPath = viewNet->getNet()->getPathManager()->getPathCalculator()->calculateDijkstraPath(vClass, fromEdge, toEdge);
62  // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
63  if (mySubPath.empty()) {
64  mySubPath = viewNet->getNet()->getPathManager()->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, fromEdge, toEdge);
65  if (mySubPath.empty()) {
66  mySubPath = {fromEdge, toEdge};
67  myConflictDisconnected = true;
68  } else {
69  myConflictVClass = true;
70  }
71  }
72 }
73 
74 
75 GNEPlanCreator::PlanPath::PlanPath(GNEViewNet* viewNet, const SUMOVehicleClass vClass, GNEEdge* fromEdge, GNEJunction* toJunction) :
76  myConflictVClass(false),
77  myConflictDisconnected(false) {
78  // calculate subpath using given vClass
79  mySubPath = viewNet->getNet()->getPathManager()->getPathCalculator()->calculateDijkstraPath(vClass, fromEdge, toJunction);
80  // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
81  if (mySubPath.empty()) {
82  mySubPath = viewNet->getNet()->getPathManager()->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, fromEdge, toJunction);
83  if (mySubPath.empty()) {
84  mySubPath = {fromEdge};
86  } else {
87  myConflictVClass = true;
88  }
89  }
90 
91 }
92 
93 
94 GNEPlanCreator::PlanPath::PlanPath(GNEViewNet* viewNet, const SUMOVehicleClass vClass, GNEJunction* fromJunction, GNEEdge* toEdge) :
95  myConflictVClass(false),
96  myConflictDisconnected(false) {
97  // calculate subpath using given vClass
98  mySubPath = viewNet->getNet()->getPathManager()->getPathCalculator()->calculateDijkstraPath(vClass, fromJunction, toEdge);
99  // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
100  if (mySubPath.empty()) {
101  mySubPath = viewNet->getNet()->getPathManager()->getPathCalculator()->calculateDijkstraPath(SVC_PEDESTRIAN, fromJunction, toEdge);
102  if (mySubPath.empty()) {
103  mySubPath = {toEdge};
104  myConflictDisconnected = true;
105  } else {
106  myConflictVClass = true;
107  }
108  }
109 
110 }
111 
112 
113 GNEPlanCreator::PlanPath::PlanPath(GNEViewNet* viewNet, const SUMOVehicleClass vClass, GNEJunction* fromJunction, GNEJunction* toJunction) :
114  myConflictVClass(false),
115  myConflictDisconnected(false) {
116  // calculate subpath using the given vClass
117  mySubPath = viewNet->getNet()->getPathManager()->getPathCalculator()->calculateDijkstraPath(vClass, fromJunction, toJunction);
118  // if subPath is empty, try it with pedestrian (i.e. ignoring vCass)
119  if (mySubPath.empty()) {
120  if (mySubPath.empty()) {
121  myConflictDisconnected = true;
122  } else {
123  myConflictVClass = true;
124  }
125  }
126 
127 }
128 
129 
130 const std::vector<GNEEdge*>&
132  return mySubPath;
133 }
134 
135 
136 bool
138  return myConflictVClass;
139 }
140 
141 
142 bool
144  return myConflictDisconnected;
145 }
146 
147 
149  myConflictVClass(false),
150  myConflictDisconnected(false) {
151 }
152 
153 
155  MFXGroupBoxModule(frameParent, TL("Route creator")),
156  myFrameParent(frameParent),
158  myPlanParents(0) {
159  // create button for use last route
161  myUseLastRoute->disable();
162  // create button for finish route creation
164  myFinishCreationButton->disable();
165  // create button for abort route creation
167  myAbortCreationButton->disable();
168  // create button for remove last inserted edge
170  myRemoveLastInsertedElement->disable();
171  // create info label
172  myInfoLabel = new FXLabel(this, "", 0, GUIDesignLabelFrameInformation);
173 }
174 
175 
177 
178 
179 bool
181  if (planTemplate == nullptr) {
182  return false;
183  } else if (planTemplate->getTagProperty().isPersonTrip()) {
185  getFromEdge(), getToEdge(),
186  getFromTAZ(), getToTAZ(),
190  } else if (planTemplate->getTagProperty().isPlanWalk()) {
193  getFromEdge(), getToEdge(),
194  getFromTAZ(), getToTAZ(),
198  } else if (planTemplate->getTagProperty().isPlanRide()) {
200  getFromEdge(), getToEdge(),
203  } else if (planTemplate->getTagProperty().isPlanTransport()) {
205  getFromEdge(), getToEdge(),
207  } else if (planTemplate->getTagProperty().isPlanTranship()) {
210  getFromEdge(), getToEdge(),
212  } else if (planTemplate->getTagProperty().isPlanStopPerson()) {
215  } else if (planTemplate->getTagProperty().isPlanStopContainer()) {
218  } else {
219  return false;
220  }
221 }
222 
223 
224 void
225 GNEPlanCreator::showPlanCreatorModule(const GNEPlanSelector* planSelector, const GNEDemandElement* previousPlan) {
226  // first abort creation
228  // hide creation buttons
230  // reset plan parents
231  myPlanParents = 0;
232  // set previous plan element
233  myPreviousPlanElement = previousPlan;
234  // get current plan template
235  const auto& planTagProperties = planSelector->getCurrentPlanTagProperties();
236  // continue depending of plan selector template
237  if (planTagProperties.planRoute()) {
238  myPlanParents |= ROUTE;
239  // show use last inserted route
240  myUseLastRoute->show();
241  } else {
242  // hide use last inserted route
243  myUseLastRoute->hide();
244  }
245  if (planTagProperties.planEdge()) {
246  myPlanParents |= EDGE;
247  }
248  if (planTagProperties.planBusStop()) {
250  }
251  if (planTagProperties.planTrainStop()) {
253  }
254  if (planTagProperties.planContainerStop()) {
256  }
257  if (planTagProperties.planConsecutiveEdges()) {
259  // show creation buttons
261  }
262  if (planTagProperties.planFromEdge() || planTagProperties.planToEdge()) {
265  // show creation buttons
267  }
268  if (planTagProperties.planFromJunction() || planTagProperties.planToJunction()) {
271  // show creation buttons
273  }
274  if (planTagProperties.planFromTAZ() || planTagProperties.planToTAZ()) {
277  // show creation buttons
279  }
280  if (planTagProperties.planFromBusStop() || planTagProperties.planToBusStop()) {
283  // show creation buttons
285  }
286  if (planTagProperties.planFromTrainStop() || planTagProperties.planToTrainStop()) {
289  // show creation buttons
291  }
292  if (planTagProperties.planFromContainerStop() || planTagProperties.planToContainerStop()) {
295  // show creation buttons
297  }
298  // update info label (after setting myPlanParents)
299  updateInfoLabel();
300  // check if add first element
301  if (myPreviousPlanElement && planTagProperties.planFromTo()) {
302  const auto previousTagProperty = myPreviousPlanElement->getTagProperty();
303  // add last element of previous plan
304  if (previousTagProperty.planToEdge() || previousTagProperty.planEdge()) {
306  } else if (previousTagProperty.planToJunction()) {
308  } else if (previousTagProperty.planToTAZ()) {
310  } else if (previousTagProperty.planToStoppingPlace() || previousTagProperty.planStoppingPlace()) {
312  }
313  }
314  // set vClass
315  if (planTagProperties.isPlanRide() || planTagProperties.isPlanContainer()) {
317  } else {
319  }
320  // recalc before show (to avoid graphic problems)
321  recalc();
322  // show modul
323  show();
324 }
325 
326 
327 void
329  // clear path
330  clearPath();
331  // hide modul
332  hide();
333 }
334 
335 
336 bool
338  // check if routes are allowed
339  if ((myPlanParents & ROUTE) == 0) {
340  return false;
341  }
342  // add edge
343  myRoute = route;
344  // create path
345  return myFrameParent->createPath(false);
346 }
347 
348 
349 bool
351  // continue depending of plan parent
353  return addConsecutiveEdge(lane->getParentEdge());
354  } else if (myPlanParents & EDGE) {
355  return addSingleEdge(lane);
356  } else if ((myPlanParents & START_EDGE) || (myPlanParents & END_EDGE)) {
357  return addFromToEdge(lane->getParentEdge());
358  } else {
359  return false;
360  }
361 }
362 
363 
364 bool
367  return addFromToJunction(junction);
368  } else {
369  return false;
370  }
371 }
372 
373 
374 bool
376  if ((myPlanParents & START_TAZ) || (myPlanParents & END_TAZ)) {
377  return addFromToTAZ(taz);
378  } else {
379  return false;
380  }
381 }
382 
383 
384 bool
386  // get stoppingPlace tag
387  auto stoppingPlaceTag = stoppingPlace->getTagProperty().getTag();
388  if ((stoppingPlaceTag == SUMO_TAG_BUS_STOP) && (myPlanParents & BUSSTOP)) {
389  return addSingleStoppingPlace(stoppingPlace);
390  } else if ((stoppingPlaceTag == SUMO_TAG_BUS_STOP) && ((myPlanParents & START_BUSSTOP) || (myPlanParents & END_BUSSTOP))) {
391  return addFromToStoppingPlace(stoppingPlace);
392  } else if ((stoppingPlaceTag == SUMO_TAG_TRAIN_STOP) && (myPlanParents & TRAINSTOP)) {
393  return addSingleStoppingPlace(stoppingPlace);
394  } else if ((stoppingPlaceTag == SUMO_TAG_TRAIN_STOP) && ((myPlanParents & START_TRAINSTOP) || (myPlanParents & END_TRAINSTOP))) {
395  return addFromToStoppingPlace(stoppingPlace);
396  } else if ((stoppingPlaceTag == SUMO_TAG_CONTAINER_STOP) && (myPlanParents & CONTAINERSTOP)) {
397  return addSingleStoppingPlace(stoppingPlace);
398  } else if ((stoppingPlaceTag == SUMO_TAG_CONTAINER_STOP) && ((myPlanParents & START_CONTAINERSTOP) || (myPlanParents & END_CONTAINERSTOP))) {
399  return addFromToStoppingPlace(stoppingPlace);
400  } else {
401  return false;
402  }
403 }
404 
405 
406 const std::vector<GNEEdge*>
408  return myConsecutiveEdges;
409 }
410 
411 
412 const std::vector<std::string>
414  std::vector<std::string> edgeIDs;
415  for (const auto& edge : myConsecutiveEdges) {
416  edgeIDs.push_back(edge->getID());
417  }
418  return edgeIDs;
419 }
420 
421 
422 GNEEdge*
424  return myFromEdge;
425 }
426 
427 
428 GNEEdge*
430  return myToEdge;
431 }
432 
433 
436  return myFromJunction;
437 }
438 
439 
442  return myToJunction;
443 }
444 
445 
448  return myFromTAZ;
449 }
450 
451 
454  return myToTAZ;
455 }
456 
457 
461  return myFromStoppingPlace;
462  } else {
463  return nullptr;
464  }
465 }
466 
467 
471  return myToStoppingPlace;
472  } else {
473  return nullptr;
474  }
475 }
476 
477 
481  return myFromStoppingPlace;
482  } else {
483  return nullptr;
484  }
485 }
486 
487 
491  return myToStoppingPlace;
492  } else {
493  return nullptr;
494  }
495 }
496 
497 
501  return myFromStoppingPlace;
502  } else {
503  return nullptr;
504  }
505 }
506 
507 
511  return myToStoppingPlace;
512  } else {
513  return nullptr;
514  }
515 }
516 
517 
520  return myRoute;
521 }
522 
523 
524 GNEEdge*
526  return myEdge;
527 }
528 
529 
533  return myStoppingPlace;
534  } else {
535  return nullptr;
536  }
537 }
538 
539 
543  return myStoppingPlace;
544  } else {
545  return nullptr;
546  }
547 }
548 
549 
553  return myStoppingPlace;
554  } else {
555  return nullptr;
556  }
557 }
558 
559 
560 double
563 }
564 
565 
566 const std::vector<GNEPlanCreator::PlanPath>&
568  return myPath;
569 }
570 
571 
572 void
574  const double lineWidth = 0.35;
575  const double lineWidthin = 0.25;
576  // Add a draw matrix
578  // Start with the drawing of the area traslating matrix to origin
579  glTranslated(0, 0, GLO_MAX - 0.1);
580  // check if draw bewteen junction or edges
581  if (myPath.size() > 0) {
582  // set first color
584  // iterate over path
585  for (int i = 0; i < (int)myPath.size(); i++) {
586  // get path
587  const GNEPlanCreator::PlanPath& path = myPath.at(i);
588  // draw line over
589  for (int j = 0; j < (int)path.getSubPath().size(); j++) {
590  const GNELane* lane = path.getSubPath().at(j)->getLanes().back();
591  if (((i == 0) && (j == 0)) || (j > 0)) {
592  GLHelper::drawBoxLines(lane->getLaneShape(), lineWidth);
593  }
594  // draw connection between lanes
595  if ((j + 1) < (int)path.getSubPath().size()) {
596  const GNELane* nextLane = path.getSubPath().at(j + 1)->getLanes().back();
597  if (lane->getLane2laneConnections().exist(nextLane)) {
599  } else {
600  GLHelper::drawBoxLines({lane->getLaneShape().back(), nextLane->getLaneShape().front()}, lineWidth);
601  }
602  }
603  }
604  }
605  glTranslated(0, 0, 0.1);
606  // iterate over path again
607  for (int i = 0; i < (int)myPath.size(); i++) {
608  // get path
609  const GNEPlanCreator::PlanPath& path = myPath.at(i);
610  // set path color color
611  if (path.isConflictDisconnected()) {
613  } else if (path.isConflictVClass()) {
615  } else {
617  }
618  // draw line over
619  for (int j = 0; j < (int)path.getSubPath().size(); j++) {
620  const GNELane* lane = path.getSubPath().at(j)->getLanes().back();
621  if (((i == 0) && (j == 0)) || (j > 0)) {
622  GLHelper::drawBoxLines(lane->getLaneShape(), lineWidthin);
623  }
624  // draw connection between lanes
625  if ((j + 1) < (int)path.getSubPath().size()) {
626  const GNELane* nextLane = path.getSubPath().at(j + 1)->getLanes().back();
627  if (lane->getLane2laneConnections().exist(nextLane)) {
629  } else {
630  GLHelper::drawBoxLines({ lane->getLaneShape().back(), nextLane->getLaneShape().front() }, lineWidthin);
631  }
632  }
633  }
634  }
635  } else if (myFromJunction && myToJunction) {
636  // set color
638  // get two points
639  const Position posA = myFromJunction->getPositionInView();
640  const Position posB = myToJunction->getPositionInView();
641  const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) 180.0 / (double)M_PI);
642  const double len = posA.distanceTo2D(posB);
643  // draw line
644  GLHelper::drawBoxLine(posA, rot, len, 0.25);
645  } else if (myFromTAZ && myToTAZ) {
646  // set color
648  // get two points
649  const Position posA = myFromTAZ->getPositionInView();
650  const Position posB = myToTAZ->getPositionInView();
651  const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) 180.0 / (double)M_PI);
652  const double len = posA.distanceTo2D(posB);
653  // draw line
654  GLHelper::drawBoxLine(posA, rot, len, 0.25);
655  }
656  // Pop last matrix
658 }
659 
660 
661 void
663  // first check that there is elements
664  if (getNumberOfSelectedElements() > 0) {
665  // unblock undo/redo
667  // clear edges
668  clearPath();
669  // disable buttons
670  myFinishCreationButton->disable();
671  myAbortCreationButton->disable();
672  myRemoveLastInsertedElement->disable();
673  // update view (to see the new route)
675  }
676 }
677 
678 
679 void
681  if (myRemoveLastInsertedElement->isEnabled()) {
682  if (myConsecutiveEdges.size() > 0) {
683  myConsecutiveEdges.pop_back();
684  } else if (myToEdge) {
685  myToEdge = nullptr;
686  } else if (myToJunction) {
687  myToJunction = nullptr;
688  } else if (myToTAZ) {
689  myToTAZ = nullptr;
690  } else if (myToStoppingPlace) {
691  myToStoppingPlace = nullptr;
692  } else if (myFromEdge) {
693  myFromEdge = nullptr;
694  } else if (myFromJunction) {
695  myFromJunction = nullptr;
696  } else if (myFromTAZ) {
697  myFromTAZ = nullptr;
698  } else if (myFromStoppingPlace) {
699  myFromStoppingPlace = nullptr;
700  }
701  // update remove last item button
703  // recalculate path
704  recalculatePath();
705  }
706 }
707 
708 
709 long
710 GNEPlanCreator::onCmdCreatePath(FXObject*, FXSelector, void*) {
711  // call create path
712  return myFrameParent->createPath(false);
713 }
714 
715 
716 long
717 GNEPlanCreator::onCmdUseLastRoute(FXObject*, FXSelector, void*) {
718  // call create path using last route
719  return myFrameParent->createPath(true);
720 }
721 
722 
723 long
724 GNEPlanCreator::onUpdUseLastRoute(FXObject* sender, FXSelector, void*) {
726  return sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
727  } else {
728  return sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), nullptr);
729  }
730 }
731 
732 long
733 GNEPlanCreator::onCmdAbortPathCreation(FXObject*, FXSelector, void*) {
734  // just call abort path creation
736  return 1;
737 }
738 
739 
740 long
741 GNEPlanCreator::onCmdRemoveLastElement(FXObject*, FXSelector, void*) {
742  // just call remove last element
744  return 1;
745 }
746 
747 
748 void
750  // clear all elements
751  myConsecutiveEdges.clear();
752  myFromEdge = nullptr;
753  myToEdge = nullptr;
754  myFromJunction = nullptr;
755  myToJunction = nullptr;
756  myFromTAZ = nullptr;
757  myToTAZ = nullptr;
758  myFromStoppingPlace = nullptr;
759  myToStoppingPlace = nullptr;
760  myStoppingPlace = nullptr;
761  myEdge = nullptr;
762  myRoute = nullptr;
764  // clear path
765  myPath.clear();
766 }
767 
768 
769 void
771  // first clear path
772  myPath.clear();
773  // continue depending of elements
774  if (myConsecutiveEdges.size() > 0) {
775  // add every segment
776  for (int i = 1; i < (int)myConsecutiveEdges.size(); i++) {
778  }
779  } else {
780  // get from edge
781  GNEEdge* fromEdge = nullptr;
782  if (myFromEdge) {
783  fromEdge = myFromEdge;
784  } else if (myFromStoppingPlace) {
785  fromEdge = myFromStoppingPlace->getParentLanes().front()->getParentEdge();
786  }
787  // get to edge
788  GNEEdge* toEdge = nullptr;
789  if (myToEdge) {
790  toEdge = myToEdge;
791  } else if (myToStoppingPlace) {
792  toEdge = myToStoppingPlace->getParentLanes().front()->getParentEdge();
793  }
794  // continue depending of edges and junctions
795  if (fromEdge && toEdge) {
796  myPath.push_back(PlanPath(myFrameParent->getViewNet(), myVClass, fromEdge, toEdge));
797  } else if (fromEdge && myToJunction) {
798  myPath.push_back(PlanPath(myFrameParent->getViewNet(), myVClass, fromEdge, myToJunction));
799  } else if (myFromJunction && toEdge) {
801  } else if (myFromJunction && myToJunction) {
803  }
804  }
805 }
806 
807 
808 int
810  return (int)myConsecutiveEdges.size() +
811  (myFromEdge != nullptr ? 1 : 0) +
812  (myToEdge != nullptr ? 1 : 0) +
813  (myFromJunction != nullptr ? 1 : 0) +
814  (myToJunction != nullptr ? 1 : 0) +
815  (myFromTAZ != nullptr ? 1 : 0) +
816  (myToTAZ != nullptr ? 1 : 0) +
817  (myFromStoppingPlace != nullptr ? 1 : 0) +
818  (myToStoppingPlace != nullptr ? 1 : 0);
819 }
820 
821 
822 void
824  if (myPreviousPlanElement) {
825  if (getNumberOfSelectedElements() == 2) {
826  myRemoveLastInsertedElement->enable();
827  } else {
828  myRemoveLastInsertedElement->disable();
829  }
830  } else {
831  if (getNumberOfSelectedElements() > 0) {
832  myRemoveLastInsertedElement->enable();
833  } else {
834  myRemoveLastInsertedElement->disable();
835  }
836  }
837 }
838 
839 
840 void
842  myFinishCreationButton->show();
843  myAbortCreationButton->show();
845 }
846 
847 
848 void
850  myFinishCreationButton->hide();
851  myAbortCreationButton->hide();
853 }
854 
855 
856 void
858  // declare booleans
859  const bool consecutiveEdges = (myPlanParents & CONSECUTIVE_EDGES);
860  const bool route = (myPlanParents & ROUTE);
861  const bool edges = (myPlanParents & EDGE) ||
864  const bool TAZs = (myPlanParents & START_TAZ) ||
866  const bool junctions = (myPlanParents & START_JUNCTION) ||
868  const bool busStops = (myPlanParents & BUSSTOP) ||
871  const bool trainStops = (myPlanParents & TRAINSTOP) ||
874  const bool containerStops = (myPlanParents & CONTAINERSTOP) ||
877 
878  // declare ostringstream for label and fill it
879  std::ostringstream information;
880  information
881  << TL("Click over:") << "\n"
882  << (consecutiveEdges ? "- Consecutive edges\n" : "")
883  << (route ? "- Routes\n" : "")
884  << (edges ? "- Edges\n" : "")
885  << (TAZs ? "- TAZs\n" : "")
886  << (junctions ? "- Junctions\n" : "")
887  << (busStops ? "- BusStops\n" : "")
888  << (trainStops ? "- TrainStops\n" : "")
889  << (containerStops ? "- ContainerStops\n" : "");
890  // remove last \n
891  std::string informationStr = information.str();
892  informationStr.pop_back();
893  // set label text
894  myInfoLabel->setText(informationStr.c_str());
895 }
896 
897 
898 bool
900  // add edge
901  myEdge = lane->getParentEdge();
902  // set position over lane
903  const auto clickedPos = myFrameParent->getViewNet()->getPositionInformation();
905  // create path
906  return myFrameParent->createPath(false);
907 }
908 
909 
910 bool
912  // add edge
913  myStoppingPlace = stoppingPlace;
914  // create path
915  return myFrameParent->createPath(false);
916 }
917 
918 
919 bool
921  // check double edges
922  if ((myConsecutiveEdges.size() > 0) && (myConsecutiveEdges.back() == edge)) {
923  // Write warning
924  WRITE_WARNING(TL("Double edges aren't allowed"));
925  // abort add edge
926  return false;
927  }
928  // All checks ok, then add it in selected elements
929  myConsecutiveEdges.push_back(edge);
930  // enable abort route button
931  myAbortCreationButton->enable();
932  // enable finish button
933  myFinishCreationButton->enable();
934  // update remove last item button
936  // recalculate path
937  recalculatePath();
938  // edge added, then return true
939  return true;
940 }
941 
942 
943 bool
945  // avoid double junctions
946  if (myFromJunction && (myFromJunction == junction)) {
947  // Write warning
948  WRITE_WARNING(TL("Double junctions aren't allowed"));
949  // abort add junction
950  return false;
951  }
952  // check number of selected items
953  if (getNumberOfSelectedElements() == 2) {
954  // Write warning
955  WRITE_WARNING(TL("Only two from-to elements are allowed"));
956  // abort add function
957  return false;
958  }
959  // set junction
960  if (getNumberOfSelectedElements() == 0) {
961  myFromJunction = junction;
962  } else {
963  myToJunction = junction;
964  }
965  // enable abort route button
966  myAbortCreationButton->enable();
967  // enable finish button
968  myFinishCreationButton->enable();
969  // update remove last item button
971  // recalculate path
972  recalculatePath();
973  return true;
974 }
975 
976 
977 bool
979  // avoid double TAZs
980  if (myFromTAZ && (myFromTAZ == TAZ)) {
981  // Write warning
982  WRITE_WARNING(TL("Double TAZs aren't allowed"));
983  // abort add TAZ
984  return false;
985  }
986  // check number of selected items
987  if (getNumberOfSelectedElements() == 2) {
988  // Write warning
989  WRITE_WARNING(TL("Only two from-to elements are allowed"));
990  // abort add function
991  return false;
992  }
993  // set TAZ
994  if (getNumberOfSelectedElements() == 0) {
995  myFromTAZ = TAZ;
996  } else {
997  myToTAZ = TAZ;
998  }
999  // enable abort route button
1000  myAbortCreationButton->enable();
1001  // enable finish button
1002  myFinishCreationButton->enable();
1003  // update remove last item button
1005  // recalculate path
1006  recalculatePath();
1007  return true;
1008 }
1009 
1010 
1011 bool
1013  // check double edges
1014  if (myFromEdge && (myFromEdge == edge)) {
1015  // Write warning
1016  WRITE_WARNING(TL("Double edges aren't allowed"));
1017  // abort add edge
1018  return false;
1019  }
1020  // check number of selected items
1021  if (getNumberOfSelectedElements() == 2) {
1022  // Write warning
1023  WRITE_WARNING(TL("Only two from-to elements are allowed"));
1024  // abort add function
1025  return false;
1026  }
1027  // set edge
1028  if (getNumberOfSelectedElements() == 0) {
1029  myFromEdge = edge;
1030  } else {
1031  myToEdge = edge;
1032  }
1033  // enable abort route button
1034  myAbortCreationButton->enable();
1035  // enable finish button
1036  myFinishCreationButton->enable();
1037  // update remove last item button
1039  // recalculate path
1040  recalculatePath();
1041  // edge added, then return true
1042  return true;
1043 }
1044 
1045 
1046 bool
1048  // check double stoppingPlaces
1049  if (myFromStoppingPlace && (myFromStoppingPlace == stoppingPlace)) {
1050  // Write warning
1051  WRITE_WARNING(TL("Double stoppingPlaces aren't allowed"));
1052  // abort add stopping place
1053  return false;
1054  }
1055  // check number of selected items
1056  if (getNumberOfSelectedElements() == 2) {
1057  // Write warning
1058  WRITE_WARNING(TL("Only two from-to elements are allowed"));
1059  // abort add function
1060  return false;
1061  }
1062  // add stoppingPlace
1063  if (getNumberOfSelectedElements() == 0) {
1064  myFromStoppingPlace = stoppingPlace;
1065  } else {
1066  myToStoppingPlace = stoppingPlace;
1067  }
1068  // enable abort route button
1069  myAbortCreationButton->enable();
1070  // enable finish button
1071  myFinishCreationButton->enable();
1072  // disable undo/redo
1074  // enable or disable remove last stoppingPlace button
1075  if (getNumberOfSelectedElements() == 1) {
1076  myRemoveLastInsertedElement->enable();
1077  } else {
1078  myRemoveLastInsertedElement->disable();
1079  }
1080  // recalculate path
1081  recalculatePath();
1082  // stopping place added, then return true
1083  return true;
1084 }
1085 
1086 /****************************************************************************/
FXDEFMAP(GNEPlanCreator) PathCreatorMap[]
@ MID_GNE_PATHCREATOR_FINISH
finish edge path creation
Definition: GUIAppEnum.h:980
@ MID_GNE_PATHCREATOR_REMOVELAST
remove last inserted element in path
Definition: GUIAppEnum.h:984
@ MID_GNE_PATHCREATOR_USELASTROUTE
use last inserted route
Definition: GUIAppEnum.h:982
@ MID_GNE_PATHCREATOR_ABORT
abort edge path creation
Definition: GUIAppEnum.h:978
#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_NOTHING
invalid tag
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:655
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.
Definition: GNEAdditional.h:49
virtual Position getPositionInView() const =0
Returns position of additional in view.
void disableUndoRedo(const std::string &reason)
disable undo-redo giving a string with the reason
void enableUndoRedo()
disable undo-redo
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
static std::pair< SumoXMLTag, GUIIcon > getPersonStopTagIcon(const GNEEdge *edge, const GNEAdditional *busStop, const GNEAdditional *trainStop)
get the person stop tag and icon for the combination
static std::pair< SumoXMLTag, GUIIcon > getPersonTripTagIcon(const GNEEdge *fromEdge, const GNEEdge *toEdge, const GNEAdditional *fromTAZ, const GNEAdditional *toTAZ, const GNEJunction *fromJunction, const GNEJunction *toJunction, const GNEAdditional *fromBusStop, const GNEAdditional *toBusStop, const GNEAdditional *fromTrainStop, const GNEAdditional *toTrainStop)
get the personTrip tag and icon for the combination
static std::pair< SumoXMLTag, GUIIcon > getRideTagIcon(const GNEEdge *fromEdge, const GNEEdge *toEdge, const GNEAdditional *fromBusStop, const GNEAdditional *toBusStop, const GNEAdditional *fromTrainStop, const GNEAdditional *toTrainStop)
get the ride tag and icon for the combination
static std::pair< SumoXMLTag, GUIIcon > getContainerStopTagIcon(const GNEEdge *edge, const GNEAdditional *containerStop)
get the container stop tag and icon for the combination
static std::pair< SumoXMLTag, GUIIcon > getTransportTagIcon(const GNEEdge *fromEdge, const GNEEdge *toEdge, const GNEAdditional *fromContainerStop, const GNEAdditional *toContainerStop)
get the transport tag and icon for the combination
static std::pair< SumoXMLTag, GUIIcon > getTranshipTagIcon(const std::vector< GNEEdge * > &consecutiveEdges, const GNEEdge *fromEdge, const GNEEdge *toEdge, const GNEAdditional *fromContainerStop, const GNEAdditional *toContainerStop)
get the tranship tag and icon for the combination
static std::pair< SumoXMLTag, GUIIcon > getWalkTagIcon(const std::vector< GNEEdge * > &consecutiveEdges, const GNEDemandElement *route, const GNEEdge *fromEdge, const GNEEdge *toEdge, const GNEAdditional *fromTAZ, const GNEAdditional *toTAZ, const GNEJunction *fromJunction, const GNEJunction *toJunction, const GNEAdditional *fromBusStop, const GNEAdditional *toBusStop, const GNEAdditional *fromTrainStop, const GNEAdditional *toTrainStop)
get the walk 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 * > & getParentAdditionals() const
get parent additionals
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
Position getPositionInView() const
Returns position of hierarchical element in view.
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:684
GNEEdge * getParentEdge() const
get parent edge
Definition: GNELane.cpp:196
GNEPathManager * getPathManager()
get path manager
Definition: GNENet.cpp:133
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
GNEDemandElement * myRoute
route
void removeLastElement()
remove path element
bool addRoute(GNEDemandElement *route)
add route
GNEEdge * myEdge
ege
GNEAdditional * getFromContainerStop() const
get from container stop
double myClickedPositionOverLane
clicked position over lane
GNEAdditional * myFromTAZ
from TAZ
GNEJunction * getFromJunction() const
get from junction
const GNEDemandElement * myPreviousPlanElement
previous person plan element
double getClickedPositionOverLane() const
get clicked position over lane
const std::vector< std::string > getConsecutiveEdgeIDs() const
get consecutive edge IDs
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
GNEJunction * myFromJunction
from junction
GNEFrame * myFrameParent
current frame parent
int myPlanParents
allowed plan parents
void hidePathCreatorModule()
show GNEPlanCreator
long onCmdCreatePath(FXObject *, FXSelector, void *)
void showCreationButtons()
show creation buttons
GNEEdge * getToEdge() const
get to edge
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
GNEEdge * myToEdge
to edge
GNEAdditional * getTrainStop() const
get trainStop
GNEAdditional * getFromTAZ() const
get from TAZ
int getNumberOfSelectedElements() const
get number of selected elements
void recalculatePath()
recalculate path
bool addEdge(GNELane *lane)
add edge (clicking over lanes)
GNEAdditional * myToStoppingPlace
to StoppingPlace
SUMOVehicleClass myVClass
current vClass
bool addFromToEdge(GNEEdge *edge)
add from to edge
~GNEPlanCreator()
destructor
GNEAdditional * myFromStoppingPlace
from StoppingPlace
GNEAdditional * getFromTrainStop() const
get from train stop
FXButton * myAbortCreationButton
button for abort route creation
GNEAdditional * getToContainerStop() const
get to container stop
GNEAdditional * getFromBusStop() const
get from bus stop
GNEAdditional * getToTAZ() const
get to TAZ
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
GNEEdge * myFromEdge
from edge
const std::vector< GNEEdge * > getConsecutiveEdges() const
get consecutive edge
GNEDemandElement * getRoute() const
get route
GNEEdge * getFromEdge() const
get from edge
void drawTemporalRoute(const GUIVisualizationSettings &s) const
draw temporal route
bool addFromToTAZ(GNEAdditional *taz)
add TAZ
GNEAdditional * myStoppingPlace
stoppingPlace
long onCmdRemoveLastElement(FXObject *, FXSelector, void *)
Called when the user click over button "Remove las inserted edge".
FXButton * myRemoveLastInsertedElement
button for removing last inserted element
GNEAdditional * getBusStop() const
get busStop
std::vector< PlanPath > myPath
vector with current path
const std::vector< PlanPath > & getPath() const
get path route
GNEPlanCreator(GNEFrame *frameParent)
default constructor
GNEAdditional * getContainerStop() const
get containerStop
FXButton * myUseLastRoute
button for use last inserted route
bool addFromToStoppingPlace(GNEAdditional *stoppingPlace)
add from to stoppingPlace
GNEEdge * getEdge() const
get edge
GNEJunction * getToJunction() const
get to junction
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
GNEAdditional * getToTrainStop() const
get to train stop
GNEAdditional * getToBusStop() const
get to bus stop
void updateInfoLabel()
update info label
GNEJunction * myToJunction
to junction
std::vector< GNEEdge * > myConsecutiveEdges
vector with consecutive edges
bool addSingleStoppingPlace(GNEAdditional *stoppingPlace)
add stoppingPlace
GNEAdditional * myToTAZ
to TAZ
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
bool isPersonTrip() const
return true if tag correspond to a person trip
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
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
Mark the entire GNEViewNet to be repainted later.
Definition: GNEViewNet.cpp:410
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
Definition: GUIDesigns.cpp:128
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:271
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)