set tk_scaling C variable global, updated in draw(), caching tcl tk_scaling variable, add tk_scaling in threshold expression in find_closest_*() functions

This commit is contained in:
stefan schippers 2025-09-15 01:38:10 +02:00
parent ee920560ff
commit 987faa1a41
6 changed files with 9 additions and 20 deletions

View File

@ -35,9 +35,7 @@ static int waves_selected(int event, KeySym key, int state, int button)
static unsigned int excl = STARTZOOM | STARTRECT | STARTLINE | STARTWIRE |
STARTPAN | STARTSELECT | STARTMOVE | STARTCOPY;
int draw_xhair = tclgetboolvar("draw_crosshair");
static double tk_scaling = 1.0;
int border;
tk_scaling = atof(tcleval("tk scaling"));
border = (int)(5.0 * tk_scaling); /* fixed number of screen pixels */
rstate = state; /* rstate does not have ShiftMask bit, so easier to test for KeyPress events */
rstate &= ~ShiftMask; /* don't use ShiftMask, identifying characters is sufficient */

View File

@ -3039,13 +3039,6 @@ static void draw_graph_grid(Graph_ctx *gr, void *ct)
int j, k;
double mark_size = gr->marginy/10.0;
#if 0
static double tk_scaling = 1.0;
int border;
tk_scaling = atof(tcleval("tk scaling"));
border = (int)(5.0 * tk_scaling); /* fixed number of screen pixels */
#endif
/* calculate dash length for grid lines */
dash_size = 1.5 * xctx->mooz;
dash_size = dash_size < 1.0 ? 0.0: (dash_size > 3.0 ? 3.0 : 2.0);
@ -3056,11 +3049,6 @@ static void draw_graph_grid(Graph_ctx *gr, void *ct)
/* graph bounding box */
drawrect(GRIDLAYER, NOW, gr->rx1, gr->ry1, gr->rx2, gr->ry2, 2, -1, -1);
#if 0
/* graph graph selection boundary */
drawrect(GRIDLAYER, NOW, gr->rx1+border, gr->ry1+border, gr->rx2-border, gr->ry2-border, 2, -1, -1);
#endif
bbox(START, 0.0, 0.0, 0.0, 0.0);
bbox(ADD, gr->rx1, gr->ry1, gr->rx2, gr->ry2);
bbox(SET_INSIDE, 0.0, 0.0, 0.0, 0.0);
@ -5110,6 +5098,7 @@ void draw(void)
dbg(1, "draw()\n");
if(!xctx || xctx->no_draw) return;
tk_scaling = atof(tcleval("tk scaling"));
cs = tclgetdoublevar("cadsnap");
cairo_font_scale = tclgetdoublevar("cairo_font_scale");
xctx->cadhalfdotsize = CADHALFDOTSIZE * (cs < 20. ? cs : 20.) / 10.;

View File

@ -33,7 +33,7 @@ static void find_closest_wire(double mx, double my, int override_lock)
int i, w=-1;
double threshold;
double d = distance;
threshold = CADWIREMINDIST * CADWIREMINDIST * xctx->zoom * xctx->zoom;
threshold = CADWIREMINDIST * CADWIREMINDIST * xctx->zoom * xctx->zoom * tk_scaling;
for(i=0;i<xctx->wires; ++i)
{
@ -117,7 +117,7 @@ static void find_closest_polygon(double mx, double my, int override_lock)
double x1, y1, x2, y2;
double threshold;
double d = distance;
threshold = CADWIREMINDIST * CADWIREMINDIST * xctx->zoom * xctx->zoom;
threshold = CADWIREMINDIST * CADWIREMINDIST * xctx->zoom * xctx->zoom * tk_scaling;
for(c=0;c<cadlayers; ++c)
{
if(!xctx->enable_layer[c]) continue;
@ -162,7 +162,7 @@ static void find_closest_line(double mx, double my, int override_lock)
int i, c, l = -1, col = 0;
double threshold;
double d = distance;
threshold = CADWIREMINDIST * CADWIREMINDIST * xctx->zoom * xctx->zoom;
threshold = CADWIREMINDIST * CADWIREMINDIST * xctx->zoom * xctx->zoom * tk_scaling;
for(c=0;c<cadlayers; ++c)
{
if(!xctx->enable_layer[c]) continue;
@ -329,7 +329,7 @@ static void find_closest_arc(double mx, double my, int override_lock)
int match;
double threshold;
double d = distance;
threshold = CADWIREMINDIST * CADWIREMINDIST * xctx->zoom * xctx->zoom;
threshold = CADWIREMINDIST * CADWIREMINDIST * xctx->zoom * xctx->zoom * tk_scaling;
for(c=0;c<cadlayers; ++c)
{
@ -447,7 +447,7 @@ static void find_closest_text(double mx, double my, int override_lock)
#endif
char *estr = NULL;
double d = distance;
threshold = CADWIREMINDIST * CADWIREMINDIST * xctx->zoom * xctx->zoom;
threshold = CADWIREMINDIST * CADWIREMINDIST * xctx->zoom * xctx->zoom * tk_scaling;
for(i=0;i<xctx->texts; ++i)
{
rot = xctx->text[i].rot;

View File

@ -184,6 +184,7 @@ int text_ps=1; /* use ps font for text instead of xschem's internal vector font
char bus_char[3] = {0, 0, 0};
int yyparse_error = 0;
char *xschem_executable=NULL;
double tk_scaling = 1.0;
Tcl_Interp *interp = NULL;
double *character[256]; /* array or per-char coordinates of xschem internal vector font */
char old_win_path[PATH_MAX] = ".drw"; /* previously switched window, used in callback() */

View File

@ -1228,6 +1228,7 @@ extern double cadhalfdotsize;
extern char bus_char[];
extern int yyparse_error;
extern char *xschem_executable;
extern double tk_scaling;
extern Tcl_Interp *interp;
extern double *character[256];
extern char old_win_path[PATH_MAX]; /* previously switched window, used in callback() */

View File

@ -710,7 +710,7 @@
#### FIX GRAPHIC PROBLEMS ON SOME DRIVERS/GPU CONFIGURATIONS
###########################################################################
#### if you see garbage on screen / graphic artifacts while editing with
#### xschem try to set this to 1. Default: not enabled (0)
#### xschem try to set this to 1. Default: enabled (1)
# set fix_broken_tiled_fill 0
###########################################################################