t_attribs.c 4.6 KB

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