Skip to content

Commit fbd6a36

Browse files
committed
Improve UX for Bvv tracing
- Now called Stream mode - Ensure commands relying on traditional images remain disabled/provide clearer errors - Overall adjustments
1 parent 67f38ca commit fbd6a36

8 files changed

Lines changed: 192 additions & 89 deletions

File tree

‎src/main/java/sc/fiji/snt/BookmarkManager.java‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ private void goToRow(final int tableRow) {
321321
} else {
322322
final ImagePlus imp = sntui.plugin.getImagePlus();
323323
if (imp == null) {
324-
sntui.guiUtils.error("No image is currently open.");
324+
noImageOpenError();
325325
} else {
326326
goTo(tableRow, imp);
327327
if (!sntui.plugin.getSinglePane()) {
@@ -334,6 +334,13 @@ private void goToRow(final int tableRow) {
334334
}
335335
}
336336

337+
private void noImageOpenError() {
338+
assert sntui != null;
339+
sntui.guiUtils.error((sntui.isStreamMode())
340+
? "No image is currently open. This table can be better accessed from BDV/BVV's <i>Markers</i> pane."
341+
: "No image is currently open.");
342+
}
343+
337344
private void resetOrResizeColumns(final boolean reset, final boolean resize) {
338345
if (table == null || model == null) return;
339346
if (reset) GuiUtils.JTables.resetColumnOrder(table);
@@ -887,7 +894,7 @@ private void showHighlights() {
887894
}
888895
final ImagePlus imp = sntui.plugin.getImagePlus();
889896
if (imp == null) {
890-
sntui.guiUtils.error("No image is currently open.");
897+
noImageOpenError();
891898
syncHighlightToggle(false);
892899
return;
893900
}
@@ -1048,7 +1055,7 @@ Action goToAction() {
10481055
@Override
10491056
public void actionPerformed(final ActionEvent e) {
10501057
if (viewer == null && sntui.plugin.getImagePlus() == null) {
1051-
sntui.guiUtils.error("No image is currently open.");
1058+
noImageOpenError();
10521059
return;
10531060
}
10541061
final String pos = guiUtils.getString("Location XYZ coordinates (comma/space separated): ",

‎src/main/java/sc/fiji/snt/FillManagerUI.java‎

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,27 @@ public enum State {READY, STARTED, ENDED, LOADED, STOPPED}
9696

9797

9898
/**
99-
* Instantiates a new Fill Manager Dialog
99+
* Instantiates a new Fill Manager Dialog, with no owning {@link SNTUI} (e.g. scripts/tests
100+
* driving a headless-ish {@link SNT} instance that never called {@code startUI()}).
100101
*
101-
* @param plugin the {@link SNT} instance to be associated
102-
* with this FillManager. It is assumed that its {@link SNTUI} is
103-
* available.
102+
* @param plugin the {@link SNT} instance to be associated with this FillManager.
104103
*/
105104
public FillManagerUI(final SNT plugin) {
106-
super(plugin.getUI(), "Fill Manager");
105+
this(plugin, null);
106+
}
107+
108+
/**
109+
* Instantiates a new Fill Manager Dialog owned by {@code ui}.
110+
*
111+
* @param plugin the {@link SNT} instance to be associated with this FillManager
112+
* @param ui the owning {@link SNTUI}, or null if none (see {@link #FillManagerUI(SNT)})
113+
*/
114+
public FillManagerUI(final SNT plugin, final SNTUI ui) {
115+
super(ui, "Fill Manager");
107116
getRootPane().putClientProperty("JRootPane.menuBarEmbedded", false);
108117

109118
this.plugin = plugin;
119+
final boolean streamMode = ui != null && ui.isStreamMode();
110120
pathAndFillManager = plugin.getPathAndFillManager();
111121
pathAndFillManager.addPathAndFillListener(this);
112122
listModel = new DefaultListModel<>();
@@ -156,6 +166,7 @@ public FillManagerUI(final SNT plugin) {
156166

157167
// Row 1: Cursor threshold choice
158168
cursorThresholdChoice = new JRadioButton("Set by clicking on traced structure (preferred)");
169+
cursorThresholdChoice.setEnabled(!streamMode);
159170
distancePanel.add(cursorThresholdChoice, gdb);
160171
gdb.gridy++;
161172

@@ -230,7 +241,7 @@ public void focusGained(java.awt.event.FocusEvent e) {
230241
transparentCheckbox = new JCheckBox("Transparent overlay");
231242
transparentCheckbox.setToolTipText("Enabling this option allows you to better\ninspect fills, but may slow down filling");
232243
transparentCheckbox.addActionListener(e -> plugin.setFillTransparent(transparentCheckbox.isSelected()));
233-
244+
transparentCheckbox.setEnabled(!streamMode);
234245
final int prevLeftMargin = c.insets.left;
235246
c.insets.left = MARGIN;
236247
add(splitFillsCheckbox, c);
@@ -286,15 +297,13 @@ public void mousePressed(final MouseEvent e) {
286297
pack();
287298
adjustListPlaceholder();
288299
changeState(State.READY);
289-
setLocationRelativeTo(plugin.getUI());
300+
setLocationRelativeTo(ui);
290301
addWindowListener(new WindowAdapter() {
291302
@Override
292303
public void windowClosing(final WindowEvent ignored) {
293304
setVisible(false);
294305
}
295306
});
296-
297-
298307
}
299308

300309
private int[] getSelectedIndices(final String msg) {
@@ -836,8 +845,19 @@ private void assembleExportFillsMenu() {
836845

837846
// Add image export actions
838847
for (ExportAction action : exportActions) {
839-
JMenuItem jmi = new JMenuItem(action.getMenuText());
840-
jmi.addActionListener(e -> action.execute());
848+
final JMenuItem jmi = new JMenuItem(action.getMenuText());
849+
jmi.addActionListener(e -> {
850+
try {
851+
action.execute();
852+
} catch (final UnsupportedOperationException ex) {
853+
final String msg = (plugin.getUI() != null && plugin.getUI().isStreamMode())
854+
? "An error occurred: This operation likely requires the entire image to be loaded into memory (RAM)."
855+
: "An error occurred.";
856+
gUtils.error(msg + " See Console for details.");
857+
if (plugin.getUI() != null) plugin.getUI().setEnableDebugMode(true);
858+
SNTUtils.error(action.getMenuText(), ex);
859+
}
860+
});
841861
exportFillsMenu.add(jmi);
842862
}
843863

‎src/main/java/sc/fiji/snt/PathManagerUI.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5545,7 +5545,7 @@ private void rebuildRelationShips() {
55455545
private boolean noValidImageDataError() {
55465546
final boolean invalidImage = !plugin.getUI().accessToValidImagePlus();
55475547
if (invalidImage) {
5548-
guiUtils.error((getSNT().getUI() != null && getSNT().getUI().getState() == SNTUI.BVV_TRACING)
5548+
guiUtils.error((getSNT().getUI() != null && getSNT().getUI().getState() == SNTUI.STREAMING)
55495549
? "This option requires the entire image to be loaded into memory (RAM)."
55505550
: "This option requires valid image data to be loaded.");
55515551
}

‎src/main/java/sc/fiji/snt/SNT.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4269,7 +4269,7 @@ public void closeAndResetAllPanes() {
42694269
// Dispose xz/zy images unless the user stored some annotations (ROIs)
42704270
// on the image overlay or modified them somehow.
42714271
removeMIPOverlayAllPanes();
4272-
final boolean bvvMode = getUI() != null && getUI().getState() == SNTUI.BVV_TRACING;
4272+
final boolean bvvMode = getUI() != null && getUI().isStreamMode();
42734273
if (!single_pane) {
42744274
final ImagePlus[] impPanes = { xz, zy };
42754275
for (final ImagePlus imp : impPanes) {

0 commit comments

Comments
 (0)