quantcore_circuits.live.snapshot ================================ .. py:module:: quantcore_circuits.live.snapshot .. autoapi-nested-parse:: KLayout screenshots of a layout, rendered by KLayout itself. ``snapshot`` uses a headless ``klayout.lay.LayoutView`` with KQC's ``default_layer_props.lyp`` (same colours and stipples as the GUI), so it works in Jupyter, CI and on the server. ``gui_snapshot`` asks the running KLayout GUI (quantcore-circuits KLayout plugin, command server on port 8083) to save its current view instead, falling back to ``snapshot`` when the GUI is not reachable. Attributes ---------- .. autoapisummary:: quantcore_circuits.live.snapshot.ANNOTATION_LAYERS quantcore_circuits.live.snapshot.GUI_PORT quantcore_circuits.live.snapshot.HIDE quantcore_circuits.live.snapshot.OUTLINE Functions --------- .. autoapisummary:: quantcore_circuits.live.snapshot.gui_available quantcore_circuits.live.snapshot.gui_snapshot quantcore_circuits.live.snapshot.layer_props_path quantcore_circuits.live.snapshot.snapshot Module Contents --------------- .. py:function:: gui_available(port: int = GUI_PORT, timeout: float = 0.3) -> bool .. py:function:: gui_snapshot(png: str | pathlib.Path, size: tuple[int, int] = (1600, 1600), layout: str | pathlib.Path | None = None, box: tuple[float, float, float, float] | None = None, port: int = GUI_PORT, timeout: float = 20.0, fallback=None) -> tuple[pathlib.Path, str] Screenshot from the running KLayout GUI (quantcore-circuits KLayout plugin, port 8083) → ``(png, "gui")``. ``layout`` makes the GUI open/reload that file first; ``box`` (µm) zooms. If the GUI is not reachable and ``fallback`` (a layout path or BuildResult; defaults to ``layout``) exists, it is rendered headless instead → ``(png, "headless")``. .. py:function:: layer_props_path() -> str | None Quantcore layer properties: KQC's ``default_layer_props.lyp`` with the **ground grid (cheese) visible** and every face shown like face ``1t1``. KQC ships ``'1t1 ground grid' 132/1`` hidden, which hid the PDK cheese band in every snapshot and KLayout view. KQC's ``2t1`` group also shows its ``waveguide path`` (centre lines) and ``base metal gap for EBL`` and hides its ``base metal gap``, unlike the other faces: here each face layer gets the visibility of the ``1t1`` layer of the same name, so a two-face picture has no centre lines over it. The variant is written next to the temp dir and refreshed when KQC's file or this module changes; load it in KLayout (*File → Load Layer Properties*) to see the cheese there too. .. py:function:: snapshot(source, png: str | pathlib.Path, size: tuple[int, int] = (1600, 1600), box: tuple[float, float, float, float] | None = None, background: str = '#ffffff', oversampling: int = 2, hide: tuple[str, ...] = HIDE) -> pathlib.Path Render ``source`` (an ``.oas``/``.gds`` path or a :class:`BuildResult`) to ``png``. ``box`` (µm, x0 y0 x1 y1) zooms to a region; default is the whole top cell. Layers whose names contain one of ``hide`` are switched off (helper layers that clutter a picture). .. py:data:: ANNOTATION_LAYERS :value: ('instance names', 'refpoints', 'annotations', 'texts') .. py:data:: GUI_PORT :value: 8083 .. py:data:: HIDE :value: ('refpoints', 'ground grid avoidance', 'waveguide path', 'waveguide length', 'annotations', 'ports') .. py:data:: OUTLINE :value: ('chip boundary',)