Class AbstractBigViewer
Bvv, Bdv, etc.).
Provides shared infrastructure for tree/path management, calibration, and bookmark support, leaving viewer-specific rendering, source loading, and camera control to concrete subclasses.
The AbstractBigViewer.AnnotationOverlay interface defined here is the common contract that
all viewer overlays must satisfy so that BookmarkManager can drive them
without knowing the concrete viewer type.
- Author:
- Tiago Ferreira
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classViewer-agnostic tracing state machine shared byBvvandBdv: manual/A*-assisted path construction from mouse clicks, fork-point resolution against currently rendered paths, single-step segment undo, and the batch-retrace channel/frame lock (seeSNT.getBatchRetraceChannelFrame()).protected classstatic interfaceCommon contract for all viewer annotation overlays.protected static enumScope forapplyAutoBrightness(BrightnessScope): which source(s) to recompute.static classConfiguration options for path rendering.static enumAuto-recenter strategy for BVV's per-click "center the view on the clicked point" behavior (seeBvv#registerCenterOnDoubleClickListener). -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double[]Voxel sizes [x, y, z] for the primary loaded volume, incalUnitunits.protected StringPhysical unit for calibration values (e.g., "um", "pixel").protected static final intprotected long[]Pixel dimensions [x, y, z] of the primary loaded volume.protected static AbstractBigViewerMost recently instantiated viewer; scripting convenience.protected BookmarkManagerLazily initialized bookmark/marker manager panel.protected static final KeyStroke[]Keystrokes bound to BDV/BVV native commands intentionally kept out of the command palette byregisterNativeCommands(sc.fiji.snt.gui.SNTCommandFinder, javax.swing.ActionMap, javax.swing.InputMap, java.util.List<java.lang.String>, javax.swing.Icon, java.util.Set<java.lang.String>, javax.swing.KeyStroke...): per-source selection/visibility digits, continuous pan/zoom/ rotate stepping, timepoint stepping, and bookmark set/recall/rotation.Action-map keys thatregisterNativeCommands(sc.fiji.snt.gui.SNTCommandFinder, javax.swing.ActionMap, javax.swing.InputMap, java.util.List<java.lang.String>, javax.swing.Icon, java.util.Set<java.lang.String>, javax.swing.KeyStroke...)should always skip, shared by every BDV/BVV-family viewer: natives that only make sense mid-gesture (aborting an in-progress bookmark placement or manual transform, neither of which has a dedicated trigger key of its own), and SNT's own press/release-pair or modal-pick overlays -- present under the same literal keys in bothBvvandBdv-- which are meaningless as a one-shot palette command (see, e.g.,Actions#hideAnnotationsPressAction).Trees currently rendered in this viewer, keyed by unique display label.protected AbstractBigViewer.PathRenderingOptionsRendering options shared across all path/annotation overlays in this viewer.protected JToggleButtonprotected final SNTThe SNT instance this viewer is tethered to, or null if no SNT instance is available.Maps SpimData sources back to the file that produced them.Labels of the trees rendered by the lastsyncPathManagerList()call.protected JButtonprotected booleanprotected JProgressBarprotected JButton -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidLoads reconstruction files (SWC, JSON, TRACES) and adds them to the viewer.voidScript-friendly dispatcher: accepts aTree,DirectedWeightedGraph,File[], or anyCollectionof supported objects.protected voidInternal dispatcher with deferred sync support for batch operations.protected voidaddCollection(Collection<?> collection, boolean syncNow) Adds all elements of a collection, optionally syncing once at the end.abstract voidAdds 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).protected static voidaddToCardPanelBottom(bdv.ui.CardPanel cardPanel, JComponent comp) Docks a component at the bottom of aCardPanel, below all cards, without a card header.voidAdds a Tree to the viewer overlay, assigning it a unique display label.protected voidInternal add with optional immediate overlay sync.abstract AbstractBigViewer.AnnotationOverlayReturns the annotation overlay for this viewer.protected abstract voidRecomputes the display range (brightness/contrast) for the source(s) selected byscope, from data percentiles, on a bounded background thread - seeinitBrightnessSafely(bdv.viewer.ViewerState, bdv.viewer.ConverterSetups, java.lang.String).protected static voidapplyBrightnessScope(AbstractBigViewer.BrightnessScope scope, bdv.viewer.ViewerState state, bdv.viewer.ConverterSetups setups, bdv.viewer.SourceAndConverter<?> currentSource, String label) DispatchesapplyAutoBrightness(BrightnessScope)for a given scope: the singlecurrent source, every currently active source (ViewerState.isSourceActive(bdv.viewer.SourceAndConverter<?>)), or (forAbstractBigViewer.BrightnessScope.ALL) the whole scene via the aggregateinitBrightnessSafely(bdv.viewer.ViewerState, bdv.viewer.ConverterSetups, String).protected JButtonBuilds the "Auto Brightness/Contrast" options button (Current Source...protected booleanWhetherM-key marker placement should be blocked in the current mode, showing a viewer message if so.protected JToolBarBuilds the shared scene-control toolbar: fit-source button, align-plane buttons (XY, XZ, YZ), minimap toggle, text-overlay toggle, scale-bar toggle.voidRemoves all rendered trees from the overlay.protected abstract BookmarkManagerCreates and returns a newBookmarkManagerfor this viewer.booleanflyTo(BoundingBox box) Animates the camera to frame the given world-coordinate bounding box: an isotropic scale is computed so the box's width/height fit the viewport, and the transform is translated to center the box's centroid on screen.Returns the world-space bounding box of the primary loaded volume, assuming an origin at (0,0,0), i.e., noworld-origin offsetor per-source transform is factored in.double[]Returns the current voxel sizes, or null if not set.protected abstract bdv.viewer.SourceAndConverter<?> Returns the currently active source, or null if none.abstract intReturns this viewer's current timepoint (1-based, matchingPath.getFrame()'s convention), or 1 if no data is loaded / timepoint tracking is unavailable.abstract ColorReturns the default color for newly placed markers, or null to use the viewer's own fallback color.abstract floatReturns the default sphere radius (in physical units) for newly placed markers.abstract voidgetGlobalMouseCoordinates(net.imglib2.RealPoint pos) Writes the current global (world-space) mouse position intopos.Returns the marker manager panel, creating it lazily on first call viacreateMarkerManager().Derives the best available physical unit string.Returns the file path/URL of the primary loaded volume, for display/logging purposes (e.g., a Notes entry documenting the dataset being traced).Returns a snapshot of the currently rendered trees (insertion order).Returns the rendering options shared across this viewer's overlays.getSNT()protected StringgetUniqueLabel(Tree tree) Returns a display label for the tree that is unique withinrenderedTrees.protected abstract ActiongetViewerAction(String name) Looks up a named action from the viewer's keybindings action map.abstract JFrameReturns the top-level Swing window for this viewer, or null if not yet open.abstract intReturns the height of the viewer canvas in logical pixels, or 0 if the viewer is not yet initialized.protected abstract JSplitPaneReturns the JSplitPane that separates the viewer canvas from the card panel.abstract net.imglib2.realtransform.AffineTransform3DReturns a snapshot of the current viewer-to-screen (world-to-screen) transform.abstract intReturns the width of the viewer canvas in logical pixels, or 0 if the viewer is not yet initialized.booleanChecks whether aBookmarkManagerhas already been created for this viewer, without triggering its (lazy, non-trivial) creation asgetMarkerManager()would.abstract voidRemoves the secondary tracing data layer previously added byshowSecondaryData()from this viewer, if one is currently displayed.protected static voidinitBrightnessSafely(bdv.viewer.SourceAndConverter<?> source, bdv.tools.brightness.ConverterSetup setup, int timepoint, String label) protected static voidinitBrightnessSafely(bdv.viewer.ViewerState state, bdv.viewer.ConverterSetups setups, String label) Computes and applies a display range from data percentiles (InitializeViewerState.initBrightness(double, double, bdv.viewer.ViewerFrame)) on a bounded background thread so that a remote N5/Zarr/SPIM data hit by a bad chunk or network stall cannot block the caller indefinitely (seeSNTUtils.runWithTimeout(java.util.concurrent.Callable<T>, long, java.lang.String)).abstract booleanisOpen()Returns true if the viewer window is currently visible and usable.protected abstract booleanReturns true if path/tree overlay rendering is currently enabled.protected JButtonoptionsButton(AbstractBigViewer.Actions actions) Builds the "Options" button (Import Reconstructions...protected static voidregisterCommandFinderAccelerator(InputMap sntIMap, ActionMap sntAMap, SNTCommandFinder commandFinder) WirescommandFinder's own show/toggle shortcut (SNTCommandFinder.getAccelerator()) into this viewer's keybindings, so it fires while the Bvv/Bdv window itself has focus.protected voidregisterNativeCommands(SNTCommandFinder commandFinder, ActionMap actionMap, InputMap inputMap, List<String> path, Icon icon, Set<String> excludedNames, KeyStroke... excludedTriggers) Registers this viewer's native (library-level) single-shot commands -- i.e., entries of the BDV/BVV keybindingsActionMap, as opposed to SNT's own overlaid commands (seeAbstractBigViewer.Actions) -- incommandFinder, so they become searchable/runnable from the command palette.booleanremoveTree(String treeLabel) Removes the tree with the given label from the overlay.abstract voidrepaint()Requests a repaint of the viewer canvas.abstract voidResets the view to frame all loaded data.abstract 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()).voidsetCalibration(double[] spacing, String unit) Sets the voxel calibration for the viewer.abstract voidsetCurrentTimepoint(int timepoint) Navigates this viewer to the specified timepoint (1-based, matchingPath.getFrame()'s convention).abstract voidsetDisplayRadii(boolean display) Sets whether paths are rendered as frusta (tubes) or simple centerlines, and triggers an overlay cache invalidation.abstract voidsetPathOverlayOffset(double offsetX, double offsetY, double offsetZ) Applies a world-space offset to all rendered path annotations.protected abstract voidsetPathRenderingEnabled(boolean enabled) Enables or disables path/tree overlay rendering.abstract voidsetViewerTransform(net.imglib2.realtransform.AffineTransform3D target, long durationMs) Animates the viewer transform totargetoverdurationMsmilliseconds.voidshowCalibrationDialog(Component parent) Prompts the user for voxel spacing and its physical unit, and updates calibration.abstract voidDisplays the main tracing data (the currently active channel/frame of the image being traced) from the associated SNT instance.abstract voidDisplays the secondary tracing data (the filtered/processed layer used for cost-function-based tracing) from the associated SNT instance.abstract voidshowViewerMessage(String msg) Displays a short status message in the viewer's overlay area.abstract voidSynchronizes all active rendering overlays (paths, markers) with the current state ofrenderedTreesand any pending annotation changes.booleanReplaces the rendered trees with the current contents of the Path Manager.protected JComponenttracingStatusRow(AbstractBigViewer.Actions actions, AbstractBigViewer.AbstractTracer tracer) Builds the second row shown below the SNT Annotations toolbar whenever this viewer has an activeAbstractBigViewer.AbstractTracer(undo/cancel controls, secondary-layer toggle, progress bar).abstract voidRefreshes the persistent "secondary layer active" indicator shown in this viewer's SNT Controls card, reflectingSNT.isTracingOnSecondaryImageActive().abstract voidupdateStatus(String message, int step, int nSteps) Updates the persistent progress bar docked at the bottom of this viewer's card panel.
-
Field Details
-
lastInstance
Most recently instantiated viewer; scripting convenience. -
snt
The SNT instance this viewer is tethered to, or null if no SNT instance is available. -
tracingEnabled
protected boolean tracingEnabled -
CLICK_MOVE_TOLERANCE_PX
protected static final int CLICK_MOVE_TOLERANCE_PX- See Also:
-
renderedTrees
Trees currently rendered in this viewer, keyed by unique display label. Insertion order is preserved so the first-added tree stays first.SNT#updateTracingViewers(boolean, boolean)fires off a new backgroundThreadfor everysyncPathManagerList()call, with no coordination between successive calls - during active interactive tracing (many calls in quick succession) more than one of these can run at the same time. All reads/writes of this plain, non-thread-safeLinkedHashMap(here,addTree(Tree, boolean),removeTree(String),clearAllTrees(),syncPathManagerList(),getRenderedTrees()) must go throughrenderedTreesLockto avoid aConcurrentModificationException -
syncedPathManagerLabels
Labels of the trees rendered by the lastsyncPathManagerList()call. Needed because that method's own diff (remove labels that are still current, then re-add) never catches a tree that has been entirely deleted from the Path Manager (all its paths removed): such a tree simply stops appearing inPathAndFillManager.getTrees()altogether, so it would otherwise never be pruned fromrenderedTreesand would linger in the scene forever. Comparing against this set is what lets a fully-deleted tree be detected and removed -
spimDataFilePaths
Maps SpimData sources back to the file that produced them. -
cal
protected double[] calVoxel sizes [x, y, z] for the primary loaded volume, incalUnitunits. -
dims
protected long[] dimsPixel dimensions [x, y, z] of the primary loaded volume. -
renderingOptions
Rendering options shared across all path/annotation overlays in this viewer. -
calUnit
Physical unit for calibration values (e.g., "um", "pixel"). -
markerManager
Lazily initialized bookmark/marker manager panel. -
tracingStatusBar
-
tracingCancelButton
-
tracingUndoButton
-
secondaryLayerIndicator
-
NATIVE_KEYS_EXCLUDED_FROM_PALETTE
Keystrokes bound to BDV/BVV native commands intentionally kept out of the command palette byregisterNativeCommands(sc.fiji.snt.gui.SNTCommandFinder, javax.swing.ActionMap, javax.swing.InputMap, java.util.List<java.lang.String>, javax.swing.Icon, java.util.Set<java.lang.String>, javax.swing.KeyStroke...): per-source selection/visibility digits, continuous pan/zoom/ rotate stepping, timepoint stepping, and bookmark set/recall/rotation. These read as noise in a command finder -
NATIVE_NAMES_EXCLUDED_FROM_PALETTE
Action-map keys thatregisterNativeCommands(sc.fiji.snt.gui.SNTCommandFinder, javax.swing.ActionMap, javax.swing.InputMap, java.util.List<java.lang.String>, javax.swing.Icon, java.util.Set<java.lang.String>, javax.swing.KeyStroke...)should always skip, shared by every BDV/BVV-family viewer: natives that only make sense mid-gesture (aborting an in-progress bookmark placement or manual transform, neither of which has a dedicated trigger key of its own), and SNT's own press/release-pair or modal-pick overlays -- present under the same literal keys in bothBvvandBdv-- which are meaningless as a one-shot palette command (see, e.g.,Actions#hideAnnotationsPressAction).
-
-
Constructor Details
-
AbstractBigViewer
protected AbstractBigViewer() -
AbstractBigViewer
-
-
Method Details
-
getSNT
- Returns:
- SNT instance this viewer is tethered to, or null if no SNT instance is available.
-
syncPathManagerList
public boolean syncPathManagerList()Replaces the rendered trees with the current contents of the Path Manager. Only available in SNT-tethered instances.- Returns:
- true if paths were synced; false if the path manager is empty
- Throws:
IllegalArgumentException- if this is a standalone viewer
-
getViewerFrame
Returns the top-level Swing window for this viewer, or null if not yet open. -
getViewerSplitPanel
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. -
getViewerWidth
public abstract int getViewerWidth()Returns the width of the viewer canvas in logical pixels, or 0 if the viewer is not yet initialized. -
getViewerHeight
public abstract int getViewerHeight()Returns the height of the viewer canvas in logical pixels, or 0 if the viewer is not yet initialized. -
getViewerTransform
public abstract net.imglib2.realtransform.AffineTransform3D getViewerTransform()Returns a snapshot of the current viewer-to-screen (world-to-screen) transform. The returned object is a copy; callers may modify it freely. -
setViewerTransform
public abstract void setViewerTransform(net.imglib2.realtransform.AffineTransform3D target, long durationMs) Animates the viewer transform totargetoverdurationMsmilliseconds. UsedurationMs = 0for an immediate jump.- Parameters:
target- the desired world-to-screen transformdurationMs- animation duration in milliseconds (0 = immediate)
-
showViewerMessage
Displays 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
updateStatus(java.lang.String, int, int)instead.- Parameters:
msg- the message to show
-
updateStatus
Updates the persistent progress bar docked at the bottom of this viewer's card panel. UnlikeshowViewerMessage(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
- Parameters:
message- short status message displayed inside the barstep- current step (0-based; ignored in indeterminate mode)nSteps- total steps (0 = hide, negative = indeterminate)
-
resyncCalibrationFromActiveSource
public abstract void resyncCalibrationFromActiveSource()Forcessnt'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.
-
applyAutoBrightness
Recomputes the display range (brightness/contrast) for the source(s) selected byscope, from data percentiles, on a bounded background thread - seeinitBrightnessSafely(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 (seeautoBrightnessButton(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).- Parameters:
scope- which source(s) to recompute
-
addToCardPanelBottom
Docks a component at the bottom of aCardPanel, below all cards, without a card header. Uses MigLayout's"dock south"constraint. If the CardPanel's container layout ever changes away from MigLayout this degrades gracefully: the component simply won't appear (no crash, no viewport flicker). Shared byBvvandBdv's own progress bars. -
initBrightnessSafely
protected static void initBrightnessSafely(bdv.viewer.ViewerState state, bdv.viewer.ConverterSetups setups, String label) Computes and applies a display range from data percentiles (InitializeViewerState.initBrightness(double, double, bdv.viewer.ViewerFrame)) on a bounded background thread so that a remote N5/Zarr/SPIM data hit by a bad chunk or network stall cannot block the caller indefinitely (seeSNTUtils.runWithTimeout(java.util.concurrent.Callable<T>, long, java.lang.String)). Callers should invoke this off the EDT; a caller that doesn't is still bounded by the timeout, just at the cost of freezing the UI for up toBRIGHTNESS_INIT_TIMEOUT_SECONDSseconds instead o`f indefinitely.On timeout or any other failure, the failure is logged and swallowed` rather than thrown: a slow/failed brightness estimate should never prevent a viewer from opening, or block whatever triggered this call (initial load, or a manual "Auto Brightness/Contrast" button click).
- Parameters:
state- the viewer state to sample and updatesetups- the converter setups whose display ranges are updatedlabel- short, human-readable description of the viewer/dataset (used only in the failure log)
-
initBrightnessSafely
protected static void initBrightnessSafely(bdv.viewer.SourceAndConverter<?> source, bdv.tools.brightness.ConverterSetup setup, int timepoint, String label) Single-source counterpart ofinitBrightnessSafely(bdv.viewer.ViewerState, bdv.viewer.ConverterSetups, String), forAbstractBigViewer.BrightnessScope.CURRENT/AbstractBigViewer.BrightnessScope.ACTIVE.InitializeViewerState. This samples the source's own data directly viaImgUtils.computePercentile(net.imglib2.RandomAccessibleInterval<? extends net.imglib2.type.numeric.RealType<?>>, double)(max 100k pixels, regardless of image size) at its coarsest available resolution level -
applyBrightnessScope
protected static void applyBrightnessScope(AbstractBigViewer.BrightnessScope scope, bdv.viewer.ViewerState state, bdv.viewer.ConverterSetups setups, bdv.viewer.SourceAndConverter<?> currentSource, String label) DispatchesapplyAutoBrightness(BrightnessScope)for a given scope: the singlecurrent source, every currently active source (ViewerState.isSourceActive(bdv.viewer.SourceAndConverter<?>)), or (forAbstractBigViewer.BrightnessScope.ALL) the whole scene via the aggregateinitBrightnessSafely(bdv.viewer.ViewerState, bdv.viewer.ConverterSetups, String). Shared byBdv.applyAutoBrightness(sc.fiji.snt.viewer.AbstractBigViewer.BrightnessScope)andBvv.applyAutoBrightness(sc.fiji.snt.viewer.AbstractBigViewer.BrightnessScope)- Parameters:
scope- which source(s) to recomputestate- the viewer state (sources, active flags)setups- the converter setups (source -> display-range control lookup)currentSource- the viewer's current/selected source, or null if nonelabel- short, human-readable description of the viewer (for logging)
-
showLoadedData
public abstract void showLoadedData()Displays the main tracing data (the currently active channel/frame of the image being traced) from the associated SNT instance. Only available in SNT-tethered instances.- Throws:
IllegalArgumentException- if this is a standalone viewer, or no valid image data is available
-
showSecondaryData
public abstract void showSecondaryData()Displays the secondary tracing data (the filtered/processed layer used for cost-function-based tracing) from the associated SNT instance. Only available in SNT-tethered instances.- Throws:
IllegalArgumentException- if this is a standalone viewer, or no secondary data is available
-
hideSecondaryData
public abstract void hideSecondaryData()Removes the secondary tracing data layer previously added byshowSecondaryData()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).- See Also:
-
updateSecondaryLayerIndicator
public abstract void updateSecondaryLayerIndicator()Refreshes 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. -
resetView
public abstract void resetView()Resets the view to frame all loaded data. -
isOpen
public abstract boolean isOpen()Returns true if the viewer window is currently visible and usable. -
repaint
public abstract void repaint()Requests a repaint of the viewer canvas. -
syncOverlays
public abstract void syncOverlays()Synchronizes all active rendering overlays (paths, markers) with the current state ofrenderedTreesand any pending annotation changes. -
setDisplayRadii
public abstract void setDisplayRadii(boolean display) Sets whether paths are rendered as frusta (tubes) or simple centerlines, and triggers an overlay cache invalidation.- Parameters:
display-trueto render frusta using per-node radii;falsefor fast centerline rendering
-
annotations
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. -
getDefaultMarkerSize
public abstract float getDefaultMarkerSize()Returns the default sphere radius (in physical units) for newly placed markers. Implementations typically derive this from their rendering-options or a sensible default. -
getDefaultMarkerColor
Returns the default color for newly placed markers, or null to use the viewer's own fallback color. -
getCurrentTimepoint
public abstract int getCurrentTimepoint()Returns this viewer's current timepoint (1-based, matchingPath.getFrame()'s convention), or 1 if no data is loaded / timepoint tracking is unavailable. -
setCurrentTimepoint
public abstract void setCurrentTimepoint(int timepoint) Navigates this viewer to the specified timepoint (1-based, matchingPath.getFrame()'s convention). Does nothing if no data is loaded.- Parameters:
timepoint- the 1-based timepoint to navigate to; values < 1 are coerced to 1
-
flyTo
Animates the camera to frame the given world-coordinate bounding box: an isotropic scale is computed so the box's width/height fit the viewport, and the transform is translated to center the box's centroid on screen. Any existing rotation is dropped.A degenerate box (zero width/height - e.g. a single-node selection, whose origin and originOpposite are the same point) cannot be "fit" (there is nothing to scale to), so this recenters on the centroid at the viewer's current zoom level instead.
- Parameters:
box- the world-coordinate bounding box to frame; a no-op ifnull, its corners are not real (e.g. an empty/uncomputed box), or the viewport has not yet been realized- Returns:
trueif the transform was computed and applied;falseotherwise
-
createMarkerManager
Creates and returns a newBookmarkManagerfor this viewer. Called exactly once (lazily) bygetMarkerManager(). -
getGlobalMouseCoordinates
public abstract void getGlobalMouseCoordinates(net.imglib2.RealPoint pos) Writes the current global (world-space) mouse position intopos. Callers must supply a pre-allocatedRealPointwith at least 3 dimensions.- Parameters:
pos- 3D point to receive the world-space cursor position
-
getCurrentSource
protected abstract bdv.viewer.SourceAndConverter<?> getCurrentSource()Returns the currently active source, or null if none. -
addMouseListenerToDisplay
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).- Parameters:
ml- the listener to add
-
getViewerAction
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.- Parameters:
name- the action key (e.g., "align XY plane")
-
registerNativeCommands
protected void registerNativeCommands(SNTCommandFinder commandFinder, ActionMap actionMap, InputMap inputMap, List<String> path, Icon icon, Set<String> excludedNames, KeyStroke... excludedTriggers) Registers this viewer's native (library-level) single-shot commands -- i.e., entries of the BDV/BVV keybindingsActionMap, as opposed to SNT's own overlaid commands (seeAbstractBigViewer.Actions) -- incommandFinder, so they become searchable/runnable from the command palette. Meant to be called once per viewer instance, only whileStream modeis activeContinuous, held-key or mouse-drag behaviors (pan, rotate, zoom, scroll) are not picked up by this scrape: they live elsewhere so they are excluded by construction.
excludedTriggersadditionally drops named actions bound to specific keys that clutter the palette.- Parameters:
commandFinder- the palette to register into; a no-op if nullactionMap- the viewer's concatenated keybindingsActionMapinputMap- the viewer's concatenated keybindingsInputMap, used only to resolveexcludedTriggersto the action keys they are bound topath- palette category shown for every registered entry, e.g.List.of("Bvv Viewer")icon- icon applied to every registered entry viaAction.SMALL_ICON; may be nullexcludedNames- action-map keys to skip outright, matched case-insensitively against the raw (un-prettified) key -- for contextual/"abort this in-progress gesture" natives that have no single dedicated trigger key, or SNT press/release-pair overlays (e.g., "hide annotations (hold)") that only make sense as a held key, never as a one-shot palette commandexcludedTriggers- keystrokes whose bound action should be skipped (the keystroke itself does not need to be a valid trigger for this viewer; unresolved ones are ignored)
-
registerCommandFinderAccelerator
protected static void registerCommandFinderAccelerator(InputMap sntIMap, ActionMap sntAMap, SNTCommandFinder commandFinder) WirescommandFinder's own show/toggle shortcut (SNTCommandFinder.getAccelerator()) into this viewer's keybindings, so it fires while the Bvv/Bdv window itself has focus. Standard Swing accelerators (as installed bySNTCommandFinder.attach(JDialog)) don't reach here: BDV/BVV's behavior-based trigger layer intercepts keystrokes before a component's ordinary InputMap/ActionMap ever sees them (see the identical constraint noted wheresntIMap/sntAMapare built inBvv/Bdv), so the shortcut has to be added to that samesntIMap/sntAMappair instead, alongside SNT's other viewer-overlay bindings. -
addTree
Adds a Tree to the viewer overlay, assigning it a unique display label.- Parameters:
tree- the Tree to render; must not be null or empty
-
addTree
Internal add with optional immediate overlay sync. Subclasses may override if they need to track per-tree state beyond the shared map. -
add
Script-friendly dispatcher: accepts aTree,DirectedWeightedGraph,File[], or anyCollectionof supported objects.- Parameters:
o- the object to add- Throws:
IllegalArgumentException- if the type is not supported
-
add
Internal dispatcher with deferred sync support for batch operations. -
addCollection
Adds all elements of a collection, optionally syncing once at the end. -
add
Loads reconstruction files (SWC, JSON, TRACES) and adds them to the viewer. Trees are colored with distinct colors and the overlay is synced once at the end. Subclasses may override for async loading with progress feedback (see Bvv).- Parameters:
reconstructionFiles- the files to load; null or empty is silently ignored
-
removeTree
Removes the tree with the given label from the overlay.- Parameters:
treeLabel- the display label of the tree to remove- Returns:
- true if a tree with that label existed and was removed
-
clearAllTrees
public void clearAllTrees()Removes all rendered trees from the overlay. -
getRenderedTrees
Returns a snapshot of the currently rendered trees (insertion order). Deliberately an independent copy, not a live view overrenderedTrees- seerenderedTreesLock's javadoc: a live view (the previous behavior) is vulnerable to aConcurrentModificationExceptionif another thread mutatesrenderedTreeswhile this collection is being iterated, which for a caller likeBvv.OverlayRenderer#updatePaths(Collection)(iterating well after this method returns) is a real, previously-observed race during active interactive tracing.- Returns:
- collection of rendered trees (insertion order)
-
getMarkerManager
Returns the marker manager panel, creating it lazily on first call viacreateMarkerManager().- Returns:
- the marker manager for this viewer
-
hasMarkerManager
public boolean hasMarkerManager()Checks whether aBookmarkManagerhas already been created for this viewer, without triggering its (lazy, non-trivial) creation asgetMarkerManager()would. Useful for display/logging code that wants to report marker counts only if the panel is already in use. -
setCalibration
Sets the voxel calibration for the viewer.- Parameters:
spacing- voxel sizes [x, y, z]unit- physical unit string (e.g., "um")
-
getCalibration
public double[] getCalibration()Returns the current voxel sizes, or null if not set. -
getBoundingBox
Returns the world-space bounding box of the primary loaded volume, assuming an origin at (0,0,0), i.e., noworld-origin offsetor per-source transform is factored in.- Returns:
- the volume's bounding box, or null if dimensions/calibration are not yet known
-
getPrimarySourcePath
Returns the file path/URL of the primary loaded volume, for display/logging purposes (e.g., a Notes entry documenting the dataset being traced).Only sources registered through
spimDataFilePaths(i.e., datasets opened viaAbstractSpimData-basedshow(...)overloads, such as N5/Zarr/BDV/IMS data) are tracked. There is no guaranteed order if more than one source is loaded; this simply returns the first entry found.- Returns:
- the source path/URL, or null if unknown/not applicable
-
getPhysicalUnit
Derives the best available physical unit string. Subclasses may override to add viewer-specific fallbacks (e.g., reading units from source VoxelDimensions). -
getUniqueLabel
Returns a display label for the tree that is unique withinrenderedTrees. Derived from the tree's own label, appending "(2)", "(3)" etc. as needed. -
isPathRenderingEnabled
protected abstract boolean isPathRenderingEnabled()Returns true if path/tree overlay rendering is currently enabled. -
setPathRenderingEnabled
protected abstract void setPathRenderingEnabled(boolean enabled) Enables or disables path/tree overlay rendering. -
setPathOverlayOffset
public abstract void setPathOverlayOffset(double offsetX, double offsetY, double offsetZ) Applies a world-space offset to all rendered path annotations.- Parameters:
offsetX- x offset in calibrated unitsoffsetY- y offset in calibrated unitsoffsetZ- z offset in calibrated units
-
getRenderingOptions
Returns the rendering options shared across this viewer's overlays. -
blockMarkerPlacement
protected boolean blockMarkerPlacement()WhetherM-key marker placement should be blocked in the current mode, showing a viewer message if so. True whenever SNTUI is present in "classic-mode-tracing", since the image canvas already has a fully working Bookmarks tab (Shift+B, right-click, etc.). Shared by Bvv/Bdv's ownM-key bindings.- Returns:
- true if placement was blocked (and a message shown); callers should return immediately without placing a marker
-
optionsButton
Builds the "Options" button (Import Reconstructions.../Remove All Annotations...) shared by Bvv/Bdv's own SNT Annotations toolbar. -
autoBrightnessButton
Builds the "Auto Brightness/Contrast" options button (Current Source.../Active Source(s).../All Sources...) for the scene-control toolbar. SeeapplyAutoBrightness(BrightnessScope). -
tracingStatusRow
protected JComponent tracingStatusRow(AbstractBigViewer.Actions actions, AbstractBigViewer.AbstractTracer tracer) Builds the second row shown below the SNT Annotations toolbar whenever this viewer has an activeAbstractBigViewer.AbstractTracer(undo/cancel controls, secondary-layer toggle, progress bar). Shared by Bvv/Bdv, which both keep the returned components (seetracingStatusBar,tracingCancelButton,tracingUndoButton,secondaryLayerIndicator) in sync from their ownAbstractBigViewer.AbstractTracersubclass. -
showCalibrationDialog
Prompts the user for voxel spacing and its physical unit, and updates calibration.Confirming here also propagates to
sntviaSNT.setImageMetadata(int, int, int, double, double, double, java.lang.String).Dimensions are left untouched (passed as 0, whichsetImageMetadatatreats as "no change").- Parameters:
parent- component used to anchor the dialog
-
buildBaseSceneControlToolbar
Builds the shared scene-control toolbar: fit-source button, align-plane buttons (XY, XZ, YZ), minimap toggle, text-overlay toggle, scale-bar toggle. Subclasses call this and may prepend or append viewer-specific buttons.- Returns:
- a partially populated JToolBar ready for additional buttons
-