Browse Source

iplot graphics scaling, printing interrupt message

pre-master-46
h_vogt 17 years ago
parent
commit
e778aab344
  1. 4
      ChangeLog
  2. 30
      src/frontend/plotting/graf.c
  3. 4
      src/frontend/signal_handler.c

4
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 2009-05-06 Holger Vogt
* pp_lst.c:428 malloc(len+1) +1 added (bug report 2787072) * pp_lst.c:428 malloc(len+1) +1 added (bug report 2787072)
configure.in:803, 958 (bug reports 1834772, 2787076 and 2787079) configure.in:803, 958 (bug reports 1834772, 2787076 and 2787079)

30
src/frontend/plotting/graf.c

@ -55,8 +55,8 @@ static char *ticlist = ticbuf;
#define MAXTICS 100 #define MAXTICS 100
double *readtics(char *string); 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. * Start of a new graph.
@ -649,7 +649,7 @@ iplot(struct plot *pl, int id)
/* Nothing yet */ /* Nothing yet */
return(0); return(0);
} else if (len == IPOINTMIN || !id) { } else if (len == IPOINTMIN || !id) {
resumption = FALSE;
resumption = FALSE;
/* Draw the grid for the first time, and plot everything. */ /* Draw the grid for the first time, and plot everything. */
lims = ft_minmax(xs, TRUE); lims = ft_minmax(xs, TRUE);
xlims[0] = lims[0]; xlims[0] = lims[0];
@ -683,7 +683,7 @@ iplot(struct plot *pl, int id)
/* note: have command options for iplot to specify xdelta, /* note: have command options for iplot to specify xdelta,
etc. So don't need static variables hack. Assume default etc. So don't need static variables hack. Assume default
values for now. */ values for now. */
sprintf(commandline, "plot %s", yl);
sprintf(commandline, "plot %s", yl);
(void) gr_init(xlims, ylims, xs->v_name, (void) gr_init(xlims, ylims, xs->v_name,
pl->pl_title, (char *) NULL, j, 0.0, 0.0, pl->pl_title, (char *) NULL, j, 0.0, 0.0,
@ -696,7 +696,8 @@ iplot(struct plot *pl, int id)
} }
inited = 1; inited = 1;
} else { } 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 */ /* First see if we have to make the screen bigger */
dy = (isreal(xs) ? xs->v_realdata[len - 1] : dy = (isreal(xs) ? xs->v_realdata[len - 1] :
realpart(&xs->v_compdata[len - 1])); realpart(&xs->v_compdata[len - 1]));
@ -707,6 +708,7 @@ iplot(struct plot *pl, int id)
stop = HUGE; stop = HUGE;
start = - stop; start = - stop;
} }
/* checking for x lo */
while (dy < currentgraph->data.xmin) { while (dy < currentgraph->data.xmin) {
changed = TRUE; changed = TRUE;
if (ft_grdb) if (ft_grdb)
@ -716,6 +718,7 @@ iplot(struct plot *pl, int id)
(currentgraph->data.xmax - (currentgraph->data.xmax -
currentgraph->data.xmin) currentgraph->data.xmin)
* XFACTOR); * XFACTOR);
/* set the new x lo value */
currentgraph->data.xmin -= currentgraph->data.xmin -=
(currentgraph->data.xmax - (currentgraph->data.xmax -
currentgraph->data.xmin) currentgraph->data.xmin)
@ -729,6 +732,7 @@ iplot(struct plot *pl, int id)
currentgraph->data.xmin) currentgraph->data.xmin)
currentgraph->data.xmax = currentgraph->data.xmax =
currentgraph->data.xmin; currentgraph->data.xmin;
/* checking for x hi */
while (dy > currentgraph->data.xmax) { while (dy > currentgraph->data.xmax) {
changed = TRUE; changed = TRUE;
if (ft_grdb) if (ft_grdb)
@ -737,6 +741,7 @@ iplot(struct plot *pl, int id)
currentgraph->data.xmax + currentgraph->data.xmax +
(currentgraph->data.xmax - (currentgraph->data.xmax -
currentgraph->data.xmin) * XFACTOR); currentgraph->data.xmin) * XFACTOR);
/* set the new x hi value */
currentgraph->data.xmax += currentgraph->data.xmax +=
(currentgraph->data.xmax - (currentgraph->data.xmax -
currentgraph->data.xmin) * currentgraph->data.xmin) *
@ -746,6 +751,7 @@ iplot(struct plot *pl, int id)
break; break;
} }
} }
/* checking for all y values */
for (v = pl->pl_dvecs; v; v = v->v_next) { for (v = pl->pl_dvecs; v; v = v->v_next) {
if (!(v->v_flags & VF_PLOT)) if (!(v->v_flags & VF_PLOT))
continue; continue;
@ -753,6 +759,7 @@ iplot(struct plot *pl, int id)
realpart(&v->v_compdata[len - 1])); realpart(&v->v_compdata[len - 1]));
if (ft_grdb) if (ft_grdb)
fprintf(cp_err, "y = %G\n\r", dy); fprintf(cp_err, "y = %G\n\r", dy);
/* checking for y lo */
while (dy < currentgraph->data.ymin) { while (dy < currentgraph->data.ymin) {
changed = TRUE; changed = TRUE;
if (ft_grdb) if (ft_grdb)
@ -761,14 +768,18 @@ iplot(struct plot *pl, int id)
currentgraph->data.ymin - currentgraph->data.ymin -
(currentgraph->data.ymax - (currentgraph->data.ymax -
currentgraph->data.ymin) * YFACTOR); currentgraph->data.ymin) * YFACTOR);
/* set the new y lo value */
currentgraph->data.ymin -= currentgraph->data.ymin -=
(currentgraph->data.ymax - (currentgraph->data.ymax -
currentgraph->data.ymin) * YFACTOR;
currentgraph->data.ymin) * YFACTOR;
/* currentgraph->data.ymin +=
(dy - currentgraph->data.ymin) * YFACTOR;*/
} }
if (currentgraph->data.ymax < if (currentgraph->data.ymax <
currentgraph->data.ymin) currentgraph->data.ymin)
currentgraph->data.ymax = currentgraph->data.ymax =
currentgraph->data.ymin; currentgraph->data.ymin;
/* checking for y hi */
while (dy > currentgraph->data.ymax) { while (dy > currentgraph->data.ymax) {
changed = TRUE; changed = TRUE;
if (ft_grdb) if (ft_grdb)
@ -777,16 +788,21 @@ iplot(struct plot *pl, int id)
currentgraph->data.ymax + currentgraph->data.ymax +
(currentgraph->data.ymax - (currentgraph->data.ymax -
currentgraph->data.ymin) * YFACTOR); currentgraph->data.ymin) * YFACTOR);
/* set the new y hi value */
currentgraph->data.ymax += currentgraph->data.ymax +=
(currentgraph->data.ymax - (currentgraph->data.ymax -
currentgraph->data.ymin) * YFACTOR;
currentgraph->data.ymin) * YFACTOR;
/* currentgraph->data.ymax +=
(dy - currentgraph->data.ymax) * YFACTOR;*/
} }
} }
if (changed) { if (changed) {
/* Redraw everything. */ /* Redraw everything. */
gr_pmsg("Resizing screen"); gr_pmsg("Resizing screen");
gr_resize(currentgraph); gr_resize(currentgraph);
#ifndef X_DISPLAY_MISSING
gr_redraw(currentgraph); gr_redraw(currentgraph);
#endif
} else { } else {
/* Just connect the last two points. This won't be done /* Just connect the last two points. This won't be done
* with curve interpolation, so it might look funny. */ * with curve interpolation, so it might look funny. */

4
src/frontend/signal_handler.c

@ -53,9 +53,9 @@ ft_sigintr(void)
gr_clean(); /* Clean up plot window */ gr_clean(); /* Clean up plot window */
if (ft_intrpt) /* check to see if we're being interrupted repeatedly */ 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 { else {
fprintf(cp_err, "Interrupted once . . .\n");
fprintf(cp_err, "\nInterrupted once . . .\n");
ft_intrpt = TRUE; ft_intrpt = TRUE;
} }

Loading…
Cancel
Save