version 1.1.1.1, 2000/01/22 14:16:27 |
version 1.1.1.2, 2003/09/15 07:09:37 |
Line 88 TERM_PUBLIC void MP_boxfill __PROTO((int style, |
|
Line 88 TERM_PUBLIC void MP_boxfill __PROTO((int style, |
|
#define MP_YSIZE 3.0 |
#define MP_YSIZE 3.0 |
|
|
/* gnuplot units will be one pixel if printing device has this |
/* gnuplot units will be one pixel if printing device has this |
resolution */ |
resolution. Too small resolutions (like 300) can give rough |
#define MP_DPI (300) |
appearence to curves when user tries to smooth a curve by choosing |
|
high sampling rate. */ |
|
#define MP_DPI (2400) |
|
|
#define MP_XMAX (MP_XSIZE*MP_DPI) |
#define MP_XMAX (MP_XSIZE*MP_DPI) |
#define MP_YMAX (MP_YSIZE*MP_DPI) |
#define MP_YMAX (MP_YSIZE*MP_DPI) |
Line 134 static TBOOLEAN MP_color = FALSE; |
|
Line 136 static TBOOLEAN MP_color = FALSE; |
|
static TBOOLEAN MP_solid = FALSE; |
static TBOOLEAN MP_solid = FALSE; |
|
|
/* compatability mode*/ |
/* compatability mode*/ |
static TBOOLEAN MP_notex = FALSE; |
/* static TBOOLEAN MP_notex = FALSE; */ |
|
#define MP_NO_TEX 0 |
|
#define MP_TEX 1 |
|
#define MP_LATEX 2 |
|
static int MP_tex = MP_TEX; |
|
/* add usepackage instructions for PSNFSS ? */ |
|
#define MP_PSNFSS_NONE 0 |
|
#define MP_PSNFSS_7 1 |
|
#define MP_PSNFSS_8 2 |
|
static int MP_psnfss = MP_PSNFSS_NONE; |
|
/* add a4paper option to documentclass */ |
|
static int MP_a4paper = 0; |
|
/* write a prologues line */ |
|
static int MP_prologues = -1; |
/* has a font change taken place? */ |
/* has a font change taken place? */ |
static TBOOLEAN MP_fontchanged = FALSE; |
static TBOOLEAN MP_fontchanged = FALSE; |
|
|
|
|
{ |
{ |
MP_color = FALSE; |
MP_color = FALSE; |
MP_solid = FALSE; |
MP_solid = FALSE; |
MP_notex = FALSE; |
/* MP_notex = FALSE;*/ |
|
MP_tex = MP_TEX; |
|
MP_a4paper = 0; |
|
MP_psnfss = MP_PSNFSS_NONE; |
MP_fontsize = 10.0; |
MP_fontsize = 10.0; |
MP_textmag = 1.0; |
MP_textmag = 1.0; |
|
MP_prologues = -1; |
strcpy(MP_fontname, "cmr10"); |
strcpy(MP_fontname, "cmr10"); |
strcpy(default_font, ""); /* output file will store default font info */ |
strcpy(default_font, ""); /* output file will store default font info */ |
while (!END_OF_COMMAND) { |
while (!END_OF_COMMAND) { |
if (almost_equals(c_token, "m$onochrome")) { |
if (almost_equals(c_token, "mo$nochrome")) { |
MP_color = FALSE; |
MP_color = FALSE; |
c_token++; |
c_token++; |
continue; |
continue; |
|
|
continue; |
continue; |
} |
} |
if (almost_equals(c_token, "n$otex")) { |
if (almost_equals(c_token, "n$otex")) { |
MP_notex = TRUE; |
/* MP_notex = TRUE;*/ |
|
MP_tex = MP_NO_TEX; |
strcpy(MP_fontname, "pcrr8r"); |
strcpy(MP_fontname, "pcrr8r"); |
c_token++; |
c_token++; |
continue; |
continue; |
} |
} |
if (almost_equals(c_token, "t$ex")) { |
if (almost_equals(c_token, "t$ex")) { |
MP_notex = FALSE; |
MP_tex = MP_TEX; |
c_token++; |
c_token++; |
continue; |
continue; |
} |
} |
|
if (almost_equals(c_token, "la$tex")) { |
|
MP_tex = MP_LATEX; |
|
c_token++; |
|
continue; |
|
} |
|
if (almost_equals(c_token, "a4$paper")) { |
|
MP_a4paper = 1; |
|
c_token++; |
|
continue; |
|
} |
|
if(almost_equals(c_token, "ps$nfss")) { |
|
MP_psnfss = MP_PSNFSS_8; |
|
c_token++; |
|
continue; |
|
} |
|
if(almost_equals(c_token, "psnfss-v$ersion7")) { |
|
MP_psnfss = MP_PSNFSS_7; |
|
c_token++; |
|
continue; |
|
} |
|
if(almost_equals(c_token, "nops$nfss")) { |
|
MP_psnfss = MP_PSNFSS_NONE; |
|
c_token++; |
|
continue; |
|
} |
if (almost_equals(c_token, "de$fault")) { |
if (almost_equals(c_token, "de$fault")) { |
c_token++; |
c_token++; |
continue; |
continue; |
} |
} |
if (almost_equals(c_token, "m$agnification")) { |
if (almost_equals(c_token, "pro$logues")) { |
|
int dummy_for_prologues; |
|
c_token++; |
|
if(!(END_OF_COMMAND)) { |
|
if(sscanf(&(input_line[token[c_token].start_index]), "%d", &dummy_for_prologues) == 1) { |
|
MP_prologues = dummy_for_prologues; |
|
} |
c_token++; |
c_token++; |
|
} |
|
continue; |
|
} |
|
if (almost_equals(c_token, "nopro$logues")) { |
|
MP_prologues = -1; |
|
c_token++; |
|
continue; |
|
} |
|
if (almost_equals(c_token, "ma$gnification")) { |
|
c_token++; |
if (!END_OF_COMMAND) { /* global text scaling */ |
if (!END_OF_COMMAND) { /* global text scaling */ |
struct value a; |
struct value a; |
MP_textmag = (double) real(const_express(&a)); |
MP_textmag = (double) real(const_express(&a)); |
|
|
MP_fontsize = 99.99; |
MP_fontsize = 99.99; |
|
|
term->v_char = (unsigned int) (MP_DPI * MP_fontsize * MP_textmag * 11 / 720); |
term->v_char = (unsigned int) (MP_DPI * MP_fontsize * MP_textmag * 11 / 720); |
if (MP_notex) { /* Courier is a little wider than cmtt */ |
if (MP_tex == MP_NO_TEX) { /* Courier is a little wider than cmtt */ |
term->h_char = (unsigned int) (MP_DPI * MP_fontsize * MP_textmag * 6.0 / 720 + 0.5); |
term->h_char = (unsigned int) (MP_DPI * MP_fontsize * MP_textmag * 6.0 / 720 + 0.5); |
} else { |
} else { |
term->h_char = (unsigned int) (MP_DPI * MP_fontsize * MP_textmag * 5.3 / 720 + 0.5); |
term->h_char = (unsigned int) (MP_DPI * MP_fontsize * MP_textmag * 5.3 / 720 + 0.5); |
} |
} |
sprintf(term_options, "%s%s%s%s%6.3f \"%s\" %5.2f", |
sprintf(term_options, "%s%s%s%s%6.3f \"%s\" %5.2f %d %d", |
MP_color ? "color " : "", MP_solid ? "solid " : "", |
MP_color ? "color " : "", MP_solid ? "solid " : "", |
MP_notex ? "notex " : "", "mag ", |
(MP_tex == MP_NO_TEX) ? "notex " : (MP_tex == MP_LATEX) ? "latex " : "", "mag ", |
MP_textmag, MP_fontname, MP_fontsize); |
MP_textmag, MP_fontname, MP_fontsize, MP_psnfss, MP_prologues); |
} |
} |
|
|
TERM_PUBLIC void |
TERM_PUBLIC void |
|
|
time(&now); |
time(&now); |
MP_posx = MP_posy = 0; |
MP_posx = MP_posy = 0; |
fprintf(gpoutfile, "%%GNUPLOT Metapost output: %s\n", asctime(localtime(&now))); |
fprintf(gpoutfile, "%%GNUPLOT Metapost output: %s\n", asctime(localtime(&now))); |
|
if(MP_prologues > -1) { |
|
fprintf(gpoutfile, "prologues:=%d;\n", MP_prologues); |
|
} |
|
if (MP_tex == MP_LATEX) { |
|
fputs("\n\ |
|
%% Add \\documentclass and \\begin{dcoument} for latex\n\ |
|
%% NB you should set the environment variable TEX to the name of your\n\ |
|
%% latex executable (normally latex) inorder for metapost to work\n\ |
|
%% or run\n\ |
|
%% mpost --tex=latex ...\n\ |
|
\n\ |
|
% BEGPRE\n\ |
|
\\verbatimtex\n", gpoutfile); |
|
if(MP_a4paper) { |
|
fputs("\\documentclass[a4paper]{article}\n", gpoutfile); |
|
} else { |
|
fputs("\\documentclass{article}\n", gpoutfile); |
|
} |
|
switch(MP_psnfss) { |
|
case MP_PSNFSS_7: { |
|
fputs("\\usepackage[latin1]{inputenc}\n\ |
|
\\usepackage[T1]{fontenc}\n\ |
|
\\usepackage{times,mathptmx}\n\ |
|
\\usepackage{helvet}\n\ |
|
\\usepackage{courier}\n", gpoutfile); |
|
} break; |
|
case MP_PSNFSS_8: { |
|
fputs("\\usepackage[latin1]{inputenc}\n\ |
|
\\usepackage[T1]{fontenc}\n\ |
|
\\usepackage{textcomp}\n\ |
|
\\usepackage{mathptmx}\n\ |
|
\\usepackage[scaled=.92]{helvet}\n\ |
|
\\usepackage{courier}\n\ |
|
\\usepackage{latexsym}\n", gpoutfile); |
|
} break; |
|
} |
|
fputs("\\begin{document}\n\ |
|
etex\n% ENDPRE\n", |
|
gpoutfile); |
|
} |
|
|
fputs("\n\ |
fputs("\n\ |
|
warningcheck:=0;\n\ |
defaultmpt:=mpt:=4;\n\ |
defaultmpt:=mpt:=4;\n\ |
th:=.6;\n\ |
th:=.6;\n\ |
|
%% Have nice sharp joins on our lines\n\ |
|
linecap:=butt;\n\ |
|
linejoin:=mitered;\n\ |
\n\ |
\n\ |
def scalepen expr n = pickup pencircle scaled (n*th) enddef;\n\ |
def scalepen expr n = pickup pencircle scaled (n*th) enddef;\n\ |
def ptsize expr n = mpt:=n*defaultmpt enddef;\n", |
def ptsize expr n = mpt:=n*defaultmpt enddef;\n\ |
|
\n", |
gpoutfile); |
gpoutfile); |
|
|
fprintf(gpoutfile, "\ntextmag:=%6.3f;\n", MP_textmag); |
fprintf(gpoutfile, "\ntextmag:=%6.3f;\n", MP_textmag); |
Line 261 vardef makepic(expr str) =\n\ |
|
Line 367 vardef makepic(expr str) =\n\ |
|
fi\n\ |
fi\n\ |
enddef;\n\ |
enddef;\n\ |
\n\ |
\n\ |
def infontsize(expr str, size) =\n\ |
def infontsize(expr str, size) =\n\ |
infont str scaled (size / fontsize str)\n\ |
infont str scaled (size / fontsize str)\n\ |
enddef;\n", |
enddef;\n", |
gpoutfile); |
gpoutfile); |
|
|
if (MP_notex) { |
if (MP_tex == MP_NO_TEX) { |
fprintf(gpoutfile, "\n\ |
fprintf(gpoutfile, "\n\ |
defaultfont:= \"%s\";\n\ |
defaultfont:= \"%s\";\n\ |
defaultscale := %6.3f/fontsize defaultfont;\n", |
defaultscale := %6.3f/fontsize defaultfont;\n", |
MP_fontname, MP_fontsize); |
MP_fontname, MP_fontsize); |
} else { |
} else { |
|
if(MP_tex != MP_LATEX) { |
fputs("\n\ |
fputs("\n\ |
%font changes\n\ |
%font changes\n\ |
verbatimtex\n\ |
verbatimtex\n\ |
\\def\\setfont#1#2{%.\n\ |
\\def\\setfont#1#2{%.\n\ |
\\font\\gpfont=#1 at #2pt\n\ |
\\font\\gpfont=#1 at #2pt\n\ |
\\gpfont}\n", |
\\gpfont}\n", gpoutfile); |
gpoutfile); |
|
|
|
fprintf(gpoutfile, "\\setfont{%s}{%5.2f}\netex\n", |
fprintf(gpoutfile, "\\setfont{%s}{%5.2f}\netex\n", |
MP_fontname, MP_fontsize); |
MP_fontname, MP_fontsize |
|
); |
|
} |
} |
} |
fputs("\n\ |
fputs("\n\ |
color currentcolor; currentcolor=black;\n\ |
color currentcolor; currentcolor=black;\n\ |
|
|
MP_oldline = -2; |
MP_oldline = -2; |
MP_oldpen = 1.0; |
MP_oldpen = 1.0; |
MP_oldptsize = pointsize; |
MP_oldptsize = pointsize; |
fprintf(gpoutfile, "\nbeginfig(%d);\nw:=%gin;h:=%gin;\n", |
fprintf(gpoutfile, "\nbeginfig(%d);\nw:=%.3fin;h:=%.3fin;\n", |
MP_char_code, MP_xsize, MP_ysize); |
MP_char_code, MP_xsize, MP_ysize); |
fprintf(gpoutfile, "a:=w/%d;b:=h/%d;\n", term->xmax, term->ymax); |
/* MetaPost can only handle numbers up to 4096. When MP_DPI |
fprintf(gpoutfile, "scalepen 1; ptsize %g;linetype -2;\n", pointsize); |
is larger than 819, this is exceeded by (term->xmax). So we |
|
scale it and all coordinates down by factor of 10.0. And |
|
compensate by scaling a and b up. |
|
*/ |
|
fprintf(gpoutfile, "a:=w/%.1f;b:=h/%.1f;\n", (term->xmax)/10.0, (term->ymax)/10.0); |
|
fprintf(gpoutfile, "scalepen 1; ptsize %.3f;linetype -2;\n", pointsize); |
MP_char_code++; |
MP_char_code++; |
} |
} |
|
|
|
|
|
|
if (pointtype >= MP_POINT_TYPES) |
if (pointtype >= MP_POINT_TYPES) |
pointtype %= MP_POINT_TYPES; |
pointtype %= MP_POINT_TYPES; |
fprintf(gpoutfile, "gpdraw(%d,%da,%db);\n", pointtype, x, y); |
/* Change %d to %f, divide x,y by 10 */ |
|
fprintf(gpoutfile, "gpdraw(%d,%.1fa,%.1fb);\n", pointtype, x/10.0, y/10.0); |
} |
} |
|
|
TERM_PUBLIC void |
TERM_PUBLIC void |
|
|
if (MP_oldptsize != ps) { |
if (MP_oldptsize != ps) { |
if (MP_inline) |
if (MP_inline) |
MP_endline(); |
MP_endline(); |
fprintf(gpoutfile, "ptsize %g;\n", ps); |
fprintf(gpoutfile, "ptsize %.3f;\n", ps); |
MP_oldptsize = ps; |
MP_oldptsize = ps; |
} |
} |
} |
} |
|
|
if (MP_oldpen != lw) { |
if (MP_oldpen != lw) { |
if (MP_inline) |
if (MP_inline) |
MP_endline(); |
MP_endline(); |
fprintf(gpoutfile, "scalepen %g;\n", lw); |
fprintf(gpoutfile, "scalepen %.3f;\n", lw); |
MP_oldpen = lw; |
MP_oldpen = lw; |
} |
} |
} |
} |
Line 483 unsigned int uy; |
|
Line 596 unsigned int uy; |
|
} |
} |
} else { |
} else { |
MP_inline = TRUE; |
MP_inline = TRUE; |
fprintf(gpoutfile, "draw (%da,%db)", MP_posx, MP_posy); |
fprintf(gpoutfile, "draw (%.1fa,%.1fb)", MP_posx/10.0, MP_posy/10.0); |
MP_linecount = 2; |
MP_linecount = 2; |
} |
} |
MP_posx = ux; |
MP_posx = ux; |
MP_posy = uy; |
MP_posy = uy; |
fprintf(gpoutfile, "--(%da,%db)", MP_posx, MP_posy); |
fprintf(gpoutfile, "--(%.1fa,%.1fb)", MP_posx/10.0, MP_posy/10.0); |
} |
} |
|
|
static void |
static void |
|
|
{ |
{ |
MP_move(sx, sy); |
MP_move(sx, sy); |
if (head) { |
if (head) { |
fprintf(gpoutfile, "drawarrow (%da,%db)--(%da,%db);\n", |
fprintf(gpoutfile, "drawarrow (%.1fa,%.1fb)--(%.1fa,%.1fb);\n", |
sx, sy, ex, ey); |
sx/10.0, sy/10.0, ex/10.0, ey/10.0); |
} else if ((sx != ex) || (sy != ey)) { |
} else if ((sx != ex) || (sy != ey)) { |
fprintf(gpoutfile, "draw (%da,%db)--(%da,%db);\n", |
fprintf(gpoutfile, "draw (%.1fa,%.1fb)--(%.1fa,%.1fb);\n", |
sx, sy, ex, ey); |
sx/10.0, sy/10.0, ex/10.0, ey/10.0); |
} /* else: arrow with no length and no head = sound of one hand clapping? */ |
} /* else: arrow with no length and no head = sound of one hand clapping? */ |
MP_posx = ex; |
MP_posx = ex; |
MP_posy = ey; |
MP_posy = ey; |
|
|
return; |
return; |
|
|
/* F***. why do drivers need to modify string args? */ |
/* F***. why do drivers need to modify string args? */ |
text = gp_alloc(strlen(str)+1, "temp string"); |
text = gp_strdup(str); |
strcpy(text,str); |
|
|
|
if (MP_inline) |
if (MP_inline) |
MP_endline(); |
MP_endline(); |
|
|
j = 3; |
j = 3; |
break; |
break; |
} |
} |
if (MP_notex) { |
if (MP_tex == MP_NO_TEX) { |
for (i = 0; i < strlen(text); i++) |
for (i = 0; i < strlen(text); i++) |
if (text[i] == '"') |
if (text[i] == '"') |
text[i] = '\''; /* Replace " with ' */ |
text[i] = '\''; /* Replace " with ' */ |
if (MP_fontchanged) { |
if (MP_fontchanged) { |
fprintf(gpoutfile, "\ |
fprintf(gpoutfile, "\ |
put_text(\"%s\" infontsize(\"%s\",%5.2f), %da, %db, %d, %d);\n", |
put_text(\"%s\" infontsize(\"%s\",%5.2f), %.1fa, %.1fb, %d, %d);\n", |
text, MP_fontname, MP_fontsize, x, y, MP_ang, j); |
text, MP_fontname, MP_fontsize, x/10.0, y/10.0, MP_ang, j); |
} else { |
} else { |
fprintf(gpoutfile, "put_text(\"%s\", %da, %db, %d, %d);\n", |
fprintf(gpoutfile, "put_text(\"%s\", %.1fa, %.1fb, %d, %d);\n", |
text, x, y, MP_ang, j); |
text, x/10.0, y/10.0, MP_ang, j); |
} |
} |
} else if (MP_fontchanged) { |
} else if (MP_fontchanged) { |
|
if(MP_tex != MP_LATEX) { |
fprintf(gpoutfile, "\ |
fprintf(gpoutfile, "\ |
put_text( btex \\setfont{%s}{%5.2f} %s etex, %da, %db, %d, %d);\n", |
put_text( btex \\setfont{%s}{%5.2f} %s etex, %.1fa, %.1fb, %d, %d);\n", |
MP_fontname, MP_fontsize, text, x, y, MP_ang, j); |
MP_fontname, MP_fontsize, text, x/10.0, y/10.0, MP_ang, j); |
|
} else { |
|
fprintf(gpoutfile, "put_text( btex %s etex, %.1fa, %.1fb, %d, %d);\n", |
|
text, x/10.0, y/10.0, MP_ang, j); |
|
} |
} else { |
} else { |
fprintf(gpoutfile, "put_text( btex %s etex, %da, %db, %d, %d);\n", |
fprintf(gpoutfile, "put_text( btex %s etex, %.1fa, %.1fb, %d, %d);\n", |
text, x, y, MP_ang, j); |
text, x/10.0, y/10.0, MP_ang, j); |
} |
} |
|
|
free(text); |
free(text); |
Line 629 unsigned int x1, y1, wd, ht; |
|
Line 746 unsigned int x1, y1, wd, ht; |
|
MP_endline(); |
MP_endline(); |
if (sty <= 0) |
if (sty <= 0) |
fprintf(gpoutfile, "\ |
fprintf(gpoutfile, "\ |
fill (%da,%db)--(%da,%db)--(%da,%db)--(%da,%db)--cycle withcolor background;\n", |
fill (%.1fa,%.1fb)--(%.1fa,%.1fb)--(%.1fa,%.1fb)--(%.1fa,%.1fb)--cycle withcolor background;\n", |
x1, y1, x1 + wd, y1, x1 + wd, y1 + ht, x1, y1 + ht); |
x1/10.0, y1/10.0, (x1 + wd)/10.0, y1/10.0, (x1 + wd)/10.0, (y1 + |
|
ht)/10.0, x1/10.0, (y1 + ht)/10.0); |
} |
} |
|
|
#endif /* TERM_BODY */ |
#endif /* TERM_BODY */ |
|
|
" allowing essentially any TeX symbols in titles and labels.", |
" allowing essentially any TeX symbols in titles and labels.", |
"", |
"", |
" The `mp` terminal is selected with a command of the form", |
" The `mp` terminal is selected with a command of the form", |
" set term mp {color} {solid} {notex} {mag <magsize>} {\"<name>\"} {<size>}", |
" set term mp {color} {solid} {notex|tex|latex} {mag <magsize>} {\"<name>\"}", |
|
" {<size>}", |
" The option `color` causes lines to be drawn in color (on a printer or display", |
" The option `color` causes lines to be drawn in color (on a printer or display", |
" that supports it), `monochrome` (or nothing) selects black lines. The option", |
" that supports it), `monochrome` (or nothing) selects black lines. The option", |
" `solid` draws solid lines, while `dashed` (or nothing) selects lines with", |
" `solid` draws solid lines, while `dashed` (or nothing) selects lines with", |
|
|
" labels under this option. This is intended for use on old plot files or files", |
" labels under this option. This is intended for use on old plot files or files", |
" that make frequent use of common characters like `$` and `%` that require", |
" that make frequent use of common characters like `$` and `%` that require", |
" special handling in TeX.", |
" special handling in TeX.", |
|
"", |
|
"", |
|
" The option `tex` sets the terminal to output its text for TeX to process.", |
|
"", |
|
" The option `latex` sets the terminal to output its text for processing by", |
|
" LaTeX. This allows things like \\frac for fractions which LaTeX knows about", |
|
" but TeX does not. Note that you must set the environment variable TEX to the", |
|
" name of your LaTeX executable (normally latex) if you use this option. ", |
|
" Otherwise metapost will try and use TeX to process the text and it won't work.", |
"", |
"", |
" Changing font sizes in TeX has no effect on the size of mathematics, and there", |
" Changing font sizes in TeX has no effect on the size of mathematics, and there", |
" is no foolproof way to make such a change, except by globally setting a", |
" is no foolproof way to make such a change, except by globally setting a", |