Search in sources :

Example 1 with PeakResultTableModel

use of uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModel in project GDSC-SMLM by aherbert.

the class ImageJ3DResultsViewer method menuActionPerformed.

private void menuActionPerformed(ActionEvent event) {
    final Object src = event.getSource();
    ContentAction action = null;
    // Adapted from univ.resetView()
    if (src == resetRotation) {
        univ.fireTransformationStarted();
        // rotate so that y shows downwards
        final Transform3D t = new Transform3D();
        final AxisAngle4d aa = new AxisAngle4d(1, 0, 0, Math.PI);
        t.set(aa);
        univ.getRotationTG().setTransform(t);
        univ.fireTransformationUpdated();
        univ.fireTransformationFinished();
        return;
    }
    if (src == resetTranslation) {
        univ.fireTransformationStarted();
        final Transform3D t = new Transform3D();
        univ.getTranslateTG().setTransform(t);
        univ.recalculateGlobalMinMax();
        univ.getViewPlatformTransformer().centerAt(univ.getGlobalCenterPoint());
        univ.fireTransformationUpdated();
        univ.fireTransformationFinished();
        return;
    }
    if (src == resetZoom) {
        univ.fireTransformationStarted();
        final Transform3D t = new Transform3D();
        univ.getZoomTG().setTransform(t);
        final Point3d max = new Point3d();
        final Point3d min = new Point3d();
        univ.getGlobalMaxPoint(max);
        univ.getGlobalMinPoint(min);
        final float range = (float) (max.x - min.x);
        final double d = (range) / Math.tan(Math.PI / 8);
        univ.getViewPlatformTransformer().zoomTo(d);
        univ.fireTransformationUpdated();
        univ.fireTransformationFinished();
        return;
    }
    if (src == updateSettings) {
        final ImageJ3DResultsViewerSettings.Builder settings = SettingsManager.readImageJ3DResultsViewerSettings(0).toBuilder();
        final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
        final ResultsSettings.Builder s = ResultsSettings.newBuilder();
        ResultsTableSettings localResultsTableSettings = resultsTableSettings.get();
        s.setResultsTableSettings(localResultsTableSettings);
        gd.addMessage("Click on the image to view localisation data.\nCtrl/Alt key must be pressed.");
        final TextField[] tf = new TextField[1];
        gd.addStringField("Highlight_colour", settings.getHighlightColour(), new OptionListener<String>() {

            @Override
            public boolean collectOptions(String value) {
                createHighlightColour(value);
                int red;
                int green;
                int blue;
                final Color3f color = highlightColor.get();
                if (color == null) {
                    red = blue = 0;
                    green = 255;
                } else {
                    red = (int) (color.x * 255);
                    green = (int) (color.y * 255);
                    blue = (int) (color.z * 255);
                }
                final ExtendedGenericDialog egd = new ExtendedGenericDialog("Highlight colour", null);
                egd.addSlider("Red", 0, 255, red);
                egd.addSlider("Green", 0, 255, green);
                egd.addSlider("Blue", 0, 255, blue);
                egd.showDialog(true, gd);
                if (egd.wasCanceled()) {
                    return false;
                }
                red = (int) egd.getNextNumber();
                green = (int) egd.getNextNumber();
                blue = (int) egd.getNextNumber();
                final Color c = new Color(red, green, blue);
                final String cvalue = c.getRed() + "," + c.getGreen() + "," + c.getBlue();
                tf[0].setText(cvalue);
                return true;
            }

            @Override
            public boolean collectOptions() {
                return false;
            }
        });
        tf[0] = gd.getLastTextField();
        gd.addCheckbox("Add_to_selection", settings.getAddToSelection());
        ResultsManager.addTableResultsOptions(gd, s, ResultsManager.FLAG_NO_SECTION_HEADER);
        gd.addMessage("Allow the 'Find Eye Point' command to save to settings");
        gd.addCheckbox("Save_eye_point", settings.getSaveEyePoint());
        // Same as CropResults
        gd.addChoice("Crop_name_option", CropResults.NAME_OPTIONS, settings.getNameOption(), new OptionListener<Integer>() {

            @Override
            public boolean collectOptions(Integer value) {
                settings.setNameOption(value);
                final ExtendedGenericDialog egd = new ExtendedGenericDialog(TITLE);
                if (settings.getNameOption() == CropResults.NAME_OPTION_NAME) {
                    return false;
                } else if (settings.getNameOption() == CropResults.NAME_OPTION_SUFFIX) {
                    final String name = (TextUtils.isNullOrEmpty(settings.getNameSuffix())) ? " Cropped" : settings.getNameSuffix();
                    egd.addStringField("Name_suffix", name, MathUtils.clip(20, 60, name.length()));
                } else if (settings.getNameOption() == CropResults.NAME_OPTION_SEQUENCE) {
                    final String name = settings.getNameSuffix();
                    egd.addStringField("Name_suffix", name, MathUtils.clip(20, 60, name.length()));
                    int counter = settings.getNameCounter();
                    if (counter < 1) {
                        counter = 1;
                    }
                    egd.addNumericField("Name_counter", counter, 0);
                } else {
                    throw new IllegalStateException("Unknown name option: " + settings.getNameOption());
                }
                egd.showDialog(true, gd);
                if (egd.wasCanceled()) {
                    return false;
                }
                if (settings.getNameOption() == CropResults.NAME_OPTION_SUFFIX) {
                    settings.setNameSuffix(egd.getNextString());
                } else if (settings.getNameOption() == CropResults.NAME_OPTION_SEQUENCE) {
                    settings.setNameSuffix(egd.getNextString());
                    settings.setNameCounter(Math.max(1, (int) egd.getNextNumber()));
                }
                return true;
            }

            @Override
            public boolean collectOptions() {
                return false;
            }
        });
        gd.addCheckbox("Update_existing_tables", localResultsTableSettings.getUpdateExistingTables());
        addHelp(gd);
        gd.showDialog();
        if (gd.wasCanceled()) {
            return;
        }
        settings.setHighlightColour(gd.getNextString());
        boolean add = gd.getNextBoolean();
        addToSelection.set(add);
        settings.setAddToSelection(add);
        final ResultsTableSettings.Builder resultsTableSettingsBuilder = s.getResultsTableSettingsBuilder();
        resultsTableSettingsBuilder.setShowTable(gd.getNextBoolean());
        settings.setSaveEyePoint(gd.getNextBoolean());
        settings.setNameOption(gd.getNextChoiceIndex());
        resultsTableSettingsBuilder.setUpdateExistingTables(gd.getNextBoolean());
        createHighlightColour(settings.getHighlightColour());
        // Save updated settings
        localResultsTableSettings = resultsTableSettingsBuilder.build();
        settings.setResultsTableSettings(localResultsTableSettings);
        SettingsManager.writeSettings(settings);
        // Update the table settings for all the selection models
        if (resultsTableSettingsBuilder.getUpdateExistingTables()) {
            for (final Triple<PeakResultTableModel, ?, ?> t : resultsTables.values()) {
                t.getLeft().setTableSettings(localResultsTableSettings);
            }
        }
        action = new UpdateHighlightColourAction();
    }
    if (src == toggleDynamicTransparency) {
        final long total = getTotalTransparentObjects(univ, "");
        final View view = univ.getViewer().getView();
        final boolean activate = view.getTransparencySortingPolicy() == View.TRANSPARENCY_SORT_NONE;
        activateDynamicTransparency(univ, total, activate);
        return;
    }
    // Actions to perform on content
    if (src == changeColour) {
        action = new ChangeColourContentAction();
    } else if (src == resetAll) {
        univ.resetView();
        univ.select(null);
        action = new ResetViewContentAction(false);
    } else if (src == resetSelectedView) {
        action = new ResetViewContentAction(true);
    } else if (src == findEyePoint) {
        action = new FindEyePointContentAction();
    } else if (src == sortBackToFront) {
        action = new SortContentAction(false);
    } else if (src == sortFrontToBack) {
        action = new SortContentAction(true);
    } else if (src == colourSurface) {
        action = new ColourSurfaceContentAction();
    } else if (src == toggleTransparent) {
        action = new ToggleTransparentAction();
    } else if (src == toggleShaded) {
        action = new ToggleShadedAction();
    } else if (src == changePointSize) {
        action = new ChangePointSizeContentAction();
    } else if (src == increasePointSize) {
        action = UpdatePointSizeContentAction.INCREASE;
    } else if (src == decreasePointSize) {
        action = UpdatePointSizeContentAction.DECREASE;
    } else if (src == cropResults) {
        action = new CropResultsAction();
    } else if (src == showHelp) {
        showHelp();
        return;
    }
    if (action == null) {
        return;
    }
    if (univ.getSelected() != null) {
        action.run(univ.getSelected());
    } else {
        for (final Iterator<Content> it = univ.contents(); it.hasNext(); ) {
            if (action.run(it.next()) < 0) {
                break;
            }
        }
    }
    action.finish();
}
Also used : ImageJ3DResultsViewerSettings(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettings) Transform3D(org.scijava.java3d.Transform3D) Color3f(org.scijava.vecmath.Color3f) PeakResultTableModel(uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModel) Point3d(org.scijava.vecmath.Point3d) TextField(java.awt.TextField) Builder(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettings.Builder) ResultsTableSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsTableSettings) Color(java.awt.Color) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) ResultsSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings) View(org.scijava.java3d.View) Content(ij3d.Content) CustomContent(uk.ac.sussex.gdsc.smlm.ij.ij3d.CustomContent) NamedObject(uk.ac.sussex.gdsc.smlm.data.NamedObject) AxisAngle4d(org.scijava.vecmath.AxisAngle4d)

