Class Bdv
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.BrightnessScope, AbstractBigViewer.PathRenderingOptions, AbstractBigViewer.RecenterStrategy -
Field Summary
Fields inherited from class sc.fiji.snt.viewer.AbstractBigViewer
cal, calUnit, CLICK_MOVE_TOLERANCE_PX, dims, lastInstance, markerManager, NATIVE_KEYS_EXCLUDED_FROM_PALETTE, NATIVE_NAMES_EXCLUDED_FROM_PALETTE, renderedTrees, renderingOptions, secondaryLayerIndicator, snt, spimDataFilePaths, syncedPathManagerLabels, tracingCancelButton, tracingEnabled, tracingStatusBar, tracingUndoButton -
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 voidRecomputes the display range (brightness/contrast) for the source(s) selected byscope, from data percentiles, on a bounded background thread - seeAbstractBigViewer.initBrightnessSafely(bdv.viewer.ViewerState, bdv.viewer.ConverterSetups, java.lang.String).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.intReturns this viewer's current timepoint (1-based, matchingPath.getFrame()'s convention), or 1 if no data is loaded / timepoint tracking is unavailable.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.voidRemoves the secondary tracing data layer previously added byAbstractBigViewer.showSecondaryData()from this viewer, if one is currently displayed.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.voidForcessnt's image metadata (dimensions, calibration, pixel data, channel/frame) to be re-read from this viewer's currently activeSource, the same resyncAbstractBigViewer.AbstractTracerperforms on its own before starting a new path (seeAbstractTracer#syncChannelFromActiveSource()).voidsetCurrentTimepoint(int timepoint) Navigates this viewer to the specified timepoint (1-based, matchingPath.getFrame()'s convention).voidsetDisplayRadii(boolean display) Switches between frustum (radius-based) and centerline rendering.voidsetPathOverlayOffset(double offsetX, double offsetY, double offsetZ) Shifts all rendered trees by (offsetX, offsetY, offsetZ) in world coordinates, for rendering purposes only.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)).voidDisplays the main tracing data from the associated SNT instance.voidDisplays the secondary tracing data from the associated SNT instance.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.voidRefreshes the persistent "secondary layer active" indicator shown in this viewer's SNT Controls card, reflectingSNT.isTracingOnSecondaryImageActive().voidupdateStatus(String message, int step, int nSteps) Updates the persistent progress bar docked at the bottom of this viewer's card panel.Methods inherited from class sc.fiji.snt.viewer.AbstractBigViewer
add, add, add, addCollection, addToCardPanelBottom, addTree, addTree, applyBrightnessScope, autoBrightnessButton, blockMarkerPlacement, buildBaseSceneControlToolbar, clearAllTrees, flyTo, getBoundingBox, getCalibration, getMarkerManager, getPhysicalUnit, getPrimarySourcePath, getRenderedTrees, getSNT, getUniqueLabel, hasMarkerManager, initBrightnessSafely, initBrightnessSafely, optionsButton, registerCommandFinderAccelerator, registerNativeCommands, removeTree, setCalibration, showCalibrationDialog, syncPathManagerList, tracingStatusRow
-
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
-
showLoadedData
public void showLoadedData()Displays the main tracing data from the associated SNT instance. This method is only available for BDV instances that are tethered to an SNT instance.- Specified by:
showLoadedDatain classAbstractBigViewer- Throws:
IllegalArgumentException- if this is a standalone viewer or no valid image data is available
-
showSecondaryData
public void showSecondaryData()Displays the secondary tracing data from the associated SNT instance. This method is only available for BDV instances that are tethered to an SNT instance.- Specified by:
showSecondaryDatain classAbstractBigViewer- Throws:
IllegalArgumentException- if this is a standalone viewer or no valid image data is available
-
hideSecondaryData
public void hideSecondaryData()Description copied from class:AbstractBigViewerRemoves the secondary tracing data layer previously added byAbstractBigViewer.showSecondaryData()from this viewer, if one is currently displayed. No-op otherwise (e.g., standalone viewers, untethered instances, or when no secondary layer has been shown yet).- Specified by:
hideSecondaryDatain classAbstractBigViewer- See Also:
-
updateSecondaryLayerIndicator
public void updateSecondaryLayerIndicator()Description copied from class:AbstractBigViewerRefreshes the persistent "secondary layer active" indicator shown in this viewer's SNT Controls card, reflectingSNT.isTracingOnSecondaryImageActive(). No-op if this is not a tethered, tracer-enabled instance (i.e., the indicator was never built). Safe to call from any thread.- Specified by:
updateSecondaryLayerIndicatorin classAbstractBigViewer
-
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.This is bdv-core/bvv-core's fading toast: it auto-dismisses after a few seconds. For an ongoing, non-auto-dismissing indication of a long-running operation, use
AbstractBigViewer.updateStatus(java.lang.String, int, int)instead.- 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
-
updateStatus
Description copied from class:AbstractBigViewerUpdates the persistent progress bar docked at the bottom of this viewer's card panel. UnlikeAbstractBigViewer.showViewerMessage(java.lang.String), it stays visible until reset.nSteps = 0: hides the barnSteps < 0: indeterminate mode (animated, no percentage)nSteps > 0: determinate mode showingstep/nSteps
- Specified by:
updateStatusin classAbstractBigViewer- Parameters:
message- short status message displayed inside the barstep- current step (0-based; ignored in indeterminate mode)nSteps- total steps (0 = hide, negative = indeterminate)- See Also:
-
resyncCalibrationFromActiveSource
public void resyncCalibrationFromActiveSource()Description copied from class:AbstractBigViewerForcessnt's image metadata (dimensions, calibration, pixel data, channel/frame) to be re-read from this viewer's currently activeSource, the same resyncAbstractBigViewer.AbstractTracerperforms on its own before starting a new path (seeAbstractTracer#syncChannelFromActiveSource()).That resync is otherwise only triggered by the first click of a new path, so
snt's calibration can be stale (or still at whateverBigDataLoaderCmd's best-effort fallback produced at load time) for anything that reads it beforehand - such asSNT#buildMaterializedCrop(BoundingBox). Callers that need calibration to reflect exactly what this viewer is currently rendering, before the user has traced anything, should call this first.A no-op if no tracer has been created yet, or if the active source can't be resolved.
- Specified by:
resyncCalibrationFromActiveSourcein classAbstractBigViewer- See Also:
-
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
-
getCurrentTimepoint
public int getCurrentTimepoint()Description copied from class:AbstractBigViewerReturns this viewer's current timepoint (1-based, matchingPath.getFrame()'s convention), or 1 if no data is loaded / timepoint tracking is unavailable.- Specified by:
getCurrentTimepointin classAbstractBigViewer
-
setCurrentTimepoint
public void setCurrentTimepoint(int timepoint) Description copied from class:AbstractBigViewerNavigates this viewer to the specified timepoint (1-based, matchingPath.getFrame()'s convention). Does nothing if no data is loaded.- Specified by:
setCurrentTimepointin classAbstractBigViewer- Parameters:
timepoint- the 1-based timepoint to navigate to; values < 1 are coerced to 1
-
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). -
applyAutoBrightness
Description copied from class:AbstractBigViewerRecomputes the display range (brightness/contrast) for the source(s) selected byscope, from data percentiles, on a bounded background thread - seeAbstractBigViewer.initBrightnessSafely(bdv.viewer.ViewerState, bdv.viewer.ConverterSetups, java.lang.String). Called automatically withAbstractBigViewer.BrightnessScope.ALLright after a source is first added, and re-invocable on demand (any scope) via the "Auto Brightness/Contrast" scene-control button (seeAbstractBigViewer.autoBrightnessButton(sc.fiji.snt.viewer.AbstractBigViewer.Actions)). Does nothing if this viewer isn't yet backed by an underlying BDV/BVV scene (e.g.show(...)hasn't been called).- Specified by:
applyAutoBrightnessin classAbstractBigViewer- Parameters:
scope- which source(s) to recompute
-
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
-
setPathOverlayOffset
public void setPathOverlayOffset(double offsetX, double offsetY, double offsetZ) Shifts all rendered trees by (offsetX, offsetY, offsetZ) in world coordinates, for rendering purposes only.- Specified by:
setPathOverlayOffsetin 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).
-