pub struct ScatterMaskWidget {
pub mask: Vec<u8>,
pub level: u8,
/* private fields */
}Expand description
A multi-level mask over scatter points, selected by point index.
Mirrors silx ScatterMask: a 1D uint8 array the same length as the
scatter data, where 0 means unmasked and 1..=255 are the (up to 254)
non-overlapping mask levels.
Fields§
§mask: Vec<u8>Per-point mask level: 0 is unmasked, 1..=255 is a mask level. The
length equals the number of scatter points.
level: u8Current mask level edited by the tools (silx levelSpinBox,
range 1..=255).
Implementations§
Source§impl ScatterMaskWidget
impl ScatterMaskWidget
Sourcepub fn new(npoints: usize) -> Self
pub fn new(npoints: usize) -> Self
Create a scatter mask for npoints points, all initially unmasked.
Sourcepub fn reset_len(&mut self, npoints: usize)
pub fn reset_len(&mut self, npoints: usize)
Reset the mask to npoints points and clear it.
Mirrors silx reset(shape): a length change resets the undo history.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Set all points of the current level back to 0.
Mirrors silx BaseMask.clear(level).
Sourcepub fn clear_all(&mut self)
pub fn clear_all(&mut self)
Clear every mask level (reset the whole mask to 0).
Mirrors silx resetSelectionMask.
Sourcepub fn invert(&mut self)
pub fn invert(&mut self)
Invert the current mask level over all points.
0 points become the current level and current-level points become
0; points at other levels are untouched. Mirrors silx
BaseMask.invert(level).
Sourcepub fn commit(&mut self)
pub fn commit(&mut self)
Commit the current mask to the undo history.
Mirrors silx BaseMask.commit.
Sourcepub fn undo(&mut self) -> bool
pub fn undo(&mut self) -> bool
Restore the previous mask snapshot, if any. Returns true if applied.
Mirrors silx BaseMask.undo.
Sourcepub fn redo(&mut self) -> bool
pub fn redo(&mut self) -> bool
Restore the most recently undone snapshot, if any. Returns true if
applied.
Mirrors silx BaseMask.redo.
Sourcepub fn reset_history(&mut self)
pub fn reset_history(&mut self)
Reset the undo history to the current mask as the only baseline.
Mirrors silx BaseMask.resetHistory.
Sourcepub fn update_points(&mut self, level: u8, indices: &[usize], mask: bool)
pub fn update_points(&mut self, level: u8, indices: &[usize], mask: bool)
Mask or unmask the points at the given indices at level.
Mirrors silx ScatterMask.updatePoints (ScatterMaskToolsWidget.py:89):
when mask is true the points are set to level; otherwise only
points already at level and in indices are cleared. Indices outside
the buffer are ignored.
Sourcepub fn update_stencil(&mut self, level: u8, stencil: &[bool], mask: bool)
pub fn update_stencil(&mut self, level: u8, stencil: &[bool], mask: bool)
Mask or unmask points selected by a per-point boolean stencil at
level.
Mirrors silx BaseMask.updateStencil (_BaseMaskToolsWidget.py:249):
when mask is true the stencil-true points are set to level,
otherwise only points already at level and stencil-true are cleared.
stencil must be the same length as the mask.
Sourcepub fn update_disk(
&mut self,
level: u8,
center: (f32, f32),
radius: f32,
x: &[f32],
y: &[f32],
)
pub fn update_disk( &mut self, level: u8, center: (f32, f32), radius: f32, x: &[f32], y: &[f32], )
Mask points inside a disk of the given radius centered at
center = (cx, cy).
Mirrors silx ScatterMask.updateDisk (ScatterMaskToolsWidget.py:137):
the stencil is (y - cy)^2 + (x - cx)^2 < radius^2 (strict). x and
y are the point coordinate arrays (same length as the mask).
Sourcepub fn update_disk_with_mask(
&mut self,
level: u8,
center: (f32, f32),
radius: f32,
x: &[f32],
y: &[f32],
mask: bool,
)
pub fn update_disk_with_mask( &mut self, level: u8, center: (f32, f32), radius: f32, x: &[f32], y: &[f32], mask: bool, )
update_disk with an explicit mask/unmask flag. center = (cx, cy).
Sourcepub fn update_polygon(
&mut self,
level: u8,
vertices: &[(f32, f32)],
x: &[f32],
y: &[f32],
mask: bool,
)
pub fn update_polygon( &mut self, level: u8, vertices: &[(f32, f32)], x: &[f32], y: &[f32], mask: bool, )
Mask or unmask points inside a polygon at level.
Mirrors silx ScatterMask.updatePolygon (ScatterMaskToolsWidget.py:107):
a Polygon.is_inside(y, x) test per point. vertices are (y, x)
corners (matching the silx call site, which passes plot (y, x)); x
and y are the point coordinate arrays.
Sourcepub fn update_rectangle(
&mut self,
level: u8,
anchor: (f32, f32),
size: (f32, f32),
px: &[f32],
py: &[f32],
mask: bool,
)
pub fn update_rectangle( &mut self, level: u8, anchor: (f32, f32), size: (f32, f32), px: &[f32], py: &[f32], mask: bool, )
Mask or unmask points inside a rectangle at level.
Mirrors silx ScatterMask.updateRectangle (ScatterMaskToolsWidget.py:124):
the rectangle is built as the 4-vertex polygon
[(y, x), (y+height, x), (y+height, x+width), (y, x+width)] then the
polygon test is applied. anchor = (y, x) is the bottom-left corner and
size = (height, width); px/py are the point coordinate arrays.
Sourcepub fn update_below_threshold(
&mut self,
level: u8,
values: &[f32],
threshold: f32,
mask: bool,
)
pub fn update_below_threshold( &mut self, level: u8, values: &[f32], threshold: f32, mask: bool, )
Mask or unmask points whose value is below threshold at level.
Mirrors silx BaseMask.updateBelowThreshold over the scatter value
array (values < threshold).
Sourcepub fn update_between_thresholds(
&mut self,
level: u8,
values: &[f32],
min: f32,
max: f32,
mask: bool,
)
pub fn update_between_thresholds( &mut self, level: u8, values: &[f32], min: f32, max: f32, mask: bool, )
Mask or unmask points whose value is within [min, max] at level.
Mirrors silx BaseMask.updateBetweenThresholds
(min <= value <= max, inclusive).
Sourcepub fn update_above_threshold(
&mut self,
level: u8,
values: &[f32],
threshold: f32,
mask: bool,
)
pub fn update_above_threshold( &mut self, level: u8, values: &[f32], threshold: f32, mask: bool, )
Mask or unmask points whose value is above threshold at level.
Mirrors silx BaseMask.updateAboveThreshold (value > threshold).
Sourcepub fn mask_not_finite(&mut self, values: &[f32])
pub fn mask_not_finite(&mut self, values: &[f32])
Mask every point whose value is not finite (NaN or +/-infinity) at the current level.
Mirrors silx _BaseMaskToolsWidget.updateNotFinite over the scatter
value array (~numpy.isfinite(values)).
Auto Trait Implementations§
impl Freeze for ScatterMaskWidget
impl RefUnwindSafe for ScatterMaskWidget
impl Send for ScatterMaskWidget
impl Sync for ScatterMaskWidget
impl Unpin for ScatterMaskWidget
impl UnsafeUnpin for ScatterMaskWidget
impl UnwindSafe for ScatterMaskWidget
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.