Tell each component which of its pins are unconnected, so it can draw a marker there. A pin is connected when a wire touches it (endpoint or passing through) or another component pin sits on it.
(self, wires=None, comps=None)
| 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 |
| 1371 | a marker there. A pin is connected when a wire touches it (endpoint or |
| 1372 | passing through) or another component pin sits on it.""" |
| 1373 | if comps is None: |
| 1374 | comps = [i for i in self.items() if isinstance(i, ComponentItem)] |
| 1375 | if wires is None: |
| 1376 | wires = [i for i in self.items() if isinstance(i, WireItem)] |
| 1377 | |
| 1378 | pin_counts: dict[tuple, int] = {} |
| 1379 | for c in comps: |
| 1380 | for p in c.pin_scene_pos(): |
| 1381 | k = _pt_key(p) |
| 1382 | pin_counts[k] = pin_counts.get(k, 0) + 1 |
| 1383 | |
| 1384 | def on_any_wire(k: tuple) -> bool: |
| 1385 | for w in wires: |
| 1386 | pts = w.points |
| 1387 | for i in range(len(pts) - 1): |
| 1388 | p1, p2 = pts[i], pts[i + 1] |
| 1389 | if _pt_key(p1) == k or _pt_key(p2) == k: |
| 1390 | return True |
| 1391 | if _pt_on_segment(k[0], k[1], p1, p2): |
| 1392 | return True |
| 1393 | return False |
| 1394 | |
| 1395 | for c in comps: |
| 1396 | unconnected = set() |
| 1397 | for idx, p in enumerate(c.pin_scene_pos()): |
| 1398 | k = _pt_key(p) |
| 1399 | connected = pin_counts.get(k, 0) >= 2 or on_any_wire(k) |
| 1400 | if not connected: |
| 1401 | unconnected.add(idx) |
| 1402 | c.set_unconnected_pins(unconnected) |
| 1403 | |
| 1404 | def _sync_port_net_names(self) -> None: |
| 1405 | """Lock net names on wires that belong to a net containing a port symbol. |
no test coverage detected