MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / _sync_junctions

Method _sync_junctions

SLiCAP/schematic/canvas.py:1340–1367  ·  view source on GitHub ↗

Split through-wires, normalize to segments, merge collinear pairs, add/remove junctions.

(self)

Source from the content-addressed store, hash-verified

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

Callers 8

_commit_pasteMethod · 0.95
_end_wireMethod · 0.95
from_dataMethod · 0.95
mousePressEventMethod · 0.95
mouseReleaseEventMethod · 0.95
keyPressEventMethod · 0.80
_on_reload_symbolsMethod · 0.80

Calls 8

_split_through_wiresMethod · 0.95
_split_wire_elbowsMethod · 0.95
_sync_port_net_namesMethod · 0.95
_refresh_pin_markersMethod · 0.95
_find_junction_pointsFunction · 0.85
JunctionItemClass · 0.85
_pt_keyFunction · 0.70

Tested by

no test coverage detected