From 053cd1da652a30ac271865ef8684444073cf4852 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Mon, 12 Oct 2020 22:51:15 -0700 Subject: [PATCH] pygui: removed edges tracking interfaces, since the link associated with them already does --- daemon/core/gui/coreclient.py | 4 ++-- daemon/core/gui/graph/edges.py | 2 -- daemon/core/gui/graph/graph.py | 16 +++++++--------- daemon/core/gui/graph/node.py | 4 ++-- daemon/core/gui/interface.py | 4 ++-- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/daemon/core/gui/coreclient.py b/daemon/core/gui/coreclient.py index 0182a6cb..0859ccd5 100644 --- a/daemon/core/gui/coreclient.py +++ b/daemon/core/gui/coreclient.py @@ -910,10 +910,10 @@ class CoreClient: src_node = canvas_src_node.core_node dst_node = canvas_dst_node.core_node if NodeUtils.is_container_node(src_node.type): - src_iface_id = edge.src_iface.id + src_iface_id = edge.link.iface1.id self.iface_to_edge[(src_node.id, src_iface_id)] = edge if NodeUtils.is_container_node(dst_node.type): - dst_iface_id = edge.dst_iface.id + dst_iface_id = edge.link.iface2.id self.iface_to_edge[(dst_node.id, dst_iface_id)] = edge def get_wlan_configs_proto(self) -> List[wlan_pb2.WlanConfig]: diff --git a/daemon/core/gui/graph/edges.py b/daemon/core/gui/graph/edges.py index e0645f22..f16b5576 100644 --- a/daemon/core/gui/graph/edges.py +++ b/daemon/core/gui/graph/edges.py @@ -285,8 +285,6 @@ class CanvasEdge(Edge): Create an instance of canvas edge object """ super().__init__(canvas, src) - self.src_iface: Optional[Interface] = None - self.dst_iface: Optional[Interface] = None self.text_src: Optional[int] = None self.text_dst: Optional[int] = None self.link: Optional[Link] = None diff --git a/daemon/core/gui/graph/graph.py b/daemon/core/gui/graph/graph.py index 13710258..a248ad7c 100644 --- a/daemon/core/gui/graph/graph.py +++ b/daemon/core/gui/graph/graph.py @@ -237,7 +237,7 @@ class CanvasGraph(tk.Canvas): src_pos = (node1.position.x, node1.position.y) dst_pos = (node2.position.x, node2.position.y) edge = CanvasEdge(self, src.id, src_pos, dst_pos) - self.complete_edge(src, dst, edge) + self.complete_edge(src, dst, edge, link) def delete_wired_edge(self, src: CanvasNode, dst: CanvasNode, link: Link) -> None: token = create_edge_token(src.id, dst.id, link) @@ -512,10 +512,10 @@ class CanvasGraph(tk.Canvas): edge.delete() # update node connected to edge being deleted other_id = edge.src - other_iface = edge.src_iface + other_iface = edge.link.iface1 if edge.src == object_id: other_id = edge.dst - other_iface = edge.dst_iface + other_iface = edge.link.iface2 other_node = self.nodes[other_id] other_node.edges.remove(edge) if other_iface: @@ -537,12 +537,12 @@ class CanvasGraph(tk.Canvas): del self.edges[edge.token] src_node = self.nodes[edge.src] src_node.edges.discard(edge) - if edge.src_iface: - del src_node.ifaces[edge.src_iface.id] + if edge.link.iface1: + del src_node.ifaces[edge.link.iface1.id] dst_node = self.nodes[edge.dst] dst_node.edges.discard(edge) - if edge.dst_iface: - del dst_node.ifaces[edge.dst_iface.id] + if edge.link.iface2: + del dst_node.ifaces[edge.link.iface2.id] src_wireless = NodeUtils.is_wireless_node(src_node.core_node.type) if src_wireless: dst_node.delete_antenna() @@ -907,11 +907,9 @@ class CanvasGraph(tk.Canvas): if link.iface1: iface1 = link.iface1 src.ifaces[iface1.id] = iface1 - edge.src_iface = iface1 if link.iface2: iface2 = link.iface2 dst.ifaces[iface2.id] = iface2 - edge.dst_iface = iface2 edge.set_link(link) edge.token = create_edge_token(src.id, dst.id, edge.link) self.arc_common_edges(edge) diff --git a/daemon/core/gui/graph/node.py b/daemon/core/gui/graph/node.py index f8f27635..2ac4219e 100644 --- a/daemon/core/gui/graph/node.py +++ b/daemon/core/gui/graph/node.py @@ -322,10 +322,10 @@ class CanvasNode: for edge in self.edges: if self.id == edge.src: other_id = edge.dst - edge_iface_id = edge.src_iface.id + edge_iface_id = edge.link.iface1.id else: other_id = edge.src - edge_iface_id = edge.dst_iface.id + edge_iface_id = edge.link.iface2.id if edge_iface_id != iface_id: continue other_node = self.canvas.nodes[other_id] diff --git a/daemon/core/gui/interface.py b/daemon/core/gui/interface.py index c075b95a..4c5f5978 100644 --- a/daemon/core/gui/interface.py +++ b/daemon/core/gui/interface.py @@ -196,10 +196,10 @@ class InterfaceManager: for edge in canvas_node.edges: src_node = canvas.nodes[edge.src] dst_node = canvas.nodes[edge.dst] - iface = edge.src_iface + iface = edge.link.iface1 check_node = src_node if src_node == canvas_node: - iface = edge.dst_iface + iface = edge.link.iface2 check_node = dst_node if check_node.core_node.id in visited: continue