Example 2 with PeakResultTableModel

use of uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModel in project GDSC-SMLM by aherbert.

the class ImageJ3DResultsViewer method run.

@Override
public void run(String arg) {
    // For testing
    // if (true || Utils.isExtraOptions())
    // {
    // new ImageJ3DResultsViewerDemo().run(arg);
    // return;
    // }
    SmlmUsageTracker.recordPlugin(this.getClass(), arg);
    if (ImageJ3DViewerUtils.JAVA_3D_VERSION == null) {
        IJ.error(TITLE, "Java 3D is not available");
        return;
    }
    if (MemoryPeakResults.isMemoryEmpty()) {
        IJ.error(TITLE, "There are no fitting results in memory");
        return;
    }
    final ImageJ3DResultsViewerSettings.Builder settings = SettingsManager.readImageJ3DResultsViewerSettings(0).toBuilder();
    addToSelection.set(settings.getAddToSelection());
    // Get a list of the window titles available. Allow the user to select
    // an existing window or a new one.
    final String title = TITLE;
    final List<Image3DUniverse> univList = new LocalList<>();
    final List<String> titleList = new LocalList<>();
    titleList.add("New window");
    buildWindowList(title, univList, titleList);
    final String[] titles = titleList.toArray(new String[0]);
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    gd.addMessage("Select a dataset to display");
    ResultsManager.addInput(gd, settings.getInputOption(), InputSource.MEMORY);
    // The behaviour is to allow the settings to store if the user prefers a new window
    // or to reuse an existing window. If 'new window' then a new window should always
    // be selected. Otherwise open in the same window as last time. If there was no last
    // window then the settings will carried over from the last ImageJ session.
    final String window = (settings.getNewWindow()) ? "" : lastWindow.get();
    gd.addChoice("Window", titles, window);
    gd.addSlider("Transparancy", 0, 0.9, settings.getTransparency(), new OptionListener<Double>() {

        @Override
        public boolean collectOptions(Double value) {
            return collectOptions(false);
        }

        @Override
        public boolean collectOptions() {
            return collectOptions(true);
        }

        private boolean collectOptions(boolean silent) {
            final ExtendedGenericDialog egd = new ExtendedGenericDialog("Transparancy options", null);
            egd.addCheckbox("Support_dynamic_transparency", settings.getSupportDynamicTransparency());
            egd.addCheckbox("Enable_dynamic_transparency", settings.getEnableDynamicTransparency());
            egd.setSilent(silent);
            egd.showDialog(true, gd);
            if (egd.wasCanceled()) {
                return false;
            }
            settings.setSupportDynamicTransparency(egd.getNextBoolean());
            settings.setEnableDynamicTransparency(egd.getNextBoolean());
            return true;
        }
    });
    gd.addChoice("Colour", LutHelper.getLutNames(), settings.getLut());
    gd.addChoice("Rendering", RENDERING, settings.getRendering(), new OptionListener<Integer>() {

        @Override
        public boolean collectOptions(Integer value) {
            settings.setRendering(value);
            return collectOptions(false);
        }

        @Override
        public boolean collectOptions() {
            return collectOptions(true);
        }

        private boolean collectOptions(boolean silent) {
            final ExtendedGenericDialog egd = new ExtendedGenericDialog("Drawing mode options", null);
            final int rendering = settings.getRendering();
            if (rendering != 0) {
                return false;
            }
            egd.addNumericField("Pixel_size", settings.getPixelSize(), 2, 6, "px");
            egd.setSilent(silent);
            egd.showDialog(true, gd);
            if (egd.wasCanceled()) {
                return false;
            }
            settings.setPixelSize(egd.getNextNumber());
            return true;
        }
    });
    gd.addCheckbox("Shaded", settings.getShaded());
    gd.addChoice("Size_mode", SIZE_MODE, settings.getSizeMode(), new OptionListener<Integer>() {

        @Override
        public boolean collectOptions(Integer value) {
            settings.setSizeMode(value);
            return collectOptions(false);
        }

        @Override
        public boolean collectOptions() {
            return collectOptions(true);
        }

        private boolean collectOptions(boolean silent) {
            final ExtendedGenericDialog egd = new ExtendedGenericDialog("Size mode options", null);
            final SizeMode mode = SizeMode.forNumber(settings.getSizeMode());
            if (mode == SizeMode.FIXED_SIZE) {
                egd.addNumericField("Size", settings.getSize(), 2, 6, "nm");
            } else {
                // Other modes do not require options
                return false;
            }
            egd.setSilent(silent);
            egd.showDialog(true, gd);
            if (egd.wasCanceled()) {
                return false;
            }
            settings.setSize(egd.getNextNumber());
            return true;
        }
    });
    gd.addChoice("Sort_mode", SORT_MODE, settings.getSortMode(), new OptionListener<Integer>() {

        @Override
        public boolean collectOptions(Integer value) {
            settings.setSortMode(value);
            return collectOptions(false);
        }

        @Override
        public boolean collectOptions() {
            return collectOptions(true);
        }

        private boolean collectOptions(boolean silent) {
            final ExtendedGenericDialog egd = new ExtendedGenericDialog("Sort mode options", null);
            final SortMode mode = SortMode.forNumber(settings.getSortMode());
            if (mode == SortMode.NONE) {
                return false;
            }
            egd.addMessage(TextUtils.wrap("Note: The sort mode is used to correctly render transparent objects. " + "For non-transparent objects faster rendering is achieved with a reverse " + "sort to put close objects at the front.", 80));
            egd.addMessage(TextUtils.wrap(mode.getDetails(), 80));
            egd.addMessage("Define the direction of the view");
            egd.addNumericField("Direction_x", settings.getSortDirectionX(), 3, 10, "");
            egd.addNumericField("Direction_y", settings.getSortDirectionY(), 3, 10, "");
            egd.addNumericField("Direction_z", settings.getSortDirectionZ(), 3, 10, "");
            if (mode == SortMode.PERSPECTIVE) {
                egd.addMessage("Define the view eye position");
                egd.addNumericField("Eye_x", settings.getSortEyeX(), 3, 10, "nm");
                egd.addNumericField("Eye_y", settings.getSortEyeY(), 3, 10, "nm");
                egd.addNumericField("Eye_z", settings.getSortEyeZ(), 3, 10, "nm");
            }
            egd.setSilent(silent);
            egd.showDialog(true, gd);
            if (egd.wasCanceled()) {
                return false;
            }
            settings.setSortDirectionX(egd.getNextNumber());
            settings.setSortDirectionY(egd.getNextNumber());
            settings.setSortDirectionZ(egd.getNextNumber());
            if (mode == SortMode.PERSPECTIVE) {
                settings.setSortEyeX(egd.getNextNumber());
                settings.setSortEyeY(egd.getNextNumber());
                settings.setSortEyeZ(egd.getNextNumber());
            }
            return true;
        }
    });
    gd.addChoice("Transparency_mode", TRANSPARENCY_MODE, settings.getTransparencyMode(), new OptionListener<Integer>() {

        @Override
        public boolean collectOptions(Integer value) {
            settings.setTransparencyMode(value);
            return collectOptions(false);
        }

        @Override
        public boolean collectOptions() {
            return collectOptions(true);
        }

        private boolean collectOptions(boolean silent) {
            final ExtendedGenericDialog egd = new ExtendedGenericDialog("Transparency mode options", null);
            final TransparencyMode mode = TransparencyMode.forNumber(settings.getTransparencyMode());
            if (mode == TransparencyMode.NONE) {
                return false;
            }
            egd.addSlider("Min_transparancy", 0, 0.95, settings.getMinTransparency());
            egd.addSlider("Max_transparancy", 0, 0.95, settings.getMaxTransparency());
            egd.setSilent(silent);
            egd.showDialog(true, gd);
            if (egd.wasCanceled()) {
                return false;
            }
            settings.setMinTransparency(egd.getNextNumber());
            settings.setMaxTransparency(egd.getNextNumber());
            return true;
        }
    });
    addColourMode(settings, gd);
    gd.addMessage("2D options");
    gd.addChoice("Depth_mode", DEPTH_MODE, settings.getDepthMode(), new OptionListener<Integer>() {

        @Override
        public boolean collectOptions(Integer value) {
            settings.setDepthMode(value);
            return collectOptions(false);
        }

        @Override
        public boolean collectOptions() {
            return collectOptions(true);
        }

        private boolean collectOptions(boolean silent) {
            final ExtendedGenericDialog egd = new ExtendedGenericDialog("Depth mode options", null);
            final DepthMode mode = DepthMode.forNumber(settings.getDepthMode());
            if (mode == DepthMode.NONE) {
                return false;
            }
            egd.addNumericField("Depth_range", settings.getDepthRange(), 2, 6, "nm");
            if (mode == DepthMode.DITHER) {
                egd.addNumericField("Dither_seed", settings.getDitherSeed(), 0);
            }
            egd.setSilent(silent);
            egd.showDialog(true, gd);
            if (egd.wasCanceled()) {
                return false;
            }
            settings.setDepthRange(egd.getNextNumber());
            if (mode == DepthMode.DITHER) {
                settings.setDitherSeed((int) egd.getNextNumber());
            }
            return true;
        }
    });
    addHelp(gd);
    gd.showDialog();
    if (gd.wasCanceled()) {
        return;
    }
    final String name = ResultsManager.getInputSource(gd);
    final int windowChoice = gd.getNextChoiceIndex();
    lastWindow.set(titles[windowChoice]);
    settings.setInputOption(name);
    settings.setTransparency(gd.getNextNumber());
    settings.setLut(gd.getNextChoiceIndex());
    settings.setRendering(gd.getNextChoiceIndex());
    settings.setShaded(gd.getNextBoolean());
    settings.setSizeMode(gd.getNextChoiceIndex());
    settings.setSortMode(gd.getNextChoiceIndex());
    settings.setTransparencyMode(gd.getNextChoiceIndex());
    settings.setColourMode(gd.getNextChoiceIndex());
    settings.setDepthMode(gd.getNextChoiceIndex());
    gd.collectOptions();
    if (windowChoice == 0) {
        // Store if the user chose a new window when they had a choice of an existing window
        if (titleList.size() > 1) {
            settings.setNewWindow(true);
        // Otherwise they had no choice so leave the preferences as they are.
        }
    } else {
        // This was not a new window
        settings.setNewWindow(false);
    }
    SettingsManager.writeSettings(settings);
    MemoryPeakResults results = ResultsManager.loadInputResults(name, false, null, null);
    if (MemoryPeakResults.isEmpty(results)) {
        IJ.error(TITLE, "No results could be loaded");
        return;
    }
    // Determine if the drawing mode is supported and compute the point size
    final Point3f[] sphereSize = createSphereSize(results, settings);
    if (sphereSize == null) {
        return;
    }
    // Cache the table settings
    resultsTableSettings.set(settings.getResultsTableSettings());
    // Create a 3D viewer.
    if (windowChoice == 0) {
        univ = createImage3DUniverse(title, titleList);
    } else {
        // Ignore the new window
        univ = univList.get(windowChoice - 1);
    }
    lastWindow.set(univ.getWindow().getTitle());
    results = results.copy();
    // Commence a digest
    final Future<PeakResultsDigest> futureDigest = PeakResultsDigest.digestLater(executorService, results.toArray());
    final LocalList<Point3f> points = getPoints(results, settings);
    final ResultsMetaData data = new ResultsMetaData(settings.build(), results, points, sphereSize);
    sort(data);
    final float[] alpha = createAlpha(results, settings, sphereSize);
    final float transparency = getTransparency(settings);
    final Color3f[] colors = createColour(results, settings);
    ContentNode contentNode;
    // Build to support true transparency (depends on settings).
    // Currently this is not supported for PointArrays as they require colouring
    // in the coordinate data.
    IJ.showStatus("Creating 3D geometry ...");
    if (settings.getSupportDynamicTransparency()) {
        final ItemGeometryGroup pointGroup = createItemGroup(settings, sphereSize, points, alpha, transparency, colors);
        if (pointGroup == null) {
            IJ.showStatus("");
            return;
        }
        if (settings.getEnableDynamicTransparency()) {
            final long total = points.size() + getTotalTransparentObjects(univ, name);
            activateDynamicTransparency(univ, total, settings.getEnableDynamicTransparency());
        } else {
            activateDynamicTransparency(univ, 0, settings.getEnableDynamicTransparency());
        }
        contentNode = new ItemGroupNode(pointGroup);
    } else {
        final ItemMesh mesh = createItemMesh(settings, points, sphereSize, transparency, alpha);
        if (mesh == null) {
            IJ.showStatus("");
            return;
        }
        setColour(mesh, colors);
        contentNode = new CustomMeshNode(mesh);
    }
    IJ.showStatus("Creating 3D content ...");
    // Use custom content to support adding new switchable nodes
    final CustomContent content = new CustomContent(name, !settings.getSupportDynamicTransparency());
    final CustomContentInstant contentInstant = (CustomContentInstant) content.getCurrent();
    contentInstant.setTransparency((float) settings.getTransparency());
    contentInstant.setShaded(settings.getShaded());
    contentInstant.showCoordinateSystem(UniverseSettings.showLocalCoordinateSystemsByDefault);
    contentInstant.display(contentNode);
    createHighlightColour(settings.getHighlightColour());
    content.setUserData(data);
    // Prevent relative rotation
    content.setLocked(true);
    // Set up the click selection node
    data.createClickSelectionNode(contentInstant);
    // Set up the results selection model
    data.digest = PeakResultsDigest.waitForDigest(futureDigest, -1);
    if (data.digest == null) {
        IJ.error(TITLE, "Failed to identify repeat results set");
        IJ.showStatus("");
        return;
    }
    Triple<PeakResultTableModel, ListSelectionModel, PeakResultTableModelFrame> triplet = resultsTables.get(data.digest);
    if (triplet == null) {
        triplet = Triple.of(new PeakResultTableModel(results, false, // Note the settings do not matter until the table is set live
        resultsTableSettings.get()), new DefaultListSelectionModel(), null);
        triplet.getLeft().setCheckDuplicates(true);
        resultsTables.put(data.digest, triplet);
    }
    // Preserve orientation on the content
    final boolean auto = univ.getAutoAdjustView();
    final Content oldContent = univ.getContent(name);
    if (oldContent == null) {
        univ.setAutoAdjustView(true);
    } else {
        univ.removeContent(name);
        univ.setAutoAdjustView(false);
    }
    IJ.showStatus("Drawing 3D content ... ");
    final StopWatch sw = StopWatch.createStarted();
    final Future<Content> future = univ.addContentLater(content);
    Content added = null;
    for (; ; ) {
        try {
            // Wait for 1 second
            for (int i = 0; i < 20; i++) {
                Thread.sleep(50);
                if (future.isDone()) {
                    // Only get the result when finished, so avoiding a blocking wait
                    added = future.get();
                    break;
                }
            }
            if (added != null) {
                break;
            }
            final long seconds = sw.getTime(TimeUnit.SECONDS);
            if (seconds % 20 == 0) {
                final ExtendedGenericDialog egd = new ExtendedGenericDialog(TITLE, null);
                egd.addMessage("Current wait time is " + sw.toString());
                egd.setOKLabel("Wait");
                egd.showDialog();
                if (egd.wasCanceled()) {
                    future.cancel(true);
                    break;
                }
            }
            IJ.showStatus("Drawing 3D content ... " + seconds);
        } catch (final InterruptedException ex) {
            Thread.currentThread().interrupt();
        } catch (final ExecutionException ex) {
            break;
        }
    }
    univ.setAutoAdjustView(auto);
    // Initialise the selection model
    if (added != null) {
        data.addSelectionModel(triplet);
    }
    IJ.showStatus("");
}
Also used : ImageJ3DResultsViewerSettings(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettings) DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) PeakResultTableModel(uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModel) LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) CustomContentInstant(uk.ac.sussex.gdsc.smlm.ij.ij3d.CustomContentInstant) MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) Builder(uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettings.Builder) DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) ListSelectionModel(javax.swing.ListSelectionModel) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) ItemGeometryGroup(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemGeometryGroup) OrderedItemGeometryGroup(uk.ac.sussex.gdsc.smlm.ij.ij3d.OrderedItemGeometryGroup) PeakResultsDigest(uk.ac.sussex.gdsc.smlm.results.PeakResultsDigest) Content(ij3d.Content) CustomContent(uk.ac.sussex.gdsc.smlm.ij.ij3d.CustomContent) CustomMeshNode(customnode.CustomMeshNode) ReferenceItemMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.ReferenceItemMesh) ItemMesh(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemMesh) Color3f(org.scijava.vecmath.Color3f) ItemGroupNode(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemGroupNode) ContentNode(ij3d.ContentNode) CustomContent(uk.ac.sussex.gdsc.smlm.ij.ij3d.CustomContent) Point3f(org.scijava.vecmath.Point3f) ExecutionException(java.util.concurrent.ExecutionException) Image3DUniverse(ij3d.Image3DUniverse) PeakResultTableModelFrame(uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModelFrame) StopWatch(org.apache.commons.lang3.time.StopWatch)

