napari_track_edit.data_views.views.tree_view.tree_widget

Classes

TreeWidget

fastplotlib-based widget for lineage tree visualization and navigation

Module Contents

class napari_track_edit.data_views.views.tree_view.tree_widget.TreeWidget(viewer: napari.Viewer)

Bases: qtpy.QtWidgets.QWidget

fastplotlib-based widget for lineage tree visualization and navigation

lineage_df
graph = None
mode = 'all'
plot_type = 'tree'
view_direction = 'vertical'
tracks_viewer
selected_nodes
tree_widget: napari_track_edit.data_views.views.tree_view.tree_plot_fpl.TreePlot
mode_widget
plot_type_widget
navigation_widget
flip_widget
options_widget
cleanup() → None

Tear down the tree view: stop reacting to TracksViewer signals, then close the wgpu canvas while its Qt widgets are still alive. Idempotent.

Called by MenuManager when the widget is destroyed, and by the event hooks below when napari’s main window goes away. Disconnecting comes first, so that nothing tries to redraw a figure that is already closed.

eventFilter(obj: qtpy.QtCore.QObject, event: qtpy.QtCore.QEvent) → bool

Trigger clean up when napari’s main window is being destroyed

closeEvent(event) → None
keyPressEvent(event: qtpy.QtGui.QKeyEvent) → None

Handle key press events.

Priority order: 1. Tree-widget-specific keybinds (highest priority) - call TreeWidget methods 2. Modifier keybinds (mouse zoom constraints) 3. General keybinds (work in table widget too) - call tracks_viewer methods 4. Navigation (arrow keys)

delete_node()

Delete a node.

connect_nodes_with_divisions()

Connect or disconnect the selected nodes, keeping existing divisions.

connect_nodes_linearly()

Connect or disconnect the selected nodes into a single linear track.

swap_nodes()

Swap the nodes by swapping upstream edges

set_division()

Make or break a division between the three selected nodes

undo()

Undo action.

redo()

Redo action.

deselect()

Deselect all nodes

restore_selection()

Restore previous selection

toggle_display_mode()

Toggle display mode.

toggle_feature_mode()

Toggle feature mode.

flip_axes()

Flip the axes of the plot

set_mouse_enabled(x: bool, y: bool)

Enable or disable mouse zoom scrolling in X or Y direction.

keyReleaseEvent(ev)

Reset the mouse scrolling when releasing a zoom modifier (X/Y) key.

A zoom modifier that is also a general keybind (Y, which sets a division) was only meant as a zoom modifier if the user scrolled while holding it down; a plain tap runs the general action instead.

_update_selected()

Called whenever the selection list is updated. Only re-computes the full graph information when the new selection is not in the lineage df (and in lineage mode)

_update_track_data(reset_view: bool | None = None) → None

Called when the TracksViewer emits the tracks_updated signal, indicating that a new set of tracks should be viewed.

_set_mode(mode: str) → None

Set the display mode to all or lineage view. Currently, linage view is always horizontal and all view is always vertical.

Parameters:

mode (str) – The mode to set the view to. Options are “all” or “lineage”

_set_plot_type(plot_type: str) → None

Set the plot_type mode to ‘tree’ or ‘feature’, and adjust view direction. Also update the feature on the navigation_widget.

Parameters:

plot_type (str) – The plot type to display. Options are “tree” or “feature”

_update_lineage_df() → None

Subset dataframe to include only nodes belonging to the current lineage