Search in sources :

Example 1 with Picker

use of ij3d.behaviors.Picker in project TrakEM2 by trakem2.

the class ControlClickBehavior method doProcess.

@Override
public void doProcess(final MouseEvent e) {
    if (!e.isControlDown() || e.getID() != MouseEvent.MOUSE_PRESSED) {
        super.doProcess(e);
        return;
    }
    final Picker picker = universe.getPicker();
    final Content content = picker.getPickedContent(e.getX(), e.getY());
    if (content == null)
        return;
    final Point3d p = picker.getPickPointGeometry(content, e);
    if (p == null) {
        Utils.log("No point was found on content " + content);
        return;
    }
    final Display display = Display.getFront(ls.getProject());
    if (display == null) {
        // If there's no Display, just return...
        return;
    }
    if (display.getLayerSet() != ls) {
        Utils.log("The LayerSet instances do not match");
        return;
    }
    if (ls == null) {
        Utils.log("No LayerSet was found for the Display");
        return;
    }
    final Calibration cal = ls.getCalibration();
    if (cal == null) {
        Utils.log("No calibration information was found for the LayerSet");
        return;
    }
    final double scaledZ = p.z / cal.pixelWidth;
    final Layer l = ls.getNearestLayer(scaledZ);
    if (l == null) {
        Utils.log("No layer was found nearest to " + scaledZ);
        return;
    }
    final Coordinate<?> coordinate = new Coordinate<Object>(p.x / cal.pixelWidth, p.y / cal.pixelHeight, l, null);
    display.center(coordinate);
}
Also used : Coordinate(ini.trakem2.display.Coordinate) Content(ij3d.Content) Point3d(org.scijava.vecmath.Point3d) Picker(ij3d.behaviors.Picker) Calibration(ij.measure.Calibration) Layer(ini.trakem2.display.Layer) Display(ini.trakem2.display.Display)

Aggregations

Calibration (ij.measure.Calibration)1 Content (ij3d.Content)1 Picker (ij3d.behaviors.Picker)1 Coordinate (ini.trakem2.display.Coordinate)1 Display (ini.trakem2.display.Display)1 Layer (ini.trakem2.display.Layer)1 Point3d (org.scijava.vecmath.Point3d)1