| 182 | |
| 183 | |
| 184 | def _wire(parent, item, stroke, width, net_color, net_fs): |
| 185 | if len(item.points) < 2: |
| 186 | return |
| 187 | el = ET.SubElement(parent, f"{{{_SVG_NS}}}polyline") |
| 188 | el.set("points", " ".join(f"{p.x():.2f},{p.y():.2f}" for p in item.points)) |
| 189 | el.set("fill", "none") |
| 190 | el.set("stroke", stroke) |
| 191 | el.set("stroke-width", f"{width:.2f}") |
| 192 | el.set("stroke-linecap", "round") |
| 193 | el.set("stroke-linejoin", "round") |
| 194 | |
| 195 | if (item.display_name and item.net_name |
| 196 | and item._net_label is not None and item._net_label.isVisible()): |
| 197 | from PySide6.QtGui import QFontMetricsF |
| 198 | lpos = item._net_label.pos() |
| 199 | # QGraphicsSimpleTextItem.pos() is the top-left of the bounding rect. |
| 200 | # SVG <text y> anchors the baseline; add the font ascent to align correctly. |
| 201 | fm = QFontMetricsF(item._net_label.font()) |
| 202 | t = ET.SubElement(parent, f"{{{_SVG_NS}}}text") |
| 203 | t.set("x", f"{lpos.x():.2f}") |
| 204 | t.set("y", f"{lpos.y() + fm.ascent():.2f}") |
| 205 | t.set("font-family", "sans-serif") |
| 206 | t.set("font-size", f"{net_fs}pt") |
| 207 | t.set("fill", net_color) |
| 208 | t.text = item.net_name |
| 209 | |
| 210 | |
| 211 | def _junction(parent, item, fill, radius): |