std::vector<GUIGlID> GUISUMOAbstractView::getObjectsAtPosition(Position pos, SUMOReal radius) { Boundary selection; selection.add(pos); selection.grow(radius); const std::vector<GUIGlID> ids = getObjectsInBoundary(selection); std::vector<GUIGlID> result; // Interpret results for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) { GUIGlID id = *it; GUIGlObject* o = GUIGlObjectStorage::gIDStorage.getObjectBlocking(id); if (o == 0) { continue; } if (o->getGlID() == 0) { continue; } //std::cout << "point selection hit " << o->getMicrosimID() << "\n"; GUIGlObjectType type = o->getType(); if (type != 0) { result.push_back(id); } GUIGlObjectStorage::gIDStorage.unblockObject(id); } return result; }
GUIGlID GUISUMOAbstractView::getObjectAtPosition(Position pos) { const SUMOReal SENSITIVITY = 0.1; // meters Boundary selection; selection.add(pos); selection.grow(SENSITIVITY); const std::vector<GUIGlID> ids = getObjectsInBoundary(selection); // Interpret results unsigned int idMax = 0; int prevLayer = -1000; for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) { GUIGlID id = *it; GUIGlObject* o = GUIGlObjectStorage::gIDStorage.getObjectBlocking(id); if (o == 0) { continue; } if (o->getGlID() == 0) { continue; } //std::cout << "point selection hit " << o->getMicrosimID() << "\n"; GUIGlObjectType type = o->getType(); if (type != 0) { int clayer = (int) type; // determine an "abstract" layer for shapes // this "layer" resembles the layer of the shape // taking into account the stac of other objects if (type == GLO_SHAPE) { if (dynamic_cast<GUIPolygon*>(o) != 0) { if (dynamic_cast<GUIPolygon*>(o)->getLayer() > 0) { clayer = GLO_MAX + dynamic_cast<GUIPolygon*>(o)->getLayer(); } if (dynamic_cast<GUIPolygon*>(o)->getLayer() < 0) { clayer = dynamic_cast<GUIPolygon*>(o)->getLayer(); } } if (dynamic_cast<GUIPointOfInterest*>(o) != 0) { if (dynamic_cast<GUIPointOfInterest*>(o)->getLayer() > 0) { clayer = GLO_MAX + dynamic_cast<GUIPointOfInterest*>(o)->getLayer(); } if (dynamic_cast<GUIPointOfInterest*>(o)->getLayer() < 0) { clayer = dynamic_cast<GUIPointOfInterest*>(o)->getLayer(); } } } // check whether the current object is above a previous one if (prevLayer == -1000 || prevLayer < clayer) { idMax = id; prevLayer = clayer; } } GUIGlObjectStorage::gIDStorage.unblockObject(id); } return idMax; }
GUIGlID GUISUMOAbstractView::getObjectAtPosition(Position pos) { const SUMOReal SENSITIVITY = 0.1; // meters Boundary selection; selection.add(pos); selection.grow(SENSITIVITY); const std::vector<GUIGlID> ids = getObjectsInBoundary(selection); // Interpret results unsigned int idMax = 0; SUMOReal maxLayer = -std::numeric_limits<SUMOReal>::max(); for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) { GUIGlID id = *it; GUIGlObject* o = GUIGlObjectStorage::gIDStorage.getObjectBlocking(id); if (o == 0) { continue; } if (o->getGlID() == 0) { continue; } //std::cout << "point selection hit " << o->getMicrosimID() << "\n"; GUIGlObjectType type = o->getType(); if (type != 0) { SUMOReal layer = (SUMOReal)type; // determine an "abstract" layer for shapes // this "layer" resembles the layer of the shape // taking into account the stac of other objects if (type == GLO_POI || type == GLO_POLYGON) { layer = dynamic_cast<Shape*>(o)->getLayer(); } #ifdef HAVE_INTERNAL if (type == GLO_LANE && GUIVisualizationSettings::UseMesoSim) { // do not select lanes in meso mode continue; } #endif // check whether the current object is above a previous one if (layer > maxLayer) { idMax = id; maxLayer = layer; } } GUIGlObjectStorage::gIDStorage.unblockObject(id); } return idMax; }