"""Manual routing with .go() and .jog().

Sometimes you want explicit GPS-style turn-by-turn instructions:
    - .go(direction, by=...) advances the route by that amount.
    - .go(direction, to=...) advances until reaching that coordinate.
    - .jog(direction, by=...) inserts a U-shaped detour offset.
Use cases: delay lines, MZI arms, anywhere you need a precise shape.
"""
import lumicron as lm
import lumicron.pdks.elyon_demo.all as pdk


@lm.pcell
def ManualRouting():
    c = lm.CELL("ManualRouting")

    c.add(lm.PORT("in", position=(0, 0), direction=0,
                  width=0.5, layer=pdk.LAYER.SILC))
    c.add(lm.PORT("out", position=(800, 300), direction=180,
                  width=0.5, layer=pdk.LAYER.SILC))

    # Manual chain: east 200, north 300, east to port_b, then auto-finish.
    (c.Route(c.ports["in"], radius=15).to(c.ports["out"])
        .go("E", by=200)
        .go("N", by=300)
        .go("E", to=c.ports["out"].position[0] - 50))
    return c


if __name__ == "__main__":
    ManualRouting().to_gds("manual_routing.gds")
