From 2ec5944dd4b681ec790f523f3fddb4b0d5802ff8 Mon Sep 17 00:00:00 2001 From: Giles Atkinson <“gatk555@gmail.com”> Date: Tue, 30 Jan 2024 13:54:21 +0000 Subject: [PATCH] Use all available precision when creating a "plot" command for a zoomed window. That prevents an unexpected zoom-out in one dimension caused by a zero-height (or width) window being requested when zooming with already high magnification. --- src/frontend/plotting/x11.c | 19 ++++++++++++++----- src/frontend/wdisp/windisp.c | 10 ++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/frontend/plotting/x11.c b/src/frontend/plotting/x11.c index fed83762c..ca468cd24 100644 --- a/src/frontend/plotting/x11.c +++ b/src/frontend/plotting/x11.c @@ -1085,14 +1085,23 @@ zoomin(GRAPH *graph) if ((t = strchr(buf2, ':')) != NULL) *t = '\0'; + /* Set the foreground and background colors to the + * "calling" window's colors using undocumented keyword, "sgraphid". + */ + if (!eq(plot_cur->pl_typename, buf2)) { + /* Switch plot before and after "plot" command. */ (void) sprintf(buf, - "setplot %s; %s xlimit %.20e %.20e ylimit %.20e %.20e sgraphid %d; setplot $curplot\n", - buf2, graph->commandline, fx0, fx1, fy0, fy1, graph->graphid); + "setplot %s; %s xlimit %.20e %.20e ylimit %.20e %.20e " + "sgraphid %d; setplot $curplot\n", + buf2, graph->commandline, fx0, fx1, fy0, fy1, + graph->graphid); } else { - /* set the foreground and background colors to the "calling" window's colors */ - (void) sprintf(buf, "%s xlimit %e %e ylimit %e %e sgraphid %d\n", - graph->commandline, fx0, fx1, fy0, fy1, graph->graphid); + (void) sprintf(buf, + "%s xlimit %.20e %.20e ylimit %.20e %.20e " + "sgraphid %d\n", + graph->commandline, fx0, fx1, fy0, fy1, + graph->graphid); } /* don't use the following if using GNU Readline or BSD EditLine */ diff --git a/src/frontend/wdisp/windisp.c b/src/frontend/wdisp/windisp.c index 33a238fcd..ed8bc5a3c 100644 --- a/src/frontend/wdisp/windisp.c +++ b/src/frontend/wdisp/windisp.c @@ -630,11 +630,13 @@ LRESULT CALLBACK PlotWindowProc(HWND hwnd, UINT uMsg, if (!eq(plot_cur->pl_typename, buf2)) { (void) sprintf(buf, -// "setplot %s; %s xlimit %e %e ylimit %e %e; setplot $curplot\n", - "setplot %s; %s xlimit %e %e ylimit %e %e sgraphid %d\n", - buf2, gr->commandline, fx0, fxe, fy0, fye, gr->graphid); + "setplot %s; %s xlimit %.20e %.20e ylimit %.20e " + "%.20e sgraphid %d ; setplot $curplot\n", + buf2, gr->commandline, fx0, fxe, fy0, fye, + gr->graphid); } else { - (void) sprintf(buf, "%s xlimit %e %e ylimit %e %e sgraphid %d\n", + (void) sprintf(buf, "%s xlimit %.20e %.20e ylimit %.20e %.20e " + "sgraphid %d\n", gr->commandline, fx0, fxe, fy0, fye, gr->graphid); }