MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / reload_svg

Method reload_svg

SLiCAP/schematic/component_item.py:705–724  ·  view source on GitHub ↗

Swap this instance's artwork for a freshly loaded symbol definition. Rebuilds the SVG renderer, re-derives geometry-dependent state (bounding rect, label anchor, pin markers) and the labels. Symbol *metadata* (pins, params, model …) must already have been republished into t

(self, svg_bytes: bytes)

Source from the content-addressed store, hash-verified

703 ]
704
705 def reload_svg(self, svg_bytes: bytes) -> None:
706 """Swap this instance's artwork for a freshly loaded symbol definition.
707
708 Rebuilds the SVG renderer, re-derives geometry-dependent state (bounding
709 rect, label anchor, pin markers) and the labels. Symbol *metadata*
710 (pins, params, model …) must already have been republished into the
711 component_item globals via SymbolLibrary.inject_into_component_item().
712
713 Connections are deliberately NOT re-derived: pins may have moved, so the
714 caller (and ultimately the user) is responsible for repairing wiring."""
715 self.prepareGeometryChange()
716 stripped, self.symbol_texts = _split_symbol_text(svg_bytes)
717 self._svg_bytes = stripped
718 self._renderer = QSvgRenderer(QByteArray(_apply_symbol_colors(stripped)))
719 self.setSharedRenderer(self._renderer)
720 # Pin count may have changed; mark every pin unconnected until the scene
721 # re-runs connectivity (_sync_junctions) and corrects the markers.
722 self._unconnected_pins = set(range(len(PIN_POSITIONS.get(self.symbol_name, []))))
723 self.update_labels()
724 self.update()
725
726 def set_unconnected_pins(self, indices: set[int]) -> None:
727 """Record which pin indices have nothing attached (scene calls this)."""

Callers 2

_on_reload_symbolsMethod · 0.80

Calls 3

update_labelsMethod · 0.95
_split_symbol_textFunction · 0.85
_apply_symbol_colorsFunction · 0.85

Tested by

no test coverage detected