iqm-finland / KQCircuits

KLayout Python library for integrated quantum circuit design.
GNU General Public License v3.0
128 stars 71 forks source link

Macro for snapping refpoints #15

Closed jkotilahti closed 8 months ago

jkotilahti commented 2 years ago

Would be cool if in GUI workflow one could snap refpoints to other. For example one might select refpoint 1 which belongs to PCell 1, then refpoint 2 which belongs to PCell 2, then runs a "snapping macro" which moves PCell 1 such that refpoints 1 and 2 would match. Waveguides would be special - instead of moving the PCell, only the node would move.

Proposed workflow: 1) you loosely place elements and waveguides 2) you select elements 3) you run the macro 4) the macro goes over all elements in the order of selection 5) it checks if the element in question has any refpoints of other elements later in the queue in vicinity of refpoints of present element, within customizable "snapping radius" 6) if there is, the macro moves the second element such that the refpoints would match

Note that there is already code in https://github.com/iqm-finland/KQCircuits/blob/main/klayout_package/python/scripts/macros/export/export_cells_as_code.lym and https://github.com/iqm-finland/KQCircuits/blob/main/klayout_package/python/kqcircuits/util/layout_to_code.py for printing out code that creates snapped elements based on loosely placed elements. The difference in this new macro would be that it moves cells existing in layout instead of printing code.