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 ofNodeobjects -gui_path: Apya.DPathparameter which is editable by the user in KLayout -gui_path_shadow: Apya.DPathparameter which is hidden, and thus not edited by the userThis function detects changes between
gui_pathandgui_path_shadow. If there are changes,nodesis updated to reflect the coordinates.To use this function, call it in
coerce_parameters_impland use the output to update all three element parameters.- Parameters:
nodes – The
Nodeobjects (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 thenodesparameter to this value (converted to strings)new_path, updated path, updategui_pathandgui_path_shadowto this value