|
23 | 23 | package sc.fiji.snt.viewer; |
24 | 24 |
|
25 | 25 | import bdv.tools.InitializeViewerState; |
| 26 | +import bdv.viewer.ViewerFrame; |
26 | 27 | import mpicbg.spim.data.generic.AbstractSpimData; |
27 | 28 | import net.imglib2.type.numeric.NumericType; |
28 | 29 | import sc.fiji.snt.*; |
@@ -147,11 +148,8 @@ public BdvStackSource<?> show(final ImagePlus imp) { |
147 | 148 | final BdvOptions chOpts = (firstSrc == null) |
148 | 149 | ? baseOpts() |
149 | 150 | : BdvOptions.options().addTo(bdvHandle); |
150 | | - // BDV requires 3D sources; add singleton Z for 2D images |
151 | | - RandomAccessibleInterval<?> chRai = ImpUtils.toImgPlus(ch); |
152 | | - if (chRai.numDimensions() < 3) chRai = Views.addDimension(chRai, 0, 0); |
153 | 151 | final BdvStackSource<?> cs = showCalibratedBdvSource( |
154 | | - chRai, imp.getTitle() + " [C" + c + "]", chOpts); |
| 152 | + ImpUtils.toImgPlus(ch), imp.getTitle() + " [C" + c + "]", chOpts); |
155 | 153 | if (firstSrc == null) { |
156 | 154 | firstSrc = cs; |
157 | 155 | if (bdvHandle == null) { |
@@ -214,9 +212,7 @@ public <T extends RealType<T> & NativeType<T>> BdvStackSource<?> show(final ImgP |
214 | 212 | BdvStackSource<?> firstSrc = null; |
215 | 213 | final int nC = (int) img.dimension(chDim); |
216 | 214 | for (int c = 0; c < nC; c++) { |
217 | | - // BDV requires 3D sources; add singleton Z for 2D images |
218 | | - RandomAccessibleInterval<T> ch = Views.hyperSlice(img, chDim, c); |
219 | | - if (ch.numDimensions() < 3) ch = Views.addDimension(ch, 0, 0); |
| 215 | + final RandomAccessibleInterval<T> ch = Views.hyperSlice(img, chDim, c); |
220 | 216 | final BdvOptions chOpts = (firstSrc == null) |
221 | 217 | ? baseOpts().sourceTransform(calToTransform()) |
222 | 218 | : BdvOptions.options().addTo(bdvHandle).sourceTransform(calToTransform()); |
@@ -324,9 +320,15 @@ public List<BdvStackSource<?>> show(final AbstractSpimData<?> spimData, final St |
324 | 320 | } |
325 | 321 |
|
326 | 322 | @Override |
327 | | - public JFrame getViewerFrame() { |
328 | | - return (bdvHandle == null) ? null |
329 | | - : bdvHandle.getSplitPanel().getTopLevelAncestor() instanceof JFrame f ? f : null; |
| 323 | + public ViewerFrame getViewerFrame() { |
| 324 | + if (bdvHandle == null) return null; |
| 325 | + final java.awt.Container top = bdvHandle.getSplitPanel().getTopLevelAncestor(); |
| 326 | + return (top instanceof ViewerFrame f) ? f : null; |
| 327 | + } |
| 328 | + |
| 329 | + @Override |
| 330 | + protected JSplitPane getViewerSplitPanel() { |
| 331 | + return (bdvHandle == null) ? null : bdvHandle.getSplitPanel(); |
330 | 332 | } |
331 | 333 |
|
332 | 334 | @Override |
@@ -561,9 +563,12 @@ private BdvStackSource<?> showCalibratedBdvSource( |
561 | 563 | final RandomAccessibleInterval<?> rai, |
562 | 564 | final String name, |
563 | 565 | final BdvOptions opts) { |
| 566 | + // BDV's renderer always calls realMax(2); add a singleton Z for 2D inputs |
| 567 | + final RandomAccessibleInterval<?> rai3d = (rai.numDimensions() < 3) |
| 568 | + ? Views.addDimension(rai, 0, 0) : rai; |
564 | 569 | final SpimDataUtils.CalibratedSource src = |
565 | 570 | new SpimDataUtils.CalibratedSource( |
566 | | - rai, (NumericType) rai.getType(), calToTransform(), name, |
| 571 | + rai3d, (NumericType) rai3d.getType(), calToTransform(), name, |
567 | 572 | cal != null ? cal : new double[]{1, 1, 1}, |
568 | 573 | calUnit != null ? calUnit : "pixel"); |
569 | 574 | return BdvFunctions.show(src, 1, opts); |
@@ -601,11 +606,12 @@ private void initializeCardPanel() { |
601 | 606 | if (cp != null) { |
602 | 607 | cp.addCard("Scene Controls", buildSceneControlToolbar(), true); |
603 | 608 | cp.addCard("SNT Annotations", sntAnnotationsCard(actions), true); |
604 | | - cp.setCardExpanded("Groups", false); |
605 | 609 | SwingUtilities.invokeLater(() -> { |
| 610 | + cp.setCardExpanded("Groups", false); |
606 | 611 | cp.setCardExpanded("Scene Controls", true); |
607 | 612 | cp.setCardExpanded("SNT Annotations", true); |
608 | 613 | }); |
| 614 | + resizeCardPanelsAsNeeded(cp.getComponent()); |
609 | 615 | } |
610 | 616 |
|
611 | 617 | // M and H keys via BDV's keybindings system so the trigger layer sees them |
@@ -874,7 +880,7 @@ public void actionPerformed(final java.awt.event.ActionEvent e) { |
874 | 880 | } |
875 | 881 |
|
876 | 882 | Action syncPathManagerAction() { |
877 | | - return new AbstractAction("Sync Path Manager Changes", IconFactory.menuIcon(IconFactory.GLYPH.REDO)) { |
| 883 | + return new AbstractAction("Sync Path Manager Changes", IconFactory.menuIcon(IconFactory.GLYPH.SYNC)) { |
878 | 884 | @Override |
879 | 885 | public void actionPerformed(final java.awt.event.ActionEvent e) { |
880 | 886 | if (syncPathManagerList()) { |
|
0 commit comments