Skip to content

Commit 90326aa

Browse files
committed
Fixed #16963
1 parent c3f50d2 commit 90326aa

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

src/netedit/GNEViewParent.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ GNEViewParent::onCmdLocate(FXObject*, FXSelector sel, void*) {
511511
// check that viewNet exist
512512
if (viewNet) {
513513
// declare a vector in which save attribute carriers to locate
514-
std::vector<GNEAttributeCarrier*> ACsToLocate;
514+
std::map<std::string, GNEAttributeCarrier*> ACsToLocate;
515515
int messageId = FXSELID(sel);
516516
GNEDialogACChooser** chooserLoc = nullptr;
517517
std::string locateTitle;
@@ -520,21 +520,21 @@ GNEViewParent::onCmdLocate(FXObject*, FXSelector sel, void*) {
520520
chooserLoc = &myACChoosers.ACChooserJunction;
521521
locateTitle = TL("Junction Chooser");
522522
for (const auto& junction : viewNet->getNet()->getAttributeCarriers()->getJunctions()) {
523-
ACsToLocate.push_back(junction.second);
523+
ACsToLocate[junction.second->getID()] = junction.second;
524524
}
525525
break;
526526
case MID_HOTKEY_SHIFT_E_LOCATEEDGE:
527527
chooserLoc = &myACChoosers.ACChooserEdges;
528528
locateTitle = TL("Edge Chooser");
529529
for (const auto& edge : viewNet->getNet()->getAttributeCarriers()->getEdges()) {
530-
ACsToLocate.push_back(edge.second);
530+
ACsToLocate[edge.second->getID()] = edge.second;
531531
}
532532
break;
533533
case MID_HOTKEY_SHIFT_W_LOCATEWALKINGAREA:
534534
chooserLoc = &myACChoosers.ACChooserWalkingAreas;
535535
locateTitle = TL("WalkingArea Chooser");
536536
for (const auto& walkingArea : viewNet->getNet()->getAttributeCarriers()->getWalkingAreas()) {
537-
ACsToLocate.push_back(walkingArea.second);
537+
ACsToLocate[walkingArea.second->getID()] = walkingArea.second;
538538
}
539539
break;
540540
case MID_HOTKEY_SHIFT_V_LOCATEVEHICLE: {
@@ -543,7 +543,7 @@ GNEViewParent::onCmdLocate(FXObject*, FXSelector sel, void*) {
543543
// fill ACsToLocate with all vehicles
544544
for (const auto& vehicleTag : NamespaceIDs::vehicles) {
545545
for (const auto& vehicle : viewNet->getNet()->getAttributeCarriers()->getDemandElements().at(vehicleTag)) {
546-
ACsToLocate.push_back(vehicle.second);
546+
ACsToLocate[vehicle.second->getID()] = vehicle.second;
547547
}
548548
}
549549
break;
@@ -554,7 +554,7 @@ GNEViewParent::onCmdLocate(FXObject*, FXSelector sel, void*) {
554554
// fill ACsToLocate with all persons
555555
for (const auto& personTag : NamespaceIDs::persons) {
556556
for (const auto& person : viewNet->getNet()->getAttributeCarriers()->getDemandElements().at(personTag)) {
557-
ACsToLocate.push_back(person.second);
557+
ACsToLocate[person.second->getID()] = person.second;
558558
}
559559
}
560560
break;
@@ -564,15 +564,15 @@ GNEViewParent::onCmdLocate(FXObject*, FXSelector sel, void*) {
564564
// fill ACsToLocate with all containers
565565
for (const auto& containerTag : NamespaceIDs::containers) {
566566
for (const auto& container : viewNet->getNet()->getAttributeCarriers()->getDemandElements().at(containerTag)) {
567-
ACsToLocate.push_back(container.second);
567+
ACsToLocate[container.second->getID()] = container.second;
568568
}
569569
}
570570
break;
571571
case MID_HOTKEY_SHIFT_R_LOCATEROUTE:
572572
chooserLoc = &myACChoosers.ACChooserRoutes;
573573
locateTitle = TL("Route Chooser");
574574
for (const auto& route : viewNet->getNet()->getAttributeCarriers()->getDemandElements().at(SUMO_TAG_ROUTE)) {
575-
ACsToLocate.push_back(route.second);
575+
ACsToLocate[route.second->getID()] = route.second;
576576
}
577577
break;
578578
case MID_HOTKEY_SHIFT_S_LOCATESTOP: {
@@ -581,7 +581,7 @@ GNEViewParent::onCmdLocate(FXObject*, FXSelector sel, void*) {
581581
// fill ACsToLocate with all vehicles
582582
for (const auto& stopTag : NamespaceIDs::stops) {
583583
for (const auto& flowTAZ : viewNet->getNet()->getAttributeCarriers()->getDemandElements().at(stopTag)) {
584-
ACsToLocate.push_back(flowTAZ.second);
584+
ACsToLocate[flowTAZ.second->getID()] = flowTAZ.second;
585585
}
586586
}
587587
break;
@@ -592,7 +592,7 @@ GNEViewParent::onCmdLocate(FXObject*, FXSelector sel, void*) {
592592
// fill ACsToLocate with junctions that haven TLS
593593
for (const auto& junction : viewNet->getNet()->getAttributeCarriers()->getJunctions()) {
594594
if (junction.second->getNBNode()->getControllingTLS().size() > 0) {
595-
ACsToLocate.push_back(junction.second);
595+
ACsToLocate[junction.second->getID()] = junction.second;
596596
}
597597
}
598598
break;
@@ -604,7 +604,7 @@ GNEViewParent::onCmdLocate(FXObject*, FXSelector sel, void*) {
604604
// avoid shapes and TAZs
605605
if (!tagProperty->isShapeElement() && !tagProperty->isTAZElement()) {
606606
for (const auto& additional : additionalTag.second) {
607-
ACsToLocate.push_back(additional.second);
607+
ACsToLocate[additional.second->getID()] = additional.second;
608608
}
609609
}
610610
}
@@ -614,8 +614,8 @@ GNEViewParent::onCmdLocate(FXObject*, FXSelector sel, void*) {
614614
locateTitle = TL("POI Chooser");
615615
// fill ACsToLocate with all POIs
616616
for (const auto& POITag : NamespaceIDs::POIs) {
617-
for (const auto& flowTAZ : viewNet->getNet()->getAttributeCarriers()->getAdditionals().at(POITag)) {
618-
ACsToLocate.push_back(flowTAZ.second);
617+
for (const auto& poi : viewNet->getNet()->getAttributeCarriers()->getAdditionals().at(POITag)) {
618+
ACsToLocate[poi.second->getID()] = poi.second;
619619
}
620620
}
621621
break;
@@ -624,8 +624,8 @@ GNEViewParent::onCmdLocate(FXObject*, FXSelector sel, void*) {
624624
locateTitle = TL("Poly Chooser");
625625
// fill ACsToLocate with all polygons
626626
for (const auto& polygonTag : NamespaceIDs::polygons) {
627-
for (const auto& flowTAZ : viewNet->getNet()->getAttributeCarriers()->getAdditionals().at(polygonTag)) {
628-
ACsToLocate.push_back(flowTAZ.second);
627+
for (const auto& polygon : viewNet->getNet()->getAttributeCarriers()->getAdditionals().at(polygonTag)) {
628+
ACsToLocate[polygon.second->getID()] = polygon.second;
629629
}
630630
}
631631
break;

src/netedit/dialogs/GNEDialogACChooser.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,25 @@
2828
// method definitions
2929
// ===========================================================================
3030

31-
GNEDialogACChooser::GNEDialogACChooser(GNEViewParent* viewParent, int messageId, FXIcon* icon, const std::string& title, const std::vector<GNEAttributeCarrier*>& ACs):
32-
GUIDialog_ChooserAbstract(viewParent, messageId, icon, title.c_str(), std::vector<GUIGlID>(), GUIGlObjectStorage::gIDStorage),
31+
GNEDialogACChooser::GNEDialogACChooser(GNEViewParent* viewParent, int messageId,
32+
FXIcon* icon, const std::string& title,
33+
const std::map<std::string, GNEAttributeCarrier*>& ACs):
34+
GUIDialog_ChooserAbstract(viewParent, messageId, icon, title.c_str(),
35+
std::vector<GUIGlID>(), GUIGlObjectStorage::gIDStorage),
3336
myViewParent(viewParent),
34-
myACs(ACs),
35-
myFilteredACs(ACs),
3637
myLocateTLS(title.find("TLS") != std::string::npos) {
38+
// fill ACs
39+
myACs.reserve(ACs.size());
40+
myFilteredACs.reserve(ACs.size());
41+
for (const auto& AC : ACs) {
42+
myACs.push_back(AC.second);
43+
myFilteredACs.push_back(AC.second);
44+
}
3745
// @note refresh must be called here because the base class constructor cannot
3846
// call the virtual function getObjectName
3947
std::vector<GUIGlID> ids;
4048
for (const auto& AC : ACs) {
41-
ids.push_back(AC->getGUIGlObject()->getGlID());
49+
ids.push_back(AC.second->getGUIGlObject()->getGlID());
4250
}
4351
refreshList(ids);
4452
}

src/netedit/dialogs/GNEDialogACChooser.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ class GNEDialogACChooser : public GUIDialog_ChooserAbstract {
4747
* @param[in] viewParent GNEViewParent of Netedit
4848
* @param[in] icon The icon to use
4949
* @param[in] title The title to use
50-
* @param[in] ACs list of choosen ACs
50+
* @param[in] ACs map with choosen ACs sorted by IDs
5151
*/
52-
GNEDialogACChooser(GNEViewParent* viewParent, int messageId, FXIcon* icon, const std::string& title, const std::vector<GNEAttributeCarrier*>& ACs);
52+
GNEDialogACChooser(GNEViewParent* viewParent, int messageId, FXIcon* icon, const std::string& title,
53+
const std::map<std::string, GNEAttributeCarrier*>& ACs);
5354

5455
/// @brief Destructor
5556
~GNEDialogACChooser();

0 commit comments

Comments
 (0)