Skip to content

Commit

Permalink
paste_graph & delete_selection should act on current graph scene
Browse files Browse the repository at this point in the history
  • Loading branch information
RazinShaikh committed Aug 30, 2023
1 parent 5637943 commit dc0540f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions zxlive/rule_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ def _ety_clicked(self, ety: EdgeType.Type) -> None:

def paste_graph(self, graph: GraphT) -> None:
if graph is None: return
new_g = copy.deepcopy(self.graph_scene_left.g)
new_verts, new_edges = new_g.merge(graph.translate(0.5,0.5))
new_g = copy.deepcopy(self.graph_scene.g)
new_verts, new_edges = new_g.merge(graph.translate(0.5, 0.5))
cmd = UpdateGraph(self.graph_view, new_g)
self.undo_stack.push(cmd)
self.graph_scene_left.select_vertices(new_verts)

def delete_selection(self) -> None:
selection = list(self.graph_scene_left.selected_vertices)
selected_edges = list(self.graph_scene_left.selected_edges)
selection = list(self.graph_scene.selected_vertices)
selected_edges = list(self.graph_scene.selected_edges)
rem_vertices = selection.copy()
for v in selection:
if vertex_is_w(self.graph_scene_left.g.type(v)):
rem_vertices.append(get_w_partner(self.graph_scene_left.g, v))
if vertex_is_w(self.graph_scene.g.type(v)):
rem_vertices.append(get_w_partner(self.graph_scene.g, v))
if not rem_vertices and not selected_edges: return
new_g = copy.deepcopy(self.graph_scene_left.g)
self.graph_scene_left.clearSelection()
new_g = copy.deepcopy(self.graph_scene.g)
self.graph_scene.clearSelection()
new_g.remove_edges(selected_edges)
new_g.remove_vertices(list(set(rem_vertices)))
cmd = SetGraph(self.graph_view,new_g) if len(set(rem_vertices)) > 128 \
Expand Down

0 comments on commit dc0540f

Please sign in to comment.