Normalize multi-segment wires into individual straight 2-point segments. An elbowed wire with N vertices becomes N-1 separate WireItems. This ensures that a single click selects only one straight segment. Net annotation (user name, display flag, label offset) is inherited
(self)
| 1305 | break |
| 1306 | |
| 1307 | def _split_wire_elbows(self) -> None: |
| 1308 | """Normalize multi-segment wires into individual straight 2-point segments. |
| 1309 | |
| 1310 | An elbowed wire with N vertices becomes N-1 separate WireItems. |
| 1311 | This ensures that a single click selects only one straight segment. |
| 1312 | Net annotation (user name, display flag, label offset) is inherited |
| 1313 | by the first segment; subsequent segments start with no annotation |
| 1314 | so the connectivity resolver can assign net names cleanly. |
| 1315 | """ |
| 1316 | for wire in list(self.items()): |
| 1317 | if not isinstance(wire, WireItem): |
| 1318 | continue |
| 1319 | pts = wire.points |
| 1320 | if len(pts) <= 2: |
| 1321 | continue |
| 1322 | pts_copy = [QPointF(p) for p in pts] |
| 1323 | net_name = wire.net_name |
| 1324 | user_net = wire._user_net_name |
| 1325 | net_locked = wire.net_locked |
| 1326 | display_name = wire.display_name |
| 1327 | label_offset = QPointF(wire.label_offset) |
| 1328 | self.removeItem(wire) |
| 1329 | for i, (a, b) in enumerate(zip(pts_copy, pts_copy[1:])): |
| 1330 | nw = WireItem([a, b]) |
| 1331 | if i == 0: |
| 1332 | nw.net_name = net_name |
| 1333 | nw._user_net_name = user_net |
| 1334 | nw.net_locked = net_locked |
| 1335 | nw.display_name = display_name |
| 1336 | nw.label_offset = label_offset |
| 1337 | self.addItem(nw) |
| 1338 | nw.update_label() |
| 1339 | |
| 1340 | def _sync_junctions(self) -> None: |
| 1341 | """Split through-wires, normalize to segments, merge collinear pairs, add/remove junctions.""" |
no test coverage detected