Annotation of OpenXM_contrib/gnuplot/term/gnugraph.trm, Revision 1.1
1.1 ! maekawa 1: /*
! 2: * $Id: $
! 3: */
! 4:
! 5: /* GNUPLOT -- gnugraph.trm */
! 6:
! 7: /*[
! 8: * Copyright 1993, 1998
! 9: *
! 10: * Permission to use, copy, and distribute this software and its
! 11: * documentation for any purpose with or without fee is hereby granted,
! 12: * provided that the above copyright notice appear in all copies and
! 13: * that both that copyright notice and this permission notice appear
! 14: * in supporting documentation.
! 15: *
! 16: * Permission to modify the software is granted, but not the right to
! 17: * distribute the complete modified source code. Modifications are to
! 18: * be distributed as patches to the released version. Permission to
! 19: * distribute binaries produced by compiling modified sources is granted,
! 20: * provided you
! 21: * 1. distribute the corresponding source modifications from the
! 22: * released version in the form of a patch file along with the binaries,
! 23: * 2. add special version identification to distinguish your version
! 24: * in addition to the base release version number,
! 25: * 3. provide your name and address as the primary contact for the
! 26: * support of your modified version, and
! 27: * 4. retain our contact information in regard to use of the base
! 28: * software.
! 29: * Permission to distribute the released version of the source code along
! 30: * with corresponding source modifications in the form of a patch file is
! 31: * granted with same provisions 2 through 4 for binary distributions.
! 32: *
! 33: * This software is provided "as is" without express or implied warranty
! 34: * to the extent permitted by applicable law.
! 35: ]*/
! 36:
! 37: /*
! 38: * This file is included by ../term.c.
! 39: *
! 40: * This terminal driver supports:
! 41: * GNU plot(5) graphics language
! 42: *
! 43: * AUTHORS
! 44: * Tony Richardson from the unixplot.trm by Colin Kelley, Thomas Williams,
! 45: * and Russell Lang and from post.trm by Russell Lang.
! 46: *
! 47: * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
! 48: */
! 49:
! 50: /*
! 51: * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
! 52: */
! 53:
! 54: /*
! 55: * This version of the 'unixplot' driver produces device independent
! 56: * output. I've chosen parameter values so that the PostScript output
! 57: * produced by plot2ps is 5" x 3". You can use the 'set size' command
! 58: * to get output up to 8.25" x 8.25", i.e. size values larger than
! 59: * 1 are okay.
! 60: */
! 61:
! 62: /*
! 63: Unixplot library writes to stdout. A fix was put in place by
! 64: ..!arizona!naucse!jdc to let set term and set output redirect
! 65: stdout. All other terminals write to gpoutfile.
! 66: */
! 67:
! 68: /* This is a device independent format, so the output should look
! 69: * look "reasonable" on any output device. I set things up there so
! 70: * that the output of plot2ps is 5" x 3" (standard GNUPLOT size).
! 71: * You can use GNUPLOT's size command to obtain plots to almost the
! 72: * 8.25" x 8.25" limit.
! 73: */
! 74:
! 75: #include "driver.h"
! 76:
! 77: #ifdef TERM_REGISTER
! 78: register_term(unixplot)
! 79: #endif
! 80:
! 81: #ifdef TERM_PROTO
! 82: TERM_PUBLIC void UP_options __PROTO((void));
! 83: TERM_PUBLIC void UP_init __PROTO((void));
! 84: TERM_PUBLIC void UP_graphics __PROTO((void));
! 85: TERM_PUBLIC void UP_text __PROTO((void));
! 86: TERM_PUBLIC void UP_linetype __PROTO((int linetype));
! 87: TERM_PUBLIC void UP_move __PROTO((unsigned int x, unsigned int y));
! 88: TERM_PUBLIC void UP_vector __PROTO((unsigned int x, unsigned int y));
! 89: TERM_PUBLIC void UP_put_text __PROTO((unsigned int x, unsigned int y, char str[]));
! 90: TERM_PUBLIC int UP_text_angle __PROTO((int ang));
! 91: TERM_PUBLIC int UP_justify_text __PROTO((enum JUSTIFY mode));
! 92: TERM_PUBLIC void UP_reset __PROTO((void));
! 93: #define UP_XMAX 19859
! 94: #define UP_YMAX 11565
! 95: /* UP_VCHAR = ((UP_FONTSIZE*UP_YMAX)/(UP_YINCHES*72))
! 96: = UP_FONTSIZE*UP_VFONTSC
! 97: UP_HCHAR = ((UP_FONTSIZE/2)*UP_XMAX)/(UP_XINCHES*72))
! 98: = UP_FONTSIZE*UP_HFONTSC
! 99: */
! 100:
! 101: #define UP_VFONTSC 53.5
! 102: #define UP_VCHAR 535 /* 10 * VFONTSC */
! 103: #define UP_HFONTSC 27.6
! 104: #define UP_HCHAR 276 /* 10 * HFONTSC */
! 105:
! 106: #define UP_VTIC (UP_YMAX/80)
! 107: #define UP_HTIC (UP_XMAX/80)
! 108: #endif /* TERM_PROTO */
! 109:
! 110: #ifndef TERM_PROTO_ONLY
! 111: #ifdef TERM_BODY
! 112:
! 113:
! 114: char up_font[MAX_ID_LEN+1] = "Courier"; /* name of font */
! 115: int up_fontsize = 10;
! 116:
! 117: /* plot2ps produces a 8.25" x 8.25" square. */
! 118: #define UP_SCREENX 32768
! 119: #define UP_SCREENY 32768
! 120: #define UP_SCRXINC 8.25
! 121: #define UP_SCRYINC 8.25
! 122:
! 123: /* We want a 5" x 3" graph by default. */
! 124: #define UP_XINCHES 5
! 125: #define UP_YINCHES 3
! 126: /* UP_XMAX = (UP_SCREENX*UP_XINCHES)/UP_SCRXINC
! 127: UP_YMAX (UP_SCREENY*UP_YINCHES)/UP_SCRYINC */
! 128:
! 129: #define UP_XLAST (UP_XMAX - 1)
! 130: #define UP_YLAST (UP_YMAX - 1)
! 131:
! 132: /* These offsets center plot2ps output in the middle of the page. The
! 133: * amount of resizing that can be done is limited. */
! 134: /*
! 135: * #define UP_XOFF 6454
! 136: * #define UP_YOFF 10601
! 137: */
! 138:
! 139: /* These offsets give a 1" offset from the lower left corner. This
! 140: * gives a greater range of permissible values in GNUPLOT's size
! 141: * command. */
! 142: #define UP_XOFF 3972
! 143: #define UP_YOFF 3972
! 144:
! 145: enum JUSTIFY up_justify = LEFT;
! 146:
! 147: #ifdef GNU_PLOTUTILS
! 148: # define ROTATE(angle) textangle(90*angle)
! 149: #else
! 150: # define ROTATE(angle) rotate(0,0,90*angle)
! 151: #endif
! 152:
! 153: #ifdef GNU_PLOTUTILS
! 154: /* We don't include plot.h from plotutils because of
! 155: * the name clash with ../plot.h.
! 156: */
! 157: extern int openpl __PROTO((void));
! 158: extern int space __PROTO((int, int, int, int));
! 159: extern int fontname __PROTO((const char *));
! 160: extern int fontsize __PROTO((int));
! 161: extern int erase __PROTO((void));
! 162: extern int linemod __PROTO((const char *));
! 163: extern int move __PROTO((int, int));
! 164: extern int cont __PROTO((int, int));
! 165: extern int alabel __PROTO((int, int, const char *));
! 166: extern int textangle __PROTO((int));
! 167: extern int closepl __PROTO((void));
! 168: #endif
! 169:
! 170: TERM_PUBLIC void UP_options()
! 171: {
! 172: if (!END_OF_COMMAND) {
! 173: if (almost_equals(c_token, "d$efault")) {
! 174: strcpy(up_font, "Courier");
! 175: up_fontsize = 10;
! 176: term->v_char = (unsigned int) (up_fontsize * UP_VFONTSC);
! 177: term->h_char = (unsigned int) (up_fontsize * UP_HFONTSC);
! 178: c_token++;
! 179: }
! 180: }
! 181: if (!END_OF_COMMAND && isstring(c_token)) {
! 182: quote_str(up_font, c_token, MAX_ID_LEN);
! 183: c_token++;
! 184: }
! 185: if (!END_OF_COMMAND) {
! 186: /* We have font size specified */
! 187: struct value a;
! 188: up_fontsize = (int) real(const_express(&a));
! 189: term->v_char = (unsigned int) (up_fontsize * UP_VFONTSC);
! 190: term->h_char = (unsigned int) (up_fontsize * UP_HFONTSC);
! 191: }
! 192: sprintf(term_options, "\"%s\" %d", up_font, up_fontsize);
! 193: }
! 194:
! 195: TERM_PUBLIC void UP_init()
! 196: {
! 197: openpl();
! 198: space(0, 0, UP_SCREENX - 1, UP_SCREENY - 1);
! 199: fontname(up_font);
! 200: /*
! 201: #ifdef GNU_PLOTUTILS
! 202: fontsize((int)((up_fontsize / 72.0 * 8.0) * (UP_SCREENY-1)));
! 203: #else
! 204: */
! 205: fontsize(up_fontsize);
! 206: /*
! 207: #endif
! 208: */
! 209: }
! 210:
! 211:
! 212: TERM_PUBLIC void UP_graphics()
! 213: {
! 214: erase();
! 215: }
! 216:
! 217:
! 218: TERM_PUBLIC void UP_text()
! 219: {
! 220: /* Flush here so that output will be complete. */
! 221: fflush(stdout);
! 222: }
! 223:
! 224:
! 225: TERM_PUBLIC void UP_linetype(linetype)
! 226: int linetype;
! 227: {
! 228: static char *lt[2+5] = { "solid", "longdashed", "solid", "dotted",
! 229: "shortdashed", "dotdashed", "longdashed"};
! 230:
! 231: if (linetype >= 5)
! 232: linetype %= 5;
! 233: linemod(lt[linetype + 2]);
! 234: }
! 235:
! 236:
! 237: TERM_PUBLIC void UP_move(x, y)
! 238: unsigned int x, y;
! 239: {
! 240: move(x + UP_XOFF, y + UP_YOFF);
! 241: }
! 242:
! 243:
! 244: TERM_PUBLIC void UP_vector(x, y)
! 245: unsigned int x, y;
! 246: {
! 247: cont(x + UP_XOFF, y + UP_YOFF);
! 248: }
! 249:
! 250:
! 251: TERM_PUBLIC void UP_put_text(x, y, str)
! 252: unsigned int x, y;
! 253: char str[];
! 254: {
! 255: UP_move(x, y); /* Don't adjust x and y! It's done in UP_move. */
! 256: switch (up_justify) {
! 257: case LEFT:
! 258: alabel('l', 'c', str);
! 259: break;
! 260: case CENTRE:
! 261: alabel('c', 'c', str);
! 262: break;
! 263: case RIGHT:
! 264: alabel('r', 'c', str);
! 265: break;
! 266: }
! 267:
! 268: }
! 269:
! 270: TERM_PUBLIC int UP_text_angle(ang)
! 271: int ang;
! 272: {
! 273: ROTATE(ang);
! 274: return TRUE;
! 275: }
! 276:
! 277: TERM_PUBLIC int UP_justify_text(mode)
! 278: enum JUSTIFY mode;
! 279: {
! 280: up_justify = mode;
! 281: return TRUE;
! 282: }
! 283:
! 284: TERM_PUBLIC void UP_reset()
! 285: {
! 286: closepl();
! 287: }
! 288:
! 289: #endif /* TERM_BODY */
! 290:
! 291: #ifdef TERM_TABLE
! 292:
! 293: TERM_TABLE_START(unixplot_driver)
! 294: "unixplot", "GNU plot(1) format [\042fontname\042 font_size]",
! 295: UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR,
! 296: UP_VTIC, UP_HTIC, UP_options, UP_init, UP_reset,
! 297: UP_text, null_scale, UP_graphics, UP_move, UP_vector,
! 298: UP_linetype, UP_put_text, UP_text_angle,
! 299: UP_justify_text, line_and_point, do_arrow, set_font_null
! 300: TERM_TABLE_END(unixplot_driver)
! 301:
! 302: #undef LAST_TERM
! 303: #define LAST_TERM unixplot_driver
! 304:
! 305: #endif /* TERM_TABLE */
! 306: #endif /* TERM_PROTO_ONLY */
! 307:
! 308: #ifdef TERM_HELP
! 309: START_HELP(unixplot)
! 310: "1 unixplot",
! 311: "?commands set terminal unixplot",
! 312: "?set terminal unixplot",
! 313: "?set term unixplot",
! 314: "?terminal unixplot",
! 315: "?term unixplot",
! 316: "?unixplot",
! 317: " The `unixplot` driver produces device-independent output in the GNU plot",
! 318: " graphics language. The default size of the PostScript results generated by",
! 319: " \"plot2ps\" is 5 x 3 inches; this can be increased up to about 8.25 x 8.25 by",
! 320: " `set size`.",
! 321: "",
! 322: " Syntax:",
! 323: " set terminal unixplot {\"<fontname>\"} {<fontsize>}",
! 324: "",
! 325: " which defaults to 10-point \"Courier\".",
! 326: "",
! 327: " There is a non-GNU version of the `unixplot` driver which cannot be compiled",
! 328: " unless this version is left out."
! 329: END_HELP(unixplot)
! 330: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>