File: vws.trm

package info (click to toggle)
gnuplot 3.7.2-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 6,212 kB
  • ctags: 4,635
  • sloc: ansic: 43,538; cpp: 970; makefile: 883; lisp: 661; sh: 578; asm: 539; objc: 379; csh: 297; pascal: 192; perl: 138
file content (496 lines) | stat: -rw-r--r-- 15,629 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
/*
 * $Id: vws.trm,v 1.7 1998/12/14 18:41:49 lhecking Exp $
 *
 */

/* GNUPLOT - vws.trm */

/*[
 * Copyright 1990 - 1993, 1998
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the complete modified source code.  Modifications are to
 * be distributed as patches to the released version.  Permission to
 * distribute binaries produced by compiling modified sources is granted,
 * provided you
 *   1. distribute the corresponding source modifications from the
 *    released version in the form of a patch file along with the binaries,
 *   2. add special version identification to distinguish your version
 *    in addition to the base release version number,
 *   3. provide your name and address as the primary contact for the
 *    support of your modified version, and
 *   4. retain our contact information in regard to use of the base
 *    software.
 * Permission to distribute the released version of the source code along
 * with corresponding source modifications in the form of a patch file is
 * granted with same provisions 2 through 4 for binary distributions.
 *
 * This software is provided "as is" without express or implied warranty
 * to the extent permitted by applicable law.
]*/

/*
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *   IRIS terminals
 *
 * AUTHORS
 *   Walter Speth
 *           BITNET: SPETH@DBNPIB5
 *
 * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
 *
 */
/*
 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
 * adapted to VAX VMS 4.7, VAX C 2.4 and activated the INTENSITY and COLOR 
 * monitor features (Lucas P. Hart, June 1997) 
 */

#include "driver.h"

#ifdef TERM_REGISTER
register_term(vws)
#endif

#ifdef TERM_PROTO
TERM_PUBLIC void VWS_init __PROTO((void));
TERM_PUBLIC void VWS_reset __PROTO((void));
TERM_PUBLIC int VWS_scale __PROTO((double xs, double ys));
TERM_PUBLIC void VWS_graphics __PROTO((void));
TERM_PUBLIC void VWS_text __PROTO((void));
TERM_PUBLIC void VWS_move __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void VWS_vector __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void VWS_linetype __PROTO((int lt));
TERM_PUBLIC void VWS_put_text __PROTO((unsigned int x, unsigned int y, char *str));
TERM_PUBLIC int VWS_text_angle __PROTO((int ang));
TERM_PUBLIC int VWS_justify_text __PROTO((enum JUSTIFY mode));
TERM_PUBLIC void VWS_point __PROTO((unsigned int x, unsigned int y, int point));
TERM_PUBLIC void VWS_arrow __PROTO((unsigned int sx, unsigned int sy,
				    unsigned int ex, unsigned int ey, int head));

#define VWS_XMAX 1024
#define VWS_YMAX 780		/* VAXstation 2000 is 864 */
#define VWS_VCHAR 25
#define VWS_HCHAR 15
#define VWS_VTIC 10
#define VWS_HTIC 10
#endif /* TERM_PROTO */

#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY
void VWS_resize_ast __PROTO((void));

#include <ssdef.h>
/* */
#include <descrip.h>

#include <uisentry.h>
#include <uisusrdef.h>

#define DEFAULT_ATTR 0
#define OVER_ATTR 1
#define ERAS_ATTR 2
#define BIS_ATTR 3
#define COLOR_ATTR 4
#define TEXT_ATTR 5
#define LINE_ATTR 6
#define BACK_ATTR 7

float current_x, current_y;

int vd_id, wd_id;
int vcm_id, ws_type;

static $DESCRIPTOR(ws_devname, "SYS$WORKSTATION");
static $DESCRIPTOR(vd_title, "gnuplot");

static float x0, y0, xsiz, ysiz, wc_xmin_new, wc_ymin_new, wc_xmax_new, wc_ymax_new, wc_xmin,
wc_ymin, wc_xmax, wc_ymax, vd_width, vd_height;

void VWS_resize_ast()
{
    extern void replotrequest();	/* in command.c */
    uis$resize_window(&vd_id, &wd_id, &x0, &y0, &xsiz, &ysiz,
		      &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax);
    replotrequest();
}

