qcc_kplugin.session¶
The live editing session inside KLayout: which design is open, its sidecar, and how edits get rebuilt.
Edits are written to design.json (never to the layout). A background qcc watch --no-klive process (started
on demand, so KQC is imported once) rebuilds in ~0.1 s; without it each commit runs qcc build. When the layout
file changes after a commit the view reloads it in place, and the sidecar (<name>.qcc.json) is re-read so the
tool overlays follow the new geometry.
Attributes¶
Classes¶
Functions¶
|
The line of a failed |
|
Environment for child processes, so |
|
|
|
|
|
Status-bar text for the routes a build left out: names and reasons, and where to fix them. |
|
An exception escaped a mouse / key / timer handler: log it and put a one-line note in the status bar. Never a |
|
|
|
Settings ▸ instance name label height (µm, 0 = none): the plugin's builds pass it as |
|
Append to |
|
Status-bar message (and console + log). Progress lines that repeat every timer tick pass |
|
OK / Cancel buttons wired to |
|
A tool action failed: the traceback goes to the log, a message box tells the user (not silently lost). |
|
Module Contents¶
- class qcc_kplugin.session.Session¶
Singleton (see
SESSION) shared by the menu actions and the tools.- attach_view(view=None) bool¶
Pick up the design behind the layout shown in
view(a qcc-written file with a sidecar).
- check_external_edit() bool¶
design.json was written by someone else since this session last wrote it.
Sim groups are bookkeeping (
qcc sim auto/qcc sim subsetwrite the group they simulate): they are kept as they are, and undo / redo carry them over, so undoing a drawing edit never drops the group the results belong to. Any other change becomes one undo step (Undo takes it back), and the layout is rebuilt when it can have changed. Returns True when the file changed.
- chip_cell()¶
The DesignChip cell of the layout in the view (its instances are the design’s components).
- commit(design: dict, what: str = '') None¶
- design() dict¶
- ensure_design() bool¶
A design to edit: the one open, else the one behind the layout in the current view (its sidecar), else the last design used (reopened and rebuilt, e.g. after a KLayout restart).
- find_view()¶
(view, cellview index) showing the design’s layout, or (None, None).
- focus_chip() None¶
Show the DesignChip cell as the view’s cell: its components are then top-level instances, so KLayout’s own select / move / rotate / properties work on them (each move is written back to design.json).
- open(design_path) None¶
Use
design_path; its layout is<design dir>/build/<stem>.oasunless the sidecar says otherwise.
- redo() bool¶
- reload_sidecar(force: bool = False) bool¶
- reload_view() None¶
Reload the rebuilt layout in place. Reloading drops KLayout back to its select mode, so the Quantcore tool that was active (Connect, Route handles, Move/Snap) is switched on again: drawing goes on after each edit.
- sidecar_path() pathlib.Path | None¶
- start_watch() None¶
- stop_watch() None¶
- sync_live_pcells() None¶
Settings > live PCells: Quantcore PCells placed with KLayout’s Instance tool, or edited in its PCell dialog → design.json (one commit, so Undo takes it back), rebuilt.
- sync_native_moves() None¶
Components moved / rotated with KLayout’s own tools (or its properties dialog) → design.json, rebuilt.
- tick() None¶
- undo() bool¶
- watching() bool¶
- builder: subprocess.Popen | None = None¶
- built: dict¶
- property capture_px: float¶
- data: dict | None = None¶
- design_path: pathlib.Path | None = None¶
- failed_routes: dict[str, str]¶
- future: list[dict] = []¶
- property grid: float¶
Snap grid (µm): KLayout’s editor grid (
edit-gridof the current view, else of the application), so the plugin’s nodes snap like KLayout’s own shapes; the plugin Settings grid when KLayout has none.
- history: list[dict] = []¶
- last_error: str | None = None¶
- layout_path: pathlib.Path | None = None¶
- listeners = []¶
- property qcc: str¶
- timer = None¶
- watcher: subprocess.Popen | None = None¶
- qcc_kplugin.session.build_error(out: str) str¶
The line of a failed
qcc buildoutput worth showing: the last exception line (RoutingError: route R2: ...), else the last line that is not a warning (aFutureWarningis printed after the error at exit and would hide it).
- qcc_kplugin.session.clean_env() dict¶
Environment for child processes, so
qcc(conda Python + pipklayout) starts as from a terminal.Drops KLayout’s embedded-Python variables and removes KLayout’s own folders from PATH: otherwise the pip
klayoutextension in the child can pick up the GUI’sklayout_*.dll(another version) and hang.
- qcc_kplugin.session.config(key: str, default: str = '') str¶
- qcc_kplugin.session.default_qcc() str¶
qccwhen Settings has none: on PATH, else the conda envqcd(KLayout started from the Start menu does not see the conda env’s Scripts folder).
- qcc_kplugin.session.failure_summary(failed: dict[str, str]) str¶
Status-bar text for the routes a build left out: names and reasons, and where to fix them.
- qcc_kplugin.session.guard_error(what: str) None¶
An exception escaped a mouse / key / timer handler: log it and put a one-line note in the status bar. Never a dialog (a mouse-move handler runs ~60 times a second) and never re-raised (KLayout would show a “Script Error”). The same error is logged once, then only counted.
- qcc_kplugin.session.label_args() list[str]¶
qcc build/qcc watcharguments for the label height (an annotation layer only: the fab mask, the simulations and the design hash do not change).
- qcc_kplugin.session.label_height() float¶
Settings ▸ instance name label height (µm, 0 = none): the plugin’s builds pass it as
--label-height.
- qcc_kplugin.session.log(text: str) None¶
Append to
%TEMP%/qcc_kplugin.log: KLayout started from the Start menu has no visible console.
- qcc_kplugin.session.message(text: str, secs: float = 6, log_it: bool = True) None¶
Status-bar message (and console + log). Progress lines that repeat every timer tick pass
log_it=False.
- qcc_kplugin.session.ok_cancel(dialog)¶
OK / Cancel buttons wired to
dialog. KLayout 0.30’s pya has noQDialogButtonBox(buttons, parent)constructor (it reads the flags as an orientation and raises), so the buttons are set afterwards.
- qcc_kplugin.session.report_error(what: str) None¶
A tool action failed: the traceback goes to the log, a message box tells the user (not silently lost).
- qcc_kplugin.session.set_config(key: str, value) None¶
- qcc_kplugin.session.CFG_CAPTURE = 'qcc-kplugin-capture-px'¶
- qcc_kplugin.session.CFG_DESIGN = 'qcc-kplugin-design'¶
- qcc_kplugin.session.CFG_DIALOG_COLUMNS = 'qcc-kplugin-dialog-columns'¶
- qcc_kplugin.session.CFG_GRID = 'qcc-kplugin-grid'¶
- qcc_kplugin.session.CFG_LABEL_HEIGHT = 'qcc-kplugin-label-height'¶
- qcc_kplugin.session.CFG_LOM_LIMIT = 'qcc-kplugin-lom-limit-min'¶
- qcc_kplugin.session.CFG_QCC = 'qcc-kplugin-qcc-exe'¶
- qcc_kplugin.session.DEFAULT_LABEL_HEIGHT = 70.0¶
- qcc_kplugin.session.ERRORS: list[str] = []¶
- qcc_kplugin.session.LOG¶
- qcc_kplugin.session.SESSION¶