Return all WireItems connected to wire on the same electrical net.
(self, wire: WireItem)
| 2078 | item.setText(item.label or item.url) |
| 2079 | |
| 2080 | def _wires_on_same_net(self, wire: WireItem) -> list: |
| 2081 | """Return all WireItems connected to wire on the same electrical net.""" |
| 2082 | from .connectivity import _UF, _rpt, _on_segment |
| 2083 | wires = [w for w in self.items() if isinstance(w, WireItem)] |
| 2084 | uf = _UF() |
| 2085 | for w in wires: |
| 2086 | pts = [_rpt(p) for p in w.points] |
| 2087 | for i in range(len(pts) - 1): |
| 2088 | uf.union(pts[i], pts[i + 1]) |
| 2089 | all_pts = [_rpt(p) for w in wires for p in w.points] |
| 2090 | for w in wires: |
| 2091 | for i in range(len(w.points) - 1): |
| 2092 | p1, p2 = w.points[i], w.points[i + 1] |
| 2093 | seg_root = uf.find(_rpt(p1)) |
| 2094 | for pt in all_pts: |
| 2095 | if _on_segment(p1, p2, QPointF(pt[0], pt[1])): |
| 2096 | uf.union(seg_root, pt) |
| 2097 | if not wire.points: |
| 2098 | return [wire] |
| 2099 | target_root = uf.find(_rpt(wire.points[0])) |
| 2100 | return [w for w in wires if w.points and uf.find(_rpt(w.points[0])) == target_root] |
| 2101 | |
| 2102 | def _open_net_label(self, wire: WireItem) -> None: |
| 2103 | from .net_label_dialog import NetLabelDialog |
no test coverage detected