home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 mARCH / PCWK3A99.iso / Linux / DDD331 / DDD-3_1_.000 / DDD-3_1_ / ddd-3.1.1 / ddd / header.str < prev    next >
Text File  |  1998-12-06  |  10KB  |  364 lines

  1. "% $Id: header.ps,v 1.11 1998/10/05 12:21:09 zeller Exp $\n"
  2. "% Header for DDD PostScript Box output\n"
  3. "\n"
  4. "% Copyright (C) 1995-1998 Technische Universitaet Braunschweig, Germany.\n"
  5. "% Written by Christian Lindig <lindig@ips.cs.tu-bs.de>.\n"
  6. "% \n"
  7. "% This file is part of DDD.\n"
  8. "% \n"
  9. "% DDD is free software; you can redistribute it and/or\n"
  10. "% modify it under the terms of the GNU General Public\n"
  11. "% License as published by the Free Software Foundation; either\n"
  12. "% version 2 of the License, or (at your option) any later version.\n"
  13. "% \n"
  14. "% DDD is distributed in the hope that it will be useful,\n"
  15. "% but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
  16. "% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
  17. "% See the GNU General Public License for more details.\n"
  18. "% \n"
  19. "% You should have received a copy of the GNU General Public\n"
  20. "% License along with DDD -- see the file COPYING.\n"
  21. "% If not, write to the Free Software Foundation, Inc.,\n"
  22. "% 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"
  23. "% \n"
  24. "% DDD is the data display debugger.\n"
  25. "% For details, see the DDD World-Wide-Web page, \n"
  26. "% `http://www.cs.tu-bs.de/softech/ddd/',\n"
  27. "% or send a mail to the DDD developers <ddd@ips.cs.tu-bs.de>.\n"
  28. "\n"
  29. "% Make all definitions local to the ddddict dictionary\n"
  30. "/ddddict 25 dict def \n"
  31. "\n"
  32. "ddddict begin        % make dict active \n"
  33. "\n"
  34. "\n"
  35. "% Global variables\n"
  36. "/fontSize+ 12 def\n"
  37. "/font+ /Courier def  \n"
  38. "\n"
  39. "\n"
  40. "% Some small utilities\n"
  41. "/cm { 28.34646 mul } bind def\n"
  42. "\n"
  43. "\n"
  44. "% ISOLATIN1* - reencode a font to ISO Latin 1 encoding\n"
  45. "%\n"
  46. "% newfont table oldfont isolatin1*\n"
  47. "\n"
  48. "/isolatin1* {\n"
  49. "    findfont\n"
  50. "    dup maxlength dict begin\n"
  51. "    {\n"
  52. "        1 index /FID ne { def } { pop pop } ifelse\n"
  53. "    } forall\n"
  54. "    /Encoding exch def\n"
  55. "    dup /FontName exch def\n"
  56. "    currentdict end definefont pop\n"
  57. "} bind def\n"
  58. "\n"
  59. "\n"
  60. "% Define the ISO Latin 1 encoding of a font\n"
  61. " \n"
  62. "/isotable[\n"
  63. "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n"
  64. "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n"
  65. "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n"
  66. "/.notdef/.notdef/.notdef/.notdef/.notdef/space/exclam/quotedbl/numbersign\n"
  67. "/dollar/percent/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma\n"
  68. "/hyphen/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon\n"
  69. "/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S\n"
  70. "/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore\n"
  71. "/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar\n"
  72. "/braceright/asciitilde/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n"
  73. "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n"
  74. "/.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve/dotaccent/dieresis\n"
  75. "/.notdef/ring/cedilla/.notdef/hungarumlaut/ogonek/caron/.notdef/exclamdown/cent\n"
  76. "/sterling/currency/yen/brokenbar/section/dieresis/copyright/ordfeminine\n"
  77. "/guilsinglleft/logicalnot/hyphen/registered/macron/degree/plusminus/twosuperior\n"
  78. "/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior\n"
  79. "/ordmasculine/guilsinglright/onequarter/onehalf/threequarters/questiondown\n"
  80. "/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla/Egrave/Eacute\n"
  81. "/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis/Eth/Ntilde/Ograve\n"
  82. "/Oacute/Ocircumflex/Otilde/Odieresis/multiply/Oslash/Ugrave/Uacute/Ucircumflex\n"
  83. "/Udieresis/Yacute/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis\n"
  84. "/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave/iacute\n"
  85. "/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis\n"
  86. "/divide/oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis\n"
  87. "] def\n"
  88. "\n"
  89. "\n"
  90. "% YCORRECT*\n"
  91. "% The reference point of a string ist NOT its lower left corner but \n"
  92. "% its baseline.  Therefore, the y coordinate must be corrected.  \n"
  93. "% Returns the correction for the current font.\n"
  94. "%\n"
  95. "% ycorrect* y\n"
  96. "\n"
  97. "/ycorrect* {\n"
  98. "    currentfont /FontBBox get\n"
  99. "    aload pop pop pop\n"
  100. "    currentfont /FontMatrix get dtransform\n"
  101. "    exch pop\n"
  102. "} def \n"
  103. "\n"
  104. "\n"
  105. "% TEXT*\n"
  106. "% print out a string and make sure not to require more space than\n"
  107. "% specified.\n"
  108. "% font xsize ysize xorigin yorigin (string) text*\n"
  109. "\n"
  110. "/text* {\n"
  111. "\n"
  112. "    /string+ exch def        % set up some variables ..\n"
  113. "    moveto                % move to (xorigin,yorigin)\n"
  114. "    /ysize+ exch def\n"
  115. "    /xsize+ exch def\n"
  116. "    /thefont+ exch def\n"
  117. "\n"
  118. "    % is the right font already selected ?\n"
  119. "\n"
  120. "    thefont+ font+ ne \n"
  121. "    ysize+ fontSize+ ne\n"
  122. "    or {    \n"
  123. "        % set up the right font - reencode it    \n"
  124. "        \n"
  125. "        /Symbol thefont+ eq \n"
  126. "        {\n"
  127. "            thefont+ findfont\n"
  128. "        }{\n"
  129. "\n"
  130. "            /isofont+ isotable thefont+ isolatin1*    \n"
  131. "            /isofont+ findfont\n"
  132. "        }ifelse\n"
  133. "\n"
  134. "        [ysize+ 0 0 ysize+ neg 0 0] makefont\n"
  135. "        setfont\n"
  136. "        \n"
  137. "        /font+ thefont+ def\n"
  138. "        /fontSize+ ysize+ def\n"
  139. "    } if\n"
  140. "\n"
  141. "    % correct current point \n"
  142. "\n"
  143. "    0 ycorrect* neg rmoveto\n"
  144. "\n"
  145. "    % string too long?  Scale it down ...\n"
  146. "    % The actual font is scaled. There is a good chance,\n"
  147. "    % that this will not happen too often when the font is not\n"
  148. "    % changed during the calls of text*\n"
  149. "\n"
  150. "    xsize+ string+ stringwidth pop div dup dup\n"
  151. "    1 lt {\n"
  152. "        0 0 1 0 0 6 array astore currentfont exch \n"
  153. "        makefont setfont\n"
  154. "        pop\n"
  155. "    }{ \n"
  156. "        % string is too short ... scale it up\n"
  157. "\n"
  158. "        1.05 gt {\n"
  159. "            0 0 1 0 0 6 array astore currentfont exch \n"
  160. "            makefont setfont    \n"
  161. "        }{\n"
  162. "            pop\n"
  163. "\n"
  164. "        } ifelse\n"
  165. "    } ifelse\n"
  166. "    \n"
  167. "    string+ show\n"
  168. "\n"
  169. "} bind def\n"
  170. "\n"
  171. "    \n"
  172. "% ARROWLINE*\n"
  173. "% Draw a line of given width with an arrow at its end\n"
  174. "% len gives the height of the triangle forming the head of the arrow\n"
  175. "% and angle the angle at its top\n"
  176. "%    \n"
  177. "% angle len  x1 y1 x2 y2 linewidth arrowline*\n"
  178. "\n"
  179. "/arrowline* {\n"
  180. "    setlinewidth            % angle len x1 y1 x2 y2\n"
  181. "    /y2 exch def\n"
  182. "    /x2 exch def\n"
  183. "    /y1 exch def\n"
  184. "    /x1 exch def\n"
  185. "    /len+ exch def            % height of triangle\n"
  186. "\n"
  187. "    /alpha+ \n"
  188. "        y2 y1 sub        % define alpha+\n"
  189. "        x2 x1 sub\n"
  190. "        atan\n"
  191. "    def\n"
  192. "\n"
  193. "    /base+                % define half of baseline\n"
  194. "        exch \n"
  195. "        2 div dup        % angle angle\n"
  196. "        sin exch cos          % sin(angle) cos(angle)\n"
  197. "        div            % tan(angle)\n"
  198. "        len+\n"
  199. "        mul            % half of baseline\n"
  200. "    def  \n"
  201. "    \n"
  202. "    newpath                % draw the line\n"
  203. "    x1 y1 moveto \n"
  204. "    x2 len+ alpha+ cos mul sub     % shorten the line to the end  \n"
  205. "    y2 len+ alpha+ sin mul sub     % of the triangle\n"
  206. "    lineto\n"
  207. "    stroke        \n"
  208. "\n"
  209. "    gsave                % set the origin to the head of\n"
  210. "    0 setlinewidth            % the arrow and rotate the system\n"
  211. "    x2 y2 \n"
  212. "    translate            % origin now at x2 y2\n"
  213. "\n"
  214. "    alpha+ 90 sub rotate         % rotate the system\n"
  215. "\n"
  216. "    newpath                % draw a triangle\n"
  217. "    0 0 moveto\n"
  218. "    base+ len+ neg rlineto\n"
  219. "    base+ 2 mul neg 0 rlineto\n"
  220. "    closepath\n"
  221. "    fill\n"
  222. "    \n"
  223. "    grestore\n"
  224. "} bind def\n"
  225. "\n"
  226. "% ARROWHEAD*\n"
  227. "% draw an arrow head inclined by alpha at (x,y)\n"
  228. "%\n"
  229. "% angle len alpha x y\n"
  230. "\n"
  231. "/arrowhead* {\n"
  232. "    /y exch def\n"
  233. "    /x exch def\n"
  234. "    /alpha+ exch def\n"
  235. "    /len+ exch def            % height of triangle\n"
  236. "\n"
  237. "    /base+                % define half of baseline\n"
  238. "        exch \n"
  239. "        2 div dup        % angle angle\n"
  240. "        sin exch cos          % sin(angle) cos(angle)\n"
  241. "        div            % tan(angle)\n"
  242. "        len+\n"
  243. "        mul            % half of baseline\n"
  244. "    def\n"
  245. "\n"
  246. "    gsave                % set the origin to the head of\n"
  247. "    0 setlinewidth            % the arrow and rotate the system\n"
  248. "    x y \n"
  249. "    translate            % origin now at x y\n"
  250. "\n"
  251. "    alpha+ 90 sub rotate         % rotate the system\n"
  252. "\n"
  253. "    newpath                % draw a triangle\n"
  254. "    0 0 moveto\n"
  255. "    base+ len+ neg rlineto\n"
  256. "    base+ 2 mul neg 0 rlineto\n"
  257. "    closepath\n"
  258. "    fill\n"
  259. "    \n"
  260. "    grestore\n"
  261. "} bind def\n"
  262. "\n"
  263. "\n"
  264. "% LINE*\n"
  265. "% draw a line of given width from (x1,y1) to (x2,y2)\n"
  266. "%\n"
  267. "% x1 y1 x2 y2 width line*\n"
  268. "\n"
  269. "/line* {\n"
  270. "    setlinewidth    % x1 y1 x2 y2\n"
  271. "    newpath\n"
  272. "    4 2 roll     % x2 y2 x1 y1\n"
  273. "    moveto        % x2 y2\n"
  274. "    lineto        \n"
  275. "    stroke\n"
  276. "} bind def\n"
  277. "\n"
  278. "\n"
  279. "% CLEAN*\n"
  280. "%\n"
  281. "% fill a box given by four points with white colour ..\n"
  282. "% x1 y1 x2 y2 x3 y3 x4 y4 clean*\n"
  283. "\n"
  284. "/clean* {\n"
  285. "    gsave\n"
  286. "    1 setgray\n"
  287. "    0 setlinewidth\n"
  288. "    newpath\n"
  289. "    moveto  lineto  lineto lineto\n"
  290. "    closepath\n"
  291. "    fill\n"
  292. "    grestore\n"
  293. "} bind def\n"
  294. "\n"
  295. "\n"
  296. "% BOX*\n"
  297. "% fill a box given by four points\n"
  298. "%\n"
  299. "% x1 y1 x2 y2 x3 y3 x4 y4 box*\n"
  300. "\n"
  301. "/box* {\n"
  302. "    0 setlinewidth\n"
  303. "    newpath\n"
  304. "    moveto     lineto     lineto lineto\n"
  305. "    closepath\n"
  306. "    fill\n"
  307. "} bind def\n"
  308. "\n"
  309. "\n"
  310. "% ARC*\n"
  311. "% draw an ellipse with center (cx,cy), radius dx dy, starting at start\n"
  312. "% and ending at end.\n"
  313. "%\n"
  314. "% start end dx dy cx cy width arc*\n"
  315. "\n"
  316. "/arc* {\n"
  317. "    gsave\n"
  318. "    setlinewidth\n"
  319. "    translate\n"
  320. "    newpath\n"
  321. "    dup 3 1 roll        % start end dy dx dy\n"
  322. "    div 1 scale        % dy dx/dy 1 scale => start end dy\n"
  323. "    \n"
  324. "    0 exch  0 exch        % start end 0 0 dy \n"
  325. "    5 -2 roll         % 0 0 dy start end\n"
  326. "\n"
  327. "    dup\n"
  328. "    0 eq {            % replace 0 by 360\n"
  329. "        pop \n"
  330. "        360\n"
  331. "    } if\n"
  332. "    arc\n"
  333. "    stroke\n"
  334. "    grestore\n"
  335. "} bind def\n"
  336. "\n"
  337. "\n"
  338. "% BEGINCOLOR* / ENDCOLOR*\n"
  339. "% Draw something using a specific foreground color\n"
  340. "%\n"
  341. "% red green blue begincolor* SOMETHING endcolor*\n"
  342. "\n"
  343. "/begincolor* {\n"
  344. "        currentrgbcolor         % red green blue red' green' blue'\n"
  345. "        6 3 roll                % red' green' blue' red green blue\n"
  346. "    setrgbcolor             % red' green' blue'\n"
  347. "} bind def\n"
  348. "\n"
  349. "/endcolor* {\n"
  350. "    setrgbcolor\n"
  351. "} bind def\n"
  352. "\n"
  353. "\n"
  354. "% Set up the right font to the right size\n"
  355. "\n"
  356. "/isofont+ isotable font+ isolatin1*     % reencode font+\n"
  357. "                    % and make it the current font\n"
  358. "/isofont+ findfont\n"
  359. "[fontSize+ 0 0 fontSize+ neg 0 0] makefont\n"
  360. "setfont\n"
  361. "\n"
  362. "\n"
  363. "%%EndProlog\n"
  364.