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

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

1.1       maekawa     1: /*
                      2:  * $Id: fig.trm,v 1.57 1998/06/18 14:59:20 ddenholm Exp $
                      3:  */
                      4:
                      5: /* GNUPLOT - fig.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:  *  Fig graphics language
                     42:  *
                     43:  * AUTHORS
                     44:  *  Micah Beck, David Kotz
                     45:  *
                     46:  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
                     47:  *
                     48:  */
                     49:
                     50: /*
                     51:  * Original for Fig code output by Micah Beck, 1989
                     52:  * Department of Computer Science, Cornell University
                     53:  * Updated by David Kotz for gnuplot 2.0
                     54:  * More efficient output by Ian Dall
                     55:  * Updated to FIG 2.1 (with color) format by Vivek Khera
                     56:  * Updated to FIG 3.1 (higher resolution) format by Ian MacPhedran, Jan 1995
                     57:  * Updated to conform to newterm format Ian MacPhedran, Apr 1995
                     58:  * Point-count option joachim.selinger@ins.uni-stuttgart.de (JFS) Feb  9 1996
                     59:  * More options (portrait/landscape, metric/inches, size, fontsize, thickness)
                     60:  * plus symbols and depth/thickness by bernlohr@eu1.mpi-hd.mpg.de (KB) Aug 15 1996
                     61:  */
                     62:
                     63: #include "driver.h"
                     64:
                     65: #ifdef TERM_REGISTER
                     66: register_term(fig)
                     67: #endif /* TERM_REGISTER */
                     68:
                     69: #ifdef TERM_PROTO
                     70: TERM_PUBLIC void FIG_options __PROTO((void));
                     71: TERM_PUBLIC void FIG_init __PROTO((void));
                     72: TERM_PUBLIC void FIG_graphics __PROTO((void));
                     73: TERM_PUBLIC void FIG_text __PROTO((void));
                     74: TERM_PUBLIC void FIG_linetype __PROTO((int linetype));
                     75: TERM_PUBLIC void FIG_move __PROTO((unsigned int x, unsigned int y));
                     76: TERM_PUBLIC void FIG_vector __PROTO((unsigned int ux, unsigned int uy));
                     77: TERM_PUBLIC void FIG_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, TBOOLEAN head));
                     78: TERM_PUBLIC void FIG_put_text __PROTO((unsigned int x, unsigned int y, char *str));
                     79: TERM_PUBLIC int FIG_justify_text __PROTO((enum JUSTIFY mode));
                     80: TERM_PUBLIC int FIG_text_angle __PROTO((int ang));
                     81: TERM_PUBLIC void FIG_pointsize __PROTO((double arg_pointsize));
                     82: TERM_PUBLIC void FIG_linewidth __PROTO((double linewidth));
                     83: TERM_PUBLIC void FIG_reset __PROTO((void));
                     84: TERM_PUBLIC void FIG_lpoint __PROTO((unsigned int x, unsigned int y, int number));
                     85:
                     86: #define GOT_FIG_PROTO
                     87: #endif /* TERM_PROTO */
                     88:
                     89: #ifndef TERM_PROTO_ONLY
                     90: #ifdef TERM_BODY
                     91:
                     92: #include "object.h"            /* modified from the XFig distribution */
                     93: #define FIG_DEFAULT DEFAULT
                     94: #define FIG_ROMAN_FONT (0)     /* actually, the default font */
                     95:
                     96: #ifndef FIG_RES
                     97: /* This is now 1200 per inch */
                     98: #define FIG_RES         (1200)
                     99: #endif
                    100:
                    101: #define FIG_COORD_SYS   2
                    102: #define FIG_ORIENT (FIG_portrait?"Portrait":"Landscape")
                    103: /* Could be "Portrait" */
                    104: #define FIG_JUST "Center"
                    105: /* Could be "Flush Left" */
                    106: #define FIG_UNIT (FIG_inches?"Inches":"Metric")
                    107: /* Could be "Inches" */
                    108:
                    109: #define FIG_MAGIC       "#FIG 3.1"
                    110: #define FIG_HTIC        (5*FIG_RES/80)
                    111: #define FIG_VTIC        (5*FIG_RES/80)
                    112: #define FIG_FONT_S      (10)   /* size in points */
                    113: #define FIG_MAX_POINTS  99999L /* almost infinite ;-) */
                    114:
                    115: #define FIG_to_pixel_v(s) ((s)*FIG_RES/72*3/4) /* height of font in pixels */
                    116: /* This is fudged to enlarge the drawing area, but gives fairly good results */
                    117: #define FIG_to_pixel_h(s) (FIG_to_pixel_v(s)*6/10)     /* this is a guess at the width */
                    118:
                    119: #define FIG_VCHAR       FIG_to_pixel_v(FIG_FONT_S)     /* just for default, */
                    120: #define FIG_HCHAR       FIG_to_pixel_h(FIG_FONT_S)     /* not really used   */
                    121:
                    122: enum FIG_poly_stat {
                    123:     FIG_poly_new, FIG_poly_part
                    124: };
                    125:
                    126: static int FIG_posx;
                    127: static int FIG_posy;
                    128: static long FIG_poly_vec_cnt;
                    129: static int FIG_depth = 10;
                    130: static int FIG_linedepth = 10;
                    131: static int FIG_thickness = 1;
                    132: static int FIG_default_thickness = 1;
                    133: static double FIG_current_pointsize = 1.;
                    134: static double FIG_current_linewidth = 1.;
                    135:
                    136: /* Maximum number of points per POLYLINE.
                    137:    Default 1000 (hardcoded in help section as well) */
                    138: static int FIG_poly_vec_max = 999;     /* JFS */
                    139:
                    140: static enum FIG_poly_stat FIG_polyvec_stat;
                    141:
                    142: /* 5 inches wide by 3 inches high */
                    143: #define FIG_XMAX (5 * FIG_RES)
                    144: #define FIG_YMAX (3 * FIG_RES)
                    145:
                    146: #define FIG_XOFF (FIG_RES/4)
                    147: #define FIG_YOFF (FIG_RES/4)
                    148:
                    149:
                    150: #define BFIG_HTIC       (7*FIG_RES/80)
                    151: #define BFIG_VTIC       (7*FIG_RES/80)
                    152: #define BFIG_FONT_S     (16)   /* size in points */
                    153: #define BFIG_VCHAR      FIG_to_pixel_v(BFIG_FONT_S)    /* height in pixels of font */
                    154: #define BFIG_HCHAR      FIG_to_pixel_h(BFIG_FONT_S)    /* this is a guess at the width */
                    155:
                    156: static F_point *FIG_points = NULL;     /* Array for the collection of points for
                    157:                                           POLYLINE, allocated on demand. */
                    158: static F_line FIG_line;
                    159:
                    160: /* 8 inches wide by 5 inches high */
                    161: #define BFIG_XMAX (8 * FIG_RES)
                    162: #define BFIG_YMAX (5 * FIG_RES)
                    163:
                    164: #define BFIG_XOFF (FIG_RES/2)
                    165: #define BFIG_YOFF (FIG_RES/2)
                    166:
                    167:
                    168: static int FIG_type;           /* negative types use real lines */
                    169: static float FIG_spacing;      /* length of dash or dot spacing */
                    170: static int FIG_justify;                /* Fig justification T_*_JUSTIFIED */
                    171: static float FIG_angle;                /* Fig text angle 0=horiz, Pi/2=vert */
                    172: static int FIG_use_color = FALSE;      /* do we use color or not? */
                    173: static int FIG_is_big = FALSE; /* big plot ? */
                    174: static int FIG_color = DEFAULT;        /* which color to use */
                    175: static int FIG_xoff = FIG_XOFF;
                    176: static int FIG_yoff = FIG_YOFF;
                    177: static int FIG_font_s = FIG_FONT_S;
                    178: static int FIG_portrait = FALSE;
                    179: static int FIG_inches = FALSE;
                    180:
                    181: static void FIG_poly_clean __PROTO((enum FIG_poly_stat fig_stat));
                    182:
                    183:
                    184: #define FIG_POINT_TYPES POINT_TYPES    /* we use the same points */
                    185:
                    186:
                    187: static void FIG_poly_clean(fig_stat)
                    188: enum FIG_poly_stat fig_stat;
                    189: {
                    190:     int i, j;
                    191:     if (fig_stat == FIG_poly_part) {
                    192:        fprintf(gpoutfile, "%d %d %d %d %d %d %d %d %d %9.3f %d %d %d %d %d %ld\n\t",
                    193:                O_POLYLINE, FIG_line.type, FIG_line.style, FIG_line.thickness,
                    194:                FIG_line.pen_color, FIG_line.fill_color, FIG_line.depth,
                    195:                FIG_line.pen_style, FIG_line.fill_style, FIG_line.style_val,
                    196:                FIG_line.join_style, FIG_line.cap_style, FIG_line.radius,
                    197:                0, 0, FIG_poly_vec_cnt);
                    198:
                    199:        j = 0;
                    200:        for (i = 0; i < FIG_poly_vec_cnt; i++) {
                    201:            fprintf(gpoutfile, " %d %d", FIG_points[i].x, FIG_points[i].y);
                    202:            if (j++ > 4 && i != FIG_poly_vec_cnt - 1) {
                    203:                fputs("\n\t", gpoutfile);
                    204:                j = 0;          /* JFS */
                    205:            }
                    206:        }
                    207:        if (j != 0) {
                    208:            putc('\n', gpoutfile);
                    209:        }
                    210:        /* Give the memory back to the system because we are done with this
                    211:         * polyline. Make sure FIG_points contains NULL afterwards!
                    212:         */
                    213:        free(FIG_points);
                    214:        FIG_points = NULL;
                    215:     }
                    216:     FIG_polyvec_stat = FIG_poly_new;
                    217: }
                    218:
                    219: TERM_PUBLIC void FIG_options()
                    220: {
                    221:     static char *options_list =        /* sun cc does not concat strings */
                    222:     "expecting monochrome, color, small, big, portrait, landscape,\n\
                    223:  \t inches, metric, size <number> <number>,  fontsize <number>,\n\
                    224:  \t thickness <numer>, depth <number> or pointsmax <number>";
                    225:
                    226:     int parse_error = FALSE;
                    227:     long temp_max;
                    228:     struct value a;
                    229:     unsigned int tmax_t;
                    230:     double xsize_t, ysize_t;
                    231:
                    232:     FIG_use_color = FALSE;     /* default */
                    233:     FIG_is_big = FALSE;                /* default */
                    234:     FIG_portrait = FALSE;
                    235:     FIG_font_s = 0;
                    236:     FIG_default_thickness = 1;
                    237:     xsize_t = ysize_t = 0.;
                    238: #if METRIC
                    239:     FIG_inches = FALSE;
                    240: #else
                    241:     FIG_inches = TRUE;
                    242: #endif
                    243:     while (!END_OF_COMMAND) {
                    244:        if (almost_equals(c_token, "mo$nochrome")) {
                    245:            FIG_use_color = FALSE;
                    246:            c_token++;
                    247:        } else if (almost_equals(c_token, "c$olor")
                    248:                   || almost_equals(c_token, "c$olour")) {
                    249:            FIG_use_color = TRUE;
                    250:            c_token++;
                    251:        } else if (almost_equals(c_token, "sm$all")) {
                    252:            FIG_is_big = FALSE;
                    253:            c_token++;
                    254:        } else if (almost_equals(c_token, "b$ig")) {
                    255:            FIG_is_big = TRUE;
                    256:            c_token++;
                    257:        } else if (almost_equals(c_token, "in$ches")) {         /* KB */
                    258:            FIG_inches = TRUE;
                    259:            c_token++;
                    260:        } else if (almost_equals(c_token, "me$tric")) {         /* KB */
                    261:            FIG_inches = FALSE;
                    262:            c_token++;
                    263:        } else if (almost_equals(c_token, "por$trait")) {       /* KB */
                    264:            /* KB: Would have preferred "p$ortrait" but that would */
                    265:            /*     collide with "p$ointsmax" below. */
                    266:            FIG_portrait = TRUE;
                    267:            c_token++;
                    268:        } else if (almost_equals(c_token, "l$andscape")) {      /* KB */
                    269:            FIG_portrait = FALSE;
                    270:            c_token++;
                    271:        } else if (almost_equals(c_token, "si$ze")) {   /* KB */
                    272:            c_token++;
                    273:            if (END_OF_COMMAND) {
                    274:                int_error("size: 2 numbers expected", c_token);
                    275:            } else {
                    276:                xsize_t = real(const_express(&a));
                    277:                if (END_OF_COMMAND) {
                    278:                    int_error("size: 2 numbers expected", c_token);
                    279:                    xsize_t = 0.;
                    280:                } else {
                    281:                    ysize_t = real(const_express(&a));
                    282:                }
                    283:                if (xsize_t < 2. || ysize_t < 2. || xsize_t > 99. || ysize_t > 99.) {
                    284:                    if (xsize_t != 0. || ysize_t != 0.)
                    285:                        int_error("size: out of range", c_token);
                    286:                    xsize_t = ysize_t = 0.;
                    287:                }
                    288:            }
                    289:        } else if (almost_equals(c_token, "f$ontsize")) {       /* KB */
                    290:            c_token++;
                    291:            if (END_OF_COMMAND) {
                    292:                int_error("fontsize: number expected", c_token);
                    293:            } else {
                    294:                FIG_font_s = (int) real(const_express(&a));
                    295:                if (FIG_font_s < 5 || FIG_font_s > 36) {
                    296:                    int_error("fontsize out of range", c_token - 1);
                    297:                    FIG_font_s = 0;
                    298:                }
                    299:            }
                    300:        } else if (almost_equals(c_token, "t$hickness")) {      /* KB */
                    301:            c_token++;
                    302:            if (END_OF_COMMAND) {
                    303:                int_error("thickness: number expected", c_token);
                    304:            } else {
                    305:                FIG_default_thickness = (int) real(const_express(&a));
                    306:                if (FIG_default_thickness < 1 || FIG_default_thickness > 10) {
                    307:                    int_error("thickness out of range", c_token - 1);
                    308:                    FIG_default_thickness = 1;
                    309:                }
                    310:            }
                    311:        } else if (almost_equals(c_token, "d$epth")) {  /* KB */
                    312:            c_token++;
                    313:            if (END_OF_COMMAND) {
                    314:                int_error("depth: number expected", c_token);
                    315:            } else {
                    316:                FIG_depth = (int) real(const_express(&a));
                    317:                if (FIG_depth < 0 || FIG_depth > 99) {
                    318:                    int_error("depth out of range", c_token - 1);
                    319:                    FIG_depth = 10;
                    320:                }
                    321:                FIG_linedepth = FIG_depth;
                    322:            }
                    323:        } else if (almost_equals(c_token, "poi$ntsmax")) {      /* JFS */
                    324:            /* Skip the word and then expect the number ! */
                    325:            c_token++;
                    326:            if (END_OF_COMMAND) {
                    327:                int_error("max. points per polyline: number expected", c_token);
                    328:            } else {
                    329:                temp_max = (long) real(const_express(&a));
                    330:                /* Now check the range for the number */
                    331:                if ((temp_max > 1) && (temp_max < (FIG_MAX_POINTS + 2))) {
                    332:                    /* OK. subtract one to the right number! See other numbers... */
                    333:                    FIG_poly_vec_max = temp_max - 1;
                    334:                } else {
                    335:                    char t[128];
                    336:
                    337:                    sprintf(t, "pointsmax: number out of range (2,%ld)",
                    338:                            (FIG_MAX_POINTS + 1));
                    339:                    int_error(t, c_token);
                    340:                }
                    341:            }
                    342:        } else {
                    343:            parse_error = TRUE;
                    344:            int_error(options_list, c_token);
                    345:        }
                    346:     }
                    347:
                    348:     sprintf(term_options, "%s %s %s %d %s %s %s %d %s %d %s %d",
                    349:            FIG_use_color ? "color" : "monochrome",
                    350:            FIG_is_big ? "big" : "small",
                    351:            "pointsmax",
                    352:            FIG_poly_vec_max + 1,
                    353:            FIG_portrait ? "portrait" : "landscape",
                    354:            FIG_inches ? "inches" : "metric",
                    355:            "fontsize", (FIG_font_s > 0 ? FIG_font_s :
                    356:                         (FIG_is_big ? BFIG_FONT_S : FIG_FONT_S)),
                    357:            "thickness", FIG_default_thickness, "depth", FIG_depth);    /* JFS, KB */
                    358:     if (xsize_t > 0. && ysize_t > 0.) {
                    359:        if (xsize_t - (int) xsize_t == 0. && ysize_t - (int) ysize_t == 0.)
                    360:            sprintf(term_options + strlen(term_options),
                    361:                    " size %d %d", (int) xsize_t, (int) ysize_t);
                    362:        else
                    363:            sprintf(term_options + strlen(term_options),
                    364:                    " size %f %f", xsize_t, ysize_t);
                    365:     }
                    366:     if (!FIG_is_big) {
                    367:        if (FIG_font_s == 0)    /* KB */
                    368:            FIG_font_s = FIG_FONT_S;
                    369:        term->xmax = FIG_XMAX;
                    370:        term->ymax = FIG_YMAX;
                    371:        term->v_tic = FIG_VTIC;
                    372:        term->h_tic = FIG_HTIC;
                    373:        FIG_xoff = FIG_XOFF;
                    374:        FIG_yoff = FIG_YOFF;
                    375:     } else {
                    376:        if (FIG_font_s == 0)    /* KB */
                    377:            FIG_font_s = BFIG_FONT_S;
                    378:        term->xmax = BFIG_XMAX;
                    379:        term->ymax = BFIG_YMAX;
                    380:        term->v_tic = BFIG_VTIC;
                    381:        term->h_tic = BFIG_HTIC;
                    382:        FIG_xoff = BFIG_XOFF;
                    383:        FIG_yoff = BFIG_YOFF;
                    384:     }
                    385:     if (FIG_portrait) {                /* KB */
                    386:        tmax_t = term->xmax;
                    387:        term->xmax = term->ymax;
                    388:        term->ymax = tmax_t;
                    389:     }
                    390:     if (xsize_t > 0. && ysize_t > 0.) {
                    391:        if (FIG_inches) {
                    392:            term->xmax = (unsigned int) (xsize_t * FIG_RES);
                    393:            term->ymax = (unsigned int) (ysize_t * FIG_RES);
                    394:        } else {
                    395:            term->xmax = (unsigned int) (xsize_t / 2.54 * FIG_RES);
                    396:            term->ymax = (unsigned int) (ysize_t / 2.54 * FIG_RES);
                    397:        }
                    398:     }
                    399:     term->v_char = FIG_to_pixel_v(FIG_font_s);
                    400:     term->h_char = FIG_to_pixel_h(FIG_font_s);
                    401:     FIG_thickness = FIG_default_thickness;
                    402:     if (parse_error) {         /* JFS, KB */
                    403:        int_error(options_list, c_token);
                    404:     }
                    405: }
                    406:
                    407: TERM_PUBLIC void FIG_init()
                    408: {
                    409:     FIG_posx = FIG_posy = 0;
                    410:     FIG_polyvec_stat = FIG_poly_new;
                    411:     FIG_linetype(-1);
                    412:     FIG_justify_text(LEFT);
                    413:     FIG_text_angle(0);
                    414:
                    415:     FIG_line.tagged = FIG_DEFAULT;
                    416:     FIG_line.distrib = FIG_DEFAULT;
                    417:     FIG_line.type = T_POLYLINE;
                    418:     FIG_line.style = 0;
                    419:     FIG_line.thickness = FIG_thickness;
                    420:     FIG_line.fill_style = -1;
                    421:     FIG_line.depth = FIG_linedepth;
                    422:     FIG_line.pen_style = 0;
                    423:     FIG_line.for_arrow = NULL;
                    424:     FIG_line.back_arrow = NULL;
                    425:     FIG_line.cap_style = 0;
                    426:     FIG_line.join_style = 0;
                    427:     FIG_line.style_val = 0.0;
                    428:     FIG_line.radius = 0;
                    429:     FIG_line.pic = NULL;
                    430:     FIG_line.next = NULL;
                    431:
                    432:     fprintf(gpoutfile, "\
                    433: %s\n\
                    434: %s\n%s\n%s\n%d %d\n",
                    435:            FIG_MAGIC,
                    436:            FIG_ORIENT, FIG_JUST,
                    437:            FIG_UNIT, FIG_RES, FIG_COORD_SYS);
                    438: }
                    439:
                    440:
                    441: TERM_PUBLIC void FIG_graphics()
                    442: {
                    443:     FIG_posx = FIG_posy = 0;
                    444:     FIG_polyvec_stat = FIG_poly_new;
                    445:     /* there is no way to have separate pictures in a FIG file */
                    446: }
                    447:
                    448:
                    449: TERM_PUBLIC void FIG_text()
                    450: {
                    451:     /* there is no way to have separate pictures in a FIG file */
                    452:     FIG_poly_clean(FIG_polyvec_stat);
                    453:     FIG_posx = FIG_posy = 0;
                    454:     fflush(gpoutfile);
                    455: }
                    456:
                    457:
                    458: /* Line types for FIG work like this:
                    459:  *  for monochrome:
                    460:  *  -2 : solid (border)
                    461:  *  -1 : dotted 4 (axes)
                    462:  *   0 : solid (first curve)
                    463:  *   1 : dotted 3
                    464:  *   2 : dashed 3
                    465:  *   3 : dotted 6
                    466:  *   4 : dashed 6
                    467:  *   ... ...
                    468:  *  for color, cycle through colors. once colors are used up, repeat colors
                    469:  *   but start using dashed lines of different dash length. don't use white
                    470:  *   as a color.
                    471:  */
                    472:
                    473: TERM_PUBLIC void FIG_linetype(linetype)
                    474: int linetype;                  /* expect linetype >= -2 */
                    475: {
                    476:     int last_FIG_type = FIG_type;
                    477:     int last_FIG_spacing = FIG_spacing;
                    478:     int last_FIG_color = FIG_color;
                    479:     int last_FIG_depth = FIG_linedepth;
                    480:     int last_FIG_thickness = FIG_thickness;
                    481:
                    482:     FIG_linedepth = FIG_depth;
                    483:     FIG_thickness = FIG_current_linewidth * FIG_default_thickness;
                    484:     if (FIG_thickness < 1)
                    485:        FIG_thickness = 1;
                    486:     FIG_color = DEFAULT;
                    487:
                    488:     if (linetype < -2)
                    489:        linetype = -2;
                    490:
                    491:     switch (linetype) {
                    492:     case 0:
                    493:     case -2:{
                    494:            FIG_type = SOLID_LINE;
                    495:            FIG_spacing = 0.0;
                    496:            if (FIG_use_color)
                    497:                FIG_color = BLACK;
                    498:            break;
                    499:        }
                    500:     case -1:{
                    501:            FIG_type = DOTTED_LINE;
                    502:            FIG_spacing = 4.0;  /* gap */
                    503:            if (FIG_use_color)
                    504:                FIG_color = BLACK;
                    505:            break;
                    506:        }
                    507:     default:{
                    508: /* now linetype >= 1 *//* shouldn't be negative anyway */
                    509:            FIG_linedepth = FIG_depth + linetype / 1000;
                    510:            linetype %= 1000;
                    511:            /* Thickness of lines is either included in the linetype */
                    512:            /* (in Fig units) or the default is scaled with the */
                    513:            /* current 'linewidth'. */
                    514:            if ((FIG_thickness = linetype / 100) == 0)
                    515:                FIG_thickness = FIG_current_linewidth * FIG_default_thickness;
                    516:            if (FIG_thickness < 1)      /* Less than 1 would be invisible */
                    517:                FIG_thickness = 1;
                    518:            linetype %= 100;
                    519:            if (FIG_use_color) {
                    520:                FIG_type = (linetype >= WHITE);         /* dashed line */
                    521:                FIG_color = linetype % WHITE;
                    522:                FIG_spacing = (linetype / WHITE) * 3;
                    523:            } else {            /* monochrome */
                    524:                FIG_type = linetype % 2 + 1;    /* dotted, dashed, ... */
                    525:                FIG_spacing = (linetype + 1) / 2 * 3;
                    526:            }
                    527:            break;
                    528:        }
                    529:     }
                    530:     if (FIG_type != last_FIG_type || FIG_spacing != last_FIG_spacing ||
                    531:        FIG_color != last_FIG_color || FIG_linedepth != last_FIG_depth ||
                    532:        FIG_thickness != last_FIG_thickness)
                    533:        FIG_poly_clean(FIG_polyvec_stat);
                    534: }
                    535:
                    536: TERM_PUBLIC void FIG_move(x, y)
                    537: unsigned int x, y;
                    538: {
                    539:     int last_FIG_posx = FIG_posx;
                    540:     int last_FIG_posy = FIG_posy;
                    541:     FIG_posx = x;
                    542:     FIG_posy = y;
                    543:     if (FIG_posx != last_FIG_posx || FIG_posy != last_FIG_posy)
                    544:        FIG_poly_clean(FIG_polyvec_stat);
                    545: }
                    546:
                    547:
                    548: TERM_PUBLIC void FIG_vector(ux, uy)
                    549: unsigned int ux, uy;
                    550: {
                    551:     int x = ux, y = uy;
                    552:
                    553:     if (FIG_polyvec_stat != FIG_poly_part) {
                    554:        FIG_line.pen_color = FIG_color;
                    555:        FIG_line.fill_color = FIG_color;
                    556:        FIG_line.style = FIG_type;
                    557:        FIG_line.style_val = FIG_spacing;
                    558:        FIG_line.depth = FIG_linedepth;
                    559:        FIG_line.thickness = FIG_thickness;
                    560:        FIG_poly_vec_cnt = 0;
                    561:        /* allocate memory for the first point */
                    562:        FIG_points = (F_point *) gp_realloc(FIG_points, sizeof(F_point), "FIG_points");         /* JFS */
                    563:        FIG_points[FIG_poly_vec_cnt].x = FIG_xoff + FIG_posx;
                    564:        FIG_points[FIG_poly_vec_cnt].y = term->ymax
                    565:            + FIG_yoff - FIG_posy;
                    566:
                    567:        FIG_poly_vec_cnt = 1;
                    568:        FIG_polyvec_stat = FIG_poly_part;
                    569:     }
                    570:     /* allocate memory for the next point */
                    571:     FIG_points = (F_point *) gp_realloc(FIG_points, (FIG_poly_vec_cnt + 1) *
                    572:                                        sizeof(F_point), "FIG_points");         /* JFS */
                    573:     FIG_points[FIG_poly_vec_cnt].x = FIG_xoff + x;
                    574:     FIG_points[FIG_poly_vec_cnt].y = term->ymax + FIG_yoff - y;
                    575:
                    576:     FIG_poly_vec_cnt++;
                    577:     if (FIG_poly_vec_cnt > FIG_poly_vec_max)
                    578:        FIG_poly_clean(FIG_polyvec_stat);
                    579:
                    580:     FIG_posx = x;
                    581:     FIG_posy = y;
                    582: }
                    583:
                    584:
                    585: TERM_PUBLIC void FIG_arrow(sx, sy, ex, ey, head)
                    586: unsigned int sx, sy;           /* start coord */
                    587: unsigned int ex, ey;           /* end coord */
                    588: TBOOLEAN head;
                    589: {
                    590:     FIG_poly_clean(FIG_polyvec_stat);
                    591:     fprintf(gpoutfile, "%d %d %d %d %d %d %d %d %d %9.3f %d %d %d %d %d %d\n",
                    592:            O_POLYLINE, FIG_line.type, FIG_line.style, FIG_line.thickness,
                    593:            FIG_line.pen_color, FIG_line.fill_color, FIG_line.depth,
                    594:            FIG_line.pen_style, FIG_line.fill_style, FIG_line.style_val,
                    595:            FIG_line.join_style, FIG_line.cap_style, FIG_line.radius,
                    596:            head ? 1 : 0, 0, 2);
                    597:
                    598:     /* arrow line */
                    599:     if (head)
                    600:        fprintf(gpoutfile, "%d %d %.3f %.3f %.3f\n",
                    601:                0, 0, 1.0,
                    602:                (double) (term->h_tic / 2 + 1),
                    603:                (double) term->h_tic);
                    604:     fprintf(gpoutfile, "%d %d %d %d\n",
                    605:            FIG_xoff + sx, FIG_yoff + term->ymax - sy,
                    606:            FIG_yoff + ex, FIG_yoff + term->ymax - ey);
                    607:
                    608:     FIG_posx = ex;
                    609:     FIG_posy = ey;
                    610: }
                    611:
                    612:
                    613: TERM_PUBLIC void FIG_put_text(x, y, str)
                    614: unsigned int x, y;
                    615: char *str;
                    616: {
                    617:     if (strlen(str) == 0)
                    618:        return;
                    619:     FIG_poly_clean(FIG_polyvec_stat);
                    620:     y -= term->v_char / 2;     /* assuming vertical center justified */
                    621:
                    622:     fprintf(gpoutfile, "%d %d %d %d %d %d %6.3f %6.3f %d %6.3f %6.3f %d %d %s\\001\n",
                    623:            O_TEXT, FIG_justify, FIG_color, 0, FIG_DEFAULT,
                    624:            FIG_ROMAN_FONT, (float) FIG_font_s,
                    625:            FIG_angle, SPECIAL_TEXT, (float) term->v_char,
                    626:            (float) term->h_char * strlen(str),
                    627:            FIG_xoff + x, term->ymax + FIG_yoff - y, str);
                    628: }
                    629:
                    630: TERM_PUBLIC int FIG_justify_text(mode)
                    631: enum JUSTIFY mode;
                    632: {
                    633:     switch (mode) {
                    634:     case LEFT:
                    635:        FIG_justify = T_LEFT_JUSTIFIED;
                    636:        break;
                    637:     case CENTRE:
                    638:        FIG_justify = T_CENTER_JUSTIFIED;
                    639:        break;
                    640:     case RIGHT:
                    641:        FIG_justify = T_RIGHT_JUSTIFIED;
                    642:        break;
                    643:        /* shouldn't happen */
                    644:     default:
                    645:        FIG_justify = T_LEFT_JUSTIFIED;
                    646:        return (FALSE);
                    647:        break;
                    648:     }
                    649:     return (TRUE);
                    650: }
                    651:
                    652: TERM_PUBLIC int FIG_text_angle(ang)
                    653: int ang;
                    654: {
                    655:     if (ang)
                    656:        FIG_angle = Pi / 2.0;   /* vertical is pi/2 radians */
                    657:     else
                    658:        FIG_angle = 0.0;        /* horizontal */
                    659:     return (TRUE);
                    660: }
                    661:
                    662: TERM_PUBLIC void FIG_lpoint(x, y, number)
                    663: unsigned int x, y;
                    664: int number;
                    665: {
                    666:     FIG_type = 0;              /* Solid lines for marker outline */
                    667:     if (number % 100 >= 49 && number % 100 < 99) {     /* circles, squares, triangles */
                    668:        int r, d, h, xpc, ypc;
                    669:        int line_color, fill_color, fill_style;
                    670:        int cnum, tnum, color, depth;
                    671:
                    672:        FIG_poly_clean(FIG_polyvec_stat);
                    673:        depth = FIG_linedepth - 1;      /* Above error bars */
                    674:        if (number > 1000)
                    675:            depth = FIG_depth + number / 1000 - 1;
                    676:        number %= 1000;
                    677:        if (depth < 0)
                    678:            depth = 0;
                    679:        if (number < 100)
                    680:            color = FIG_color;
                    681:        else if (FIG_use_color)
                    682:            color = number / 100 - 1;
                    683:        else if (number / 100 >= WHITE)
                    684:            color = WHITE;
                    685:        else
                    686:            color = DEFAULT;
                    687:        number %= 100;
                    688:        cnum = (number + 1) % 10;
                    689:        tnum = (number - 49) / 10;
                    690:        if (cnum < 5)
                    691:            line_color = (FIG_use_color ? BLACK : DEFAULT);
                    692:        else
                    693:            line_color = FIG_color;
                    694:        fill_color = color;
                    695:        if (cnum == 0 || cnum == 5)
                    696:            fill_style = -1;
                    697:        else
                    698:            fill_style = (cnum % 5) * 5;
                    699:
                    700:        xpc = FIG_xoff + x;
                    701:        ypc = term->ymax + FIG_yoff - y;
                    702:
                    703:        if (tnum == 0) {        /* circle */
                    704:            r = FIG_current_pointsize * term->v_char / 4 + 1;
                    705:            fprintf(gpoutfile,
                    706:                    "1 3 %d %d %d %d %d %d %d %6.3f 1 0.000 %d %d %d %d %d %d %d %d\n",
                    707:                    FIG_type, FIG_thickness, line_color,
                    708:                    fill_color, depth, 0, fill_style, FIG_spacing,
                    709:                    xpc, ypc, r, r, xpc, ypc, xpc, ypc - r);
                    710:        } else {
                    711:            fprintf(gpoutfile, "2 3 %d %d %d %d %d %d %d %6.3f 0 0 0 0 0 ",
                    712:                    FIG_type, FIG_thickness, line_color,
                    713:                    fill_color, depth, 0, fill_style, FIG_spacing);
                    714:
                    715:            if (tnum == 1) {    /* square */
                    716:                d = FIG_current_pointsize * term->v_char / 4 + 1;
                    717:                fprintf(gpoutfile, "5\n\t%d %d %d %d %d %d %d %d %d %d\n",
                    718:                        xpc - d, ypc - d, xpc - d, ypc + d, xpc + d, ypc + d, xpc + d, ypc - d,
                    719:                        xpc - d, ypc - d);
                    720:            } else if (tnum == 2) {     /* diamond */
                    721:                d = FIG_current_pointsize * term->v_char / 3 + 1;
                    722:                fprintf(gpoutfile, "5\n\t%d %d %d %d %d %d %d %d %d %d\n",
                    723:                        xpc - d, ypc, xpc, ypc + d, xpc + d, ypc, xpc, ypc - d, xpc - d, ypc);
                    724:            } else if (tnum == 3) {     /* triangle up */
                    725:                d = FIG_current_pointsize * term->v_char / 3 + 1;
                    726:                h = d * 4 / 7;  /* About d times one 3rd of sqrt(3) */
                    727:                fprintf(gpoutfile, "4\n\t%d %d %d %d %d %d %d %d\n",
                    728:                        xpc - d, ypc + h, xpc, ypc - 2 * h, xpc + d, ypc + h, xpc - d, ypc + h);
                    729:            } else if (tnum == 4) {     /* triangle down */
                    730:                d = FIG_current_pointsize * term->v_char / 3 + 1;
                    731:                h = d * 4 / 7;
                    732:                fprintf(gpoutfile, "4\n\t%d %d %d %d %d %d %d %d\n",
                    733:                        xpc - d, ypc - h, xpc, ypc + 2 * h, xpc + d, ypc - h, xpc - d, ypc - h);
                    734:            }
                    735:        }
                    736:     } else
                    737:        do_point(x, y, number);
                    738: }
                    739:
                    740: TERM_PUBLIC void FIG_pointsize(arg_pointsize)
                    741: double arg_pointsize;
                    742: {
                    743:     FIG_current_pointsize = arg_pointsize;
                    744:     /* Bug-fix by hkeller@gwdg.de and K.B.: set pointsize for do_point() */
                    745:     do_pointsize(arg_pointsize * FIG_font_s / (double) FIG_FONT_S);
                    746: }
                    747:
                    748: TERM_PUBLIC void FIG_linewidth(linewidth)
                    749: double linewidth;
                    750: {
                    751:     FIG_current_linewidth = linewidth;
                    752: }
                    753:
                    754: TERM_PUBLIC void FIG_reset()
                    755: {
                    756:     FIG_poly_clean(FIG_polyvec_stat);
                    757:     FIG_posx = FIG_posy = 0;
                    758:     fflush(gpoutfile);
                    759: }
                    760:
                    761: #endif /* TERM_BODY */
                    762:
                    763: #ifdef TERM_TABLE
                    764:
                    765: TERM_TABLE_START(fig_driver)
                    766:     "fig", "FIG 3.1 graphics language: X graphics editor",
                    767:     FIG_XMAX, FIG_YMAX, FIG_VCHAR, FIG_HCHAR,
                    768:     FIG_VTIC, FIG_HTIC, FIG_options, FIG_init, FIG_reset,
                    769:     FIG_text, null_scale, FIG_graphics, FIG_move, FIG_vector,
                    770:     FIG_linetype, FIG_put_text, FIG_text_angle, FIG_justify_text,
                    771:     FIG_lpoint, FIG_arrow, set_font_null, FIG_pointsize,
                    772:     0 /*flags */ , 0 /*suspend */ , 0 /*resume */ , 0 /*fillbox */ ,
                    773:     FIG_linewidth
                    774: TERM_TABLE_END(fig_driver)
                    775:
                    776: #undef LAST_TERM
                    777: #define LAST_TERM fig_driver
                    778: #endif /* TERM_TABLE */
                    779: #endif /* TERM_PROTO_ONLY */
                    780:
                    781: #ifdef TERM_HELP
                    782: START_HELP(fig)
                    783: "1 fig",
                    784: "?commands set terminal fig",
                    785: "?set terminal fig",
                    786: "?set term fig",
                    787: "?terminal fig",
                    788: "?term fig",
                    789: "?fig",
                    790: " The `fig` terminal device generates output in the Fig graphics language.",
                    791: "",
                    792: " Syntax:",
                    793: "       set terminal fig {monochrome | color} {small | big}",
                    794: "                        {pointsmax <max_points>}",
                    795: "                        {landscape | portrait}",
                    796: "                        {metric | inches}",
                    797: "                        {fontsize <fsize>}",
                    798: "                        {size <xsize> <ysize>}",
                    799: "                        {thickness <units>}",
                    800: "                        {depth <layer>}",
                    801: "",
                    802: " `monochrome` and `color` determine whether the picture is black-and-white or",
                    803: " `color`.  `small` and `big` produce a 5x3 or 8x5 inch graph in the default",
                    804: " `landscape` mode and 3x5 or 5x8 inches in `portrait` mode.  <max_points>",
                    805: " sets the maximum number of points per polyline.  Default units for editing",
                    806: " with \"xfig\" may be `metric` or `inches`.  `fontsize` sets the size of the",
                    807: " text font to <fsize> points.  `size` sets (overrides) the size of the drawing",
                    808: " area to <xsize>*<ysize> in units of inches or centimeters depending on the",
                    809: " `inches` or `metric` setting in effect.  `depth` sets the default depth layer",
                    810: " for all lines and text.  The default depth is 10 to leave room for adding",
                    811: " material with \"xfig\" on top of the plot.",
                    812: "",
                    813: " `thickness` sets the default line thickness, which is 1 if not specified.",
                    814: " Overriding the thickness can be achieved by adding a multiple of 100 to the",
                    815: " to the `linetype` value for a `plot` command.  In a similar way the `depth`",
                    816: " of plot elements (with respect to the default depth) can be controlled by",
                    817: " adding a multiple of 1000 to <linetype>.  The depth is then <layer> +",
                    818: " <linetype>/1000 and the thickness is (<linetype>%1000)/100 or, if that is",
                    819: " zero, the default line thickness.",
                    820: "",
                    821: " Additional point-plot symbols are also available with the `fig` driver. The",
                    822: " symbols can be used through `pointtype` values % 100 above 50, with different",
                    823: " fill intensities controlled by <pointtype> % 5 and outlines in black (for",
                    824: " <pointtype> % 10 < 5) or in the current color.  Available symbols are",
                    825: "         50 - 59:  circles",
                    826: "         60 - 69:  squares",
                    827: "         70 - 79:  diamonds",
                    828: "         80 - 89:  upwards triangles",
                    829: "         90 - 99:  downwards triangles",
                    830: " The size of these symbols is linked to the font size.  The depth of symbols",
                    831: " is by default one less than the depth for lines to achieve nice error bars.",
                    832: " If <pointtype> is above 1000, the depth is <layer> + <pointtype>/1000-1.  If",
                    833: " <pointtype>%1000 is above 100, the fill color is (<pointtype>%1000)/100-1.",
                    834: "",
                    835: " Available fill colors are (from 1 to 9): black, blue, green, cyan, red,",
                    836: " magenta, yellow, white and dark blue (in monochrome mode: black for 1 to 6",
                    837: " and white for 7 to 9).",
                    838: "",
                    839: " See `plot with` for details of <linetype> and <pointtype>.",
                    840: "",
                    841: " The `big` option is a substitute for the `bfig` terminal in earlier versions,",
                    842: " which is no longer supported.",
                    843: "",
                    844: " Examples:",
                    845: "       set terminal fig monochrome small pointsmax 1000  # defaults",
                    846: "",
                    847: "       plot 'file.dat' with points linetype 102 pointtype 759",
                    848: " would produce circles with a blue outline of width 1 and yellow fill color.",
                    849: "",
                    850: "       plot 'file.dat' using 1:2:3 with err linetype 1 pointtype 554",
                    851: " would produce errorbars with black lines and circles filled red.  These",
                    852: " circles are one layer above the lines (at depth 9 by default).",
                    853: "",
                    854: " To plot the error bars on top of the circles use",
                    855: "       plot 'file.dat' using 1:2:3 with err linetype 1 pointtype 2554"
                    856: END_HELP(fig)
                    857: #endif /* TERM_HELP */
                    858:
                    859:
                    860:
                    861:
                    862: #if 0
                    863:
                    864: /* I hope this is enough to stop compilers looking in here
                    865:  * (I think that anything inside #if 0 is still strictly
                    866:  *  required to be valid C, rather than just any old junk
                    867:  *  like this.)
                    868:  */
                    869:
                    870: /*
                    871:  * FIG : Facility for Interactive Generation of figures
                    872:  * Copyright (c) 1985 by Supoj Sutanthavibul
                    873:  * Parts Copyright (c) 1994 by Brian V. Smith
                    874:  * Parts Copyright (c) 1991 by Paul King
                    875:  *
                    876:  * The X Consortium, and any party obtaining a copy of these files from
                    877:  * the X Consortium, directly or indirectly, is granted, free of charge, a
                    878:  * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
                    879:  * nonexclusive right and license to deal in this software and
                    880:  * documentation files (the "Software"), including without limitation the
                    881:  * rights to use, copy, modify, merge, publish, distribute, sublicense,
                    882:  * and/or sell copies of the Software, and to permit persons who receive
                    883:  * copies from any such party to do so, with the only requirement being
                    884:  * that this copyright notice remain intact.  This license includes without
                    885:  * limitation a license to do the foregoing actions under any patents of
                    886:  * the party supplying this software to the X Consortium.
                    887:  */
                    888:
                    889: /*
                    890: The only difference from version 3.0 to version 3.1 is that the position
                    891: of the "magnet" has been shifted by 14 Fig units.
                    892: In the 2.1 and older versions of xfig the grid was in multiples of 5 Fig
                    893: units, but they were on intervals 4, 9, 14, 19, etc.
                    894: When version 3.0 was created, coordinates were simply multiplied by the
                    895: ratio of the resolutions (1200/80 = 15) so values like 4 became 60 instead
                    896: of 74 ((4+1)*15 - 1).
                    897:
                    898: This means that figures converted from 2.1 and older files are offset by
                    899: 14 Fig units but new objects entered with version 3.0 are correct.
                    900:
                    901: In version 3.1 the magnet grid is at intervals 0, 75, 150, etc instead of
                    902: -1, 74, 149, etc.
                    903: Figures from 2.1 and older are correctly converted now and a warning is popped
                    904: up when you read in a version 3.0 file that says you may have to offset the
                    905: figure when you load it, using the x and y offsets in the file panel.
                    906:
                    907: --------------------------------------------------------------------------------
                    908: Description of the Fig Format Follows
                    909: --------------------------------------------------------------------------------
                    910:
                    911: (1) The very first line is a comment line containing the name and version:
                    912:        #FIG 3.1
                    913:
                    914:     The character # at the first column of a line indicates that the line
                    915:     is a comment line which will be ignored.
                    916:
                    917: (2) The first non-comment line consists of two numbers and two strings:
                    918:
                    919:        int     fig_resolution          (Fig units/inch)
                    920:        string  orientation             ("Landscape" or "Portrait")
                    921:        string  justification           ("Center" or "Flush Left")
                    922:        string  units                   ("Metric" or "Inches")
                    923:        int     coordinate_system       (1: origin is the lower left corner (NOT USED)
                    924:                                         2: upper left)
                    925:
                    926:     Fig_resolution is the resolution of the figure in the file.
                    927:     Xfig will always write the file with a resolution of 1200ppi so it
                    928:     will scale the figure upon reading it in if its resolution is different
                    929:     from 1200ppi.  Pixels are assumed to be square.
                    930:
                    931:     Xfig will read the orientation string and change the canvas to match
                    932:     either the Landscape or Portrait mode of the figure file.
                    933:
                    934:     The units specification is self-explanatory.
                    935:
                    936:     The coordinate_system variable is ignored - the origin is ALWAYS the
                    937:     upper-left corner.
                    938:
                    939:     ** Coordinates are given in "fig_resolution" units.
                    940:     ** Line thicknesses are given in 1/80 of an inch ("display units").  The
                    941:        minimum line thickness is 0 (no line is drawn) and the maximum is 500.
                    942:     ** dash-lengths/dot-gaps are given in 1/80 of an inch.
                    943:
                    944:
                    945: (3) The rest of the file contains various objects.  An object can be one
                    946:     of six classes (or types).
                    947:
                    948:        0)      Color pseudo-object.
                    949:        1)      Arc.
                    950:        2)      Ellipse which is a generalization of circle.
                    951:        3)      Polyline which includes polygon and box.
                    952:        4)      Spline which includes closed/open control/interpolated spline.
                    953:        5)      Text.
                    954:        6)      Compound object which is composed of one or more objects.
                    955:
                    956:     In the following elaboration on object formats, every value of Fig
                    957:     output are separated by blank characters or new line ('\n').  The
                    958:     value of the unused parameters will be -1.
                    959:
                    960:     Some fields are described as "enumeration type" or "bit vector"; the
                    961:     values which these fields can take are defined in the header file object.h.
                    962:     The pen_style field is unused.
                    963:     These values may be defined in some future version of Fig.
                    964:
                    965:     The two color fields (pen and fill; pen only, for texts) are
                    966:     defined as follows:
                    967:
                    968:            -1 = Default
                    969:             0 = Black
                    970:             1 = Blue
                    971:             2 = Green
                    972:             3 = Cyan
                    973:             4 = Red
                    974:             5 = Magenta
                    975:             6 = Yellow
                    976:             7 = White
                    977:          8-11 = four shades of blue (dark to lighter)
                    978:         12-14 = three shades of green (dark to lighter)
                    979:         15-17 = three shades of cyan (dark to lighter)
                    980:         18-20 = three shades of red (dark to lighter)
                    981:         21-23 = three shades of magenta (dark to lighter)
                    982:         24-26 = three shades of brown (dark to lighter)
                    983:         27-30 = four shades of pink (dark to lighter)
                    984:            31 = Gold
                    985:
                    986:         values from 32 to 543 (512 total) are user colors and
                    987:         are defined in color pseudo-objects (type 0)
                    988:
                    989:     For WHITE color, the area fill field is defined as follows:
                    990:
                    991:        -1 = not filled
                    992:         0 = black
                    993:        ...  values from 1 to 19 are shades of grey, from darker to lighter
                    994:        20 = white
                    995:        21-40 not used
                    996:        41-56 see patterns for colors, below
                    997:
                    998:     For BLACK or DEFAULT color, the area fill field is defined as follows:
                    999:
                   1000:        -1 = not filled
                   1001:         0 = white
                   1002:        ...  values from 1 to 19 are shades of grey, from lighter to darker
                   1003:        20 = black
                   1004:        21-40 not used
                   1005:        41-56 see patterns for colors, below
                   1006:
                   1007:     For all other colors, the area fill field is defined as follows:
                   1008:
                   1009:        -1 = not filled
                   1010:         0 = black
                   1011:        ...  values from 1 to 19 are "shades" of the color, from darker to lighter.
                   1012:                A shade is defined as the color mixed with black
                   1013:        20 = full saturation of the color
                   1014:        ...  values from 21 to 39 are "tints" of the color from the color to white.
                   1015:                A tint is defined as the color mixed with white
                   1016:        40 = white
                   1017:        41 = 30 degree left diagonal pattern
                   1018:        42 = 30 degree right diagonal pattern
                   1019:        43 = 30 degree crosshatch
                   1020:        44 = 45 degree left diagonal pattern
                   1021:        45 = 45 degree right diagonal pattern
                   1022:        46 = 45 degree crosshatch
                   1023:        47 = bricks
                   1024:        48 = circles
                   1025:        49 = horizontal lines
                   1026:        50 = vertical lines
                   1027:        51 = crosshatch
                   1028:        52 = fish scales
                   1029:        53 = small fish scales
                   1030:        54 = octagons
                   1031:        55 = horizontal "tire treads"
                   1032:        56 = vertical "tire treads"
                   1033:
                   1034:     The depth field is defined as follows:
                   1035:
                   1036:         0 ... 999 where larger value means object is deeper than (under)
                   1037:                   objects with smaller depth
                   1038:
                   1039:     The line_style field is defined as follows:
                   1040:
                   1041:        -1 = Default
                   1042:         0 = Solid
                   1043:         1 = Dashed
                   1044:         2 = Dotted
                   1045:
                   1046:     The style_val field is defined as the length, in 1/80 inches, of the on/off
                   1047:     dashes for dashed lines, and the distance between the dots, in 1/80 inches,
                   1048:     for dotted lines.
                   1049:
                   1050:     The join_style field is defined FOR LINES only as follows:
                   1051:
                   1052:         0 = Miter (the default in xfig 2.1 and earlier)
                   1053:         1 = Bevel
                   1054:         2 = Round
                   1055:
                   1056:     The cap_style field is defined FOR LINES, OPEN SPLINES and ARCS only as follows:
                   1057:
                   1058:         0 = Butt (the default in xfig 2.1 and earlier)
                   1059:         1 = Round
                   1060:         2 = Projecting
                   1061:
                   1062:     The arrow_type field is defined for LINES, ARCS and OPEN SPLINES
                   1063:     only as follows:
                   1064:
                   1065:         0 = Stick-type (the default in xfig 2.1 and earlier)
                   1066:         1 = Closed triangle:
                   1067:                |\
                   1068:                |  \
                   1069:                |    \
                   1070:                |    /
                   1071:                |  /
                   1072:                |/
                   1073:         2 = Closed with "indented" butt:
                   1074:                |\
                   1075:                \  \
                   1076:                 \   \
                   1077:                  \    \
                   1078:                  /    /
                   1079:                 /   /
                   1080:                /  /
                   1081:                |/
                   1082:         3 = Closed with "pointed" butt:
                   1083:                   |\
                   1084:                  /   \
                   1085:                 /      \
                   1086:                /         \
                   1087:                \         /
                   1088:                 \      /
                   1089:                  \   /
                   1090:                   |/
                   1091:
                   1092:     The arrow_style field is defined for LINES, ARCS and OPEN SPLINES
                   1093:     only as follows:
                   1094:
                   1095:         0 = Hollow (actually filled with white)
                   1096:         1 = Filled with pen_color
                   1097:
                   1098: (3.0) OBJECT DEFINITION:
                   1099:
                   1100:     (3.1) Color Pseudo-objects (user-defined colors)
                   1101:          This is used to define arbitrary colors beyond the 32 standard colors.
                   1102:          The color objects must be defined before any other Fig objects.
                   1103:
                   1104:     First line:
                   1105:        type    name                    (brief description)
                   1106:        ----    ----                    -------------------
                   1107:        int     object_code             (always 0)
                   1108:        int     color_number            (color number, from 32-543 (512 total))
                   1109:      hex string        rgb values              (hexadecimal string describing red,
                   1110:                                         green and blue values (e.g. #330099) )
                   1111:
                   1112:     (3.2) ARC
                   1113:
                   1114:     First line:
                   1115:        type    name                    (brief description)
                   1116:        ----    ----                    -------------------
                   1117:        int     object_code             (always 5)
                   1118:        int     sub_type                (0: pie-wedge (closed)
                   1119:                                         1: open ended arc)
                   1120:        int     line_style              (enumeration type)
                   1121:        int     line_thickness          (1/80 inch)
                   1122:        int     pen_color               (enumeration type, pen color)
                   1123:        int     fill_color              (enumeration type, fill color)
                   1124:        int     depth                   (enumeration type)
                   1125:        int     pen_style               (pen style, not used)
                   1126:        int     area_fill               (enumeration type, -1 = no fill)
                   1127:        float   style_val               (1/80 inch)
                   1128:        int     cap_style               (enumeration type)
                   1129:        int     direction               (0: clockwise, 1: counterclockwise)
                   1130:        int     forward_arrow           (0: no forward arrow, 1: on)
                   1131:        int     backward_arrow          (0: no forward arrow, 1: on)
                   1132:        float   center_x, center_y      (center of the arc)
                   1133:        int     x1, y1                  (Fig units, the 1st point the user entered)
                   1134:        int     x2, y2                  (Fig units, the 2nd point)
                   1135:        int     x3, y3                  (Fig units, the last point)
                   1136:
                   1137:     Forward arrow line (Optional; absent if forward_arrow is 0):
                   1138:        type    name                    (brief description)
                   1139:        ----    ----                    -------------------
                   1140:        int     arrow_type              (enumeration type)
                   1141:        int     arrow_style             (enumeration type)
                   1142:        float   arrow_thickness         (1/80 inch)
                   1143:        float   arrow_width             (Fig units)
                   1144:        float   arrow_height            (Fig units)
                   1145:
                   1146:     Backward arrow line (Optional; absent if backward_arrow is 0):
                   1147:        type    name                    (brief description)
                   1148:        ----    ----                    -------------------
                   1149:        int     arrow_type              (enumeration type)
                   1150:        int     arrow_style             (enumeration type)
                   1151:        float   arrow_thickness         (1/80 inch)
                   1152:        float   arrow_width             (Fig units)
                   1153:        float   arrow_height            (Fig units)
                   1154:
                   1155:     (3.3) COMPOUND
                   1156:
                   1157:     A line with object code 6 signifies the start of a compound.
                   1158:     There are four more numbers on this line which indicate the
                   1159:     upper right corner and the lower left corner of the bounding
                   1160:     box of this compound.  A line with object code -6 signifies
                   1161:     the end of the compound.  Compound may be nested.
                   1162:
                   1163:     First line:
                   1164:        type    name                    (brief description)
                   1165:        ----    ----                    -------------------
                   1166:        int     object_code             (always 6)
                   1167:        int     upperright_corner_x     (Fig units)
                   1168:        int     upperright_corner_y     (Fig units)
                   1169:        int     lowerleft_corner_x      (Fig units)
                   1170:        int     lowerleft_corner_y      (Fig units)
                   1171:
                   1172:     Subsequent lines:
                   1173:        objects
                   1174:        .
                   1175:        .
                   1176:
                   1177:     Last line:
                   1178:        -6
                   1179:
                   1180:     (3.4) ELLIPSE
                   1181:
                   1182:     First line:
                   1183:        type    name                    (brief description)
                   1184:        ----    ----                    -------------------
                   1185:        int     object_code             (always 1)
                   1186:        int     sub_type                (1: ellipse defined by radiuses
                   1187:                                         2: ellipse defined by diameters
                   1188:                                         3: circle defined by radius
                   1189:                                         4: circle defined by diameter)
                   1190:        int     line_style              (enumeration type)
                   1191:        int     thickness               (1/80 inch)
                   1192:        int     pen_color               (enumeration type, pen color)
                   1193:        int     fill_color              (enumeration type, fill color)
                   1194:        int     depth                   (enumeration type)
                   1195:        int     pen_style               (pen style, not used)
                   1196:        int     area_fill               (enumeration type, -1 = no fill)
                   1197:        float   style_val               (1/80 inch)
                   1198:        int     direction               (always 1)
                   1199:        float   angle                   (radians, the angle of the x-axis)
                   1200:        int     center_x, center_y      (Fig units)
                   1201:        int     radius_x, radius_y      (Fig units)
                   1202:        int     start_x, start_y        (Fig units; the 1st point entered)
                   1203:        int     end_x, end_y            (Fig units; the last point entered)
                   1204:
                   1205:     (3.5) POLYLINE
                   1206:
                   1207:     First line:
                   1208:        type    name                    (brief description)
                   1209:        ----    ----                    -------------------
                   1210:        int     object_code             (always 2)
                   1211:        int     sub_type                (1: polyline
                   1212:                                         2: box
                   1213:                                         3: polygon
                   1214:                                         4: arc-box)
                   1215:                                         5: imported-picture bounding-box)
                   1216:        int     line_style              (enumeration type)
                   1217:        int     thickness               (1/80 inch)
                   1218:        int     pen_color               (enumeration type, pen color)
                   1219:        int     fill_color              (enumeration type, fill color)
                   1220:        int     depth                   (enumeration type)
                   1221:        int     pen_style               (pen style, not used)
                   1222:        int     area_fill               (enumeration type, -1 = no fill)
                   1223:        float   style_val               (1/80 inch)
                   1224:        int     join_style              (enumeration type)
                   1225:        int     cap_style               (enumeration type, only used for POLYLINE)
                   1226:        int     radius                  (1/80 inch, radius of arc-boxes)
                   1227:        int     forward_arrow           (0: off, 1: on)
                   1228:        int     backward_arrow          (0: off, 1: on)
                   1229:        int     npoints                 (number of points in line)
                   1230:
                   1231:     Forward arrow line: same as ARC object
                   1232:
                   1233:     Backward arrow line: same as ARC object
                   1234:
                   1235:     Points line:
                   1236:        type    name                    (brief description)
                   1237:        ----    ----                    -------------------
                   1238:        int     x1, y1                  (Fig units)
                   1239:        int     x2, y2                  (Fig units)
                   1240:          .
                   1241:          .
                   1242:        int     xnpoints ynpoints       (this will be the same as the 1st
                   1243:                                        point for polygon and box)
                   1244:
                   1245:     PIC line:
                   1246:        type    name                    (brief description)
                   1247:        ----    ----                    -------------------
                   1248:        boolean flipped                 orientation = normal (0) or flipped (1)
                   1249:        char    file[]                  name of picture file to import
                   1250:
                   1251:     (3.6) SPLINE
                   1252:
                   1253:     First line:
                   1254:        type    name                    (brief description)
                   1255:        ----    ----                    -------------------
                   1256:        int     object_code             (always 3)
                   1257:        int     sub_type                (0: open spline
                   1258:                                         1: closed spline
                   1259:                                         2: open interpolated spline
                   1260:                                         3: closed interpolated spline)
                   1261:        int     line_style              (See the end of this section)
                   1262:        int     thickness               (1/80 inch)
                   1263:        int     pen_color               (enumeration type, pen color)
                   1264:        int     fill_color              (enumeration type, fill color)
                   1265:        int     depth                   (enumeration type)
                   1266:        int     pen_style               (pen style, not used)
                   1267:        int     area_fill               (enumeration type, -1 = no fill)
                   1268:        float   style_val               (1/80 inch)
                   1269:        int     cap_style               (enumeration type, only used for open splines)
                   1270:        int     forward_arrow           (0: off, 1: on)
                   1271:        int     backward_arrow          (0: off, 1: on)
                   1272:        int     npoints                 (number of control points in spline)
                   1273:
                   1274:     Forward arrow line: same as ARC object
                   1275:
                   1276:     Backward arrow line: same as ARC object
                   1277:
                   1278:     Points line: same as POLYLINE object
                   1279:
                   1280:     Control points line (absent if sub_type is 0 or 1):
                   1281:        Control points of interpolated spline.  There are two control
                   1282:        points for each knots.  A section i, of the spline is drawn
                   1283:        using Bezier cubic with the following four points:
                   1284:                (x ,y ), (rx ,ry ), (lx   , ly   ), (x   , y   ).
                   1285:                  i  i      i   i      i+1    i+1     i+1   i+1
                   1286:        For closed interpolated spline the last pair of control points,
                   1287:        (lxnpoints,lynpoints) and (rxnpoints,rynpoints) (which can be ignored),
                   1288:        are the same as (lx1,ly1) and (rx1,ry1) respectively.
                   1289:
                   1290:        type    name                    (brief description)
                   1291:        ----    ----                    -------------------
                   1292:        float   lx1, ly1                (Fig units)
                   1293:        float   rx1, ry1                (Fig units)
                   1294:        float   lx2, ly2                (Fig units)
                   1295:        float   rx2, ry2                (Fig units)
                   1296:          .
                   1297:          .
                   1298:        float   lxnpoints, lynpoints    (Fig units)
                   1299:        float   rxnpoints, rynpoints    (Fig units)
                   1300:
                   1301:     (3.7) TEXT
                   1302:        type    name                    (brief description)
                   1303:        ----    ----                    -------------------
                   1304:        int     object                  (always 4)
                   1305:        int     sub_type                (0: Left justified
                   1306:                                         1: Center justified
                   1307:                                         2: Right justified)
                   1308:        int     color                   (enumeration type)
                   1309:        int     depth                   (enumeration type)
                   1310:        int     pen_style               (enumeration , not used)
                   1311:        int     font                    (enumeration type)
                   1312:        float   font_size               (font size in points)
                   1313:        float   angle                   (radians, the angle of the text)
                   1314:        int     font_flags              (bit vector)
                   1315:        float   height                  (Fig units)
                   1316:        float   length                  (Fig units)
                   1317:        int     x, y                    (Fig units, coordinate of the origin
                   1318:                                         of the string.  If sub_type = 0, it is
                   1319:                                         the lower left corner of the string.
                   1320:                                         If sub_type = 1, it is the lower
                   1321:                                         center.  Otherwise it is the lower
                   1322:                                         right corner of the string.)
                   1323:        char    string[]                (ASCII characters; starts after a blank
                   1324:                                         character following the last number and
                   1325:                                         ends before the sequence '\001'.  This
                   1326:                                         sequence is not part of the string.
                   1327:                                         Characters above octal 177 are
                   1328:                                         represented by \xxx where xxx is the
                   1329:                                         octal value.  This permits Fig files to
                   1330:                                         be edited with 7-bit editors and sent
                   1331:                                         by e-mail without data loss.
                   1332:                                         Note that the string may contain '\n'.)
                   1333:
                   1334:     The font_flags field is defined as follows:
                   1335:
                   1336:         Bit    Description
                   1337:
                   1338:          0     Rigid text (text doesn't scale when scaling compound objects)
                   1339:          1     Special text (for LaTeX)
                   1340:          2     PostScript font (otherwise LaTeX font is used)
                   1341:          3     Hidden text
                   1342:
                   1343:     The font field is defined as follows:
                   1344:
                   1345:        For font_flags bit 2 = 0 (LaTeX fonts):
                   1346:
                   1347:         0      Default font
                   1348:         1      Roman
                   1349:         2      Bold
                   1350:         3      Italic
                   1351:         4      Sans Serif
                   1352:         5      Typewriter
                   1353:
                   1354:        For font_flags bit 3 = 1 (PostScript fonts):
                   1355:
                   1356:        -1      Default font
                   1357:         0      Times Roman
                   1358:         1      Times Italic
                   1359:         2      Times Bold
                   1360:         3      Times Bold Italic
                   1361:         4      AvantGarde Book
                   1362:         5      AvantGarde Book Oblique
                   1363:         6      AvantGarde Demi
                   1364:         7      AvantGarde Demi Oblique
                   1365:         8      Bookman Light
                   1366:         9      Bookman Light Italic
                   1367:        10      Bookman Demi
                   1368:        11      Bookman Demi Italic
                   1369:        12      Courier
                   1370:        13      Courier Oblique
                   1371:        14      Courier Bold
                   1372:        15      Courier Bold Oblique
                   1373:        16      Helvetica
                   1374:        17      Helvetica Oblique
                   1375:        18      Helvetica Bold
                   1376:        19      Helvetica Bold Oblique
                   1377:        20      Helvetica Narrow
                   1378:        21      Helvetica Narrow Oblique
                   1379:        22      Helvetica Narrow Bold
                   1380:        23      Helvetica Narrow Bold Oblique
                   1381:        24      New Century Schoolbook Roman
                   1382:        25      New Century Schoolbook Italic
                   1383:        26      New Century Schoolbook Bold
                   1384:        27      New Century Schoolbook Bold Italic
                   1385:        28      Palatino Roman
                   1386:        29      Palatino Italic
                   1387:        30      Palatino Bold
                   1388:        31      Palatino Bold Italic
                   1389:        32      Symbol
                   1390:        33      Zapf Chancery Medium Italic
                   1391:        34      Zapf Dingbats
                   1392: */
                   1393:
                   1394: #endif

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