[BACK]Return to gnugraph.trm CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot / term

Annotation of OpenXM_contrib/gnuplot/term/gnugraph.trm, Revision 1.1.1.2

1.1       maekawa     1: /*
1.1.1.2 ! maekawa     2:  * $Id: gnugraph.trm,v 1.8.2.1 1999/08/19 14:17:45 lhecking Exp $
1.1       maekawa     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"
1.1.1.2 ! maekawa    76:
        !            77: #if defined (HAVE_PLOTCOMPAT_H)
        !            78: # include <plotcompat.h>
        !            79: #endif
1.1       maekawa    80:
                     81: #ifdef TERM_REGISTER
                     82: register_term(unixplot)
                     83: #endif
                     84:
                     85: #ifdef TERM_PROTO
                     86: TERM_PUBLIC void UP_options __PROTO((void));
                     87: TERM_PUBLIC void UP_init __PROTO((void));
                     88: TERM_PUBLIC void UP_graphics __PROTO((void));
                     89: TERM_PUBLIC void UP_text __PROTO((void));
                     90: TERM_PUBLIC void UP_linetype __PROTO((int linetype));
                     91: TERM_PUBLIC void UP_move __PROTO((unsigned int x, unsigned int y));
                     92: TERM_PUBLIC void UP_vector __PROTO((unsigned int x, unsigned int y));
                     93: TERM_PUBLIC void UP_put_text __PROTO((unsigned int x, unsigned int y, char str[]));
                     94: TERM_PUBLIC int UP_text_angle __PROTO((int ang));
                     95: TERM_PUBLIC int UP_justify_text __PROTO((enum JUSTIFY mode));
                     96: TERM_PUBLIC void UP_reset __PROTO((void));
                     97: #define UP_XMAX 19859
                     98: #define UP_YMAX 11565
                     99: /* UP_VCHAR = ((UP_FONTSIZE*UP_YMAX)/(UP_YINCHES*72))
                    100:             = UP_FONTSIZE*UP_VFONTSC
                    101:    UP_HCHAR = ((UP_FONTSIZE/2)*UP_XMAX)/(UP_XINCHES*72))
                    102:             = UP_FONTSIZE*UP_HFONTSC
                    103: */
                    104:
                    105: #define UP_VFONTSC  53.5
                    106: #define UP_VCHAR    535                /* 10 * VFONTSC */
                    107: #define UP_HFONTSC  27.6
                    108: #define UP_HCHAR    276                /* 10 * HFONTSC */
                    109:
                    110: #define UP_VTIC (UP_YMAX/80)
                    111: #define UP_HTIC (UP_XMAX/80)
                    112: #endif /* TERM_PROTO */
                    113:
                    114: #ifndef TERM_PROTO_ONLY
                    115: #ifdef TERM_BODY
                    116:
                    117:
                    118: char up_font[MAX_ID_LEN+1] = "Courier";        /* name of font */
                    119: int up_fontsize = 10;
                    120:
                    121: /* plot2ps produces a 8.25" x 8.25" square. */
                    122: #define UP_SCREENX 32768
                    123: #define UP_SCREENY 32768
                    124: #define UP_SCRXINC 8.25
                    125: #define UP_SCRYINC 8.25
                    126:
                    127: /* We want a 5" x 3" graph by default. */
                    128: #define UP_XINCHES 5
                    129: #define UP_YINCHES 3
                    130: /* UP_XMAX = (UP_SCREENX*UP_XINCHES)/UP_SCRXINC
                    131:    UP_YMAX (UP_SCREENY*UP_YINCHES)/UP_SCRYINC */
                    132:
                    133: #define UP_XLAST (UP_XMAX - 1)
                    134: #define UP_YLAST (UP_YMAX - 1)
                    135:
                    136: /* These offsets center plot2ps output in the middle of the page.  The
                    137:  * amount of resizing that can be done is limited. */
                    138: /*
                    139:  * #define UP_XOFF 6454
                    140:  * #define UP_YOFF 10601
                    141:  */
                    142:
                    143: /* These offsets give a 1" offset from the lower left corner.  This
                    144:  * gives a greater range of permissible values in GNUPLOT's size
                    145:  * command. */
                    146: #define UP_XOFF 3972
                    147: #define UP_YOFF 3972
                    148:
                    149: enum JUSTIFY up_justify = LEFT;
                    150:
                    151: #ifdef GNU_PLOTUTILS
                    152: # define ROTATE(angle) textangle(90*angle)
                    153: #else
                    154: # define ROTATE(angle) rotate(0,0,90*angle)
                    155: #endif
                    156:
                    157: #ifdef GNU_PLOTUTILS
                    158: /* We don't include plot.h from plotutils because of
                    159:  * the name clash with ../plot.h.
                    160:  */
                    161: extern int openpl __PROTO((void));
                    162: extern int space __PROTO((int, int, int, int));
                    163: extern int fontname __PROTO((const char *));
                    164: extern int fontsize __PROTO((int));
                    165: extern int erase __PROTO((void));
                    166: extern int linemod __PROTO((const char *));
                    167: extern int move __PROTO((int, int));
                    168: extern int cont __PROTO((int, int));
                    169: extern int alabel __PROTO((int, int, const char *));
                    170: extern int textangle __PROTO((int));
                    171: extern int closepl __PROTO((void));
                    172: #endif
                    173:
                    174: TERM_PUBLIC void UP_options()
                    175: {
                    176:     if (!END_OF_COMMAND) {
                    177:        if (almost_equals(c_token, "d$efault")) {
                    178:            strcpy(up_font, "Courier");
                    179:            up_fontsize = 10;
                    180:            term->v_char = (unsigned int) (up_fontsize * UP_VFONTSC);
                    181:            term->h_char = (unsigned int) (up_fontsize * UP_HFONTSC);
                    182:            c_token++;
                    183:        }
                    184:     }
                    185:     if (!END_OF_COMMAND && isstring(c_token)) {
                    186:        quote_str(up_font, c_token, MAX_ID_LEN);
                    187:        c_token++;
                    188:     }
                    189:     if (!END_OF_COMMAND) {
                    190:        /* We have font size specified */
                    191:        struct value a;
                    192:        up_fontsize = (int) real(const_express(&a));
                    193:        term->v_char = (unsigned int) (up_fontsize * UP_VFONTSC);
                    194:        term->h_char = (unsigned int) (up_fontsize * UP_HFONTSC);
                    195:     }
                    196:     sprintf(term_options, "\"%s\" %d", up_font, up_fontsize);
                    197: }
                    198:
                    199: TERM_PUBLIC void UP_init()
                    200: {
                    201:     openpl();
                    202:     space(0, 0, UP_SCREENX - 1, UP_SCREENY - 1);
                    203:     fontname(up_font);
                    204: /*
                    205: #ifdef GNU_PLOTUTILS
                    206:        fontsize((int)((up_fontsize / 72.0 * 8.0) * (UP_SCREENY-1)));
                    207: #else
                    208: */
                    209:     fontsize(up_fontsize);
                    210: /*
                    211: #endif
                    212: */
                    213: }
                    214:
                    215:
                    216: TERM_PUBLIC void UP_graphics()
                    217: {
                    218:     erase();
                    219: }
                    220:
                    221:
                    222: TERM_PUBLIC void UP_text()
                    223: {
                    224:     /* Flush here so that output will be complete. */
                    225:     fflush(stdout);
                    226: }
                    227:
                    228:
                    229: TERM_PUBLIC void UP_linetype(linetype)
                    230: int linetype;
                    231: {
                    232:     static char *lt[2+5] = { "solid", "longdashed", "solid", "dotted",
                    233:                             "shortdashed", "dotdashed", "longdashed"};
                    234:
                    235:     if (linetype >= 5)
                    236:        linetype %= 5;
                    237:     linemod(lt[linetype + 2]);
                    238: }
                    239:
                    240:
                    241: TERM_PUBLIC void UP_move(x, y)
                    242: unsigned int x, y;
                    243: {
                    244:     move(x + UP_XOFF, y + UP_YOFF);
                    245: }
                    246:
                    247:
                    248: TERM_PUBLIC void UP_vector(x, y)
                    249: unsigned int x, y;
                    250: {
                    251:     cont(x + UP_XOFF, y + UP_YOFF);
                    252: }
                    253:
                    254:
                    255: TERM_PUBLIC void UP_put_text(x, y, str)
                    256: unsigned int x, y;
                    257: char str[];
                    258: {
                    259:     UP_move(x, y);             /* Don't adjust x and y! It's done in UP_move. */
                    260:     switch (up_justify) {
                    261:     case LEFT:
                    262:        alabel('l', 'c', str);
                    263:        break;
                    264:     case CENTRE:
                    265:        alabel('c', 'c', str);
                    266:        break;
                    267:     case RIGHT:
                    268:        alabel('r', 'c', str);
                    269:        break;
                    270:     }
                    271:
                    272: }
                    273:
                    274: TERM_PUBLIC int UP_text_angle(ang)
                    275: int ang;
                    276: {
                    277:     ROTATE(ang);
                    278:     return TRUE;
                    279: }
                    280:
                    281: TERM_PUBLIC int UP_justify_text(mode)
                    282: enum JUSTIFY mode;
                    283: {
                    284:     up_justify = mode;
                    285:     return TRUE;
                    286: }
                    287:
                    288: TERM_PUBLIC void UP_reset()
                    289: {
                    290:     closepl();
                    291: }
                    292:
                    293: #endif /* TERM_BODY */
                    294:
                    295: #ifdef TERM_TABLE
                    296:
                    297: TERM_TABLE_START(unixplot_driver)
                    298:     "unixplot", "GNU plot(1) format [\042fontname\042 font_size]",
                    299:     UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR,
                    300:     UP_VTIC, UP_HTIC, UP_options, UP_init, UP_reset,
                    301:     UP_text, null_scale, UP_graphics, UP_move, UP_vector,
                    302:     UP_linetype, UP_put_text, UP_text_angle,
                    303:     UP_justify_text, line_and_point, do_arrow, set_font_null
                    304: TERM_TABLE_END(unixplot_driver)
                    305:
                    306: #undef LAST_TERM
                    307: #define LAST_TERM unixplot_driver
                    308:
                    309: #endif /* TERM_TABLE */
                    310: #endif /* TERM_PROTO_ONLY */
                    311:
                    312: #ifdef TERM_HELP
                    313: START_HELP(unixplot)
                    314: "1 unixplot",
                    315: "?commands set terminal unixplot",
                    316: "?set terminal unixplot",
                    317: "?set term unixplot",
                    318: "?terminal unixplot",
                    319: "?term unixplot",
                    320: "?unixplot",
                    321: " The `unixplot` driver produces device-independent output in the GNU plot",
                    322: " graphics language.  The default size of the PostScript results generated by",
                    323: " \"plot2ps\" is 5 x 3 inches; this can be increased up to about 8.25 x 8.25 by",
                    324: " `set size`.",
                    325: "",
                    326: " Syntax:",
                    327: "       set terminal unixplot {\"<fontname>\"} {<fontsize>}",
                    328: "",
                    329: " which defaults to 10-point \"Courier\".",
                    330: "",
                    331: " There is a non-GNU version of the `unixplot` driver which cannot be compiled",
                    332: " unless this version is left out."
                    333: END_HELP(unixplot)
                    334: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>