use of org.scijava.java3d.utils.pickfast.PickCanvas in project GDSC-SMLM by aherbert.
the class ImageJ3DResultsViewer method getPickedContent.
/**
* Get the Content and closest intersection point at the specified canvas position.
*
* <p>Adapted from Picker.getPickedContent(...).
*
* @param canvas the canvas
* @param scene the scene
* @param x the x
* @param y the y
* @return the Content and closest intersection point
*/
private static Pair<Content, IntersectionInfo> getPickedContent(Canvas3D canvas, BranchGroup scene, final int x, final int y) {
final PickCanvas pickCanvas = new PickCanvas(canvas, scene);
pickCanvas.setMode(PickInfo.PICK_GEOMETRY);
pickCanvas.setFlags(PickInfo.SCENEGRAPHPATH | PickInfo.CLOSEST_GEOM_INFO);
pickCanvas.setTolerance(3);
pickCanvas.setShapeLocation(x, y);
try {
final PickInfo[] result = pickCanvas.pickAllSorted();
if (result == null) {
return null;
}
for (int i = 0; i < result.length; i++) {
final SceneGraphPath path = result[i].getSceneGraphPath();
Content content = null;
for (int j = path.nodeCount(); j-- > 0; ) {
if (path.getNode(j) instanceof Content) {
content = (Content) path.getNode(j);
}
}
if (content == null) {
continue;
}
return Pair.of(content, result[i].getIntersectionInfos()[0]);
}
return null;
} catch (final Exception ex) {
return null;
}
}
Aggregations