1 /* This file is part of the GNU plotutils package.  Copyright (C) 1995,
2    1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
3 
4    The GNU plotutils package is free software.  You may redistribute it
5    and/or modify it under the terms of the GNU General Public License as
6    published by the Free Software foundation; either version 2, or (at your
7    option) any later version.
8 
9    The GNU plotutils package is distributed in the hope that it will be
10    useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License along
15    with the GNU plotutils package; see the file COPYING.  If not, write to
16    the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
17    Boston, MA 02110-1301, USA. */
18 
19 /* This internal method is invoked before drawing any polyline.  It sets
20    the relevant attributes of a Tektronix display (line type only, since
21    cap type, join type, line width are not supported) to what they should
22    be.
23 
24    Our canonical line types are the same as those of a Tektronix, except
25    that we also support "dotdotdashed" lines.  So setting the line type is
26    straightforward.  kermit's assignment of line types is different from
27    that of a genuine Tektronix, though. */
28 
29 #include "sys-defines.h"
30 #include "extern.h"
31 
32 void
_pl_t_set_attributes(S___ (Plotter * _plotter))33 _pl_t_set_attributes (S___(Plotter *_plotter))
34 {
35   if ((!(_plotter->tek_line_type_is_unknown))
36       && (_plotter->tek_line_type == _plotter->drawstate->line_type))
37     return;
38 
39   switch (_plotter->drawstate->line_type)
40     {
41     default:
42     case PL_L_SOLID:
43       /* ASCII ESC `, i.e. ^[` */
44       _write_string (_plotter->data, "\033`");
45       break;
46     case PL_L_DOTTED:
47       /* ASCII ESC a, i.e. ^[a */
48       _write_string (_plotter->data, "\033a");
49       break;
50       /* following two are interchanged in kermit emulator */
51     case PL_L_DOTDASHED:
52       if (_plotter->tek_display_type == TEK_DPY_KERMIT)
53 	/* ASCII ESC c, i.e. ^[c */
54 	_write_string (_plotter->data, "\033c");
55       else
56 	/* ASCII ESC b, i.e. ^[b */
57 	_write_string (_plotter->data, "\033b");
58       break;
59     case PL_L_SHORTDASHED:
60       if (_plotter->tek_display_type == TEK_DPY_KERMIT)
61 	/* ASCII ESC b, i.e. ^[b */
62 	_write_string (_plotter->data, "\033b");
63       else
64 	/* ASCII ESC c, i.e. ^[c */
65 	_write_string (_plotter->data, "\033c");
66       break;
67     case PL_L_LONGDASHED:
68       /* in kermit emulator, the following switches to "dotlongdashed"
69 	 rather than "longdashed", but we can live with that */
70       /* ASCII ESC d, i.e. ^[d */
71       _write_string (_plotter->data, "\033d");
72       break;
73     case PL_L_DOTDOTDASHED:
74       if (_plotter->tek_display_type == TEK_DPY_KERMIT)
75 	/* ASCII ESC e, i.e. ^[e */
76 	_write_string (_plotter->data, "\033e");
77       else
78 	/* not supported on a genuine Tektronix, so punt */
79 	/* ASCII ESC b, i.e. ^[b */
80 	_write_string (_plotter->data, "\033b");
81       break;
82     case PL_L_DOTDOTDOTDASHED:
83       /* not supported, so punt */
84       /* ASCII ESC b, i.e. ^[b */
85       _write_string (_plotter->data, "\033b");
86       break;
87     }
88 
89   /* Tek now agrees with us on line type */
90   _plotter->tek_line_type = _plotter->drawstate->line_type;
91   _plotter->tek_line_type_is_unknown = false;
92 }
93 
94 /* The reason for the kermit-specific modifications above is that according
95    to kermit documentation, the MS-DOS kermit Tektronix emulator has a
96    different ordering for line types:
97 
98         ` = solid		11111111 11111111
99         a = dotted      	10101010 10101010
100         b = shortdashed		11110000 11110000
101         c = dotdashed           11111010 11111010
102         d = dotlongdashed       11111111 11001100
103         e = dotdotdashed        11111100 10010010
104         x = user defined (by ESC / Pn a)
105         y = user defined (by ESC / Pn b)
106         z = user defined (by ESC / Pn c)
107 
108    Incidentally, line type characters recognized by VT-type terminals in
109    Tektronix emulator mode also allegedly differ.  According to an old doc
110    file,
111 
112         ` = solid
113         a = dotted
114 	b = shortdashed
115 	c = dotdashed
116 	d = dotlongdashed
117 	h = solid (bold)
118         i = dotted (bold)
119         j = shortdashed (bold)
120         k = dotdashed (bold)
121         l = dotlongdashed (bold)
122 
123    Interestingly, BSD atoplot(1) recognizes "dotlongdashed",
124    "dotshortdashed", and "dotdotdashed" (with final "ed" omitted), besides
125    the five canonical Tektronix line types.  So when atoplot(1) was
126    written, there must have been plot(1) filters for output devices that
127    supported those additional types.  Presumably on VT-type terminals? */
128