Class Bdv


public class Bdv extends AbstractBigViewer
SNT's BigDataViewer-based 2D slice viewer.

Complements Bvv for images where orthographic 2D slice navigation is preferable over GPU volume rendering. Because BDV uses orthographic projection, cursor coordinates returned by AbstractViewerPanel.getGlobalMouseCoordinates(net.imglib2.RealPositionable) are unambiguous at the current slice depth, making marker placement more accurate than in BVV.

This class extends AbstractBigViewer and shares tree management, calibration, and bookmark infrastructure with Bvv.

Path and annotation overlays reuse Bvv.PathOverlay and Bvv.AnnotationOverlay via the BigViewerPanel adapter, with dCam = Double.MAX_VALUE so the perspective factor evaluates to 1.0 (orthographic rendering, no foreshortening).

Usage (scripting)

 bdv = new Bdv()
 bdv.show(imp)
 bdv.addTree(tree)
 bdv.getMarkerManager().toggleViewerPanel()
 
Author:
Tiago Ferreira
See Also:
  • Constructor Details

    • Bdv

      public Bdv()
      Creates a standalone BDV viewer (not tethered to an SNT instance).
    • Bdv

      public Bdv(SNT snt)
      Creates a BDV viewer tethered to an SNT instance.
  • Method Details

    • getInstance

      public static Bdv getInstance()
      Returns the most recently created Bdv instance, or null. Convenience accessor for scripts.
    • show

      public bdv.util.BdvStackSource<?> show(ij.ImagePlus imp)
      Opens an ImagePlus in the BDV viewer.
      Parameters:
      imp - the image to display
      Returns:
      the BdvStackSource for the displayed image
    • show

      public <T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>> bdv.util.BdvStackSource<?> show(net.imagej.ImgPlus<T> img)
      Opens a calibrated ImgPlus in the BDV viewer.
      Parameters:
      img - the image to display
      Returns:
      the BdvStackSource for the displayed image
    • show

      public <T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>> bdv.util.BdvStackSource<?> show(net.imglib2.RandomAccessibleInterval<T> rai, double... calibration)
      Opens a 3D RAI with explicit calibration in the BDV viewer.
      Parameters:
      rai - the 3D volume
      calibration - voxel sizes [x, y, z]
      Returns:
      the BdvStackSource for the displayed image
    • show

      public List<bdv.util.BdvStackSource<?>> show(mpicbg.spim.data.generic.AbstractSpimData<?> spimData)
      Opens a SpimData dataset (HDF5/N5/Zarr/IMS/OME-TIFF via XML) in the BDV viewer. Populates AbstractBigViewer.cal, AbstractBigViewer.dims, and AbstractBigViewer.calUnit from the first setup's metadata so that calibration is available for tree/marker rendering.
      Parameters:
      spimData - the dataset to display
      Returns:
      list of BdvStackSources, one per setup, in setup order
    • show

      public List<bdv.util.BdvStackSource<?>> show(mpicbg.spim.data.generic.AbstractSpimData<?> spimData, String sourcePath)
      Opens a SpimData dataset and records its source file path for later reference (e.g., for export or re-opening). Delegates to show(AbstractSpimData).
      Parameters:
      spimData - the dataset to display
      sourcePath - the absolute file path from which spimData was loaded; ignored if null or blank
      Returns:
      list of BdvStackSources, one per setup
    • show

      public List<bdv.util.BdvStackSource<?>> show(SpimDataUtils.N5Sources n5Sources)
      Opens sources loaded from an N5 or OME-Zarr container (see SpimDataUtils.resolvePathToSource(String)). Unlike show(AbstractSpimData), there is no BDV-XML descriptor or AbstractSpimData involved: sources are built directly from the container's own N5/OME-NGFF metadata via n5-viewer_fiji.
      Parameters:
      n5Sources - the sources to display
      Returns:
      list of BdvStackSources, one per setup
    • getViewerFrame

      public bdv.viewer.ViewerFrame getViewerFrame()
      Description copied from class: AbstractBigViewer
      Returns the top-level Swing window for this viewer, or null if not yet open.
      Specified by:
      getViewerFrame in class AbstractBigViewer
    • getViewerSplitPanel

      protected JSplitPane getViewerSplitPanel()
      Description copied from class: AbstractBigViewer
      Returns the JSplitPane that separates the viewer canvas from the card panel. Both BDV and BVV frames expose this via their own getSplitPanel() methods, but those classes share no common supertype above JFrame, so this method lets subclasses expose the split pane without the abstract method returning a viewer-specific frame type.
      Specified by:
      getViewerSplitPanel in class AbstractBigViewer
    • getViewerWidth

      public int getViewerWidth()
      Description copied from class: AbstractBigViewer
      Returns the width of the viewer canvas in logical pixels, or 0 if the viewer is not yet initialized.
      Specified by:
      getViewerWidth in class AbstractBigViewer
    • getViewerHeight

      public int getViewerHeight()
      Description copied from class: AbstractBigViewer
      Returns the height of the viewer canvas in logical pixels, or 0 if the viewer is not yet initialized.
      Specified by:
      getViewerHeight in class AbstractBigViewer
    • getViewerTransform

      public net.imglib2.realtransform.AffineTransform3D getViewerTransform()
      Description copied from class: AbstractBigViewer
      Returns a snapshot of the current viewer-to-screen (world-to-screen) transform. The returned object is a copy; callers may modify it freely.
      Specified by:
      getViewerTransform in class AbstractBigViewer
    • setViewerTransform

      public void setViewerTransform(net.imglib2.realtransform.AffineTransform3D target, long durationMs)
      Description copied from class: AbstractBigViewer
      Animates the viewer transform to target over durationMs milliseconds. Use durationMs = 0 for an immediate jump.
      Specified by:
      setViewerTransform in class AbstractBigViewer
      Parameters:
      target - the desired world-to-screen transform
      durationMs - animation duration in milliseconds (0 = immediate)
    • showViewerMessage

      public void showViewerMessage(String msg)
      Description copied from class: AbstractBigViewer
      Displays a short status message in the viewer's overlay area.
      Specified by:
      showViewerMessage in class AbstractBigViewer
      Parameters:
      msg - the message to show
    • getGlobalMouseCoordinates

      public void getGlobalMouseCoordinates(net.imglib2.RealPoint pos)
      Description copied from class: AbstractBigViewer
      Writes the current global (world-space) mouse position into pos. Callers must supply a pre-allocated RealPoint with at least 3 dimensions.
      Specified by:
      getGlobalMouseCoordinates in class AbstractBigViewer
      Parameters:
      pos - 3D point to receive the world-space cursor position
    • getCurrentSource

      protected bdv.viewer.SourceAndConverter<?> getCurrentSource()
      Description copied from class: AbstractBigViewer
      Returns the currently active source, or null if none.
      Specified by:
      getCurrentSource in class AbstractBigViewer
    • getViewerAction

      protected Action getViewerAction(String name)
      Description copied from class: AbstractBigViewer
      Looks up a named action from the viewer's keybindings action map. Returns null if the action is not registered or the viewer is not ready.
      Specified by:
      getViewerAction in class AbstractBigViewer
      Parameters:
      name - the action key (e.g., "align XY plane")
    • addMouseListenerToDisplay

      public void addMouseListenerToDisplay(MouseListener ml)
      Description copied from class: AbstractBigViewer
      Adds a mouse listener to the viewer's canvas component so that click events on the display surface can be handled (e.g. for hit testing annotation markers).
      Specified by:
      addMouseListenerToDisplay in class AbstractBigViewer
      Parameters:
      ml - the listener to add
    • resetView

      public void resetView()
      Description copied from class: AbstractBigViewer
      Resets the view to frame all loaded data.
      Specified by:
      resetView in class AbstractBigViewer
    • isOpen

      public boolean isOpen()
      Description copied from class: AbstractBigViewer
      Returns true if the viewer window is currently visible and usable.
      Specified by:
      isOpen in class AbstractBigViewer
    • repaint

      public void repaint()
      Description copied from class: AbstractBigViewer
      Requests a repaint of the viewer canvas.
      Specified by:
      repaint in class AbstractBigViewer
    • syncOverlays

      public void syncOverlays()
      Description copied from class: AbstractBigViewer
      Synchronizes all active rendering overlays (paths, markers) with the current state of AbstractBigViewer.renderedTrees and any pending annotation changes.
      Specified by:
      syncOverlays in class AbstractBigViewer
    • annotations

      public Bvv.AnnotationOverlay annotations()
      Description copied from class: AbstractBigViewer
      Returns the annotation overlay for this viewer. The overlay renders point markers in the viewer's world coordinate space. May return null if the viewer has not been opened yet.
      Specified by:
      annotations in class AbstractBigViewer
    • getDefaultMarkerSize

      public float getDefaultMarkerSize()
      Description copied from class: AbstractBigViewer
      Returns the default sphere radius (in physical units) for newly placed markers. Implementations typically derive this from their rendering-options or a sensible default.
      Specified by:
      getDefaultMarkerSize in class AbstractBigViewer
    • getDefaultMarkerColor

      public Color getDefaultMarkerColor()
      Description copied from class: AbstractBigViewer
      Returns the default color for newly placed markers, or null to use the viewer's own fallback color.
      Specified by:
      getDefaultMarkerColor in class AbstractBigViewer
    • createMarkerManager

      protected BookmarkManager createMarkerManager()
      Description copied from class: AbstractBigViewer
      Creates and returns a new BookmarkManager for this viewer. Called exactly once (lazily) by AbstractBigViewer.getMarkerManager().
      Specified by:
      createMarkerManager in class AbstractBigViewer
    • getBdvHandle

      public bdv.util.BdvHandle getBdvHandle()
      Returns the underlying BdvHandle that manages sources and the viewer state.
    • getViewerPanel

      public bdv.viewer.ViewerPanel getViewerPanel()
      Returns the BDV display panel. Unlike BVV, BDV uses a ViewerPanel (orthographic slice viewer).
    • getRenderingOptions

      public AbstractBigViewer.PathRenderingOptions getRenderingOptions()
      Returns the rendering options controlling path thickness, transparency, etc. For BDV, slab clipping options have no effect (slab mode is BVV-only).
      Overrides:
      getRenderingOptions in class AbstractBigViewer
    • setCanvasOffset

      public void setCanvasOffset(double offsetX, double offsetY, double offsetZ)
      Shifts all rendered trees by (offsetX, offsetY, offsetZ) in world coordinates and records the offset in the rendering options so it survives a syncOverlays() call.
      Specified by:
      setCanvasOffset in class AbstractBigViewer
      Parameters:
      offsetX - x offset in calibrated units
      offsetY - y offset in calibrated units
      offsetZ - z offset in calibrated units
    • isPathRenderingEnabled

      protected boolean isPathRenderingEnabled()
      Description copied from class: AbstractBigViewer
      Returns true if path/tree overlay rendering is currently enabled.
      Specified by:
      isPathRenderingEnabled in class AbstractBigViewer
    • setPathRenderingEnabled

      protected void setPathRenderingEnabled(boolean enabled)
      Description copied from class: AbstractBigViewer
      Enables or disables path/tree overlay rendering.
      Specified by:
      setPathRenderingEnabled in class AbstractBigViewer
    • setDisplayRadii

      public void setDisplayRadii(boolean display)
      Switches between frustum (radius-based) and centerline rendering. Invalidates the overlay cache and requests a repaint.
      Specified by:
      setDisplayRadii in class AbstractBigViewer
      Parameters:
      display - true to render frusta using per-node radii; false for fast centerline rendering
    • getDisplayRadii

      public boolean getDisplayRadii()
      Returns whether paths are rendered as frusta (true) or centerlines (false).