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

Annotation of OpenXM_contrib/gnuplot/term/eepic.trm, Revision 1.1

1.1     ! maekawa     1: /*
        !             2:  * $Id: eepic.trm,v 1.18 1998/04/14 00:17:39 drd Exp $
        !             3:  *
        !             4:  */
        !             5:
        !             6: /* GNUPLOT - eepic.trm */
        !             7:
        !             8: /*[
        !             9:  * Copyright 1990 - 1993, 1998
        !            10:  *
        !            11:  * Permission to use, copy, and distribute this software and its
        !            12:  * documentation for any purpose with or without fee is hereby granted,
        !            13:  * provided that the above copyright notice appear in all copies and
        !            14:  * that both that copyright notice and this permission notice appear
        !            15:  * in supporting documentation.
        !            16:  *
        !            17:  * Permission to modify the software is granted, but not the right to
        !            18:  * distribute the complete modified source code.  Modifications are to
        !            19:  * be distributed as patches to the released version.  Permission to
        !            20:  * distribute binaries produced by compiling modified sources is granted,
        !            21:  * provided you
        !            22:  *   1. distribute the corresponding source modifications from the
        !            23:  *    released version in the form of a patch file along with the binaries,
        !            24:  *   2. add special version identification to distinguish your version
        !            25:  *    in addition to the base release version number,
        !            26:  *   3. provide your name and address as the primary contact for the
        !            27:  *    support of your modified version, and
        !            28:  *   4. retain our contact information in regard to use of the base
        !            29:  *    software.
        !            30:  * Permission to distribute the released version of the source code along
        !            31:  * with corresponding source modifications in the form of a patch file is
        !            32:  * granted with same provisions 2 through 4 for binary distributions.
        !            33:  *
        !            34:  * This software is provided "as is" without express or implied warranty
        !            35:  * to the extent permitted by applicable law.
        !            36: ]*/
        !            37:
        !            38: /*
        !            39:  * This file is included by ../term.c.
        !            40:  *
        !            41:  * This terminal driver supports:
        !            42:  *   The EEPIC macros for LaTeX.
        !            43:  *
        !            44:  * AUTHORS
        !            45:  *   David Kotz
        !            46:  *
        !            47:  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
        !            48:  *
        !            49:  */
        !            50: /*
        !            51:  *  This file contains the eepic terminal driver, intended for use with the
        !            52:  *  eepic.sty macro package for LaTeX. This is an alternative to the
        !            53:  *  latex driver. You need eepic.sty, epic.sty, and a printer driver that
        !            54:  *  supports the tpic \specials.
        !            55:  *
        !            56:  * Although dotted and dashed lines are possible with EEPIC, and are
        !            57:  * tempting, they do not work well for high-sample-rate curves, mushing
        !            58:  * the dashes all together into a solid line. For now anyway, the EEPIC
        !            59:  * driver will have only solid lines. Anyone got a solution?
        !            60:  *
        !            61:  * LATEX must also be defined.
        !            62:  */
        !            63: /*
        !            64:  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
        !            65:  */
        !            66:
        !            67: #include "driver.h"
        !            68:
        !            69: #ifdef TERM_REGISTER
        !            70: register_term(eepic)
        !            71: #endif
        !            72:
        !            73: #ifdef TERM_PROTO
        !            74: TERM_PUBLIC void EEPIC_init __PROTO((void));
        !            75: TERM_PUBLIC void EEPIC_graphics __PROTO((void));
        !            76: TERM_PUBLIC void EEPIC_text __PROTO((void));
        !            77: TERM_PUBLIC void EEPIC_linetype __PROTO((int linetype));
        !            78: TERM_PUBLIC void EEPIC_move __PROTO((unsigned int x, unsigned int y));
        !            79: TERM_PUBLIC void EEPIC_point __PROTO((unsigned int x, unsigned int y,
        !            80:                                      int number));
        !            81: TERM_PUBLIC void EEPIC_vector __PROTO((unsigned int ux, unsigned int uy));
        !            82: TERM_PUBLIC void EEPIC_arrow __PROTO((unsigned int sx, unsigned int sy,
        !            83:                                      unsigned int ex, unsigned int ey,
        !            84:                                      TBOOLEAN head));
        !            85: TERM_PUBLIC void EEPIC_put_text __PROTO((unsigned int x, unsigned int y,
        !            86:                                         char str[]));
        !            87: TERM_PUBLIC int EEPIC_justify_text __PROTO((enum JUSTIFY mode));
        !            88: TERM_PUBLIC int EEPIC_text_angle __PROTO((int ang));
        !            89: TERM_PUBLIC void EEPIC_reset __PROTO((void));
        !            90:
        !            91: #define EEPIC_PTS_PER_INCH (72.27)
        !            92: /* resolution of printer we expect to use */
        !            93: #define DOTS_PER_INCH (300)
        !            94: /* dot size in pt */
        !            95: #define EEPIC_UNIT (EEPIC_PTS_PER_INCH/DOTS_PER_INCH)
        !            96:
        !            97: /* 5 inches wide by 3 inches high (default) */
        !            98: /* (EEPIC_PTS_PER_INCH/EEPIC_UNIT*5.0) */
        !            99: #define EEPIC_XMAX (5*DOTS_PER_INCH)
        !           100: /* (EEPIC_PTS_PER_INCH/EEPIC_UNIT*3.0) */
        !           101: #define EEPIC_YMAX (3*DOTS_PER_INCH)
        !           102:
        !           103: #define EEPIC_HTIC (5*DOTS_PER_INCH/72)                /* (5./EEPIC_UNIT) */
        !           104: #define EEPIC_VTIC (5*DOTS_PER_INCH/72)                /* (5./EEPIC_UNIT) */
        !           105: #define EEPIC_HCHAR (DOTS_PER_INCH*53/10/72)   /* (5.3/EEPIC_UNIT) */
        !           106: #define EEPIC_VCHAR (DOTS_PER_INCH*11/72)      /* (11./EEPIC_UNIT) */
        !           107: #endif /* TERM_PROTO */
        !           108:
        !           109: #ifndef TERM_PROTO_ONLY
        !           110: #ifdef TERM_BODY
        !           111:
        !           112: static unsigned int EEPIC_posx;
        !           113: static unsigned int EEPIC_posy;
        !           114: enum JUSTIFY eepic_justify = LEFT;
        !           115: static int eepic_angle = 0;
        !           116:
        !           117: /* for DOTS point style */
        !           118: #define EEPIC_TINY_DOT "\\rule{.1pt}{.1pt}"
        !           119:
        !           120: /* POINTS */
        !           121: #define EEPIC_POINT_TYPES 12   /* we supply more point types */
        !           122: static char GPFAR *GPFAR EEPIC_points[] =
        !           123: {
        !           124:     "\\raisebox{-1.2pt}{\\makebox(0,0){$\\Diamond$}}",
        !           125:     "\\makebox(0,0){$+$}",
        !           126:     "\\raisebox{-1.2pt}{\\makebox(0,0){$\\Box$}}",
        !           127:     "\\makebox(0,0){$\\times$}",
        !           128:     "\\makebox(0,0){$\\triangle$}",
        !           129:     "\\makebox(0,0){$\\star$}",
        !           130:     "\\circle{12}", "\\circle{18}", "\\circle{24}",
        !           131:     "\\circle*{12}", "\\circle*{18}", "\\circle*{24}"
        !           132: };
        !           133:
        !           134: /* LINES */
        !           135: #define EEPIC_NUMLINES 5       /* number of linetypes below */
        !           136: static char GPFAR *GPFAR EEPIC_lines[] =
        !           137: {
        !           138:     "\\thicklines \\path",     /* -2 border */
        !           139:     "\\thinlines \\drawline[-50]",     /* -1 axes */
        !           140:     "\\thinlines \\path",      /*  0 solid thin  */
        !           141:     "\\thicklines \\path",     /*  1 solid thick */
        !           142:     "\\Thicklines \\path",     /*  2 solid Thick */
        !           143: };
        !           144: /* These are other possibilities
        !           145:     "\\thinlines \\dottedline{30}",
        !           146:     "\\thinlines \\drawline[-30]",
        !           147:     "\\thinlines \\dottedline{60}",
        !           148:     "\\thinlines \\drawline[-60]",
        !           149:     "\\thinlines \\dashline[-10]{20}[6]"
        !           150: */
        !           151: static int EEPIC_type;         /* current line type */
        !           152: static TBOOLEAN EEPIC_inline = FALSE;  /* are we in the middle of a line */
        !           153: void EEPIC_endline __PROTO((void));    /* terminate any line in progress */
        !           154: static int EEPIC_linecount = 0;        /* number of points in line so far */
        !           155: #define EEPIC_LINEMAX 50       /* max value for linecount */
        !           156:
        !           157: /* ARROWS */
        !           158: /* we use the same code as for LATEX */
        !           159: /* figure out the best arrow */
        !           160: void best_latex_arrow __PROTO((int sx, int sy, int ex, int ey, int who,
        !           161:                               TBOOLEAN head));
        !           162:
        !           163: TERM_PUBLIC void EEPIC_init()
        !           164: {
        !           165:     EEPIC_posx = EEPIC_posy = 0;
        !           166:     EEPIC_linetype(-1);
        !           167:     fprintf(gpoutfile, "%% GNUPLOT: LaTeX picture using EEPIC macros\n\
        !           168: \\setlength{\\unitlength}{%fpt}\n", EEPIC_UNIT);
        !           169: }
        !           170:
        !           171:
        !           172: TERM_PUBLIC void EEPIC_graphics()
        !           173: {
        !           174:     register struct termentry *t = term;
        !           175:
        !           176:     fprintf(gpoutfile, "\\begin{picture}(%d,%d)(0,0)\n\
        !           177: \\footnotesize\n", t->xmax, t->ymax);
        !           178:
        !           179: }
        !           180:
        !           181:
        !           182: TERM_PUBLIC void EEPIC_text()
        !           183: {
        !           184:     EEPIC_endline();
        !           185:     fputs("\\end{picture}\n", gpoutfile);
        !           186: }
        !           187:
        !           188:
        !           189: TERM_PUBLIC void EEPIC_linetype(linetype)
        !           190: int linetype;
        !           191: {
        !           192:     EEPIC_endline();
        !           193:
        !           194:     if (linetype >= EEPIC_NUMLINES - 2)
        !           195:        linetype %= (EEPIC_NUMLINES - 2);
        !           196:
        !           197:     EEPIC_type = linetype;
        !           198: }
        !           199:
        !           200:
        !           201:
        !           202: TERM_PUBLIC void EEPIC_move(x, y)
        !           203: unsigned int x, y;
        !           204: {
        !           205:     EEPIC_endline();
        !           206:
        !           207:     EEPIC_posx = x;
        !           208:     EEPIC_posy = y;
        !           209: }
        !           210:
        !           211:
        !           212: TERM_PUBLIC void EEPIC_point(x, y, number) /* version of line_and_point */
        !           213: unsigned int x, y;
        !           214: int number;                    /* type of point */
        !           215: {
        !           216:     EEPIC_move(x, y);
        !           217:
        !           218:     /* Print the character defined by 'number'; number < 0 means
        !           219:        to use a dot, otherwise one of the defined points. */
        !           220:     fprintf(gpoutfile, "\\put(%d,%d){%s}\n", x, y,
        !           221:            (number < 0 ? EEPIC_TINY_DOT
        !           222:             : EEPIC_points[number % EEPIC_POINT_TYPES]));
        !           223: }
        !           224:
        !           225:
        !           226: TERM_PUBLIC void EEPIC_vector(ux, uy)
        !           227: unsigned int ux, uy;
        !           228: {
        !           229:     if (!EEPIC_inline) {
        !           230:        EEPIC_inline = TRUE;
        !           231:
        !           232:        /* Start a new line. This depends on line type */
        !           233:        fprintf(gpoutfile, "%s(%u,%u)",
        !           234:                EEPIC_lines[EEPIC_type + 2],
        !           235:                EEPIC_posx, EEPIC_posy);
        !           236:        EEPIC_linecount = 1;
        !           237:     } else {
        !           238:        /* Even though we are in middle of a path,
        !           239:         * we may want to start a new path command.
        !           240:         * If they are too long then latex will choke.
        !           241:         */
        !           242:        if (EEPIC_linecount++ >= EEPIC_LINEMAX) {
        !           243:            fprintf(gpoutfile, "\n%s(%u,%u)",
        !           244:                    EEPIC_lines[EEPIC_type + 2],
        !           245:                    EEPIC_posx, EEPIC_posy);
        !           246:            EEPIC_linecount = 1;
        !           247:        }
        !           248:     }
        !           249:     fprintf(gpoutfile, "(%u,%u)", ux, uy);
        !           250:     EEPIC_posx = ux;
        !           251:     EEPIC_posy = uy;
        !           252: }
        !           253:
        !           254: void EEPIC_endline()
        !           255: {
        !           256:     if (EEPIC_inline) {
        !           257:        putc('\n', gpoutfile);
        !           258:        EEPIC_inline = FALSE;
        !           259:     }
        !           260: }
        !           261:
        !           262:
        !           263: TERM_PUBLIC void EEPIC_arrow(sx, sy, ex, ey, head)
        !           264: unsigned int sx, sy, ex, ey;
        !           265: TBOOLEAN head;
        !           266: {
        !           267:     best_latex_arrow(sx, sy, ex, ey, 2, head); /* call latex routine */
        !           268:
        !           269:     EEPIC_posx = ex;
        !           270:     EEPIC_posy = ey;
        !           271: }
        !           272:
        !           273:
        !           274: TERM_PUBLIC void EEPIC_put_text(x, y, str)
        !           275: unsigned int x, y;             /* reference point of string */
        !           276: char str[];                    /* the text */
        !           277: {
        !           278:     EEPIC_endline();
        !           279:
        !           280:     fprintf(gpoutfile, "\\put(%d,%d)", x, y);
        !           281:     if ((str[0] == '{') || (str[0] == '[')) {
        !           282:        fprintf(gpoutfile, "{\\makebox(0,0)%s}\n", str);
        !           283:     } else
        !           284:        switch (eepic_angle) {
        !           285:        case 0:{
        !           286:                switch (eepic_justify) {
        !           287:                case LEFT:{
        !           288:                        fprintf(gpoutfile,
        !           289:                                "{\\makebox(0,0)[l]{%s}}\n", str);
        !           290:                        break;
        !           291:                    }
        !           292:                case CENTRE:{
        !           293:                        fprintf(gpoutfile,
        !           294:                                "{\\makebox(0,0){%s}}\n", str);
        !           295:                        break;
        !           296:                    }
        !           297:                case RIGHT:{
        !           298:                        fprintf(gpoutfile,
        !           299:                                "{\\makebox(0,0)[r]{%s}}\n", str);
        !           300:                        break;
        !           301:                    }
        !           302:                }
        !           303:                break;
        !           304:            }
        !           305:        case 1:{                /* put text in a short stack */
        !           306:                switch (eepic_justify) {
        !           307:                case LEFT:{
        !           308:                        fprintf(gpoutfile,
        !           309:                                "{\\makebox(0,0)[lb]{\\shortstack{%s}}}\n", str);
        !           310:                        break;
        !           311:                    }
        !           312:                case CENTRE:{
        !           313:                        fprintf(gpoutfile,
        !           314:                                "{\\makebox(0,0)[l]{\\shortstack{%s}}}\n", str);
        !           315:                        break;
        !           316:                    }
        !           317:                case RIGHT:{
        !           318:                        fprintf(gpoutfile,
        !           319:                                "{\\makebox(0,0)[lt]{\\shortstack{%s}}}\n", str);
        !           320:                        break;
        !           321:                    }
        !           322:                }
        !           323:                break;
        !           324:            }
        !           325:        }
        !           326: }
        !           327:
        !           328:
        !           329:
        !           330: TERM_PUBLIC int EEPIC_justify_text(mode)
        !           331: enum JUSTIFY mode;
        !           332: {
        !           333:     eepic_justify = mode;
        !           334:     return (TRUE);
        !           335: }
        !           336:
        !           337: TERM_PUBLIC int EEPIC_text_angle(ang)
        !           338: int ang;
        !           339: {
        !           340:     /* we can't really write text vertically, but this will
        !           341:        put the ylabel centred at the left of the plot, and
        !           342:        then we'll make a \shortstack */
        !           343:     eepic_angle = ang;
        !           344:     return (TRUE);
        !           345: }
        !           346:
        !           347: TERM_PUBLIC void EEPIC_reset()
        !           348: {
        !           349:     EEPIC_endline();
        !           350:     EEPIC_posx = EEPIC_posy = 0;
        !           351: }
        !           352:
        !           353: #endif
        !           354:
        !           355: #ifdef TERM_TABLE
        !           356:
        !           357: TERM_TABLE_START(eepic_driver)
        !           358:     "eepic", "EEPIC -- extended LaTeX picture environment",
        !           359:     EEPIC_XMAX, EEPIC_YMAX, EEPIC_VCHAR, EEPIC_HCHAR,
        !           360:     EEPIC_VTIC, EEPIC_HTIC, options_null, EEPIC_init, EEPIC_reset,
        !           361:     EEPIC_text, null_scale, EEPIC_graphics, EEPIC_move, EEPIC_vector,
        !           362:     EEPIC_linetype, EEPIC_put_text, EEPIC_text_angle,
        !           363:     EEPIC_justify_text, EEPIC_point, EEPIC_arrow, set_font_null
        !           364: TERM_TABLE_END(eepic_driver)
        !           365:
        !           366: #undef LAST_TERM
        !           367: #define LAST_TERM eepic_driver
        !           368:
        !           369: #endif
        !           370: #endif
        !           371:
        !           372: #ifdef TERM_HELP
        !           373: START_HELP(eepic)
        !           374: "1 eepic",
        !           375: "?commands set terminal eepic",
        !           376: "?set terminal eepic",
        !           377: "?set term eepic",
        !           378: "?terminal eepic",
        !           379: "?term eepic",
        !           380: "?eepic",
        !           381: " The `eepic` terminal driver supports the extended LaTeX picture environment.",
        !           382: " It is an alternative to the `latex` driver.",
        !           383: "",
        !           384: " The output of this terminal is intended for use with the \"eepic.sty\" macro",
        !           385: " package for LaTeX.  To use it, you need \"eepic.sty\", \"epic.sty\" and a",
        !           386: " printer driver that supports the \"tpic\" \\specials.  If your printer driver",
        !           387: " doesn't support those \\specials, \"eepicemu.sty\" will enable you to use some",
        !           388: " of them.",
        !           389: "",
        !           390: " Although dotted and dashed lines are possible with `eepic` and are tempting,",
        !           391: " they do not work well for high-sample-rate curves, fusing the dashes all",
        !           392: " together into a solid line.  For now, the `eepic` driver creates only solid",
        !           393: " lines.  There is another gnuplot driver (`tpic`) that supports dashed lines,",
        !           394: " but it cannot be used if your DVI driver doesn't support \"tpic\" \\specials.",
        !           395: "",
        !           396: " All drivers for LaTeX offer a special way of controlling text positioning:",
        !           397: " If any text string begins with '{', you also need to include a '}' at the",
        !           398: " end of the text, and the whole text will be centered both horizontally",
        !           399: " and vertically by LaTeX. --- If the text string begins with '[', you need",
        !           400: " to continue it with: a position specification (up to two out of t,b,l,r),",
        !           401: " ']{', the text itself, and finally, '}'. The text itself may be anything",
        !           402: " LaTeX can typeset as an LR-box. \\rule{}{}'s may help for best positioning.",
        !           403: "",
        !           404: " The `eepic` terminal has no options.",
        !           405: "",
        !           406: " Examples:",
        !           407: " About label positioning:",
        !           408: " Use gnuplot defaults (mostly sensible, but sometimes not really best):",
        !           409: "        set title '\\LaTeX\\ -- $ \\gamma $'",
        !           410: " Force centering both horizontally and vertically:",
        !           411: "        set label '{\\LaTeX\\ -- $ \\gamma $}' at 0,0",
        !           412: " Specify own positioning (top here):",
        !           413: "        set xlabel '[t]{\\LaTeX\\ -- $ \\gamma $}'",
        !           414: " The other label -- account for long ticlabels:",
        !           415: "        set ylabel '[r]{\\LaTeX\\ -- $ \\gamma $\\rule{7mm}{0pt}'"
        !           416: END_HELP(eepic)
        !           417: #endif /* TERM_HELP */

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