Annotation of OpenXM_contrib/gnuplot/term/vws.trm, Revision 1.1
1.1 ! maekawa 1: /*
! 2: * $Id: vws.trm,v 1.14 1998/04/14 00:18:14 drd Exp $
! 3: *
! 4: */
! 5:
! 6: /* GNUPLOT - vws.trm */
! 7:
! 8: /*[
! 9: * Copyright 1990 - 1993, 1998
! 10: *
! 11: * Permission to use, copy, and distribute this software and its
! 12: * documentation for any purpose with or without fee is hereby granted,
! 13: * provided that the above copyright notice appear in all copies and
! 14: * that both that copyright notice and this permission notice appear
! 15: * in supporting documentation.
! 16: *
! 17: * Permission to modify the software is granted, but not the right to
! 18: * distribute the complete modified source code. Modifications are to
! 19: * be distributed as patches to the released version. Permission to
! 20: * distribute binaries produced by compiling modified sources is granted,
! 21: * provided you
! 22: * 1. distribute the corresponding source modifications from the
! 23: * released version in the form of a patch file along with the binaries,
! 24: * 2. add special version identification to distinguish your version
! 25: * in addition to the base release version number,
! 26: * 3. provide your name and address as the primary contact for the
! 27: * support of your modified version, and
! 28: * 4. retain our contact information in regard to use of the base
! 29: * software.
! 30: * Permission to distribute the released version of the source code along
! 31: * with corresponding source modifications in the form of a patch file is
! 32: * granted with same provisions 2 through 4 for binary distributions.
! 33: *
! 34: * This software is provided "as is" without express or implied warranty
! 35: * to the extent permitted by applicable law.
! 36: ]*/
! 37:
! 38: /*
! 39: * This file is included by ../term.c.
! 40: *
! 41: * This terminal driver supports:
! 42: * IRIS terminals
! 43: *
! 44: * AUTHORS
! 45: * Walter Speth
! 46: * BITNET: SPETH@DBNPIB5
! 47: *
! 48: * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
! 49: *
! 50: */
! 51: /*
! 52: * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
! 53: * adapted to VAX VMS 4.7, VAX C 2.4 and activated the INTENSITY and COLOR
! 54: * monitor features (Lucas P. Hart, June 1997)
! 55: */
! 56:
! 57: #include "driver.h"
! 58:
! 59: #ifdef TERM_REGISTER
! 60: register_term(vws)
! 61: #endif
! 62:
! 63: #ifdef TERM_PROTO
! 64: TERM_PUBLIC void VWS_init __PROTO((void));
! 65: TERM_PUBLIC void VWS_reset __PROTO((void));
! 66: TERM_PUBLIC int VWS_scale __PROTO((double xs, double ys));
! 67: TERM_PUBLIC void VWS_graphics __PROTO((void));
! 68: TERM_PUBLIC void VWS_text __PROTO((void));
! 69: TERM_PUBLIC void VWS_move __PROTO((unsigned int x, unsigned int y));
! 70: TERM_PUBLIC void VWS_vector __PROTO((unsigned int x, unsigned int y));
! 71: TERM_PUBLIC void VWS_linetype __PROTO((int lt));
! 72: TERM_PUBLIC void VWS_put_text __PROTO((unsigned int x, unsigned int y, char *str));
! 73: TERM_PUBLIC int VWS_text_angle __PROTO((int ang));
! 74: TERM_PUBLIC int VWS_justify_text __PROTO((enum JUSTIFY mode));
! 75: TERM_PUBLIC void VWS_point __PROTO((unsigned int x, unsigned int y, int point));
! 76: TERM_PUBLIC void VWS_arrow __PROTO((unsigned int sx, unsigned int sy,
! 77: unsigned int ex, unsigned int ey, int head));
! 78:
! 79: #define VWS_XMAX 1024
! 80: #define VWS_YMAX 780 /* VAXstation 2000 is 864 */
! 81: #define VWS_VCHAR 25
! 82: #define VWS_HCHAR 15
! 83: #define VWS_VTIC 10
! 84: #define VWS_HTIC 10
! 85: #endif /* TERM_PROTO */
! 86:
! 87: #ifndef TERM_PROTO_ONLY
! 88: #ifdef TERM_BODY
! 89: void VWS_resize_ast __PROTO((void));
! 90:
! 91: #include <ssdef.h>
! 92: /* */
! 93: #include <descrip.h>
! 94:
! 95: #include <uisentry.h>
! 96: #include <uisusrdef.h>
! 97:
! 98: #define DEFAULT_ATTR 0
! 99: #define OVER_ATTR 1
! 100: #define ERAS_ATTR 2
! 101: #define BIS_ATTR 3
! 102: #define COLOR_ATTR 4
! 103: #define TEXT_ATTR 5
! 104: #define LINE_ATTR 6
! 105: #define BACK_ATTR 7
! 106:
! 107: float current_x, current_y;
! 108:
! 109: int vd_id, wd_id;
! 110: int vcm_id, ws_type;
! 111:
! 112: static $DESCRIPTOR(ws_devname, "SYS$WORKSTATION");
! 113: static $DESCRIPTOR(vd_title, "gnuplot");
! 114:
! 115: static float x0, y0, xsiz, ysiz, wc_xmin_new, wc_ymin_new, wc_xmax_new, wc_ymax_new, wc_xmin,
! 116: wc_ymin, wc_xmax, wc_ymax, vd_width, vd_height;
! 117:
! 118: void VWS_resize_ast()
! 119: {
! 120: extern void replotrequest(); /* in command.c */
! 121: uis$resize_window(&vd_id, &wd_id, &x0, &y0, &xsiz, &ysiz,
! 122: &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax);
! 123: replotrequest();
! 124: }
! 125:
! 126: /****************************************************************************/
! 127: TERM_PUBLIC void VWS_init()
! 128: {
! 129: int i;
! 130: int cattr;
! 131: $DESCRIPTOR(a_font, "DTABER0003WK00PG0001UZZZZ02A000");
! 132: const int i0 = 0, i1 = 1, i2 = 2, i3 = 3, i4 = 4, i5 = 5, i6 = 6, i7 = 7, i8 = 8;
! 133: const float p0 = 0.0, p1 = 0.1, p2 = 0.2, p3 = 0.3, p4 = 0.4;
! 134: const float p5 = 0.5, p6 = 0.6, p7 = 0.7, p8 = 0.8, p9 = 0.9;
! 135: const int n1 = 0xFFFFFFFF;
! 136: const int uis$c_mode_over = UIS$C_MODE_OVER;
! 137: const int uis$c_mode_eras = UIS$C_MODE_ERAS;
! 138: const int uis$c_mode_bis = UIS$C_MODE_BIS;
! 139: const float vws_hchar = (float) VWS_HCHAR;
! 140: const float vws_vchar = (float) VWS_VCHAR;
! 141: const int default_attr = DEFAULT_ATTR;
! 142: const int over_attr = OVER_ATTR;
! 143: const int eras_attr = ERAS_ATTR;
! 144: const int bis_attr = BIS_ATTR;
! 145: const int color_attr = COLOR_ATTR;
! 146: const int text_attr = TEXT_ATTR;
! 147: const int line_attr = LINE_ATTR;
! 148: const int back_attr = BACK_ATTR;
! 149:
! 150: /* lph: the similar notation may lead to some confusion
! 151: * attributes are grouped in "attribute block" data structures
! 152: * which are referenced by block number
! 153: * attribute block 0 contains default attribute settings
! 154: *
! 155: * To customize settings, a function will read the source
! 156: * attribute block, set the particular attribute, and
! 157: * write to the destination attribute block.
! 158: * Both the block number and attribute are integers, so it
! 159: * is easy to confuse an attribute and an attribute blcok
! 160: */
! 161:
! 162: /* lph: Color map corresponding to an example in
! 163: * MicroVMS Graphics Progamming Guide (V3.0) */
! 164:
! 165: const float r_map[8] = { 0.40, 0.50, 0.50, 0.00, 0.25, 0.90, 0.80, 0.35 };
! 166: const float g_map[8] = { 0.30, 0.50, 0.25, 0.70, 0.25, 0.50, 0.30, 0.65 };
! 167: const float b_map[8] = { 0.00, 0.50, 0.50, 0.30, 0.90, 0.00, 0.00, 0.95 };
! 168:
! 169: /* the array format is easier to customize */
! 170:
! 171: vd_width = 14;
! 172: vd_height = 10; /* aspect sqrt(2) as DIN A paper */
! 173:
! 174: wc_xmin = 0.0;
! 175: wc_ymin = 0.0;
! 176: wc_xmax = (float) VWS_XMAX;
! 177: wc_ymax = (float) VWS_YMAX;
! 178:
! 179: vcm_id = uis$create_color_map(&i8);
! 180:
! 181: vd_id = uis$create_display(&wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax,
! 182: &vd_width, &vd_height, &vcm_id);
! 183: uis$get_hw_color_info(&ws_devname, &ws_type);
! 184:
! 185: /* lph: ws's color table for monochrome */
! 186: /* by default, color table index 0 is backgound, and 1 is foregound */
! 187: /* a color {index into the color table} is assigned to the active line */
! 188: /* in VWS_linetype */
! 189:
! 190: if (ws_type == UIS$C_DEV_MONO) {
! 191: uis$set_color(&vd_id, &i0, &p5, &p5, &p5);
! 192: uis$set_color(&vd_id, &i1, &p0, &p0, &p0);
! 193: uis$set_color(&vd_id, &i2, &p0, &p0, &p0);
! 194: uis$set_color(&vd_id, &i3, &p0, &p0, &p0);
! 195: uis$set_color(&vd_id, &i4, &p0, &p0, &p0);
! 196: uis$set_color(&vd_id, &i5, &p0, &p0, &p0);
! 197: uis$set_color(&vd_id, &i6, &p0, &p0, &p0);
! 198: uis$set_color(&vd_id, &i7, &p0, &p0, &p0);
! 199: } else if (ws_type == UIS$C_DEV_INTENSITY) {
! 200: /* Intensity scale, untested */
! 201: uis$set_color(&vd_id, &i2, &p2, &p2, &p2);
! 202: uis$set_color(&vd_id, &i3, &p3, &p3, &p3);
! 203: uis$set_color(&vd_id, &i4, &p4, &p4, &p4);
! 204: uis$set_color(&vd_id, &i5, &p5, &p5, &p5);
! 205: uis$set_color(&vd_id, &i6, &p6, &p6, &p6);
! 206: uis$set_color(&vd_id, &i7, &p7, &p7, &p7);
! 207: }
! 208: /* ws: perhaps better for color terms (which I do not have) */
! 209:
! 210: else if (ws_type == UIS$C_DEV_COLOR) {
! 211: /* */
! 212: uis$set_color(&vd_id, &i0, &p0, &p0, &p0);
! 213: uis$set_color(&vd_id, &i1, &p9, &p0, &p0);
! 214: uis$set_color(&vd_id, &i2, &p0, &p9, &p0);
! 215: uis$set_color(&vd_id, &i3, &p9, &p9, &p0);
! 216: uis$set_color(&vd_id, &i4, &p0, &p0, &p9);
! 217: uis$set_color(&vd_id, &i5, &p9, &p0, &p9);
! 218: uis$set_color(&vd_id, &i6, &p0, &p9, &p9);
! 219: uis$set_color(&vd_id, &i7, &p9, &p9, &p9);
! 220: /*
! 221: * lph: Another way to set up the color table is to use arrays,
! 222: * which simplifies customizing the appearance.
! 223: *
! 224: uis$set_colors(&vd_id, &i0, &i8, &r_map, &g_map, &b_map);
! 225: */
! 226: }
! 227: uis$disable_display_list(&vd_id);
! 228:
! 229: wd_id = uis$create_window(&vd_id, &ws_devname, &vd_title,
! 230: &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax,
! 231: &vd_width, &vd_height);
! 232:
! 233: uis$set_resize_ast(&vd_id, &wd_id, &VWS_resize_ast, &i0,
! 234: &x0, &y0, &xsiz, &ysiz,
! 235: &wc_xmin_new, &wc_ymin_new, &wc_xmax_new, &wc_ymax_new);
! 236: /*
! 237: * lph: This sets up three different attribute blocks, each having a different
! 238: * mode, but they are never utilized and it is not clear when they might
! 239: * be of use.
! 240: * The attribute blocks used for writing are line_attr, text_attr.
! 241: *
! 242: uis$set_writing_mode(&vd_id, &default_attr, &over_attr, &uis$c_mode_over);
! 243: uis$set_writing_mode(&vd_id, &default_attr, &eras_attr, &uis$c_mode_eras);
! 244: uis$set_writing_mode(&vd_id, &default_attr, &bis_attr, &uis$c_mode_bis);
! 245: */
! 246:
! 247: /* lph: this was commented out; it changes the COLOR_ATTR BLOCK and
! 248: * the following BLOCKS
! 249: *
! 250: if (ws_type >= UIS$C_DEV_INTENSITY) {
! 251: for (i=0; i<8; i++) {
! 252: cattr = COLOR_ATTR+i;
! 253: uis$set_writing_index(&vd_id, &default_attr, &cattr, &i);
! 254: }
! 255: }
! 256: *
! 257: */
! 258:
! 259: /* lph: default value for the background index into the virtual color
! 260: /* table is 0, and the back_attr block is never used
! 261: *
! 262: uis$set_background_index(&vd_id, &default_attr, &back_attr, &i0);
! 263: *
! 264: * the rest look OK, setting up the two attribute blocks
! 265: */
! 266: uis$set_writing_mode(&vd_id, &default_attr, &text_attr, &uis$c_mode_over);
! 267: uis$set_font(&vd_id, &text_attr, &text_attr, &a_font);
! 268: uis$set_char_size(&vd_id, &text_attr, &text_attr, &i0, &vws_hchar, &vws_vchar);
! 269: uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
! 270: }
! 271:
! 272: /****************************************************************************/
! 273:
! 274: TERM_PUBLIC void VWS_reset()
! 275: {
! 276: uis$delete_display(&vd_id);
! 277: }
! 278:
! 279: /****************************************************************************/
! 280: TERM_PUBLIC int VWS_scale(xs, ys)
! 281: double xs, ys;
! 282: {
! 283: return FALSE;
! 284: }
! 285: /****************************************************************************/
! 286: TERM_PUBLIC void VWS_graphics()
! 287: {
! 288: uis$erase(&vd_id, &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax);
! 289: }
! 290:
! 291: /****************************************************************************/
! 292: TERM_PUBLIC void VWS_text()
! 293: {
! 294: }
! 295:
! 296: /****************************************************************************/
! 297: TERM_PUBLIC void VWS_move(x, y)
! 298: unsigned int x, y;
! 299: {
! 300: current_x = (float) (x);
! 301: current_y = (float) (y);
! 302: }
! 303:
! 304: /****************************************************************************/
! 305: TERM_PUBLIC void VWS_vector(x, y)
! 306: unsigned int x, y;
! 307: {
! 308: int col;
! 309: int line_attr = LINE_ATTR;
! 310: float fx, fy;
! 311: fx = (float) x;
! 312: fy = (float) y;
! 313:
! 314: uis$line(&vd_id, &line_attr, ¤t_x, ¤t_y, &fx, &fy);
! 315: VWS_move(x, y);
! 316: }
! 317:
! 318: /****************************************************************************/
! 319: TERM_PUBLIC void VWS_linetype(lt)
! 320: int lt;
! 321: {
! 322: const int n1 = 0xFFFFFFFF;
! 323: /* indices into the color map */
! 324: const int i[8] = {0, 1, 2, 3, 4, 5, 6, 7};
! 325: const float p15 = 2.0, p20 = 3.0, p10 = 1.0;
! 326: long int lstyle[9] =
! 327: {0xffffffff,
! 328: 0Xff00ff00,
! 329: 0xffffff00,
! 330: 0xffff0000,
! 331: 0xf0f0f0f0,
! 332: 0Xfff0fff0,
! 333: 0xf000f000,
! 334: 0xa5a5a5af,
! 335: 0xf00f00f0
! 336: };
! 337: int line_attr = LINE_ATTR;
! 338: /* use multiplier of normal line width; default is width in pixels */
! 339: const int uis$c_width_world = UIS$C_WIDTH_WORLD;
! 340:
! 341: if (lt < 0) {
! 342: switch (lt) {
! 343: case -1: /* used for axis */
! 344: uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
! 345: uis$set_line_width(&vd_id, &line_attr, &line_attr, &p15,
! 346: &uis$c_width_world);
! 347: if (ws_type >= UIS$C_DEV_INTENSITY) {
! 348: uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1]);
! 349: }
! 350: break;
! 351: case -2: /* the borders */
! 352: uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
! 353: uis$set_line_width(&vd_id, &line_attr, &line_attr, &p20,
! 354: &uis$c_width_world);
! 355: if (ws_type >= UIS$C_DEV_INTENSITY) {
! 356: uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1]);
! 357: }
! 358: break;
! 359: default: /* else a thick line ? */
! 360: uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
! 361: uis$set_line_width(&vd_id, &line_attr, &line_attr, &p20,
! 362: &uis$c_width_world);
! 363: if (ws_type >= UIS$C_DEV_INTENSITY) {
! 364: uis$set_writing_index(&vd_id, &line_attr, &line_attr,
! 365: &i[1 + ((-lt) % 7)]);
! 366: }
! 367: break;
! 368: }
! 369: } else {
! 370: /* assign the color index (excluding the background index, 0*/
! 371: if (ws_type >= UIS$C_DEV_INTENSITY) {
! 372: uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1 + lt % 7]);
! 373: }
! 374: /* assign the line style
! 375: uis$set_line_style(&vd_id,&line_attr,&line_attr,&lstyle[lt % 8]);
! 376: * ws: makes part of curve disappear on my workstation
! 377: * lph: also observed w/ VS2000 and 4 plane graphics coprocesssor; line
! 378: * types change appropriately, but has problems as pixels/line segment
! 379: * decreases. Better with full screen display and "set samples" smaller
! 380: * but start out with only solid lines
! 381: */
! 382: uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
! 383:
! 384: uis$set_line_width(&vd_id, &line_attr, &line_attr, &p10,
! 385: &uis$c_width_world);
! 386: }
! 387: }
! 388:
! 389: /****************************************************************************/
! 390: static int justify_mode = CENTRE, up;
! 391:
! 392: TERM_PUBLIC void VWS_put_text(x, y, str)
! 393: unsigned int x, y;
! 394: char *str;
! 395: {
! 396: float fx, fy, thih, twid;
! 397: int text_attr = TEXT_ATTR;
! 398:
! 399: /* uis$text parameter is descriptor string not character string */
! 400:
! 401: struct dsc$descriptor_s textline =
! 402: {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, ""};
! 403:
! 404:
! 405: textline.dsc$a_pointer = str;
! 406: textline.dsc$w_length = strlen(textline.dsc$a_pointer);
! 407: uis$measure_text(&vd_id, &text_attr, &textline, &twid, &thih);
! 408: fx = (float) x;
! 409: fy = (float) y;
! 410:
! 411: switch (justify_mode) {
! 412: case LEFT:
! 413: fy += thih / 2.;
! 414: break;
! 415: case RIGHT:
! 416: fy += thih / 2.;
! 417: fx -= twid;
! 418: break;
! 419:
! 420: case CENTRE:
! 421: fy += thih / 2.;
! 422: fx -= twid / 2;
! 423: break;
! 424: };
! 425:
! 426: uis$text(&vd_id, &text_attr, &textline, &fx, &fy);
! 427: /* write to Example Viewport window */
! 428:
! 429:
! 430: }
! 431: /****************************************************************************/
! 432: TERM_PUBLIC int VWS_text_angle(ang)
! 433: int ang;
! 434: {
! 435: float degrees;
! 436: int text_attr = TEXT_ATTR;
! 437: degrees = 90. * (up = ang);
! 438: uis$set_text_slope(&vd_id, &text_attr, &text_attr, °rees);
! 439: return TRUE;
! 440: }
! 441: /****************************************************************************/
! 442: TERM_PUBLIC int VWS_justify_text(mode)
! 443: enum JUSTIFY mode;
! 444: {
! 445: justify_mode = mode;
! 446: return TRUE;
! 447: }
! 448: /****************************************************************************/
! 449: TERM_PUBLIC void VWS_point(x, y, point)
! 450: unsigned int x, y;
! 451: int point;
! 452: {
! 453: do_point(x, y, point);
! 454: }
! 455:
! 456: /****************************************************************************/
! 457: TERM_PUBLIC void VWS_arrow(sx, sy, ex, ey, head)
! 458: unsigned int sx, sy, ex, ey;
! 459: int head;
! 460: {
! 461: do_arrow(sx, sy, ex, ey, head);
! 462: }
! 463:
! 464: #endif /* TERM_BODY */
! 465:
! 466: #ifdef TERM_TABLE
! 467:
! 468: TERM_TABLE_START(vws_driver)
! 469: "VWS", "VAX Windowing System (UIS)",
! 470: VWS_XMAX, VWS_YMAX, VWS_VCHAR, VWS_HCHAR,
! 471: VWS_VTIC, VWS_HTIC, options_null, VWS_init, VWS_reset,
! 472: VWS_text, null_scale, VWS_graphics, VWS_move, VWS_vector,
! 473: VWS_linetype, VWS_put_text, VWS_text_angle,
! 474: VWS_justify_text, do_point, do_arrow, set_font_null
! 475: TERM_TABLE_END(vws_driver)
! 476:
! 477: #undef LAST_TERM
! 478: #define LAST_TERM vws_driver
! 479:
! 480: #endif /* TERM_TABLE */
! 481: #endif /* TERM_PROTO_ONLY */
! 482:
! 483: #ifdef TERM_HELP
! 484: START_HELP(VWS)
! 485: "1 VWS",
! 486: "?commands set terminal VWS",
! 487: "?set terminal VWS",
! 488: "?set term VWS",
! 489: "?terminal VWS",
! 490: "?term VWS",
! 491: "?VWS",
! 492: " The `VWS` terminal driver supports the VAX Windowing System. It has",
! 493: " no options. It will sense the display type (monochrome, gray scale,",
! 494: " or color.) All line styles are plotted as solid lines."
! 495: END_HELP(VWS)
! 496: #endif /* TERM_HELP */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>