Skip to main content

CompareImages

Struct CompareImages 

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

A retained widget that displays two co-registered images with a draggable split slider, mirroring silx CompareImages.

Create once, call Self::set_images to upload both images, then in the frame loop call Self::show_toolbar and Self::show.

let mut cmp = CompareImages::new(render_state, 0);
cmp.set_images((wa, ha), &data_a, (wb, hb), &data_b, Colormap::viridis(0.0, 1.0))?;

// frame loop
cmp.show_toolbar(ui);
cmp.show(ui);

Implementations§

Source§

impl CompareImages

Source

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

Create a new compare-images widget backed by wgpu plot id id.

Source

pub fn set_images( &mut self, shape_a: (u32, u32), data_a: &[f32], shape_b: (u32, u32), data_b: &[f32], colormap: Colormap, ) -> Result<(), PlotDataError>

Upload both images. Unlike the old single-shape API, A and B may have different shapes (silx setData(image1, image2)), each given as a (width, height) tuple; the alignment mode decides how they share a common display grid. Validates data_a.len() == width_a * height_a and data_b.len() == width_b * height_b.

Source

pub fn alignment(&self) -> CompareAlignment

Current image-alignment mode (silx getAlignmentMode).

Source

pub fn set_alignment(&mut self, alignment: CompareAlignment)

Set the image-alignment mode (silx setAlignmentMode).

Source

pub fn transformation(&self) -> Option<AffineTransformation>

The affine transform applied to image B to align it onto image A, or None when no SIFT registration is in effect — silx CompareImages.getTransformation.

silx populates the transform only from the AUTO/SIFT path (__createSiftData); getTransformation is None for ORIGIN/CENTER/ STRETCH. siplot matches this: the value is Some exactly while CompareAlignment::Auto registration has succeeded (it is cleared when the mode changes or registration fails), so it reads as None in every non-SIFT mode.

Source

pub fn keypoints_visible(&self) -> bool

Whether the matched SIFT keypoints are drawn over the images — silx getKeypointsVisible.

Source

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

Show or hide the matched SIFT keypoints overlay — silx setKeypointsVisible. The overlay only ever has points to draw in CompareAlignment::Auto (it is fed by the registration’s matched keypoints); in the other modes this flag has no visible effect.

Source

pub fn matched_keypoints(&self) -> &[MatchedKeypoint]

The matched SIFT keypoint pairs from the active registration (silx __matching_keypoints), or an empty slice when no registration is in effect.

Source

pub fn split(&self) -> f32

Current split position in [0, 1] — fraction of the width shown as A.

Source

pub fn set_split(&mut self, split: f32)

Set the split position.

Source

pub fn mode(&self) -> CompareMode

Current visualization mode.

Source

pub fn set_mode(&mut self, mode: CompareMode)

Set the visualization mode.

Source

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

Show mode + split controls in a compact toolbar row. Returns the current mode.

Call this before Self::show.

Source

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

Render the comparison image in ui.

Source

pub fn data_to_pixel(&self, x: f64, y: f64, axis: YAxis) -> Option<Pos2>

Map a data position to its on-screen pixel under the inner plot’s cached transform (None before the first frame caches the data area). Forwards to the inner PlotWidget; useful for hit-testing the draggable separator.

Source

pub fn raw_pixel_data(&self, x: f64, y: f64) -> (Option<f32>, Option<f32>)

The raw A and B pixel values under data position (x, y), mirroring silx CompareImages.getRawPixelData. (x, y) is in the reference of the displayed (aligned) grid; it is mapped back to each raw image’s own coordinates per the alignment mode by compare_aligned_coords. Each value is None when that image has no data or the mapped position is outside it.

Source

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

Show a status bar with the cursor’s data coordinate and the raw A / B pixel values under it (silx CompareImagesStatusBar, the ImageA:/ ImageB: labels), plus an Align: label summarising the SIFT affine when one is in effect. silx populates that transform only from its AUTO/SIFT alignment (Self::transformation is None for ORIGIN/CENTER/STRETCH), so the label appears only in AUTO, with the per-component breakdown (translation px / scale / rotation degrees) on hover. Call after Self::show, which updates the tracked cursor. GPU/UI — not covered by the tests.

Methods from Deref<Target = PlotWidget>§

Source

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

Render the widget in ui, handling interaction and plot item selection.

Source

pub fn show_with_context_menu( &mut self, ui: &mut Ui, menu_ext: impl FnMut(&mut Ui), ) -> PlotResponse

Render the widget like Self::show, appending custom entries to the plot’s built-in right-click context menu (after the Zoom Back / Reset Zoom items), mirroring silx plotContextMenu.py adding actions to the plot’s default menu.

This is the ONLY way to add custom menu entries: calling Response::context_menu on the returned response would register a second menu on a response that already carries the built-in one, and egui then closes the menu in the same frame it opens — no menu appears at all. The closure only renders entries and signals choices (e.g. via captured flags applied after show returns); it cannot borrow the widget itself while the plot is being shown.

Source

pub fn plot(&self) -> &Plot

Access the underlying plot model.

Source

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

Mutably access the underlying plot model.

Source

pub fn backend(&self) -> &WgpuBackend

Access the underlying backend.

Source

pub fn backend_mut(&mut self) -> &mut WgpuBackend

Mutably access the underlying backend.

Source

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

Toggle whether newly added data updates the displayed data limits.

Source

pub fn auto_reset_zoom(&self) -> bool

Whether newly added data updates the displayed data limits.

Source

pub fn set_interaction_mode(&mut self, mode: PlotInteractionMode)

Set the primary pointer interaction mode used by Self::show.

Source

pub fn interaction_mode(&self) -> PlotInteractionMode

Primary pointer interaction mode used by Self::show.

Source

pub fn set_roi_create_mode(&mut self, kind: RoiDrawKind)

Arm on-plot creation of a new ROI of kind (silx RegionOfInterestManager.start(roiClass)). A convenience for set_interaction_mode(PlotInteractionMode::RoiCreate(kind)): the next primary drag (or click, for RoiDrawKind::Point/RoiDrawKind::Cross) draws the shape; finishing it appends the ROI to plot().rois and queues a PlotEvent::RoiCreated. Creation re-arms continuously until the mode is changed.

Source

pub fn roi_creation_message(&self) -> Option<String>

The ROI-creation status message for the current interaction mode and ROI count, for display in a host status bar (silx InteractiveRegionOfInterestManager.getMessage). Some("Select {name}s ({n} selected)") while an on-plot ROI creation mode is armed (the kind being drawn + the current ROI count), else None. Delegates to PlotInteractionMode::roi_creation_message.

Source

pub fn events(&self) -> &[PlotEvent]

Queued plot events since the last drain.

Source

pub fn drain_events(&mut self) -> Vec<PlotEvent>

Take queued plot events.

Source

pub fn add_curve(&mut self, x: &[f64], y: &[f64], color: Color32) -> ItemHandle

Add a curve with default silx-like styling.

Source

pub fn add_curve_with_legend( &mut self, x: &[f64], y: &[f64], color: Color32, legend: impl Into<String>, ) -> ItemHandle

Add a curve and assign a legend label.

Source

pub fn add_curve_data(&mut self, curve: &CurveData) -> ItemHandle

Add a curve from an existing CurveData value.

Source

pub fn add_curve_data_with_legend( &mut self, curve: &CurveData, legend: impl Into<String>, ) -> ItemHandle

Add a curve from CurveData and assign a legend label in one call.

Source

