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 "center the view on the clicked point" behavior while tracing (seeBvv#registerRecenterListener). -
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 intSource file/URL of each dataset shown (keyed by identity: anAbstractSpimDataor aSpimDataUtils.N5Sources)protected long[]Pixel dimensions [x, y, z] of the primary loaded volume.protected static final StringKey bindings id used for the (transient) Edit Mode shortcuts.static final longAnimation duration used byflyTo(BoundingBox)itself, exposed so a caller that needs to run something else only once the camera has actually settled there (e.g. a rotation that must pivot on the boxflyTo(BoundingBox)just framed, not on wherever the camera was beforehand - seeGuidedTutorial#showCurrentStep()) knows how long to wait firstprotected static final KeyStrokeCtrl (Cmd on macOS) + G: prompts for a location to fly toprotected 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.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 voidaddSharedSceneOptions(JPopupMenu menu, AbstractBigViewer.Actions actions) Adds the entries common to the scene-control "Options" menu of Bvv/Bdv: navigation, restore view (display settings) and help.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 - seeViewerSettingsUtils.initBrightnessSafely(bdv.viewer.ViewerState, bdv.viewer.ConverterSetups, java.lang.String).protected voidapplyCamParams(double dCam, double nearClip, double farClip) Applies camera/slab parameters from aKeyframe.protected JButtonBuilds the "Auto Brightness/Contrast" options button (Current Source...protected voidawaitRender(Runnable trigger, long settleMillis) Runstrigger(which updates the viewer and requests a repaint) and blocks until the resulting frame has been rendered.protected JToolBarBuilds the shared scene-control toolbar: fit-source button, align-plane buttons (XY, XZ, YZ), minimap toggle, text-overlay toggle, scale-bar toggle.Captures the current viewer state as aKeyframe: transform, camera/slab parameters (BVV only), timepoint, and visible actors.voidRemoves all rendered trees from the overlay.protected static voidcollapseGroupsCard(bdv.ui.CardPanel cardPanel) Collapses the stock "Groups" card.protected abstract BookmarkManagerCreates and returns a newBookmarkManagerfor this viewer.final voiddispose()Releases the resources held by this viewer (overlays, timers, cached data, ...) and closes its window.protected voidViewer-specific part ofdispose(), called at most once.voidenableTracing(boolean manual) Enables tracing on this viewer, as if the user had clicked its manual/interactive tracing-mode toggle button (seeAbstractTracer#getToggleAction(boolean)), so a click on the canvas traces instead of panning it.protected JToolBarfinishSceneControlToolbar(JToolBar bar, JPopupMenu menu) Completes a scene-control toolbar started withbuildBaseSceneControlToolbar()by appending the trailing "Options" button holding the given menuvoidAnimates the camera so that the given world position lands at the center of the viewport, keeping the current rotation and scale, and jumps to the given timepoint if it differs from the current one.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.double[]Returns the current voxel sizes, or null if not set.protected double[]Returns the current{dCam, nearClip, farClip}.protected abstract bdv.viewer.ConverterSetupsReturns the viewer's per-source display settings (levels, LUTs) ornullif not yet liveprotected 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.Gets the path rendering style used when no preference has been stored.double[]getDisplayRange(int sourceIndex) Returns the display range (brightness min/max) of a source in the viewer.double[]getDownsamplingFactors(int sourceIndex, int level) Returns how much coarser a resolution level is than full resolution, along each axis.abstract voidgetGlobalMouseCoordinates(net.imglib2.RealPoint pos) Writes the current global (world-space) mouse position intopos.protected GuiUtilsprotected abstract org.scijava.ui.behaviour.util.InputActionBindingsReturns the marker manager panel, creating it lazily on first call viacreateMarkerManager().intgetNumResolutionLevels(int sourceIndex) Returns the number of resolution levels of a source in the viewer.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.longGets the time without new render passes after which a recorded frame is considered fully refined.The world-space point currently displayed at the center of this viewer, i.e. the inverse offlyTo(sc.fiji.snt.util.BoundingBox)'s centroid-to-screen-center mapping: applies the inverse viewer transform to the viewport's center screen point, at the focal plane (viewer-space Z = 0).protected abstract StringTag identifying the viewer type in the names of settings files (e.g., "bdv" or "bvv")getSNT()net.imglib2.RandomAccessibleInterval<?> getSourceData(int sourceIndex, int level) Returns the pixel data of a source in the viewer at the current timepoint.getSourceName(int sourceIndex) Returns the name of a source in the viewer.Returns the distinct file paths/URLs of all datasets tracked by this viewer (seegetPrimarySourcePath()for the tracking caveat)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 ComponentReturns the viewer canvas itself, i.e., the actual ComponentgetViewerWidth()/getViewerHeight()measure, ornullif the viewer is not yet initialized.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.protected abstract bdv.viewer.SynchronizedViewerStateReturns the viewer's state (sources, groups, timepoint) ornullif not yet liveabstract 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 voidinitBrightnessOrRestore(bdv.viewer.ViewerState state, bdv.viewer.ConverterSetups setups, String title, String id, String label) Initializes the display range of the sources.protected voidinitProgressBar(bdv.ui.CardPanel cardPanel) Creates the progress bar driven byupdateStatus(String, int, int)and docks it at the bottom of the card panel, below all cards and without a card header.protected voidAttaches the context menu (seeBigViewerMenu) to the viewer's display.protected voidinstallEditKeybindings(InputMap inputMap, ActionMap actionMap) Adds transient key bindings (taking precedence over the viewer's own and the permanent SNT ones) for the duration of Edit Mode.protected voidinstallFileDrop(bdv.ui.CardPanel c) Allows files to be imported by dropping them onto a component (e.g., the viewer's card panel): reconstructions (SWC, TRACES, etc.) as inadd(File[]), display settings files as inloadViewerSettings(String), and CSV files into themarker manager.protected voidDiscards cached path geometry and repaints.final booleanbooleanabstract booleanisOpen()Returns true if the viewer window is currently visible and usable.booleanprotected abstract booleanReturns true if path/tree overlay rendering is currently enabled.booleanprotected abstract voidloadViewerSettings(String path) Loads viewer settings (display ranges, colors, etc.) from an XML file.voidCalled by SNT when the active node (or its lock state) was changed by another front-endvoidCalled by SNT when nodes of the path being edited were modified in place by another front-endvoidCalled by SNT when the path being edited has changed while in Edit ModevoidonSntEditModeChanged(boolean enabled) Called by SNT when Edit Mode is (de)activated from any front-end, including this one (seeSNT#enterEditMode(Path))protected JButtonoptionsButton(AbstractBigViewer.Actions actions) Builds the "Options" button (Import Reconstructions...voidPlays back an animation between keyframes in the viewer without saving frames.voidPlays back keyframesfromtoto(both inclusive, 0-based).playPaths(Collection<Path> paths, double speed, double fov) Plays a walkthrough of the specified paths: the view is centered on a point traveling along each path at constant speed (translation only: the current rotation is preserved).voidPrompts for an XYZ location (physical units), pre-filled with the clipboard contents if these look like coordinates, and flies to it at the current timepoint.protected voidRe-evaluates the Edit Mode markers after a selection change (they are only shown for a selected path)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 voidregisterKeyframeCapture(InputMap sntIMap, ActionMap sntAMap) Registers the keyframe hotkeys:Kcaptures aKeyframeand appends it to a running script-readykfsblock that is printed to the console and copied to the clipboard, andShift+Kclears that block.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.voidregisterOmeZarrSource(String path) Registers the path of a source so that a unit set throughshowCalibrationDialog(java.awt.Component)can be saved to it.protected voidregisterSntKeybindings(InputMap sntIMap, ActionMap sntAMap, AbstractBigViewer.Actions actions, Action addMarker, AbstractBigViewer.AbstractTracer tracer) Registers SNT's viewer keybindings shared by Bvv and Bdv:M(marker),H(hold to hide annotations),L(secondary layer),P(pick sigma point) and, if a tracer is available, the tracing shortcuts (G, Shift+G, Enter, Esc, Z, Space).protected voidRemoves the bindings added byinstallEditKeybindings(InputMap, ActionMap)booleanremoveTree(String treeLabel) Removes the tree with the given label from the overlay.voidrenderFrames(List<Keyframe> keyframes, String outputDir) Renders an animation between keyframes, saving each frame as a PNG.abstract voidrepaint()Requests a repaint of the viewer canvas.abstract voidResets the view to frame all loaded data.protected double[]World position of the cursor, as used by Edit Mode to place/move nodes.protected voidrestoreSidecarSettings(bdv.viewer.ViewerState state, bdv.viewer.ConverterSetups setups) Restores the settings file stored next to the primary source, if any, without touching the display range otherwise.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()).voidDisplays the viewer's context menu at the center of the display, with the item of a command armedvoidrevealContextItem(JMenuItem canvasItem) Displays the viewer's context menu with the equivalent of a tracing canvas menu item armedRuns a command of the viewer's context menu without displaying itrunContextItem(JMenuItem canvasItem) Runs the equivalent of a tracing canvas menu item without displaying the viewer's menuprotected abstract voidsaveViewerSettings(String path) Saves viewer settings (display ranges, colors, etc.) to an XML file.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.voidsetRenderSettleTime(long millis) Sets the time without new render passes after which a recorded frame is considered fully refined and is captured byrenderFrames(List, String).voidsetTracingLockedByPause(boolean locked) Locks/unlocks this viewer's tracing-mode toolbar buttons to "No tracing", as for a global SNT pause.Maps current converter setup ids to source namesabstract voidsetViewerTransform(net.imglib2.realtransform.AffineTransform3D target, long durationMs) Animates the viewer transform totargetoverdurationMsmilliseconds.protected voidsetViewerTransformImmediate(net.imglib2.realtransform.AffineTransform3D target) Sets the viewer transform at once (no animation).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.protected abstract voidshowShortcuts(GuiUtils gui) Displays the dialog listing the viewer's keyboard shortcutsabstract voidshowViewerMessage(String msg) Displays a short status message in the viewer's overlay area.voidStops the playback started byplayPaths(Collection, double, double), if anyabstract 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.voidToggles Edit Mode: node-level editing of the single selected path, mirroring the Edit-path commands of the classic canvas.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().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 -
EDIT_KEYBINDINGS_ID
Key bindings id used for the (transient) Edit Mode shortcuts. SeeinstallEditKeybindings(javax.swing.InputMap, javax.swing.ActionMap)- See Also:
-
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 -
datasetPaths
Source file/URL of each dataset shown (keyed by identity: anAbstractSpimDataor aSpimDataUtils.N5Sources) -
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
-
FLY_TO_DURATION_MS
public static final long FLY_TO_DURATION_MSAnimation duration used byflyTo(BoundingBox)itself, exposed so a caller that needs to run something else only once the camera has actually settled there (e.g. a rotation that must pivot on the boxflyTo(BoundingBox)just framed, not on wherever the camera was beforehand - seeGuidedTutorial#showCurrentStep()) knows how long to wait first- See Also:
-
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). -
GO_TO_KEYSTROKE
Ctrl (Cmd on macOS) + G: prompts for a location to fly to
-
-
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.
-
isTracingEnabled
public boolean isTracingEnabled()- Returns:
- whether this viewer's own Start/Stop Tracing toggle is on, i.e. whether
AbstractBigViewer.AbstractTracer.handleClick(MouseEvent)will act on the next click (start/extend/fork a path) rather than ignoring it outright. Exposed so other click-consuming features sharing this viewer's display component (e.g.SeedOverlayBigViewerHandler's Alt+Click, which collides with Alt+Click-to-fork below) can back off while tracing-by-click is live, sinceAbstractTracerreacts inmouseReleased- always dispatched beforemouseClicked- so a later listener'sMouseEvent#consume()cannot undo it.
-
isEditModeEnabled
public boolean isEditModeEnabled()- Returns:
- whether this viewer is currently in Edit Mode (node-level editing of a single selected path)
-
toggleEditMode
public void toggleEditMode()Toggles Edit Mode: node-level editing of the single selected path, mirroring the Edit-path commands of the classic canvas. Only available in SNT-tethered viewers. Entering requires exactly one selected path and suspends tracing for the duration. -
onSntEditModeChanged
public void onSntEditModeChanged(boolean enabled) Called by SNT when Edit Mode is (de)activated from any front-end, including this one (seeSNT#enterEditMode(Path)) -
refreshEditNodesOnSelectionChange
protected void refreshEditNodesOnSelectionChange()Re-evaluates the Edit Mode markers after a selection change (they are only shown for a selected path) -
onSntEditedPathModified
public void onSntEditedPathModified()Called by SNT when nodes of the path being edited were modified in place by another front-end -
onSntActiveNodeChanged
public void onSntActiveNodeChanged()Called by SNT when the active node (or its lock state) was changed by another front-end -
onSntEditingPathChanged
public void onSntEditingPathChanged()Called by SNT when the path being edited has changed while in Edit Mode -
resolveCursorWorldPosition
protected double[] resolveCursorWorldPosition()World position of the cursor, as used by Edit Mode to place/move nodes. The default is the position reported bygetGlobalMouseCoordinates(RealPoint)(appropriate for an orthogonal slicing view);Bvvoverrides it to resolve depth the same way its tracer does.- Returns:
- calibrated (x,y,z) position, or null if it could not be resolved
-
invalidatePathGeometry
protected void invalidatePathGeometry()Discards cached path geometry and repaints. Needed after in-place edits of a Path (e.g., a moved node), which the structural fingerprint of the cached screen data does not detect -
installContextMenu
protected void installContextMenu()Attaches the context menu (seeBigViewerMenu) to the viewer's display. To be called once the display exists. No-op in standalone viewers -
runContextCommand
Runs a command of the viewer's context menu without displaying it- Parameters:
cmd- the command- Returns:
- null if the command was run, otherwise the reason why it was not
-
revealContextCommand
Displays the viewer's context menu at the center of the display, with the item of a command armed- Parameters:
cmd- the command
-
runContextItem
Runs the equivalent of a tracing canvas menu item without displaying the viewer's menu- Parameters:
canvasItem- the item of the tracing canvas menu- Returns:
- null if the item was run, otherwise the reason why it was not
-
revealContextItem
Displays the viewer's context menu with the equivalent of a tracing canvas menu item armed- Parameters:
canvasItem- the item of the tracing canvas menu
-
setTracingLockedByPause
public void setTracingLockedByPause(boolean locked) Locks/unlocks this viewer's tracing-mode toolbar buttons to "No tracing", as for a global SNT pause. Also used to suspend tracing-by-click while in Edit Mode. Does nothing if this viewer has no tracer- Parameters:
locked- whether tracing is currently suspended
-
getKeybindings
protected abstract org.scijava.ui.behaviour.util.InputActionBindings getKeybindings()- Returns:
- the key bindings of the viewer's frame, or null if the frame does not exist (yet)
-
installEditKeybindings
Adds transient key bindings (taking precedence over the viewer's own and the permanent SNT ones) for the duration of Edit Mode. Counterpart ofremoveEditKeybindings() -
removeEditKeybindings
protected void removeEditKeybindings()Removes the bindings added byinstallEditKeybindings(InputMap, ActionMap) -
getGuiUtils
-
enableTracing
public void enableTracing(boolean manual) Enables tracing on this viewer, as if the user had clicked its manual/interactive tracing-mode toggle button (seeAbstractTracer#getToggleAction(boolean)), so a click on the canvas traces instead of panning it. Shows an error dialog and leaves tracing off ifmanualisfalse(semi-automated tracing) and no image data is available to trace on. Does nothing if this viewer has no tracer (e.g. a standalone viewer with no attached SNT instance, or the toolbar has not been built yet).- Parameters:
manual-truefor manual (point-and-click) tracing,falsefor semi-automated (auto-trace) tracing- See Also:
-
isPathInProgress
public boolean isPathInProgress()- Returns:
- whether this viewer currently has a path in progress, i.e. the user has clicked to start
(or extend/fork) a path but has not yet finished or discarded it. Always
falseif this viewer has no tracer (seeenableTracing(boolean)). - See Also:
-
registerOmeZarrSource
Registers the path of a source so that a unit set throughshowCalibrationDialog(java.awt.Component)can be saved to it. Ignored unlesspathis a local OME-Zarr (OME-NGFF v0.5) directory- Parameters:
path- the path of the loaded dataset
-
getDefaultRenderingStyle
Gets the path rendering style used when no preference has been stored. Centerlines by default; overridden by viewers that favor frusta.- Returns:
- the default style
-
isDisposed
public final boolean isDisposed()- Returns:
- whether
dispose()has been called
-
dispose
public final void dispose()Releases the resources held by this viewer (overlays, timers, cached data, ...) and closes its window. Called when the window is dismissed. Safe to call from any thread, and more than once -
disposeViewer
protected void disposeViewer() -
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
-
collapseGroupsCard
protected static void collapseGroupsCard(bdv.ui.CardPanel cardPanel) Collapses the stock "Groups" card. Must be called on the EDT- Parameters:
cardPanel- the viewer's card panel
-
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. -
getViewerCanvas
Returns the viewer canvas itself, i.e., the actual ComponentgetViewerWidth()/getViewerHeight()measure, ornullif the viewer is not yet initialized. Unlike those two, callers can use this to locate the canvas on screen (e.g. viaSwingUtilities.convertPoint()) - the canvas is not necessarily centered in, or even the same size as, the frame's content pane, sincegetViewerSplitPanel()may also be hosting a side panel next to it -
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)
-
initProgressBar
protected void initProgressBar(bdv.ui.CardPanel cardPanel) Creates the progress bar driven byupdateStatus(String, int, int)and docks it at the bottom of the card panel, below all cards and without a card header. This avoids the viewport flicker caused by adding the bar to the frame's BorderLayout.SOUTH.- Parameters:
cardPanel- the viewer's card panel
-
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 - seeViewerSettingsUtils.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 (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. -
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
-
flyTo
Animates the camera so that the given world position lands at the center of the viewport, keeping the current rotation and scale, and jumps to the given timepoint if it differs from the current one.- Parameters:
x- the X coordinate (world/physical units)y- the Y coordinate (world/physical units)z- the Z coordinate (world/physical units)t- the (1-based) timepoint to displaylabel- text shown in the viewer message
-
setViewerTransformImmediate
protected void setViewerTransformImmediate(net.imglib2.realtransform.AffineTransform3D target) Sets the viewer transform at once (no animation). Used byPathPlayer, which updates the transform at every tick. The default implementation relies on a minimal-duration animation.- Parameters:
target- the transform to be applied
-
playPaths
Plays a walkthrough of the specified paths: the view is centered on a point traveling along each path at constant speed (translation only: the current rotation is preserved). Playback is non-blocking, and can be aborted by clicking on the display or by callingstopPlayback(). Since the distance covered per tick does not depend on rendering speed, playbacks are reproducible, and the elapsed time reported byPathPlayer.getSummary()reflects how well the viewer keeps up.- Parameters:
paths- the paths to be played, in orderspeed- the travel speed, in world units per second (<= 0 for the default of 50)fov- the width of the field of view, in world units, or <= 0 to keep the current zoom- Returns:
- the player, or null if the viewer is not ready. Use it to register callbacks or retrieve the summary
-
stopPlayback
public void stopPlayback()Stops the playback started byplayPaths(Collection, double, double), if any -
promptGoTo
public void promptGoTo()Prompts for an XYZ location (physical units), pre-filled with the clipboard contents if these look like coordinates, and flies to it at the current timepoint. -
getSceneCenter
The world-space point currently displayed at the center of this viewer, i.e. the inverse offlyTo(sc.fiji.snt.util.BoundingBox)'s centroid-to-screen-center mapping: applies the inverse viewer transform to the viewport's center screen point, at the focal plane (viewer-space Z = 0).Correct as-is for an orthogonal slicing view (the displayed slice is the focal plane).
Bvvoverrides this to prefer the depth of whatever is actually visible there (seeBvv.findSceneCenterMaxima()), falling back to this same focal-plane result when that ray finds nothing.- Returns:
- the world-space scene center, or
nullif the viewport has not yet been realized
-
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. -
registerSntKeybindings
protected void registerSntKeybindings(InputMap sntIMap, ActionMap sntAMap, AbstractBigViewer.Actions actions, Action addMarker, AbstractBigViewer.AbstractTracer tracer) Registers SNT's viewer keybindings shared by Bvv and Bdv:M(marker),H(hold to hide annotations),L(secondary layer),P(pick sigma point) and, if a tracer is available, the tracing shortcuts (G, Shift+G, Enter, Esc, Z, Space). They must go through BDV/BVV's keybindings system, since its input trigger layer shadows ordinary Swing InputMaps. SamesntIMap/sntAMapconstraints asregisterCommandFinderAccelerator(javax.swing.InputMap, javax.swing.ActionMap, sc.fiji.snt.gui.SNTCommandFinder).- Parameters:
sntIMap- the viewer's own SNT-overlayInputMap, not yet installedsntAMap- the matchingActionMap, not yet installedactions- the viewer'sAbstractBigViewer.ActionsaddMarker- the action bound toMtracer- the viewer's tracer, ornullif tracing is unavailable
-
registerKeyframeCapture
Registers the keyframe hotkeys:Kcaptures aKeyframeand appends it to a running script-readykfsblock that is printed to the console and copied to the clipboard, andShift+Kclears that block. SamesntIMap/sntAMapconstraints asregisterCommandFinderAccelerator(javax.swing.InputMap, javax.swing.ActionMap, sc.fiji.snt.gui.SNTCommandFinder). -
captureKeyframe
Captures the current viewer state as aKeyframe: transform, camera/slab parameters (BVV only), timepoint, and visible actors.- Returns:
- the current state as a Keyframe
- Throws:
IllegalStateException- if no viewer is active
-
getRenderSettleTime
public long getRenderSettleTime()Gets the time without new render passes after which a recorded frame is considered fully refined.- Returns:
- the settle time in milliseconds
- See Also:
-
setRenderSettleTime
public void setRenderSettleTime(long millis) Sets the time without new render passes after which a recorded frame is considered fully refined and is captured byrenderFrames(List, String). The viewer renders progressively (coarse first): values that are too small may yield low-resolution frames, while large values slow down recording. Default is 250 ms.- Parameters:
millis- the settle time in milliseconds (non-negative)
-
playback
Plays back an animation between keyframes in the viewer without saving frames. The frame count of each transition is read fromKeyframe.frameson the destination keyframe.- Parameters:
keyframes- ordered list of keyframes (at least 2)- See Also:
-
playback
Plays back keyframesfromtoto(both inclusive, 0-based).- Parameters:
keyframes- ordered list of all keyframesfrom- start indexto- end index- See Also:
-
renderFrames
Renders an animation between keyframes, saving each frame as a PNG. The transform is interpolated usingSimilarityTransformAnimatorand the timepoint linearly (if specified in both keyframes); visibility and slab bounds snap at keyframe boundaries. The first keyframe'sKeyframe.framesis ignored. Must be called from a non-EDT thread: blocks until done.- Parameters:
keyframes- ordered list of keyframes (at least 2)outputDir- directory for the PNGs (created if needed); ifnull, frames are played back live without saving- Throws:
IllegalArgumentException- if arguments are inconsistentIllegalStateException- if no viewer is active
-
getViewerState
protected abstract bdv.viewer.SynchronizedViewerState getViewerState()Returns the viewer's state (sources, groups, timepoint) ornullif not yet live -
loadViewerSettings
Loads viewer settings (display ranges, colors, etc.) from an XML file.- Parameters:
path- the path of the settings file- Throws:
Exception- if the settings could not be loaded
-
saveViewerSettings
Saves viewer settings (display ranges, colors, etc.) to an XML file.- Parameters:
path- the path of the settings file- Throws:
Exception- if the settings could not be saved
-
getSettingsTag
Tag identifying the viewer type in the names of settings files (e.g., "bdv" or "bvv") -
installFileDrop
protected void installFileDrop(bdv.ui.CardPanel c) Allows files to be imported by dropping them onto a component (e.g., the viewer's card panel): reconstructions (SWC, TRACES, etc.) as inadd(File[]), display settings files as inloadViewerSettings(String), and CSV files into themarker manager. Children added to the component later are covered as they do not define drop targets -
initBrightnessOrRestore
protected void initBrightnessOrRestore(bdv.viewer.ViewerState state, bdv.viewer.ConverterSetups setups, String title, String id, String label) Initializes the display range of the sources. If saved settings for this dataset exist, and the user agrees to restore them, they are loaded instead of computing the display range- Parameters:
state- the viewer statesetups- the converter setupstitle- the dataset title (null to use the name of the first source)id- the dataset identifier, e.g., path (null to use the title)label- short description of the viewer/dataset, for logging
-
restoreSidecarSettings
protected void restoreSidecarSettings(bdv.viewer.ViewerState state, bdv.viewer.ConverterSetups setups) Restores the settings file stored next to the primary source, if any, without touching the display range otherwise. For viewers that rely on their own auto-brightness (e.g., BDV) -
setupIdToName
Maps current converter setup ids to source names -
showShortcuts
Displays the dialog listing the viewer's keyboard shortcuts -
getDisplayRange
public double[] getDisplayRange(int sourceIndex) Returns the display range (brightness min/max) of a source in the viewer.- Parameters:
sourceIndex- 0-based index of the source (e.g., channel), or a negative value for the active source- Returns:
- {min, max} in raw intensity units, or
nullif unavailable - See Also:
-
getSourceData
public net.imglib2.RandomAccessibleInterval<?> getSourceData(int sourceIndex, int level) Returns the pixel data of a source in the viewer at the current timepoint. UnlikeSNT.getLoadedData(), which holds a single channel, this gives access to any source.- Parameters:
sourceIndex- 0-based index of the source (e.g., channel), or a negative value for the active sourcelevel- the resolution level (0: full resolution). Clamped to the levels available- Returns:
- the source's data
- Throws:
IllegalStateException- if the viewer has no live state or the source cannot be resolved/read- See Also:
-
getSourceName
Returns the name of a source in the viewer.- Parameters:
sourceIndex- 0-based index of the source (e.g., channel), or a negative value for the active source- Returns:
- the source name, or
nullif unavailable
-
getNumResolutionLevels
public int getNumResolutionLevels(int sourceIndex) Returns the number of resolution levels of a source in the viewer.- Parameters:
sourceIndex- 0-based index of the source (e.g., channel), or a negative value for the active source- Returns:
- the number of levels (1 if the source has no pyramid or is unavailable)
-
getDownsamplingFactors
public double[] getDownsamplingFactors(int sourceIndex, int level) Returns how much coarser a resolution level is than full resolution, along each axis.- Parameters:
sourceIndex- 0-based index of the source (e.g., channel), or a negative value for the active sourcelevel- the resolution level (clamped to the levels available)- Returns:
- {x, y, z} downsampling factors (all 1 for level 0)
-
getConverterSetups
protected abstract bdv.viewer.ConverterSetups getConverterSetups()Returns the viewer's per-source display settings (levels, LUTs) ornullif not yet live -
getCamParams
protected double[] getCamParams()Returns the current{dCam, nearClip, farClip}. Defaults to BVV's defaults: viewers without a perspective camera (BDV) keep this implementation. -
applyCamParams
protected void applyCamParams(double dCam, double nearClip, double farClip) Applies camera/slab parameters from aKeyframe. No-op by default -
awaitRender
Runstrigger(which updates the viewer and requests a repaint) and blocks until the resulting frame has been rendered. Must not be called on the EDT. The default implementation waits a fixed interval.- Parameters:
trigger- the action that changes the scenesettleMillis- the time without new render passes after which the frame is considered fully refined (implementations may ignore it)- Throws:
InterruptedException- if interrupted while waiting
-
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': 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. The box is anchored at the translation of the first source'ssourceTransform(the same valueSNT.getWorldOriginOffset()is built from in Stream mode), or at (0,0,0) if no source is available. Only the translation is considered: rotation/shear is ignored- 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
datasetPaths(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
-
getSourcePaths
Returns the distinct file paths/URLs of all datasets tracked by this viewer (seegetPrimarySourcePath()for the tracking caveat)- Returns:
- the source paths/URLs (unordered, possibly empty)
-
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. -
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
-
finishSceneControlToolbar
Completes a scene-control toolbar started withbuildBaseSceneControlToolbar()by appending the trailing "Options" button holding the given menu- Returns:
- the toolbar, for chaining
-
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
-