erlab.interactive.imagetool.viewer_linking

Linking and history decorators for ImageTool viewer widgets.

Functions

apply_splitter_layout(slicers, sizes, ...)

Apply a layout to compatible slicers outside user history.

link_slicer([func, indices, steps, color])

Sync decorated methods across multiple ImageSlicerArea instances.

record_history([method])

Log history before calling the decorated method.

suppress_history([method])

Ignore history changes made within the decorated method.

Classes

LinkSyncResult([values, sync, arguments])

List return value with private link-sync metadata.

SlicerLinkProxy(*slicers[, link_colors, ...])

Internal class for handling linked ImageSlicerArea s.

class erlab.interactive.imagetool.viewer_linking.LinkSyncResult(values=(), *, sync=True, arguments=None)[source]

Bases: list

List return value with private link-sync metadata.

erlab.interactive.imagetool.viewer_linking.suppress_history(method=None)[source]

Ignore history changes made within the decorated method.

erlab.interactive.imagetool.viewer_linking.record_history(method=None)[source]

Log history before calling the decorated method.

Sync decorated methods across multiple ImageSlicerArea instances.

Parameters:
  • func (Callable | None, default: None) – The method to sync across multiple instances of ImageSlicerArea.

  • indices (bool, default: False) – If True, the input argument named value given to func are interpreted as indices, and will be converted to appropriate values for other instances of ImageSlicerArea. The behavior of this conversion is determined by steps. If True, An input argument named axis of type integer must be present in the decorated method to determine the axis along which the index is to be changed.

  • steps (bool, default: False) – If False, considers value as an absolute index. If True, considers value as a relative value such as the number of steps or bins. See the implementation of SlicerLinkProxy for more information.

  • color (bool, default: False) – Boolean whether the decorated method is related to visualization, such as colormap control.

erlab.interactive.imagetool.viewer_linking.apply_splitter_layout(slicers, sizes, source_ndim)[source]

Apply a layout to compatible slicers outside user history.

class erlab.interactive.imagetool.viewer_linking.SlicerLinkProxy(*slicers, link_colors=True, align_splitters=True)[source]

Bases: object

Internal class for handling linked ImageSlicerArea s.

Parameters:
  • *slicers (ImageSlicerArea) – The slicers to link.

  • link_colors (bool, default: True) – Whether to sync color related changes, by default True.

  • align_splitters (bool, default: True) – Whether compatible slicers should adopt the existing linked layout when joining the link, by default True.

property children: WeakSet
property num_children: int
add(slicer_area)[source]
remove(slicer_area)[source]
align_splitter_sizes(source)[source]

Align compatible linked layouts to source without recording history.

sync(source, funcname, arguments, source_dims, indices, steps, color, transaction_id, keep_pending)[source]

Propagate changes across multiple ImageSlicerAreas.

This method is invoked every time a method decorated with link_slicer() in a linked ImageSlicerArea is called.

Parameters:
  • source (ImageSlicerArea) – Instance of ImageSlicerArea corresponding to the called method.

  • funcname (str) – Name of the called method.

  • arguments (dict[str, Any]) – Arguments included in the function call.

  • source_dims (tuple[Hashable, ...]) – Dimension order on source before the linked method changed it.

  • indices (bool) – Arguments given to the decorator. See link_slicer()

  • steps (bool) – Arguments given to the decorator. See link_slicer()

  • color (bool) – Arguments given to the decorator. See link_slicer()

convert_args(source, target, args, source_dims, indices, steps, transaction_id, keep_pending)[source]
static convert_axis(source_dims, target, axis)[source]
classmethod convert_axes(source_dims, target, axes)[source]
static convert_index(source, target, source_axis, target_axis, index, steps)[source]