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

Annotation of OpenXM_contrib/gnuplot/term/hp26.trm, Revision 1.1.1.1

1.1       maekawa     1: /*
                      2:  * $Id: hp26.trm,v 1.14 1998/04/14 00:17:47 drd Exp $
                      3:  */
                      4:
                      5: /* GNUPLOT - HP26.trm */
                      6:
                      7: /*[
                      8:  * Copyright 1990 - 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:  *  HP2623A
                     42:  *
                     43:  * AUTHORS
                     44:  *   luecken@udel.edu (Bruce Lueckenhoff)
                     45:  *   hplvlch!ch (Chuck Heller)
                     46:  *
                     47:  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
                     48:  *
                     49:  */
                     50:
                     51: /*
                     52:  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
                     53:  */
                     54:
                     55: #include "driver.h"
                     56:
                     57: #ifdef TERM_REGISTER
                     58: register_term(hp2623a)
                     59: #endif
                     60:
                     61: #ifdef TERM_PROTO
                     62: TERM_PUBLIC void HP26_vector __PROTO((unsigned int x, unsigned int y));
                     63: TERM_PUBLIC void HP26_move __PROTO((unsigned int x, unsigned int y));
                     64: TERM_PUBLIC void HP26_init __PROTO((void));
                     65: TERM_PUBLIC void HP26_graphics __PROTO((void));
                     66: TERM_PUBLIC void HP26_text __PROTO((void));
                     67: TERM_PUBLIC void HP26_reset __PROTO((void));
                     68: TERM_PUBLIC int HP26_text_angle __PROTO((int ang));
                     69: TERM_PUBLIC void HP26_put_text __PROTO((unsigned int x, unsigned int y, char *str));
                     70: TERM_PUBLIC void HP26_linetype __PROTO((int linetype));
                     71: TERM_PUBLIC void HP26_line_and_point __PROTO((unsigned int x, unsigned int y, int number));
                     72:
                     73: #define HP26_XMAX 512
                     74: #define HP26_YMAX 390
                     75:
                     76: /* Use a size 1 character, or a 7 x 10 grid. */
                     77: #define HP26_VCHAR     10
                     78: #define HP26_HCHAR     7
                     79: #define HP26_VTIC      5
                     80: #define HP26_HTIC      5
                     81: #endif /* TERM_PROTO */
                     82:
                     83: #ifndef TERM_PROTO_ONLY
                     84: #ifdef TERM_BODY
                     85: /* include the stream compaction routines */
                     86:
                     87: #define HP26_XLAST (HP26_XMAX - 1)
                     88: #define HP26_YLAST (HP26_XMAX - 1)
                     89:
                     90: void HP26_do_point __PROTO((unsigned int x, unsigned int y, int number));
                     91: int compact_slope __PROTO((int xp[], int yp[], int isa_move[], int *sz, double delta));
                     92: int compact_int __PROTO((int xp[], int yp[], int isa_move[], int *size));
                     93: struct _HP26_Buffer_Node *BN_create __PROTO((int index, int size, int linetype));
                     94: void BN_delete __PROTO((struct _HP26_Buffer_Node * the_node));
                     95: int HP26_flush __PROTO((struct _HP26_Buffer_Node * the_buff));
                     96: void HP26_handle_overflow __PROTO((void));
                     97:
                     98: #include "compact.c"
                     99:
                    100: typedef struct _HP26_Buffer_Node {
                    101:     int index;
                    102:     int size;
                    103:     int next;
                    104:     int linetype;
                    105:     int *x;
                    106:     int *y;
                    107:     TBOOLEAN *isa_move;
                    108: } HP26_Buffer_Node;
                    109:
                    110: /* constructor method */
                    111: HP26_Buffer_Node *BN_create(index, size, linetype)
                    112: int index, size, linetype;
                    113: {
                    114:     HP26_Buffer_Node *the_node;
                    115:     the_node = (HP26_Buffer_Node *) malloc(sizeof(HP26_Buffer_Node));
                    116:     the_node->index = index;
                    117:     the_node->linetype = linetype;
                    118:     the_node->size = size;
                    119:     the_node->next = 0;
                    120:     the_node->x = (int *) calloc(the_node->size, sizeof(int));
                    121:     the_node->y = (int *) calloc(the_node->size, sizeof(int));
                    122:     the_node->isa_move = (TBOOLEAN *) calloc(the_node->size, sizeof(TBOOLEAN));
                    123:     if (the_node->x == NULL
                    124:        || the_node->y == NULL
                    125:        || the_node->isa_move == NULL)
                    126:        return (NULL);
                    127:     else
                    128:        return (the_node);
                    129: }
                    130:
                    131: /* destructor method */
                    132: void BN_delete(the_node)
                    133: HP26_Buffer_Node *the_node;
                    134: {
                    135:     free(the_node->x);
                    136:     free(the_node->y);
                    137:     free(the_node->isa_move);
                    138:     free(the_node);
                    139: }
                    140:
                    141: /* 2 for border and axes + 9 for plots + 1 for dots */
                    142: #define HP26_gnu_map_size 12
                    143: HP26_Buffer_Node *HP26_gnu_map[HP26_gnu_map_size];
                    144: HP26_Buffer_Node *HP26_buff;
                    145: int HP26_pen_x;
                    146: int HP26_pen_y;
                    147: int HP26_angle;
                    148: int HP26_cursor_x;
                    149: int HP26_cursor_y;
                    150: TBOOLEAN HP26_in_text;
                    151: int HP26_linetype_current;
                    152: int HP26_reduction_int;
                    153: int HP26_reduction_slope;
                    154: int HP26_overflows;
                    155: int HP26_nop_move;
                    156: int HP26_nop_vect;
                    157: int HP26_nop_line;
                    158:
                    159: /* linetype stuff */
                    160: #define        SOLID   1
                    161: #define        USER    2
                    162: #define LINE3  3
                    163: #define LINE4  4
                    164: #define LINE5  5
                    165: #define LINE6  6
                    166: #define        DOTS    7
                    167: #define LINE8  8
                    168: #define LINE9  9
                    169: #define LINE10 10
                    170: #define POINT  11
                    171:
                    172:
                    173:
                    174: #define swap(a, b) a ^= b; b ^= a; a ^= b;
                    175:
                    176: char HP26_bin_short_table[32] =
                    177: {
                    178:     '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>',
                    179:     '?', ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-',
                    180:     '.', '/'
                    181: };
                    182: /* encodes an integer (assumed to be in range) into
                    183:    binary short incremental format (j)*/
                    184: #define short_encode(n) (HP26_bin_short_table[n+16])
                    185:
                    186: /* tells whether a given delta_x,delta_y pair can be expressed in
                    187:    binary short incremental format */
                    188: #define qualified(dx,dy) ((dx>-17)&&(dy>-17)&&(dx<16)&&(dy<16))
                    189:
                    190:
                    191: char HP26_bin_table[32] =
                    192: {
                    193:     ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-',
                    194:     '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<',
                    195:     '=', '>', '?'
                    196: };
                    197: /* returns the high byte of integer n in binary absolute format (i) */
                    198: #define bin_encode_hi(n) (HP26_bin_table[n>>5])
                    199: /* returns the low byte of integer n in binary absolute format (i) */
                    200: #define bin_encode_lo(n) (HP26_bin_table[n & 31])
                    201:
                    202:
                    203:
                    204: /* the guts of the program
                    205: -- first checks if any work need be done and, failing that, returns
                    206:        immediately
                    207: -- tries to compress the vector stream
                    208: -- goes through the buffer, using binary short incremental (2 bytes/point)
                    209:        as much as possible, even if must output two pairs to express one vector
                    210:        (it's no more expensive, and will hopefully damp any excessive switching
                    211:        back and forth between the two formats)
                    212:        if can't use binary short incremental, use binary
                    213:        absolute(4 bytes/point)
                    214: -- finally, resets the HP26_next pointer to zero    */
                    215: int HP26_flush(the_buff)
                    216: HP26_Buffer_Node *the_buff;
                    217: {
                    218:     int i, delta_x, delta_y, half_dx, half_dy;
                    219:     int *buff_x, *buff_y;
                    220:     TBOOLEAN *isa_move;
                    221:     TBOOLEAN bin_short;
                    222:
                    223:     if (the_buff->next == 0)
                    224:        return (FALSE);
                    225:     /* init pointers for easy access */
                    226:     buff_x = the_buff->x;
                    227:     buff_y = the_buff->y;
                    228:     isa_move = the_buff->isa_move;
                    229:     if (HP26_in_text) {
                    230:        fputs("\033*dT", gpoutfile);
                    231:        HP26_in_text = FALSE;
                    232:     }
                    233:     if (HP26_linetype_current != the_buff->linetype
                    234:        && (the_buff->next > 1 || !isa_move[0])) {
                    235:        fprintf(gpoutfile, "\033*m%dB", the_buff->linetype);
                    236:        HP26_linetype_current = the_buff->linetype;
                    237:     }
                    238:     /* try to compress the stream */
                    239:     if (the_buff->next > 30 && the_buff->linetype != POINT) {
                    240: /*             HP26_reduction_int += compact_int(buff_x,buff_y,isa_move, &(the_buff->next));   */
                    241:        HP26_reduction_slope += compact_slope(buff_x, buff_y, isa_move, &(the_buff->next), 0.1);
                    242:     }
                    243:     /* start escape sequence */
                    244:     fputs("\033*p", gpoutfile);
                    245:     /* initialize the state:  binary short incremental or binary absolute */
                    246:     delta_x = buff_x[0] - HP26_pen_x;
                    247:     delta_y = buff_y[0] - HP26_pen_y;
                    248:     if (qualified(delta_x, delta_y)) {
                    249:        fputc('j', gpoutfile);
                    250:        bin_short = TRUE;
                    251:     } else {
                    252:        fputc('i', gpoutfile);
                    253:        bin_short = FALSE;
                    254:     }
                    255:     /* now work through the list */
                    256:     for (i = 0; i < the_buff->next; i++) {
                    257:        if (i > 0) {
                    258:            delta_x = buff_x[i] - buff_x[i - 1];
                    259:            delta_y = buff_y[i] - buff_y[i - 1];
                    260:        }
                    261:        if ((delta_x == 0) && (delta_y == 0)) {
                    262:            if (i > 0 && !isa_move[i - 1] && !isa_move[i]) {
                    263:                /* allow null vectors only when drawing dots */
                    264:                HP26_nop_vect++;
                    265:                continue;
                    266:            } else if (isa_move[i]) {
                    267:                /* a null move */
                    268:                HP26_nop_move++;
                    269:                continue;
                    270:            }
                    271:        } else if (i > 0
                    272:                   && i + 1 < the_buff->next
                    273:                   && isa_move[i]
                    274:                   && isa_move[i + 1]) {
                    275:            /* consecutive moves are condensed into one */
                    276:            HP26_nop_move++;
                    277:            continue;
                    278:        } else if (!qualified(delta_x, delta_y)
                    279:                   && i > 0
                    280:                   && i + 2 < the_buff->next
                    281:                   && isa_move[i]
                    282:                   && !isa_move[i + 1]
                    283:                   && isa_move[i + 2]
                    284:                   && qualified(buff_x[i + 1] - buff_x[i - 1], buff_y[i + 1] - buff_y[i - 1])) {
                    285:            swap(buff_x[i], buff_x[i + 1]);
                    286:            swap(buff_y[i], buff_y[i + 1]);
                    287:            /* set up new delta_x & delta_y */
                    288:            delta_x = buff_x[i] - buff_x[i - 1];
                    289:            delta_y = buff_y[i] - buff_y[i - 1];
                    290:        }
                    291:        if (qualified(delta_x, delta_y)) {
                    292:            if (!bin_short) {
                    293:                fputc('j', gpoutfile);
                    294:                bin_short = TRUE;
                    295:            }
                    296:            if (isa_move[i])
                    297:                fputc('a', gpoutfile);
                    298:            fputc(short_encode(delta_x), gpoutfile);
                    299:            fputc(short_encode(delta_y), gpoutfile);
                    300:        } else {
                    301:            half_dx = (delta_x + (delta_x > 0 ? 1 : -1)) / 2;
                    302:            half_dy = (delta_y + (delta_y > 0 ? 1 : -1)) / 2;
                    303:            if (bin_short && qualified(half_dx, half_dy)) {
                    304:                if (isa_move[i])
                    305:                    fputc('a', gpoutfile);
                    306:                fputc(short_encode(half_dx), gpoutfile);
                    307:                fputc(short_encode(half_dy), gpoutfile);
                    308:                if (isa_move[i])
                    309:                    fputc('a', gpoutfile);
                    310:                fputc(short_encode(delta_x - half_dx), gpoutfile);
                    311:                fputc(short_encode(delta_y - half_dy), gpoutfile);
                    312:            } else {
                    313:                if (bin_short) {
                    314:                    bin_short = FALSE;
                    315:                    fputc('i', gpoutfile);
                    316:                }
                    317:                if (isa_move[i])
                    318:                    fputc('a', gpoutfile);
                    319:                fputc(bin_encode_hi(buff_x[i]), gpoutfile);
                    320:                fputc(bin_encode_lo(buff_x[i]), gpoutfile);
                    321:                fputc(bin_encode_hi(buff_y[i]), gpoutfile);
                    322:                fputc(bin_encode_lo(buff_y[i]), gpoutfile);
                    323:            }
                    324:        }
                    325:     }                          /* end for.. */
                    326:     /* the term doesn't seem to mind leaving this out */
                    327:     /* finish the escape sequence */
                    328:     fputc('Z', gpoutfile);
                    329:     /* set these for next time */
                    330:     HP26_pen_x = buff_x[the_buff->next - 1];
                    331:     HP26_pen_y = buff_y[the_buff->next - 1];
                    332:     the_buff->next = 0;
                    333:     return (TRUE);
                    334: }
                    335:
                    336: void HP26_handle_overflow()
                    337: {
                    338:     HP26_Buffer_Node *bigger, *old;
                    339:     int x, y;
                    340:     x = (HP26_buff->x)[HP26_buff->next - 1];
                    341:     y = (HP26_buff->y)[HP26_buff->next - 1];
                    342:     HP26_flush(HP26_buff);
                    343:     bigger = BN_create(HP26_buff->index, HP26_buff->size * 2,
                    344:                       HP26_buff->linetype);
                    345:     if (bigger != NULL) {
                    346:        old = HP26_buff;
                    347:        HP26_gnu_map[bigger->index] = bigger;
                    348:        /* special case since DOTS entry is shared 3 ways */
                    349:        if (bigger->index == 0) {
                    350:            HP26_gnu_map[1] = bigger;
                    351:            HP26_gnu_map[3] = bigger;
                    352:        }
                    353:        HP26_buff = bigger;
                    354:        BN_delete(old);
                    355:     }
                    356:     (HP26_buff->x)[0] = x;
                    357:     (HP26_buff->y)[0] = y;
                    358:     (HP26_buff->isa_move)[0] = TRUE;
                    359:     HP26_buff->next = 1;
                    360:     HP26_overflows++;
                    361: }
                    362:
                    363: /* checks for NOP, overcapacity condition, and then adds vector to the list */
                    364: TERM_PUBLIC void HP26_vector(x, y)
                    365: unsigned int x, y;
                    366: {
                    367:     if (HP26_buff->next > 2
                    368:        && x == (HP26_buff->x)[HP26_buff->next - 1]
                    369:        && y == (HP26_buff->y)[HP26_buff->next - 1]
                    370:        && !(HP26_buff->isa_move)[HP26_buff->next - 1]) {
                    371:        HP26_nop_vect++;
                    372:        return;
                    373:     }
                    374:     if (HP26_buff->next == HP26_buff->size)
                    375:        HP26_handle_overflow();
                    376:     /* otherwise add to the list */
                    377:     (HP26_buff->x)[HP26_buff->next] = x;
                    378:     (HP26_buff->y)[HP26_buff->next] = y;
                    379:     (HP26_buff->isa_move)[HP26_buff->next] = FALSE;
                    380:     HP26_buff->next++;
                    381: }
                    382:
                    383: /* checks for NOP, checks for overcapacity, puts self on list */
                    384: TERM_PUBLIC void HP26_move(x, y)
                    385: unsigned int x, y;
                    386: {
                    387:     if (HP26_buff->next > 0) {
                    388:        if (((HP26_buff->x)[HP26_buff->next - 1] == x)
                    389:            && ((HP26_buff->y)[HP26_buff->next - 1] == y)) {
                    390:            /* null moves are NOP's */
                    391:            HP26_nop_move++;
                    392:            return;
                    393:        } else if ((HP26_buff->isa_move)[HP26_buff->next - 1]) {
                    394:            /* consecutive moves are NOP's */
                    395:            (HP26_buff->x)[HP26_buff->next - 1] = x;
                    396:            (HP26_buff->y)[HP26_buff->next - 1] = y;
                    397:            HP26_nop_move++;
                    398:            return;
                    399:        }
                    400:     }
                    401:     if (HP26_buff->next == HP26_buff->size)
                    402:        HP26_handle_overflow();
                    403:     (HP26_buff->x)[HP26_buff->next] = x;
                    404:     (HP26_buff->y)[HP26_buff->next] = y;
                    405:     (HP26_buff->isa_move)[HP26_buff->next] = TRUE;
                    406:     HP26_buff->next++;
                    407:     return;
                    408: }
                    409:
                    410: TERM_PUBLIC void HP26_init()
                    411: {
                    412:     HP26_gnu_map[-2 + 2] = BN_create(0, 2048, DOTS);   /* border */
                    413:     HP26_gnu_map[-1 + 2] = HP26_gnu_map[-2 + 2];       /* axes */
                    414:     HP26_gnu_map[0 + 2] = BN_create(2, 3072, SOLID);   /* plot 0 */
                    415:     HP26_gnu_map[1 + 2] = HP26_gnu_map[-2 + 2];                /* plot 1 */
                    416:     HP26_gnu_map[2 + 2] = BN_create(4, 1024, LINE5);   /* plot 2 */
                    417:     HP26_gnu_map[3 + 2] = BN_create(5, 256, LINE6);    /* plot 3 */
                    418:     HP26_gnu_map[4 + 2] = BN_create(6, 256, LINE8);    /* plot 4 */
                    419:     HP26_gnu_map[5 + 2] = BN_create(7, 128, LINE9);    /* plot 5 */
                    420:     HP26_gnu_map[6 + 2] = BN_create(8, 128, LINE10);   /* plot 6 */
                    421:     HP26_gnu_map[7 + 2] = BN_create(9, 64, LINE6);     /* plot 7 */
                    422:     HP26_gnu_map[8 + 2] = BN_create(10, 64, LINE4);    /* plot 8 */
                    423:     HP26_gnu_map[9 + 2] = BN_create(11, 512, POINT);   /* point plot */
                    424:     HP26_buff = HP26_gnu_map[10];      /* set to an unlikely linetype */
                    425:     HP26_linetype_current = 0; /* set to force a linetype change */
                    426:     HP26_angle = 1;            /* left to right, default */
                    427:     fputs("\033*mp1m2a2Q", gpoutfile);
                    428:     /*           1 2 3 4
                    429:        1.  make text upright
                    430:        2.  select text size 1
                    431:        3.  make SET the default drawing op
                    432:        4.  left justify text */
                    433:     fflush(gpoutfile);
                    434: }
                    435:
                    436:
                    437: TERM_PUBLIC void HP26_graphics()
                    438: {
                    439:     fputs("\033*daflsC", gpoutfile);
                    440:     /*           12345
                    441:        1.  clear graphics display
                    442:        2.  shut off the alphanumeric display
                    443:        3.  graphics cursor off
                    444:        4.  into graphics text mode
                    445:        5.  enable graphics display */
                    446:     /* set the pen & cursor positions to force an initial absolute move */
                    447:     HP26_pen_x = HP26_pen_y = -200;
                    448:     HP26_cursor_x = HP26_cursor_y = 800;
                    449:     HP26_in_text = TRUE;
                    450:     /* initialize statistics */
                    451:     HP26_reduction_int = 0;
                    452:     HP26_reduction_slope = 0;
                    453:     HP26_nop_move = 0;
                    454:     HP26_nop_vect = 0;
                    455:     HP26_nop_line = 0;
                    456:     HP26_overflows = 0;
                    457: }
                    458:
                    459:
                    460: TERM_PUBLIC void HP26_text()
                    461: {
                    462:     int i, j, curr;
                    463:
                    464:     /* always flush the current line first */
                    465:     for (i = 0; i < HP26_gnu_map_size; i++)
                    466:        if ((HP26_gnu_map[i])->linetype == HP26_linetype_current)
                    467:            HP26_flush(HP26_gnu_map[i]);
                    468:     /* now flush the rest of the lines */
                    469:     for (i = 0; i < HP26_gnu_map_size; i++) {
                    470:        HP26_flush(HP26_gnu_map[i]);
                    471:        curr = HP26_gnu_map[i]->linetype;
                    472:        for (j = 0; j < HP26_gnu_map_size; j++)
                    473:            if ((HP26_gnu_map[j])->linetype == curr)
                    474:                HP26_flush(HP26_gnu_map[j]);
                    475:     }
                    476:     fputs("\033*deT", gpoutfile);
                    477:     /*           12
                    478:        1. turn on the alphanumeric display
                    479:        2. back to text mode */
                    480:     fflush(gpoutfile);
                    481:     /* informational:  tells how many points compressed, how
                    482:        many NOP's of each type, and how many times a buffer
                    483:        overflowed during this plot */
                    484:     /*
                    485:        if(HP26_reduction_int
                    486:        + HP26_reduction_slope
                    487:        + HP26_nop_move
                    488:        + HP26_nop_vect
                    489:        + HP26_overflows
                    490:        + HP26_nop_line > 0){
                    491:        if (HP26_reduction_int>0)
                    492:        printf("%d int-compress",HP26_reduction_int);
                    493:        if (HP26_reduction_slope>0)
                    494:        printf("%d slope-compress",HP26_reduction_slope);
                    495:        if (HP26_nop_move>0)
                    496:        printf("  %d nop_move",HP26_nop_move);
                    497:        if (HP26_nop_vect>0)
                    498:        printf("  %d nop_vect",HP26_nop_vect);
                    499:        if (HP26_nop_line>0)
                    500:        printf("  %d nop_line",HP26_nop_line);
                    501:        if (HP26_overflows>0)
                    502:        printf("  %d buffer overflows",HP26_overflows);
                    503:        printf("\n");
                    504:        }
                    505:      */
                    506: }
                    507:
                    508: TERM_PUBLIC void HP26_reset()
                    509: {
                    510:     int i;
                    511:     for (i = 2; i < HP26_gnu_map_size; i++)
                    512:        BN_delete(HP26_gnu_map[i]);
                    513: }
                    514:
                    515: TERM_PUBLIC int HP26_text_angle(ang)
                    516: int ang;
                    517: {
                    518:     HP26_angle = ang + 1;
                    519:     fprintf(gpoutfile, "\033*m%dN", HP26_angle);
                    520:     return (TRUE);
                    521: }
                    522:
                    523:
                    524: TERM_PUBLIC void HP26_put_text(x, y, str)
                    525: unsigned int x, y;
                    526: char *str;
                    527: {
                    528:     char abs_str[10], rel_str[10];
                    529:
                    530:     if (!strlen(str))
                    531:        return;
                    532:     else {
                    533:        fputs("\033*d", gpoutfile);
                    534:        if (!HP26_in_text) {
                    535:            fputc('s', gpoutfile);
                    536:            HP26_in_text = TRUE;
                    537:        }
                    538:        sprintf(rel_str, "%d,%dP", x - HP26_cursor_x, y - HP26_cursor_y);
                    539:        sprintf(abs_str, "%d,%dO", x, y);
                    540:        if (strlen(rel_str) < strlen(abs_str))
                    541:            fputs(rel_str, gpoutfile);
                    542:        else
                    543:            fputs(abs_str, gpoutfile);
                    544:        fputs(str, gpoutfile);
                    545:        HP26_pen_x = HP26_cursor_x = x;
                    546:        HP26_pen_y = HP26_cursor_y = y;
                    547:     }
                    548:     /*
                    549:        tmp = &(HP26_all_buffers[HP26_linetype_current]);
                    550:        tmp->x[tmp->next] = x;
                    551:        tmp->y[tmp->next] = y;
                    552:        tmp->isa_move[tmp->next] = TRUE;
                    553:        tmp->next++;
                    554:        HP26_flush(tmp);
                    555:        fprintf(gpoutfile,"\033*l%s\r",str);
                    556:      */
                    557:     return;
                    558: }
                    559:
                    560:
                    561: /* checks for NOP, sets HP26_buff to point to the right buffer */
                    562: TERM_PUBLIC void HP26_linetype(linetype)
                    563: int linetype;
                    564: {
                    565:     if (linetype > 8)
                    566:        linetype %= 9;
                    567:     linetype += 2;
                    568:     if (HP26_gnu_map[linetype] == HP26_buff) {
                    569:        HP26_nop_line++;
                    570:        return;                 /* gnuplot just sent us another NOP */
                    571:     }
                    572:     HP26_buff = HP26_gnu_map[linetype];
                    573: }
                    574:
                    575:
                    576:
                    577: /* switches to a solid linetype and calls do_point, then switches back */
                    578: TERM_PUBLIC void HP26_line_and_point(x, y, number)
                    579: unsigned int x, y;
                    580: int number;
                    581: {
                    582:     int line_save, not_solid;
                    583:
                    584:     /* shut up warnings with dummy initializer  -SB */
                    585:     line_save = 0;
                    586:     not_solid = (HP26_buff->linetype != SOLID);
                    587:     if (not_solid) {
                    588:        line_save = HP26_buff->linetype;
                    589:        HP26_linetype(0);       /*switch to a solid line */
                    590:     }
                    591:     HP26_do_point(x, y, number);
                    592:     if (not_solid)
                    593:        HP26_linetype(line_save);
                    594: }
                    595:
                    596:
                    597: /* provides 9 point types so they stay in sync with the linetypes
                    598: puts simpler point types first on the assumption they are more
                    599: frequently used */
                    600: void HP26_do_point(x, y, number)
                    601: unsigned int x, y;
                    602: int number;
                    603: {
                    604:     int htic, vtic;
                    605:     HP26_Buffer_Node *tmp;
                    606:
                    607:     vtic = HP26_VTIC / 2;
                    608:     htic = HP26_HTIC / 2;
                    609:     if (number < 0) {
                    610:        /* do a dot -- special case */
                    611:        tmp = HP26_buff;
                    612:        HP26_buff = HP26_gnu_map[11];   /* point plot */
                    613:        HP26_vector(x, y);
                    614:        HP26_buff = tmp;
                    615:     }
                    616:     switch (number % 9) {
                    617:     case 0:
                    618:        /* do triangle */
                    619:        HP26_move(x - htic, y - vtic);
                    620:        HP26_vector(x, y + vtic);
                    621:        HP26_vector(x + htic, y - vtic);
                    622:        HP26_vector(x - htic, y - vtic);
                    623:        break;
                    624:     case 1:
                    625:        /* do nambla */
                    626:        HP26_move(x - htic, y + vtic);
                    627:        HP26_vector(x, y - vtic);
                    628:        HP26_vector(x + htic, y + vtic);
                    629:        HP26_vector(x - htic, y + vtic);
                    630:        break;
                    631:     case 2:
                    632:        /* do left triangle */
                    633:        HP26_move(x - htic, y);
                    634:        HP26_vector(x + htic, y + vtic);
                    635:        HP26_vector(x + htic, y - vtic);
                    636:        HP26_vector(x - htic, y);
                    637:        break;
                    638:     case 3:
                    639:        /* do right triangle */
                    640:        HP26_move(x + htic, y);
                    641:        HP26_vector(x - htic, y + vtic);
                    642:        HP26_vector(x - htic, y - vtic);
                    643:        HP26_vector(x + htic, y);
                    644:        break;
                    645:     case 4:
                    646:        /* do box */
                    647:        HP26_move(x - htic, y - vtic);
                    648:        HP26_vector(x - htic, y + vtic);
                    649:        HP26_vector(x + htic, y + vtic);
                    650:        HP26_vector(x + htic, y - vtic);
                    651:        HP26_vector(x - htic, y - vtic);
                    652:        break;
                    653:     case 5:
                    654:        /* do plus */
                    655:        HP26_move(x, y + vtic);
                    656:        HP26_vector(x, y - vtic);
                    657:        HP26_move(x - htic, y);
                    658:        HP26_vector(x + htic, y);
                    659:        break;
                    660:     case 6:
                    661:        /* do X */
                    662:        HP26_move(x + htic, y + vtic);
                    663:        HP26_vector(x - htic, y - vtic);
                    664:        HP26_move(x - htic, y + vtic);
                    665:        HP26_vector(x + htic, y - vtic);
                    666:        break;
                    667:     default:
                    668:        /* do diamond */
                    669:        HP26_move(x, y - vtic);
                    670:        HP26_vector(x - htic, y);
                    671:        HP26_vector(x, y + vtic);
                    672:        HP26_vector(x + htic, y);
                    673:        HP26_vector(x, y - vtic);
                    674:        break;
                    675:     }
                    676: }
                    677:
                    678: #endif /* TERM_BODY */
                    679:
                    680: #ifdef TERM_TABLE
                    681:
                    682: TERM_TABLE_START(hp2623a_driver)
                    683:     "hp2623A", "HP2623A and maybe others",
                    684:     HP26_XMAX, HP26_YMAX, HP26_VCHAR, HP26_HCHAR,
                    685:     HP26_VTIC, HP26_HTIC, options_null, HP26_init, HP26_reset,
                    686:     HP26_text, null_scale, HP26_graphics, HP26_move, HP26_vector,
                    687:     HP26_linetype, HP26_put_text, HP26_text_angle,
                    688:     null_justify_text, HP26_line_and_point, do_arrow, set_font_null
                    689: TERM_TABLE_END(hp2623a_driver)
                    690:
                    691: #undef LAST_TERM
                    692: #define LAST_TERM hp2623a_driver
                    693:
                    694: #endif /* TERM_TABLE */
                    695: #endif /* TERM_PROTO_ONLY */
                    696:
                    697: #ifdef TERM_HELP
                    698: START_HELP(hp2623a)
                    699: "1 hp2623a",
                    700: "?commands set terminal hp2623a",
                    701: "?set terminal hp2623a",
                    702: "?set term hp2623a",
                    703: "?terminal hp2623a",
                    704: "?term hp2623a",
                    705: "?hp2623a",
                    706: " The `hp2623a` terminal driver supports the Hewlett Packard HP2623A.  It has",
                    707: " no options."
                    708: END_HELP(hp2623a)
                    709: #endif

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