1 /* Hello, Emacs, this is -*-C-*-
2 * $Id: vws.trm,v 1.18 2006/07/21 02:35:48 sfeam Exp $
6 /* GNUPLOT - vws.trm */
9 * Copyright 1990 - 1993, 1998, 2004
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.
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,
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
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.
34 * This software is provided "as is" without express or implied warranty
35 * to the extent permitted by applicable law.
39 * This file is included by ../term.c.
41 * This terminal driver supports:
46 * BITNET: SPETH@DBNPIB5
48 * send your comments or suggestions to (gnuplot-info@lists.sourceforge.net).
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)
64 TERM_PUBLIC void VWS_init __PROTO((void));
65 TERM_PUBLIC void VWS_reset __PROTO((void));
66 TERM_PUBLIC void VWS_graphics __PROTO((void));
67 TERM_PUBLIC void VWS_text __PROTO((void));
68 TERM_PUBLIC void VWS_move __PROTO((unsigned int x, unsigned int y));
69 TERM_PUBLIC void VWS_vector __PROTO((unsigned int x, unsigned int y));
70 TERM_PUBLIC void VWS_linetype __PROTO((int lt));
71 TERM_PUBLIC void VWS_put_text __PROTO((unsigned int x, unsigned int y, const char *str));
72 TERM_PUBLIC int VWS_text_angle __PROTO((int ang));
73 TERM_PUBLIC int VWS_justify_text __PROTO((enum JUSTIFY mode));
74 TERM_PUBLIC void VWS_point __PROTO((unsigned int x, unsigned int y, int point));
75 TERM_PUBLIC void VWS_arrow __PROTO((unsigned int sx, unsigned int sy,
76 unsigned int ex, unsigned int ey, int head));
79 #define VWS_YMAX 780 /* VAXstation 2000 is 864 */
84 #endif /* TERM_PROTO */
86 #ifndef TERM_PROTO_ONLY
88 void VWS_resize_ast __PROTO((void));
95 #include <uisusrdef.h>
97 #define DEFAULT_ATTR 0
106 float current_x, current_y;
111 static $DESCRIPTOR(ws_devname, "SYS$WORKSTATION");
112 static $DESCRIPTOR(vd_title, "gnuplot");
114 static float x0, y0, xsiz, ysiz, wc_xmin_new, wc_ymin_new, wc_xmax_new, wc_ymax_new, wc_xmin,
115 wc_ymin, wc_xmax, wc_ymax, vd_width, vd_height;
120 uis$resize_window(&vd_id, &wd_id, &x0, &y0, &xsiz, &ysiz,
121 &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax);
125 /****************************************************************************/
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;
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
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
162 /* lph: Color map corresponding to an example in
163 * MicroVMS Graphics Progamming Guide (V3.0) */
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 };
169 /* the array format is easier to customize */
172 vd_height = 10; /* aspect sqrt(2) as DIN A paper */
176 wc_xmax = (float) VWS_XMAX;
177 wc_ymax = (float) VWS_YMAX;
179 vcm_id = uis$create_color_map(&i8);
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);
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 */
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);
208 /* ws: perhaps better for color terms (which I do not have) */
210 else if (ws_type == UIS$C_DEV_COLOR) {
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);
221 * lph: Another way to set up the color table is to use arrays,
222 * which simplifies customizing the appearance.
224 uis$set_colors(&vd_id, &i0, &i8, &r_map, &g_map, &b_map);
227 uis$disable_display_list(&vd_id);
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);
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);
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
240 * The attribute blocks used for writing are line_attr, text_attr.
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);
247 /* lph: this was commented out; it changes the COLOR_ATTR BLOCK and
248 * the following BLOCKS
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);
259 /* lph: default value for the background index into the virtual color
260 * table is 0, and the back_attr block is never used
262 uis$set_background_index(&vd_id, &default_attr, &back_attr, &i0);
264 * the rest look OK, setting up the two attribute blocks
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);
272 /****************************************************************************/
277 uis$delete_display(&vd_id);
280 /****************************************************************************/
284 uis$erase(&vd_id, &wc_xmin, &wc_ymin, &wc_xmax, &wc_ymax);
287 /****************************************************************************/
293 /****************************************************************************/
295 VWS_move(unsigned int x, unsigned int y)
297 current_x = (float) (x);
298 current_y = (float) (y);
301 /****************************************************************************/
303 VWS_vector(unsigned int x, unsigned int y)
306 int line_attr = LINE_ATTR;
311 uis$line(&vd_id, &line_attr, ¤t_x, ¤t_y, &fx, &fy);
315 /****************************************************************************/
319 const int n1 = 0xFFFFFFFF;
320 /* indices into the color map */
321 const int i[8] = {0, 1, 2, 3, 4, 5, 6, 7};
322 const float p15 = 2.0, p20 = 3.0, p10 = 1.0;
334 int line_attr = LINE_ATTR;
335 /* use multiplier of normal line width; default is width in pixels */
336 const int uis$c_width_world = UIS$C_WIDTH_WORLD;
340 case LT_AXIS: /* used for axis */
341 uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
342 uis$set_line_width(&vd_id, &line_attr, &line_attr, &p15,
344 if (ws_type >= UIS$C_DEV_INTENSITY) {
345 uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1]);
348 case LT_BLACK: /* the borders */
349 uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
350 uis$set_line_width(&vd_id, &line_attr, &line_attr, &p20,
352 if (ws_type >= UIS$C_DEV_INTENSITY) {
353 uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1]);
356 default: /* else a thick line ? */
357 uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
358 uis$set_line_width(&vd_id, &line_attr, &line_attr, &p20,
360 if (ws_type >= UIS$C_DEV_INTENSITY) {
361 uis$set_writing_index(&vd_id, &line_attr, &line_attr,
362 &i[1 + ((-lt) % 7)]);
367 /* assign the color index (excluding the background index, 0*/
368 if (ws_type >= UIS$C_DEV_INTENSITY) {
369 uis$set_writing_index(&vd_id, &line_attr, &line_attr, &i[1 + lt % 7]);
371 /* assign the line style
372 uis$set_line_style(&vd_id,&line_attr,&line_attr,&lstyle[lt % 8]);
373 * ws: makes part of curve disappear on my workstation
374 * lph: also observed w/ VS2000 and 4 plane graphics coprocesssor; line
375 * types change appropriately, but has problems as pixels/line segment
376 * decreases. Better with full screen display and "set samples" smaller
377 * but start out with only solid lines
379 uis$set_line_style(&vd_id, &line_attr, &line_attr, &n1);
381 uis$set_line_width(&vd_id, &line_attr, &line_attr, &p10,
386 /****************************************************************************/
387 static int justify_mode = CENTRE, up;
390 VWS_put_text(unsigned int x, unsigned int y, const char *str)
392 float fx, fy, thih, twid;
393 int text_attr = TEXT_ATTR;
395 /* uis$text parameter is descriptor string not character string */
397 struct dsc$descriptor_s textline =
398 {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, ""};
401 textline.dsc$a_pointer = str;
402 textline.dsc$w_length = strlen(textline.dsc$a_pointer);
403 uis$measure_text(&vd_id, &text_attr, &textline, &twid, &thih);
407 switch (justify_mode) {
422 uis$text(&vd_id, &text_attr, &textline, &fx, &fy);
423 /* write to Example Viewport window */
427 /****************************************************************************/
429 VWS_text_angle(int ang)
432 int text_attr = TEXT_ATTR;
435 uis$set_text_slope(&vd_id, &text_attr, &text_attr, °rees);
438 /****************************************************************************/
440 VWS_justify_text(enum JUSTIFY mode)
445 /****************************************************************************/
447 VWS_point(unsigned int x, unsigned int y, int point)
449 do_point(x, y, point);
452 /****************************************************************************/
455 unsigned int sx, unsigned int sy,
456 unsigned int ex, unsigned int ey,
459 do_arrow(sx, sy, ex, ey, head);
462 #endif /* TERM_BODY */
466 TERM_TABLE_START(vws_driver)
467 "VWS", "VAX Windowing System (UIS)",
468 VWS_XMAX, VWS_YMAX, VWS_VCHAR, VWS_HCHAR,
469 VWS_VTIC, VWS_HTIC, options_null, VWS_init, VWS_reset,
470 VWS_text, null_scale, VWS_graphics, VWS_move, VWS_vector,
471 VWS_linetype, VWS_put_text, VWS_text_angle,
472 VWS_justify_text, do_point, do_arrow, set_font_null
473 TERM_TABLE_END(vws_driver)
476 #define LAST_TERM vws_driver
478 #endif /* TERM_TABLE */
479 #endif /* TERM_PROTO_ONLY */
484 "?commands set terminal VWS",
490 " The `VWS` terminal driver supports the VAX Windowing System. It has",
491 " no options. It will sense the display type (monochrome, gray scale,",
492 " or color.) All line styles are plotted as solid lines."
494 #endif /* TERM_HELP */