Load a schematic file into this window. Returns True on success. Note: project/config and the symbol-metadata dicts are process-global, so this repoints them at ``path``; each window re-establishes its own context when activated (see changeEvent).
(self, path: Path)
| 585 | self._load_file(Path(path)) |
| 586 | |
| 587 | def _load_file(self, path: Path) -> bool: |
| 588 | """Load a schematic file into this window. Returns True on success. |
| 589 | |
| 590 | Note: project/config and the symbol-metadata dicts are process-global, so |
| 591 | this repoints them at ``path``; each window re-establishes its own |
| 592 | context when activated (see changeEvent).""" |
| 593 | from .schematic_data import SchematicData |
| 594 | try: |
| 595 | data = SchematicData.load(path) |
| 596 | except Exception as exc: |
| 597 | QMessageBox.critical(self, "Open failed", str(exc)) |
| 598 | return False |
| 599 | # Point sidecars at this schematic before loading, so any LaTeX rendered |
| 600 | # while building the scene goes to (and is read from) <name>.cache, and |
| 601 | # the schematic's own style (<name>.ini) is applied before items render. |
| 602 | project.set_current(path) |
| 603 | import SLiCAP.schematic.config as _config |
| 604 | _config.load(project.ini_path()) |
| 605 | # Rebuild the library with this schematic's frozen symbols overlaid, so |
| 606 | # it renders with the symbols it was drawn with (and user symbols win). |
| 607 | self._build_library(project.symbols_path()) |
| 608 | self._scene.from_data(data, self._library) |
| 609 | self._scene.clear_history() |
| 610 | self._doc_props = data.properties |
| 611 | self._current_path = path |
| 612 | self._dirty = False |
| 613 | self.setWindowTitle(f"SLiCAP — {path.name}") |
| 614 | return True |
| 615 | |
| 616 | def open_subschematic(self, path: Path): |
| 617 | """Open a subcircuit's schematic in a new editable window (descending the |
no test coverage detected