Class GuidedTutorial

java.lang.Object
sc.fiji.snt.gui.GuidedTutorial

public class GuidedTutorial extends Object
Drives a short, click-through tutorial over a live AbstractBigViewer (Bdv or Bvv, including Stream mode): flies the camera to a region of interest, shows a CalloutManager callout describing what to do there, and only advances once a caller-supplied check confirms the user did it. A failed check re-shows an earlier (by default, the same) step instead of silently moving on.

This class owns no tracing logic and reads only public SNT/PathAndFillManager state, so the same tutorial works whether the viewer is Bdv or Bvv, and regardless of the data backing it (in-memory image or Stream mode).

Positioning relies on AbstractBigViewer.flyTo(BoundingBox) always centering its target on screen: a single reused, invisible anchor kept at the canvas's center is enough to point a callout at "wherever flyTo just centered", with no per-frame tracking of the camera transform. The anchor's screen position is read from AbstractBigViewer.getViewerCanvas().

Author:
Tiago Ferreira
  • Constructor Details

  • Method Details

    • setPreAction

      public GuidedTutorial setPreAction(Runnable preAction)
      Sets a one-off action to run at the top of start(), before the first step is shown, e.g. switching the viewer into whatever tracing mode the tutorial expects. Replaces any previously set action; null (the default) runs nothing.
      Returns:
      this, for chaining onto the constructor call
    • setPreAction

      public GuidedTutorial setPreAction(Runnable preAction, long settleMs)
      As setPreAction(Runnable), but waits settleMs after running preAction before showing the first step, instead of showing it immediately. Useful when preAction triggers window arranging/resizing or anything else whose on-screen effects don't land synchronously.
      Returns:
      this, for chaining onto the constructor call
    • setPostAction

      public GuidedTutorial setPostAction(Runnable postAction)
      Sets a one-off action to run at the end of stop(), once the tutorial's own teardown is done e.g., to undo whatever setPreAction(Runnable) changed. Runs exactly once per start()/stop() pair, even though stop() itself is safe to call more than once; runs even if the teardown above throws Replaces any previously set action; null (the default) runs nothing.
      Returns:
      this, for chaining onto the constructor call
    • start

      public void start()
      Runs setPreAction(java.lang.Runnable), waits its settle delay (if any), then starts the tutorial from its first step
    • stop

      public void stop()
      Aborts the tutorial: hides the current callout, forgets the anchor, unregisters the state listener, then runs setPostAction(java.lang.Runnable). Called automatically once the last step is dismissed, or as soon as the viewer's window closes.
    • rotate

      public static Consumer<AbstractBigViewer> rotate(int axis, double degrees, long durationMs)
      Returns a GuidedTutorial.Step camera action that orbits the view by degrees around axis (0 = X, i.e. tumbling around the horizontal screen axis; 1 = Y, tumbling around the vertical screen axis; 2 = Z, spinning in-plane around the line of sight), pivoting on the current screen center - i.e. on whatever the step's own roi just centered via AbstractBigViewer.flyTo(BoundingBox) - so the framed region stays put and only orbits, rather than swinging off-screen. Animates over durationMs (0 = immediate).

      The pivot-preserving matrix is composed by hand (plain get/set arithmetic) rather than via AffineTransform3D#rotate, which pivots on the transform's own (world) origin, not on whatever is currently centered on screen.