Example 3 with PeakResultTableModel

use of uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModel in project GDSC-SMLM by aherbert.

the class ResultsManager method showInteractiveTable.

/**
 * Show interactive table.
 *
 * @param results the results
 * @param resultsTableSettings the results table settings
 */
public static void showInteractiveTable(MemoryPeakResults results, ResultsTableSettings resultsTableSettings) {
    final PeakResultTableModel model = new PeakResultTableModel(results, true, resultsTableSettings);
    final PeakResultTableModelFrame frame = new PeakResultTableModelFrame(model);
    frame.setTitle(results.getName());
    frame.setVisible(true);
    // Save changes to the interactive table settings
    model.addSettingsUpdatedAction(s -> {
        // Load the latest settings and save the table options
        final ResultsSettings.Builder resultsSettings = SettingsManager.readResultsSettings(0).toBuilder();
        resultsSettings.setResultsTableSettings(s);
        SettingsManager.writeSettings(resultsSettings.build());
    });
}
Also used : Builder(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings.Builder) PeakResultTableModelFrame(uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModelFrame) ResultsSettings(uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings) PeakResultTableModel(uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModel)

Aggregations

PeakResultTableModel (uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModel)3 Content (ij3d.Content)2 Color3f (org.scijava.vecmath.Color3f)2 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)2 ResultsSettings (uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings)2 PeakResultTableModelFrame (uk.ac.sussex.gdsc.smlm.ij.gui.PeakResultTableModelFrame)2 CustomContent (uk.ac.sussex.gdsc.smlm.ij.ij3d.CustomContent)2 ImageJ3DResultsViewerSettings (uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettings)2 Builder (uk.ac.sussex.gdsc.smlm.ij.settings.GUIProtos.ImageJ3DResultsViewerSettings.Builder)2 CustomMeshNode (customnode.CustomMeshNode)1 ContentNode (ij3d.ContentNode)1 Image3DUniverse (ij3d.Image3DUniverse)1 Color (java.awt.Color)1 TextField (java.awt.TextField)1 ExecutionException (java.util.concurrent.ExecutionException)1 DefaultListSelectionModel (javax.swing.DefaultListSelectionModel)1 ListSelectionModel (javax.swing.ListSelectionModel)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1 Transform3D (org.scijava.java3d.Transform3D)1 View (org.scijava.java3d.View)1