/****************************************************************************/
TERM_PUBLIC void VWS_init()
{
    int i;
    int cattr;
    $DESCRIPTOR(a_font, "DTABER0003WK00PG0001UZZZZ02A000");
    const int i0 = 0, i1 = 1, i2 = 2, i3 = 3, i4 = 4, i5 = 5, i6 = 6, i7 = 7, i8 = 8;
    const float p0 = 0.0, p1 = 0.1, p2 = 0.2, p3 = 0.3, p4 = 0.4;
    const float p5 = 0.5, p6 = 0.6, p7 = 0.7, p8 = 0.8, p9 = 0.9;
    const int n1 = 0xFFFFFFFF;
    const int uis$c_mode_over = UIS$C_MODE_OVER;
    const int uis$c_mode_eras = UIS$C_MODE_ERAS;
    const int uis$c_mode_bis = UIS$C_MODE_BIS;
    const float vws_hchar = (float) VWS_HCHAR;
    const float vws_vchar = (float) VWS_VCHAR;
    const int default_attr = DEFAULT_ATTR;
    const int over_attr = OVER_ATTR;
    const int eras_attr = ERAS_ATTR;
    const int bis_attr = BIS_ATTR;
    const int color_attr = COLOR_ATTR;
    const int text_attr = TEXT_ATTR;
    const int line_attr = LINE_ATTR;
    const int back_attr = BACK_ATTR;

/* lph:  the similar notation may lead to some confusion
 * attributes are grouped in "attribute block" data structures
 * which are referenced by block number
 * attribute block 0 contains default attribute settings
 *
 * To customize settings, a function will read the source 
 * attribute block, set the particular attribute, and
 * write to the destination attribute block.
 * Both the block number and attribute are integers, so it
 * is easy to confuse an attribute and an attribute blcok
 */

/*  lph:  Color map corresponding to an example in
 *  MicroVMS Graphics Progamming Guide (V3.0) */

    const float r_map[8] = { 0.40, 0.50, 0.50, 0.00, 0.25, 0.90, 0.80, 0.35 };
    const float g_map[8] = { 0.30, 0.50, 0.25, 0.70, 0.25, 0.50, 0.30, 0.65 };
    const float b_map[8] = { 0.00, 0.50, 0.50, 0.30, 0.90, 0.00, 0.00, 0.95 };

/* the array format is easier to customize */

    vd_width = 14;
    vd_height = 10;		/* aspect sqrt(2) as DIN A paper */

    wc_xmin = 0.0;
    wc_ymin = 0.0;
    wc_xmax = (float) VWS_XMAX;
    wc_ymax = (float) VWS_YMAX;

    vcm_id = uis$create_color_map(&i8);

    vd_id = uis$create_display(&wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax,
			       &vd_width, &vd_height, &vcm_id);
    uis$get_hw_color_info(&ws_devname, &ws_type);

/* lph: ws's color table for monochrome  */
/* by default,  color table index 0 is backgound, and 1 is foregound */
/* a color {index into the color table} is assigned to the active line */
/* in VWS_linetype */

    if (ws_type == UIS$C_DEV_MONO) {
	uis$set_color(&vd_id, &i0, &p5, &p5, &p5);
	uis$set_color(&vd_id, &i1, &p0, &p0, &p0);
	uis$set_color(&vd_id, &i2, &p0, &p0, &p0);
	uis$set_color(&vd_id, &i3, &p0, &p0, &p0);
	uis$set_color(&vd_id, &i4, &p0, &p0, &p0);
	uis$set_color(&vd_id, &i5, &p0, &p0, &p0);
	uis$set_color(&vd_id, &i6, &p0, &p0, &p0);
	uis$set_color(&vd_id, &i7, &p0, &p0, &p0);
    } else if (ws_type == UIS$C_DEV_INTENSITY) {
        /* Intensity scale, untested */
	uis$set_color(&vd_id, &i2, &p2, &p2, &p2);
	uis$set_color(&vd_id, &i3, &p3, &p3, &p3);
	uis$set_color(&vd_id, &i4, &p4, &p4, &p4);
	uis$set_color(&vd_id, &i5, &p5, &p5, &p5);
	uis$set_color(&vd_id, &i6, &p6, &p6, &p6);
	uis$set_color(&vd_id, &i7, &p7, &p7, &p7);
    }
    /* ws: perhaps better for color terms (which I do not have) */

    else if (ws_type == UIS$C_DEV_COLOR) {
/* */
	uis$set_color(&vd_id, &i0, &p0, &p0, &p0);
	uis$set_color(&vd_id, &i1, &p9, &p0, &p0);
	uis$set_color(&vd_id, &i2, &p0, &p9, &p0);
	uis$set_color(&vd_id, &i3, &p9, &p9, &p0);
	uis$set_color(&vd_id, &i4, &p0, &p0, &p9);
	uis$set_color(&vd_id, &i5, &p9, &p0, &p9);
	uis$set_color(&vd_id, &i6, &p0, &p9, &p9);
	uis$set_color(&vd_id, &i7, &p9, &p9, &p9);
	/*
	   * lph: Another way to set up the color table is to use arrays,
	   * which simplifies customizing the appearance.
	   *
	   uis$set_colors(&vd_id, &i0, &i8, &r_map, &g_map, &b_map);  
	 */
    }
    uis$disable_display_list(&vd_id);

    wd_id = uis$create_window(&vd_id, &ws_devname, &vd_title,
			      &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax,
			      &vd_width, &vd_height);

    uis$set_resize_ast(&vd_id, &wd_id, &VWS_resize_ast, &i0,
		       &x0, &y0, &xsiz, &ysiz,
		       &wc_xmin_new, &wc_ymin_new, &wc_xmax_new, &wc_ymax_new);
/* 
 * lph: This sets up three different attribute blocks, each having a different
 * mode, but they are never utilized and it is not clear when they might
 * be of use.
 * The attribute blocks used for writing are line_attr, text_attr.
 * 
  uis$set_writing_mode(&vd_id, &default_attr, &over_attr, &uis$c_mode_over);
  uis$set_writing_mode(&vd_id, &default_attr, &eras_attr, &uis$c_mode_eras);
  uis$set_writing_mode(&vd_id, &default_attr, &bis_attr, &uis$c_mode_bis);
 */

/* lph:  this was commented out;  it changes the COLOR_ATTR BLOCK and 
 * the following BLOCKS
 *
if (ws_type >=  UIS$C_DEV_INTENSITY) {
  for (i=0; i<8; i++) {
  cattr = COLOR_ATTR+i;
  uis$set_writing_index(&vd_id, &default_attr, &cattr, &i);
  }
  }
 *
  */

/* lph: default value for the background index into the virtual color
/* table is 0, and the back_attr block is never used
 *
  uis$set_background_index(&vd_id, &default_attr, &back_attr, &i0);
 *
 * the rest look OK, setting up the two attribute blocks 
 */
    uis$set_writing_mode(&vd_id, &default_attr, &text_attr, &uis$c_mode_over);
    uis$set_font(&vd_id, &text_attr, &text_attr, &a_font);
    uis$set_char_size(&vd_id, &text_attr, &text_attr, &i0, &vws_hchar, &vws_vchar);
    uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
}

