qcc_kplugin.tools¶
Interactive KLayout tools (toolbar modes) for editing a qcc design in place.
Structure follows KQC’s kqcircuits/util/edit_node_plugin.py (GPL-3.0): a pya.PluginFactory registers each mode
and creates one pya.Plugin per view; overlays are pya.Marker objects sized in screen pixels. Unlike KQC’s
node editor these tools never change the layout: every action edits design.json through
qcc_kplugin.design_io and the session rebuilds it.
qcc Connect — pen tool: start on a port or on empty canvas (a free end), click nodes, finish on a port, on a line (a hanger coupler) or on the last node again (a free end) → route dialog (cpw / meander + length, bend radius, free-end termination). Clicks snap to KLayout’s editor grid; without a modifier each click adds a square corner (Manhattan), Shift makes the segment 0° / 45° / 90° or along the start port’s own angle when it faces an angle, Ctrl places the node as clicked: any angle, one oblique straight. The rubber band shows the route with its corners bent to the radius as you move (and the oblique straight the router draws between ports that face an angle).
qcc Route handles — every route shows its nodes (filled squares: click to select and pick up, click to drop; right-click deletes) and an insert handle on each free straight segment (hollow square). Nodes move to any angle on the grid; Shift snaps to 0° / 45° / 90° or an angled port’s axis. A route the last build left out (failed) is drawn in red with the same handles. A selected corner shows a curvature handle that sets that corner’s own bend radius. Double-click a node for its properties, a route for its options (type, length, radius, meander segment).
qcc Move/Snap — drag an instance; a port that comes within the capture radius of a compatible port (same CPW, facing) snaps, and the placement is stored as
place.snap. Otherwise the newplace.atis grid-rounded.[/]rotate by 90° while dragging; a port near a compatible one also turns the component to face it (any angle: StarQubit pins, ConcentricTransmon couplers), unless Ctrl is held. A pending component (double-click in the panel, Duplicate) follows the mouse and snaps the same way; the next click drops it.
Attributes¶
Classes¶
Pen-tool routing. Start on a port, or on empty canvas (a free end); every canvas click adds a node; finish on |
|
The junction section of the component dialog: L_J, I_c, R_n and C_J (L_J = Φ0/2πI_c, I_c·R_n = πΔ/2e with the |
|
Pen-tool node editing. Click a node (filled square) to select it and pick it up, move, click to drop it (grid, |
|
The optional "Targets" rows of an edit dialog: one line edit per key (empty = no target). The values go to |
Functions¶
|
Write the result of |
|
Next click in Move/Snap drops |
|
Delete node |
|
Delete route |
|
Quantcore menu: delete the node selected in Route handles. |
|
One failed route in red: its last good path (the route as it last built, wide) when there is one, and the path |
|
What the cell's drawn trilayer junction gives ( |
|
Dialog: the placed instance's parameters (its values over the cell defaults), rotation and, for components |
|
The route dialog for an existing route (type, length, radius, meander segment). |
|
Two-column parameter table (name, value); |
|
Placing a qubit fixes its junction at design time: |
|
The component's outline, bbox and ports in its own frame (cached; one qcc call, ~1.5 s, per cell+params). |
|
Load the outline in the background ( |
|
|
|
Options of a route ending on line |
|
|
|
The build sidecar's |
|
Bare λ/4 frequency of a CPW of this length on the design's substrate: f = c / (4 L √ε_eff), ε_eff = (εr + 1) / 2 |
|
Read-only rows: the element's circuit as the last build's LOM sees it (C to ground and couplings, L_J / C_J, |
|
Whether a placed |
|
Quantcore menu: put the meander of the route under the cursor on the segment under the cursor (Route |
|
Node |
|
Quantcore menu: x, y, corner radius and airbridge of the node selected in Route handles. |
|
Red markers for the routes the last build left out, on the design's view (a listener of the session: it runs |
|
Rotate the component being placed (or the instance being dragged) by |
|
Sharp polyline → path with every corner bent to radius |
|
Route options → dict |
|
The cell's editable parameters and defaults (qcc components CELL --schema, cached). |
|
|
|
"" when the outline fits on the chip, else a status-bar sentence: a wafer-level or frame cell (WaferMap75, |
|
The label of a port snap while dragging: which ports, and the turn the snap added. |
|
L of a DC SQUID at flux Φ/Φ0 with asymmetry d: L_J0 / √(cos² πΦ + d² sin² πΦ) (the library's |
|
εr of the open design's substrate (Chip settings; the PDK's by default), from the sidecar. |
|
|
|
Quantcore menu (Ctrl+Shift+J): a route that ends on a line hangs beside it (a hanger coupler) or merges into it (a |
Module Contents¶
- class qcc_kplugin.tools.ConnectTool(manager, view)¶
Bases:
_ToolPen-tool routing. Start on a port, or on empty canvas (a free end); every canvas click adds a node; finish on a port, on a line (a hanger coupler on it), or by clicking the last node again (a free end there). Clicks snap to the grid. Without Shift a segment turns once with a square corner (the preview shows it and the click commits it, so the built route is what was previewed); with Shift it goes straight at 0° / 45° / 90° / …. Right-click removes the last click (or cancels).
- anchor()¶
The previous point of the route (what Shift aligns the next segment with): the last node, the free start, or the end of the start port’s stub.
- anchor_before(end)¶
- anchor_dir()¶
Direction of the segment arriving at the anchor: the next square corner leaves along it.
- finish(end)¶
- finish_free()¶
The last node clicked again: the route ends there in a free end pointing back along the last segment.
- finish_hanger(host, here)¶
End the route on route
host[0]at the clicked point: as a hanger coupler beside it (a λ/4 readout on a feedline: meander from a claw or from a free open end, short end on the line), or merged into it with a T (the join mode, Ctrl+Shift+J; the dialog’s checkbox decides).
- finish_merge(design, rname, poly, here, opts)¶
Split line
rnameatherewith a T (KQCWaveguideCoplanarSplitter) whose stem faces the dialog’s side and end the route on the stem: a capacitor or a resonator galvanically on the line, not beside it.
- keep_state()¶
The route in progress, to carry it over a layout reload (a rebuild that lands while the user is drawing switches the tool off and on again, which would otherwise drop the clicks made so far).
- key_event(key, buttons)¶
- mouse_click_event(p, buttons, prio)¶
- mouse_moved_event(p, buttons, prio)¶
- node_point(p)¶
A canvas click / hover at
p→ the node it places (grid; Shift: 0° / 45° / 90° or the start port’s angle; Ctrl: the grid point, any angle).
- pdk_ab_if_wide()¶
The PDK CPW (a, b) when the start port is no CPW end (a reference plane much wider than the PDK line, e.g. a Gatemon
readoutisland edge, a = 150 µm): a route would otherwise take that width. (None, None) else.
- port_corner(end_port: str)¶
Square corner into the stub of
end_portafter the user’s nodes (none without nodes: the router turns by itself then, as before; none with Shift or Ctrl: straight into the stub).
- rays() list¶
The axis of the start port when it faces an angle (a StarQubit pin, a ConcentricTransmon coupler): offered by Shift next to 0° / 45° / 90°, so a node can sit exactly on the port’s own direction.
- redraw()¶
- reset()¶
- restore_state(state) None¶
Take back a
keep_state()after the reload; dropped when its start port is gone.
- route_near(p)¶
(route, segment) under
p(capture radius), not a route starting at the start port.
- route_r(value)¶
The route’s
rfor design.json: None when the dialog still holds the PDK turn radius it was preset with, so the route keeps following the PDK (a changed value is written).
- segment_to(q)¶
Nodes a click at
q(already on the grid / Shift-snapped) adds: the square corner the preview shows, thenq; with Shift justq(a straight 0° / 45° / 90° / port-angle segment), with Ctrl justqat the clicked point (any angle).
- start_point()¶
(position, outward direction or None) of the route start.
- stub() float¶
- target(p)¶
What a click at
pdoes: (“start-port”, name) / (“start-free”, pt) before the start; then (“port”, name) / (“finish-free”, pt) / (“line”, (route, seg)) / (“node”, pt). A port near the click always wins, so port → port routing behaves as before.
- undo_click()¶
Remove the nodes the last click added (a square corner goes with its node).
- property started: bool¶
- class qcc_kplugin.tools.JunctionRows(dialog, form, junction: dict | None, info: dict | None = None, drawn: dict | None = None)¶
The junction section of the component dialog: L_J, I_c, R_n and C_J (L_J = Φ0/2πI_c, I_c·R_n = πΔ/2e with the PDK’s Δ: typing any one fills the other two), for a SQUID the flux Φ/Φ0 and the asymmetry d, then read-only: the L at this bias (L_J0 / √(cos² πΦ + d² sin² πΦ), live), where the value comes from, and the junction the cell draws (PDK rule). These are simulation and LOM values, fixed per component: the drawn junction is for fab only.
junction: design.json’sjunction.info: the sidecar’s entry (kind, source,error).drawn: the drawn trilayer junction’s values. With no design value but a drawn junction, its values are the fields’ placeholders (“PDK, drawn junction”) and nothing is written unless the user types.- lj0()¶
L_J0 in use: the typed / stored value, else the drawn junction’s PDK value, else None.
- refresh()¶
Recompute the read-only rows from the fields.
- source_text() str¶
- values()¶
(Lj_nH or None, Cj_fF or None, flux_phi0, asym)(flux and asymdesign_ops.KEEPfor a component that is not a SQUID), or None for a multi-junction qubit (left as it is).
- drawn = None¶
- e¶
- e_asym¶
- e_cj¶
- e_flux¶
- gap¶
- l_drawn = None¶
- l_eff¶
- l_err¶
- l_src¶
- l_title¶
- multi¶
- pdk = None¶
- squid¶
- class qcc_kplugin.tools.RouteEditTool(manager, view)¶
Bases:
_ToolPen-tool node editing. Click a node (filled square) to select it and pick it up, move, click to drop it (grid, any angle; Shift aligns it with its neighbours at 0° / 45° / 90° or on an angled port’s axis, Ctrl = no alignment). A route the last build left out is drawn in red with its handles: edit its nodes, double-click it for its options, or press Delete on its line to delete the route. A selected corner shows its curvature handle (green, on the arc): pick it, move, drop to set that corner’s bend radius. Hollow squares insert a node. Right-click a node deletes it.
- corner(rname, i)¶
(prev, pos, next, radius, polyline index) of node
iofrname, or None.
- drag_point(p)¶
- drag_radius(p) float | None¶
- drop(here)¶
- handle_near(p)¶
- handles()¶
- key_event(key, buttons)¶
- mouse_click_event(p, buttons, prio)¶
Click a handle to pick it up, move, click again to drop it there. Right-click a node deletes it; right-click while moving cancels.
- mouse_double_click_event(p, buttons, prio)¶
Double-click a node: its properties (x, y, corner radius, airbridge); elsewhere on a route: the route’s options (type, length, radius, meander segment).
- mouse_moved_event(p, buttons, prio)¶
- neighbours(route: dict, kind: str, index: int)¶
- static port_rays(route: dict) list¶
Axes of the end stubs that face an angle (a StarQubit pin, a ConcentricTransmon coupler): Shift offers them next to 0° / 45° / 90°. Failed routes have no stubs.
- preview(route: dict, kind: str, index: int, pos)¶
(points, radii) of
routewith the dragged handle atpos(a radius for kind “radius”).
- radii(route: dict) list¶
Bend radius of each polyline point (the route’s, or a waypoint’s own).
- radius_handle()¶
- redraw()¶
- reset()¶
- route(rname) dict¶
- routes() dict¶
The sidecar routes with every corner as a node: the router’s own corners (a route drawn without clicks, corners the router added) are listed next to the user’s nodes, so each gets a handle; the first edit of such a corner writes them all to design.json (
design_io.materialize_nodes()).
- selected = None¶
- class qcc_kplugin.tools.SnapTool(manager, view)¶
Bases:
_Tool- drop_instance()¶
- instance_at(p)¶
- key_event(key, buttons)¶
- load_outline(inst)¶
The held instance’s etched outline for the preview (background query, cached; the bbox shows until it arrives, and when the instance’s parameters cannot be read).
- mouse_click_event(p, buttons, prio)¶
- mouse_double_click_event(p, buttons, prio)¶
Double-click a placed component: edit its parameters and rotation (written to design.json, rebuilt).
- mouse_moved_event(p, buttons, prio)¶
- other_ports(inst) dict¶
- own_ports(inst) dict¶
- pending_snap(c)¶
(own port, target port, corrected position, extra turn)for the component being placed with its origin atc(it follows the mouse like a held instance: a port near a compatible one snaps, turning to face it; Ctrl: only ports that already face each other), or None.
- place(at)¶
- redraw()¶
- reset()¶
- class qcc_kplugin.tools.TargetsEditor(dialog, layout, keys: dict, current: dict)¶
The optional “Targets” rows of an edit dialog: one line edit per key (empty = no target). The values go to
design.jsontargets[element](seedesign_io.set_targets()).- values() dict¶
- edits¶
- qcc_kplugin.tools.apply_instance_edit(design: dict, name: str, out) str¶
Write the result of
edit_instance_dialog()intodesignand describe it.
- qcc_kplugin.tools.arm_place(cell: str, params: dict, rot: float = 0.0, mirror: bool = False, extra: dict | None = None) None¶
Next click in Move/Snap drops
cell; its outline follows the mouse; [ and ] rotate it by 90°.rot/mirror/extra(entry keys such asjunction) come from a duplicated component.
- qcc_kplugin.tools.delete_node(rname: str, index: int) None¶
Delete node
indexofrnameas Route handles shows it (the router’s own corners count as nodes: they are written to design.json first, then the one is removed).
- qcc_kplugin.tools.delete_route(rname: str) None¶
Delete route
rname(and the routes hanging on it) from design.json: a failed route has no cell, so KLayout’s own Delete cannot reach it.
- qcc_kplugin.tools.delete_selected_node() None¶
Quantcore menu: delete the node selected in Route handles.
- qcc_kplugin.tools.draw_failed(o, name: str, f: dict) None¶
One failed route in red: its last good path (the route as it last built, wide) when there is one, and the path the design asks for now (its ends and nodes, dashed), with the name and the reason.
- qcc_kplugin.tools.drawn_junction_value(entry: dict, info: dict | None) dict | None¶
What the cell’s drawn trilayer junction gives (
{"Lj_nH", "Cj_fF", "source"}, PDK rule), or None. The sidecar has it when the design holds no value of its own (source“drawn …”); with a design value, and a cell whosejunction_typeis a trilayer junction, the library is asked (qcc design placement-junction).
- qcc_kplugin.tools.edit_instance_dialog(name: str, entry: dict, targets: dict | None = None)¶
Dialog: the placed instance’s parameters (its values over the cell defaults), rotation and, for components that can have them (qubits), targets.
targetsis the element’s currentdesign.jsontargets (None: no targets section). Returns(changed params, rotation or None, targets or None, position or None, junction or None)(None targets: section not shown; None position: unchanged or snapped; junction(Lj_nH, Cj_fF, flux, asym)for a qubit) or None when cancelled.
- qcc_kplugin.tools.edit_route_options(rname: str, segment: int | None = None) None¶
The route dialog for an existing route (type, length, radius, meander segment).
- qcc_kplugin.tools.fill_table(table, rows: list[dict], values: dict, cell: str | None = None) None¶
Two-column parameter table (name, value);
valuesoverride the defaults; hover shows the description (and, withcell, the PDK junction an unset KQCjunction_typedefault is drawn as).
- qcc_kplugin.tools.fix_placed_junction(design: dict, name: str) str | None¶
Placing a qubit fixes its junction at design time:
junction = {Lj_nH, Cj_fF}goes into design.json (a drawn trilayer junction’s PDK value, else the PDK nominal SQUID, both from the library), unless the instance already has one (a duplicate keeps its source’s). Returns the status-bar note, or None.
- qcc_kplugin.tools.ghost(cell: str, params: dict) dict | None¶
The component’s outline, bbox and ports in its own frame (cached; one qcc call, ~1.5 s, per cell+params).
- qcc_kplugin.tools.ghost_async(cell: str, params: dict, done=None) None¶
Load the outline in the background (
done(outline or None)afterwards; at once when it is cached).
- qcc_kplugin.tools.ghost_cached(cell: str, params: dict) bool¶
- qcc_kplugin.tools.hanger_dialog(name, host, side, r, free_start=False, merge=False, a=None, b=None, wide_port=None)¶
Options of a route ending on line
host→ dict{name, kind, length, r, coupler, side, end, gap, merge}(+free/free_gapfor a free start) or None.mergepresets the checkbox that merges the route into the line with a T instead of hanging it beside the line (the coupler fields are then unused);a/bpreset the line’s own width / gap (wide_port: the start port that is no CPW end, named in a note).
- qcc_kplugin.tools.icon(name: str) str | None¶
- qcc_kplugin.tools.junction_info(name: str) dict | None¶
The build sidecar’s
instances.<name>.junction(kind, Lj0_nH, Cj_fF, flux_phi0, asym, Lj_eff_nH, source, maybe error), None for a component without a junction or before the first build.
- qcc_kplugin.tools.length_hint(text: str, eps_r: float | None = None) str¶
Bare λ/4 frequency of a CPW of this length on the design’s substrate: f = c / (4 L √ε_eff), ε_eff = (εr + 1) / 2 (a thick substrate; a claw or a hanger coupler loads it a few % to ~10 % lower: Q1 + R1, 4200 µm: 7.5 GHz bare, 6.65 GHz in its LOM). The thickness does not matter at these widths; the loss tangent sets Q, not f.
- qcc_kplugin.tools.lom_section(dialog, layout, element: str) None¶
Read-only rows: the element’s circuit as the last build’s LOM sees it (C to ground and couplings, L_J / C_J, the resonator line, the hanger κ); Run LOM uses these, a simulation replaces the C values.
- qcc_kplugin.tools.may_have_junction(cell: str, params: dict | None = None) bool¶
Whether a placed
cellcan carry a junction (a qubit, or a cell with ajunction_typeparameter): then the placement asks the library for its simulation value (fix_placed_junction()).
- qcc_kplugin.tools.meander_here() None¶
Quantcore menu: put the meander of the route under the cursor on the segment under the cursor (Route handles).
- qcc_kplugin.tools.node_dialog(route: str, index: int, props: dict, route_r: float)¶
Node
indexofroute: x, y, bend radius of its corner (empty = the route’s), airbridge, and the line width / gap from this node on (a taper; empty = as before the node) → dict or None.
- qcc_kplugin.tools.node_properties() None¶
Quantcore menu: x, y, corner radius and airbridge of the node selected in Route handles.
- qcc_kplugin.tools.refresh_failed_overlay() None¶
Red markers for the routes the last build left out, on the design’s view (a listener of the session: it runs after every sidecar change, so the marks follow each build and vanish when the route builds again).
- qcc_kplugin.tools.register_tools()¶
- qcc_kplugin.tools.rotate(step: float) None¶
Rotate the component being placed (or the instance being dragged) by
stepdegrees: the Quantcore menu’s [ / ] actions, so the keys work wherever the keyboard focus is (e.g. still in the panel after a double-click).
- qcc_kplugin.tools.rounded_path(points, width: float, r: float) pya.DPath¶
Sharp polyline → path with every corner bent to radius
r(what KQC does when it builds the route).
- qcc_kplugin.tools.route_dialog(name, kind, length, r, title='qcc route', free_ends=(), segment=None, segments=None, targets=None, a=None, b=None, join=None, hanger=None, meander=None, lom_of=None, error=None, last_good=None)¶
Route options → dict
{name, kind, length, r, a, b}(+free_<end>/free_gapfor each free end,segmentfor the meander segment,mergewhenjoinis given) or None.lengthis only used for meanders;a/b(CPW width and gap, empty = taken from the ports) are written only when set.join=(line, merged)for a route that ends on a line: the checkbox merges it into the line with a T (checked) or hangs it beside the line (unchecked).hanger(the route’s hanger end) adds its coupler rows →out["hanger"]with the editedlength,side,end,ground_gap,open_gap,direction.meander({"meanders", "meander_direction"}of an existing route) adds the meander’s turn count and first-turn side →out["meanders"](-1 = automatic) andout["meander_direction"](1 / -1).error(a route the last build left out) shows why at the top, withlast_good(its last good length) and a “Delete this route” box →out["delete"].
- qcc_kplugin.tools.schema(cell: str) list[dict]¶
The cell’s editable parameters and defaults (qcc components CELL –schema, cached).
- qcc_kplugin.tools.schema_async(cell: str, done) None¶
done(rows)with the cell’s parameters, loaded in the background (at once when cached).
- qcc_kplugin.tools.size_note(cell: str, g: dict | None) str¶
“” when the outline fits on the chip, else a status-bar sentence: a wafer-level or frame cell (WaferMap75, BoundaryBox, AlignmentMarkers) is not a component to drop on a chip, and the user should know before it builds.
- qcc_kplugin.tools.snap_text(hit, rot: float) str¶
The label of a port snap while dragging: which ports, and the turn the snap added.
- qcc_kplugin.tools.squid_l_eff(lj0_nh: float, flux_phi0: float = 0.0, asym: float = 0.0) float¶
L of a DC SQUID at flux Φ/Φ0 with asymmetry d: L_J0 / √(cos² πΦ + d² sin² πΦ) (the library’s
lom.fragment.squid_l_eff; raises at Φ = ½ with d = 0).
- qcc_kplugin.tools.substrate_eps() float¶
εr of the open design’s substrate (Chip settings; the PDK’s by default), from the sidecar.
- qcc_kplugin.tools.table_values(table, rows: list[dict]) dict¶
- qcc_kplugin.tools.toggle_join() None¶
Quantcore menu (Ctrl+Shift+J): a route that ends on a line hangs beside it (a hanger coupler) or merges into it (a T-junction); the dialog can still change it per route.
- qcc_kplugin.tools.ACTIVE: list = []¶
- qcc_kplugin.tools.CATEGORY: dict¶
- qcc_kplugin.tools.CTRL¶
- qcc_kplugin.tools.C_UM_PER_NS = 299792.458¶
- qcc_kplugin.tools.FACING_GAP_TEXT = "Coupler: this route's gap facing the line µm (empty = its b)"¶
- qcc_kplugin.tools.FACTORIES = []¶
- qcc_kplugin.tools.FAILED¶
- qcc_kplugin.tools.HANGER_TITLE = 'Hanger coupler beside {host}'¶
- qcc_kplugin.tools.ICONS¶
- qcc_kplugin.tools.INSTANCES = []¶
- qcc_kplugin.tools.JOIN¶
- qcc_kplugin.tools.JUNCTION_TITLE = 'Junction (simulation and LOM only, not drawn, not in the fab mask)'¶
- qcc_kplugin.tools.LEFT¶
- qcc_kplugin.tools.LINE_GAP_TEXT = "Coupler: {host}'s gap facing this route µm (empty = {host}'s b)"¶
- qcc_kplugin.tools.MEANDER_SIDES = ('left of the travel (+1)', 'right of the travel (-1)')¶
- qcc_kplugin.tools.MERGE_TEXT = 'Merge into {host} (T-junction) instead of hanging beside it'¶
- qcc_kplugin.tools.PENDING_PLACE: dict¶
- qcc_kplugin.tools.RIGHT¶
- qcc_kplugin.tools.ROTATE_HINT = '[ ] rotate 90°'¶
- qcc_kplugin.tools.ROTATE_KEYS¶
- qcc_kplugin.tools.SEGMENT_TEXT = 'Meander on straight'¶
- qcc_kplugin.tools.SHIFT¶