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

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

1.1       maekawa     1: /*
                      2:  * $Id: corel.trm,v 1.12 1998/04/14 00:17:35 drd Exp $
                      3:  */
                      4:
                      5: /*
                      6:    corel.trm
                      7:
                      8:    A modified ai.trm for CorelDraw import filters
                      9:    by Chris Parks, parks@physics.purdue.edu
                     10:    Import from CorelDraw with the CorelTrace filter
                     11:
                     12:    syntax: set terminal default
                     13:            set terminal mode "fontname" fontsize,xsize,ysize,linewidth
                     14:
                     15:            mode= color or monochrome             (default=mono)
                     16:            "fontname"= postscript font name      (default="SwitzerlandLight")
                     17:            fontsize  = size of font in points    (default=22pt)
                     18:            xsize     = width of page in inches   (default=8.2in)
                     19:            ysize     = height of page in inches  (default=10in)
                     20:            linewidth = width of lines in points  (default=1.2pt)
                     21:
                     22: */
                     23:
                     24: /*
                     25:  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
                     26:  */
                     27:
                     28: #include "driver.h"
                     29:
                     30: #ifdef TERM_REGISTER
                     31: register_term(corel)
                     32: #endif
                     33:
                     34: #ifdef TERM_PROTO
                     35: TERM_PUBLIC void COREL_options __PROTO((void));
                     36: TERM_PUBLIC void COREL_init __PROTO((void));
                     37: TERM_PUBLIC void COREL_graphics __PROTO((void));
                     38: TERM_PUBLIC void COREL_text __PROTO((void));
                     39: TERM_PUBLIC void COREL_reset __PROTO((void));
                     40: TERM_PUBLIC void COREL_linetype __PROTO((int linetype));
                     41: TERM_PUBLIC void COREL_move __PROTO((unsigned int x, unsigned int y));
                     42: TERM_PUBLIC void COREL_vector __PROTO((unsigned int x, unsigned int y));
                     43: TERM_PUBLIC void COREL_put_text __PROTO((unsigned int x, unsigned int y,
                     44:                                         char *str));
                     45: TERM_PUBLIC int COREL_text_angle __PROTO((int ang));
                     46: TERM_PUBLIC int COREL_justify_text __PROTO((enum JUSTIFY mode));
                     47: #define CORELD_XMAX  5960      /* 8.2 inches wide */
                     48: #define CORELD_YMAX  7200      /* 10 inches high  */
                     49: #define CORELD_VTIC  (CORELD_YMAX/80)
                     50: #define CORELD_HTIC  (CORELD_YMAX/80)
                     51: #define CORELD_VCHAR (22*COREL_SC)     /* default is 22 point characters */
                     52: #define CORELD_HCHAR (22*COREL_SC*6/10)
                     53: #endif
                     54:
                     55: #ifndef TERM_PROTO_ONLY
                     56: #ifdef TERM_BODY
                     57:
                     58: /* plots for publication should be sans-serif (don't use TimesRoman) */
                     59: char corel_font[MAX_ID_LEN + 1] = "SwitzerlandLight";  /* name of font */
                     60: int corel_fontsize = 22;       /* size of font in pts */
                     61: TBOOLEAN corel_color = FALSE;
                     62: TBOOLEAN corel_stroke = FALSE;
                     63: int corel_path_count = 0;      /* count of lines in path */
                     64: int corel_ang = 0;             /* text angle */
                     65: enum JUSTIFY corel_justify = LEFT;     /* text is flush left */
                     66:
                     67:
                     68: /* default mode constants */
                     69: #define CORELD_XOFF  0         /* page offset in pts */
                     70: #define CORELD_YOFF  0
                     71: #define COREL_SC     (10.0)    /* scale is 1pt = 10 units */
                     72: #define CORELD_LW    (1.2*COREL_SC)    /* linewidth = 1.2 pts */
                     73:
                     74: unsigned int corel_xmax = CORELD_XMAX;
                     75: unsigned int corel_ymax = CORELD_YMAX;
                     76: float corel_lw = CORELD_LW;
                     77:
                     78: TERM_PUBLIC void COREL_options()
                     79: {
                     80:     struct value a;
                     81:
                     82:     if (!END_OF_COMMAND && almost_equals(c_token, "def$ault")) {
                     83:        corel_color = FALSE;
                     84:        strcpy(corel_font, "SwitzerlandLight");
                     85:        corel_fontsize = 22;
                     86:        corel_lw = CORELD_LW;
                     87:        corel_xmax = CORELD_XMAX;
                     88:        corel_ymax = CORELD_YMAX;
                     89:        c_token++;
                     90:     }
                     91:     if (!END_OF_COMMAND && almost_equals(c_token, "mono$chrome")) {
                     92:        corel_color = FALSE;
                     93:        c_token++;
                     94:     } else if (!END_OF_COMMAND && (almost_equals(c_token, "color$")
                     95:                                   || almost_equals(c_token, "colour$"))) {
                     96:        corel_color = TRUE;
                     97:        c_token++;
                     98:     }
                     99:     if (!END_OF_COMMAND && isstring(c_token)) {
                    100:        quote_str(corel_font, c_token, MAX_ID_LEN);
                    101:        c_token++;
                    102:     }
                    103:     if (!END_OF_COMMAND) {
                    104:        /* We have font size specified */
                    105:        corel_fontsize = (int) real(const_express(&a));
                    106:        c_token++;
                    107:        term->v_char = (unsigned int) (corel_fontsize * COREL_SC);
                    108:        term->h_char = (unsigned int) (corel_fontsize * COREL_SC * 6 / 10);
                    109:     }
                    110:     if (!END_OF_COMMAND) {
                    111:        corel_xmax = (unsigned int) (real(const_express(&a)) * 720);
                    112:        c_token++;
                    113:        if (!END_OF_COMMAND) {
                    114:            corel_ymax = (unsigned int) (real(const_express(&a)) * 720);
                    115:            c_token++;
                    116:        }
                    117:        term->xmax = corel_xmax;
                    118:        term->ymax = corel_ymax;
                    119:        term->v_tic = corel_ymax / 80;
                    120:        term->h_tic = corel_ymax / 80;
                    121:     }
                    122:     if (!END_OF_COMMAND) {
                    123:        corel_lw = real(const_express(&a)) * COREL_SC;
                    124:        c_token++;
                    125:     }
                    126:     sprintf(term_options, "%s \"%s\" %d,%0.1f,%0.1f,%0.1f",
                    127:            corel_color ? "color" : "monochrome", corel_font,
                    128:            corel_fontsize, corel_xmax / 720.0, corel_ymax / 720.0,
                    129:            corel_lw / COREL_SC);
                    130: }
                    131:
                    132: TERM_PUBLIC void COREL_init()
                    133: {
                    134:     fprintf(gpoutfile, "\
                    135: %%!PS-Adobe-2.0 EPSF-1.2\n\
                    136: %%%%BoundingBox: %d %d %d %d\n\
                    137: %%%%TemplateBox: %d %d %d %d\n\
                    138: %%%%EndComments\n\
                    139: %%%%EndProlog\n\
                    140: %%%%BeginSetup\n%%%%EndSetup\n",
                    141:            CORELD_XOFF, CORELD_YOFF,
                    142:            (int) ((corel_xmax) / COREL_SC + 0.5 + CORELD_XOFF),
                    143:            (int) ((corel_ymax) / COREL_SC + 0.5 + CORELD_YOFF),
                    144:            CORELD_XOFF, CORELD_YOFF,
                    145:            (int) ((corel_xmax) / COREL_SC + 0.5 + CORELD_XOFF),
                    146:            (int) ((corel_ymax) / COREL_SC + 0.5 + CORELD_YOFF));
                    147: }
                    148:
                    149:
                    150: TERM_PUBLIC void COREL_graphics()
                    151: {
                    152:     corel_path_count = 0;
                    153:     corel_stroke = FALSE;
                    154: }
                    155:
                    156:
                    157: TERM_PUBLIC void COREL_text()
                    158: {
                    159:     if (corel_stroke) {
                    160:        fputs("S\n", gpoutfile);
                    161:        corel_stroke = FALSE;
                    162:     }
                    163:     corel_path_count = 0;
                    164: }
                    165:
                    166:
                    167: TERM_PUBLIC void COREL_reset()
                    168: {
                    169:     fputs("%%%%Trailer\n", gpoutfile);
                    170: }
                    171:
                    172:
                    173: TERM_PUBLIC void COREL_linetype(linetype)
                    174: int linetype;
                    175: {
                    176:     if (corel_stroke) {
                    177:        fputs("S\n", gpoutfile);
                    178:        corel_stroke = FALSE;
                    179:     }
                    180:     switch (linetype) {
                    181:     case -2:
                    182:        fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
                    183:        if (corel_color) {
                    184:            fputs("0 0 0 1 K\n", gpoutfile);
                    185:        } else {
                    186:            fputs("\
                    187: [] 0 d\n\
                    188: 0 j\n0 G\n", gpoutfile);
                    189:        }
                    190:        break;
                    191:
                    192:     case -1:
                    193:        fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
                    194:        if (corel_color) {
                    195:            fputs("0 0 0 1 K\n", gpoutfile);
                    196:        } else {
                    197:            fputs("\
                    198: [1 2] 0 d\n\
                    199: 0 j\n0 G\n", gpoutfile);
                    200:        }
                    201:        break;
                    202:
                    203:     case 0:
                    204:        fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
                    205:        if (corel_color) {
                    206:            fputs("1 0 1 0 K\n", gpoutfile);
                    207:        } else {
                    208:            fputs("\
                    209: [] 0 d\n\
                    210: 2 j\n0 G\n", gpoutfile);
                    211:        }
                    212:        break;
                    213:
                    214:     case 1:
                    215:        fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
                    216:        if (corel_color) {
                    217:            fputs("1 1 0 0 K\n", gpoutfile);
                    218:        } else {
                    219:            fputs("\
                    220: [4 2] 0 d\n\
                    221: 2 j\n0 G\n", gpoutfile);
                    222:        }
                    223:        break;
                    224:
                    225:     case 2:
                    226:        fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
                    227:        if (corel_color) {
                    228:            fputs("0 1 1 0 K\n", gpoutfile);
                    229:        } else {
                    230:            fputs("\
                    231: [2 3] 0 d\n\
                    232: 2 j\n0 G\n", gpoutfile);
                    233:        }
                    234:        break;
                    235:
                    236:     case 3:
                    237:        fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
                    238:        if (corel_color) {
                    239:            fputs("0 1 0 0 K\n", gpoutfile);
                    240:        } else {
                    241:            fputs("\
                    242: [1 1.5] 0 d\n\
                    243: 2 j\n0 G\n", gpoutfile);
                    244:        }
                    245:        break;
                    246:
                    247:     case 4:
                    248:        fprintf(gpoutfile, "%f w\n", corel_lw / COREL_SC);
                    249:        if (corel_color) {
                    250:            fputs("1 0 0 0 K\n", gpoutfile);
                    251:        } else {
                    252:            fputs("\
                    253: [5 2 1 2] 0 d\n\
                    254: 2 j\n0 G\n", gpoutfile);
                    255:        }
                    256:        break;
                    257:
                    258:     case 5:
                    259:        fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
                    260:        if (corel_color) {
                    261:            fputs("0 0 1 0 K\n", gpoutfile);
                    262:        } else {
                    263:            fputs("\
                    264: [4 3 1 3] 0 d\n\
                    265: 2 j\n0 G\n", gpoutfile);
                    266:        }
                    267:        break;
                    268:
                    269:     case 6:
                    270:        fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
                    271:        if (corel_color) {
                    272:            fputs("0 0 0 1 K\n", gpoutfile);
                    273:        } else {
                    274:            fputs("\
                    275: [2 2 2 4] 0 d\n\
                    276: 2 j\n0 G\n", gpoutfile);
                    277:        }
                    278:        break;
                    279:
                    280:     case 7:
                    281:        fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
                    282:        if (corel_color) {
                    283:            fputs("0 0.7 1 0 K\n", gpoutfile);
                    284:        } else {
                    285:            fputs("\
                    286: [2 2 2 2 2 4] 0 d\n\
                    287: 2 j\n0 G\n", gpoutfile);
                    288:        }
                    289:        break;
                    290:
                    291:     case 8:
                    292:        fprintf(gpoutfile, "%.2f w\n", corel_lw / COREL_SC);
                    293:        if (corel_color) {
                    294:            fputs("0.5 0.5 0.5 0 K\n", gpoutfile);
                    295:        } else {
                    296:            fputs("\
                    297: [2 2 2 2 2 2 2 4] 0 d\n\
                    298: 2 j\n0 G\n", gpoutfile);
                    299:        }
                    300:        break;
                    301:     }
                    302:     corel_path_count = 0;
                    303: }
                    304:
                    305:
                    306: TERM_PUBLIC void COREL_move(x, y)
                    307: unsigned int x, y;
                    308: {
                    309:     if (corel_stroke)
                    310:        fputs("S\n", gpoutfile);
                    311:     fprintf(gpoutfile, "%0.2f %0.2f m\n", x / COREL_SC, y / COREL_SC);
                    312:     corel_path_count += 1;
                    313:     corel_stroke = TRUE;
                    314: }
                    315:
                    316:
                    317: TERM_PUBLIC void COREL_vector(x, y)
                    318: unsigned int x, y;
                    319: {
                    320:     fprintf(gpoutfile, "%.2f %.2f l\n", x / COREL_SC, y / COREL_SC);
                    321:     corel_path_count += 1;
                    322:     corel_stroke = TRUE;
                    323:     if (corel_path_count >= 400) {
                    324:        fprintf(gpoutfile, "S\n%.2f %.2f m\n", x / COREL_SC, y / COREL_SC);
                    325:        corel_path_count = 0;
                    326:     }
                    327: }
                    328:
                    329:
                    330: TERM_PUBLIC void COREL_put_text(x, y, str)
                    331: unsigned int x, y;
                    332: char *str;
                    333: {
                    334:     char ch;
                    335:     if (corel_stroke) {
                    336:        fputs("S\n", gpoutfile);
                    337:        corel_stroke = FALSE;
                    338:     }
                    339:     switch (corel_justify) {
                    340:     case LEFT:
                    341:        fprintf(gpoutfile, "/_%s %d %d 0 0 z\n",
                    342:                corel_font, corel_fontsize, corel_fontsize);
                    343:        break;
                    344:     case CENTRE:
                    345:        fprintf(gpoutfile, "/_%s %d %d 0 1 z\n",
                    346:                corel_font, corel_fontsize, corel_fontsize);
                    347:        break;
                    348:     case RIGHT:
                    349:        fprintf(gpoutfile, "/_%s %d %d 0 2 z\n",
                    350:                corel_font, corel_fontsize, corel_fontsize);
                    351:        break;
                    352:     }
                    353:     if (corel_ang == 0) {
                    354:        fprintf(gpoutfile, "[1 0 0 1 %.2f %.2f]e\n0 g\n",
                    355:                x / COREL_SC, y / COREL_SC - corel_fontsize / 3.0);
                    356:     } else {
                    357:        fprintf(gpoutfile, "[0 1 -1 0 %.2f %.2f]e\n0 g\n",
                    358:                x / COREL_SC - corel_fontsize / 3.0, y / COREL_SC);
                    359:     }
                    360:
                    361:     putc('(', gpoutfile);
                    362:     ch = *str++;
                    363:     while (ch != NUL) {
                    364:        if ((ch == '(') || (ch == ')') || (ch == '\\'))
                    365:            putc('\\', gpoutfile);
                    366:        putc(ch, gpoutfile);
                    367:        ch = *str++;
                    368:     }
                    369:     fputs(")t\nT\n", gpoutfile);
                    370:     corel_path_count = 0;
                    371: }
                    372:
                    373: TERM_PUBLIC int COREL_text_angle(ang)
                    374: int ang;
                    375: {
                    376:     corel_ang = ang;
                    377:     return TRUE;
                    378: }
                    379:
                    380: TERM_PUBLIC int COREL_justify_text(mode)
                    381: enum JUSTIFY mode;
                    382: {
                    383:     corel_justify = mode;
                    384:     return TRUE;
                    385: }
                    386:
                    387: #endif /* TERM_BODY */
                    388:
                    389: #ifdef TERM_TABLE
                    390:
                    391: TERM_TABLE_START(corel_driver)
                    392:     "corel", "EPS format for CorelDRAW",
                    393:     CORELD_XMAX, CORELD_YMAX, CORELD_VCHAR, CORELD_HCHAR,
                    394:     CORELD_VTIC, CORELD_HTIC, COREL_options, COREL_init, COREL_reset,
                    395:     COREL_text, null_scale, COREL_graphics, COREL_move, COREL_vector,
                    396:     COREL_linetype, COREL_put_text, COREL_text_angle,
                    397:     COREL_justify_text, do_point, do_arrow, set_font_null
                    398: TERM_TABLE_END(corel_driver)
                    399:
                    400: #undef LAST_TERM
                    401: #define LAST_TERM corel_driver
                    402:
                    403: #endif /* TERM_TABLE */
                    404: #endif /* TERM_PROTO_ONLY */
                    405:
                    406: #ifdef TERM_HELP
                    407: START_HELP(corel)
                    408: "1 corel",
                    409: "?commands set terminal corel",
                    410: "?set terminal corel",
                    411: "?set term corel",
                    412: "?terminal corel",
                    413: "?term corel",
                    414: "?corel",
                    415: " The `corel` terminal driver supports CorelDraw.",
                    416: "",
                    417: " Syntax:",
                    418: "       set terminal corel {  default",
                    419: "                           | {monochrome | color",
                    420: "                                {<fontname> {\"<fontsize>\" ",
                    421: "                                   {<xsize> <ysize> {<linewidth> }}}}}",
                    422: "",
                    423: " where the fontsize and linewidth are specified in points and the sizes in",
                    424: " inches.  The defaults are monochrome, \"SwitzerlandLight\", 22, 8.2, 10 and 1.2."
                    425: END_HELP(corel)
                    426: #endif /* TERM_HELP */

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