From 6a43b2069e4a8f1d408a417ced5f7bc4adaef678 Mon Sep 17 00:00:00 2001 From: Chayan Deb Date: Tue, 18 Mar 2025 22:59:52 +0530 Subject: [PATCH] [Bugfix]: Fixed an issue stemming from recent feature update of 'orthogonal_wiring' on objects connected to multiple wires. The functionality was refactored and the bug was later pointed out in issue #336 in the upstream repo. --- src/move.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/move.c b/src/move.c index d07ffe5c..7515aeae 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