/****************************************************************************/

TERM_PUBLIC void VWS_reset()
{
    uis$delete_display(&vd_id);
}

/****************************************************************************/
TERM_PUBLIC int VWS_scale(xs, ys)
double xs, ys;
{
    return FALSE;
}
/****************************************************************************/
TERM_PUBLIC void VWS_graphics()
{
    uis$erase(&vd_id, &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax);
}

/****************************************************************************/
TERM_PUBLIC void VWS_text()
{
}

/****************************************************************************/
TERM_PUBLIC void VWS_move(x, y)
unsigned int x, y;
{
    current_x = (float) (x);
    current_y = (float) (y);
}

/****************************************************************************/
TERM_PUBLIC void VWS_vector(x, y)
unsigned int x, y;
{
    int col;
    int line_attr = LINE_ATTR;
    float fx, fy;
    fx = (float) x;
    fy = (float) y;

    uis$line(&vd_id, &line_attr, &current_x, &current_y, &fx, &fy);
    VWS_move(x, y);
}

/****************************************************************************/
TERM_PUBLIC void VWS_linetype(lt)
int lt;
{
    const int n1 = 0xFFFFFFFF;
    /* indices into the color map */
    const int i[8] = {0, 1, 2, 3, 4, 5, 6, 7};
    const float p15 = 2.0, p20 = 3.0, p10 = 1.0;
    long int lstyle[9] =
    {0xffffffff,
     0Xff00ff00,
     0xffffff00,
     0xffff0000,
     0xf0f0f0f0,
     0Xfff0fff0,
     0xf000f000,
     0xa5a5a5af,
     0xf00f00f0
    };
    int line_attr = LINE_ATTR;
    /* use multiplier of normal line width; default is width in pixels */
    const int uis$c_width_world = UIS$C_WIDTH_WORLD;

    if (lt < 0) {
	switch (lt) {
	case -1:		/* used for axis */
	    uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
	    uis$set_line_width(&vd_id, &line_attr, &line_attr, &p15,
			       &uis$c_width_world);
	    if (ws_type >= UIS$C_DEV_INTENSITY) {
		uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1]);
	    }
	    break;
	case -2:		/* the borders */
	    uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
	    uis$set_line_width(&vd_id, &line_attr, &line_attr, &p20,
			       &uis$c_width_world);
	    if (ws_type >= UIS$C_DEV_INTENSITY) {
		uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1]);
	    }
	    break;
	default:		/* else a thick line ? */
	    uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
	    uis$set_line_width(&vd_id, &line_attr, &line_attr, &p20,
			       &uis$c_width_world);
	    if (ws_type >= UIS$C_DEV_INTENSITY) {
		uis$set_writing_index(&vd_id, &line_attr, &line_attr,
				      &i[1 + ((-lt) % 7)]);
	    }
	    break;
	}
    } else {
/* assign the color index (excluding the background index, 0*/
	if (ws_type >= UIS$C_DEV_INTENSITY) {
	    uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1 + lt % 7]);
	}
