Skip to content

Commit

Permalink
Added exception for W nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdwetering committed Aug 1, 2024
1 parent f965866 commit fac3b1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions zxlive/editor_base_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ def add_edge(self, u: VT, v: VT, verts: list[VItem]) -> None:
if graph.type(u) == VertexType.W_INPUT and len(graph.neighbors(u)) >= 2 or \
graph.type(v) == VertexType.W_INPUT and len(graph.neighbors(v)) >= 2:
return None
# We will try to connect all the vertices together in order
# First we filter out the vertices that are not compatible with the edge.
verts = [vitem for vitem in verts if not graph.type(vitem.v) == VertexType.W_INPUT] # we will be adding two edges, which is not compatible with W_INPUT
# but first we check if there any vertices that we do want to additionally connect.
if not self.snap_vertex_edge or not verts:
cmd = AddEdge(self.graph_view, u, v, self._curr_ety)
self.undo_stack.push(cmd)
Expand Down
5 changes: 4 additions & 1 deletion zxlive/graphscene.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,11 @@ def add_edge(self, e: QGraphicsSceneMouseEvent) -> None:
for it in self.items(e.scenePos(), deviceTransform=QTransform()):
if isinstance(it, VItem):
v2 = it
break
#self.edge_added.emit(self._drag.start.v, it.v)
assert v2 is not None
else:
e.ignore()
return
path = QPainterPath(v1.pos())
path.lineTo(e.scenePos())
colliding_verts = []
Expand Down

0 comments on commit fac3b1a

Please sign in to comment.