Split through-wires, normalize to segments, merge collinear pairs, add/remove junctions.
(self)
| 1338 | nw.update_label() |
| 1339 | |
| 1340 | def _sync_junctions(self) -> None: |
| 1341 | """Split through-wires, normalize to segments, merge collinear pairs, add/remove junctions.""" |
| 1342 | # Remove degenerate zero-length wires (created when two pins are brought together) |
| 1343 | for item in list(self.items()): |
| 1344 | if isinstance(item, WireItem): |
| 1345 | pts = item.points |
| 1346 | if len(pts) >= 2 and _pt_key(pts[0]) == _pt_key(pts[-1]): |
| 1347 | self.removeItem(item) |
| 1348 | self._split_through_wires() |
| 1349 | self._split_wire_elbows() |
| 1350 | self._merge_collinear_wires() |
| 1351 | wires = [i for i in self.items() if isinstance(i, WireItem)] |
| 1352 | comps = [i for i in self.items() if isinstance(i, ComponentItem)] |
| 1353 | required = _find_junction_points(wires, comps) |
| 1354 | kept: set[tuple] = set() |
| 1355 | for item in list(self.items()): |
| 1356 | if not isinstance(item, JunctionItem): |
| 1357 | continue |
| 1358 | k = _pt_key(item.pos()) |
| 1359 | if k in required: |
| 1360 | kept.add(k) |
| 1361 | else: |
| 1362 | self.removeItem(item) |
| 1363 | for k in required: |
| 1364 | if k not in kept: |
| 1365 | self.addItem(JunctionItem(QPointF(k[0], k[1]))) |
| 1366 | self._sync_port_net_names() |
| 1367 | self._refresh_pin_markers(wires, comps) |
| 1368 | |
| 1369 | def _refresh_pin_markers(self, wires=None, comps=None) -> None: |
| 1370 | """Tell each component which of its pins are unconnected, so it can draw |
no test coverage detected