/* assign the line style
    uis$set_line_style(&vd_id,&line_attr,&line_attr,&lstyle[lt % 8]);
 * ws: makes part of curve disappear on my workstation
 * lph: also observed w/ VS2000 and 4 plane graphics coprocesssor; line 
 * types change appropriately, but has problems as pixels/line segment 
 * decreases.  Better with full screen display and "set samples" smaller
 * but start out with only solid lines
  */
	uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);

	uis$set_line_width(&vd_id, &line_attr, &line_attr, &p10,
			   &uis$c_width_world);
    }
}

/****************************************************************************/
static int justify_mode = CENTRE, up;

TERM_PUBLIC void VWS_put_text(x, y, str)
unsigned int x, y;
char *str;
{
    float fx, fy, thih, twid;
    int text_attr = TEXT_ATTR;

/* uis$text parameter is descriptor string not character string */

    struct dsc$descriptor_s textline =
    {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, ""};


    textline.dsc$a_pointer = str;
    textline.dsc$w_length = strlen(textline.dsc$a_pointer);
    uis$measure_text(&vd_id, &text_attr, &textline, &twid, &thih);
    fx = (float) x;
    fy = (float) y;

    switch (justify_mode) {
    case LEFT:
	fy += thih / 2.;
	break;
    case RIGHT:
	fy += thih / 2.;
	fx -= twid;
	break;

    case CENTRE:
	fy += thih / 2.;
	fx -= twid / 2;
	break;
    };

    uis$text(&vd_id, &text_attr, &textline, &fx, &fy);
    /* write to Example Viewport window */


}
/****************************************************************************/
TERM_PUBLIC int VWS_text_angle(ang)
int ang;
{
    float degrees;
    int text_attr = TEXT_ATTR;
    degrees = 90. * (up = ang);
    uis$set_text_slope(&vd_id, &text_attr, &text_attr, &degrees);
    return TRUE;
}
/****************************************************************************/
TERM_PUBLIC int VWS_justify_text(mode)
enum JUSTIFY mode;
{
    justify_mode = mode;
    return TRUE;
}
/****************************************************************************/
TERM_PUBLIC void VWS_point(x, y, point)
unsigned int x, y;
int point;
{
    do_point(x, y, point);
}

/****************************************************************************/
TERM_PUBLIC void VWS_arrow(sx, sy, ex, ey, head)
unsigned int sx, sy, ex, ey;
int head;
{
    do_arrow(sx, sy, ex, ey, head);
}

#endif /* TERM_BODY */

#ifdef TERM_TABLE

TERM_TABLE_START(vws_driver)
    "VWS", "VAX Windowing System (UIS)",
    VWS_XMAX, VWS_YMAX, VWS_VCHAR, VWS_HCHAR,
    VWS_VTIC, VWS_HTIC, options_null, VWS_init, VWS_reset,
    VWS_text, null_scale, VWS_graphics, VWS_move, VWS_vector,
    VWS_linetype, VWS_put_text, VWS_text_angle,
    VWS_justify_text, do_point, do_arrow, set_font_null
TERM_TABLE_END(vws_driver)

#undef LAST_TERM
#define LAST_TERM vws_driver

#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */

#ifdef TERM_HELP
START_HELP(VWS)
"1 VWS",
"?commands set terminal VWS",
"?set terminal VWS",
"?set term VWS",
"?terminal VWS",
"?term VWS",
"?VWS",
" The `VWS` terminal driver supports the VAX Windowing System.  It has",
" no options.  It will sense the display type (monochrome, gray scale,",
" or color.)  All line styles are plotted as solid lines."
END_HELP(VWS)
#endif /* TERM_HELP */