Annotation of OpenXM_contrib/gnuplot/term/cgm.trm, Revision 1.1.1.3
1.1.1.3 ! ohara 1: /*
! 2: * $Id: cgm.trm,v 1.16.2.8 2002/12/04 19:31:09 lhecking Exp $
1.1 maekawa 3: */
4:
5: /* GNUPLOT - cgm.trm */
6:
7: /*[
8: * Copyright 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 and ../docs/termdoc.c.
39: *
40: * This terminal driver supports:
41: * Computer Graphics Metafile
42: *
43: * TODO
44: * better control over plot size (never cutting off labels, correct font
45: * sizes)
1.1.1.3 ! ohara 46:
! 47: * REFERENCES
! 48: *
! 49: * ISO 8632-1:1992 Computer Graphics Metafile (CGM), Part 1,
! 50: * Functional Specification.
! 51: *
! 52: * ISO 8632-1:1992 Computer Graphics Metafile (CGM), Part 3,
! 53: * Binary Encoding.
! 54: *
! 55: * FIPS PUB 128 - Computer Graphics Metafile (CGM).
! 56: *
! 57: * MIL-STD-2301A Computer Graphics Metafile (CGM) Implementation
! 58: * Standard for the National Imagery Transmission Format Standard, 5
! 59: * June 1998, http://164.214.2.51/ntb/baseline/docs/2301a/. Only a
! 60: * subset of CGM version 1, but does include the binary format for
! 61: * that subset.
! 62: *
! 63: * MIL-D-28003A "Digital Representation for Communication of
! 64: * Illustration Data: CGM Application Profile", 15 November 1991,
! 65: * http://www-cals.itsi.disa.mil/core/standards/28003aa1.pdf.
! 66: *
! 67: * "The computer graphics metafile", Lofton R. Henderson and Anne
! 68: * M. Mumford, Butterworths, London, 1990, ISBN 0-408-02680-4.
1.1 maekawa 69: *
70: * AUTHOR
71: * Jim Van Zandt <jrv@vanzandt.mv.com>
72: *
1.1.1.3 ! ohara 73: * send your comments or suggestions to the author or
! 74: * info-gnuplot@dartmouth.edu.
1.1 maekawa 75: */
76:
77: #include "driver.h"
78:
79: #ifdef TERM_REGISTER
80: register_term(cgm)
81: #endif
82:
83: #ifdef TERM_PROTO
84: TERM_PUBLIC void CGM_options __PROTO((void));
85: TERM_PUBLIC void CGM_init __PROTO((void));
86: TERM_PUBLIC void CGM_reset __PROTO((void));
87: TERM_PUBLIC void CGM_text __PROTO((void));
88: TERM_PUBLIC void CGM_graphics __PROTO((void));
89: TERM_PUBLIC void CGM_move __PROTO((unsigned int x, unsigned int y));
90: TERM_PUBLIC void CGM_dashed_vector __PROTO((unsigned int ux, unsigned int uy));
91: TERM_PUBLIC void CGM_solid_vector __PROTO((unsigned int ux, unsigned int uy));
92: TERM_PUBLIC void CGM_linetype __PROTO((int linetype));
93: TERM_PUBLIC void CGM_linecolor __PROTO((int color));
94: TERM_PUBLIC void CGM_dashtype __PROTO((int dashtype));
95: TERM_PUBLIC void CGM_linewidth __PROTO((double width));
96: TERM_PUBLIC void CGM_put_text __PROTO((unsigned int x, unsigned int y,
97: char *str));
98: TERM_PUBLIC int CGM_text_angle __PROTO((int ang));
99: TERM_PUBLIC int CGM_justify_text __PROTO((enum JUSTIFY mode));
100: TERM_PUBLIC void CGM_point __PROTO((unsigned int x, unsigned int y,
101: int number));
1.1.1.3 ! ohara 102: TERM_PUBLIC int CGM_find_font __PROTO((char *name, int len, double *relwidth));
1.1 maekawa 103: TERM_PUBLIC int CGM_set_font __PROTO((char *font));
104: TERM_PUBLIC void CGM_set_pointsize __PROTO((double size));
105:
106: #define CGM_LARGE 32767
107: #define CGM_SMALL 32767/18*13 /* aspect ratio 1:.7222 */
108: #define CGM_MARGIN (CGM_LARGE/180)
109: /* convert from plot units to pt */
110: #define CGM_PT ((term->xmax + CGM_MARGIN)/cgm_plotwidth)
111: #define CGM_LINE_TYPES 9 /* number of line types we support */
1.1.1.3 ! ohara 112: #define CGM_COLORS 8 /* number of line colors we support in
! 113: the default color table */
! 114: #define CGM_POINTS 13 /* number of markers we support */
1.1 maekawa 115: #define CGM_MAX_SEGMENTS 104 /* maximum # polyline coordinates */
116: #define CGM_VCHAR (CGM_SMALL/360*12)
117: #define CGM_HCHAR (CGM_SMALL/360*12*5/9)
118: #define CGM_VTIC (CGM_LARGE/80)
119: #define CGM_HTIC (CGM_LARGE/80)
120: #endif
121:
122: #ifndef TERM_PROTO_ONLY
123: #ifdef TERM_BODY
124:
125: /*
126: * on NeXTstep, id is an identifier (in ObjC) and causes a parse error
127: * since some asserts below are mistaken as casts. datum is a type
128: * defined in ndbm.h which also causes a parse error (ndbm.h is
129: * included as part of appkit.h, I think). Strangely enough, both
130: * errors only happen with cpp-precomp -smart, not with the regular
131: * cpp. (AL)
132: */
133:
134: #ifdef NEXT
135: #define id id_
136: #define datum datum_
137: #endif
138:
139: #include <ctype.h> /* for isspace() */
140:
141: #ifndef assert
142: #define assert(x) 0 /* defeat assertions */
143: #endif
144:
145: /* uncomment the following to enable assertions for this module only,
1.1.1.3 ! ohara 146: regardless of compiler switches
1.1 maekawa 147: #ifdef NDEBUG
148: #define DEFEAT_ASSERTIONS
149: #endif
150: #undef NDEBUG
151: #include <assert.h>
1.1.1.3 ! ohara 152: */
1.1 maekawa 153:
154: #define CGM_ADJ (sizeof(int)/sizeof(short))
155:
156: static unsigned int cgm_posx;
157: static unsigned int cgm_posy;
158: static unsigned int cgm_linetype = 1;
159: static unsigned int cgm_dashtype = 0;
160: static unsigned int cgm_color = 0;
1.1.1.3 ! ohara 161: static int cgm_polyline[CGM_MAX_SEGMENTS]; /* stored polyline coordinates */
1.1 maekawa 162: static int cgm_coords = 0; /* # polyline coordinates saved */
1.1.1.3 ! ohara 163: /* static enum JUSTIFY cgm_justify = LEFT; */ /* unused */
1.1 maekawa 164: static int cgm_step_sizes[8]; /* array of currently used dash
165: lengths in plot units */
166: static int cgm_step_index = 0; /* index into cgm_step_sizes[] */
167: static int cgm_step = 0; /* amount of current dash not yet
168: drawn, in plot units */
169: static int cgm_tic, cgm_tic707, cgm_tic866, cgm_tic500, cgm_tic1241, cgm_tic1077, cgm_tic621; /* marker dimensions */
1.1.1.3 ! ohara 170: static struct cgm_properties {
! 171: double angle; /* angle of text baseline (radians
! 172: counter-clockwise from horizontal) */
! 173: int font_index; /* font index */
! 174: int char_height; /* character height in picture units */
! 175: enum JUSTIFY justify_mode; /* how text is justified */
! 176:
! 177: int edge_visibility; /* nonzero if edge is visible */
! 178: int edge_color;
! 179: int fill_color;
! 180: } cgm_current={-1,-1,-1,(enum JUSTIFY)-1,-1,-1,-1}, /* written to file */
! 181: cgm_next={0,-2,-2,LEFT,-2,-2,-2}, /* needed for next text string/marker */
! 182: cgm_reset={-1,-1,-1,(enum JUSTIFY)-1,-1,-1,-1}; /* invalid entries */
! 183:
! 184: static int cgm_user_color_count[] = { 0 };
! 185: static int cgm_user_color_max = 0;
! 186: static int cgm_maximum_color_index[] = { CGM_COLORS };
! 187: static int GPFAR *cgm_user_color_table;
! 188: static int GPFAR cgm_default_color_table[] =
! 189: {
! 190: 0, /* starting index */
! 191: 255,255,255, /* white (the background color) */
! 192: 0,0,0, /* black */
! 193: 255,0,0, /* red */
! 194: 0,255,0, /* green */
! 195: 0,0,255, /* blue */
! 196: 255,165,0, /* orange */
! 197: 255,0,255, /* magenta */
! 198: 0,255,255, /* cyan */
! 199: 190,190,190 /* gray75 (which Windows calls "gray 25%") */
! 200: };
! 201:
! 202: struct fontdata {
! 203: char *name; /* the name of the font */
! 204: double width; /* the width of the font, relative to
! 205: Times Bold Italic. The width
! 206: adjustment can only be approximate.
! 207: Of the standard fonts, only the
! 208: four versions of "Courier" are
! 209: monospaced. Also, metrics of the
! 210: same font from different foundaries
! 211: are sometimes different. */
! 212: };
! 213:
! 214: struct fontdata GPFAR cgm_basic_font_data[]={
! 215:
! 216: /* these are WebCGM recommended fonts */
! 217: {"Helvetica",1.039},
! 218: {"Helvetica Oblique",1.099},
! 219: {"Helvetica Bold",1.083},
! 220: {"Helvetica Bold Oblique",1.011},
! 221: {"Times Roman",.981},
! 222: {"Times Bold",.985},
! 223: {"Times Italic",.959},
! 224: {"Times Bold Italic",1.0},
! 225: {"Courier",1.327},
! 226: {"Courier Bold",1.327},
! 227: {"Courier Oblique",1.218},
! 228: {"Courier Bold Oblique",1.341},
! 229: {"Symbol",.897},
! 230:
! 231: /* These are basic public domain fonts required by MIL-D-28003A */
! 232: {"Hershey/Cartographic_Roman",1.2404},
! 233: {"Hershey/Cartographic_Greek",.9094},
! 234: {"Hershey/Simplex_Roman",1.2369},
! 235: {"Hershey/Simplex_Greek",.9129},
! 236: {"Hershey/Simplex_Script",1.4181},
! 237: {"Hershey/Complex_Roman",1.1150},
! 238: {"Hershey/Complex_Greek",.9059},
! 239: {"Hershey/Complex_Script",1.3868},
! 240: {"Hershey/Complex_Italic",1.4146},
! 241: {"Hershey/Complex_Cyrillic",1.2056},
! 242: {"Hershey/Duplex_Roman",1.1707},
! 243: {"Hershey/Triplex_Roman",1.3240},
! 244: {"Hershey/Triplex_Italic",1.3310},
! 245: {"Hershey/Gothic_German",1.2056},
! 246: {"Hershey/Gothic_English",1.2021},
! 247: {"Hershey/Gothic_Italian",1.2021},
! 248: {"Hershey/Symbol_Set_1",.9059},
! 249: {"Hershey/Symbol_Set_2",.9059},
! 250: {"Hershey/Symbol_Math",.9059},
! 251:
! 252: /* These are available in the Microsoft Office import filter. By
! 253: default, the script font can apparently be accessed only via
! 254: the name "15". */
! 255: {"ZapfDingbats",1.583},
! 256: {"Script",1.139},
! 257: {"15",1.139},
! 258:
! 259: /* in the Microsoft Office and Corel Draw import filters, these
! 260: are pseudonyms for some of the above */
! 261: {"Helvetica Italic",1.099},
! 262: {"Helvetica Bold Italic",1.011},
! 263: {"Courier Italic",1.218},
! 264: {"Courier Bold Italic",1.341},
! 265: {"Times Oblique",.959},
! 266: {"Times Bold Oblique",1.0},
! 267:
! 268: {0,0}
! 269: },
! 270: *cgm_font_data = cgm_basic_font_data;
! 271:
! 272: #define DEFAULT_CGMFONT "Helvetica Bold"
1.1 maekawa 273:
274: /* variables to record the options */
1.1.1.3 ! ohara 275: static char cgm_font[32] = DEFAULT_CGMFONT;
! 276: static unsigned int cgm_fontsize = 12;
1.1 maekawa 277: static unsigned cgm_linewidth; /* line width in plot units */
278: static unsigned cgm_linewidth_pt = 1; /* line width in pt */
279: static TBOOLEAN cgm_monochrome = FALSE; /* colors enabled? */
280: static int cgm_plotwidth = 432; /* assumed width of plot in pt. */
281: static TBOOLEAN cgm_portrait = FALSE; /* portrait orientation? */
282: static TBOOLEAN cgm_rotate = TRUE; /* text rotation enabled? */
283: static TBOOLEAN cgm_dashed = TRUE; /* dashed linestyles enabled? */
1.1.1.3 ! ohara 284: static TBOOLEAN cgm_nofontlist_mode = FALSE; /* omit font list? */
1.1 maekawa 285:
286: /* prototypes for static functions */
1.1.1.3 ! ohara 287: static void CGM_local_reset __PROTO((void));
1.1 maekawa 288: static void CGM_flush_polyline __PROTO((void));
289: static void CGM_flush_polygon __PROTO((void));
290: static void CGM_write_char_record __PROTO((int class, int cgm_id, int length,
291: char *data));
292: static void CGM_write_code __PROTO((int class, int cgm_id, int length));
293: static void CGM_write_int __PROTO((int value));
294: static void CGM_write_int_record __PROTO((int class, int cgm_id, int length,
295: int *data));
296: static void CGM_write_mixed_record __PROTO((int class, int cgm_id,
297: int numint, int *int_data,
298: int numchar, char *char_data));
1.1.1.2 maekawa 299: static void CGM_write_byte_record __PROTO((int class, int cgm_id, int length,
300: char *data));
1.1 maekawa 301:
1.1.1.3 ! ohara 302: TERM_PUBLIC void
! 303: CGM_options()
! 304: {
! 305: struct value a;
! 306:
! 307: CGM_local_reset();
! 308:
! 309: while (!END_OF_COMMAND) {
! 310: if (almost_equals(c_token, "p$ortrait")) {
! 311: cgm_portrait = TRUE;
! 312: c_token++;
! 313: continue;
! 314: }
! 315: if (almost_equals(c_token, "la$ndscape")) {
! 316: cgm_portrait = FALSE;
! 317: c_token++;
! 318: continue;
! 319: }
! 320: if (almost_equals(c_token, "de$fault")) {
! 321: CGM_local_reset();
! 322: c_token++;
! 323: continue;
! 324: }
! 325: if (almost_equals(c_token, "nof$ontlist")
! 326: || almost_equals(c_token, "w$inword6")) { /* deprecated */
! 327: cgm_nofontlist_mode = TRUE;
! 328: c_token++;
! 329: continue;
! 330: }
! 331: if (almost_equals(c_token, "m$onochrome")) {
! 332: cgm_monochrome = TRUE;
! 333: c_token++;
! 334: continue;
! 335: }
! 336: if (almost_equals(c_token, "c$olor")
! 337: || almost_equals(c_token, "c$olour")) {
! 338: cgm_monochrome = FALSE;
! 339: c_token++;
! 340: continue;
! 341: }
! 342: if (almost_equals(c_token, "r$otate")) {
! 343: cgm_rotate = TRUE;
! 344: c_token++;
! 345: continue;
! 346: }
! 347: if (almost_equals(c_token, "nor$otate")) {
! 348: cgm_rotate = FALSE;
! 349: c_token++;
! 350: continue;
! 351: }
! 352: if (almost_equals(c_token, "da$shed")) {
! 353: cgm_dashed = TRUE;
! 354: c_token++;
! 355: continue;
! 356: }
! 357: if (almost_equals(c_token, "s$olid")) {
! 358: cgm_dashed = FALSE;
! 359: c_token++;
! 360: continue;
! 361: }
! 362: if (almost_equals(c_token, "li$newidth")) {
! 363: c_token++;
! 364: if (!END_OF_COMMAND) {
! 365: cgm_linewidth_pt = (unsigned int) real(const_express(&a));
! 366: if (cgm_linewidth_pt == 0 || cgm_linewidth_pt > 10000) {
! 367: int_warn("linewidth out of range", c_token);
! 368: cgm_linewidth_pt = 1;
! 369: }
! 370: c_token++;
! 371: continue;
! 372: } else {
! 373: int_error("linewidth option needs an argument", c_token);
! 374: }
! 375: }
! 376: if (almost_equals(c_token, "wid$th")) {
! 377: c_token++;
! 378: if (!END_OF_COMMAND) {
! 379: cgm_plotwidth = (int) real(const_express(&a));
! 380: if (cgm_plotwidth < 0 || cgm_plotwidth > 10000) {
! 381: int_warn("width out of range", c_token);
! 382: cgm_plotwidth = 6 * 72;
! 383: }
! 384: continue;
! 385: } else {
! 386: int_error("width option needs an argument", c_token);
! 387: }
! 388: }
! 389: if (isstring(c_token)) {
! 390: double relwidth;
! 391:
! 392: quote_str(cgm_font, c_token, MAX_ID_LEN);
! 393: if (CGM_find_font(cgm_font, strlen(cgm_font),
! 394: &relwidth) == 0) {
! 395: /* insert the font in the font table */
! 396: size_t l = strlen(cgm_font);
! 397: int n;
! 398:
! 399: for (n=0; cgm_font_data[n].name; n++)
! 400: ; /* do nothing */
! 401: if (l <= 255) {
! 402: struct fontdata *new_font_data;
! 403: int i;
! 404:
! 405: new_font_data = gp_alloc((n + 2) * sizeof(struct fontdata),
! 406: "CGM font list");
! 407: new_font_data->name = gp_alloc(l+1,"CGM font list");
! 408: strcpy(new_font_data->name, cgm_font);
! 409: /* punt, since we don't know the real font width */
! 410: new_font_data->width = 1.0;
! 411: for (i = 0; i <= n; i++)
! 412: new_font_data[i+1] = cgm_font_data[i];
! 413: cgm_font_data = new_font_data;
! 414: } /* if(name not too long */
! 415: c_token++;
! 416: continue;
! 417: } /* if (font parsing successful) */
! 418: } /* if (string) --> font name */
! 419:
! 420: if (isanumber(c_token)) {
! 421: /* the user is specifying the font size */
! 422: cgm_fontsize = (int) real(const_express(&a));
! 423: continue;
! 424: }
! 425:
! 426: if (input_line[token[c_token].start_index] == 'x') {
! 427: /* set color */
! 428: char *string = input_line + token[c_token].start_index;
! 429: unsigned short red, green, blue;
! 430:
! 431: if (sscanf(string, "x%2hx%2hx%2hx", &red, &green, &blue ) != 3)
! 432: int_error("invalid color spec, must be xRRGGBB",c_token);
! 433: if (cgm_user_color_count[0] >= cgm_user_color_max) {
! 434: cgm_user_color_max = cgm_user_color_max*2 + 4;
! 435: cgm_user_color_table =
! 436: gp_realloc(cgm_user_color_table,
! 437: (cgm_user_color_max*3+1)*sizeof(int),
! 438: "CGM color table");
! 439: /* 1st table entry is the minimum color index value */
! 440: cgm_user_color_table[0] = 0;
! 441: }
! 442: cgm_user_color_table[1 + 3*cgm_user_color_count[0]] = red;
! 443: cgm_user_color_table[2 + 3*cgm_user_color_count[0]] = green;
! 444: cgm_user_color_table[3 + 3*cgm_user_color_count[0]] = blue;
! 445: cgm_user_color_count[0]++;
! 446: ++c_token;
! 447: continue;
! 448: } /* if (string begins with 'x') */
! 449:
! 450: break;
! 451: } /* while(!END_OF_COMMAND) */
! 452:
! 453: if (cgm_portrait) {
! 454: term->xmax = CGM_SMALL - CGM_MARGIN;
! 455: term->ymax = CGM_LARGE - CGM_MARGIN;
! 456: } else {
! 457: term->xmax = CGM_LARGE - CGM_MARGIN;
! 458: term->ymax = CGM_SMALL - CGM_MARGIN;
! 459: }
! 460:
! 461: { /* cgm_font, cgm_fontsize, and/or term->v_char may have changed */
! 462: double w;
! 463: CGM_find_font(cgm_font, strlen(cgm_font), &w);
! 464: term->v_char = (unsigned int) (cgm_fontsize*CGM_PT);
! 465: term->h_char = (unsigned int) (cgm_fontsize*CGM_PT*.527*w);
! 466: }
! 467:
! 468: sprintf(default_font, "%s,%d", cgm_font, cgm_fontsize);
! 469: /* default_font holds the font and size set at 'set term' */
! 470: sprintf(term_options, "%s %s %s %s %s width %d linewidth %d \"%s\" %d",
! 471: cgm_portrait ? "portrait" : "landscape",
! 472: cgm_monochrome ? "monochrome" : "color",
! 473: cgm_rotate ? "rotate" : "norotate",
! 474: cgm_dashed ? "dashed" : "solid",
! 475: cgm_nofontlist_mode ? "nofontlist" : "",
! 476: cgm_plotwidth,
! 477: cgm_linewidth_pt,
! 478: cgm_font, cgm_fontsize);
! 479:
! 480: if (cgm_user_color_count[0]) {
! 481: int i, red, green, blue;
! 482: for (i = 0; i < cgm_user_color_count[0] &&
! 483: (strlen(term_options) + 9 < MAX_LINE_LEN); i++) {
! 484: red = cgm_user_color_table[1 + 3*i];
! 485: green = cgm_user_color_table[2 + 3*i];
! 486: blue = cgm_user_color_table[3 + 3*i];
! 487: sprintf(term_options + strlen(term_options),
! 488: " x%02x%02x%02x", red, green, blue);
! 489: }
! 490: if (cgm_user_color_count[0] == 1) {
! 491: /* user only specified the background color */
! 492: cgm_default_color_table[1] = cgm_user_color_table[1];
! 493: cgm_default_color_table[2] = cgm_user_color_table[2];
! 494: cgm_default_color_table[3] = cgm_user_color_table[3];
! 495: cgm_user_color_count[0] = 0;
! 496: } else {
! 497: cgm_maximum_color_index[0] = cgm_user_color_count[0] - 1;
! 498: }
! 499: }
! 500: }
1.1 maekawa 501:
1.1.1.3 ! ohara 502: static void
! 503: CGM_local_reset()
! 504: {
! 505: double w;
! 506: strcpy(cgm_font, DEFAULT_CGMFONT);
! 507: CGM_find_font(cgm_font, strlen(cgm_font), &w);
! 508: cgm_fontsize = 12;
! 509: term->v_char = (unsigned int) (cgm_fontsize * CGM_PT);
! 510: term->h_char = (unsigned int) (cgm_fontsize * CGM_PT * .527 * w);
! 511: cgm_linewidth_pt = 1;
! 512: cgm_monochrome = FALSE;
! 513: cgm_plotwidth = 6 * 72;
! 514: cgm_portrait = FALSE;
! 515: cgm_rotate = TRUE;
! 516: cgm_dashed = TRUE;
! 517: cgm_nofontlist_mode = FALSE;
! 518: cgm_current = cgm_reset;
! 519: cgm_user_color_count[0] = 0;
! 520: }
1.1 maekawa 521:
1.1.1.3 ! ohara 522: TERM_PUBLIC void
! 523: CGM_init()
1.1 maekawa 524: {
525: cgm_posx = cgm_posy = 0;
526: cgm_linetype = 0;
1.1.1.3 ! ohara 527: cgm_next.angle = 0;
1.1 maekawa 528: }
529:
1.1.1.3 ! ohara 530: TERM_PUBLIC void
! 531: CGM_graphics()
1.1 maekawa 532: {
533: register struct termentry *t = term;
534: static int version_data[] = { 1 };
535: static int vdc_type_data[] = { 0 };
536: static int integer_precision_data[] = { 16 };
537: static int real_precision_data[] = { 1, 16, 16 };
538: static int index_precision_data[] = { 16 };
539: static int color_precision_data[] = { 16 };
540: static int color_index_precision_data[] = { 16 };
541: static int scaling_mode_data[] = { 0, 0, 0 };
542: static int color_value_extent_data[] = { 0, 0, 0, 255, 255, 255 };
543: static int color_selection_mode_data[] = { 0 };
544: static int linewidth_specification_mode_data[] = { 0 };
1.1.1.3 ! ohara 545: static int edge_width_specification_mode_data[] = { 0 };
1.1 maekawa 546: static int marker_size_specification_mode_data[] = { 0 };
547: static int vdc_extent_data[] = { 0, 0, 0, 0 };
548: /* static int line_color_data[] = { 1 }; */
549: static int line_type_data[] = { 1 };
550: static int interior_style_data[] = { 1 }; /* 1=filled */
551:
552: static int GPFAR elements_list_data[] =
553: {
554: 0, /* will be set to # elements in this list */
555: 0, 1, /* Begin Metafile */
556: 0, 2, /* End Metafile */
557: 0, 3, /* Begin Picture */
558: 0, 4, /* Begin Picture Body */
559: 0, 5, /* End Picture */
560: 1, 1, /* Metafile Version */
561: 1, 2, /* Metafile Description */
562: 1, 3, /* VDC Type */
563: 1, 4, /* Integer Precision */
564: 1, 5, /* Real Precision */
565: 1, 6, /* Index Precision */
566: 1, 7, /* Color Precision */
567: 1, 8, /* Color Index Precision */
568: 1, 9, /* Maximum Color Index */
1.1.1.3 ! ohara 569: 1, 10, /* Color Value Extent */
! 570: 1, 13, /* Font List */
1.1 maekawa 571: 2, 1, /* Scaling Mode */
572: 2, 2, /* Color Selection Mode */
573: 2, 3, /* Line Width Specification Mode */
574: 2, 4, /* Marker Size Specification Mode */
1.1.1.3 ! ohara 575: 2, 5, /* Edge Width Specification Mode */
1.1 maekawa 576: 2, 6, /* VDC Extent */
1.1.1.3 ! ohara 577: #ifdef NEVER
! 578: /* disabled due to complaints from CGM import filters */
1.1 maekawa 579: 3, 1, /* VDC Integer Precision */
580: 3, 4, /* Transparency */
581: 3, 6, /* Clip Indicator */
1.1.1.3 ! ohara 582: #endif
1.1 maekawa 583: 4, 1, /* Polyline */
584: 4, 3, /* Polymarker */
585: 4, 4, /* Text */
586: 4, 7, /* Polygon */
587: 4, 11, /* Rectangle */
588: 4, 12, /* Circle */
589: 4, 15, /* Circular Arc Center */
590: 4, 16, /* Circular Arc Center Close */
591: 4, 17, /* Ellipse */
592: 4, 18, /* Elliptical Arc */
593: 4, 19, /* Elliptical Arc Close */
594: 5, 2, /* Line Type */
595: 5, 3, /* Line Width */
596: 5, 4, /* Line Color */
597: 5, 6, /* Marker Type */
598: 5, 7, /* Marker Size */
599: 5, 8, /* Marker Color */
600: 5, 10, /* Text Font Index */
601: 5, 14, /* Text Color */
602: 5, 15, /* Character Height */
603: 5, 16, /* Character Orientation */
604: 5, 18, /* Text Alignment */
605: 5, 22, /* Interior Style */
606: 5, 23, /* Fill Color */
607: 5, 24, /* Hatch Index */
1.1.1.3 ! ohara 608: 5, 27, /* Edge Type */
! 609: 5, 28, /* Edge Width */
! 610: 5, 29, /* Edge Color */
! 611: 5, 30, /* Edge Visibility */
! 612: 5, 34, /* Color Table */
1.1 maekawa 613: 6, 1, /* Escape */
614: 7, 2 /* Application Data */
615: };
616:
1.1.1.3 ! ohara 617: /* metafile description (class 1), including filename if available */
1.1 maekawa 618: if (!outstr)
619: CGM_write_char_record(0, 1, 1, outstr);
620: else
621: CGM_write_char_record(0, 1, strlen(outstr) + 1, outstr);
622: CGM_write_int_record(1, 1, 2, version_data);
1.1.1.3 ! ohara 623: {
! 624: char description_data[256];
! 625: sprintf(description_data, "\
! 626: Gnuplot version %s patchlevel %s,\
! 627: Computer Graphics Metafile version 1 per MIL-D-28003A/BASIC-1.%d",
! 628: gnuplot_version, gnuplot_patchlevel, cgm_monochrome? 0:2);
! 629: CGM_write_char_record(1, 2, strlen(description_data),
! 630: description_data);
! 631: }
! 632: elements_list_data[0] = (sizeof(elements_list_data) / CGM_ADJ - 2) / 4;
! 633: CGM_write_int_record(1, 11, sizeof(elements_list_data) / CGM_ADJ,
! 634: elements_list_data);
1.1 maekawa 635: CGM_write_int_record(1, 3, 2, vdc_type_data);
636: CGM_write_int_record(1, 4, 2, integer_precision_data);
637: CGM_write_int_record(1, 5, 6, real_precision_data);
638: CGM_write_int_record(1, 6, 2, index_precision_data);
639: CGM_write_int_record(1, 7, 2, color_precision_data);
640: CGM_write_int_record(1, 8, 2, color_index_precision_data);
1.1.1.3 ! ohara 641: CGM_write_int_record(1, 9, 2, cgm_maximum_color_index);
1.1 maekawa 642: CGM_write_int_record(1, 10, sizeof(color_value_extent_data) / CGM_ADJ,
643: color_value_extent_data);
1.1.1.3 ! ohara 644: if (cgm_nofontlist_mode == FALSE)
! 645: {
! 646: char *buf, *s;
! 647: int i, lgh = 0;
! 648: for (i = 0; cgm_font_data[i].name; i++)
! 649: lgh += strlen(cgm_font_data[i].name) + 1;
! 650: buf = gp_alloc(lgh + 1, "CGM font list");
! 651: for (s = buf, i = 0; cgm_font_data[i].name; i++)
! 652: {
! 653: int lgh = strlen(cgm_font_data[i].name);
! 654: *s++ = (char)lgh;
! 655: strcpy(s, cgm_font_data[i].name);
! 656: s += lgh;
! 657: }
! 658: CGM_write_byte_record(1, 13, lgh, buf);
! 659: free(buf);
! 660: }
1.1 maekawa 661:
662: /* picture description (classes 2 and 3) */
663: CGM_write_char_record(0, 3, 8, "PICTURE1");
664: CGM_write_int_record(2, 1, 6, scaling_mode_data);
665: CGM_write_int_record(2, 2, 2, color_selection_mode_data);
666: CGM_write_int_record(2, 3, 2, linewidth_specification_mode_data);
667: CGM_write_int_record(2, 4, 2, marker_size_specification_mode_data);
1.1.1.3 ! ohara 668: CGM_write_int_record(2, 5, 2, edge_width_specification_mode_data);
1.1 maekawa 669: vdc_extent_data[2] = t->xmax + CGM_MARGIN;
670: vdc_extent_data[3] = t->ymax + CGM_MARGIN;
671: CGM_write_int_record(2, 6, 8, vdc_extent_data);
672:
673: /* picture body (classes 4 and 5) */
674: CGM_write_int_record(0, 4, 0, NULL);
1.1.1.3 ! ohara 675:
! 676: #ifdef NEVER /* no need for these, since we accept the defaults */
! 677: {
! 678: static int vdc_integer_precision_data[] = { 16 };
! 679: CGM_write_int_record(3, 1, 2, vdc_integer_precision_data);
! 680: }
! 681: {
! 682: static int transparency_data[] = { 1 }; /* text background:
! 683: 0=auxiliary color
! 684: 1=transparent */
! 685: CGM_write_int_record(3, 4, sizeof(transparency_data) / CGM_ADJ,
! 686: transparency_data);
! 687: }
! 688: {
! 689: static int clip_indicator_data[] = { 0 };
! 690: CGM_write_int_record(3, 6, sizeof(clip_indicator_data) / CGM_ADJ,
! 691: clip_indicator_data);
! 692: }
! 693: #endif
! 694: if (!cgm_monochrome) {
! 695: if (cgm_user_color_count[0]) {
! 696: CGM_write_int_record(5, 34, (cgm_user_color_count[0]*3+1)*
! 697: sizeof(cgm_user_color_table[0])/CGM_ADJ,
! 698: cgm_user_color_table);
! 699: } else
! 700: CGM_write_int_record(5, 34, sizeof(cgm_default_color_table)/CGM_ADJ,
! 701: cgm_default_color_table);
! 702: }
1.1 maekawa 703: CGM_write_int_record(5, 2, sizeof(line_type_data) / CGM_ADJ,
1.1.1.3 ! ohara 704: line_type_data); /* line type 1=SOLID */
1.1 maekawa 705: cgm_linewidth = cgm_linewidth_pt * CGM_PT;
706: CGM_write_int_record(5, 3, sizeof(cgm_linewidth) / CGM_ADJ,
1.1.1.3 ! ohara 707: (int *) &cgm_linewidth); /* line width */
! 708: CGM_write_int_record(5, 28, sizeof(cgm_linewidth) / CGM_ADJ,
! 709: (int *) &cgm_linewidth); /* edge width */
! 710: CGM_write_int_record(5, 27, sizeof(line_type_data) / CGM_ADJ,
! 711: line_type_data); /* edge type 1=SOLID */
1.1 maekawa 712: CGM_linecolor(0);
1.1.1.3 ! ohara 713:
! 714: cgm_current = cgm_reset;
! 715: cgm_next.char_height = t->v_char;
! 716:
1.1 maekawa 717: CGM_write_int_record(5, 22, 2, interior_style_data);
718: {
719: char buf[45];
720: sprintf(buf, "%.31s,%d", cgm_font, cgm_fontsize);
721: CGM_set_font(buf);
722: }
723: CGM_set_pointsize(pointsize);
724: }
725:
1.1.1.3 ! ohara 726: /* Return the index for the font with the name `name'. The index for
! 727: the first font is 1. Set relwidth to the width of the font,
! 728: relative to Times Bold Italic. If the font is not in the table,
! 729: set *relwidth to 1.0 and return 0. */
! 730: TERM_PUBLIC int
! 731: CGM_find_font(name, numchar, relwidth)
! 732: char *name;
! 733: int numchar;
! 734: double *relwidth;
1.1 maekawa 735: {
1.1.1.3 ! ohara 736: int i;
! 737: *relwidth = 1.;
! 738: for (i=0; cgm_font_data[i].name; i++)
! 739: /* strnicmp is not standard, but defined by stdfn.c if not available */
! 740: if (strlen(cgm_font_data[i].name) == numchar &&
! 741: strnicmp(name, cgm_font_data[i].name, numchar) == 0)
! 742: {
! 743: *relwidth = cgm_font_data[i].width;
! 744: return i+1;
! 745: }
! 746:
1.1 maekawa 747: return 0;
748: }
749:
1.1.1.3 ! ohara 750: TERM_PUBLIC int
! 751: CGM_set_font(font)
1.1 maekawa 752: char *font;
753: {
754: register struct termentry *t = term;
755: int size, font_index;
1.1.1.3 ! ohara 756: char *comma = strchr(font, ',');
! 757: int len;
! 758: double width;
1.1 maekawa 759:
760: /* find font in font table, or use 1st font */
1.1.1.3 ! ohara 761: if (comma)
! 762: len = comma - font;
! 763: else
! 764: len = strlen(font);
! 765:
! 766: font_index = CGM_find_font(font, len, &width);
1.1 maekawa 767: if (font_index == 0)
768: font_index = 1;
1.1.1.3 ! ohara 769: cgm_next.font_index = font_index;
! 770:
! 771: {
! 772: char *s = cgm_font_data[font_index-1].name;
! 773:
! 774: len = strlen(s);
! 775: if (len > 31)
! 776: len = 31;
! 777: strncpy(cgm_font, s, len);
! 778: cgm_font[len] = NUL;
! 779: }
1.1 maekawa 780:
781: /* set font size */
782: size = cgm_fontsize;
1.1.1.3 ! ohara 783: if (comma)
! 784: sscanf(comma + 1, "%d", &size);
1.1 maekawa 785: t->v_char = size * CGM_PT;
1.1.1.3 ! ohara 786: t->h_char = size * CGM_PT * .527 * width;
! 787:
! 788: cgm_next.char_height = t->v_char;
! 789:
1.1 maekawa 790: return TRUE;
791: }
792:
1.1.1.3 ! ohara 793: TERM_PUBLIC void
! 794: CGM_text()
1.1 maekawa 795: {
796: CGM_flush_polyline();
797: CGM_write_int_record(0, 5, 0, NULL); /* end picture */
798: CGM_write_int_record(0, 2, 0, NULL); /* end metafile */
799: }
800:
1.1.1.3 ! ohara 801: TERM_PUBLIC void
! 802: CGM_linetype(linetype)
1.1 maekawa 803: int linetype;
804: {
805: assert(linetype >= -2);
806: if (linetype == cgm_linetype)
807: return;
808: cgm_linetype = linetype;
809:
810: CGM_linecolor(linetype);
811: if (cgm_dashed) {
812: CGM_dashtype(linetype); /* DBT 10-8-98 use dashes */
813: } else {
814: /* dashes for gridlines, solid for everything else */
815: CGM_dashtype(linetype == -1 ? 2 : 0);
816: }
817: /* CGM_dashtype(cgm_monochrome ? linetype : 0); first fix, color->no dashes */
818: /* CGM_dashtype(linetype); orig distribution */
819: }
820:
1.1.1.3 ! ohara 821: TERM_PUBLIC void
! 822: CGM_linecolor(linecolor)
1.1 maekawa 823: int linecolor;
824: {
825: assert(linecolor >= -2);
1.1.1.3 ! ohara 826: linecolor = (linecolor < 1) ? 1 :
! 827: linecolor % cgm_maximum_color_index[0] + 1;
1.1 maekawa 828: if (cgm_monochrome || linecolor == cgm_color)
829: return;
830: cgm_color = linecolor;
831:
832: CGM_flush_polyline();
833: CGM_write_int_record(5, 4, 2, (int *) &cgm_color);
834: }
835:
1.1.1.3 ! ohara 836: TERM_PUBLIC void
! 837: CGM_linewidth(width)
1.1 maekawa 838: double width;
839: {
840: int new_linewidth;
841:
1.1.1.3 ! ohara 842: assert(width > 0);
1.1 maekawa 843: new_linewidth = width * cgm_linewidth_pt * CGM_PT;
844: if (new_linewidth == cgm_linewidth)
845: return;
1.1.1.3 ! ohara 846:
! 847: CGM_flush_polyline();
! 848:
1.1 maekawa 849: cgm_linewidth = new_linewidth;
850: CGM_write_int_record(5, 3, sizeof(cgm_linewidth) / CGM_ADJ,
851: (int *) &cgm_linewidth);
852: CGM_dashtype(cgm_dashtype); /* have dash lengths recalculated */
853: }
854:
1.1.1.3 ! ohara 855: TERM_PUBLIC void
! 856: CGM_dashtype(dashtype)
1.1 maekawa 857: int dashtype;
858: {
859: int i, j;
860: /* Each group of 8 entries in dot_length[] defines a dash
861: pattern. Entries in each group are alternately length of
862: whitespace and length of line, in units of 2/3 of the
863: linewidth. */
864: static int dot_length[CGM_LINE_TYPES * 8] =
865: { /* 0 - solid */
866: 5, 8, 5, 8, 5, 8, 5, 8, /* 1 - dashes */
867: 5, 3, 5, 3, 5, 3, 5, 3, /* 2 - short dashes */
868: 4, 1, 4, 1, 4, 1, 4, 1, /* 3 - dotted */
869: 4, 8, 4, 1, 4, 8, 4, 1, /* 4 - dash-dot */
870: 4, 9, 4, 1, 4, 1, 0, 0, /* 5 - dash-dot-dot */
871: 4, 10, 4, 1, 4, 1, 4, 1, /* 6 - dash-dot-dot-dot */
872: 4, 10, 4, 10, 4, 1, 0, 0, /* 7 - dash-dash-dot */
873: 4, 10, 4, 10, 4, 1, 4, 1}; /* 8 - dash-dash-dot-dot */
874:
875:
876: assert(dashtype >= -2);
877: if (dashtype == cgm_dashtype)
878: return;
879: cgm_dashtype = dashtype;
880:
881: CGM_flush_polyline();
882:
883: if (dashtype >= CGM_LINE_TYPES)
884: dashtype = dashtype % CGM_LINE_TYPES;
885: if (dashtype < 1) {
886: term->vector = CGM_solid_vector;
887: return;
888: }
889: term->vector = CGM_dashed_vector;
890:
891: /* set up dash dimensions */
892: j = (dashtype - 1) * 8;
893: for (i = 0; i < 8; i++, j++) {
894: if (dot_length[j])
895: cgm_step_sizes[i] = (dot_length[j] * cgm_linewidth) * 2 / 3;
896: else
897: cgm_step_sizes[i] = 0;
898: }
899: /* first thing drawn will be a line */
900: cgm_step = cgm_step_sizes[1];
901: cgm_step_index = 1;
902: }
903:
1.1.1.3 ! ohara 904: TERM_PUBLIC void
! 905: CGM_move(x, y)
1.1 maekawa 906: unsigned int x, y;
907: {
908: assert(x < term->xmax && y < term->ymax);
1.1.1.3 ! ohara 909:
1.1 maekawa 910: if (x == cgm_posx && y == cgm_posy)
911: return;
912: CGM_flush_polyline();
913: cgm_posx = x;
914: cgm_posy = y;
915: }
916:
1.1.1.3 ! ohara 917: static void
! 918: CGM_flush_polyline()
1.1 maekawa 919: {
920: if (cgm_coords == 0)
921: return;
922: CGM_write_int_record(4, 1, cgm_coords * 2, cgm_polyline);
923: cgm_coords = 0;
924: }
925:
1.1.1.3 ! ohara 926: static void
! 927: CGM_write_char_record(class, cgm_id, numbytes, data)
1.1 maekawa 928: int class, cgm_id, numbytes;
929: char *data;
930: {
1.1.1.2 maekawa 931: int i, pad, length;
1.1 maekawa 932: static unsigned char flag = 0xff;
1.1.1.2 maekawa 933: static unsigned char paddata = 0;
1.1 maekawa 934: char short_len;
935:
936: pad = 0;
1.1.1.2 maekawa 937: length = numbytes + 1;
1.1 maekawa 938: if (numbytes >= 255)
1.1.1.2 maekawa 939: length += 2; /* long string */
940: if (length & 1)
941: pad = 1; /* needs pad */
942: CGM_write_code(class, cgm_id, length);
1.1 maekawa 943: if (numbytes < 255)
1.1.1.2 maekawa 944: {
945: short_len = (char)numbytes;
1.1 maekawa 946: fwrite(&short_len, 1, 1, gpoutfile); /* write true length */
1.1.1.2 maekawa 947: } else {
948: fwrite(&flag, 1, 1, gpoutfile);
1.1 maekawa 949: CGM_write_int(numbytes);
950: }
1.1.1.2 maekawa 951:
952: if (data)
1.1.1.3 ! ohara 953: fwrite(data, 1, numbytes, gpoutfile); /* write string */
1.1.1.2 maekawa 954: else
955: for (i=0; i<numbytes+pad; i++)
1.1.1.3 ! ohara 956: fputc('\0', gpoutfile); /* write null bytes */
1.1.1.2 maekawa 957:
958: if(pad)
959: fwrite(&paddata, 1, 1, gpoutfile);
960: }
961:
1.1.1.3 ! ohara 962: static void
! 963: CGM_write_byte_record(class, cgm_id, numbytes, data)
1.1.1.2 maekawa 964: int class, cgm_id, numbytes;
965: char *data;
966: {
967: int pad;
968: static unsigned char paddata = 0;
969:
970: pad = numbytes & 1;
971: CGM_write_code(class, cgm_id, numbytes);
972: fwrite(data, 1, numbytes, gpoutfile); /* write string */
973: if(pad)
974: fwrite(&paddata, 1, 1, gpoutfile);
1.1 maekawa 975: }
976:
1.1.1.3 ! ohara 977: static void
! 978: CGM_write_int_record(class, cgm_id, numbytes, data)
1.1 maekawa 979: int class, cgm_id, numbytes, *data;
980: {
981: int i;
982: assert((numbytes & 1) == 0);
983: CGM_write_code(class, cgm_id, numbytes);
984: numbytes >>= 1;
985: for (i = 0; i < numbytes; i++)
986: CGM_write_int(data[i]);
987: }
988:
1.1.1.3 ! ohara 989: static void
! 990: CGM_write_mixed_record(class, cgm_id, numint, int_data, numchar, char_data)
1.1 maekawa 991: int class, cgm_id, numint, *int_data, numchar;
992: char *char_data;
993: {
1.1.1.2 maekawa 994: int i, pad, length;
995: static unsigned char paddata = 0;
1.1 maekawa 996: static unsigned char flag = 0xff;
997: char short_len;
998:
999: pad = 0;
1.1.1.2 maekawa 1000: length = numchar + 1;
1.1 maekawa 1001: if (numchar >= 255)
1.1.1.2 maekawa 1002: length += 2; /* long string */
1003: if (length & 1)
1004: pad = 1; /* needs pad */
1.1 maekawa 1005:
1.1.1.2 maekawa 1006: CGM_write_code(class, cgm_id, numint * 2 + length);
1.1 maekawa 1007:
1008: for (i = 0; i < numint; i++)
1009: CGM_write_int(int_data[i]); /* write integers */
1010:
1.1.1.2 maekawa 1011: if (numchar < 255) {
1012: short_len = (char)numchar;
1.1 maekawa 1013: fwrite(&short_len, 1, 1, gpoutfile); /* write string length */
1.1.1.2 maekawa 1014: } else {
1.1 maekawa 1015: fwrite(&flag, 1, 1, gpoutfile);
1016: CGM_write_int(numchar);
1017: }
1.1.1.2 maekawa 1018: fwrite(char_data, 1, numchar, gpoutfile); /* write string */
1019: if(pad)
1020: fwrite(&paddata, 1, 1, gpoutfile);
1.1 maekawa 1021: }
1022:
1023: /*
1024: Write the code word that starts a CGM record.
1025: bits in code word are as follows...
1026: cccciiiiiiilllll
1027: where
1028: cccc is a 4-bit class number
1029: iiiiiii is a 7-bit ID number
1030: lllll is a 5-bit length (# bytes following the code word, or
1031: 31 followed by a word with the actual number)
1032: */
1.1.1.3 ! ohara 1033: static void
! 1034: CGM_write_code(class, cgm_id, length)
1.1 maekawa 1035: int class, cgm_id, length;
1036: {
1037: unsigned code;
1038:
1039: assert((0 <= class) &&(class <16));
1040: assert((0 <= cgm_id) && (cgm_id < 128));
1041: assert(0 <= length);
1042: if (length < 31) {
1043: code = ((class &0x0f) <<12) |
1044: ((cgm_id & 0x7f) << 5) |
1045: ((length & 0x1f));
1046: CGM_write_int(code);
1047: } else {
1048: code = ((class &0x0f) <<12) |
1049: ((cgm_id & 0x7f) << 5) |
1050: 0x1f;
1051: CGM_write_int(code);
1052: CGM_write_int(length);
1053: }
1054: }
1055:
1.1.1.3 ! ohara 1056: static void
! 1057: CGM_write_int(value)
1.1 maekawa 1058: int value;
1059: {
1060: union {
1061: short s;
1062: char c[2];
1063: } u;
1064:
1065: #if !defined(DOS16) && !defined(WIN16)
1.1.1.3 ! ohara 1066: assert( -32768 <= value );
! 1067: assert( value <= 32767 );
1.1 maekawa 1068: #endif
1069:
1070: u.c[0] = (value >> 8) & 255; /* convert to network order */
1071: u.c[1] = value & 255;
1072:
1073: fwrite(&u.s, 1, 2, gpoutfile);
1074: }
1075:
1076: /* Draw a dashed line to (ux,uy). CGM has linestyles, but
1077: they are not usable -- at least with the Word for Windows
1078: 6.0 filter, where lines of significant width (even 1 pt)
1079: always come out solid. Therefore, we implement dashed
1080: lines here instead. */
1.1.1.3 ! ohara 1081: TERM_PUBLIC void
! 1082: CGM_dashed_vector(ux, uy)
1.1 maekawa 1083: unsigned int ux, uy;
1084: {
1085: int xa, ya;
1086: int dx, dy, adx, ady;
1087: int dist; /* approximate distance in plot units
1088: from starting point to specified end
1089: point. */
1090: long remain; /* approximate distance in plot units
1091: remaining to specified end point. */
1092:
1093: assert(ux < term->xmax && uy < term->ymax);
1094:
1095: dx = (ux - cgm_posx);
1096: dy = (uy - cgm_posy);
1097: adx = abs(dx);
1098: ady = abs(dy * 10);
1099:
1100: /* using the approximation
1101: sqrt(x**2 + y**2) ~ x + (5*x*x)/(12*y) when x > y.
1102: Note ordering of calculations to avoid overflow on 16 bit
1103: architectures */
1104: if (10 * adx < ady)
1105: dist = (ady / 2 + 25 * adx / ady * adx / 6 * 5) / 5;
1106: else {
1107: if (adx == 0)
1108: return;
1109: dist = (adx * 10 + (ady / 24) * (ady / adx)) / 10;
1110: }
1111: remain = dist;
1112: xa = cgm_posx;
1113: ya = cgm_posy;
1114: while (remain > cgm_step) {
1115: remain -= cgm_step;
1116: if (cgm_step_index & 1)
1117: CGM_solid_vector((int) (ux - (remain * dx) / dist),
1118: (int) (uy - (remain * dy) / dist));
1119: else {
1120: xa = (int) (ux - (remain * dx) / dist);
1121: ya = (int) (uy - (remain * dy) / dist);
1122: CGM_move(xa, ya);
1123: }
1124: if (++cgm_step_index >= 8)
1125: cgm_step_index = 0;
1126: cgm_step = cgm_step_sizes[cgm_step_index];
1127: }
1128: if (cgm_step_index & 1)
1129: CGM_solid_vector(ux, uy);
1130: else
1131: CGM_move(ux, uy);
1132: cgm_step -= (int) remain;
1133: }
1134:
1.1.1.3 ! ohara 1135: TERM_PUBLIC void
! 1136: CGM_solid_vector(ux, uy)
1.1 maekawa 1137: unsigned int ux, uy;
1138: {
1139: assert(ux < term->xmax && uy < term->ymax);
1.1.1.3 ! ohara 1140:
1.1 maekawa 1141: if (ux == cgm_posx && uy == cgm_posy)
1142: return;
1143: if (cgm_coords > CGM_MAX_SEGMENTS - 2) {
1144: CGM_flush_polyline();
1145: cgm_polyline[cgm_coords++] = cgm_posx;
1146: cgm_polyline[cgm_coords++] = cgm_posy + CGM_MARGIN;
1147: } else if (cgm_coords == 0) {
1148: cgm_polyline[cgm_coords++] = cgm_posx;
1149: cgm_polyline[cgm_coords++] = cgm_posy + CGM_MARGIN;
1150: }
1151: cgm_polyline[cgm_coords++] = ux;
1152: cgm_polyline[cgm_coords++] = uy + CGM_MARGIN;
1153: cgm_posx = ux;
1154: cgm_posy = uy;
1155: }
1156:
1.1.1.3 ! ohara 1157: TERM_PUBLIC void
! 1158: CGM_put_text(x, y, str)
1.1 maekawa 1159: unsigned int x, y;
1160: char str[];
1161: {
1.1.1.3 ! ohara 1162: static int where[3] = { 0, 0, 1 }; /* the final "1" signals that
! 1163: this is the last text in the
! 1164: string */
1.1 maekawa 1165: char *s = str;
1166:
1167: while (*s)
1168: if (!isspace((int) *s++))
1169: goto showit;
1170: return;
1171:
1172: showit:
1.1.1.3 ! ohara 1173:
1.1 maekawa 1174: CGM_flush_polyline();
1.1.1.3 ! ohara 1175:
! 1176: /* update the text characteristics if they have changed since the
! 1177: last text string was output */
! 1178: if (cgm_current.font_index != cgm_next.font_index) {
! 1179: cgm_current.font_index = cgm_next.font_index;
! 1180: CGM_write_int_record(5, 10, 2, &cgm_next.font_index);
! 1181: }
! 1182: if (cgm_current.justify_mode != cgm_next.justify_mode) {
! 1183: static int data[6] = { 1, 3, 0, 0, 0, 0 };
! 1184: cgm_current.justify_mode = cgm_next.justify_mode;
! 1185:
! 1186: switch (cgm_current.justify_mode) {
! 1187: case LEFT:
! 1188: data[0] = 1;
! 1189: break;
! 1190: case CENTRE:
! 1191: data[0] = 2;
! 1192: break;
! 1193: case RIGHT:
! 1194: data[0] = 3;
! 1195: break;
! 1196: default:
! 1197: assert(0);
! 1198: }
! 1199: CGM_write_int_record(5, 18, 12, data);
! 1200: }
! 1201:
! 1202: if (cgm_current.char_height != cgm_next.char_height) {
! 1203: int h = cgm_next.char_height;
! 1204: cgm_current.char_height = h;
! 1205: h = h*2/3; /* gnuplot measures fonts by the
! 1206: baseline-to-baseline distance,
! 1207: while the CGM file needs the actual
! 1208: height of the upper case
! 1209: characters. */
! 1210: CGM_write_int_record(5, 15, 2, &h);
! 1211: }
! 1212:
! 1213: /* "angle" is the angle of the text baseline (counter-clockwise in
! 1214: radians from horizontal). This is a bit more general than
! 1215: gnuplot needs right now. */
! 1216: if (cgm_current.angle != cgm_next.angle) {
! 1217: /* The first two elements of orient are components of a vector
! 1218: "upward" with respect to the text. The next two elements are
! 1219: components of a vector along the baseline of the text. The
! 1220: lengths of both vectors are equal to the baseline-to-baseline
! 1221: distance in plot units. */
! 1222: static int orient[4];
! 1223: extern double sin(double), cos(double);
! 1224: cgm_current.angle = cgm_next.angle;
! 1225:
! 1226: orient[0] = (int)cgm_next.char_height*cos(cgm_next.angle+3.1416/2);
! 1227: orient[1] = (int)cgm_next.char_height*sin(cgm_next.angle+3.1416/2);
! 1228: orient[2] = (int)cgm_next.char_height*cos(cgm_next.angle);
! 1229: orient[3] = (int)cgm_next.char_height*sin(cgm_next.angle);
! 1230: CGM_write_int_record(5, 16, 8, orient);
! 1231: }
! 1232:
1.1 maekawa 1233: where[0] = x;
1234: where[1] = y + CGM_MARGIN;
1235: CGM_write_mixed_record(4, 4, 3, where, strlen(str), str);
1236:
1237: cgm_posx = cgm_posy = -2000;
1238: }
1239:
1.1.1.3 ! ohara 1240: TERM_PUBLIC int
! 1241: CGM_text_angle(ang)
1.1 maekawa 1242: int ang;
1243: {
1244: if (cgm_rotate) {
1.1.1.3 ! ohara 1245: cgm_next.angle = ang ? M_PI_2 : 0;
1.1 maekawa 1246: return TRUE;
1247: }
1248: return ang ? FALSE : TRUE;
1249: }
1250:
1.1.1.3 ! ohara 1251: TERM_PUBLIC int
! 1252: CGM_justify_text(mode)
1.1 maekawa 1253: enum JUSTIFY mode;
1254: {
1.1.1.3 ! ohara 1255: cgm_next.justify_mode = mode;
! 1256: return (TRUE);
1.1 maekawa 1257: }
1258:
1.1.1.3 ! ohara 1259: TERM_PUBLIC void
! 1260: CGM_reset()
1.1 maekawa 1261: {
1262: cgm_posx = cgm_posy = 0;
1263: }
1264:
1.1.1.3 ! ohara 1265: TERM_PUBLIC void
! 1266: CGM_point(x, y, number)
1.1 maekawa 1267: unsigned int x, y;
1268: int number;
1269: {
1270: int old_dashtype;
1271:
1272: if (number < 0) { /* draw dot */
1273: CGM_move(x, y);
1274: CGM_solid_vector(x + 1, y);
1275: return;
1276: }
1277: number %= CGM_POINTS;
1278:
1279: CGM_flush_polyline();
1280: old_dashtype = cgm_dashtype;
1281: CGM_dashtype(0);
1.1.1.3 ! ohara 1282: if (number <= 7) {
! 1283: cgm_next.edge_visibility = 0;
! 1284: cgm_next.fill_color = cgm_color;
! 1285: } else {
! 1286: cgm_next.edge_visibility = 1;
! 1287: cgm_next.fill_color = 0; /* index 0 is always the background color */
! 1288: cgm_next.edge_color = cgm_color;
! 1289: }
! 1290: if (cgm_current.fill_color != cgm_next.fill_color){
! 1291: cgm_current.fill_color = cgm_next.fill_color;
! 1292: CGM_write_int_record(5, 23, 2, &cgm_next.fill_color);
! 1293: }
! 1294: if (cgm_current.edge_visibility != cgm_next.edge_visibility){
! 1295: cgm_current.edge_visibility = cgm_next.edge_visibility;
! 1296: CGM_write_int_record(5, 30, 2, &cgm_current.edge_visibility);
! 1297: }
! 1298: if (cgm_current.edge_visibility &&
! 1299: cgm_current.edge_color != cgm_next.edge_color){
! 1300: cgm_current.edge_color = cgm_next.edge_color;
! 1301: CGM_write_int_record(5, 29, 2, &cgm_current.edge_color);
! 1302: }
! 1303:
1.1 maekawa 1304: switch (number) {
1305: case 0: /* draw diamond */
1.1.1.3 ! ohara 1306: case 8:
1.1 maekawa 1307: CGM_move(x - cgm_tic, y);
1308: CGM_solid_vector(x, y - cgm_tic);
1309: CGM_solid_vector(x + cgm_tic, y);
1310: CGM_solid_vector(x, y + cgm_tic);
1311: CGM_flush_polygon();
1312: break;
1313: case 1: /* draw plus */
1314: CGM_move(x - cgm_tic, y);
1315: CGM_solid_vector(x + cgm_tic, y);
1316: CGM_move(x, y - cgm_tic);
1317: CGM_solid_vector(x, y + cgm_tic);
1318: break;
1319: case 2: /* draw box */
1.1.1.3 ! ohara 1320: case 9:
1.1 maekawa 1321: CGM_move(x - cgm_tic707, y - cgm_tic707);
1322: CGM_solid_vector(x + cgm_tic707, y - cgm_tic707);
1323: CGM_solid_vector(x + cgm_tic707, y + cgm_tic707);
1324: CGM_solid_vector(x - cgm_tic707, y + cgm_tic707);
1325: CGM_flush_polygon();
1326: break;
1327: case 3: /* draw X */
1328: CGM_move(x - cgm_tic707, y - cgm_tic707);
1329: CGM_solid_vector(x + cgm_tic707, y + cgm_tic707);
1330: CGM_move(x - cgm_tic707, y + cgm_tic707);
1331: CGM_solid_vector(x + cgm_tic707, y - cgm_tic707);
1332: break;
1333: case 4: /* draw triangle (point up) */
1.1.1.3 ! ohara 1334: case 10:
1.1 maekawa 1335: CGM_move(x, y + cgm_tic1241);
1336: CGM_solid_vector(x - cgm_tic1077, y - cgm_tic621);
1337: CGM_solid_vector(x + cgm_tic1077, y - cgm_tic621);
1338: CGM_flush_polygon();
1339: break;
1340: case 5: /* draw star (asterisk) */
1341: CGM_move(x, y - cgm_tic);
1342: CGM_solid_vector(x, y + cgm_tic);
1343: CGM_move(x + cgm_tic866, y - cgm_tic500);
1344: CGM_solid_vector(x - cgm_tic866, y + cgm_tic500);
1345: CGM_move(x + cgm_tic866, y + cgm_tic500);
1346: CGM_solid_vector(x - cgm_tic866, y - cgm_tic500);
1347: break;
1348: case 6: /* draw triangle (point down) */
1.1.1.3 ! ohara 1349: case 11:
1.1 maekawa 1350: CGM_move(x, y - cgm_tic1241);
1351: CGM_solid_vector(x - cgm_tic1077, y + cgm_tic621);
1352: CGM_solid_vector(x + cgm_tic1077, y + cgm_tic621);
1353: CGM_flush_polygon();
1354: break;
1.1.1.3 ! ohara 1355: case 7:
! 1356: case 12: /* draw circle (actually, dodecagon)
1.1 maekawa 1357: (WinWord 6 accepts the CGM "circle"
1358: element, but the resulting circle
1359: is not correctly centered!) */
1360: CGM_move(x, y - cgm_tic);
1361: CGM_solid_vector(x + cgm_tic500, y - cgm_tic866);
1362: CGM_solid_vector(x + cgm_tic866, y - cgm_tic500);
1363: CGM_solid_vector(x + cgm_tic, y);
1364: CGM_solid_vector(x + cgm_tic866, y + cgm_tic500);
1365: CGM_solid_vector(x + cgm_tic500, y + cgm_tic866);
1366: CGM_solid_vector(x, y + cgm_tic);
1367: CGM_solid_vector(x - cgm_tic500, y + cgm_tic866);
1368: CGM_solid_vector(x - cgm_tic866, y + cgm_tic500);
1369: CGM_solid_vector(x - cgm_tic, y);
1370: CGM_solid_vector(x - cgm_tic866, y - cgm_tic500);
1371: CGM_solid_vector(x - cgm_tic500, y - cgm_tic866);
1372: CGM_flush_polygon();
1373: break;
1374: }
1375: CGM_dashtype(old_dashtype);
1376: }
1377:
1378:
1.1.1.3 ! ohara 1379: TERM_PUBLIC void
! 1380: CGM_set_pointsize(size)
1.1 maekawa 1381: double size;
1382: {
1383: /* Markers were chosen to have approximately equal
1384: areas. Dimensions are as follows, in units of
1385: cgm_tic:
1386:
1387: plus, diamond: half height = 1
1388:
1389: square, cross: half height = sqrt(1/2) ~ 12/17
1390:
1391: triangle: half width = sqrt(sqrt(4/3)) ~ 14/13,
1392: height = sqrt(3*sqrt(4/3)) ~ 54/29
1393:
1394: star: half height = 1, half width = sqrt(3/4) ~ 13/15
1395:
1396: dodecagon: coordinates of vertices are 0,
1397: sin(30) = 1/2, cos(30) = sqrt(3/4) ~ 13/15, or 1
1398:
1399: The fractions are approximates of the equivalent
1400: continued fractions. */
1401: cgm_tic = (size * term->h_tic / 2);
1402: cgm_tic707 = cgm_tic * 12 / 17;
1403: cgm_tic866 = cgm_tic * 13 / 15;
1404: cgm_tic500 = cgm_tic / 2;
1405: cgm_tic1241 = cgm_tic * 36 / 29;
1406: cgm_tic1077 = cgm_tic * 14 / 13;
1407: cgm_tic621 = cgm_tic * 18 / 29;
1408: }
1409:
1.1.1.3 ! ohara 1410: static void
! 1411: CGM_flush_polygon()
1.1 maekawa 1412: {
1413: if (cgm_coords == 0)
1414: return;
1415: CGM_write_int_record(4, 7, cgm_coords * 2, cgm_polyline);
1416: cgm_coords = 0;
1417: }
1418:
1419:
1420: #ifdef DEFEAT_ASSERTIONS
1421: #define NDEBUG
1422: #include <assert.h>
1423: #undef DEFEAT_ASSERTIONS
1424: #endif /* DEFEAT_ASSERTIONS */
1425:
1426: #ifdef NEXT
1427: #undef id
1428: #undef datum
1429: #endif
1430:
1431: #endif /* TERM_BODY */
1432:
1433: #ifdef TERM_TABLE
1434: TERM_TABLE_START(cgm_driver)
1435: "cgm", "Computer Graphics Metafile",
1436: CGM_LARGE - CGM_MARGIN, CGM_SMALL - CGM_MARGIN, CGM_VCHAR, CGM_HCHAR,
1437: CGM_VTIC, CGM_HTIC, CGM_options, CGM_init, CGM_reset,
1438: CGM_text, null_scale, CGM_graphics, CGM_move, CGM_solid_vector,
1439: CGM_linetype, CGM_put_text, CGM_text_angle,
1440: CGM_justify_text, CGM_point, do_arrow, CGM_set_font,
1441: CGM_set_pointsize,
1442: TERM_BINARY, /* various flags */
1443: NULL, /* after one plot of multiplot */
1444: NULL, /* before subsequent plot of multiplot */
1445: NULL, /* clear part of multiplot */
1446: CGM_linewidth
1447: TERM_TABLE_END(cgm_driver)
1448:
1449: #undef LAST_TERM
1450: #define LAST_TERM cgm_driver
1451:
1452: #endif /* TERM_TABLE */
1453: #endif /* TERM_PROTO_ONLY */
1454:
1455: #ifdef TERM_HELP
1456: START_HELP(cgm)
1457: "1 cgm",
1458: "?commands set terminal cgm",
1459: "?set terminal cgm",
1460: "?set term cgm",
1461: "?terminal cgm",
1462: "?term cgm",
1463: "?cgm",
1.1.1.3 ! ohara 1464: " The `cgm` terminal generates a Computer Graphics Metafile, Version 1. ",
! 1465: " This file format is a subset of the ANSI X3.122-1986 standard entitled",
! 1466: " \"Computer Graphics - Metafile for the Storage and Transfer of Picture",
! 1467: " Description Information\".",
1.1 maekawa 1468: " Several options may be set in `cgm`.",
1469: "",
1470: " Syntax:",
1471: " set terminal cgm {<mode>} {<color>} {<rotation>} {solid | dashed}",
1472: " {width <plot_width>} {linewidth <line_width>}",
1473: " {\"<font>\"} {<fontsize>}",
1.1.1.3 ! ohara 1474: " {<color0> <color1> <color2> ...}",
1.1 maekawa 1475: "",
1476: " where <mode> is `landscape`, `portrait`, or `default`;",
1477: " <color> is either `color` or `monochrome`; ",
1478: " <rotation> is either `rotate` or `norotate`;",
1479: " `solid` draws all curves with solid lines, overriding any dashed patterns;",
1.1.1.3 ! ohara 1480: " <plot_width> is the assumed width of the plot in points; ",
! 1481: " <line_width> is the line width in points (default 1); ",
1.1 maekawa 1482: " <font> is the name of a font; and ",
1.1.1.3 ! ohara 1483: " <fontsize> is the size of the font in points (default 12).",
1.1 maekawa 1484: "",
1485: " By default, `cgm` uses rotated text for the Y axis label.",
1486: "",
1487: " The first six options can be in any order. Selecting `default` sets all",
1488: " options to their default values.",
1489: "",
1.1.1.3 ! ohara 1490: " Each color must be of the form 'xrrggbb', where x is the literal",
! 1491: " character 'x' and 'rrggbb' are the red, green and blue components in",
! 1492: " hex. For example, 'x00ff00' is green. The background color is set",
! 1493: " first, then the plotting colors."
! 1494: "",
1.1 maekawa 1495: " Examples:",
1496: " set terminal cgm landscape color rotate dashed width 432 \\",
1.1.1.3 ! ohara 1497: " linewidth 1 'Helvetica Bold' 12 # defaults",
! 1498: " set terminal cgm linewidth 2 14 # wider lines & larger font",
! 1499: " set terminal cgm portrait \"Times Italic\" 12",
! 1500: " set terminal cgm color solid # no pesky dashes!",
! 1501:
1.1 maekawa 1502: "2 font",
1503: "?commands set terminal cgm font",
1504: "?set terminal cgm font",
1505: "?set term cgm font",
1506: "?cgm font",
1507: " The first part of a Computer Graphics Metafile, the metafile description,",
1508: " includes a font table. In the picture body, a font is designated by an",
1509: " index into this table. By default, this terminal generates a table with",
1.1.1.3 ! ohara 1510: " the following 16 fonts, plus six more with `italic` replaced by",
! 1511: " `oblique`, or vice-versa (since at least the Microsoft Office and Corel",
! 1512: " Draw CGM import filters treat `italic` and `oblique` as equivalent):",
1.1 maekawa 1513: "@start table - first is interactive cleartext form",
1514: " Helvetica",
1.1.1.3 ! ohara 1515: " Helvetica Bold",
! 1516: " Helvetica Oblique",
! 1517: " Helvetica Bold Oblique",
! 1518: " Times Roman",
! 1519: " Times Bold",
! 1520: " Times Italic",
! 1521: " Times Bold Italic",
! 1522: " Courier",
! 1523: " Courier Bold",
! 1524: " Courier Oblique",
! 1525: " Courier Bold Oblique",
! 1526: " Symbol",
! 1527: " Hershey/Cartographic_Roman",
! 1528: " Hershey/Cartographic_Greek",
! 1529: " Hershey/Simplex_Roman",
! 1530: " Hershey/Simplex_Greek",
! 1531: " Hershey/Simplex_Script",
! 1532: " Hershey/Complex_Roman",
! 1533: " Hershey/Complex_Greek",
! 1534: " Hershey/Complex_Script",
! 1535: " Hershey/Complex_Italic",
! 1536: " Hershey/Complex_Cyrillic",
! 1537: " Hershey/Duplex_Roman",
! 1538: " Hershey/Triplex_Roman",
! 1539: " Hershey/Triplex_Italic",
! 1540: " Hershey/Gothic_German",
! 1541: " Hershey/Gothic_English",
! 1542: " Hershey/Gothic_Italian",
! 1543: " Hershey/Symbol_Set_1",
! 1544: " Hershey/Symbol_Set_2",
! 1545: " Hershey/Symbol_Math",
! 1546: " ZapfDingbats",
! 1547: " Script",
! 1548: " 15",
1.1 maekawa 1549: "#\\begin{tabular}{|ccl|} \\hline",
1550: "#\\multicolumn{2}{|c|}{CGM fonts}\\\\",
1551: "#&Helvetica&\\\\",
1.1.1.3 ! ohara 1552: "#&Helvetica Bold&\\\\",
! 1553: "#&Helvetica Oblique&\\\\",
! 1554: "#&Helvetica Bold Oblique&\\\\",
! 1555: "#&Times Roman&\\\\",
! 1556: "#&Times Bold&\\\\",
! 1557: "#&Times Italic&\\\\",
! 1558: "#&Times Bold Italic&\\\\",
! 1559: "#&Courier&\\\\",
! 1560: "#&Courier Bold&\\\\",
! 1561: "#&Courier Oblique&\\\\",
! 1562: "#&Courier Bold Oblique&\\\\",
! 1563: "#&Symbol&\\\\",
! 1564: "#&Hershey/Cartographic\\_Roman&\\\\",
! 1565: "#&Hershey/Cartographic\\_Greek&\\\\",
! 1566: "#&Hershey/Simplex\\_Roman&\\\\",
! 1567: "#&Hershey/Simplex\\_Greek&\\\\",
! 1568: "#&Hershey/Simplex\\_Script&\\\\",
! 1569: "#&Hershey/Complex\\_Roman&\\\\",
! 1570: "#&Hershey/Complex\\_Greek&\\\\",
! 1571: "#&Hershey/Complex\\_Script&\\\\",
! 1572: "#&Hershey/Complex\\_Italic&\\\\",
! 1573: "#&Hershey/Complex\\_Cyrillic&\\\\",
! 1574: "#&Hershey/Duplex\\_Roman&\\\\",
! 1575: "#&Hershey/Triplex\\_Roman&\\\\",
! 1576: "#&Hershey/Triplex\\_Italic&\\\\",
! 1577: "#&Hershey/Gothic\\_German&\\\\",
! 1578: "#&Hershey/Gothic\\_English&\\\\",
! 1579: "#&Hershey/Gothic\\_Italian&\\\\",
! 1580: "#&Hershey/Symbol\\_Set\\_1&\\\\",
! 1581: "#&Hershey/Symbol\\_Set\\_2&\\\\",
! 1582: "#&Hershey/Symbol\\_Math&\\\\",
! 1583: "#&ZapfDingbats&\\\\",
! 1584: "#&Script&\\\\",
! 1585: "#&15&\\\\",
1.1 maekawa 1586: "%c c l .",
1587: "%@@CGM fonts",
1588: "%_",
1589: "%@@Helvetica",
1.1.1.3 ! ohara 1590: "%@@Helvetica Bold",
! 1591: "%@@Helvetica Oblique",
! 1592: "%@@Helvetica Bold Oblique",
! 1593: "%@@Times Roman",
! 1594: "%@@Times Bold",
! 1595: "%@@Times Italic",
! 1596: "%@@Times Bold Italic",
! 1597: "%@@Courier",
! 1598: "%@@Courier Bold",
! 1599: "%@@Courier Oblique",
! 1600: "%@@Courier Bold Oblique",
! 1601: "%@@Symbol",
! 1602: "%@@Hershey/Cartographic_Roman",
! 1603: "%@@Hershey/Cartographic_Greek",
! 1604: "%@@Hershey/Simplex_Roman",
! 1605: "%@@Hershey/Simplex_Greek",
! 1606: "%@@Hershey/Simplex_Script",
! 1607: "%@@Hershey/Complex_Roman",
! 1608: "%@@Hershey/Complex_Greek",
! 1609: "%@@Hershey/Complex_Script",
! 1610: "%@@Hershey/Complex_Italic",
! 1611: "%@@Hershey/Complex_Cyrillic",
! 1612: "%@@Hershey/Duplex_Roman",
! 1613: "%@@Hershey/Triplex_Roman",
! 1614: "%@@Hershey/Triplex_Italic",
! 1615: "%@@Hershey/Gothic_German",
! 1616: "%@@Hershey/Gothic_English",
! 1617: "%@@Hershey/Gothic_Italian",
! 1618: "%@@Hershey/Symbol_Set_1",
! 1619: "%@@Hershey/Symbol_Set_2",
! 1620: "%@@Hershey/Symbol_Math",
! 1621: "%@@ZapfDingbats",
! 1622: "%@@Script",
! 1623: "%@@15",
1.1 maekawa 1624: "@end table",
1.1.1.3 ! ohara 1625:
! 1626: " The first thirteen of these fonts are required for WebCGM. The",
! 1627: " Microsoft Office CGM import filter implements the 13 standard fonts",
! 1628: " listed above, and also 'ZapfDingbats' and 'Script'. However, the",
! 1629: " script font may only be accessed under the name '15'. For more on",
! 1630: " Microsoft import filter font substitutions, check its help file which",
! 1631: " you may find here:",
! 1632: " C:\\Program Files\\Microsoft Office\\Office\\Cgmimp32.hlp",
! 1633: " and/or its configuration file, which you may find here:",
! 1634: " C:\\Program Files\\Common Files\\Microsoft Shared\\Grphflt\\Cgmimp32.cfg",
! 1635: "",
! 1636: " In the `set term` command, you may specify a font name which does not",
! 1637: " appear in the default font table. In that case, a new font table is",
! 1638: " constructed with the specified font as its first entry. You must ensure",
! 1639: " that the spelling, capitalization, and spacing of the name are",
! 1640: " appropriate for the application that will read the CGM file. (Gnuplot",
! 1641: " and any MIL-D-28003A compliant application ignore case in font names.)",
! 1642: " If you need to add several new fonts, use several `set term` commands.",
1.1 maekawa 1643: "",
1.1.1.3 ! ohara 1644: " Example:",
! 1645: " set terminal cgm 'Old English'",
! 1646: " set terminal cgm 'Tengwar'",
! 1647: " set terminal cgm 'Arabic'",
! 1648: " set output 'myfile.cgm'",
! 1649: " plot ...",
! 1650: " set output",
! 1651: "",
! 1652: " You cannot introduce a new font in a `set label` command."
! 1653:
1.1 maekawa 1654: "2 fontsize",
1655: "?commands set terminal cgm fontsize",
1656: "?set terminal cgm fontsize",
1657: "?set term cgm fontsize",
1658: "?cgm fontsize",
1.1.1.3 ! ohara 1659: " Fonts are scaled assuming the page is 6 inches wide. If the `size`",
! 1660: " command is used to change the aspect ratio of the page or the CGM file",
! 1661: " is converted to a different width, the resulting font sizes will be",
! 1662: " scaled up or down accordingly. To change the assumed width, use the",
! 1663: " `width` option.",
! 1664:
1.1 maekawa 1665: "2 linewidth",
1666: "?commands set terminal cgm linewidth",
1667: "?set terminal cgm linewidth",
1668: "?set term cgm linewidth",
1669: "?cgm linewidth",
1.1.1.3 ! ohara 1670: " The `linewidth` option sets the width of lines in pt. The default width",
! 1671: " is 1 pt. Scaling is affected by the actual width of the page, as",
! 1672: " discussed under the `fontsize` and `width` options.",
! 1673:
1.1 maekawa 1674: "2 rotate",
1675: "?commands set terminal cgm rotate",
1676: "?set terminal cgm rotate",
1677: "?set term cgm rotate",
1678: "?cgm rotate",
1.1.1.3 ! ohara 1679: " The `norotate` option may be used to disable text rotation. For",
! 1680: " example, the CGM input filter for Word for Windows 6.0c can accept",
! 1681: " rotated text, but the DRAW editor within Word cannot. If you edit a",
! 1682: " graph (for example, to label a curve), all rotated text is restored to",
! 1683: " horizontal. The Y axis label will then extend beyond the clip boundary.",
! 1684: " With `norotate`, the Y axis label starts in a less attractive location,",
! 1685: " but the page can be edited without damage. The `rotate` option confirms",
! 1686: " the default behavior.",
! 1687:
1.1 maekawa 1688: "2 solid",
1689: "?set terminal cgm solid",
1690: "?set term cgm solid",
1691: "?cgm solid",
1692: " The `solid` option may be used to disable dashed line styles in the",
1.1.1.3 ! ohara 1693: " plots. This is useful when color is enabled and the dashing of the",
! 1694: " lines detracts from the appearance of the plot. The `dashed` option",
! 1695: " confirms the default behavior, which gives a different dash pattern to",
! 1696: " each curve.",
! 1697:
1.1 maekawa 1698: "2 size",
1699: "?commands set terminal cgm size",
1700: "?set terminal cgm size",
1701: "?set term cgm size",
1.1.1.3 ! ohara 1702: "?cgm size",
! 1703: " Default size of a CGM plot is 32599 units wide and 23457 units high for",
1.1 maekawa 1704: " landscape, or 23457 units wide by 32599 units high for portrait.",
1.1.1.3 ! ohara 1705:
1.1 maekawa 1706: "2 width",
1707: "?commands set terminal cgm width",
1708: "?set terminal cgm width",
1709: "?set term cgm width",
1710: "?cgm width",
1.1.1.3 ! ohara 1711: " All distances in the CGM file are in abstract units. The application",
! 1712: " that reads the file determines the size of the final plot. By default,",
! 1713: " the width of the final plot is assumed to be 6 inches (15.24 cm). This",
! 1714: " distance is used to calculate the correct font size, and may be changed",
! 1715: " with the `width` option. The keyword should be followed by the width in",
! 1716: " points. (Here, a point is 1/72 inch, as in PostScript. This unit is",
! 1717: " known as a \"big point\" in TeX.) Gnuplot `expressions` can be used to",
! 1718: " convert from other units.",
! 1719: "",
! 1720: " Example:",
1.1 maekawa 1721: " set terminal cgm width 432 # default",
1722: " set terminal cgm width 6*72 # same as above",
1723: " set terminal cgm width 10/2.54*72 # 10 cm wide",
1.1.1.3 ! ohara 1724:
! 1725: "2 nofontlist",
! 1726: "?commands set terminal cgm nofontlist",
! 1727: "?set terminal cgm nofontlist",
! 1728: "?set term cgm nofontlist",
! 1729: "?cgm nofontlist",
1.1 maekawa 1730: "?commands set terminal cgm winword6",
1731: "?set terminal cgm winword6",
1732: "?set term cgm winword6",
1733: "?cgm winword6",
1.1.1.3 ! ohara 1734: " The default font table includes the fonts recommended for WebCGM, which",
! 1735: " are compatible with the Computer Graphics Metafile input filter for",
! 1736: " Microsoft Office and Corel Draw. Another application might use",
! 1737: " different fonts and/or different font names, which may not be",
! 1738: " documented. As a workaround, the `nofontlist` option deletes the font",
! 1739: " table from the CGM file. In this case, the reading application should",
! 1740: " use a default table. Gnuplot will still use its own default font table",
! 1741: " to select font indices. Thus, 'Helvetica' will give you an index of 1,",
! 1742: " which should get you the first entry in your application's default font",
! 1743: " table. 'Helvetica Bold' will give you its second entry, etc.",
1.1 maekawa 1744: "",
1.1.1.3 ! ohara 1745: " The former `winword6` option is now a deprecated synonym for",
! 1746: " `nofontlist`. The problems involving the color and font tables that",
! 1747: " the `winword6` option was intended to work around turned out to be",
! 1748: " gnuplot bugs which have now been fixed."
! 1749:
1.1 maekawa 1750: END_HELP(cgm)
1751: #endif /* TERM_HELP */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>