Skip to content

Commit ebd6a50

Browse files
committed
Apply 82ddf6c patch to Bdv
1 parent 0d53f95 commit ebd6a50

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

  • src/main/java/sc/fiji/snt/viewer

‎src/main/java/sc/fiji/snt/viewer/Bdv.java‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,21 @@ public List<BdvStackSource<?>> show(final AbstractSpimData<?> spimData, final St
328328
* @return list of BdvStackSources, one per setup
329329
*/
330330
public List<BdvStackSource<?>> show(final SpimDataUtils.N5Sources n5Sources) {
331-
final BdvOptions opts = (bdvHandle == null)
332-
? baseOpts()
333-
: BdvOptions.options().addTo(bdvHandle);
331+
final boolean firstEverSource = bdvHandle == null;
334332
final List<BdvStackSource<?>> sources = new ArrayList<>();
335-
for (final SourceAndConverter<?> soc : n5Sources.sources)
336-
sources.add(BdvFunctions.show(soc, n5Sources.numTimepoints, opts));
333+
for (final SourceAndConverter<?> soc : n5Sources.sources) {
334+
// See Bvv's identical fix for multiple channels being displayed across instances
335+
// NB: Each channel is a separate BdvFunctions.show(...) call, and options *without* addTo(...)
336+
// always opens a brand new top-level window. Deciding "attach to existing handle" once, before
337+
// any channel exists, meant bdvHandle was still null for the whole loop on a fresh Bdv, so
338+
// every channel got its own window instead of being appended to the first one
339+
final BdvOptions opts = (bdvHandle == null)
340+
? baseOpts()
341+
: BdvOptions.options().addTo(bdvHandle);
342+
final BdvStackSource<?> source = BdvFunctions.show(soc, n5Sources.numTimepoints, opts);
343+
sources.add(source);
344+
if (bdvHandle == null) bdvHandle = source.getBdvHandle(); // subsequent channels attach to this window
345+
}
337346
if (sources.isEmpty()) return sources;
338347

339348
if (dims == null || cal == null) {
@@ -350,8 +359,9 @@ public List<BdvStackSource<?>> show(final SpimDataUtils.N5Sources n5Sources) {
350359
} catch (final Exception ignored) {} // never break rendering for a metadata hiccup
351360
}
352361

353-
if (bdvHandle == null) {
354-
bdvHandle = sources.getFirst().getBdvHandle();
362+
// bdvHandle is already set by the loop above, so this checks firstEverSource instead
363+
// to still fire exactly once, the very first time any source is shown.
364+
if (firstEverSource) {
355365
viewerPanel = bdvHandle.getViewerPanel();
356366
initializeOverlays();
357367
}

0 commit comments

Comments
 (0)