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
impl ImageStack
Sourcepub fn new(render_state: &RenderState, id: PlotId) -> Self
pub fn new(render_state: &RenderState, id: PlotId) -> Self
Create an empty image stack backed by wgpu plot id id.
Sourcepub fn set_frames(&mut self, frames: Vec<Option<Frame>>)
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.
Sourcepub fn set_loader(&mut self, loader: Arc<dyn FrameLoader>)
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).
Sourcepub fn set_sources(&mut self, sources: Vec<String>)
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.
Sourcepub fn sources(&self) -> &[String]
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.
Sourcepub fn remove_source(&mut self, index: usize)
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.
Sourcepub fn set_n_prefetch(&mut self, n: usize)
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.
Sourcepub fn n_prefetch(&self) -> usize
pub fn n_prefetch(&self) -> usize
The prefetch radius (slots preloaded on each side; silx getNPrefetch).
Sourcepub fn set_current(&mut self, index: usize)
pub fn set_current(&mut self, index: usize)
Jump to frame index, clamped to [0, len). An empty stack is a no-op.
Sourcepub fn next_frame(&mut self)
pub fn next_frame(&mut self)
Step to the next frame, clamping at the last. No-op at the last frame.
Sourcepub fn prev_frame(&mut self)
pub fn prev_frame(&mut self)
Step to the previous frame, clamping at the first. No-op at the first.
Sourcepub fn first_frame(&mut self)
pub fn first_frame(&mut self)
Jump to the first frame (silx _firstClicked).
Sourcepub fn last_frame(&mut self)
pub fn last_frame(&mut self)
Jump to the last frame (silx _lastClicked). No-op on an empty stack.
Sourcepub fn is_visible(&self, index: usize) -> bool
pub fn is_visible(&self, index: usize) -> bool
Whether frame index is currently visible. Out-of-range is false.
Sourcepub fn set_visible(&mut self, index: usize, visible: bool)
pub fn set_visible(&mut self, index: usize, visible: bool)
Set frame index’s visibility. Out-of-range is a no-op.
Sourcepub fn toggle_visible(&mut self, index: usize)
pub fn toggle_visible(&mut self, index: usize)
Toggle frame index’s visibility. Out-of-range is a no-op.
Sourcepub fn frame_label(&self, index: usize) -> String
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.
Sourcepub fn current_is_displayable(&self) -> bool
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).
Sourcepub fn set_colormap(&mut self, colormap: Colormap)
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).
Sourcepub fn set_auto_reset_zoom(&mut self, reset: bool)
pub fn set_auto_reset_zoom(&mut self, reset: bool)
Whether to reset the zoom when the displayed frame changes
(silx setAutoResetZoom, default true).
Sourcepub fn is_auto_reset_zoom(&self) -> bool
pub fn is_auto_reset_zoom(&self) -> bool
true when the displayed frame change resets the zoom
(silx isAutoResetZoom).
Sourcepub fn set_table_visible(&mut self, visible: bool)
pub fn set_table_visible(&mut self, visible: bool)
Toggle whether the frame table is shown (silx toggle button,
_ToggleableUrlSelectionTable.toggleUrlSelectionTable).
Sourcepub fn ui(&mut self, ui: &mut Ui) -> Response
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.
Sourcepub fn show_toolbar(&mut self, ui: &mut Ui)
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§
impl !RefUnwindSafe for ImageStack
impl !Sync for ImageStack
impl !UnwindSafe for ImageStack
impl Freeze for ImageStack
impl Send for ImageStack
impl Unpin for ImageStack
impl UnsafeUnpin for ImageStack
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.