Class AbstractBigViewer.AbstractTracer
- All Implemented Interfaces:
MouseListener,MouseMotionListener,MouseWheelListener,EventListener
- Enclosing class:
AbstractBigViewer
Bvv and Bdv: 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 (see
SNT.getBatchRetraceChannelFrame()).
Concrete subclasses supply only the genuinely viewer-specific bits: how a click resolves to a world position, how the path/click-highlight overlays are obtained, how the active channel/frame is derived from the viewer's own source-selection UI, and (optionally) how a status row/undo button reflect tracing state.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCancels the A* search currently in flight (if any), viaFuture.cancel(boolean).protected voidRefreshes the path overlay so a stale preview segment (from a just-discarded/finished path) is no longer shown, if a path overlay has already been initialized.protected abstract voidClears the click-highlight overlay's contents, if one has been initialized.protected voidDiscards the current in-progress path: cancels any in-flight segment search, clearstempPath/previousNodeand the preview overlay, and resets the tracing status row.protected abstract voidDisposes of the click-highlight overlay, if one has been initialized, and forgets it.protected abstract sc.fiji.snt.viewer.Bvv.PathOverlayReturns the path overlay used to preview/draw the in-progresstempPath, lazily initializing it first if necessary.protected abstract Bvv.AnnotationOverlayReturns the annotation overlay used to highlight clicked node locations, lazily initializing it first if necessary.protected voidexit()protected AbstractActionBuilds the Escape-key action: discards the in-progress path (seediscardCurrentPath()) without exiting tracing mode, so the user can immediately start a new path.protected AbstractActionBuilds the Enter-key action: finishes the in-progress path, same as a double click, but without the spurious node a double click's own first (clickCount==1) click would leave behind.protected AbstractActiongetToggleAction(boolean manualTraceFlag) protected AbstractActionBuilds the undo action shared by an Undo button (if any) and the Cmd/Ctrl+Z hotkey.voidvoidprotected voidonManualTraceModeChanged(boolean manualTraceFlag) Notifies the viewer that the manual-vs-A* tracing mode was just toggled, so it can enable/ disable any UI that only makes sense for one mode (e.g. the status row/Cancel button, which only apply to A* search).protected abstract int[]Resolves whatsyncChannelFromActiveSource()would set channel/frame to, without mutating anything.protected doublepickRadiusWorld(double screenPx) Converts a screen-space pixel radius into a world-space distance, using the scale of the current viewer transform.protected abstract double[]Resolves the mouse event to a calibrated (x,y,z) world position.protected voidsetTracingStatus(boolean busy, String message) Updates a tracing status row (progress bar/label + Cancel button), if the viewer has one.protected abstract voidRe-derives the pixel data, calibration, and channel/frame that A* search and path metadata should use, from whichever source is currently "active" in the viewer's own source-selection UI and the viewer's current timepoint.protected voidUndoes the most recently confirmed segment, one click at a time (single-step; no redo).protected voidRecomputes whether anything is currently available to undo and notifies the viewer (seeupdateUndoButtonState(boolean)).protected voidupdateUndoButtonState(boolean hasUndo) Notifies the viewer that whether there is a confirmed segment available to undo has changed, so it can enable/disable an Undo button.Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseWheelMoved
-
Field Details
-
tracingSettleUntilMs
protected volatile long tracingSettleUntilMs
-
-
Constructor Details
-
AbstractTracer
-
-
Method Details
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener- Overrides:
mousePressedin classMouseAdapter
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener- Overrides:
mouseReleasedin classMouseAdapter
-
resolveClickWorldPosition
Resolves the mouse event to a calibrated (x,y,z) world position. Viewer-specific: BVV resolves this via ray-max intensity picking with a focal-plane fallback ; BDV resolves it directly from the orthographic slice cursor position .- Parameters:
e- the mouse event that triggered the click- Returns:
- calibrated world position, or
nullif it could not be resolved (a message has already been shown to the user in that case)
-
ensurePathOverlay
protected abstract sc.fiji.snt.viewer.Bvv.PathOverlay ensurePathOverlay()Returns the path overlay used to preview/draw the in-progresstempPath, lazily initializing it first if necessary. -
ensureTracingOverlay
Returns the annotation overlay used to highlight clicked node locations, lazily initializing it first if necessary. -
clearTracingOverlayContents
protected abstract void clearTracingOverlayContents()Clears the click-highlight overlay's contents, if one has been initialized. No-op otherwise. -
disposeTracingOverlay
protected abstract void disposeTracingOverlay()Disposes of the click-highlight overlay, if one has been initialized, and forgets it. -
clearPathOverlayPreview
protected void clearPathOverlayPreview()Refreshes the path overlay so a stale preview segment (from a just-discarded/finished path) is no longer shown, if a path overlay has already been initialized. Deliberately does *not* force lazy initialization (unlikeensurePathOverlay()): if nothing has been drawn yet, there is nothing to clear and no reason to instantiate the overlay machinery early. -
syncChannelFromActiveSource
protected abstract void syncChannelFromActiveSource()Re-derives the pixel data, calibration, and channel/frame that A* search and path metadata should use, from whichever source is currently "active" in the viewer's own source-selection UI and the viewer's current timepoint. If the current source can't be resolved for any reason (should not normally happen), this should leave whatever image data/channel/frame SNT already had. -
peekActiveChannelFrame
protected abstract int[] peekActiveChannelFrame()Resolves whatsyncChannelFromActiveSource()would set channel/frame to, without mutating anything. Used to check whether starting a new path now would change the channel/frame away from one a background batch re-trace is locked to.- Returns:
{channel, frame}(1-based), or null if the active source can't be resolved
-
setTracingStatus
Updates a tracing status row (progress bar/label + Cancel button), if the viewer has one. No-op by default; overridden by viewers that expose such UI- Parameters:
busy-truewhile a search is ongoing;falseto reset to idlemessage- short status text (ignored/cleared when!busy)
-
onManualTraceModeChanged
protected void onManualTraceModeChanged(boolean manualTraceFlag) Notifies the viewer that the manual-vs-A* tracing mode was just toggled, so it can enable/ disable any UI that only makes sense for one mode (e.g. the status row/Cancel button, which only apply to A* search). No-op by default; overridden by viewers with such UI (see -
updateUndoButtonState
protected void updateUndoButtonState(boolean hasUndo) Notifies the viewer that whether there is a confirmed segment available to undo has changed, so it can enable/disable an Undo button. No-op by default; overridden by viewers with such UI- Parameters:
hasUndo-trueifundoLastSegment()would currently do something
-
pickRadiusWorld
protected double pickRadiusWorld(double screenPx) Converts a screen-space pixel radius into a world-space distance, using the scale of the current viewer transform. Used to make on-screen "pick" tolerances (e.g. snapping to an existing node to fork from) scale-invariant with respect to zoom.Same technique as BvvUtils#colMagnitudes(AffineTransform3D): sum-of-squares of a transform's linear part, applied to the viewer transform rather than a source transform. BVV/BDV viewer transforms are similarity transforms (rotation + uniform scale), so the three columns should agree closely; averaging them is a simplification, not an exact per-axis fix.
NB> this ignores perspective foreshortening (scale technically also depends on depth along the camera axis in BVV). Good enough here because clicks are first centered onto the focal plane (see
Bvv#registerCenterOnDoubleClickListener), where foreshortening is minimal- Parameters:
screenPx- the desired pick radius, in screen pixels- Returns:
- the equivalent world-space distance at the current zoom level, or
screenPxunscaled if the viewer transform isn't available (should not normally happen)
-
getFinishPathAction
Builds the Enter-key action: finishes the in-progress path, same as a double click, but without the spurious node a double click's own first (clickCount==1) click would leave behind. Deferred viapendingFinishif a segment is still being traced, exactly like the click-based finish path. -
getDiscardPathAction
Builds the Escape-key action: discards the in-progress path (seediscardCurrentPath()) without exiting tracing mode, so the user can immediately start a new path. -
discardCurrentPath
protected void discardCurrentPath()Discards the current in-progress path: cancels any in-flight segment search, clearstempPath/previousNodeand the preview overlay, and resets the tracing status row. Unlikeexit(),tracingEnabledis left untouched, so the user stays in tracing mode and can start a new path right away. No-op if tracing is disabled or there is nothing pending. -
cancelCurrentSearch
protected void cancelCurrentSearch()Cancels the A* search currently in flight (if any), viaFuture.cancel(boolean).BiSearch's loop already checks for thread interruption, so this actually stops the search. Has no effect during manual tracing (nothing to cancel) or when idle. -
updateUndoButtonState
protected void updateUndoButtonState()Recomputes whether anything is currently available to undo and notifies the viewer (seeupdateUndoButtonState(boolean)). Safe to call at any time, including before any undo-related UI exists. -
undoLastSegment
protected void undoLastSegment()Undoes the most recently confirmed segment, one click at a time (single-step; no redo). Ported fromSNT#undoLastSegment(): pops the last segment's node count offconfirmedSegmentSizesand removes that many trailing nodes fromtempPath. If that emptiestempPathentirely (undone back to the very first point), this falls back todiscardCurrentPath(), exactly as the classic 2D canvas cancels the whole path in that case. No-op if tracing is disabled, nothing has been confirmed yet, or a segment is currently being traced (undoing mid-search would race withdone()). -
getUndoSegmentAction
Builds the undo action shared by an Undo button (if any) and the Cmd/Ctrl+Z hotkey.- See Also:
-
exit
protected void exit() -
getToggleAction
-