redo gnuplot_terminal: Do not save eps/png automatically

none      1: do not print an eps or png file (default)
png       2: print png file, keep command window open
png/quit  3: print png file, quit command window
eps       4: print eps file, keep command window open
eps/quit  5: print eps file, quit command window
This commit is contained in:
Holger Vogt 2019-02-23 22:57:34 +01:00
parent b2aaa44bb4
commit 6952c4fb7e
1 changed files with 30 additions and 24 deletions

View File

@ -85,6 +85,10 @@ ft_gnuplot(double *xlims, double *ylims, char *filename, char *title, char *xlab
terminal_type = 2; terminal_type = 2;
if (cieq(terminal,"png/quit")) if (cieq(terminal,"png/quit"))
terminal_type = 3; terminal_type = 3;
if (cieq(terminal, "eps"))
terminal_type = 4;
if (cieq(terminal, "eps/quit"))
terminal_type = 5;
} }
if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth, 0)) if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth, 0))
@ -219,11 +223,6 @@ ft_gnuplot(double *xlims, double *ylims, char *filename, char *title, char *xlab
fprintf(file, "set format y \"%%g\"\n"); fprintf(file, "set format y \"%%g\"\n");
fprintf(file, "set format x \"%%g\"\n"); fprintf(file, "set format x \"%%g\"\n");
if (terminal_type == 3) {
fprintf(file, "set terminal png noenhanced\n");
fprintf(file, "set out \'%s.png\'\n", filename);
}
fprintf(file, "plot "); fprintf(file, "plot ");
i = 0; i = 0;
@ -240,28 +239,35 @@ ft_gnuplot(double *xlims, double *ylims, char *filename, char *title, char *xlab
} }
fprintf(file, "\n"); fprintf(file, "\n");
/* do not print an eps or png file if filename start with 'np_' */ /* terminal_type
if (!ciprefix("np_", filename)) { 1: do not print an eps or png file
if (terminal_type != 3) 2: print png file, keep command window open
3: print png file, quit command window
4: print eps file, keep command window open
5: print eps file, quit command window
*/
if ((terminal_type == 2) || (terminal_type == 4))
fprintf(file, "set terminal push\n"); fprintf(file, "set terminal push\n");
if (terminal_type == 1) { if ((terminal_type == 4) || (terminal_type == 5)) {
fprintf(file, "set terminal postscript eps color noenhanced\n"); fprintf(file, "set terminal postscript eps color noenhanced\n");
fprintf(file, "set out \'%s.eps\'\n", filename); fprintf(file, "set out \'%s.eps\'\n", filename);
} }
if (terminal_type == 2) { if ((terminal_type == 2) || (terminal_type == 3)) {
fprintf(file, "set terminal png noenhanced\n"); fprintf(file, "set terminal png noenhanced\n");
fprintf(file, "set out \'%s.png\'\n", filename); fprintf(file, "set out \'%s.png\'\n", filename);
} }
if (terminal_type != 3) { if ((terminal_type == 2) || (terminal_type == 4)) {
fprintf(file, "replot\n"); fprintf(file, "replot\n");
fprintf(file, "set term pop\n"); fprintf(file, "set term pop\n");
} fprintf(file, "replot\n");
} }
if (terminal_type == 3) if ((terminal_type == 3) || (terminal_type == 5)) {
fprintf(file, "exit\n");
else
fprintf(file, "replot\n"); fprintf(file, "replot\n");
fprintf(file, "exit\n");
}
(void) fclose(file); (void) fclose(file);