Package sc.fiji.snt.viewer
Class Bdv
java.lang.Object
sc.fiji.snt.viewer.AbstractBigViewer
sc.fiji.snt.viewer.Bdv
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class sc.fiji.snt.viewer.AbstractBigViewer
AbstractBigViewer.AbstractTracer, AbstractBigViewer.Actions, AbstractBigViewer.AnnotationOverlay, AbstractBigViewer.PathRenderingOptions, AbstractBigViewer.RecenterStrategy -
Field Summary
Fields inherited from class sc.fiji.snt.viewer.AbstractBigViewer
cal, calUnit, CLICK_MOVE_TOLERANCE_PX, dims, lastInstance, markerManager, renderedTrees, renderingOptions, snt, spimDataFilePaths, syncedPathManagerLabels, tracingEnabled -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds 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).Returns the annotation overlay for this viewer.protected BookmarkManagerCreates and returns a newBookmarkManagerfor this viewer.bdv.util.BdvHandleReturns the underlyingBdvHandlethat manages sources and the viewer state.protected bdv.viewer.SourceAndConverter<?> Returns the currently active source, or null if none.Returns the default color for newly placed markers, or null to use the viewer's own fallback color.floatReturns the default sphere radius (in physical units) for newly placed markers.booleanReturns whether paths are rendered as frusta (true) or centerlines (false).voidgetGlobalMouseCoordinates(net.imglib2.RealPoint pos) Writes the current global (world-space) mouse position intopos.static BdvReturns the most recently createdBdvinstance, ornull.Returns the rendering options controlling path thickness, transparency, etc.protected ActiongetViewerAction(String name) Looks up a named action from the viewer's keybindings action map.bdv.viewer.ViewerFrameReturns the top-level Swing window for this viewer, or null if not yet open.intReturns the height of the viewer canvas in logical pixels, or 0 if the viewer is not yet initialized.bdv.viewer.ViewerPanelReturns the BDV display panel.protected JSplitPaneReturns the JSplitPane that separates the viewer canvas from the card panel.net.imglib2.realtransform.AffineTransform3DReturns a snapshot of the current viewer-to-screen (world-to-screen) transform.intReturns the width of the viewer canvas in logical pixels, or 0 if the viewer is not yet initialized.booleanisOpen()Returns true if the viewer window is currently visible and usable.protected booleanReturns true if path/tree overlay rendering is currently enabled.voidrepaint()Requests a repaint of the viewer canvas.voidResets the view to frame all loaded data.voidsetCanvasOffset(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.voidsetDisplayRadii(boolean display) Switches between frustum (radius-based) and centerline rendering.protected voidsetPathRenderingEnabled(boolean enabled) Enables or disables path/tree overlay rendering.voidsetViewerTransform(net.imglib2.realtransform.AffineTransform3D target, long durationMs) Animates the viewer transform totargetoverdurationMsmilliseconds.bdv.util.BdvStackSource<?> show(ij.ImagePlus imp) Opens an ImagePlus in the BDV viewer.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.List<bdv.util.BdvStackSource<?>> Opens a SpimData dataset and records its source file path for later reference (e.g., for export or re-opening).<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.<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.List<bdv.util.BdvStackSource<?>> show(SpimDataUtils.N5Sources n5Sources) Opens sources loaded from an N5 or OME-Zarr container (seeSpimDataUtils.resolvePathToSource(String)).voidshowViewerMessage(String msg) Displays a short status message in the viewer's overlay area.voidSynchronizes all active rendering overlays (paths, markers) with the current state ofAbstractBigViewer.renderedTreesand any pending annotation changes.Methods inherited from class sc.fiji.snt.viewer.AbstractBigViewer
add, add, add, addCollection, addTree, addTree, buildBaseSceneControlToolbar, clearAllTrees, getCalibration, getCalUnit, getMarkerManager, getPhysicalUnit, getRenderedTrees, getSNT, getUniqueLabel, registerMarkerKeyBinding, removeTree, setCalibration, showCalibrationDialog, syncPathManagerList
-
Constructor Details
-
Bdv
public Bdv()Creates a standalone BDV viewer (not tethered to an SNT instance). -
Bdv
Creates a BDV viewer tethered to an SNT instance.
-
-
Method Details
-
getInstance
Returns the most recently createdBdvinstance, ornull. 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 volumecalibration- voxel sizes [x, y, z]- Returns:
- the BdvStackSource for the displayed image
-
show
Opens a SpimData dataset (HDF5/N5/Zarr/IMS/OME-TIFF via XML) in the BDV viewer. PopulatesAbstractBigViewer.cal,AbstractBigViewer.dims, andAbstractBigViewer.calUnitfrom 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 toshow(AbstractSpimData).- Parameters:
spimData- the dataset to displaysourcePath- the absolute file path from which spimData was loaded; ignored if null or blank- Returns:
- list of BdvStackSources, one per setup
-
show
Opens sources loaded from an N5 or OME-Zarr container (seeSpimDataUtils.resolvePathToSource(String)). Unlikeshow(AbstractSpimData), there is no BDV-XML descriptor orAbstractSpimDatainvolved: sources are built directly from the container's own N5/OME-NGFF metadata vian5-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:AbstractBigViewerReturns the top-level Swing window for this viewer, or null if not yet open.- Specified by:
getViewerFramein classAbstractBigViewer
-
getViewerSplitPanel
Description copied from class:AbstractBigViewerReturns 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:
getViewerSplitPanelin classAbstractBigViewer
-
getViewerWidth
public int getViewerWidth()Description copied from class:AbstractBigViewerReturns the width of the viewer canvas in logical pixels, or 0 if the viewer is not yet initialized.- Specified by:
getViewerWidthin classAbstractBigViewer
-
getViewerHeight
public int getViewerHeight()Description copied from class:AbstractBigViewerReturns the height of the viewer canvas in logical pixels, or 0 if the viewer is not yet initialized.- Specified by:
getViewerHeightin classAbstractBigViewer
-
getViewerTransform
public net.imglib2.realtransform.AffineTransform3D getViewerTransform()Description copied from class:AbstractBigViewerReturns 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:
getViewerTransformin classAbstractBigViewer
-
setViewerTransform
public void setViewerTransform(net.imglib2.realtransform.AffineTransform3D target, long durationMs) Description copied from class:AbstractBigViewerAnimates the viewer transform totargetoverdurationMsmilliseconds. UsedurationMs = 0for an immediate jump.- Specified by:
setViewerTransformin classAbstractBigViewer- Parameters:
target- the desired world-to-screen transformdurationMs- animation duration in milliseconds (0 = immediate)
-
showViewerMessage
Description copied from class:AbstractBigViewerDisplays a short status message in the viewer's overlay area.- Specified by:
showViewerMessagein classAbstractBigViewer- Parameters:
msg- the message to show
-
getGlobalMouseCoordinates
public void getGlobalMouseCoordinates(net.imglib2.RealPoint pos) Description copied from class:AbstractBigViewerWrites the current global (world-space) mouse position intopos. Callers must supply a pre-allocatedRealPointwith at least 3 dimensions.- Specified by:
getGlobalMouseCoordinatesin classAbstractBigViewer- Parameters:
pos- 3D point to receive the world-space cursor position
-
getCurrentSource
protected bdv.viewer.SourceAndConverter<?> getCurrentSource()Description copied from class:AbstractBigViewerReturns the currently active source, or null if none.- Specified by:
getCurrentSourcein classAbstractBigViewer
-
getViewerAction
Description copied from class:AbstractBigViewerLooks 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:
getViewerActionin classAbstractBigViewer- Parameters:
name- the action key (e.g., "align XY plane")
-
addMouseListenerToDisplay
Description copied from class:AbstractBigViewerAdds 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:
addMouseListenerToDisplayin classAbstractBigViewer- Parameters:
ml- the listener to add
-
resetView
public void resetView()Description copied from class:AbstractBigViewerResets the view to frame all loaded data.- Specified by:
resetViewin classAbstractBigViewer
-
isOpen
public boolean isOpen()Description copied from class:AbstractBigViewerReturns true if the viewer window is currently visible and usable.- Specified by:
isOpenin classAbstractBigViewer
-
repaint
public void repaint()Description copied from class:AbstractBigViewerRequests a repaint of the viewer canvas.- Specified by:
repaintin classAbstractBigViewer
-
syncOverlays
public void syncOverlays()Description copied from class:AbstractBigViewerSynchronizes all active rendering overlays (paths, markers) with the current state ofAbstractBigViewer.renderedTreesand any pending annotation changes.- Specified by:
syncOverlaysin classAbstractBigViewer
-
annotations
Description copied from class:AbstractBigViewerReturns 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:
annotationsin classAbstractBigViewer
-
getDefaultMarkerSize
public float getDefaultMarkerSize()Description copied from class:AbstractBigViewerReturns 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:
getDefaultMarkerSizein classAbstractBigViewer
-
getDefaultMarkerColor
Description copied from class:AbstractBigViewerReturns the default color for newly placed markers, or null to use the viewer's own fallback color.- Specified by:
getDefaultMarkerColorin classAbstractBigViewer
-
createMarkerManager
Description copied from class:AbstractBigViewerCreates and returns a newBookmarkManagerfor this viewer. Called exactly once (lazily) byAbstractBigViewer.getMarkerManager().- Specified by:
createMarkerManagerin classAbstractBigViewer
-
getBdvHandle
public bdv.util.BdvHandle getBdvHandle()Returns the underlyingBdvHandlethat manages sources and the viewer state. -
getViewerPanel
public bdv.viewer.ViewerPanel getViewerPanel()Returns the BDV display panel. Unlike BVV, BDV uses aViewerPanel(orthographic slice viewer). -
getRenderingOptions
Returns the rendering options controlling path thickness, transparency, etc. For BDV, slab clipping options have no effect (slab mode is BVV-only).- Overrides:
getRenderingOptionsin classAbstractBigViewer
-
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:
setCanvasOffsetin classAbstractBigViewer- Parameters:
offsetX- x offset in calibrated unitsoffsetY- y offset in calibrated unitsoffsetZ- z offset in calibrated units
-
isPathRenderingEnabled
protected boolean isPathRenderingEnabled()Description copied from class:AbstractBigViewerReturns true if path/tree overlay rendering is currently enabled.- Specified by:
isPathRenderingEnabledin classAbstractBigViewer
-
setPathRenderingEnabled
protected void setPathRenderingEnabled(boolean enabled) Description copied from class:AbstractBigViewerEnables or disables path/tree overlay rendering.- Specified by:
setPathRenderingEnabledin classAbstractBigViewer
-
setDisplayRadii
public void setDisplayRadii(boolean display) Switches between frustum (radius-based) and centerline rendering. Invalidates the overlay cache and requests a repaint.- Specified by:
setDisplayRadiiin classAbstractBigViewer- Parameters:
display-trueto render frusta using per-node radii;falsefor fast centerline rendering
-
getDisplayRadii
public boolean getDisplayRadii()Returns whether paths are rendered as frusta (true) or centerlines (false).
-