Skip to content

Commit

Permalink
[MV] Update instance state as frame idx callback (#2012)
Browse files Browse the repository at this point in the history
Update "instance" state as "frame_idx" callback
  • Loading branch information
roomrys authored Nov 1, 2024
1 parent 62035aa commit ef8a496
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions sleap/gui/widgets/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
>>> vp.addInstance(instance=my_instance, color=(r, g, b))
"""

from collections import deque

# FORCE_REQUESTS controls whether we emit a signal to process frame requests
Expand Down Expand Up @@ -270,8 +271,13 @@ def update_selection_state(a, b):

self.seekbar.selectionChanged.connect(update_selection_state)

self.state.connect("frame_idx", lambda idx: self.plot())
self.state.connect("frame_idx", lambda idx: self.seekbar.setValue(idx))
def frame_idx_callback(frame_idx: int):
"""All callbacks that need to be called when frame_idx changes."""
self.plot()
self.seekbar.setValue(frame_idx)
self.state["instance"] = None

self.state.connect("frame_idx", lambda idx: frame_idx_callback(idx))
self.state.connect("instance", self.view.selectInstance)
self.state.connect("instance_group", self.view.selectInstance)

Expand Down Expand Up @@ -340,6 +346,7 @@ def _load_and_show_requested_image(self, frame_idx):
# Display image
self.view.setImage(qimage)

# TODO: Delegate to command context
def _register_shortcuts(self):
self._shortcut_triggers = dict()

Expand Down Expand Up @@ -1908,7 +1915,7 @@ def __init__(
self.track_label.setHtml(instance_label_text)

# Add nodes
for (node, point) in self.instance.nodes_points:
for node, point in self.instance.nodes_points:
if point.visible or self.show_non_visible:
node_item = QtNode(
parent=self,
Expand All @@ -1923,7 +1930,7 @@ def __init__(
self.nodes[node.name] = node_item

# Add edges
for (src, dst) in self.skeleton.edge_names:
for src, dst in self.skeleton.edge_names:
# Make sure that both nodes are present in this instance before drawing edge
if src in self.nodes and dst in self.nodes:
edge_item = QtEdge(
Expand Down

0 comments on commit ef8a496

Please sign in to comment.