napari_track_edit.data_views.views.ortho_views

Attributes

sync_filters

Functions

copy_layer(layer[, name])

get_property_names_from_class(layer_cls)

Return all property names for a Layer class.

point_data_hook(→ list[tuple[Any, ...)

Hook to connect to sync points data and visualization between original and copied

paint_event_hook(→ list[tuple[Any, ...)

Hook to connect to paint events and process them on the original TracksLabels

needs_own_colormap(→ bool)

Check whether the copied layer needs a colormap separate from the original's.

make_own_colormap(→ None)

Give the copied layer a color dict of its own, holding the original's colors.

colormap_hook(→ list[tuple[Any, collections.abc.Callable]])

Hook to sync colormap changes from the original TrackLabels layer to the copied

labels_paint_hook(→ list[tuple[Any, ...)

Replacement for the built-in paint syncing, for TrackLabels layers only. This is to

track_layers_hook(→ None)

Hook to capture click events on TrackLabels and TrackPoints derived Labels and

copy_detection_hook(→ None)

Hook to forward right-clicks on an orthogonal-view copy of a track layer to the

initialize_ortho_views(...)

Initialize orthoviews on the current napari Viewer and register hooks and filters.

Module Contents

napari_track_edit.data_views.views.ortho_views.copy_layer(layer: napari.layers.Layer, name: str = '')
napari_track_edit.data_views.views.ortho_views.get_property_names_from_class(layer_cls)

Return all property names for a Layer class.

napari_track_edit.data_views.views.ortho_views.sync_filters
napari_track_edit.data_views.views.ortho_views.point_data_hook(orig_layer: napari_track_edit.data_views.views.layers.track_points.TrackPoints, copied_layer: napari_track_edit.data_views.views.layers.out_of_slice_points.ZOnlyPoints) → list[tuple[Any, collections.abc.Callable]]

Hook to connect to sync points data and visualization between original and copied Points layers.

Parameters:
  • orig_layer (TrackPoints) – TracksLabels layer from which the copied layer is derived.

  • copied_layer (ZOnlyPoints) – ZOnlyPoints equivalent of the TracksPoints layer.

Returns:

the (signal, handler) pairs connected here, so the

orthoviews can disconnect them again when the layer or the views go away.

Return type:

list[tuple[Any, Callable]]

napari_track_edit.data_views.views.ortho_views.paint_event_hook(orig_layer: napari_track_edit.data_views.views.layers.track_labels.TrackLabels, copied_layer: napari.layers.Labels) → list[tuple[Any, collections.abc.Callable]]

Hook to connect to paint events and process them on the original TracksLabels layer.

Parameters:
  • orig_layer (TrackLabels) – TracksLabels layer from which the copied layer is derived.

  • copied_layer (Labels) – Labels equivalent of the TracksLabels layer. Instead of processing paint actions on this copy, we want to send them to the original layer and process them there.

Returns:

the (signal, handler) pairs connected here.

Return type:

list[tuple[Any, Callable]]

napari_track_edit.data_views.views.ortho_views.needs_own_colormap(orig_layer: napari_track_edit.data_views.views.layers.track_labels.TrackLabels, copied_layer: napari.layers.Labels) → bool

Check whether the copied layer needs a colormap separate from the original’s.

It only does when the two disagree about the background opacity, which happens when contours are on and exactly one of the two views renders in 3D: contours are not rendered in 3D, so there the labels are shown filled and the background is hidden instead (see colormap_hook). In every other case the colors are identical and the colormap object can simply be shared.

Parameters:
  • orig_layer (TrackLabels) – TrackLabels layer from which the copy is derived.

  • copied_layer (ContourLabels) – ContourLabels equivalent of the TrackLabels layer.

Returns:

True if the copied layer needs a color dict of its own.

Return type:

bool

napari_track_edit.data_views.views.ortho_views.make_own_colormap(orig_layer: napari_track_edit.data_views.views.layers.track_labels.TrackLabels, copied_layer: napari.layers.Labels) → None

Give the copied layer a color dict of its own, holding the original’s colors.

Uses construct_direct_colormap to skip pydantic’s per-color validation, since every color here is already a properly-shaped (4,) float array copied from orig_layer’s colormap.

Parameters:
  • orig_layer (TrackLabels) – TrackLabels layer from which the copy is derived.

  • copied_layer (ContourLabels) – ContourLabels equivalent of the TrackLabels layer.

napari_track_edit.data_views.views.ortho_views.colormap_hook(orig_layer: napari_track_edit.data_views.views.layers.track_labels.TrackLabels, copied_layer: napari.layers.Labels) → list[tuple[Any, collections.abc.Callable]]

Hook to sync colormap changes from the original TrackLabels layer to the copied layers. We need a hook for the special case in which one of the views is showing a 3D rendering in combination with partially filled contour labels. Since contours are not rendered in 3D, we want to display the non-filled labels with full opacity instead.

That special case is the only one in which the copy needs a colormap of its own; the rest of the time both views show identical colors and share a single colormap object.

Parameters:
  • orig_layer (TrackLabels) – TracksLabels layer from which the copied layer is derived.

  • copied_layer (ContourLabels) – ContourLabels equivalent of the TracksLabels layer.

Returns:

the (signal, handler) pairs connected here, so they can be cleaned up when the layer or the views go away.

Return type:

list[tuple[Any, Callable]]

napari_track_edit.data_views.views.ortho_views.labels_paint_hook(orig_layer: napari.layers.Labels, copied_layer: napari.layers.Labels) → list[tuple[Any, collections.abc.Callable]] | None

Replacement for the built-in paint syncing, for TrackLabels layers only. This is to ensure that normal Labels layers keep the default behavior, but TrackLabels layers skip this because they are handled via our custom paint_event_hook.

Parameters:
  • orig_layer (Labels) – the layer on the main viewer.

  • copied_layer (Labels) – its counterpart in the orthogonal view.

Returns:

connections made for a non-TrackLabels layer,

or None for a TrackLabels layer (handled separately).

Return type:

list[tuple[Any, Callable]] | None

napari_track_edit.data_views.views.ortho_views.track_layers_hook(orig_layer: napari_track_edit.data_views.views.layers.track_labels.TrackLabels | napari_track_edit.data_views.views.layers.track_points.TrackPoints, copied_layer: napari.layers.Labels | napari_track_edit.data_views.views.layers.out_of_slice_points.ZOnlyPoints) → None

Hook to capture click events on TrackLabels and TrackPoints derived Labels and ZOnlyPoints layers, and forward them to their original layer. Also, register key binds for view mode, undo & redo to copied layer, that call functions on the original layer.

Parameters:
  • orig_layer (TrackLabels | TrackPoints) – TracksLabels or TrackPoints layer from which the copied layer is derived.

  • copied_layer (Labels | ZOnlyPoints) – Labels or ZOnlyPoints equivalent of the TracksLabels or TrackPoints layer.

Nothing is returned because everything connected here lives on the copied layer, which is discarded together with the orthogonal view.

napari_track_edit.data_views.views.ortho_views.copy_detection_hook(orig_layer: napari_track_edit.data_views.views.layers.track_labels.TrackLabels | napari_track_edit.data_views.views.layers.track_points.TrackPoints, copied_layer: napari.layers.Labels | napari_track_edit.data_views.views.layers.out_of_slice_points.ZOnlyPoints) → None

Hook to forward right-clicks on an orthogonal-view copy of a track layer to the main-view copy logic, so copying a detection from a connected source layer works identically from the ortho views.

The forwarding is only active while a source layer is connected: the CopyFromSourceWidget stores a _manual_copy_detection callback on the target track layer while connected and removes it afterwards. It is looked up dynamically, so this hook is a no-op for track layers without a connected source (and their copies).

Parameters:
  • orig_layer (TrackLabels | TrackPoints) – the original track layer in the main viewer.

  • copied_layer (Labels | ZOnlyPoints) – the ortho-view copy of that layer.

napari_track_edit.data_views.views.ortho_views.initialize_ortho_views(viewer: napari.Viewer) → napari_orthogonal_views.ortho_view_manager.OrthoViewManager

Initialize orthoviews on the current napari Viewer and register hooks and filters.

Parameters:

viewer (napari.Viewer) – viewer to set the orthogonal views for.

Returns:

reference to the OrthoViewManager instance

Return type:

OrthoViewManager