Skip to content

Commit

Permalink
Magic drag and drop now knows about copying Z and X spiders through H…
Browse files Browse the repository at this point in the history
…-boxes.
  • Loading branch information
jvdwetering committed Oct 23, 2024
1 parent 8bf31d5 commit b8ea10a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions zxlive/proof_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def _vertex_dragged(self, state: DragState, v: VT, w: VT) -> None:
anims.anticipate_fuse(self.graph_scene.vertex_map[w])
elif pyzx.basicrules.check_strong_comp(self.graph, v, w):
anims.anticipate_strong_comp(self.graph_scene.vertex_map[w])
elif pyzx.hrules.match_copy(self.graph, lambda x: x in (v, w)): # This function takes a vertex matching function, which we restrict to just match to v and w
anims.anticipate_strong_comp(self.graph_scene.vertex_map[w])
else:
anims.back_to_default(self.graph_scene.vertex_map[w])

Expand All @@ -137,13 +139,22 @@ def _vertex_dropped_onto(self, v: VT, w: VT) -> None:
cmd = AddRewriteStep(self.graph_view, g, self.step_view, "fuse spiders")
self.play_sound_signal.emit(SFXEnum.THATS_SPIDER_FUSION)
self.undo_stack.push(cmd, anim_before=anim)
elif pyzx.hrules.match_copy(g, lambda x: x in (v, w)):
match = pyzx.hrules.match_copy(g, lambda x: x in (v, w))
etab, rem_verts, rem_edges, check_isolated_vertices = pyzx.hrules.apply_copy(g, match)
g.add_edge_table(etab)
g.remove_edges(rem_edges)
g.remove_vertices(rem_verts)
cmd = AddRewriteStep(self.graph_view, g, self.step_view, "copy")
self.undo_stack.push(cmd)
elif pyzx.basicrules.check_strong_comp(g, v, w):
pyzx.basicrules.strong_comp(g, w, v)
anim = anims.strong_comp(self.graph, g, w, self.graph_scene)
cmd = AddRewriteStep(self.graph_view, g, self.step_view, "bialgebra")
self.play_sound_signal.emit(SFXEnum.BOOM_BOOM_BOOM)
self.undo_stack.push(cmd, anim_after=anim)


def _wand_trace_finished(self, trace: WandTrace) -> None:
if self._magic_slice(trace):
return
Expand Down

0 comments on commit b8ea10a

Please sign in to comment.