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

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

1.1     ! maekawa     1: /*
        !             2:  * $Id: hpljii.trm,v 1.20 1998/04/14 00:17:51 drd Exp $
        !             3:  *
        !             4:  */
        !             5:
        !             6: /* GNUPLOT - hpljii.trm */
        !             7:
        !             8: /*[
        !             9:  * Copyright 1990 - 1993, 1998   Thomas Williams, Colin Kelley
        !            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:  *  hpljii, hpdj
        !            43:  *
        !            44:  * AUTHORS
        !            45:  *  John Engels
        !            46:  *  Russell Lang
        !            47:  *  Maurice Castro
        !            48:  *
        !            49:  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
        !            50:  *
        !            51:  */
        !            52:
        !            53: /* The following HP laserjet series II driver uses generic bit mapped graphics
        !            54:    routines from bitmap.c to build up a bit map in memory.  The driver
        !            55:    interchanges colomns and lines in order to access entire lines
        !            56:    easily and returns the lines to get bits in the right order :
        !            57:    (x,y) -> (y,XMAX-1-x). */
        !            58: /* This interchange is done by calling b_makebitmap() with reversed
        !            59:    xmax and ymax, and then setting b_rastermode to TRUE.  b_setpixel()
        !            60:    will then perform the interchange before each pixel is plotted */
        !            61: /* by John Engels JENGELS@BNANDP51.BITNET, inspired by the hpljet driver
        !            62:    of Jyrki Yli-Nokari */
        !            63:
        !            64: /*
        !            65:  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
        !            66:  */
        !            67:
        !            68: #include "driver.h"
        !            69:
        !            70: #ifdef TERM_REGISTER
        !            71: register_term(hpljii)
        !            72: register_term(hpdj)
        !            73: #endif
        !            74:
        !            75: #ifdef TERM_PROTO
        !            76: TERM_PUBLIC void HPLJIIoptions __PROTO((void));
        !            77: TERM_PUBLIC void HPLJIIinit __PROTO((void));
        !            78: TERM_PUBLIC void HPLJIIgraphics __PROTO((void));
        !            79: TERM_PUBLIC void HPLJIItext __PROTO((void));
        !            80: TERM_PUBLIC void HPLJIIlinetype __PROTO((int linetype));
        !            81: TERM_PUBLIC void HPLJIIput_text __PROTO((unsigned int x, unsigned int y, char *str));
        !            82: TERM_PUBLIC void HPLJIIreset __PROTO((void));
        !            83: #define HPLJIImove b_move
        !            84: #define HPLJIIvector b_vector
        !            85: #define HPLJIItext_angle b_text_angle
        !            86: TERM_PUBLIC void HPDJgraphics __PROTO((void));
        !            87: TERM_PUBLIC void HPDJtext __PROTO((void));
        !            88: #define HPDJtext_angle b_text_angle
        !            89: #define HPDJput_text b_put_text
        !            90: /* default values for term_tbl */
        !            91: #define HPLJII_75PPI_XMAX (1920/4)
        !            92: #define HPLJII_75PPI_YMAX (1920/4)
        !            93: #define HPLJII_75PPI_HCHAR (1920/4/6)
        !            94: #define HPLJII_75PPI_VCHAR (1920/4/10)
        !            95: #define HPLJII_75PPI_VTIC 5
        !            96: #define HPLJII_75PPI_HTIC 5
        !            97: #endif
        !            98:
        !            99: #ifndef TERM_PROTO_ONLY
        !           100: #ifdef TERM_BODY
        !           101:
        !           102: /* We define 4 different print qualities : 300ppi, 150ppi, 100ppi and
        !           103:    75ppi.  (Pixel size = 1, 2, 3, 4 dots) */
        !           104:
        !           105: #define HPLJII_DPP (hplj_dpp)  /* dots per pixel */
        !           106: #define HPLJII_PPI (300/HPLJII_DPP)    /* pixel per inch */
        !           107: /* make XMAX and YMAX a multiple of 8 */
        !           108: #define HPLJII_XMAX (8*(unsigned int)(xsize*1920/HPLJII_DPP/8.0+0.9))
        !           109: #define HPLJII_YMAX (8*(unsigned int)(ysize*1920/HPLJII_DPP/8.0+0.9))
        !           110:
        !           111: /* Courier font with 6 lines per inch */
        !           112: #define HPLJII_VCHAR (HPLJII_PPI/6)
        !           113: /* Courier font with 10 caracters per inch */
        !           114: #define HPLJII_HCHAR (HPLJII_PPI/10)
        !           115: /* Save current cursor position */
        !           116: #define HPLJII_PUSH_CURSOR fputs("\033&f0S",gpoutfile)
        !           117: /* Restore cursor position */
        !           118: #define HPLJII_POP_CURSOR fputs("\033&f1S",gpoutfile)
        !           119: /* be sure to use courier font with 6lpi and 10cpi */
        !           120: #define HPLJII_COURIER fputs("\033(0N\033(s0p10.0h12.0v0s0b3T\033&l6D",gpoutfile)
        !           121:
        !           122:
        !           123: void HPLJIIputc __PROTO((unsigned int x, unsigned int y, char c, int ang));
        !           124: static int hplj_dpp = 4;
        !           125: /* bm_pattern not appropriate for 300ppi graphics */
        !           126: #ifndef GOT_300_PATTERN
        !           127: # define GOT_300_PATTERN
        !           128: static unsigned int b_300ppi_pattern[] =
        !           129: {
        !           130:     0xffff, 0x1111, 0xffff, 0x3333,
        !           131:     0x0f0f, 0x3f3f, 0x0fff, 0x00ff, 0x33ff
        !           132: };
        !           133: #endif
        !           134:
        !           135: TERM_PUBLIC void HPLJIIoptions()
        !           136: {
        !           137:     char opt[4];
        !           138:     int parse_error = 0;
        !           139:
        !           140:     if (END_OF_COMMAND) {
        !           141:        term_options[0] = NUL;
        !           142:     } else {
        !           143:        if (token[c_token].length > 3) {
        !           144:            parse_error = 1;    /* see below */
        !           145:        } else {
        !           146:            /* almost_equals() won't accept numbers - use strcmp() instead */
        !           147:            capture(opt, c_token, c_token, 4);
        !           148:            if (!strcmp(opt, "75")) {
        !           149:                hplj_dpp = 4;
        !           150:            } else if (!strcmp(opt, "100")) {
        !           151:                hplj_dpp = 3;
        !           152:            } else if (!strcmp(opt, "150")) {
        !           153:                hplj_dpp = 2;
        !           154:            } else if (!strcmp(opt, "300")) {
        !           155:                hplj_dpp = 1;
        !           156:            } else {
        !           157:                /* error, but set dpi anyway, since term it already set */
        !           158:                parse_error = 1;
        !           159:            }
        !           160:            c_token++;
        !           161:        }
        !           162:     }
        !           163:
        !           164:     term->xmax = HPLJII_XMAX;
        !           165:     term->ymax = HPLJII_YMAX;
        !           166:     switch (hplj_dpp) {
        !           167:     case 1:
        !           168:        strcpy(term_options, "300");
        !           169:        term->v_tic = 15;
        !           170:        term->h_tic = 15;
        !           171:        break;
        !           172:     case 2:
        !           173:        strcpy(term_options, "150");
        !           174:        term->v_tic = 8;
        !           175:        term->h_tic = 8;
        !           176:        break;
        !           177:     case 3:
        !           178:        strcpy(term_options, "100");
        !           179:        term->v_tic = 6;
        !           180:        term->h_tic = 6;
        !           181:        break;
        !           182:     case 4:
        !           183:        strcpy(term_options, "75");
        !           184:        term->v_tic = 5;
        !           185:        term->h_tic = 5;
        !           186:        break;
        !           187:     }
        !           188:
        !           189:     if (parse_error)
        !           190:        int_error("expecting dots per inch size 75, 100, 150 or 300",
        !           191:                  c_token);
        !           192: }
        !           193:
        !           194:
        !           195: TERM_PUBLIC void HPLJIIinit()
        !           196: {
        !           197:     term->v_char = HPLJII_VCHAR;
        !           198:     term->h_char = HPLJII_HCHAR;
        !           199: }
        !           200:
        !           201:
        !           202: TERM_PUBLIC void HPLJIIgraphics()
        !           203: {
        !           204:     HPLJII_COURIER;
        !           205:     HPLJII_PUSH_CURSOR;
        !           206:     /* rotate plot -90 degrees by reversing XMAX and YMAX and by
        !           207:        setting b_rastermode to TRUE */
        !           208:     b_makebitmap(HPLJII_YMAX, HPLJII_XMAX, 1);
        !           209:     b_rastermode = TRUE;
        !           210: }
        !           211:
        !           212:
        !           213: /* HPLJIItext by rjl - no compression */
        !           214: TERM_PUBLIC void HPLJIItext()
        !           215: {
        !           216:     register int x, j, row;
        !           217:
        !           218:     fprintf(gpoutfile, "\033*t%dR", HPLJII_PPI);
        !           219:     HPLJII_POP_CURSOR;
        !           220:     fputs("\033*r1A", gpoutfile);
        !           221:
        !           222:     /* dump bitmap in raster mode */
        !           223:     for (x = b_xsize - 1; x >= 0; x--) {
        !           224:        row = (b_ysize / 8) - 1;
        !           225:        fprintf(gpoutfile, "\033*b0m%dW", b_ysize / 8);
        !           226:        for (j = row; j >= 0; j--) {
        !           227:            (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile);
        !           228:        }
        !           229:     }
        !           230:     fputs("\033*rB", gpoutfile);
        !           231:
        !           232:     b_freebitmap();
        !           233:
        !           234: #ifndef VMS
        !           235:     /* most vms spoolers add a formfeed character */
        !           236:     putc('\f', gpoutfile);
        !           237: #endif /* !VMS */
        !           238: }
        !           239:
        !           240:
        !           241:
        !           242: TERM_PUBLIC void HPLJIIlinetype(linetype)
        !           243: int linetype;
        !           244: {
        !           245:
        !           246:     if (hplj_dpp == 1) {
        !           247:        if (linetype >= 7)
        !           248:            linetype %= 7;
        !           249:        /* b_pattern not appropriate for 300ppi graphics */
        !           250:        b_linemask = b_300ppi_pattern[linetype + 2];
        !           251:        b_maskcount = 0;
        !           252:     } else {
        !           253:        b_setlinetype(linetype);
        !           254:     }
        !           255: }
        !           256:
        !           257: TERM_PUBLIC void HPLJIIput_text(x, y, str)
        !           258: unsigned int x, y;
        !           259: char *str;
        !           260: {
        !           261:     switch (b_angle) {
        !           262:     case 0:
        !           263:        y -= HPLJII_VCHAR / 5;
        !           264:        HPLJII_POP_CURSOR;
        !           265:        HPLJII_PUSH_CURSOR;
        !           266:        /* (0,0) is the upper left point of the paper */
        !           267:        fprintf(gpoutfile, "\033*p%+dx%+dY", x * HPLJII_DPP
        !           268:                ,(HPLJII_YMAX - y - 1) * HPLJII_DPP);
        !           269:        fputs(str, gpoutfile);
        !           270: /*       for (; *str; ++str, x += HPLJII_HCHAR)
        !           271:             HPLJIIputc (x, y, *str, b_angle);*/
        !           272:        break;
        !           273:     case 1:
        !           274:        y += (HPLJII_HCHAR - 2 * HPLJII_VCHAR) / 2;
        !           275:        y += (HPLJII_VCHAR + HPLJII_HCHAR) * strlen(str) / 2;
        !           276:        for (; *str; ++str, y -= HPLJII_VCHAR)
        !           277:            HPLJIIputc(x, y, *str, b_angle);
        !           278:        break;
        !           279:     }
        !           280: }
        !           281:
        !           282: #ifdef PROTOTYPES
        !           283: void HPLJIIputc(unsigned int x, unsigned int y, char c, int ang)
        !           284: #else
        !           285: void HPLJIIputc(x, y, c, ang)
        !           286: unsigned int x, y;
        !           287: int ang;
        !           288: char c;
        !           289: #endif
        !           290: {
        !           291:     HPLJII_POP_CURSOR;
        !           292:     HPLJII_PUSH_CURSOR;
        !           293:     /* (0,0) is the upper left point of the paper */
        !           294:     fprintf(gpoutfile, "\033*p%+dx%+dY", x * HPLJII_DPP
        !           295:            ,(HPLJII_YMAX - y - 1) * HPLJII_DPP);
        !           296:     fputc(c, gpoutfile);
        !           297: }
        !           298:
        !           299:
        !           300: TERM_PUBLIC void HPLJIIreset()
        !           301: {
        !           302: #ifdef VMS
        !           303:     fflush_binary();
        !           304: #endif /* VMS */
        !           305: }
        !           306:
        !           307:
        !           308: /* HP DeskJet routines */
        !           309: TERM_PUBLIC void HPDJgraphics()
        !           310: {
        !           311:     switch (hplj_dpp) {
        !           312:     case 1:
        !           313:        b_charsize(FNT13X25);
        !           314:        term->v_char = FNT13X25_VCHAR;
        !           315:        term->h_char = FNT13X25_HCHAR;
        !           316:        break;
        !           317:     case 2:
        !           318:        b_charsize(FNT13X25);
        !           319:        term->v_char = FNT13X25_VCHAR;
        !           320:        term->h_char = FNT13X25_HCHAR;
        !           321:        break;
        !           322:     case 3:
        !           323:        b_charsize(FNT9X17);
        !           324:        term->v_char = FNT9X17_VCHAR;
        !           325:        term->h_char = FNT9X17_HCHAR;
        !           326:        break;
        !           327:     case 4:
        !           328:        b_charsize(FNT5X9);
        !           329:        term->v_char = FNT5X9_VCHAR;
        !           330:        term->h_char = FNT5X9_HCHAR;
        !           331:        break;
        !           332:     }
        !           333:     /* rotate plot -90 degrees by reversing XMAX and YMAX and by
        !           334:        setting b_rastermode to TRUE */
        !           335:     b_makebitmap(HPLJII_YMAX, HPLJII_XMAX, 1);
        !           336:     b_rastermode = TRUE;
        !           337: }
        !           338:
        !           339:
        !           340: /* 0 compression raster bitmap dump. Compatible with HP DeskJet 500
        !           341:    hopefully compatible with other HP Deskjet printers */
        !           342: TERM_PUBLIC void HPDJtext()
        !           343: {
        !           344:     register int x, j, row;
        !           345:
        !           346:     fprintf(gpoutfile, "\
        !           347: \033*b0M\
        !           348: \033*t%dR\
        !           349: \033*r1A",
        !           350:            HPLJII_PPI);
        !           351:
        !           352:     /* dump bitmap in raster mode */
        !           353:     for (x = b_xsize - 1; x >= 0; x--) {
        !           354:        row = (b_ysize / 8) - 1;
        !           355:        fprintf(gpoutfile, "\033*b%dW", b_ysize / 8);
        !           356:        for (j = row; j >= 0; j--) {
        !           357:            (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile);
        !           358:        }
        !           359:     }
        !           360:     fputs("\033*rbC", gpoutfile);
        !           361:
        !           362:     b_freebitmap();
        !           363:
        !           364: #ifndef VMS                    /* most vms spoolers add a formfeed character */
        !           365:     putc('\f', gpoutfile);
        !           366: #endif /* !VMS */
        !           367: }
        !           368:
        !           369: #endif
        !           370:
        !           371: #ifdef TERM_TABLE
        !           372:
        !           373: TERM_TABLE_START(hpljii_driver)
        !           374:     "hpljii", "HP Laserjet series II, [75 100 150 300]",
        !           375:     HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
        !           376:     HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
        !           377:     HPLJIIinit, HPLJIIreset, HPLJIItext, null_scale,
        !           378:     HPLJIIgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
        !           379:     HPLJIIput_text, HPLJIItext_angle, null_justify_text, line_and_point,
        !           380:     do_arrow, set_font_null, 0, TERM_BINARY
        !           381: TERM_TABLE_END(hpljii_driver)
        !           382:
        !           383: #undef LAST_TERM
        !           384: #define LAST_TERM hpljii_driver
        !           385:
        !           386: TERM_TABLE_START(hpdj_driver)
        !           387:     "hpdj", "HP DeskJet 500, [75 100 150 300]",
        !           388:     HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
        !           389:     HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
        !           390:     HPLJIIinit, HPLJIIreset, HPDJtext, null_scale,
        !           391:     HPDJgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
        !           392:     HPDJput_text, HPDJtext_angle, null_justify_text, line_and_point,
        !           393:     do_arrow, set_font_null, 0, TERM_BINARY
        !           394: TERM_TABLE_END(hpdj_driver)
        !           395:
        !           396: #undef LAST_TERM
        !           397: #define LAST_TERM hpdj_driver
        !           398:
        !           399: #endif
        !           400: #endif
        !           401:
        !           402: #ifdef TERM_HELP
        !           403: START_HELP(hpljii)
        !           404: "1 hpljii",
        !           405: "?commands set terminal hpljii",
        !           406: "?set terminal hpljii",
        !           407: "?set term hpljii",
        !           408: "?terminal hpljii",
        !           409: "?term hpljii",
        !           410: "?hpljii",
        !           411: "?commands set terminal hpdj",
        !           412: "?set terminal hpdj",
        !           413: "?set term hpdj",
        !           414: "?terminal hpdj",
        !           415: "?term hpdj",
        !           416: "?hpdj",
        !           417: " The `hpljii` terminal driver supports the HP Laserjet Series II printer.  The",
        !           418: " `hpdj` driver supports the HP DeskJet 500 printer.  These drivers allow a",
        !           419: " choice of resolutions.",
        !           420: "",
        !           421: " Syntax:",
        !           422: "       set terminal hpljii | hpdj {<res>}",
        !           423: "",
        !           424: " where `res` may be 75, 100, 150 or 300 dots per inch; the default is 75.",
        !           425: " Rasterization at the higher resolutions may require a large amount of memory.",
        !           426: "",
        !           427: " The `hp500c` terminal is similar to `hpdj`; `hp500c` additionally supports",
        !           428: " color and compression."
        !           429: END_HELP(hpljii)
        !           430: #endif /* TERM_HELP */

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