Search in sources :

Example 1 with BoundingBox

use of ij3d.shapes.BoundingBox in project GDSC-SMLM by aherbert.

the class CustomContentInstant method display.

@Override
public void display(final ContentNode node) {
    // Remove everything if possible
    for (final Enumeration<Node> e = ordered.getAllChildren(); e.hasMoreElements(); ) {
        final Switch s = (Switch) e.nextElement();
        s.removeAllChildren();
    }
    // Remove custom switch objects
    while (ordered.numChildren() > 5) {
        ordered.removeChild(ordered.numChildren() - 1);
    }
    customBefore = 0;
    if (switchMap != null) {
        switchMap.clear();
    }
    // Create content node and add it to the switch
    contentNode = node;
    ((Switch) ordered.getChild(CO)).addChild(contentNode);
    // Create the bounding box and add it to the switch
    final Point3d min = new Point3d();
    contentNode.getMin(min);
    final Point3d max = new Point3d();
    contentNode.getMax(max);
    BoundingBox bb = new BoundingBox(min, max);
    bb.setPickable(false);
    ((Switch) ordered.getChild(BS)).addChild(bb);
    bb = new BoundingBox(min, max, new Color3f(0, 1, 0));
    bb.setPickable(false);
    ((Switch) ordered.getChild(BB)).addChild(bb);
    // Create coordinate system and add it to the switch
    final float cl = (float) Math.abs(max.x - min.x) / 5f;
    final CoordinateSystem cs = new CoordinateSystem(cl, new Color3f(0, 1, 0));
    cs.setPickable(false);
    ((Switch) ordered.getChild(CS)).addChild(cs);
    // Create point list and add it to the switch
    ((Switch) ordered.getChild(PL)).addChild(plShape);
    // Adjust the landmark point size properly
    plShape.setRadius((float) min.distance(max) / 100f);
    // Initialize child mask of the switch
    setSwitchValue(BS, selected);
    setSwitchValue(CS, coordVisible);
    setSwitchValue(CO, visible);
    setSwitchValue(PL, showPl);
    // Update type
    this.type = CUSTOM;
}
Also used : Switch(org.scijava.java3d.Switch) Point3d(org.scijava.vecmath.Point3d) CoordinateSystem(ij3d.shapes.CoordinateSystem) ContentNode(ij3d.ContentNode) CustomMeshNode(customnode.CustomMeshNode) Node(org.scijava.java3d.Node) BoundingBox(ij3d.shapes.BoundingBox) Color3f(org.scijava.vecmath.Color3f)

Aggregations

CustomMeshNode (customnode.CustomMeshNode)1 ContentNode (ij3d.ContentNode)1 BoundingBox (ij3d.shapes.BoundingBox)1 CoordinateSystem (ij3d.shapes.CoordinateSystem)1 Node (org.scijava.java3d.Node)1 Switch (org.scijava.java3d.Switch)1 Color3f (org.scijava.vecmath.Color3f)1 Point3d (org.scijava.vecmath.Point3d)1