pub fn add_curve_spec(&mut self, spec: CurveSpec<'_>) -> ItemHandle

Add a curve from the full backend spec.

Source

pub fn update_curve_spec( &mut self, handle: ItemHandle, spec: CurveSpec<'_>, ) -> bool

Replace an existing curve by handle.

Source

pub fn update_curve_data( &mut self, handle: ItemHandle, curve: &CurveData, ) -> bool

Replace an existing curve by handle from CurveData.

Source

pub fn add_scatter( &mut self, x: &[f64], y: &[f64], color: Color32, ) -> ItemHandle

Add a scatter item: markers at every (x, y) point, with no connecting line.

Source

pub fn add_scatter_with_legend( &mut self, x: &[f64], y: &[f64], color: Color32, legend: impl Into<String>, ) -> ItemHandle

Add a scatter item and assign a legend label.

Source

pub fn add_scatter_with_symbol( &mut self, x: &[f64], y: &[f64], color: Color32, symbol: Symbol, symbol_size: f32, ) -> ItemHandle

Add a scatter item with explicit marker symbol and size.

Source

pub fn add_histogram( &mut self, edges: &[f64], counts: &[f64], color: Color32, ) -> Result<ItemHandle, PlotDataError>

Add a histogram from bin edges and bin counts.

Source

pub fn add_histogram_with_legend( &mut self, edges: &[f64], counts: &[f64], color: Color32, legend: impl Into<String>, ) -> Result<ItemHandle, PlotDataError>

Add a histogram and assign a legend label.

Source

pub fn add_histogram_aligned( &mut self, positions: &[f64], counts: &[f64], color: Color32, align: HistogramAlign, ) -> Result<ItemHandle, PlotDataError>

Add a histogram from N bin positions and N counts, deriving the N + 1 bin edges from align (silx Histogram.setData(align=)).

The edges are computed by histogram_edges; positions.len() must equal counts.len() (mismatched lengths surface as PlotDataError::HistogramLength from the underlying Self::add_histogram).

Source

pub fn add_histogram_aligned_with_legend( &mut self, positions: &[f64], counts: &[f64], color: Color32, align: HistogramAlign, legend: impl Into<String>, ) -> Result<ItemHandle, PlotDataError>

Add an aligned histogram (see Self::add_histogram_aligned) and assign a legend label.

Source

pub fn add_image( &mut self, width: u32, height: u32, data: &[f32], colormap: Colormap, ) -> ItemHandle

Add a scalar image with unit scale and origin (0, 0).

Source

pub fn try_add_image( &mut self, width: u32, height: u32, data: &[f32], colormap: Colormap, ) -> Result<ItemHandle, PlotDataError>

Add a scalar image, returning an error instead of panicking on length mismatch.

Source

pub fn add_image_default( &mut self, width: u32, height: u32, data: &[f32], ) -> ItemHandle

Add a scalar image using the widget’s default colormap.

Source

pub fn try_add_image_default( &mut self, width: u32, height: u32, data: &[f32], ) -> Result<ItemHandle, PlotDataError>

Add a scalar image using the widget’s default colormap, returning an error instead of panicking on length mismatch.

Source

pub fn add_image_with_geometry( &mut self, width: u32, height: u32, data: &[f32], colormap: Colormap, geometry: ImageGeometry, ) -> Result<ItemHandle, PlotDataError>

Add a scalar image with explicit origin/scale/alpha.

Source

pub fn add_image_with_legend( &mut self, width: u32, height: u32, data: &[f32], legend: impl Into<String>, ) -> ItemHandle

Add a scalar image using the widget’s default colormap and assign a legend label.

Source

pub fn add_rgba_image( &mut self, width: u32, height: u32, data: &[[u8; 4]], ) -> ItemHandle

Add a direct RGBA image with unit scale and origin (0, 0).

Source

pub fn add_rgba_image_with_legend( &mut self, width: u32, height: u32, data: &[[u8; 4]], legend: impl Into<String>, ) -> ItemHandle

Add a direct RGBA image and assign a legend label.

Source

pub fn try_add_rgba_image( &mut self, width: u32, height: u32, data: &[[u8; 4]], ) -> Result<ItemHandle, PlotDataError>

Add a direct RGBA image, returning an error instead of panicking on length mismatch.

Source

pub fn add_rgba_image_with_geometry( &mut self, width: u32, height: u32, data: &[[u8; 4]], geometry: ImageGeometry, ) -> Result<ItemHandle, PlotDataError>

Add a direct RGBA image with explicit origin/scale/alpha.

Source

pub fn add_image_data(&mut self, image: &ImageData) -> ItemHandle

Add an image from an existing ImageData value.

Source

pub fn add_image_spec(&mut self, spec: ImageSpec<'_>) -> ItemHandle

Add an image from the full backend spec.

Source

pub fn update_image_spec( &mut self, handle: ItemHandle, spec: ImageSpec<'_>, ) -> bool

Replace an existing image by handle.

Source

pub fn try_update_image( &mut self, handle: ItemHandle, width: u32, height: u32, data: &[f32], colormap: Colormap, ) -> Result<bool, PlotDataError>

Replace an existing scalar image, returning an error instead of panicking on length mismatch.

Source

pub fn try_update_rgba_image( &mut self, handle: ItemHandle, width: u32, height: u32, data: &[[u8; 4]], ) -> Result<bool, PlotDataError>

Replace an existing direct RGBA image, returning an error instead of panicking on length mismatch.

Source

pub fn update_image_data( &mut self, handle: ItemHandle, image: &ImageData, ) -> bool

Replace an existing image by handle from ImageData.

Source

pub fn add_mask( &mut self, width: u32, height: u32, mask: &[bool], color: Color32, ) -> Result<ItemHandle, PlotDataError>

Add a boolean mask as a transparent RGBA overlay.

Source

pub fn add_mask_with_geometry( &mut self, width: u32, height: u32, mask: &[bool], color: Color32, geometry: ImageGeometry, ) -> Result<ItemHandle, PlotDataError>

Add a boolean mask as a transparent RGBA overlay with explicit geometry.

Source

pub fn add_rgba_mask( &mut self, width: u32, height: u32, pixels: &[[u8; 4]], ) -> Result<ItemHandle, PlotDataError>

Add raw per-pixel RGBA pixels as a mask-kind overlay item.

Unlike add_mask (a boolean stencil painted in one color), this carries fully resolved per-pixel RGBA, so a multi-level mask can map each level through its own LUT entry (silx _BaseMaskToolsWidget discrete mask colormap). pixels is row-major, width * height long.

Source

pub fn add_mask_with_legend( &mut self, width: u32, height: u32, mask: &[bool], color: Color32, legend: impl Into<String>, ) -> Result<ItemHandle, PlotDataError>

Add a boolean mask overlay and assign a legend label.

Source

pub fn add_horizontal_profile_curve( &mut self, width: u32, height: u32, data: &[f32], row: u32, color: Color32, ) -> Result<ItemHandle, PlotDataError>

Add a horizontal image profile as a curve.

Source

pub fn add_vertical_profile_curve( &mut self, width: u32, height: u32, data: &[f32], column: u32, color: Color32, ) -> Result<ItemHandle, PlotDataError>

Add a vertical image profile as a curve.

Source

pub fn add_triangles(&mut self, spec: TriangleSpec<'_>) -> ItemHandle

Add a triangle mesh.

Source

pub fn add_triangles_data(&mut self, triangles: &Triangles) -> ItemHandle

Add a triangle mesh from an existing Triangles value.

Source

pub fn add_triangles_data_with_legend( &mut self, triangles: &Triangles, legend: impl Into<String>, ) -> ItemHandle

Add a triangle mesh from Triangles and assign a legend label.

Source

pub fn add_shape(&mut self, spec: ShapeSpec<'_>) -> ItemHandle

Add a shape overlay.

Source

pub fn add_shape_data(&mut self, shape: &Shape) -> ItemHandle

Add a shape overlay from an existing Shape value.

Source

pub fn add_shape_data_with_legend( &mut self, shape: &Shape, legend: impl Into<String>, ) -> ItemHandle

Add a shape overlay from Shape and assign a legend label.

Source

pub fn add_rectangle( &mut self, x0: f64, y0: f64, x1: f64, y1: f64, color: Color32, fill: bool, ) -> ItemHandle

Add a rectangle shape.

Source

pub fn add_marker(&mut self, spec: MarkerSpec<'_>) -> ItemHandle

Add a point or line marker.

Source

pub fn add_marker_data(&mut self, marker: &Marker) -> ItemHandle

Add a marker from an existing Marker value.

Source

pub fn add_marker_data_with_legend( &mut self, marker: &Marker, legend: impl Into<String>, ) -> ItemHandle

Add a marker from Marker and assign a legend label.

Source

pub fn add_point_marker( &mut self, x: f64, y: f64, color: Color32, symbol: Symbol, ) -> ItemHandle

Add a point marker.

Source

pub fn add_x_marker(&mut self, x: f64, color: Color32) -> ItemHandle

Add a vertical marker line.

Source

pub fn add_y_marker( &mut self, y: f64, color: Color32, axis: YAxis, ) -> ItemHandle

Add a horizontal marker line.

Source

pub fn marker_position(&self, handle: ItemHandle) -> Option<(f64, f64)>

The current data position (x, y) of the marker handle (silx MarkerBase.getPosition), or None if no marker with that handle exists. For a line marker the off-axis coordinate is reported as 0.0 (see Marker::position).

Source

pub fn set_marker_position( &mut self, handle: ItemHandle, x: f64, y: f64, ) -> bool

Move the marker handle to data position (x, y), applying the marker’s drag constraint (silx MarkerBase.setPosition), and emit PlotEvent::MarkerMoved. Returns false if no marker with that handle exists (no event is emitted in that case).

The constraint is applied via Marker::drag anchored at the marker’s current position, so a 'horizontal' / 'vertical' preset pins the constrained coordinate exactly as an on-screen drag would. A non-draggable marker does not move (Marker::drag is a no-op when is_draggable is false), matching silx, but the call still returns true and emits the event because the marker exists.

Source

pub fn remove(&mut self, handle: ItemHandle) -> bool

Remove an item by handle.

Source

pub fn clear(&mut self)

Remove all items.

Source

pub fn clear_curves(&mut self)

Remove all curve-like items.

Source

pub fn clear_images(&mut self)

Remove all image-like items.

Source

pub fn clear_items(&mut self)

Remove all shape and triangle overlay items.

Source

pub fn clear_markers(&mut self)

Remove all marker items.

Source

pub fn clear_histograms(&mut self)

Remove all histogram items.

Source

pub fn clear_scatters(&mut self)

Remove all scatter items.

Source

pub fn clear_masks(&mut self)

Remove all mask overlay items.

Source

pub fn remove_curve(&mut self, handle: ItemHandle) -> bool

Remove a curve-like item by handle.

Source

pub fn remove_image(&mut self, handle: ItemHandle) -> bool

Remove an image-like item by handle.

Source

pub fn remove_histogram(&mut self, handle: ItemHandle) -> bool

Remove a histogram item by handle.

Source

pub fn remove_scatter(&mut self, handle: ItemHandle) -> bool

Remove a scatter item by handle.

Source

pub fn remove_mask(&mut self, handle: ItemHandle) -> bool

Remove a mask item by handle.

Source

pub fn remove_marker(&mut self, handle: ItemHandle) -> bool

Remove a marker item by handle.

Source

pub fn remove_overlay_item(&mut self, handle: ItemHandle) -> bool

Remove a shape or triangle overlay item by handle.

Source

pub fn get_items(&self) -> Vec<ItemHandle>

Return every backend item handle in draw order.

Source

pub fn get_all_curves(&self) -> Vec<ItemHandle>

Return curve-like handles in draw order.

Source

pub fn get_all_images(&self) -> Vec<ItemHandle>

Return image-like handles in draw order.

Source

pub fn get_all_markers(&self) -> Vec<ItemHandle>

Return marker handles in draw order.

Source

pub fn get_all_histograms(&self) -> Vec<ItemHandle>

Return histogram handles in draw order.

Source

pub fn get_all_scatters(&self) -> Vec<ItemHandle>

Return scatter handles in draw order.

Source

pub fn get_all_masks(&self) -> Vec<ItemHandle>

Return mask handles in draw order.

Source

pub fn item_by_legend(&self, legend: &str) -> Option<ItemHandle>

Return the first item handle with this legend label.

Source

pub fn curve_by_legend(&self, legend: &str) -> Option<ItemHandle>

Return the first curve-like item handle with this legend label.

Source

pub fn image_by_legend(&self, legend: &str) -> Option<ItemHandle>

Return the first image-like item handle with this legend label.

Source

pub fn histogram_by_legend(&self, legend: &str) -> Option<ItemHandle>

Return the first histogram item handle with this legend label.

Source

pub fn scatter_by_legend(&self, legend: &str) -> Option<ItemHandle>

Return the first scatter item handle with this legend label.

Source

pub fn mask_by_legend(&self, legend: &str) -> Option<ItemHandle>

Return the first mask item handle with this legend label.

Source

pub fn item_kind(&self, handle: ItemHandle) -> Option<PlotItemKind>

Return the high-level family of an item.

Source

pub fn set_item_legend( &mut self, handle: ItemHandle, legend: impl Into<String>, ) -> bool

Attach or replace the legend label for an item.

Source

pub fn clear_item_legend(&mut self, handle: ItemHandle) -> bool

Remove the legend label from an item.

Source

pub fn item_legend(&self, handle: ItemHandle) -> Option<&str>

Legend label assigned to an item.

Source

pub fn set_curve_x_label( &mut self, handle: ItemHandle, label: impl Into<String>, ) -> bool

Set the curve’s X-axis label, shown on the X axis while it is the active curve (silx Curve.setXLabel). The active curve’s label overrides the graph default (Self::set_graph_x_label). Returns false for an unknown handle.

Source

pub fn clear_curve_x_label(&mut self, handle: ItemHandle) -> bool

Remove the curve’s X-axis label, so the graph default shows when it is active (silx setting the label back to None).

Source

pub fn curve_x_label(&self, handle: ItemHandle) -> Option<&str>

The curve’s X-axis label, if set (silx Curve.getXLabel).

Source

pub fn set_curve_y_label( &mut self, handle: ItemHandle, label: impl Into<String>, ) -> bool

Set the curve’s Y-axis label, shown on the left or right (y2) axis (per the curve’s Y-axis binding) while it is the active curve (silx Curve.setYLabel). Returns false for an unknown handle.

Source

pub fn clear_curve_y_label(&mut self, handle: ItemHandle) -> bool

Remove the curve’s Y-axis label, so the graph default shows when it is active.

Source

pub fn curve_y_label(&self, handle: ItemHandle) -> Option<&str>

The curve’s Y-axis label, if set (silx Curve.getYLabel).

Source

pub fn active_item(&self) -> Option<ItemHandle>

Currently active item.

Source

pub fn set_active_item(&mut self, item: Option<ItemHandle>) -> bool

Set the active item, emitting PlotEvent::ActiveItemChanged when it changes.

Source

pub fn active_curve(&self) -> Option<ItemHandle>

Currently active curve-like item.

Source

pub fn active_curve_style(&self) -> &CurveStyle

The override style applied to the active curve when active-curve handling is enabled (silx PlotWidget.getActiveCurveStyle).

Source

pub fn is_active_curve_handling(&self) -> bool

Whether the active curve is highlighted with the active-curve style (silx PlotWidget.isActiveCurveHandling).

Source

pub fn set_active_curve_style(&mut self, style: CurveStyle)

Set the override style applied to the active curve (silx PlotWidget.setActiveCurveStyle), then re-apply it to the active curve through the single highlight owner so the change takes effect at once.

Source

pub fn set_active_curve_handling(&mut self, enabled: bool)

Enable or disable active-curve highlighting (silx PlotWidget.setActiveCurveHandling), then re-sync the active curve: enabling applies the highlight, disabling reverts it to its base style.

Source

pub fn active_curve_line_style(&self) -> Option<LineStyle>

The current line style of the active curve-like item, if one is active and its style is retained.

Source

pub fn is_default_plot_lines(&self) -> bool

Whether curves default to being drawn with a connecting line (silx PlotWidget.isDefaultPlotLines).

Source

pub fn is_default_plot_points(&self) -> bool

Whether curves default to being drawn with point markers (silx PlotWidget.isDefaultPlotPoints).

Source

pub fn set_default_plot_lines(&mut self, flag: bool) -> usize

Set the default line style of every curve, mirroring silx PlotWidget.setDefaultPlotLines: true applies a solid line (silx "-"), false removes the line (silx " "). Like silx, this resets the line style of all existing curves (silx iterates getAllCurves; siplot iterates PlotItemKind::Curve items, the equivalent set — histograms and scatters are excluded). Returns the number of curves whose line style actually changed.

Source

pub fn set_default_plot_points(&mut self, flag: bool) -> usize

Set the default symbol of every curve, mirroring silx PlotWidget.setDefaultPlotPoints: true applies the o (Circle) symbol (silx.config.DEFAULT_PLOT_SYMBOL), false removes the symbol. Resets the symbol of all existing curves (same item set as Self::set_default_plot_lines). Returns the number of curves whose symbol actually changed.

Source

pub fn cycle_curve_style(&mut self) -> (bool, bool)

Cycle the plot-wide default curve style, mirroring silx CurveStyleAction: advances the (lines, points) state line-only → line+symbol → symbol-only → line-only (via crate::widget::actions::control::next_curve_style_state), then applies the new defaults to every curve through Self::set_default_plot_lines and Self::set_default_plot_points. Returns the new (lines, points) state.

Source

pub fn set_curve_y_axis(&mut self, handle: ItemHandle, axis: YAxis) -> bool

Move a curve between the left (YAxis::Left) and right (YAxis::Right) Y axis (silx legend Map to left / Map to right). Clones the retained CurveData, sets y_axis, re-applies it through Self::update_curve_data, then recomputes auto limits because the curve’s bounds now contribute to a different Y/Y2 range. Returns false if the handle is unknown or has no retained curve data (non-curve item).

Source

pub fn set_curve_points_visible( &mut self, handle: ItemHandle, visible: bool, ) -> bool

Show or hide a curve’s point markers (silx legend checkable Points). Toggling is lossless: hiding stashes the current Symbol in a UI-only restore cache and showing restores that exact variant (falling back to a default only if the curve was created with no symbol). The drawn state is decided solely by CurveData::symbol; the cache is never read by any render/bounds/legend path. Returns false if the handle is unknown or has no retained curve data (non-curve item).

Source

pub fn set_curve_lines_visible( &mut self, handle: ItemHandle, visible: bool, ) -> bool

Show or hide a curve’s connecting line (silx legend checkable Lines). Toggling is lossless: hiding stashes the current LineStyle in a UI-only restore cache and showing restores that exact style (e.g. Dashed), falling back to a solid line only if the curve was created with no line. The drawn state is decided solely by CurveData::line_style; the cache is never read by any render/bounds/legend path. Returns false if the handle is unknown or has no retained curve data (non-curve item).

Source

pub fn set_all_symbols(&mut self, symbol: Option<Symbol>) -> usize

Set the marker symbol of every curve-like item (curve, histogram, scatter) in one call, mirroring silx SymbolToolButton / _SymbolToolButtonBase._markerChanged, which calls setSymbol on every SymbolMixIn item in the plot. Some(symbol) draws that marker at each point; None hides the markers (silx’s “None” entry, an empty symbol string). Returns the number of items whose symbol actually changed.

Source

pub fn set_all_symbol_sizes(&mut self, size: f32) -> usize

Set the marker size (logical points) of every curve-like item, mirroring silx SymbolToolButton / _SymbolToolButtonBase._sizeChanged, which calls setSymbolSize on every single-symbol-size SymbolMixIn item. siplot curves carry one size per item (no per-point sizes), so every curve-like item qualifies. Returns the number of items whose size actually changed.

Source

pub fn set_active_curve(&mut self, item: Option<ItemHandle>) -> bool

Set the active curve-like item.

Source

pub fn active_image(&self) -> Option<ItemHandle>

Currently active image-like item.

Source

pub fn set_active_image(&mut self, item: Option<ItemHandle>) -> bool

Set the active image-like item.

Source

pub fn set_item_visible(&mut self, handle: ItemHandle, visible: bool) -> bool

Show or hide an item. Hidden items are excluded from all draw passes. Returns false if the handle is unknown.

Source

pub fn is_item_visible(&self, handle: ItemHandle) -> bool

Whether an item is currently visible.

Source

pub fn set_item_z(&mut self, handle: ItemHandle, z: f32) -> bool

Set the draw-order z-value for an item. Within each GPU item layer (images, curves), higher-z items are drawn on top. Returns false if the handle is unknown.

Source

pub fn item_z_value(&self, handle: ItemHandle) -> f32

Current z-value for an item.

Source

pub fn item_stats(&self, handle: ItemHandle) -> Option<&ItemStats>

Return retained statistics for an item.

Source

pub fn curve_stats(&self, handle: ItemHandle) -> Option<&CurveStats>

Return retained statistics for a curve-like item.

Source

pub fn image_stats(&self, handle: ItemHandle) -> Option<&ImageStats>

Return retained statistics for an image-like item.

Source

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

Draw a selectable legend list. Clicking a row body makes it active; clicking the eye icon toggles visibility.

Source

pub fn show_stats(&self, ui: &mut Ui, handle: ItemHandle) -> bool

Draw retained statistics for an item. Returns false if the handle is unknown.

Source

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

Draw retained statistics for the active item.

Source

pub fn feed_active_stats( &self, stats: &mut StatsWidget, viewport: Option<((f64, f64), (f64, f64))>, ) -> bool

Feed the active item’s retained data into a StatsWidget, recomputing its rows from the live data (silx StatsWidget bound to the active item). The row is labelled with the item’s legend.

viewport is the visible data rectangle ((x0, x1), (y0, y1)), used only when the widget’s on-visible-data toggle is enabled. Returns true when there is an active item with retained scalar data to feed; false otherwise (the widget is then fed an empty input and shows no rows).

Source

pub fn feed_all_stats( &self, stats: &mut StatsWidget, viewport: Option<((f64, f64), (f64, f64))>, ) -> usize

Feed every plot item that has retained scalar data into a StatsWidget, one row per item labelled by its legend — silx StatsWidget in its default all-items mode, the counterpart to the active-only Self::feed_active_stats (silx setDisplayOnlyActiveItem chooses between them). Items with no retained scalar data (RGBA images, triangles, shapes, markers) are skipped. Returns the number of rows fed.

viewport is the visible data rectangle ((x0, x1), (y0, y1)), used only when the widget’s on-visible-data toggle is enabled.

Source

pub fn feed_roi_stats(&self, widget: &mut RoiStatsWidget) -> bool

Compute per-ROI statistics over the active item’s retained data and store them in widget (silx ROIStatsWidget bound to the active item): one row per ROI on the plot, reduced inside that ROI via image_roi_stats (image) / curve_roi_stats (curve). Returns true when there is an active item with retained data to reduce; false otherwise (the widget is then cleared).

Source

pub fn show_roi_stats_widget(&self, ui: &mut Ui, widget: &mut RoiStatsWidget)

Feed the active item’s per-ROI statistics into widget and render its table (silx ROIStatsWidget). Combines Self::feed_roi_stats with RoiStatsWidget::ui; the table follows the active item and the live ROI list.

Source

pub fn feed_curves_roi_stats(&self, widget: &mut CurvesRoiWidget) -> bool

Compute per-ROI raw/net counts and raw/net area over the active curve and store them in widget (silx CurvesROIWidget): one row per curve ROI (those with an x-span), reduced via curve_roi_counts. Returns true when the active item is a curve with retained data; false otherwise (the active item is an image, or there is none — the widget is cleared, since these counts are curve-specific).

Source

pub fn show_curves_roi_widget(&self, ui: &mut Ui, widget: &mut CurvesRoiWidget)

Feed the active curve’s per-ROI counts into widget and render its table (silx CurvesROIWidget). Combines Self::feed_curves_roi_stats with CurvesRoiWidget::ui; the table follows the active curve and the live ROI list.

Source

pub fn set_fit_target(&self, fit: &mut FitWidget, handle: ItemHandle) -> bool

Feed an item’s retained curve (x, y) into a FitWidget as its fit target, so a fit runs against the live curve (silx FitWidget.setData bound to a plot curve). Returns true when the item is a curve with retained data; false for an unknown handle or a non-curve item (the fit widget is left unchanged in that case).

Source

pub fn set_active_fit_target(&self, fit: &mut FitWidget) -> bool

Feed the active item’s retained curve (x, y) into a FitWidget as its fit target (silx FitWidget bound to the active curve). Returns true when the active item is a curve with retained data.

Source

pub fn show_active_stats_widget( &self, ui: &mut Ui, stats: &mut StatsWidget, viewport: Option<((f64, f64), (f64, f64))>, )

Feed the active item’s retained data into a StatsWidget and render its table (silx StatsWidget). Combines Self::feed_active_stats with StatsWidget::ui; the widget recomputes as the active item changes.

Source

pub fn show_all_stats_widget( &self, ui: &mut Ui, stats: &mut StatsWidget, viewport: Option<((f64, f64), (f64, f64))>, )

Feed all items with retained scalar data into a StatsWidget and render its table (silx all-items StatsWidget). Combines Self::feed_all_stats’s selection with StatsWidget::ui; the table follows every plot item, recomputing as items are added/removed.

Source

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

Draw an egui-native plot toolbar.

Source

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

Draw the silx LimitsToolBar (tools/LimitsToolBar.py): editable X-min/X-max/Y-min/Y-max fields that display and control the plot’s display limits.

The fields always reflect the current effective limits (silx’s limitsChanged slot, which refreshes the edits on every plot limit change). Committing an edit applies it through set_graph_x_limits / set_graph_y_limits, ordering the two bounds so min ≤ max (silx _xFloatEditChanged swaps when max < min). The Y fields edit the primary (left) axis.

Source

pub fn show_toolbar_with<R>( &mut self, ui: &mut Ui, add_contents: impl FnOnce(&mut Ui, &mut Self) -> R, ) -> (ToolbarResponse, R)

Draw the standard toolbar and append caller-provided controls in the same toolbar row.

The closure receives this plot after the built-in controls have been drawn, so custom actions can mutate plot state while still sharing the standard toolbar layout.

Source

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

Draw toolbar then plot in the remaining UI.

Source

pub fn show_with_toolbar_with<R>( &mut self, ui: &mut Ui, add_toolbar_contents: impl FnOnce(&mut Ui, &mut Self) -> R, ) -> (PlotWithToolbarResponse, R)

Draw the standard toolbar plus caller controls, then draw the plot.

Source

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

Show a compact profile-mode toolbar with None / Horizontal / Vertical buttons.

The selected mode is stored in egui temp-memory keyed by the plot id so it persists across frames. Returns the current mode.

Place it inside show_toolbar_with so it sits in the same toolbar row:

let (_, mode) = plot.show_toolbar_with(ui, |ui, plot| {
    ui.separator();
    plot.show_profile_toolbar(ui)
});
Source

pub fn set_limits( &mut self, xmin: f64, xmax: f64, ymin: f64, ymax: f64, y2: Option<(f64, f64)>, )

Set graph limits.

Source

pub fn reset_zoom(&mut self)

Reset the displayed limits from accumulated data bounds.

Source

pub fn zoom_back(&mut self) -> bool

Restore the most recently pushed view from the limits history (silx LimitsHistory.pop), emitting PlotEvent::LimitsChanged if the view changed. Returns true if a stored view was restored, or false if the history was empty (callers fall back to Self::reset_zoom, matching silx LimitsHistory.pop).

Source

pub fn x_limits(&self) -> (f64, f64)

Return the current X axis limits (min, max).

Source

pub fn get_graph_x_limits(&self) -> (f64, f64)

Return the current X axis limits (min, max) (alias for x_limits).

Source

pub fn set_graph_x_limits(&mut self, xmin: f64, xmax: f64)

Set the X axis display limits.

Source

pub fn y_limits(&self, axis: YAxis) -> Option<(f64, f64)>

Return the current Y axis limits (min, max) for axis, or None if the axis has not been given explicit limits.

Source

pub fn get_graph_y_limits(&self, axis: YAxis) -> Option<(f64, f64)>

Return Y axis limits (alias for y_limits).

Source

pub fn set_graph_y_limits(&mut self, ymin: f64, ymax: f64, axis: YAxis)

Set the Y axis display limits. Pass YAxis::Right for the secondary axis.

Source

pub fn add_extra_y_axis(&mut self, side: AxisSide) -> usize

Add an extra (stacked) Y axis on side and return its index, usable as YAxis::Extra(index) with set_curve_y_axis, set_graph_y_limits, set_graph_y_label, and the extra_y_* methods below. The axis starts linear, autoscaling, with no range or label; bind curves to it and either set an explicit range or let reset-zoom autoscale fit it. Same-side extra axes stack outward in creation order (silx-style multi-axis).

Source

pub fn extra_y_axis_count(&self) -> usize

The number of extra (stacked) Y axes (Plot::extra length).

Source

pub fn set_extra_y_autoscale(&mut self, index: usize, on: bool) -> bool

Set whether extra axis index refits to its curves’ data on reset-zoom (silx per-axis setAutoScale). Returns false for an unknown index.

Source

pub fn set_extra_y_log(&mut self, index: usize, on: bool) -> bool

Enable or disable a log10 scale on extra axis index (its range must be strictly positive when on). Returns false for an unknown index.

Source

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

Return true if extra axis index is logarithmic (false for an unknown index).

Source

pub fn set_x_log(&mut self, on: bool)

Enable or disable a log10 X axis. Limits must be strictly positive when on.

Source

pub fn set_graph_x_log(&mut self, on: bool)

Enable or disable a log10 X axis (alias for set_x_log).

Source

pub fn is_x_logarithmic(&self) -> bool

Return true if the X axis is logarithmic.

Source

pub fn is_graph_x_log(&self) -> bool

Return true if the X axis is logarithmic (alias for is_x_logarithmic).

Source

pub fn set_y_log(&mut self, on: bool)

Enable or disable a log10 Y axis. Limits must be strictly positive when on.

Source

pub fn set_graph_y_log(&mut self, on: bool)

Enable or disable a log10 Y axis (alias for set_y_log).

Source

pub fn is_y_logarithmic(&self) -> bool

Return true if the Y axis is logarithmic.

Source

pub fn is_graph_y_log(&self) -> bool

Return true if the Y axis is logarithmic (alias for is_y_logarithmic).

Source

pub fn set_x_inverted(&mut self, on: bool)

Invert the X axis direction (right-to-left).

Source

pub fn is_x_inverted(&self) -> bool

Return true if the X axis is inverted.

Source

pub fn set_x_min_range(&mut self, min: Option<f64>)

Minimum allowed X span (prevents zooming in below this width).

Source

pub fn set_x_max_range(&mut self, max: Option<f64>)

Maximum allowed X span (prevents zooming out above this width).

Source

pub fn set_x_min_pos(&mut self, min: Option<f64>)

Minimum allowed X lower bound (prevents panning below this value).

Source

pub fn set_x_max_pos(&mut self, max: Option<f64>)

Maximum allowed X upper bound (prevents panning above this value).

Source

pub fn set_y_min_range(&mut self, min: Option<f64>)

Minimum allowed Y span (prevents zooming in below this height).

Source

pub fn set_y_max_range(&mut self, max: Option<f64>)

Maximum allowed Y span (prevents zooming out above this height).

Source

pub fn set_y_min_pos(&mut self, min: Option<f64>)

Minimum allowed Y lower bound (prevents panning below this value).

Source

pub fn set_y_max_pos(&mut self, max: Option<f64>)

Maximum allowed Y upper bound (prevents panning above this value).

Source

pub fn x_constraints(&self) -> AxisConstraints

Read back current X axis constraints.

Source

pub fn y_constraints(&self) -> AxisConstraints

Read back current Y axis constraints.

Source

pub fn set_y_inverted(&mut self, on: bool)

Invert the Y axis direction (top-to-bottom, as in image coordinates).

Source

pub fn is_y_inverted(&self) -> bool

Return true if the Y axis is inverted.

Source

pub fn set_x_tick_count(&mut self, n: Option<usize>)

Set the maximum number of major ticks on the X axis.

The chrome calls nice_ticks with this cap, so the actual count may be lower to keep round step sizes. Pass None to restore the default (8 ticks).

Source

pub fn x_tick_count(&self) -> Option<usize>

Return the current X tick-count cap, or None for the default (8).

Source

pub fn set_y_tick_count(&mut self, n: Option<usize>)

Set the maximum number of major ticks on the Y axis.

Pass None to restore the default (6 ticks).

Source

pub fn y_tick_count(&self) -> Option<usize>

Return the current Y tick-count cap, or None for the default (6).

Source

pub fn set_keep_data_aspect_ratio(&mut self, on: bool)

Keep data square on screen by expanding the tighter axis’ display range.

Source

pub fn is_keep_data_aspect_ratio(&self) -> bool

Source

pub fn set_axes_margins(&mut self, margins: Margins)

Source

pub fn axes_margins(&self) -> Margins

Source

pub fn set_graph_title(&mut self, title: impl Into<String>)

Source

pub fn graph_title(&self) -> Option<&str>

Source

pub fn clear_graph_title(&mut self)

Source

pub fn set_graph_x_label(&mut self, label: impl Into<String>)

Source

pub fn graph_x_label(&self) -> Option<&str>

Source

pub fn clear_graph_x_label(&mut self)

Source

pub fn set_graph_y_label(&mut self, label: impl Into<String>, axis: YAxis)

Source

pub fn graph_y_label(&self, axis: YAxis) -> Option<&str>

Source

pub fn clear_graph_y_label(&mut self, axis: YAxis)

Source

pub fn set_foreground_colors(&mut self, foreground: Color32, grid: Color32)

Source

pub fn set_background_colors( &mut self, background: Color32, data_background: Color32, )

Source

pub fn data_background_color(&self) -> Color32

Source

pub fn foreground_color(&self) -> Option<Color32>

Source

pub fn grid_color(&self) -> Option<Color32>

Source

pub fn set_graph_grid(&mut self, on: bool)

Source

pub fn graph_grid(&self) -> bool

Source

pub fn set_graph_grid_mode(&mut self, mode: GraphGrid)

Source

pub fn graph_grid_mode(&self) -> GraphGrid

Source

pub fn show_colorbar(&self) -> bool

Whether the built-in colorbar is drawn when the plot has a colormap (silx colorbar visibility). Defaults to true.

Source

pub fn set_show_colorbar(&mut self, show: bool)

Set whether the built-in colorbar is drawn when the plot has a colormap. Composite views that render their own dedicated colorbar (e.g. ImageView) set this false on their internal image plot so the colorbar is not drawn twice.

Source

pub fn interactive_colorbar(&self) -> bool

Whether the colorbar is the interactive pyqtgraph-style histogram colorbar (drag the handles to set the colormap vmin/vmax) rather than a static strip. See Self::set_interactive_colorbar.

Source

pub fn set_interactive_colorbar(&mut self, interactive: bool)

Make the colorbar an interactive histogram colorbar (drag-to-set-levels). The drag is surfaced via PlotResponse::colorbar_dragged_levels for the caller to apply to the colormap (and re-upload the image); supply the value-distribution histogram with Self::set_colorbar_histogram and the axis range with Self::set_colorbar_value_range.

Source

pub fn set_colorbar_histogram( &mut self, histogram: Option<(Vec<u64>, Vec<f64>)>, )

Set the value-distribution histogram drawn beside the interactive colorbar’s gradient ((counts, edges) from crate::core::histogram::compute_histogram); None draws gradient + handles only.

Source

pub fn set_colorbar_value_range(&mut self, range: Option<(f64, f64)>)

Set the value range (min, max) the interactive colorbar’s axis spans (handles move within it); None falls back to the colormap’s vmin/vmax.

Source

pub fn set_graph_minor_grid(&mut self, on: bool)

Source

pub fn graph_minor_grid(&self) -> bool

Source

pub fn default_colormap(&self) -> &Colormap

Source

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

Source

pub fn colorbar_colormap(&self) -> Option<&Colormap>

Source

pub fn get_image_pixels_raw(&self) -> Option<Vec<f64>>

The active image’s raw scalar pixels as f64, row-major (silx ImageData.getData), or None when the active item is not a scalar image with retained data.

Used by Self::autoscale_active_image to drive a raw-pixel autoscale, and exposed so callers can compute their own value statistics over the exact pixels the image was uploaded with (NaN-preserving).

Source

pub fn autoscale_active_image( &mut self, mode: AutoscaleMode, ) -> Option<(f64, f64)>

Autoscale the active image’s colormap value limits from its raw pixels using mode (silx ColormapDialog Stddev3 / Percentile autoscale, ColormapDialog.py:450-480).

Computes the (vmin, vmax) range over the active image’s raw scalar pixels (NaN-ignoring; AutoscaleMode::Stddev3 = mean ± 3·std, AutoscaleMode::Percentile = the colormap’s percentile pair), then re-uploads the image with a colormap carrying those limits (preserving the LUT / normalization / gamma). Returns the applied (vmin, vmax), or None when the active item is not a scalar image with retained data.

Source

pub fn set_active_image_levels(&mut self, vmin: f64, vmax: f64) -> bool

Set the active image’s colormap value limits to an explicit (vmin, vmax), re-uploading the image with those levels (preserving the LUT / normalization / gamma / geometry, like Self::autoscale_active_image).

This is the apply path for the interactive colorbar drag: feed the (vmin, vmax) from PlotResponse::colorbar_dragged_levels back here so a bare Plot2D/Plot1D updates its contrast live. Returns true when a scalar image with retained data was updated, false otherwise.

Source

pub fn image_alpha(&self, handle: ItemHandle) -> Option<f32>

The global opacity of the scalar image at handle (silx image getAlpha, AlphaMixIn), or None when the item is not a scalar image with retained data.

This is the read side of the AlphaSlider item bindings (ActiveImageAlphaSlider/NamedItemAlphaSlider): getItem().getAlpha(). Only images carry a retained, re-applicable alpha — curves bake opacity into their color and scatters retain no data, so neither is addressable here (the bindings disable for them, mirroring silx’s “no item → disabled” rule).

Source

pub fn set_image_alpha(&mut self, handle: ItemHandle, alpha: f32) -> bool

Set the global opacity of the scalar image at handle, re-uploading it with the new alpha and the same pixels / geometry / colormap (silx image setAlpha, AlphaMixIn). Returns true when a scalar image with retained data was updated, false otherwise.

alpha is clamped to [0, 1] (silx AlphaMixIn.setAlpha). This is the write side of the ActiveImageAlphaSlider/NamedItemAlphaSlider bindings (getItem().setAlpha(value)).

Source

pub fn active_image_handle(&self) -> Option<ItemHandle>

The active item’s handle when it is a scalar image with retained data, else None (silx getActiveImage() restricted to images that carry an addressable alpha). Used by ActiveImageAlphaSlider to detect when the active-image binding changes and re-seed the slider from the new item.

Source

pub fn active_image_alpha(&self) -> Option<f32>

The active image’s global opacity (silx ActiveImageAlphaSlider getItem().getAlpha() = getActiveImage().getAlpha()), or None when the active item is not a scalar image with retained data.

Source

pub fn set_active_image_alpha(&mut self, alpha: f32) -> bool

Set the active image’s global opacity (silx ActiveImageAlphaSlider getItem().setAlpha(value)). Returns true when a scalar active image was updated, false otherwise. alpha is clamped to [0, 1].

Source

pub fn apply_median_filter( &mut self, kernel_width: usize, conditional: bool, ) -> bool

Apply a median filter to the active image and replace it in place (silx MedianFilterAction / MedianFilter2DAction re-adding the filtered image with addImage(replace=True)).

Reads the active image’s raw scalar pixels and geometry, runs crate::widget::actions::analysis::median_filter_2d with a square (kernel_width, kernel_width) kernel (silx MedianFilter2DAction) and the default mode='nearest' edge handling, then re-uploads the result with the same origin / scale / colormap. kernel_width is forced odd (silx MedianFilterDialog spinbox step 2, min 1) by rounding up to the next odd value; a width of 1 (or 0) leaves the image unchanged.

Returns true if a scalar image was filtered and replaced, or false when the active item is not a scalar image with retained data.

Source

pub fn apply_median_filter_1d( &mut self, kernel_width: usize, conditional: bool, ) -> bool

Apply a 1D median filter to the active image (silx MedianFilter1DAction, kernel (kernel_width, 1)), replacing it in place.

Same contract as Self::apply_median_filter but with a column-1 kernel that filters along image rows (the height / y direction).

Source

pub fn active_image_histogram( &self, n_bins: Option<usize>, ) -> Option<PixelHistogram>

Compute the pixel-intensity histogram of the active image (silx PixelIntensitiesHistoAction).

Reads the active image’s raw scalar pixels and runs crate::widget::actions::analysis::pixel_intensity_histogram with the silx defaults (bin count min(1024, floor(sqrt(finite_count))), finite range, last_bin_closed, non-finite excluded). Pass n_bins to override the bin count (mirroring the widget’s editable bin-count field), or None for the silx default.

Returns None when the active item is not a scalar image with retained data, or when the image has no finite pixel.

Source

pub fn set_graph_cursor(&mut self, on: bool)

Source

pub fn graph_cursor(&self) -> bool

Source

pub fn data_to_pixel(&self, x: f64, y: f64, axis: YAxis) -> Option<Pos2>

Source

pub fn pixel_to_data(&self, p: Pos2, axis: YAxis) -> Option<(f64, f64)>

Source

pub fn plot_bounds_in_pixels(&self) -> Option<Rect>

Source

pub fn snap_cursor(&self, cursor: [f64; 2], mode: SnappingMode) -> Option<Snap>

Snap the data-space cursor to the nearest data point under the live mode, porting silx PositionInfo._updateStatusBar’s snap (PositionInfo.py:196-292) against this widget’s retained items.

Builds a SnapItem per item (kind, is_item_visible, whether it shows a symbol, whether it is the active item), runs snapping_candidates to pick the participating items for mode, projects every candidate’s retained vertices to pixels through the cached display transform (axis-aware, so a y2 curve snaps in its own axis), and returns the snap_to_nearest result within SNAP_THRESHOLD_DIST logical pixels — its data is the snapped coordinate to show in a PositionInfo, with a None result meaning “no snap” (feed false to PositionInfo::ui_snapped).

Curves, histograms, and scatters all participate: each is stored with retained RetainedItemData::Curve { x, y } vertices (a scatter is a symbol-only curve-kind item, Self::add_scatter), so a SCATTER-mode snap matches scatter points and a CURVE-mode snap matches curve and histogram vertices. Items whose data is not retained as vertices (images, triangles, shapes, markers) classify as SnapItemKind::Other and are never candidates.

Returns None when snapping is not engaged (no CURVE/SCATTER flag), nothing is within the radius, or no frame has been rendered yet (the transform is uncached). The SnappingMode::CROSSHAIR gate is the caller’s precondition (silx :198), as is the empty/None-cursor case.

Source

pub fn add_roi(&mut self, roi: Roi) -> usize

Source

pub fn rois(&self) -> &[ManagedRoi]

Source

pub fn rois_mut(&mut self) -> &mut [ManagedRoi]

Source

pub fn clear_rois(&mut self)

Source

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

Remove the ROI at index, keeping the current-ROI selection consistent via the Plot owner (silx RegionOfInterestManager.removeRoi). Emits PlotEvent::RoiAboutToBeRemoved before the removal (silx sigRoiAboutToBeRemoved), so a listener can still read the ROI being dropped; an out-of-range index is ignored (no event).

Source

pub fn add_managed_roi(&mut self, managed: ManagedRoi) -> usize

Append a fully-specified ManagedRoi (geometry + appearance) and return its index, emitting PlotEvent::RoiAdded (silx RegionOfInterestManager.addRoisigRoiAdded). Use this to add a styled/named ROI in one call; Self::add_roi adds bare geometry with default appearance.

Source

pub fn ruler_active(&self) -> bool

Whether the ruler measurement tool is armed (silx RulerToolButton.isChecked).

Source

pub fn ruler_roi(&self) -> Option<usize>

The index of the live ruler line ROI in rois, or None when no ruler line has been drawn (or the ruler is disarmed).

Source

pub fn set_ruler_active(&mut self, active: bool)

Arm or disarm the ruler measurement tool (silx RulerToolButton toggle).

Arming enters a line-ROI draw (PlotInteractionMode::RoiCreate(RoiDrawKind::Line)), remembering the prior mode; each completed drag draws a line ROI whose name is its measured length (RulerToolButton::distance_text), recomputed in show — a new measurement replaces the previous ruler line. Disarming removes the ruler line and restores the prior interaction mode (silx deselect). A no-op if already in the requested state.

Source

pub fn roi_interaction_mode(&self, index: usize) -> Option<RoiInteractionMode>

The current handle-editing interaction mode of the ROI at index (silx InteractionModeMixIn.getInteractionMode). None for an out-of-range index or a ROI kind without interaction modes (everything but Arc/Band).

Source

pub fn set_roi_interaction_mode( &mut self, index: usize, mode: RoiInteractionMode, ) -> bool

Switch the interaction mode of the ROI at index (silx InteractionModeMixIn.setInteractionMode). Emits PlotEvent::RoiInteractionModeChanged and returns true only when the index is valid and mode is one of that ROI’s Roi::available_interaction_modes; an out-of-range index or a mode foreign to the kind is ignored (no event).

Source

pub fn set_roi_color(&mut self, index: usize, color: Color32)

Set the per-ROI color override at index (silx RegionOfInterest.setColor). An out-of-range index is ignored.

Source

pub fn set_roi_name(&mut self, index: usize, name: impl Into<String>)

Set the display name of the ROI at index (silx RegionOfInterest.setName). An out-of-range index is ignored.

Source

pub fn set_roi_line_width(&mut self, index: usize, width: f32)

Set the outline line width of the ROI at index (silx RegionOfInterest.setLineWidth). An out-of-range index is ignored.

Source

pub fn set_roi_line_style(&mut self, index: usize, style: RoiLineStyle)

Set the outline stroke style of the ROI at index (silx RegionOfInterest.setLineStyle). An out-of-range index is ignored.

Source

pub fn set_roi_line_gap_color( &mut self, index: usize, gap_color: Option<Color32>, )

Set the gap fill color of a dashed/dotted ROI outline at index (silx LineMixIn.setLineGapColor); None leaves the gaps transparent. Only visible on a dashed/dotted line style. An out-of-range index is ignored.

Source

pub fn set_roi_fill(&mut self, index: usize, fill: bool)

Set whether the ROI at index fills its interior (silx RegionOfInterest.setFill). An out-of-range index is ignored.

Source

pub fn current_roi(&self) -> Option<usize>

The index of the current/highlighted ROI, or None (silx RegionOfInterestManager.getCurrentRoi).

Source

pub fn set_current_roi(&mut self, index: Option<usize>)

Set the current/highlighted ROI by index, or None to clear it (silx RegionOfInterestManager.setCurrentRoi). Highlights exactly that ROI on the plot; an out-of-range index clears the selection. Emits PlotEvent::CurrentRoiChanged when the current ROI actually changes (silx sigCurrentRoiChanged).

Source

pub fn show_roi_manager(&mut self, ui: &mut Ui) -> Option<usize>

Show a compact ROI manager panel: a table listing all current ROIs — each row carries an editable name (silx label column), the geometry shown as a make-current selector (silx row selection → sigCurrentRoiChanged, highlighted when current), and a remove button — followed by buttons to add each ROI kind and a clear-all button. Mirrors silx RegionOfInterestTableWidget / RegionOfInterestManager.

Per-row edits are routed through the owner APIs (Self::set_roi_name, Self::set_current_roi, Self::remove_roi) so events fire and the current-ROI index stays consistent.

New ROIs are centered on the current plot view. Returns the index of any newly added ROI, or None when none was added this frame.

Source

pub fn pick_item(&self, p: Pos2, item: ItemHandle) -> Option<PickResult>

Source

pub fn items_back_to_front(&self) -> Vec<ItemHandle>

Source

pub fn replot(&mut self)

Source

pub fn save_graph(&self, path: &Path, size: (u32, u32)) -> Result<(), SaveError>

Source

pub fn save_graph_with_format( &self, path: &Path, size: (u32, u32), format: SaveFormat, dpi: u32, ) -> Result<(), SaveError>

Render the figure to path in the given SaveFormat at dpi, generalizing Self::save_graph (PNG-only) over silx’s raster save formats (PNG/PPM/SVG/TIFF) plus the raster-embedding EPS/PDF. Faithful to silx BackendBase.saveGraph(fileName, fileFormat, dpi). The GPU readback + file write are native shims; the per-format encoding is unit-tested in crate::render::save.

Source

pub fn save_to_path( &self, path: &Path, size: (u32, u32), ) -> Result<bool, SaveError>

Save to path, dispatching by its extension (silx SaveAction): a .csv path writes the active curve’s (x, y) data; a figure extension (png/ppm/svg/tif/tiff/eps/pdf) renders the figure to a size pixel image in the matching SaveFormat. Returns Ok(true) when a file was written, Ok(false) when the path’s extension is not a recognized save target or (for CSV) there is no active curve to save.

All recognized figure formats are routed through Self::save_graph_with_format at DEFAULT_SAVE_DPI; PNG remains byte-identical to Self::save_graph (both go through crate::render::save::encode_png). The extension-to-target decision is the pure, unit-tested SaveTarget::from_path.

Source

pub fn save_dialog(&self, size: (u32, u32)) -> Result<bool, SaveError>

Open a native save-file dialog (silx SaveAction file dialog) and save the figure or active-curve data to the chosen path via Self::save_to_path. Returns Ok(true) when a file was written, Ok(false) when the dialog was cancelled or the chosen path was not a recognized target. The dialog is a native shim; the save logic it calls is covered by unit tests.

Source

pub fn save_rois_to_path(&self, path: impl AsRef<Path>) -> Result<()>

Save the current ROIs to path in the siplot ROI text format (silx CurvesROIWidget.save(filename)) via crate::save_rois. The encoder is unit-tested (core::roi_io); this is the widget-level wrapper.

Source

pub fn load_rois_from_path(&mut self, path: impl AsRef<Path>) -> Result<()>

Replace the current ROIs with those loaded from path (silx CurvesROIWidget.load(filename)) via crate::load_rois. The previous set is cleared first, so this emits PlotEvent::RoisCleared followed by one PlotEvent::RoiAdded per loaded ROI.

Source

pub fn save_rois_dialog(&self) -> Result<bool>

Open a native save-file dialog (silx CurvesROIWidget save button) and write the current ROIs to the chosen path via Self::save_rois_to_path. Returns Ok(true) when a file was written, Ok(false) on cancel. The dialog is a native shim; the save logic it calls is unit-tested.

Source

pub fn load_rois_dialog(&mut self) -> Result<bool>

Open a native open-file dialog (silx CurvesROIWidget load button) and replace the current ROIs with those from the chosen path via Self::load_rois_from_path. Returns Ok(true) when a file was loaded, Ok(false) on cancel. The dialog is a native shim.

Source

pub fn copy_to_clipboard(&self, size: (u32, u32)) -> Result<bool, SaveError>

Copy a size pixel snapshot of the figure to the system clipboard as an image (silx CopyAction, which renders the plot to a bitmap and calls QApplication.clipboard().setImage).

The figure is rendered to a PNG (the only in-memory figure encoding available), decoded back to RGBA via decode_png_to_rgba, shaped into an arboard::ImageData via rgba_to_clipboard_image, then placed on the clipboard. The GPU readback and the clipboard call are untested native shims; the PNG-decode and RGBA-shaping logic between them is unit-tested.

Source

pub fn print_graph(&self, size: (u32, u32)) -> Result<bool, SaveError>

Print a size pixel snapshot of the figure to the default system printer (silx PrintAction.printPlot).

Mirrors silx’s raster print path: silx renders the plot to a PNG (_plotAsPNG) and draws that bitmap onto the printer via QPainter/QPrinter — not vector graphics. Here the figure is rasterized to a temp PNG via Self::save_graph (the only public figure-encoding entry point), then submitted to the default printer with the printers crate. Returns Ok(true) when a print job was queued, Ok(false) when no default printer is available (the silx getDefaultPrinter analogue).

The GPU readback and the printer submission are untested native shims (a real printer / spooler is required); the rasterization step reuses the unit-tested crate::render::save encoders, and the temp-path naming is unit-tested via print_temp_png_path. The toolbar Print button opens a printer-selection dialog (crate::widget::print_dialog::PrintDialog) that routes to Self::print_graph_to; this method is the dialog-less direct path to the default printer.

Source

pub fn print_graph_to( &self, printer_name: &str, size: (u32, u32), ) -> Result<bool, SaveError>

Print a size pixel snapshot of the figure to the system printer with the given system name (the print dialog’s chosen target). Returns Ok(false) when no printer of that name exists (e.g. it disappeared between the dialog opening and the click).

Source

pub fn reset_zoom_to_data(&mut self)

Apply accumulated data bounds to the current view.

Trait Implementations§

Source§

impl Deref for CompareImages

Source§

type Target = PlotWidget

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for CompareImages

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

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> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,