From 6cc7883e51fcedf8b9fa6a9d61c0a1fad3c3e19e Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sat, 25 Jan 2025 14:33:01 +0100 Subject: [PATCH] reduce overlap area when clearing crosshair, add return value to find_closest_net_or_symbol_pin() --- src/callback.c | 36 ++++++++++++++++++------------------ src/findnet.c | 7 ++++++- src/xschem.h | 3 ++- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/callback.c b/src/callback.c index 66a14b98..e21cfb07 100644 --- a/src/callback.c +++ b/src/callback.c @@ -1354,28 +1354,28 @@ void draw_crosshair(int what) if(fix_broken_tiled_fill || !_unix) { if(xhair_size) { MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gc[0], - (int)X_TO_SCREEN(xctx->prev_crossx) - 2 * INT_WIDTH(xctx->lw) - xhair_size, - (int)Y_TO_SCREEN(xctx->prev_crossy) - 2 * INT_WIDTH(xctx->lw) - xhair_size, - 4 * INT_WIDTH(xctx->lw) + 4 * xhair_size, - 4 * INT_WIDTH(xctx->lw) + 4 * xhair_size, - (int)X_TO_SCREEN(xctx->prev_crossx) - 2 * INT_WIDTH(xctx->lw) - xhair_size, - (int)Y_TO_SCREEN(xctx->prev_crossy) - 2 * INT_WIDTH(xctx->lw) - xhair_size); + (int)X_TO_SCREEN(xctx->prev_crossx) - 1 * INT_WIDTH(xctx->lw) - xhair_size, + (int)Y_TO_SCREEN(xctx->prev_crossy) - 1 * INT_WIDTH(xctx->lw) - xhair_size, + 2 * INT_WIDTH(xctx->lw) + 2 * xhair_size, + 2 * INT_WIDTH(xctx->lw) + 2 * xhair_size, + (int)X_TO_SCREEN(xctx->prev_crossx) - 1 * INT_WIDTH(xctx->lw) - xhair_size, + (int)Y_TO_SCREEN(xctx->prev_crossy) - 1 * INT_WIDTH(xctx->lw) - xhair_size); MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gc[0], - (int)X_TO_SCREEN(xctx->prev_crossx) - 2 * INT_WIDTH(xctx->lw) - xhair_size, - (int)Y_TO_SCREEN(xctx->prev_crossy) - 2 * INT_WIDTH(xctx->lw) - xhair_size, - 4 * INT_WIDTH(xctx->lw) + 4 * xhair_size, - 4 * INT_WIDTH(xctx->lw) + 4 * xhair_size, - (int)X_TO_SCREEN(xctx->prev_crossx) - 2 * INT_WIDTH(xctx->lw) - xhair_size, - (int)Y_TO_SCREEN(xctx->prev_crossy) - 2 * INT_WIDTH(xctx->lw) - xhair_size); + (int)X_TO_SCREEN(xctx->prev_crossx) - 1 * INT_WIDTH(xctx->lw) - xhair_size, + (int)Y_TO_SCREEN(xctx->prev_crossy) - 1 * INT_WIDTH(xctx->lw) - xhair_size, + 2 * INT_WIDTH(xctx->lw) + 2 * xhair_size, + 2 * INT_WIDTH(xctx->lw) + 2 * xhair_size, + (int)X_TO_SCREEN(xctx->prev_crossx) - 1 * INT_WIDTH(xctx->lw) - xhair_size, + (int)Y_TO_SCREEN(xctx->prev_crossy) - 1 * INT_WIDTH(xctx->lw) - xhair_size); } else { /* full screen span xhair */ MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gc[0], - 0, (int)Y_TO_SCREEN(xctx->prev_crossy) - 2 * INT_WIDTH(xctx->lw), - xctx->xrect[0].width, 4 * INT_WIDTH(xctx->lw), - 0, (int)Y_TO_SCREEN(xctx->prev_crossy) - 2 * INT_WIDTH(xctx->lw)); + 0, (int)Y_TO_SCREEN(xctx->prev_crossy) - 1 * INT_WIDTH(xctx->lw), + xctx->xrect[0].width, 2 * INT_WIDTH(xctx->lw), + 0, (int)Y_TO_SCREEN(xctx->prev_crossy) - 1 * INT_WIDTH(xctx->lw)); MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gc[0], - (int)X_TO_SCREEN(xctx->prev_crossx) - 2 * INT_WIDTH(xctx->lw), 0, - 4 * INT_WIDTH(xctx->lw), xctx->xrect[0].height, - (int)X_TO_SCREEN(xctx->prev_crossx) - 2 * INT_WIDTH(xctx->lw), 0); + (int)X_TO_SCREEN(xctx->prev_crossx) - 1 * INT_WIDTH(xctx->lw), 0, + 2 * INT_WIDTH(xctx->lw), xctx->xrect[0].height, + (int)X_TO_SCREEN(xctx->prev_crossx) - 1 * INT_WIDTH(xctx->lw), 0); } } else { diff --git a/src/findnet.c b/src/findnet.c index 852e72bb..cc9801e1 100644 --- a/src/findnet.c +++ b/src/findnet.c @@ -185,7 +185,7 @@ static void find_closest_line(double mx, double my) /* snap wire to closest pin or net endpoint (if it is inside the current screen viewport) */ /* use spatial hash table iterators to avoid O(N) */ -void find_closest_net_or_symbol_pin(double mx, double my, double *x, double *y) +int find_closest_net_or_symbol_pin(double mx, double my, double *x, double *y) { double x1, y1, x2, y2; Iterator_ctx ctx; @@ -193,6 +193,7 @@ void find_closest_net_or_symbol_pin(double mx, double my, double *x, double *y) Wireentry *wireptr; double curr_dist = DBL_MAX; double xx, yy, dist, min_dist_x = xctx->mousex_snap, min_dist_y = xctx->mousey_snap; + int found_net_or_pin = 0; x1 = X_TO_XSCHEM(xctx->areax1); y1 = Y_TO_XSCHEM(xctx->areay1); @@ -218,6 +219,7 @@ void find_closest_net_or_symbol_pin(double mx, double my, double *x, double *y) curr_dist = dist; min_dist_x = xx; min_dist_y = yy; + found_net_or_pin = 1; } } } @@ -236,6 +238,7 @@ void find_closest_net_or_symbol_pin(double mx, double my, double *x, double *y) curr_dist = dist; min_dist_x = xx; min_dist_y = yy; + found_net_or_pin = 1; } xx = wire[i].x2; yy = wire[i].y2; @@ -245,11 +248,13 @@ void find_closest_net_or_symbol_pin(double mx, double my, double *x, double *y) curr_dist = dist; min_dist_x = xx; min_dist_y = yy; + found_net_or_pin = 1; } } *x = min_dist_x; *y = min_dist_y; + return found_net_or_pin; } #if 0 diff --git a/src/xschem.h b/src/xschem.h index 3d98fc33..68eefe8e 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1396,7 +1396,8 @@ extern int callback(const char *winpath, int event, int mx, int my, KeySym key, int button, int aux, int state); extern void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h); extern Selected find_closest_obj(double mx,double my, int override_lock); -extern void find_closest_net_or_symbol_pin(double mx,double my, double *x, double *y); +/*extern void find_closest_net_or_symbol_pin(double mx,double my, double *x, double *y);*/ +extern int find_closest_net_or_symbol_pin(double mx,double my, double *x, double *y); extern void drawline(int c, int what, double x1,double y1,double x2,double y2, int dash, void *ct); extern void draw_xhair_line(GC gc, int size, double linex1, double liney1, double linex2, double liney2);