From e778aab344751c9bcb66fb3a7d2a423dacfb4218 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sat, 9 May 2009 13:23:08 +0000 Subject: [PATCH] iplot graphics scaling, printing interrupt message --- ChangeLog | 4 ++++ src/frontend/plotting/graf.c | 30 +++++++++++++++++++++++------- src/frontend/signal_handler.c | 4 ++-- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index c92f6b403..cf482ddd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-05-09 Holger Vogt + * graf.c: graphics scaling during iplot mad ea little more + convenient + 2009-05-06 Holger Vogt * pp_lst.c:428 malloc(len+1) +1 added (bug report 2787072) configure.in:803, 958 (bug reports 1834772, 2787076 and 2787079) diff --git a/src/frontend/plotting/graf.c b/src/frontend/plotting/graf.c index aa60f310e..4ce3d2358 100644 --- a/src/frontend/plotting/graf.c +++ b/src/frontend/plotting/graf.c @@ -55,8 +55,8 @@ static char *ticlist = ticbuf; #define MAXTICS 100 double *readtics(char *string); -#define XFACTOR 2 /* How much to expand the X scale during iplot. */ -#define YFACTOR 1.5 /* How much to expand the Y scale during iplot. */ +#define XFACTOR 1 /* How much to expand the X scale during iplot. */ +#define YFACTOR 0.2 /* How much to expand the Y scale during iplot. */ /* * Start of a new graph. @@ -649,7 +649,7 @@ iplot(struct plot *pl, int id) /* Nothing yet */ return(0); } else if (len == IPOINTMIN || !id) { - resumption = FALSE; + resumption = FALSE; /* Draw the grid for the first time, and plot everything. */ lims = ft_minmax(xs, TRUE); xlims[0] = lims[0]; @@ -683,7 +683,7 @@ iplot(struct plot *pl, int id) /* note: have command options for iplot to specify xdelta, etc. So don't need static variables hack. Assume default values for now. */ - sprintf(commandline, "plot %s", yl); + sprintf(commandline, "plot %s", yl); (void) gr_init(xlims, ylims, xs->v_name, pl->pl_title, (char *) NULL, j, 0.0, 0.0, @@ -696,7 +696,8 @@ iplot(struct plot *pl, int id) } inited = 1; } else { - Input(&reqst, 0); + /* plot the last points and resize if needed */ + Input(&reqst, 0); /* First see if we have to make the screen bigger */ dy = (isreal(xs) ? xs->v_realdata[len - 1] : realpart(&xs->v_compdata[len - 1])); @@ -707,6 +708,7 @@ iplot(struct plot *pl, int id) stop = HUGE; start = - stop; } + /* checking for x lo */ while (dy < currentgraph->data.xmin) { changed = TRUE; if (ft_grdb) @@ -716,6 +718,7 @@ iplot(struct plot *pl, int id) (currentgraph->data.xmax - currentgraph->data.xmin) * XFACTOR); + /* set the new x lo value */ currentgraph->data.xmin -= (currentgraph->data.xmax - currentgraph->data.xmin) @@ -729,6 +732,7 @@ iplot(struct plot *pl, int id) currentgraph->data.xmin) currentgraph->data.xmax = currentgraph->data.xmin; + /* checking for x hi */ while (dy > currentgraph->data.xmax) { changed = TRUE; if (ft_grdb) @@ -737,6 +741,7 @@ iplot(struct plot *pl, int id) currentgraph->data.xmax + (currentgraph->data.xmax - currentgraph->data.xmin) * XFACTOR); + /* set the new x hi value */ currentgraph->data.xmax += (currentgraph->data.xmax - currentgraph->data.xmin) * @@ -746,6 +751,7 @@ iplot(struct plot *pl, int id) break; } } + /* checking for all y values */ for (v = pl->pl_dvecs; v; v = v->v_next) { if (!(v->v_flags & VF_PLOT)) continue; @@ -753,6 +759,7 @@ iplot(struct plot *pl, int id) realpart(&v->v_compdata[len - 1])); if (ft_grdb) fprintf(cp_err, "y = %G\n\r", dy); + /* checking for y lo */ while (dy < currentgraph->data.ymin) { changed = TRUE; if (ft_grdb) @@ -761,14 +768,18 @@ iplot(struct plot *pl, int id) currentgraph->data.ymin - (currentgraph->data.ymax - currentgraph->data.ymin) * YFACTOR); + /* set the new y lo value */ currentgraph->data.ymin -= (currentgraph->data.ymax - - currentgraph->data.ymin) * YFACTOR; + currentgraph->data.ymin) * YFACTOR; +/* currentgraph->data.ymin += + (dy - currentgraph->data.ymin) * YFACTOR;*/ } if (currentgraph->data.ymax < currentgraph->data.ymin) currentgraph->data.ymax = currentgraph->data.ymin; + /* checking for y hi */ while (dy > currentgraph->data.ymax) { changed = TRUE; if (ft_grdb) @@ -777,16 +788,21 @@ iplot(struct plot *pl, int id) currentgraph->data.ymax + (currentgraph->data.ymax - currentgraph->data.ymin) * YFACTOR); + /* set the new y hi value */ currentgraph->data.ymax += (currentgraph->data.ymax - - currentgraph->data.ymin) * YFACTOR; + currentgraph->data.ymin) * YFACTOR; +/* currentgraph->data.ymax += + (dy - currentgraph->data.ymax) * YFACTOR;*/ } } if (changed) { /* Redraw everything. */ gr_pmsg("Resizing screen"); gr_resize(currentgraph); +#ifndef X_DISPLAY_MISSING gr_redraw(currentgraph); +#endif } else { /* Just connect the last two points. This won't be done * with curve interpolation, so it might look funny. */ diff --git a/src/frontend/signal_handler.c b/src/frontend/signal_handler.c index 1f9292c91..f226eec59 100644 --- a/src/frontend/signal_handler.c +++ b/src/frontend/signal_handler.c @@ -53,9 +53,9 @@ ft_sigintr(void) gr_clean(); /* Clean up plot window */ if (ft_intrpt) /* check to see if we're being interrupted repeatedly */ - fprintf(cp_err, "Interrupted again (ouch)\n"); + fprintf(cp_err, "\nInterrupted again (ouch)\n"); else { - fprintf(cp_err, "Interrupted once . . .\n"); + fprintf(cp_err, "\nInterrupted once . . .\n"); ft_intrpt = TRUE; }