napari_track_edit.data_views.views.ortho_views ============================================== .. py:module:: napari_track_edit.data_views.views.ortho_views Attributes ---------- .. autoapisummary:: napari_track_edit.data_views.views.ortho_views.sync_filters Functions --------- .. autoapisummary:: napari_track_edit.data_views.views.ortho_views.copy_layer napari_track_edit.data_views.views.ortho_views.get_property_names_from_class napari_track_edit.data_views.views.ortho_views.point_data_hook napari_track_edit.data_views.views.ortho_views.paint_event_hook napari_track_edit.data_views.views.ortho_views.needs_own_colormap napari_track_edit.data_views.views.ortho_views.make_own_colormap napari_track_edit.data_views.views.ortho_views.colormap_hook napari_track_edit.data_views.views.ortho_views.labels_paint_hook napari_track_edit.data_views.views.ortho_views.track_layers_hook napari_track_edit.data_views.views.ortho_views.copy_detection_hook napari_track_edit.data_views.views.ortho_views.initialize_ortho_views Module Contents --------------- .. py:function:: copy_layer(layer: napari.layers.Layer, name: str = '') .. py:function:: get_property_names_from_class(layer_cls) Return all property names for a Layer class. .. py:data:: sync_filters .. py:function:: 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. :param orig_layer: TracksLabels layer from which the copied layer is derived. :type orig_layer: TrackPoints :param copied_layer: ZOnlyPoints equivalent of the TracksPoints layer. :type copied_layer: ZOnlyPoints :returns: the (signal, handler) pairs connected here, so the orthoviews can disconnect them again when the layer or the views go away. :rtype: list[tuple[Any, Callable]] .. py:function:: 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. :param orig_layer: TracksLabels layer from which the copied layer is derived. :type orig_layer: TrackLabels :param copied_layer: 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. :type copied_layer: Labels :returns: the (signal, handler) pairs connected here. :rtype: list[tuple[Any, Callable]] .. py:function:: 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. :param orig_layer: TrackLabels layer from which the copy is derived. :type orig_layer: TrackLabels :param copied_layer: ContourLabels equivalent of the TrackLabels layer. :type copied_layer: ContourLabels :returns: True if the copied layer needs a color dict of its own. :rtype: bool .. py:function:: 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. :param orig_layer: TrackLabels layer from which the copy is derived. :type orig_layer: TrackLabels :param copied_layer: ContourLabels equivalent of the TrackLabels layer. :type copied_layer: ContourLabels .. py:function:: 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. :param orig_layer: TracksLabels layer from which the copied layer is derived. :type orig_layer: TrackLabels :param copied_layer: ContourLabels equivalent of the TracksLabels layer. :type copied_layer: ContourLabels :returns: the (signal, handler) pairs connected here, so they can be cleaned up when the layer or the views go away. :rtype: list[tuple[Any, Callable]] .. py:function:: 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. :param orig_layer: the layer on the main viewer. :type orig_layer: Labels :param copied_layer: its counterpart in the orthogonal view. :type copied_layer: Labels :returns: connections made for a non-TrackLabels layer, or None for a TrackLabels layer (handled separately). :rtype: list[tuple[Any, Callable]] | None .. py:function:: 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. :param orig_layer: TracksLabels or TrackPoints layer from which the copied layer is derived. :type orig_layer: TrackLabels | TrackPoints :param copied_layer: Labels or ZOnlyPoints equivalent of the TracksLabels or TrackPoints layer. :type copied_layer: Labels | ZOnlyPoints Nothing is returned because everything connected here lives on the copied layer, which is discarded together with the orthogonal view. .. py:function:: 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). :param orig_layer: the original track layer in the main viewer. :type orig_layer: TrackLabels | TrackPoints :param copied_layer: the ortho-view copy of that layer. :type copied_layer: Labels | ZOnlyPoints .. py:function:: 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. :param viewer: viewer to set the orthogonal views for. :type viewer: napari.Viewer :returns: reference to the OrthoViewManager instance :rtype: OrthoViewManager