kqcircuits.util.gui_waveguide_editing

kqcircuits.util.gui_waveguide_editing.coerce_nodes_with_gui_path(nodes: list[Node], gui_path: DPath, gui_path_shadow: DPath, snap_point_callback: Callable[[DPoint], DPoint], dbu) tuple[list[Node], DPath][source]

Detect GUI editing changes in WaveguideComposite-like elements, and update the nodes list accordingly.

To implement GUI editing of a WaveguiceComposite-like element, it needs three parameters: - nodes: the actual list of Node objects - gui_path: A pya.DPath parameter which is editable by the user in KLayout - gui_path_shadow: A pya.DPath parameter which is hidden, and thus not edited by the user

This function detects changes between gui_path and gui_path_shadow. If there are changes, nodes is updated to reflect the coordinates.

To use this function, call it in coerce_parameters_impl and use the output to update all three element parameters.

Parameters:
  • nodes – The Node objects (deserialzed with Node.nodes_from_string)

  • gui_path – Path with a point for each Node that may have been edited by the user

  • gui_path_shadow – reference Path with a point for each user that is never edited by the user.

  • snap_point_callback – callback that can modify points to snap to a relevant grid. Only applied to new and changed positions.

  • dbu – Value of layout.dbu

Returns: tuple containing:

  • new_nodes, updated list of Nodes, update the nodes parameter to this value (converted to strings)

  • new_path, updated path, update gui_path and gui_path_shadow to this value

../_images/kqcircuits.util.gui_waveguide_editing.png