void MapTool:: selectShape(const Geometry::Point<double,3>& pos) { MapManager* mapMan = crusta->getMapManager(); Shape*& curShape = mapMan->getActiveShape(toolId); Shape* oldShape = curShape; ShapePtrs shapes = getShapes(); double threshold = 1.0 / Vrui::getNavigationTransformation().getScaling(); threshold *= mapMan->getSelectDistance(); bool noShapeSelected = true; for (ShapePtrs::iterator it=shapes.begin(); it!=shapes.end(); ++it) { double distance; Shape::ControlId control = (*it)->select(pos, distance); if (control!=Shape::BAD_ID && distance<=threshold) { curShape = *it; threshold = distance; noShapeSelected = false; } } if (noShapeSelected && curShape!=NULL) unselectShape(curShape, curControl); //inform the manager that the active shape has changed if (curShape != oldShape) mapMan->updateActiveShape(toolId); }
void MapTool:: selectControl(const Geometry::Point<double,3>& pos) { MapManager* mapMan = crusta->getMapManager(); Shape*& curShape = mapMan->getActiveShape(toolId); assert(curShape != NULL); curControl = Shape::BAD_ID; double distance; Shape::ControlId control = curShape->select(pos, distance, mapMan->getPointSelectionBias()); if (control == Shape::BAD_ID) return; double threshold = 1.0 / Vrui::getNavigationTransformation().getScaling(); threshold *= mapMan->getSelectDistance(); if (distance > threshold) return; curControl = control; }