Skip to main content

ImageStack

Struct ImageStack 

Source
pub struct ImageStack { /* private fields */ }
Expand description

Browse an in-memory ordered list of 2D frames.

Owns an internal Plot2D (like ComplexImageView/StackView) plus the pure FrameNav navigation state. The displayed image is rebuilt in place from the current slot, reusing the plot item handle so browsing does not reset the zoom unless Self::set_auto_reset_zoom is enabled (silx _autoResetZoom, default true).

let mut stack = ImageStack::new(render_state, 0);
stack.set_frames(vec![
    Some(Frame::new(2, 2, vec![0.0, 1.0, 2.0, 3.0], Some("a".into()))),
    None, // empty slot -> waiting overlay
]);

// frame loop
stack.ui(ui);

Implementations§

Source§

impl ImageStack

Source

pub fn new(render_state: &RenderState, id: PlotId) -> Self

Create an empty image stack backed by wgpu plot id id.

Source

pub fn set_frames(&mut self, frames: Vec<Option<Frame>>)

Replace the whole frame list with in-memory frames, resetting the current index to 0 and marking every frame visible (silx setUrls -> reset then re-add). Leaves the lazy-loading mode: any source list and pending load state are cleared, so these resident frames are shown as-is.

Source

pub fn set_loader(&mut self, loader: Arc<dyn FrameLoader>)

Set the loader used to turn a source string into a Frame off the UI thread (silx setUrlLoaderClass, ImageStack.py :207-215). Must be set before (or together with) Self::set_sources for lazy loading to run; sources browsed to while no loader is set stay empty (waiting overlay).

Source

pub fn set_sources(&mut self, sources: Vec<String>)

Switch to lazy loading from sources (silx setUrls, ImageStack.py :337-361): each source is an opaque string the FrameLoader resolves to a frame on demand. Every slot starts empty (waiting overlay) and is loaded on a background thread when browsed to (and, with a prefetch radius set, when it falls within it). Resets the current index to 0 and drops any in-memory frames previously set.

Source

pub fn sources(&self) -> &[String]

The source strings backing the lazy path, in slot order (empty in the in-memory Self::set_frames mode). Mirrors silx getUrls.

Source

pub fn remove_source(&mut self, index: usize)

Remove slot index from a lazy-mode stack (silx removeUrl / sigUrlRemoved): drops its source, its frame/visibility, and its load state together so the four parallel lanes stay aligned, then keeps the displayed frame where possible (the nav adjusts its current index: a removal before the current shifts it down, removing the current points at the next frame clamped to the new last, removing after is index-neutral). Out-of-range, or a call in the in-memory Self::set_frames mode, is a no-op.

This is the single owner of slot removal: every lane (sources, schedule, the nav’s frames/visible) is mutated here in lockstep, so sources.len() == frames.len() holds by construction.

Source

pub fn set_n_prefetch(&mut self, n: usize)

Set the prefetch radius: the number of neighbouring slots on each side of the current slot to preload in the background (silx setNPrefetch, ImageStack.py :294-304 — “in total 2*n DataUrls”). 0 disables prefetch. The new radius takes effect on the next render.

Source

pub fn n_prefetch(&self) -> usize

The prefetch radius (slots preloaded on each side; silx getNPrefetch).

Source

pub fn len(&self) -> usize

Number of frame slots in the stack.

Source

pub fn is_empty(&self) -> bool

true when the stack holds no frame slots.

Source

pub fn current(&self) -> usize

Index of the current frame.

Source

pub fn set_current(&mut self, index: usize)

Jump to frame index, clamped to [0, len). An empty stack is a no-op.

Source

pub fn next_frame(&mut self)

Step to the next frame, clamping at the last. No-op at the last frame.

Source

pub fn prev_frame(&mut self)

Step to the previous frame, clamping at the first. No-op at the first.

Source

pub fn first_frame(&mut self)

Jump to the first frame (silx _firstClicked).

Source

pub fn last_frame(&mut self)

Jump to the last frame (silx _lastClicked). No-op on an empty stack.

Source

pub fn is_visible(&self, index: usize) -> bool

Whether frame index is currently visible. Out-of-range is false.

Source

pub fn set_visible(&mut self, index: usize, visible: bool)

Set frame index’s visibility. Out-of-range is a no-op.

Source

pub fn toggle_visible(&mut self, index: usize)

Toggle frame index’s visibility. Out-of-range is a no-op.

Source

pub fn frame_label(&self, index: usize) -> String

The label shown for frame index in the table: the frame’s own label, Frame N (1-based) when unset, or Frame N (empty) for an empty slot. Out-of-range returns an empty string.

Source

pub fn current_is_displayable(&self) -> bool

true when the current frame slot holds a displayable, visible image; false for an empty slot, a hidden frame, or a length-mismatched frame, in which cases the waiting overlay is shown (silx: empty-slot branch of setCurrentUrl clears the plot and shows WaitingOverlay).

Source

pub fn set_colormap(&mut self, colormap: Colormap)

Set the colormap applied to every frame (silx frames use the plot’s active colormap; this exposes it directly).

Source

pub fn set_auto_reset_zoom(&mut self, reset: bool)

Whether to reset the zoom when the displayed frame changes (silx setAutoResetZoom, default true).

Source

pub fn is_auto_reset_zoom(&self) -> bool

true when the displayed frame change resets the zoom (silx isAutoResetZoom).

Source

pub fn set_table_visible(&mut self, visible: bool)

Toggle whether the frame table is shown (silx toggle button, _ToggleableUrlSelectionTable.toggleUrlSelectionTable).

Source

pub fn plot(&self) -> &Plot2D

Access the underlying Plot2D.

Source

pub fn plot_mut(&mut self) -> &mut Plot2D

Mutably access the underlying Plot2D.

Source

pub fn ui(&mut self, ui: &mut Ui) -> Response

Render the composite widget: an optional frame table, a navigation row (first/prev slider next/last with a counter), and the plot with the waiting overlay drawn on top when the current slot has no image.

Returns the egui Response of the plot area.

Source

pub fn show_toolbar(&mut self, ui: &mut Ui)

Show only the navigation toolbar (first/prev slider next/last with a cur/len counter), without the frame table or plot. A standalone entry point over the same row Self::ui draws, for callers that lay the plot out themselves (silx FrameBrowser / HorizontalSliderWithBrowser).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,