| 1 |
% grestore |
| 2 |
% special commands for setting up tree macros |
| 3 |
%% version .91 - May 16, 1995 |
| 4 |
|
| 5 |
TeXDict begin |
| 6 |
|
| 7 |
% the commands needed to get any of this working. The first section |
| 8 |
% may need to be modified if different dvi to postscript programs are |
| 9 |
% used. |
| 10 |
|
| 11 |
% redefinition of /@beginspec suggested by Gintas Grigelionis |
| 12 |
% ([email protected]) 5/95. also dropped bop_hook and texpsmatrix |
| 13 |
% |
| 14 |
% /@beginspec {gsave texpsmatrix setmatrix treedict begin} def |
| 15 |
/@beginspec {gsave |
| 16 |
Resolution 72 div VResolution -72 div scale |
| 17 |
treedict begin} def |
| 18 |
/@endspec {end grestore} def |
| 19 |
|
| 20 |
% for landscape Landscape=true, letter Landscape=false |
| 21 |
% In dvips 5.5 and later, the matrix in landscape was changed from |
| 22 |
% [0.0 -1.0 1.0 0.0 0.0 0.0] to the current setting of [0.0 1.0 -1.0 |
| 23 |
% 0.0 0.0 0.0]. If you are using an earlier version, switch back. |
| 24 |
|
| 25 |
/treedict 200 dict def treedict begin |
| 26 |
|
| 27 |
% num pt num (converts a number in TeX pts (72.27 pts/in) to |
| 28 |
% postscript pts (72pts/in) |
| 29 |
/pt {72 mul 72.07 div} def |
| 30 |
|
| 31 |
% end of first section |
| 32 |
|
| 33 |
% definition of a node as a box containing the following information |
| 34 |
% The x y location of the lower left hand corner of the box |
| 35 |
% the height of the box (h) |
| 36 |
% the width of the box (w) |
| 37 |
% nodemargin is added to all sides to ensure a boundary around the box |
| 38 |
% str w h d node - |
| 39 |
% (nodemargin is defined in the TeX file) |
| 40 |
/nodemargin 2 def |
| 41 |
/nodes 100 dict def |
| 42 |
/node { /dpth exch def |
| 43 |
/hght exch def |
| 44 |
/wdth exch def |
| 45 |
4 dict dup begin |
| 46 |
/x /y currentpoint |
| 47 |
dpth sub nodemargin sub exch 3 1 roll def |
| 48 |
nodemargin sub def |
| 49 |
/h hght dpth add nodemargin dup add add def |
| 50 |
/w wdth nodemargin dup add add def |
| 51 |
end nodes 3 1 roll put} def |
| 52 |
|
| 53 |
|
| 54 |
% commands to find various locations around the nodebox |
| 55 |
% |
| 56 |
% nodetopleft nodetop nodetopright |
| 57 |
% *--------*--------* |
| 58 |
% | | |
| 59 |
% | | |
| 60 |
% nodeleft * (nodebox) * noderight |
| 61 |
% | | |
| 62 |
% | | |
| 63 |
% *--------*--------* |
| 64 |
% nodebotleft nodebottom nodebotright |
| 65 |
% |
| 66 |
|
| 67 |
|
| 68 |
% all of these take |
| 69 |
% dict nodebottom x1 y1 [dict has x y h w defined] |
| 70 |
/nodebottom {begin |
| 71 |
x w 2 div add y |
| 72 |
end} def |
| 73 |
/nodetop {begin |
| 74 |
x w 2 div add y h add |
| 75 |
end} def |
| 76 |
/nodeleft {begin |
| 77 |
x y h 2 div add |
| 78 |
end} def |
| 79 |
/noderight {begin |
| 80 |
x w add y h 2 div add |
| 81 |
end} def |
| 82 |
/nodetopleft {begin |
| 83 |
x y h add |
| 84 |
end} def |
| 85 |
/nodetopright {begin |
| 86 |
x w add y h add |
| 87 |
end} def |
| 88 |
/nodebottomleft {begin |
| 89 |
x y |
| 90 |
end} def |
| 91 |
/nodebottomright {begin |
| 92 |
x w add y |
| 93 |
end} def |
| 94 |
|
| 95 |
% some more locations of use |
| 96 |
/farright {begin |
| 97 |
x w add depth add h 2 div y add |
| 98 |
end} def |
| 99 |
|
| 100 |
/farleft {begin |
| 101 |
x depth sub h 2 div y add |
| 102 |
end} def |
| 103 |
|
| 104 |
/farbottom {begin |
| 105 |
x w 2 div add y depth sub |
| 106 |
end} def |
| 107 |
|
| 108 |
/fartop {begin |
| 109 |
x w 2 div add y h add depth add |
| 110 |
end} def |
| 111 |
|
| 112 |
/farbottomleft {begin |
| 113 |
x depth 45 cos mul sub y depth 45 sin mul sub |
| 114 |
end} def |
| 115 |
|
| 116 |
/farbottomright {begin |
| 117 |
x w add depth 45 cos mul add y depth 45 sin mul sub |
| 118 |
end} def |
| 119 |
|
| 120 |
/fartopright {begin |
| 121 |
x w add depth 45 cos mul add y h add depth 45 sin mul add |
| 122 |
end} def |
| 123 |
|
| 124 |
/fartopleft {begin |
| 125 |
x depth 45 cos mul sub y h add depth 45 sin mul add |
| 126 |
end} def |
| 127 |
|
| 128 |
|
| 129 |
% connects two nodes with a straight line |
| 130 |
% add location information (e.g., whether to go from |
| 131 |
% nodetop to nodeleft ... |
| 132 |
|
| 133 |
% nodename1 loc1 nodename2 loc2 nodeconnect - |
| 134 |
% e.g., a nodetop b nodebottom nodeconnect |
| 135 |
|
| 136 |
% to see if straight lines are indeed straight |
| 137 |
% x1 x2 alignpoint x1' x2' finds out if the two numbers are less than |
| 138 |
% one pixel apart if so make x1'=x2' |
| 139 |
|
| 140 |
/alignpoint {2 copy sub abs 1 le {add 2 div round dup} if} def |
| 141 |
|
| 142 |
% nodelocation nodename getnodepoint x y |
| 143 |
/getnode {nodes exch get} def |
| 144 |
|
| 145 |
% xfrom yfrom xto yto nodeconnect - |
| 146 |
/nodeconnect { gsave |
| 147 |
transform 4 2 roll |
| 148 |
transform |
| 149 |
exch 4 1 roll alignpoint |
| 150 |
4 2 roll alignpoint |
| 151 |
4 1 roll exch |
| 152 |
itransform moveto itransform lineto |
| 153 |
stroke |
| 154 |
grestore |
| 155 |
} def |
| 156 |
|
| 157 |
% arrowheads |
| 158 |
% xtail ytail xtip ytip headthickness headlength insetlength arrow - |
| 159 |
|
| 160 |
/arrowdict 15 dict def |
| 161 |
|
| 162 |
arrowdict begin |
| 163 |
/mtrx matrix def |
| 164 |
end |
| 165 |
|
| 166 |
/arrow {arrowdict begin |
| 167 |
/insetlength exch def |
| 168 |
/headlength exch def |
| 169 |
/halfheadthickness exch 2 div def |
| 170 |
/tipy exch def /tipx exch def |
| 171 |
/taily exch def /tailx exch def |
| 172 |
|
| 173 |
/dx tipx tailx sub def |
| 174 |
/dy tipy taily sub def |
| 175 |
/angle dy dx atan def |
| 176 |
|
| 177 |
/savematrix mtrx currentmatrix def |
| 178 |
tipx tipy translate |
| 179 |
angle rotate |
| 180 |
% following is for arrow |
| 181 |
0 0 moveto |
| 182 |
headlength neg halfheadthickness neg lineto |
| 183 |
headlength insetlength sub neg 0 lineto |
| 184 |
headlength neg halfheadthickness lineto |
| 185 |
closepath |
| 186 |
fill |
| 187 |
savematrix setmatrix |
| 188 |
end } def |
| 189 |
|
| 190 |
% does regular filled arrowhead |
| 191 |
/arrowfill {gsave |
| 192 |
newpath |
| 193 |
arrowwidth arrowlength arrowinset arrow |
| 194 |
grestore} def |
| 195 |
|
| 196 |
% draws line for arrow but not arrow head(s) |
| 197 |
% xtail ytail xtip ytip tailfix tipfix arrowline |
| 198 |
/arrowline {arrowdict begin |
| 199 |
gsave |
| 200 |
newpath |
| 201 |
/tipfix exch def |
| 202 |
/tailfix exch def |
| 203 |
/tipy exch def /tipx exch def |
| 204 |
/taily exch def /tailx exch def |
| 205 |
|
| 206 |
/dx tipx tailx sub def |
| 207 |
/dy tipy taily sub def |
| 208 |
/angle dy dx atan def |
| 209 |
|
| 210 |
/savematrix mtrx currentmatrix def |
| 211 |
tipx tipy translate |
| 212 |
angle rotate |
| 213 |
tipfix neg 0 moveto |
| 214 |
savematrix setmatrix |
| 215 |
/savematrix mtrx currentmatrix def |
| 216 |
tailx taily translate |
| 217 |
angle rotate |
| 218 |
tailfix 0 lineto |
| 219 |
savematrix setmatrix |
| 220 |
stroke |
| 221 |
grestore |
| 222 |
end} def |
| 223 |
|
| 224 |
|
| 225 |
% xfrom yfrom xto yto testcmd - |
| 226 |
% arrownodeconnect |
| 227 |
/arrownodeconnect{ gsave |
| 228 |
transform 4 2 roll |
| 229 |
transform |
| 230 |
exch 4 1 roll alignpoint |
| 231 |
4 2 roll alignpoint |
| 232 |
4 1 roll exch |
| 233 |
itransform 4 2 roll itransform |
| 234 |
% line |
| 235 |
4 copy |
| 236 |
0 arrowdict begin arrowlength arrowinset sub end arrowline |
| 237 |
% arrow |
| 238 |
gsave |
| 239 |
newpath |
| 240 |
arrowfill |
| 241 |
grestore |
| 242 |
grestore |
| 243 |
} def |
| 244 |
|
| 245 |
|
| 246 |
/doublearrownodeconnect{ gsave |
| 247 |
transform 4 2 roll |
| 248 |
transform |
| 249 |
exch 4 1 roll alignpoint |
| 250 |
4 2 roll alignpoint |
| 251 |
4 1 roll exch |
| 252 |
itransform 4 2 roll itransform |
| 253 |
% line |
| 254 |
% 4 copy moveto lineto |
| 255 |
% stroke |
| 256 |
4 copy |
| 257 |
arrowdict begin arrowlength arrowinset sub end dup arrowline |
| 258 |
4 copy |
| 259 |
% arrow at one end |
| 260 |
gsave |
| 261 |
newpath |
| 262 |
arrowfill |
| 263 |
grestore |
| 264 |
% arrow at other end |
| 265 |
gsave |
| 266 |
newpath |
| 267 |
4 2 roll arrowfill |
| 268 |
grestore |
| 269 |
grestore |
| 270 |
} def |
| 271 |
|
| 272 |
|
| 273 |
% connecting with a bar like |
| 274 |
% _______________ |
| 275 |
% | | |
| 276 |
% or like |
| 277 |
% _______________ |
| 278 |
% | | |
| 279 |
% | node |
| 280 |
% node |
| 281 |
|
| 282 |
% depth fromnode fromloc tonode toloc |
| 283 |
% depth x1 y1 x2 y2 barnodeconnect - |
| 284 |
/barnodeconnect {4 2 roll |
| 285 |
2 copy moveto |
| 286 |
5 -1 roll add |
| 287 |
dup 3 1 roll |
| 288 |
lineto |
| 289 |
2 index exch |
| 290 |
lineto lineto |
| 291 |
stroke |
| 292 |
} def |
| 293 |
|
| 294 |
/arrowbarnodeconnect {4 2 roll |
| 295 |
2 copy moveto |
| 296 |
5 -1 roll add |
| 297 |
dup 3 1 roll |
| 298 |
lineto |
| 299 |
2 index exch |
| 300 |
4 copy lineto lineto |
| 301 |
gsave |
| 302 |
newpath |
| 303 |
4 2 roll |
| 304 |
arrowfill |
| 305 |
fill |
| 306 |
grestore |
| 307 |
stroke |
| 308 |
} def |
| 309 |
|
| 310 |
|
| 311 |
% Takes two nodes and forms a triangle |
| 312 |
% node1 |
| 313 |
% /\ |
| 314 |
% / \ |
| 315 |
% ---- |
| 316 |
% nodess |
| 317 |
% |
| 318 |
% fromnodename tonodename nodetriangle - |
| 319 |
/nodetriangle { |
| 320 |
gsave |
| 321 |
exch |
| 322 |
nodes exch get nodebottom moveto |
| 323 |
dup |
| 324 |
nodes exch get nodetopleft lineto |
| 325 |
nodes exch get nodetopright lineto |
| 326 |
closepath |
| 327 |
stroke |
| 328 |
grestore } def |
| 329 |
|
| 330 |
|
| 331 |
% not sure what I am using the following for |
| 332 |
% x y x y slope num |
| 333 |
/slope {/y1 exch def |
| 334 |
/x1 exch def |
| 335 |
/y0 exch def |
| 336 |
/x0 exch def |
| 337 |
y1 y0 sub x1 x0 sub div |
| 338 |
} def |
| 339 |
|
| 340 |
% x y x y midpoint x y |
| 341 |
/midpoint {/y1 exch def |
| 342 |
/x1 exch def |
| 343 |
/y0 exch def |
| 344 |
/x0 exch def |
| 345 |
x1 x0 sub abs |
| 346 |
x1 x0 ge {x0 add} {x1 add} ifelse |
| 347 |
y1 y0 sub abs |
| 348 |
y1 y0 ge {y0 add} {y1 add} ifelse |
| 349 |
} def |
| 350 |
|
| 351 |
|
| 352 |
% variant of curveto where x1 y1 = x2 y2 |
| 353 |
/tancurveto {1 index exch |
| 354 |
curveto} def |
| 355 |
|
| 356 |
/nodetancurve {/depth exch def |
| 357 |
/to exch def |
| 358 |
/from exch def |
| 359 |
gsave |
| 360 |
nodes from get noderight moveto |
| 361 |
|
| 362 |
nodes to get noderight |
| 363 |
tancurveto |
| 364 |
stroke |
| 365 |
grestore } def |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
% the node curves draw curves between two points |
| 370 |
% |
| 371 |
% this swaps a dictionary around an angle, pulls out depth, & dismisses |
| 372 |
% the dictionary. |
| 373 |
% node locname farloc angle depth |
| 374 |
|
| 375 |
/getloc {3 -1 roll |
| 376 |
nodes exch get dup |
| 377 |
begin depth end |
| 378 |
3 1 roll |
| 379 |
exch cvx exec |
| 380 |
4 2 roll} def |
| 381 |
|
| 382 |
% nodename rightcur x1 y1 x2 y2 |
| 383 |
/rightcur {0 /noderight getloc} def |
| 384 |
/leftcur {180 /nodeleft getloc } def |
| 385 |
/topcur {90 /nodetop getloc} def |
| 386 |
/bottomcur {270 /nodebottom getloc} def |
| 387 |
/topleftcur {135 /nodetopleft getloc} def |
| 388 |
/toprightcur {45 /nodetopright getloc} def |
| 389 |
/bottomleftcur {225 /nodebottomleft getloc} def |
| 390 |
/bottomrightcur {315 /nodebottomright getloc} def |
| 391 |
|
| 392 |
% (depth predefined) x1 y1 x2 y2 x3 y3 x4 y4 nodecurve - |
| 393 |
% where nodename nodeposition produces x1 y1 x2 y2 |
| 394 |
% where x1 y1 are the endpoint, x2 y2 end-control, etc. |
| 395 |
|
| 396 |
% adjustments for arrowheads, etc. |
| 397 |
/arrowfiddledict 10 dict def |
| 398 |
|
| 399 |
% x1 y1 angle depth shift twist arrowfiddle x3 y3 x4 y4 |
| 400 |
% where x3 y3 are revised endpoint for arrow-headed bezier curves |
| 401 |
/arrowfiddle {arrowfiddledict begin |
| 402 |
/twist exch def |
| 403 |
/shift exch def |
| 404 |
/shaft exch def |
| 405 |
/angle exch twist add def |
| 406 |
/tipy exch def /tipx exch def |
| 407 |
tipx angle cos shaft mul add |
| 408 |
tipy angle sin shaft mul add |
| 409 |
tipx angle cos shift mul add |
| 410 |
tipy angle sin shift mul add |
| 411 |
end} def |
| 412 |
|
| 413 |
/nodecurve {gsave |
| 414 |
0 fromangle arrowfiddle moveto |
| 415 |
6 2 roll |
| 416 |
0 toangle arrowfiddle curveto |
| 417 |
stroke |
| 418 |
grestore} def |
| 419 |
|
| 420 |
/arrownodecurve {gsave |
| 421 |
0 fromangle arrowfiddle % adjust from angle |
| 422 |
moveto |
| 423 |
6 2 roll |
| 424 |
4 copy 10 4 roll % prepare arrowhead material |
| 425 |
arrowlength arrowinset sub %arrowfiddle param. |
| 426 |
toangle % ditto |
| 427 |
arrowfiddle |
| 428 |
curveto |
| 429 |
0 toangle arrowfiddle arrowfill |
| 430 |
stroke |
| 431 |
grestore} def |
| 432 |
|
| 433 |
/arrow2nodecurve {gsave |
| 434 |
4 copy |
| 435 |
0 fromangle arrowfiddle arrowfill |
| 436 |
arrowlength arrowinset sub fromangle arrowfiddle |
| 437 |
moveto |
| 438 |
6 2 roll |
| 439 |
4 copy 10 4 roll % prepare arrowhead material |
| 440 |
arrowlength arrowinset sub %arrowfiddle param. |
| 441 |
toangle % ditto |
| 442 |
arrowfiddle |
| 443 |
curveto |
| 444 |
0 toangle arrowfiddle arrowfill |
| 445 |
stroke |
| 446 |
grestore} def |
| 447 |
|
| 448 |
|
| 449 |
% commands for doing things along line |
| 450 |
% blong (predefined) xfrom yfrom xto yto delink - |
| 451 |
% need to find halfway point |
| 452 |
/delink { gsave |
| 453 |
4 copy newslope |
| 454 |
6 2 roll newmidpoint |
| 455 |
delinkline } def |
| 456 |
|
| 457 |
%% calculated (dx dy xmid ymid) now moveto midpoint |
| 458 |
% moveto dup 0 eq |
| 459 |
%% duplicate dy and check whether line is horizontal |
| 460 |
% {blong 2 div neg 0 rmoveto blong 0 rlineto 2 pop} |
| 461 |
%% line not horizontal so check whether vertical |
| 462 |
% {exch dup 0 eq |
| 463 |
% {0 blong 2 div neg rmoveto 0 blong rlineto 2 pop} |
| 464 |
%% If neither than calculate standard case (dy dx) |
| 465 |
% {div neg dup dup mul 1 add sqrt |
| 466 |
% blong exch div |
| 467 |
% 2 copy mul 2 copy 2 div neg exch 2 div neg exch |
| 468 |
% rmoveto rlineto 1 pop} ifelse} ifelse |
| 469 |
% stroke |
| 470 |
% grestore |
| 471 |
% } def |
| 472 |
|
| 473 |
% actually draws the line |
| 474 |
% dx dy xmid ymid delinkline - |
| 475 |
|
| 476 |
/delinkline { moveto dup 0 eq |
| 477 |
% duplicate dy and check whether line is horizontal |
| 478 |
{blong 2 div neg 0 rmoveto blong 0 rlineto 2 pop} |
| 479 |
% line not horizontal so check whether vertical |
| 480 |
{exch dup 0 eq |
| 481 |
{0 blong 2 div neg rmoveto 0 blong rlineto 2 pop} |
| 482 |
% If neither than calculate standard case (dy dx) |
| 483 |
{div neg dup dup mul 1 add sqrt |
| 484 |
blong exch div |
| 485 |
2 copy mul 2 copy 2 div neg exch 2 div neg exch |
| 486 |
rmoveto rlineto 1 pop} ifelse} ifelse |
| 487 |
stroke |
| 488 |
grestore |
| 489 |
} def |
| 490 |
|
| 491 |
|
| 492 |
% |
| 493 |
% delink curve |
| 494 |
% blong (predefined) x0 y0 x1 y1 x2 y2 x3 y3 delinkcurve - |
| 495 |
|
| 496 |
/delinkcurve { 8 copy 8 copy |
| 497 |
bezslope 10 2 roll % push to back |
| 498 |
bezmidpoint |
| 499 |
delinkline |
| 500 |
} def |
| 501 |
|
| 502 |
% x0 y0 x1 y1 x2 y2 x3 y3 xyarrange x0 x1 x2 x3 y0 y1 y2 y3 |
| 503 |
% x0 y0 x1 y1 x2 y2 x3 y3 |
| 504 |
/xyarrange { exch % x0 y0 x1 y1 x2 y2 y3 x3 |
| 505 |
3 1 roll % x0 y0 x1 y1 x2 x3 y2 y3 |
| 506 |
5 -1 roll % x0 y0 x1 x2 x3 y2 y3 y1 |
| 507 |
7 -1 roll % x0 x1 x2 x3 y2 y3 y1 y0 |
| 508 |
exch % x0 x1 x2 x3 y2 y3 y0 y1 |
| 509 |
4 2 roll } def % x0 x1 x2 x3 y0 y1 y2 y3 |
| 510 |
|
| 511 |
% x0 x1 x2 x3 calcx xn 8(x3+3x2+3x1+x0)=xn |
| 512 |
/calcx { exch 3 mul |
| 513 |
3 -1 roll 3 mul |
| 514 |
add add add 8 mul} def |
| 515 |
|
| 516 |
% x0 x1 x2 x3 calcx xn x3+x2-x1-x0=xn |
| 517 |
/calcy { add exch sub exch sub } def |
| 518 |
|
| 519 |
|
| 520 |
% x0 y0 x1 y1 x2 y2 x3 y3 bezmidpoint xm ym |
| 521 |
% using the following equations |
| 522 |
% xb=8*(x3+3x2+3x1+x0) |
| 523 |
% yb=8*(y3+3y2+3y1+y0) |
| 524 |
|
| 525 |
/bezmidpoint {xyarrange |
| 526 |
calcx 5 1 roll calcx exch |
| 527 |
} def |
| 528 |
|
| 529 |
|
| 530 |
% x0 y0 x1 y1 x2 y2 x3 y3 bezslope dx dy |
| 531 |
% equations are dx=x3+x2-x1-x0 |
| 532 |
% dy=y3+y2-y1-y0 |
| 533 |
/bezslope {xyarrange |
| 534 |
calcy 5 1 roll calcy exch |
| 535 |
} def |
| 536 |
|
| 537 |
% finds midpoint between two points xfrom yfrom xto yto newmidpoint xmid ymid |
| 538 |
/newmidpoint { exch |
| 539 |
4 -1 roll |
| 540 |
add 2 div |
| 541 |
3 1 roll |
| 542 |
add 2 div |
| 543 |
} def |
| 544 |
|
| 545 |
% finds slope between two points: xfrom yfrom xto yto newslope dx dy |
| 546 |
/newslope { 4 -1 roll |
| 547 |
exch |
| 548 |
4 1 roll |
| 549 |
sub 3 1 roll sub exch |
| 550 |
} def |
| 551 |
|
| 552 |
|
| 553 |
%% commands for drawing things around nodes |
| 554 |
% nodename nodebox - |
| 555 |
/nodebox {nodes exch get begin |
| 556 |
gsave |
| 557 |
newpath |
| 558 |
x y moveto |
| 559 |
h w dobox |
| 560 |
cleanup |
| 561 |
stroke |
| 562 |
grestore |
| 563 |
end} def |
| 564 |
|
| 565 |
|
| 566 |
% nodename nodecircle - |
| 567 |
% would be nice to have a parameter that adjusts diameter of circle |
| 568 |
% depth nodename nodecircle - |
| 569 |
/nodecircle {nodes exch get begin |
| 570 |
gsave |
| 571 |
newpath |
| 572 |
w 2 div x add h 2 div y add |
| 573 |
w w mul h h mul add sqrt 2 div 4 -1 roll add |
| 574 |
360 0 arcn |
| 575 |
cleanup |
| 576 |
stroke |
| 577 |
grestore |
| 578 |
end} def |
| 579 |
|
| 580 |
% no cleanup |
| 581 |
/nodecircletrans {nodes exch get begin |
| 582 |
gsave |
| 583 |
newpath |
| 584 |
w 2 div x add h 2 div y add |
| 585 |
w w mul h h mul add sqrt 2 div 4 -1 roll add |
| 586 |
360 0 arcn |
| 587 |
stroke |
| 588 |
grestore |
| 589 |
end} def |
| 590 |
|
| 591 |
% nodename nodeoval - |
| 592 |
/nodeoval {nodes exch get begin |
| 593 |
gsave |
| 594 |
newpath |
| 595 |
x 2 sub y 2 sub moveto |
| 596 |
h 4 add w 4 add dooval |
| 597 |
cleanup |
| 598 |
stroke |
| 599 |
grestore |
| 600 |
end } def |
| 601 |
|
| 602 |
% ratio depth nodename testnodeoval - |
| 603 |
% ratio should be between 0 and 1 |
| 604 |
/testnodeoval {nodes exch get begin |
| 605 |
gsave |
| 606 |
newpath |
| 607 |
h h mul w w mul add sqrt div dup dup dup |
| 608 |
w mul neg x add exch |
| 609 |
h mul neg y add |
| 610 |
moveto |
| 611 |
dup |
| 612 |
h mul 2 mul h add exch |
| 613 |
w mul 2 mul w add |
| 614 |
testdooval |
| 615 |
stroke |
| 616 |
grestore |
| 617 |
end } def |
| 618 |
|
| 619 |
|
| 620 |
/cleanup{gsave |
| 621 |
x y moveto |
| 622 |
h nodemargin sub .5 add w nodemargin sub .5 add doccbox |
| 623 |
1 setgray fill grestore |
| 624 |
}def |
| 625 |
|
| 626 |
/boxdict 4 dict def |
| 627 |
boxdict /mtrx matrix put |
| 628 |
|
| 629 |
/dobox{boxdict begin |
| 630 |
/w exch def |
| 631 |
/h exch def |
| 632 |
/savematrix mtrx currentmatrix def |
| 633 |
0 h rlineto |
| 634 |
w 0 rlineto |
| 635 |
0 h neg rlineto |
| 636 |
closepath |
| 637 |
savematrix setmatrix |
| 638 |
end} def |
| 639 |
|
| 640 |
% do box in counterclockwise fashion |
| 641 |
/doccbox{boxdict begin |
| 642 |
/w exch def |
| 643 |
/h exch def |
| 644 |
/savematrix mtrx currentmatrix def |
| 645 |
w 0 rlineto |
| 646 |
0 h rlineto |
| 647 |
w neg 0 rlineto |
| 648 |
closepath |
| 649 |
savematrix setmatrix |
| 650 |
end} def |
| 651 |
|
| 652 |
|
| 653 |
/ovaldict 6 dict def |
| 654 |
ovaldict /mtrx matrix put |
| 655 |
|
| 656 |
% h w ovaldict - |
| 657 |
/dooval{ovaldict begin |
| 658 |
/w exch def |
| 659 |
/h exch def |
| 660 |
/savematrix mtrx currentmatrix def |
| 661 |
0 h 2 div rmoveto |
| 662 |
0 h 2 div nodemargin sub |
| 663 |
nodemargin h 2 div |
| 664 |
w 2 div h 2 div |
| 665 |
rcurveto |
| 666 |
w 2 div nodemargin sub 0 |
| 667 |
w 2 div nodemargin neg |
| 668 |
w 2 div h 2 div neg |
| 669 |
rcurveto |
| 670 |
0 h 2 div neg nodemargin add |
| 671 |
nodemargin neg h 2 div neg |
| 672 |
w 2 div neg h 2 div neg |
| 673 |
rcurveto |
| 674 |
w 2 div neg nodemargin add 0 |
| 675 |
w 2 div neg nodemargin |
| 676 |
w 2 div neg h 2 div |
| 677 |
rcurveto |
| 678 |
savematrix setmatrix |
| 679 |
end} def |
| 680 |
|
| 681 |
% give height and width of a box and the lower left hand point |
| 682 |
% produce a curve that will enclose the box. |
| 683 |
% initial point already defined |
| 684 |
% ratio h w testdooval - |
| 685 |
/testdooval{ovaldict begin |
| 686 |
/w exch def |
| 687 |
/h exch def |
| 688 |
/r exch def |
| 689 |
h 2 div neg r mul dup |
| 690 |
h 2 div dup |
| 691 |
r mul 3 1 roll |
| 692 |
2 r sub mul |
| 693 |
0 h |
| 694 |
rcurveto |
| 695 |
w 2 div dup |
| 696 |
r mul exch |
| 697 |
2 r sub mul |
| 698 |
w 2 div r mul dup 3 1 roll |
| 699 |
w 0 |
| 700 |
rcurveto |
| 701 |
h 2 div r mul dup |
| 702 |
h 2 div neg dup |
| 703 |
r mul 3 1 roll |
| 704 |
2 r sub mul |
| 705 |
0 h neg |
| 706 |
rcurveto |
| 707 |
w 2 div neg dup |
| 708 |
r mul exch |
| 709 |
2 r sub mul |
| 710 |
w 2 div neg r mul dup 3 1 roll |
| 711 |
w neg 0 |
| 712 |
rcurveto |
| 713 |
end} def |
| 714 |
|
| 715 |
end % of treedict |
| 716 |
|
| 717 |
end % of TeXdict |
| 718 |
% gsave |