From 7e46ec6efbc94b4a92a3b649a0b2b011e52ddfe1 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Tue, 18 Mar 2025 18:41:50 +0100 Subject: [PATCH] merge in SuperChayan changes for orthogonal wiring / manhattan move --- src/move.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/move.c b/src/move.c index 9d02b400..afbe9288 100644 --- a/src/move.c +++ b/src/move.c @@ -1031,13 +1031,18 @@ static void place_moved_wire(int n, int orthogonal_wiring) xWire * const wire = xctx->wire; - /* FIXME: Chayan Deb: this needs to be updated - * If things get too complicated a place_moved_wire_orthogonal() can be created - */ - if((wire[n].sel & (SELECTED|SELECTED1)) && orthogonal_wiring) - { - if(xctx->manhattan_lines & 1) xctx->manhattan_lines=2; - else if(xctx->manhattan_lines & 2) xctx->manhattan_lines=1; + /* Need to dynamically assign `manhattan_lines` to each wire. Otherwise, a single + * `manhattan_lines` value gets forced on all wires connected to a moved object*/ + if(orthogonal_wiring) { + double origin_shifted_x2, origin_shifted_y2; + /* Origin shift the cartesian coordinate p2(x2,y2) w.r.t. p1(x1,y1) */ + origin_shifted_x2 = xctx->rx2 - xctx->rx1; + origin_shifted_y2 = xctx->ry2 - xctx->ry1; + /* Draw whichever component of the resulting orthogonal-wire is bigger (either horizontal or vertical), first */ + if(origin_shifted_x2*origin_shifted_x2 > origin_shifted_y2*origin_shifted_y2) + xctx->manhattan_lines = 1; + else + xctx->manhattan_lines = 2; } /* wire x1,y1 point was moved