| 1 |
%% |
| 2 |
%% This is file `expressg.mp', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% expressg.dtx (with options: `up') |
| 8 |
%% |
| 9 |
%% Author: Peter Wilson (CUA) now at [email protected] until June 2004 |
| 10 |
%% (or [email protected]) |
| 11 |
%% Copyright 1996, 2003 Peter R. Wilson |
| 12 |
%% |
| 13 |
%% v1.0 1996/05/09 (first release) |
| 14 |
%% v1.2 1999/11/15 |
| 15 |
%% v1.3 2000/05/22 |
| 16 |
%% v1.4 2000/07/10 |
| 17 |
%% v1.5 2003/07/31 |
| 18 |
%% v1.6 2004/02/29 |
| 19 |
%% v1.61 2004/03/17 |
| 20 |
%% |
| 21 |
%% This work may be distributed and/or modified under the |
| 22 |
%% conditions of the LaTeX Project Public License, either |
| 23 |
%% version 1.3 of this license or (at your option) any |
| 24 |
%% later version. |
| 25 |
%% The latest version of the license is in |
| 26 |
%% http://www.latex-project.org/lppl.txt |
| 27 |
%% and version 1.3 or later is part of all distributions of |
| 28 |
%% LaTeX version 2003/06/01 or later. |
| 29 |
%% |
| 30 |
%% This work has the LPPL maintenance status "author-maintained". |
| 31 |
%% |
| 32 |
%% This work consists of the files listed in the README file. |
| 33 |
%% This program is provided under the terms of the |
| 34 |
%% LaTeX Project Public License distributed from CTAN |
| 35 |
%% archives in directory macros/latex/base/lppl.txt. |
| 36 |
%% |
| 37 |
%%% EXPRESSG.MP MetaPost macros for EXPRESS-G and other BLA diagrams |
| 38 |
%%% version 1.5, 31 July 2003 |
| 39 |
%%% version 1.6, 29 February 2004 |
| 40 |
%%% version 1.61, 17 March 2004 |
| 41 |
|
| 42 |
show "expressg.mp version 1.61, 2004/03/17"; |
| 43 |
|
| 44 |
newinternal u; numeric u; |
| 45 |
u := 1mm; |
| 46 |
|
| 47 |
newinternal maxx, maxy; |
| 48 |
numeric maxx, maxy; |
| 49 |
maxx := 159.5u; % smidgeon under 160mm for ISO |
| 50 |
maxy := 210u; % 210mm for ISO |
| 51 |
|
| 52 |
newinternal defaultdotdiam, dotdiam; |
| 53 |
numeric defaultdotdiam, dotdiam; |
| 54 |
defaultdotdiam := 2u; |
| 55 |
dotdiam := defaultdotdiam; |
| 56 |
|
| 57 |
newinternal normalpensize, thickpensize, thinpensize; |
| 58 |
numeric normalpensize, thickpensize, thinpensize; |
| 59 |
normalpensize := 0.5bp; |
| 60 |
thickpensize := 1.5bp; |
| 61 |
thinpensize := 0.25bp; |
| 62 |
newinternal dotsscale; numeric dotsscale; |
| 63 |
dotsscale := 2; |
| 64 |
|
| 65 |
newinternal normalpen, thickpen, thinpen, dotspen, dotpen; |
| 66 |
pen normalpen, thickpen, thinpen, dotspen, dotpen; |
| 67 |
normalpen := pencircle scaled normalpensize; % i.e. defaultpen; |
| 68 |
thickpen := pencircle scaled thickpensize; |
| 69 |
thinpen := pencircle scaled thinpensize; |
| 70 |
dotspen := pencircle scaled (dotsscale*normalpensize); |
| 71 |
dotpen := pencircle scaled dotdiam; |
| 72 |
|
| 73 |
newinternal defaultsmoothrad; |
| 74 |
numeric smoothrad, defaultsmoothrad; |
| 75 |
smoothrad := defaultsmoothrad := 2u; |
| 76 |
|
| 77 |
newinternal defaultdrumlid; |
| 78 |
numeric drumlid, defaultdrumlid; |
| 79 |
drumlid := defaultdrumlid := 0.2; |
| 80 |
|
| 81 |
%%% default length and base width for arrowheads and fanin |
| 82 |
newinternal defaultgal, defaultgab, defaultgfl, defaultgfb; |
| 83 |
numeric defaultgal, defaultgab, defaultgfl, defaultgfb; |
| 84 |
defaultgal := defaultgfl := defaultdotdiam; |
| 85 |
defaultgab := defaultgfb := defaultgal; |
| 86 |
|
| 87 |
%%% length and base width of arrowheads and fanins |
| 88 |
newinternal gal, gab, gfl, gfb; |
| 89 |
numeric gal, gab, gfl, gfb; |
| 90 |
gal := defaultgal; |
| 91 |
gab := defaultgab; |
| 92 |
gfl := defaultgfl; |
| 93 |
gfb := defaultgfb; |
| 94 |
|
| 95 |
newinternal onelineh; |
| 96 |
numeric onelineh; |
| 97 |
onelineh := 5u; |
| 98 |
|
| 99 |
%%% length, height & inset for simple data type boxes |
| 100 |
newinternal sdtbl, sdtbh, sdtbs; |
| 101 |
numeric sdtbl, sdtbh, sdtbs; |
| 102 |
sdtbl := 22u; |
| 103 |
sdtbh := onelineh; |
| 104 |
sdtbs := 2u; |
| 105 |
|
| 106 |
%%% length, height & inset for EXPRESSION data type boxes |
| 107 |
newinternal sdtbel, sdtbeh, sdtbes; |
| 108 |
numeric sdtbel, sdtbeh, sdtbes; |
| 109 |
sdtbel := 28u; |
| 110 |
sdtbeh := sdtbh; sdtbes := sdtbs; |
| 111 |
|
| 112 |
%%% length, height & inset for GENERICENT data type boxes |
| 113 |
newinternal sdtbgel, sdtbgeh, sdtbges; |
| 114 |
numeric sdtbgel, sdtbgeh, sdtbges; |
| 115 |
sdtbgel := 38u; |
| 116 |
sdtbgeh := sdtbh; sdtbges := sdtbs; |
| 117 |
|
| 118 |
%%% average length of numeric page connector |
| 119 |
newinternal pconl; |
| 120 |
numeric pconl; % length of page connector (for e.g., 9,9 (9,9) ) |
| 121 |
pconl:=15u; |
| 122 |
%%% height of page connectors (one line) |
| 123 |
newinternal pconh; |
| 124 |
numeric pconh; |
| 125 |
pconh := onelineh; |
| 126 |
|
| 127 |
%%% heights of entity, enum, select, type boxes (One text line) |
| 128 |
newinternal enth, typeh; |
| 129 |
numeric enth, typeh; |
| 130 |
enth := onelineh; |
| 131 |
typeh := onelineh; |
| 132 |
|
| 133 |
%%% height of interschema boxes (one text line, no rename), and (name + rename) |
| 134 |
newinternal ish, isrh; |
| 135 |
numeric ish, isrh; |
| 136 |
ish := 2onelineh; |
| 137 |
isrh := 3onelineh; |
| 138 |
|
| 139 |
%%% height of schema boxes (one text line) |
| 140 |
newinternal schemah; |
| 141 |
numeric schemah; |
| 142 |
schemah := 2onelineh; |
| 143 |
|
| 144 |
%%% height and slope of event boxes |
| 145 |
newinternal eventh, eventslope; |
| 146 |
numeric eventh, eventslope; |
| 147 |
eventh := onelineh; |
| 148 |
eventslope := 0.25; |
| 149 |
|
| 150 |
%%% extra namespaces for boxed names |
| 151 |
newinternal nextra, niextra; |
| 152 |
numeric nextra, niextra; |
| 153 |
nextra := 2u; |
| 154 |
niextra := nextra+sdtbs; |
| 155 |
|
| 156 |
%%% extra namespace for attribute names |
| 157 |
newinternal ndextra; |
| 158 |
numeric ndextra; |
| 159 |
ndextra := nextra+dotdiam; |
| 160 |
|
| 161 |
%%% calculates mid-point on a path like |_ (vertical, horizontal) |
| 162 |
%%% final points are: z$, z$vh, z$$, where z$vh=(x$,y$$) |
| 163 |
def VH(suffix $, $$) = |
| 164 |
z$vh=(x$,y$$); |
| 165 |
enddef; |
| 166 |
|
| 167 |
%%% Calculates mid-points on a path like |_ |
| 168 |
%%% | (vertical, horizontal, vertical) |
| 169 |
%%% final points are: z$, z$vhv, z$$vhv, z$$ |
| 170 |
def VhV(suffix $, $$) = |
| 171 |
y$$vhv=1/2[y$,y$$]; x$$vhv=x$$; |
| 172 |
z$vhv=(x$,y$$vhv); |
| 173 |
enddef; |
| 174 |
|
| 175 |
%%% Calculates mid-points on a path like -|_ (horizontal, vertical, horizontal) |
| 176 |
%%% final points are: z$, z$hvh, z$$hvh, z$$ |
| 177 |
def HvH(suffix $, $$) = |
| 178 |
x$hvh=1/2[x$,x$$]; y$hvh=y$; |
| 179 |
z$$hvh=(x$hvh,y$$); |
| 180 |
enddef; |
| 181 |
|
| 182 |
%%% Calculates turning points on a U shaped path (vertical, horizontal, vertical) |
| 183 |
%%% final points are: z$, z$vyv, z$$vyv, z$$ |
| 184 |
def VyV(suffix $, @, $$) = |
| 185 |
z$$vyv=(x$$,y@); |
| 186 |
z$vyv =(x$, y@); |
| 187 |
enddef; |
| 188 |
|
| 189 |
%%% Calculates corner points rotated U shaped path (horizontal, vertical, horizontal) |
| 190 |
%%% final points are: z$, z$hxh, z$$hxh, z$$ |
| 191 |
def HxH(suffix $, @, $$) = |
| 192 |
z$$hxh=(x@,y$$); |
| 193 |
z$hxh =(x@,y$); |
| 194 |
enddef; |
| 195 |
|
| 196 |
%%% calculates length taken up by typesetting str, plus margin |
| 197 |
def namespace(text str)(expr margin) = |
| 198 |
(xpart lrcorner(str) - xpart llcorner(str) + margin) |
| 199 |
enddef; |
| 200 |
|
| 201 |
def dashes = |
| 202 |
dashed evenly |
| 203 |
enddef; |
| 204 |
|
| 205 |
def dots = |
| 206 |
dashed withdots |
| 207 |
enddef; |
| 208 |
|
| 209 |
def dashedgrid(expr nx, ny, dist) = |
| 210 |
save zg_, zg__, oldpen; |
| 211 |
pair zg_[], zg__[]; |
| 212 |
pen oldpen; oldpen = currentpen; |
| 213 |
pickup thinpen; |
| 214 |
for i = 0 upto nx: |
| 215 |
zg_[i] = (i*dist, 0); zg_[i+1000] = (i*dist, ny*dist); |
| 216 |
draw zg_[i]--zg_[i+1000] dashes; |
| 217 |
label.bot(decimal(i), zg_[i]); |
| 218 |
endfor |
| 219 |
for i = 0 upto ny: |
| 220 |
zg__[i] = (0, i*dist); zg__[i+1000] = (nx*dist, i*dist); |
| 221 |
draw zg__[i]--zg__[i+1000] dashes; |
| 222 |
label.lft(decimal(i), zg__[i]); |
| 223 |
endfor |
| 224 |
pickup oldpen; |
| 225 |
enddef; |
| 226 |
|
| 227 |
%%% draw a 1cm spaced grid of 16(x) by 21(y) cms. (units are mm) |
| 228 |
def drawgrid = |
| 229 |
dashedgrid(16, 21, 10mm); |
| 230 |
enddef; |
| 231 |
|
| 232 |
%%% calculates corner and midpoints of a rectangle, |
| 233 |
%%% bottom left at $, length l, height h |
| 234 |
def rectpoints(suffix $)(expr l, h) = |
| 235 |
z$bl = z$; |
| 236 |
z$tr = (x$+l, y$+h); |
| 237 |
z$br = (x$tr, y$bl); |
| 238 |
z$tl = (x$bl, y$tr); |
| 239 |
z$ml = 1/2[z$bl, z$tl]; |
| 240 |
z$mr = 1/2[z$br, z$tr]; |
| 241 |
z$bm = 1/2[z$bl, z$br]; |
| 242 |
z$tm = 1/2[z$tl, z$tr]; |
| 243 |
enddef; |
| 244 |
|
| 245 |
%%% calculate corner, midpoints and center point of a rhomboid. |
| 246 |
def rhompoints(suffix $)(expr l, h, s) = |
| 247 |
save eshift; |
| 248 |
numeric eshift; eshift = s*h; |
| 249 |
z$bl = z$; |
| 250 |
z$tr = (x$+l+eshift, y$+h); |
| 251 |
z$br = (x$bl+l, y$bl); |
| 252 |
z$tl = (x$bl+eshift, y$tr); |
| 253 |
z$ml = 1/2[z$bl, z$tl]; |
| 254 |
z$mr = 1/2[z$br, z$tr]; |
| 255 |
z$bm = (1/2[x$ml,x$mr], y$bl); |
| 256 |
z$tm = (x$bm, y$tr); |
| 257 |
enddef; |
| 258 |
|
| 259 |
%%% calculate circumferential points on a circle |
| 260 |
def circpoints(suffix $)(expr diam) = |
| 261 |
save rad, sinrad, cosrad; |
| 262 |
numeric rad, sinrad, cosrad; |
| 263 |
rad = diam/2; |
| 264 |
sinrad = rad*(sind 45); |
| 265 |
cosrad = rad*(cosd 45); |
| 266 |
z$c=z$; |
| 267 |
z$ml=(x$c-rad, y$c); |
| 268 |
z$mr=(x$c+rad, y$c); |
| 269 |
z$bm=(x$c, y$c-rad); |
| 270 |
z$tm=(x$c, y$c+rad); |
| 271 |
z$tr=(x$c+cosrad, y$c+sinrad); |
| 272 |
z$bl=(x$c-cosrad, y$c-sinrad); |
| 273 |
z$br=(x$tr, y$bl); |
| 274 |
z$tl=(x$bl, y$tr); |
| 275 |
enddef; |
| 276 |
|
| 277 |
%%% circular arc join between two paths |
| 278 |
tertiarydef p ~ q = |
| 279 |
begingroup |
| 280 |
c_ := fullcircle scaled 2smoothrad shifted point 0 of q; |
| 281 |
a_ := ypart(c_ intersectiontimes p); |
| 282 |
b_ := ypart(c_ intersectiontimes q); |
| 283 |
if a_ < 0: point 0 of p{direction 0 of p} else: subpath(0,a_) of p fi |
| 284 |
... if b_ < 0: {direction infinity of q}point infinity of q |
| 285 |
else: subpath(b_,infinity) of q fi |
| 286 |
endgroup |
| 287 |
enddef; |
| 288 |
|
| 289 |
%%% piecewise linear path between the given points |
| 290 |
def sharply(text t) = % t is a list of pairs |
| 291 |
hide(n_:=0; for z=t: z_[incr n_]:=z; endfor) |
| 292 |
z_1 for k=2 upto n_: --z_[k] endfor |
| 293 |
enddef; |
| 294 |
|
| 295 |
%%% piecewise linear path between the given points with smooth corners |
| 296 |
def smoothly(text t) = % t is a list of pairs |
| 297 |
hide(n_:=0; for z=t: z_[incr n_]:=z; endfor) |
| 298 |
(z_1 for k=2 upto n_-1: --z_[k]) ~ (z_[k] endfor --z_[n_]) |
| 299 |
enddef; |
| 300 |
|
| 301 |
%%% Draw an open circle at end of vector from $ to $$ |
| 302 |
def drawO(suffix $, $$) = |
| 303 |
begingroup |
| 304 |
save v_, c_, l, p; |
| 305 |
pair v_, c_; |
| 306 |
numeric l; |
| 307 |
path p; |
| 308 |
v_ := z$-z$$; |
| 309 |
l := (xpart v_)++(ypart v_); % length of the line |
| 310 |
c_ := (dotdiam/(2l))[z$$,z$]; |
| 311 |
p := fullcircle scaled dotdiam shifted c_; |
| 312 |
unfill p; |
| 313 |
draw p; draw p; |
| 314 |
endgroup |
| 315 |
enddef; |
| 316 |
|
| 317 |
%%% Draw a closed circle at end of vector from $ to $$ |
| 318 |
def drawD(suffix $, $$) = |
| 319 |
begingroup |
| 320 |
save v_, c_, l, p; |
| 321 |
pair v_, c_; |
| 322 |
numeric l; |
| 323 |
path p; |
| 324 |
v_ := z$-z$$; |
| 325 |
l := (xpart v_)++(ypart v_); % length of the line |
| 326 |
c_ := (dotdiam/(2l))[z$$,z$]; |
| 327 |
p := fullcircle scaled dotdiam shifted c_; |
| 328 |
fill p; |
| 329 |
endgroup |
| 330 |
enddef; |
| 331 |
|
| 332 |
%%% draw an open arrowhead at end of vector from $ to $$ |
| 333 |
def drawOA(suffix $, $$) = |
| 334 |
begingroup |
| 335 |
save v_, c_, v_u, c_t, c_b, l, hb, p; |
| 336 |
pair v_, c_, v_u, c_t, c_b; |
| 337 |
numeric l, hb; |
| 338 |
path p; |
| 339 |
hb := gab/2; |
| 340 |
v_ := z$-z$$; |
| 341 |
l := (xpart v_)++(ypart v_); % length of the line |
| 342 |
c_ := (gal/(l))[z$$,z$]; % base of arrowhead |
| 343 |
v_u := unitvector v_; |
| 344 |
c_t := c_ shifted (-hb*(ypart v_u), hb*(xpart v_u)); |
| 345 |
c_b - c_ = c_ - c_t; |
| 346 |
p = c_b--z$$--c_t--cycle; |
| 347 |
unfill p; |
| 348 |
draw p; draw p; |
| 349 |
endgroup |
| 350 |
enddef; |
| 351 |
|
| 352 |
%%% draw a closed arrowhead at end of vector from $ to $$ |
| 353 |
def drawCA(suffix $, $$) = |
| 354 |
begingroup |
| 355 |
save v_, c_, v_u, c_t, c_b, l, hb, p; |
| 356 |
pair v_, c_, v_u, c_t, c_b; |
| 357 |
numeric l, hb; |
| 358 |
path p; |
| 359 |
hb := gab/2; |
| 360 |
v_ := z$-z$$; |
| 361 |
l := (xpart v_)++(ypart v_); % length of the line |
| 362 |
c_ := (gal/(l))[z$$,z$]; % base of arrowhead |
| 363 |
v_u := unitvector v_; |
| 364 |
c_t := c_ shifted (-hb*(ypart v_u), hb*(xpart v_u)); |
| 365 |
c_b - c_ = c_ - c_t; |
| 366 |
p = c_b--z$$--c_t--cycle; |
| 367 |
filldraw p; |
| 368 |
endgroup |
| 369 |
enddef; |
| 370 |
|
| 371 |
%%% draw a simple arrowhead at end of vector from $ to $$ |
| 372 |
def drawA(suffix $, $$) = |
| 373 |
begingroup |
| 374 |
save v_, c_, v_u, c_t, c_b, l, hb, p; |
| 375 |
pair v_, c_, v_u, c_t, c_b; |
| 376 |
numeric l, hb; |
| 377 |
path p; |
| 378 |
hb := gab/2; |
| 379 |
v_ := z$-z$$; |
| 380 |
l := (xpart v_)++(ypart v_); % length of the line |
| 381 |
c_ := (gal/(l))[z$$,z$]; % base of arrowhead |
| 382 |
v_u := unitvector v_; |
| 383 |
c_t := c_ shifted (-hb*(ypart v_u), hb*(xpart v_u)); |
| 384 |
c_b - c_ = c_ - c_t; |
| 385 |
p = c_b--z$$--c_t; |
| 386 |
draw p; |
| 387 |
endgroup |
| 388 |
enddef; |
| 389 |
|
| 390 |
%%% draws a fanin at the end of the vector from $ to $$ |
| 391 |
def drawF(suffix $, $$) = |
| 392 |
begingroup |
| 393 |
save v_, c_, v_u, c_t, c_b, l, hb, p; |
| 394 |
pair v_, c_, v_u, c_t, c_b; |
| 395 |
numeric l, hb; |
| 396 |
path p; |
| 397 |
hb := gfb/2; |
| 398 |
v_ := z$-z$$; |
| 399 |
l := (xpart v_)++(ypart v_); % length of the line |
| 400 |
c_ := (gfl/(l))[z$$,z$]; % apex of fan |
| 401 |
v_u := unitvector v_; |
| 402 |
c_t := z$$ shifted (-hb*(ypart v_u), hb*(xpart v_u)); |
| 403 |
c_b - z$$ = z$$ - c_t; |
| 404 |
p = c_b--c_--c_t; |
| 405 |
draw p; |
| 406 |
endgroup |
| 407 |
enddef; |
| 408 |
|
| 409 |
%%% Draw a dotted line from $ to $$ |
| 410 |
def drawdots(suffix $, $$) = |
| 411 |
pickup dotspen; |
| 412 |
draw z$--z$$ dots; |
| 413 |
pickup normalpen; |
| 414 |
enddef; |
| 415 |
|
| 416 |
%%% Draws the dotted line $--@--$$ |
| 417 |
def drawdotsthree(suffix $, @, $$) = |
| 418 |
pickup dotspen; |
| 419 |
draw z$--z@--z$$ dots; |
| 420 |
pickup normalpen; |
| 421 |
enddef; |
| 422 |
|
| 423 |
%%% Draw the dotted line $--@--@@--$$ |
| 424 |
def drawdotsfour(suffix $, @, @@, $$) = |
| 425 |
pickup dotspen; |
| 426 |
draw z$--z@--z@@--z$$ dots; |
| 427 |
pickup normalpen; |
| 428 |
enddef; |
| 429 |
|
| 430 |
%%% Draw a dotted line from $ to $$ with open circle at $$ |
| 431 |
def drawdotsO(suffix $, $$) = |
| 432 |
pickup dotspen; |
| 433 |
draw z$--z$$ dots; |
| 434 |
pickup normalpen; |
| 435 |
drawO($, $$); |
| 436 |
enddef; |
| 437 |
|
| 438 |
%%% Draws the dotted line $--@--$$ |
| 439 |
def drawdotsthreeO(suffix $, @, $$) = |
| 440 |
pickup dotspen; |
| 441 |
draw z$--z@--z$$ dots; |
| 442 |
pickup normalpen; |
| 443 |
drawO(@, $$); |
| 444 |
enddef; |
| 445 |
|
| 446 |
%%% Draw the dotted line $--@--@@--$$ |
| 447 |
def drawdotsfourO(suffix $, @, @@, $$) = |
| 448 |
pickup dotspen; |
| 449 |
draw z$--z@--z@@--z$$ dots; |
| 450 |
pickup normalpen; |
| 451 |
drawO(@@, $$); |
| 452 |
enddef; |
| 453 |
|
| 454 |
%%% Draw the dotted line from $ to $$, ending in circles diameter dotdiam at $ and $$ |
| 455 |
def drawdotsOO(suffix $, $$) = |
| 456 |
pickup dotspen; |
| 457 |
draw z$--z$$ dots; |
| 458 |
pickup normalpen; |
| 459 |
drawO($, $$); drawO($$, $); |
| 460 |
enddef; |
| 461 |
|
| 462 |
%%% draws a dashed line from $ to $$ |
| 463 |
def drawdash(suffix $, $$) = |
| 464 |
draw z$--z$$ dashes; |
| 465 |
enddef; |
| 466 |
|
| 467 |
%%% draws the dashed line $--@--$$ |
| 468 |
def drawdashthree(suffix $, @, $$) = |
| 469 |
draw z$--z@--z$$ dashes; |
| 470 |
enddef; |
| 471 |
|
| 472 |
%%% draws the dashed line $--@--@@--$$ |
| 473 |
def drawdashfour(suffix $, @, @@, $$) = |
| 474 |
draw z$--z@--z@@--z$$ dashes; |
| 475 |
enddef; |
| 476 |
|
| 477 |
%%% draws a dashed line from $ to $$, ending in a circle diameter dotdiam at $$ |
| 478 |
def drawdashO(suffix $, $$) = |
| 479 |
draw z$--z$$ dashes; |
| 480 |
drawO($, $$); |
| 481 |
enddef; |
| 482 |
|
| 483 |
%%% draws the dashed line $--@--$$ with circle at $$ |
| 484 |
def drawdashthreeO(suffix $, @, $$) = |
| 485 |
draw z$--z@--z$$ dashes; |
| 486 |
drawO(@, $$); |
| 487 |
enddef; |
| 488 |
|
| 489 |
%%% draws the dashed line $--@--@@--$$ with circle at $$ |
| 490 |
def drawdashfourO(suffix $, @, @@, $$) = |
| 491 |
draw z$--z@--z@@--z$$ dashes; |
| 492 |
drawO(@@, $$); |
| 493 |
enddef; |
| 494 |
|
| 495 |
%%% draws a dashed line from $ to $$, ending in circles diameter dotdiam at $ and $$ |
| 496 |
def drawdashOO(suffix $, $$) = |
| 497 |
draw z$--z$$ dashes; |
| 498 |
drawO($, $$); drawO($$, $); |
| 499 |
enddef; |
| 500 |
|
| 501 |
%%% draws a normal line from $ to $$. |
| 502 |
def drawnormal(suffix $, $$) = |
| 503 |
draw z$--z$$; |
| 504 |
enddef; |
| 505 |
|
| 506 |
%%% draws the normal line $--@--$$ |
| 507 |
def drawnormalthree(suffix $, @, $$) = |
| 508 |
draw z$--z@--z$$; |
| 509 |
enddef; |
| 510 |
|
| 511 |
%%% draws the normal line $--@--@@--$$ |
| 512 |
def drawnormalfour(suffix $, @, @@, $$) = |
| 513 |
draw z$--z@--z@@--z$$; |
| 514 |
enddef; |
| 515 |
|
| 516 |
%%% draws a normal line from $ to $$, ending in a circle diameter dotdiam at $$ |
| 517 |
def drawnormalO(suffix $, $$) = |
| 518 |
draw z$--z$$; |
| 519 |
drawO($, $$); |
| 520 |
enddef; |
| 521 |
|
| 522 |
%%% draws the normal line $--@--$$, ending in a circle at $$ |
| 523 |
def drawnormalthreeO(suffix $, @, $$) = |
| 524 |
draw z$--z@--z$$; |
| 525 |
drawO(@, $$); |
| 526 |
enddef; |
| 527 |
|
| 528 |
%%% draws the line $--@--@@--$$, ending in a circle at $$ |
| 529 |
def drawnormalfourO(suffix $, @, @@, $$) = |
| 530 |
draw z$--z@--z@@--z$$; |
| 531 |
drawO(@@, $$); |
| 532 |
enddef; |
| 533 |
|
| 534 |
%%% draws a normal line from $ to $$, ending in circles diameter dotdiam at $ and $$ |
| 535 |
def drawnormalOO(suffix $, $$) = |
| 536 |
draw z$--z$$; |
| 537 |
drawO($, $$); drawO($$, $); |
| 538 |
enddef; |
| 539 |
|
| 540 |
%%% draws a normal line from $ to $$, ending in a dot diameter dotdiam at $$ |
| 541 |
def drawnormalD(suffix $, $$) = |
| 542 |
draw z$--z$$; |
| 543 |
drawD($, $$); |
| 544 |
enddef; |
| 545 |
|
| 546 |
%%% draws the normal line $--@--$$, ending in a dot at $$ |
| 547 |
def drawnormalthreeD(suffix $, @, $$) = |
| 548 |
draw z$--z@--z$$; |
| 549 |
drawD(@, $$); |
| 550 |
enddef; |
| 551 |
|
| 552 |
%%% draws the normal line $--@--@@--$$, ending in a dot at $$ |
| 553 |
def drawnormalfourD(suffix $, @, @@, $$) = |
| 554 |
draw z$--z@--z@@--z$$; |
| 555 |
drawD(@@, $$); |
| 556 |
enddef; |
| 557 |
|
| 558 |
%%% draws a normal line from $ to $$, ending in dots diameter dotdiam at $ and $$ |
| 559 |
def drawnormalDD(suffix $, $$) = |
| 560 |
draw z$--z$$; |
| 561 |
drawD($, $$); drawD($$, $); |
| 562 |
enddef; |
| 563 |
|
| 564 |
%%% draws a normal line from $ to $$, ending with an open arrowhead at $$ |
| 565 |
def drawnormalOA(suffix $, $$) = |
| 566 |
draw z$--z$$; |
| 567 |
drawOA($, $$); |
| 568 |
enddef; |
| 569 |
|
| 570 |
%%% draws a normal line from $ to $$, ending with a closed arrowhead at $$ |
| 571 |
def drawnormalCA(suffix $, $$) = |
| 572 |
draw z$--z$$; |
| 573 |
drawCA($, $$); |
| 574 |
enddef; |
| 575 |
|
| 576 |
%%% draws the normal line $--@--$$, ending in a black arrowhead at $$ |
| 577 |
def drawnormalthreeCA(suffix $, @, $$) = |
| 578 |
draw z$--z@--z$$; |
| 579 |
drawCA(@, $$); |
| 580 |
enddef; |
| 581 |
|
| 582 |
%%% draws the normal line $--@--@@--$$, ending in a black arrowhead at $$ |
| 583 |
def drawnormalfourCA(suffix $, @, @@, $$) = |
| 584 |
draw z$--z@--z@@--z$$; |
| 585 |
drawCA(@@, $$); |
| 586 |
enddef; |
| 587 |
|
| 588 |
%%% draws a normal line from $ to $$, ending with a fanin at $$ |
| 589 |
def drawnormalF(suffix $, $$) = |
| 590 |
draw z$--z$$; |
| 591 |
drawF($, $$); |
| 592 |
enddef; |
| 593 |
|
| 594 |
%%% draws a normal line from $ to $$, with a fanin at $ and an open circle at $$ |
| 595 |
def drawnormalFO(suffix $, $$) = |
| 596 |
draw z$--z$$; |
| 597 |
drawO($, $$); drawF($$, $); |
| 598 |
enddef; |
| 599 |
|
| 600 |
%%% draws a thick line from $ to $$. |
| 601 |
def drawthick(suffix $, $$) = |
| 602 |
pickup thickpen; |
| 603 |
draw z$--z$$; |
| 604 |
pickup normalpen; |
| 605 |
enddef; |
| 606 |
|
| 607 |
%%% draws a thick line from $ to $$, ending in a circle diameter dotdiam at $$ |
| 608 |
def drawthickO(suffix $, $$) = |
| 609 |
pickup thickpen; |
| 610 |
draw z$--z$$; |
| 611 |
drawO($, $$); |
| 612 |
pickup normalpen; |
| 613 |
enddef; |
| 614 |
|
| 615 |
%%% draws a thick line from $ to $$, ending in circles diameter dotdiam at $ and $$ |
| 616 |
def drawthickOO(suffix $, $$) = |
| 617 |
pickup thickpen; |
| 618 |
draw z$--z$$; |
| 619 |
drawO($, $$); drawO($$, $); |
| 620 |
pickup normalpen; |
| 621 |
enddef; |
| 622 |
|
| 623 |
%%% replaces the sharp corner on $--@--$$ with a circular arc radius smoothrad |
| 624 |
def smooth(suffix $, @, $$) = |
| 625 |
begingroup |
| 626 |
save v_, c_, l, p; |
| 627 |
pair v_, v_', c_, c_'; |
| 628 |
path p; |
| 629 |
v_ := z@-z$; |
| 630 |
l := (xpart v_)++(ypart v_); % length of $--@ |
| 631 |
c_ := (smoothrad/l)[z@,z$]; % start of arc on $--@ |
| 632 |
v_' := z$$-z@; |
| 633 |
l := (xpart v_')++(ypart v_'); % length of @--$$ |
| 634 |
c_' := (smoothrad/l)[z@,z$$]; % end of arc on @--$$ |
| 635 |
undraw c_--z@--c_'; % blank original join |
| 636 |
draw c_{v_}..{v_'}c_'; % draw the arc |
| 637 |
endgroup |
| 638 |
enddef; |
| 639 |
|
| 640 |
%%% replaces the sharp corners on $--@--@@--$$ with a circular arc radius smoothrad |
| 641 |
def smoothtwo(suffix $, @, @@, $$) = |
| 642 |
smooth($, @, @@); smooth(@, @@, $$); |
| 643 |
enddef; |
| 644 |
|
| 645 |
%%% replaces the sharp corner on the dashed lines $--@--$$ |
| 646 |
%%% with a circular arc radius smoothrad |
| 647 |
def smoothdash(suffix $, @, $$) = |
| 648 |
begingroup |
| 649 |
save v_, c_, l, p; |
| 650 |
pair v_, v_', c_, c_'; |
| 651 |
path p; |
| 652 |
v_ := z@-z$; |
| 653 |
l := (xpart v_)++(ypart v_); % length of $--@ |
| 654 |
c_ := (smoothrad/l)[z@,z$]; % start of arc on $--@ |
| 655 |
v_' := z$$-z@; |
| 656 |
l := (xpart v_')++(ypart v_'); % length of @--$$ |
| 657 |
c_' := (smoothrad/l)[z@,z$$]; % end of arc on @--$$ |
| 658 |
undraw c_--z@--c_'; % blank original join |
| 659 |
draw c_{v_}..{v_'}c_' dashes; % draw the dashed arc |
| 660 |
endgroup |
| 661 |
enddef; |
| 662 |
|
| 663 |
%%% replaces the sharp corner on the dotted line $--@--$$ |
| 664 |
%%% with a circular arc radius smoothrad |
| 665 |
def smoothdots(suffix $, @, $$) = |
| 666 |
begingroup |
| 667 |
save oldpen; |
| 668 |
pen oldpen; oldpen := currentpen; |
| 669 |
save v_, c_, l, p; |
| 670 |
pair v_, v_', c_, c_'; |
| 671 |
path p; |
| 672 |
v_ := z@-z$; |
| 673 |
l := (xpart v_)++(ypart v_); % length of $--@ |
| 674 |
c_ := (smoothrad/l)[z@,z$]; % start of arc on $--@ |
| 675 |
v_' := z$$-z@; |
| 676 |
l := (xpart v_')++(ypart v_'); % length of @--$$ |
| 677 |
c_' := (smoothrad/l)[z@,z$$]; % end of arc on @--$$ |
| 678 |
undraw c_--z@--c_'; % blank original join |
| 679 |
pickup dotspen; |
| 680 |
draw c_{v_}..{v_'}c_' dots; % draw the dotted arc |
| 681 |
pickup oldpen; |
| 682 |
endgroup |
| 683 |
enddef; |
| 684 |
|
| 685 |
%%% draws a schema box, bottom left at $, length l, height h |
| 686 |
def drawSCHEMA(suffix $)(expr l, h)(text str) = |
| 687 |
rectpoints($, l, h); |
| 688 |
x$c = 1/2[x$ml, x$mr]; |
| 689 |
y$c = 1/2[y$ml, y$tl]; |
| 690 |
draw z$bl--z$br--z$tr--z$tl--cycle; % outer box |
| 691 |
draw z$ml--z$mr; % dividing line |
| 692 |
label(str, z$c); |
| 693 |
enddef; |
| 694 |
|
| 695 |
def drawSDT(suffix $)(text str) = |
| 696 |
rectpoints($, sdtbl, sdtbh); |
| 697 |
z$ti = (x$tr-sdtbs, y$tr); |
| 698 |
z$bi = (x$ti, y$br); |
| 699 |
z$c = 1/2[z$bl,z$ti]; |
| 700 |
draw z$bl--z$br--z$tr--z$tl--cycle; |
| 701 |
draw z$bi--z$ti; |
| 702 |
label(str, z$c); |
| 703 |
enddef; |
| 704 |
|
| 705 |
def drawASDT(suffix $)(expr l, h)(text str) = |
| 706 |
rectpoints($, l, h); |
| 707 |
z$ti = (x$tr-sdtbs, y$tr); |
| 708 |
z$bi = (x$ti, y$br); |
| 709 |
z$c = 1/2[z$bl,z$ti]; |
| 710 |
draw z$bl--z$br--z$tr--z$tl--cycle; |
| 711 |
draw z$bi--z$ti; |
| 712 |
label(str, z$c); |
| 713 |
enddef; |
| 714 |
|
| 715 |
def drawBINARY(suffix $) = drawASDT($)(sdtbl, sdtbh)("BINARY"); |
| 716 |
enddef; |
| 717 |
def drawBOOLEAN(suffix $) = drawASDT($)(sdtbl, sdtbh)("BOOLEAN"); |
| 718 |
enddef; |
| 719 |
def drawCOMPLEX(suffix $) = drawASDT($)(sdtbl, sdtbh)("COMPLEX"); |
| 720 |
enddef; |
| 721 |
def drawEXPRESSION(suffix $) = drawASDT($)(sdtbel, sdtbeh)("EXPRESSION"); |
| 722 |
enddef; |
| 723 |
def drawGENERIC(suffix $) = drawASDT($)(sdtbl, sdtbh)("GENERIC"); |
| 724 |
enddef; |
| 725 |
def drawINTEGER(suffix $) = drawASDT($)(sdtbl, sdtbh)("INTEGER"); |
| 726 |
enddef; |
| 727 |
def drawLOGICAL(suffix $) = drawASDT($)(sdtbl, sdtbh)("LOGICAL"); |
| 728 |
enddef; |
| 729 |
def drawNUMBER(suffix $) = drawASDT($)(sdtbl, sdtbh)("NUMBER"); |
| 730 |
enddef; |
| 731 |
def drawREAL(suffix $) = drawASDT($)(sdtbl, sdtbh)("REAL"); |
| 732 |
enddef; |
| 733 |
def drawSTRING(suffix $) = drawASDT($)(sdtbl, sdtbh)("STRING"); |
| 734 |
enddef; |
| 735 |
|
| 736 |
%%% draw an enumeration type box, bottom left at $, length l, height h |
| 737 |
def drawENUM(suffix $)(expr l, h)(text str) = |
| 738 |
rectpoints($, l, h); |
| 739 |
z$ti = (x$tr-sdtbs, y$tr); |
| 740 |
z$bi = (x$ti, y$br); |
| 741 |
z$c = 1/2[z$bl,z$ti]; |
| 742 |
draw z$bl--z$br--z$tr--z$tl--cycle dashes; |
| 743 |
draw z$bi--z$ti dashes; |
| 744 |
label(str, z$c); |
| 745 |
enddef; |
| 746 |
|
| 747 |
%%% draw a select type box, bottom left at $, length l, height h |
| 748 |
def drawSELECT(suffix $)(expr l, h)(text str) = |
| 749 |
rectpoints($, l, h); |
| 750 |
z$ti = (x$tl+sdtbs, y$tl); |
| 751 |
z$bi = (x$ti, y$bl); |
| 752 |
z$c = 1/2[z$br,z$ti]; |
| 753 |
draw z$bl--z$br--z$tr--z$tl--cycle dashes; |
| 754 |
draw z$bi--z$ti dashes; |
| 755 |
label(str, z$c); |
| 756 |
enddef; |
| 757 |
|
| 758 |
%%% draw a simple user defined TYPE box, bottom left at $, length l, height h |
| 759 |
def drawTYPE(suffix $)(expr l, h)(text str) = |
| 760 |
rectpoints($, l, h); |
| 761 |
z$c = 1/2[z$bl,z$tr]; |
| 762 |
draw z$bl--z$br--z$tr--z$tl--cycle dashes; |
| 763 |
label(str, z$c); |
| 764 |
enddef; |
| 765 |
|
| 766 |
%%% draw an entity box, bottom left at $, length l, height h |
| 767 |
def drawENT(suffix $)(expr l, h)(text str) = |
| 768 |
rectpoints($, l, h); |
| 769 |
z$c = 1/2[z$bl,z$tr]; |
| 770 |
draw z$bl--z$br--z$tr--z$tl--cycle; |
| 771 |
label(str, z$c); |
| 772 |
enddef; |
| 773 |
|
| 774 |
def drawOB(suffix $)(expr l, h) = |
| 775 |
save rad; |
| 776 |
numeric rad; rad := h/2; |
| 777 |
rectpoints($, l, h); |
| 778 |
z$cl = 1/2[z$bl, z$tl]; |
| 779 |
z$cr = 1/2[z$br, z$tr]; |
| 780 |
z$bli = (x$bl+rad, y$bl); |
| 781 |
z$tli = (x$bli, y$tl); |
| 782 |
z$bri = (x$br-rad, y$br); |
| 783 |
z$tri = (x$bri, y$tr); |
| 784 |
z$c = 1/2[z$bl,z$tr]; |
| 785 |
draw z$bli--z$bri..z$cr..z$tri--z$tli..z$cl..cycle; |
| 786 |
enddef; |
| 787 |
|
| 788 |
%%% draw a page reference box oval, bottom left at $, length l, height h |
| 789 |
def drawPREF(suffix $)(expr l, h)(text str) = |
| 790 |
drawOB($, l, h); |
| 791 |
label(str, z$c); |
| 792 |
enddef; |
| 793 |
|
| 794 |
%%% draw an interschema USE box, bottom left at $, length l, height h |
| 795 |
def drawISU(suffix $)(expr l, h)(text str) = |
| 796 |
save quarter; |
| 797 |
numeric quarter; quarter := h/4; |
| 798 |
rectpoints($, l, h); |
| 799 |
z$o = (x$, y$+quarter); |
| 800 |
drawOB($o, l, 2quarter); |
| 801 |
z$c = 1/2[z$bl,z$tr]; |
| 802 |
label(str, z$c); |
| 803 |
draw z$bl--z$br--z$tr--z$tl--cycle; |
| 804 |
enddef; |
| 805 |
|
| 806 |
%%% draw an interschema USE RENAME box, bottom left at $, length l, height h |
| 807 |
def drawISUR(suffix $)(expr l, h)(text str, rname) = |
| 808 |
save third; |
| 809 |
numeric third; third := h/3; |
| 810 |
rectpoints($, l, h); |
| 811 |
z$o = (x$, y$+third); |
| 812 |
drawOB($o, l, third); |
| 813 |
z$c = 1/2[z$bl, z$tr]; |
| 814 |
label(str, z$c); |
| 815 |
z$rnm = 1/2[z$bl,(x$br,y$br+third)]; |
| 816 |
draw z$bl--z$br--z$tr--z$tl--cycle; |
| 817 |
label(rname, z$rnm); |
| 818 |
enddef; |
| 819 |
|
| 820 |
%%% draw an interschema REFERENCE box, bottom left at $, length l, height h |
| 821 |
def drawISR(suffix $)(expr l, h)(text str) = |
| 822 |
save quarter; |
| 823 |
numeric quarter; quarter := h/4; |
| 824 |
rectpoints($, l, h); |
| 825 |
z$o = (x$, y$+quarter); |
| 826 |
drawOB($o, l, 2quarter); |
| 827 |
z$c = 1/2[z$bl,z$tr]; |
| 828 |
label(str, z$c); |
| 829 |
draw z$bl--z$br--z$tr--z$tl--cycle dashes; |
| 830 |
enddef; |
| 831 |
|
| 832 |
%%% draw an interschema REFERENCE RENAME box, bottom left at $, length l, height h |
| 833 |
def drawISRR(suffix $)(expr l, h)(text str, rname) = |
| 834 |
save third; |
| 835 |
numeric third; third := h/3; |
| 836 |
rectpoints($, l, h); |
| 837 |
z$o = (x$, y$+third); |
| 838 |
drawOB($o, l, third); |
| 839 |
z$c = 1/2[z$bl,z$tr]; |
| 840 |
label(str, z$c); |
| 841 |
z$rnm = 1/2[z$bl,(x$br,y$br+third)]; |
| 842 |
draw z$bl--z$br--z$tr--z$tl--cycle dashes; |
| 843 |
label(rname, z$rnm); |
| 844 |
enddef; |
| 845 |
|
| 846 |
%%% draw a Local EVENT box, bottom left at $, length l, height h |
| 847 |
def drawLEVENT(suffix $)(expr l, h)(text str) = |
| 848 |
rhompoints($, l, h, eventslope); |
| 849 |
z$c = 1/2[z$ml,z$mr]; |
| 850 |
draw z$bl--z$br--z$tr--z$tl--cycle; |
| 851 |
label(str, z$c); |
| 852 |
enddef; |
| 853 |
|
| 854 |
%%% draw a Global EVENT box, bottom left at $, length l, height h |
| 855 |
def drawGEVENT(suffix $)(expr l, h)(text str) = |
| 856 |
rhompoints($, l, h, eventslope); |
| 857 |
z$c = 1/2[z$ml,z$mr]; |
| 858 |
pickup thickpen; |
| 859 |
draw z$bl--z$br--z$tr--z$tl--cycle; |
| 860 |
pickup normalpen; |
| 861 |
label(str, z$c); |
| 862 |
enddef; |
| 863 |
|
| 864 |
%%% draw a circled name, diameter diam centered at $ |
| 865 |
def drawcirclebox(suffix $)(expr diam)(text str) = |
| 866 |
circpoints($, diam); |
| 867 |
draw z$bl..z$bm..z$br..z$mr..z$tr..z$tm..z$tl..z$ml..cycle; |
| 868 |
label(str, z$c); |
| 869 |
enddef; |
| 870 |
|
| 871 |
%%% length and base width of diamond line end styles |
| 872 |
newinternal gdl, gdb; |
| 873 |
numeric gdl, gdb; |
| 874 |
gdl := 2defaultgal; |
| 875 |
gdb := 0.75defaultgab; |
| 876 |
|
| 877 |
def ellipsepoints(suffix $)(expr l, h) = |
| 878 |
save epp, move; |
| 879 |
path epp; |
| 880 |
pair move; |
| 881 |
z$ml=(x$-l/2, y$); z$mr=(x$ml+l,y$); |
| 882 |
z$tm=(x$, y$+h/2); z$bm=(x$, y$tm-h); |
| 883 |
move = 1/2[z$ml,z$mr]; |
| 884 |
epp = fullcircle scaled h xscaled (l/h) shifted move; |
| 885 |
z$tr = point 1.2 of epp; |
| 886 |
z$tl = point 2.8 of epp; |
| 887 |
z$bl = point 5.2 of epp; |
| 888 |
z$br = point 6.8 of epp; |
| 889 |
enddef; |
| 890 |
|
| 891 |
%%% draws double closed arrowheads at end of vector from $ to $$ |
| 892 |
def drawDCA(suffix $, $$) = |
| 893 |
begingroup |
| 894 |
save v_, c_, v_u, c_t, c_b, l, hb, p; |
| 895 |
pair v_, c_, v_u, c_t, c_b; |
| 896 |
path p[]; |
| 897 |
numeric l, hb; |
| 898 |
hb := gab/2; |
| 899 |
v_ := z$-z$$; |
| 900 |
l := (xpart v_)++(ypart v_); % length of the line |
| 901 |
c_ := (gal/(l))[z$$,z$]; % base of arrowhead |
| 902 |
v_u := unitvector v_; |
| 903 |
c_t := c_ shifted (-hb*(ypart v_u), hb*(xpart v_u)); |
| 904 |
c_b - c_ = c_ - c_t; |
| 905 |
p1 := c_b--z$$--c_t--cycle; |
| 906 |
filldraw p1; |
| 907 |
p2 := p1 shifted ((xpart c_ - x$$), (ypart c_ - y$$)); |
| 908 |
filldraw p2; |
| 909 |
endgroup |
| 910 |
enddef; |
| 911 |
|
| 912 |
%%% draws an open diamond at end of vector from $ to $$ |
| 913 |
def drawOD(suffix $, $$) = |
| 914 |
begingroup |
| 915 |
save v_, c_, c__, v_u, c_t, c_b, l, hb, p; |
| 916 |
pair v_, c_, c__, v_u, c_t, c_b; |
| 917 |
numeric l, hb; |
| 918 |
path p; |
| 919 |
hb := gdb/2; |
| 920 |
v_ := z$-z$$; |
| 921 |
l := (xpart v_)++(ypart v_); % length of the line |
| 922 |
c_ := (gdl/(2l))[z$$,z$]; % base of diamond |
| 923 |
c__ := (gdl/(l))[z$$,z$]; % interior tip of diamond |
| 924 |
v_u := unitvector v_; |
| 925 |
c_t := c_ shifted (-hb*(ypart v_u), hb*(xpart v_u)); |
| 926 |
c_b - c_ = c_ - c_t; |
| 927 |
p = c_b--z$$--c_t--c__--cycle; |
| 928 |
unfill p; |
| 929 |
draw p; draw p; |
| 930 |
endgroup |
| 931 |
enddef; |
| 932 |
|
| 933 |
%%% draws a closed diamond at end of vector from $ to $$ |
| 934 |
def drawCD(suffix $, $$) = |
| 935 |
begingroup |
| 936 |
save v_, c_, c__, v_u, c_t, c_b, l, hb, p; |
| 937 |
pair v_, c_, c__, v_u, c_t, c_b; |
| 938 |
numeric l, hb; |
| 939 |
path p; |
| 940 |
hb := gdb/2; |
| 941 |
v_ := z$-z$$; |
| 942 |
l := (xpart v_)++(ypart v_); % length of the line |
| 943 |
c_ := (gdl/(2l))[z$$,z$]; % base of diamond |
| 944 |
c__ := (gdl/(l))[z$$,z$]; % interior tip of diamond |
| 945 |
v_u := unitvector v_; |
| 946 |
c_t := c_ shifted (-hb*(ypart v_u), hb*(xpart v_u)); |
| 947 |
c_b - c_ = c_ - c_t; |
| 948 |
p = c_b--z$$--c_t--c__--cycle; |
| 949 |
filldraw p; |
| 950 |
endgroup |
| 951 |
enddef; |
| 952 |
|
| 953 |
%%% draws a dashed line from $ to $$, ending with an arrowhead at $$ |
| 954 |
def drawdashA(suffix $, $$) = |
| 955 |
draw z$--z$$ dashes; |
| 956 |
drawA($, $$); |
| 957 |
enddef; |
| 958 |
|
| 959 |
%%% draws a dashed line from $ to $$, ending with an open arrowhead at $$ |
| 960 |
def drawdashOA(suffix $, $$) = |
| 961 |
draw z$--z$$ dashes; |
| 962 |
drawOA($, $$); |
| 963 |
enddef; |
| 964 |
|
| 965 |
%%% draws a normal line from $ to $$, ending with double closed arrowheads at $$ |
| 966 |
def drawnormalDCA(suffix $, $$) = |
| 967 |
draw z$--z$$; |
| 968 |
drawDCA($, $$); |
| 969 |
enddef; |
| 970 |
|
| 971 |
%%% draws a normal line from $ to $$, ending with an open diamond at $$ |
| 972 |
def drawnormalOD(suffix $, $$) = |
| 973 |
draw z$--z$$; |
| 974 |
drawOD($, $$); |
| 975 |
enddef; |
| 976 |
|
| 977 |
%%% draws a normal line from $ to $$, ending with a closed diamond at $$ |
| 978 |
def drawnormalCD(suffix $, $$) = |
| 979 |
draw z$--z$$; |
| 980 |
drawCD($, $$); |
| 981 |
enddef; |
| 982 |
|
| 983 |
%%% draws an open dashed circle, center z$, diameter diam |
| 984 |
def drawdashcircle(suffix $)(expr diam) = |
| 985 |
circpoints($, diam); |
| 986 |
draw z$bl..z$bm..z$br..z$mr..z$tr..z$tm..z$tl..z$ml..cycle dashes; |
| 987 |
enddef; |
| 988 |
|
| 989 |
%%% draws an open circle, center z$, diameter diam, with an arrow at the top |
| 990 |
def drawcircleA(suffix $)(expr diam) = |
| 991 |
circpoints($, diam); |
| 992 |
begingroup |
| 993 |
save c_, c_t, c_b, hb; |
| 994 |
pair c_, c_t, c_b; |
| 995 |
numeric hb; |
| 996 |
hb := gab/2; |
| 997 |
c_ := z$tm shifted (gal*right); % base of arrowhead |
| 998 |
c_t := c_ shifted (hb*up); |
| 999 |
c_b := c_ shifted (hb*down); |
| 1000 |
draw z$bl..z$bm..z$br..z$mr..z$tr..z$tm..z$tl..z$ml..cycle; |
| 1001 |
draw c_t--z$tm--c_b; |
| 1002 |
endgroup |
| 1003 |
enddef; |
| 1004 |
|
| 1005 |
%%% draws black dot, center z$, diameter diam |
| 1006 |
def drawDot(suffix $)(expr diam) = |
| 1007 |
begingroup |
| 1008 |
save p; |
| 1009 |
path p; |
| 1010 |
p := fullcircle scaled diam shifted z$; |
| 1011 |
filldraw p; |
| 1012 |
endgroup |
| 1013 |
enddef; |
| 1014 |
|
| 1015 |
%%% draws black dot surrounded by a circle, center z$, diameter diam |
| 1016 |
def drawCircledDot(suffix $)(expr diam) = |
| 1017 |
begingroup |
| 1018 |
save l_, p; |
| 1019 |
numeric l_; |
| 1020 |
path p[]; |
| 1021 |
l_ := 5/7diam; |
| 1022 |
p1 := fullcircle scaled diam shifted z$; |
| 1023 |
unfill p1; |
| 1024 |
draw p1; |
| 1025 |
p2 := fullcircle scaled l_ shifted z$; |
| 1026 |
filldraw p2; |
| 1027 |
endgroup |
| 1028 |
enddef; |
| 1029 |
|
| 1030 |
def drawcardbox(suffix $)(expr l, h, m)(text str) = |
| 1031 |
rectpoints($, l, h); |
| 1032 |
begingroup |
| 1033 |
save c; |
| 1034 |
pair c[]; |
| 1035 |
c1 = (x$tr-m, y$tr); |
| 1036 |
c3 = (x$tr, y$tr-m); |
| 1037 |
c2 = (xpart c1, ypart c3); |
| 1038 |
draw z$bl--z$br--c3--c1--z$tl--cycle; |
| 1039 |
draw c1--c2--c3; |
| 1040 |
endgroup; |
| 1041 |
z$c = 1/2[z$ml,z$mr]; |
| 1042 |
label(str, z$c); |
| 1043 |
enddef; |
| 1044 |
|
| 1045 |
def drawdiamondbox(suffix $)(expr l, h)(text str) = |
| 1046 |
z$ml=(x$-l/2, y$); z$tm=(x$, y$+h/2); |
| 1047 |
z$mr=(x$ml+l, y$); z$bm=(x$, y$tm-h); |
| 1048 |
z$bl=1/2[z$ml,z$bm]; |
| 1049 |
z$br=1/2[z$bm,z$mr]; |
| 1050 |
z$tr=1/2[z$mr,z$tm]; |
| 1051 |
z$tl=1/2[z$tm,z$ml]; |
| 1052 |
z$c=z$; |
| 1053 |
draw z$ml--z$bm--z$mr--z$tm--cycle; |
| 1054 |
label(str, z$c); |
| 1055 |
enddef; |
| 1056 |
|
| 1057 |
def drawtwodiamondbox(suffix $)(expr l, h, mrg)(text str) = |
| 1058 |
z$ml=(x$-l/2, y$); z$tm=(x$, y$+h/2); |
| 1059 |
z$mr=(x$ml+l, y$); z$bm=(x$, y$tm-h); |
| 1060 |
z$bl=1/2[z$ml,z$bm]; |
| 1061 |
z$br=1/2[z$bm,z$mr]; |
| 1062 |
z$tr=1/2[z$mr,z$tm]; |
| 1063 |
z$tl=1/2[z$tm,z$ml]; |
| 1064 |
z$c=z$; |
| 1065 |
begingroup |
| 1066 |
save v_, p, tl, sf; |
| 1067 |
pair v_; |
| 1068 |
numeric tl, sf; |
| 1069 |
path p[]; |
| 1070 |
p1 = z$ml--z$bm--z$mr--z$tm--cycle; |
| 1071 |
draw p1; |
| 1072 |
v_ := z$c-z$tr; |
| 1073 |
tl := (xpart v_)++(ypart v_); |
| 1074 |
sf = 1.0 - mrg/tl; |
| 1075 |
p2 = p1 shifted -z$c scaled sf shifted z$c; |
| 1076 |
draw p2; |
| 1077 |
endgroup; |
| 1078 |
label(str, z$c); |
| 1079 |
|
| 1080 |
enddef; |
| 1081 |
|
| 1082 |
def drawdoublerectangle(suffix $)(expr l, h, tf) = |
| 1083 |
rectpoints($, l, h); |
| 1084 |
z$tfl=tf[z$tl,z$bl]; z$tfr=tf[z$tr,z$br]; |
| 1085 |
z$cb=1/2[z$bl,z$tfr]; |
| 1086 |
z$ct=1/2[z$tfl,z$tr]; |
| 1087 |
draw z$bl--z$br--z$tr--z$tl--cycle; |
| 1088 |
draw z$tfl--z$tfr; |
| 1089 |
enddef; |
| 1090 |
|
| 1091 |
def drawtriplerectangle(suffix $)(expr l, h, tf, bf) = |
| 1092 |
rectpoints($, l, h); |
| 1093 |
z$tfl=tf[z$tl,z$bl]; z$tfr=tf[z$tr,z$br]; |
| 1094 |
z$bfl=bf[z$bl,z$tl]; z$bfr=bf[z$br,z$tr]; |
| 1095 |
z$cb=1/2[z$bl,z$bfr]; |
| 1096 |
z$cm=1/2[z$bfl,z$tfr]; |
| 1097 |
z$ct=1/2[z$tfl,z$tr]; |
| 1098 |
draw z$bl--z$br--z$tr--z$tl--cycle; |
| 1099 |
draw z$bfl--z$bfr; |
| 1100 |
draw z$tfl--z$tfr; |
| 1101 |
enddef; |
| 1102 |
|
| 1103 |
def hiderectangle(suffix $)(expr l, h) = |
| 1104 |
begingroup |
| 1105 |
save c; |
| 1106 |
pair c[]; |
| 1107 |
c1=(x$,y$); |
| 1108 |
c2=c1+(l,0); |
| 1109 |
c3=c1+(l,h); |
| 1110 |
c4=c1+(0,h); |
| 1111 |
unfilldraw c1--c2--c3--c4--cycle; |
| 1112 |
endgroup |
| 1113 |
enddef; |
| 1114 |
|
| 1115 |
def drawdashboxover(suffix $)(expr l, h) = |
| 1116 |
rectpoints($, l, h); |
| 1117 |
hiderectangle($, l, h); |
| 1118 |
z$c = 1/2[z$bl,z$tr]; |
| 1119 |
draw z$bl--z$br--z$tr--z$tl--cycle dashes; |
| 1120 |
enddef; |
| 1121 |
|
| 1122 |
def drawindexbox(suffix $)(expr l, h, lp, hp)(text str) = |
| 1123 |
rectpoints($, l, h); |
| 1124 |
z$c = 1/2[z$bl,z$tr]; |
| 1125 |
z$P = z$tl; |
| 1126 |
rectpoints($P, lp, hp); |
| 1127 |
z$P.c = 1/2[z$P.bl, z$P.tr]; |
| 1128 |
draw z$bl--z$br--z$tr--z$tl--cycle; |
| 1129 |
draw z$P.bl--z$P.br--z$P.tr--z$P.tl--cycle; |
| 1130 |
label(str, z$P.c); |
| 1131 |
enddef; |
| 1132 |
|
| 1133 |
def drawroundedbox(suffix $)(expr l, h, r)(text str) = |
| 1134 |
rectpoints($, l, h); |
| 1135 |
begingroup |
| 1136 |
save rad; |
| 1137 |
numeric rad; rad := r; |
| 1138 |
if rad > l/2: |
| 1139 |
rad := l/2; |
| 1140 |
fi |
| 1141 |
if rad > h/2: |
| 1142 |
rad := h/2; |
| 1143 |
fi |
| 1144 |
draw (x$br-rad, y$br){right}..{up}(x$br, y$br+rad)-- |
| 1145 |
(x$tr, y$tr-rad){up}..{left}(x$tr-rad, y$tr)-- |
| 1146 |
(x$tl+rad, y$tl){left}..{down}(x$tl, y$tl-rad)-- |
| 1147 |
(x$bl, y$bl+rad){down}..{right}(x$bl+rad, y$bl)--cycle; |
| 1148 |
endgroup; |
| 1149 |
z$c = 1/2[z$bl,z$tr]; |
| 1150 |
label(str, z$c); |
| 1151 |
enddef; |
| 1152 |
|
| 1153 |
def drawovalbox(suffix $)(expr l, h)(text str) = |
| 1154 |
ellipsepoints($, l, h); |
| 1155 |
z$c = 1/2[z$ml,z$mr]; |
| 1156 |
begingroup |
| 1157 |
save p; |
| 1158 |
path p; |
| 1159 |
p = fullcircle scaled h xscaled (l/h) shifted z$c; |
| 1160 |
draw p; |
| 1161 |
endgroup; |
| 1162 |
label(str, z$c); |
| 1163 |
enddef; |
| 1164 |
|
| 1165 |
def drawdashellipse(suffix $)(expr l, h) = |
| 1166 |
ellipsepoints($, l, h); |
| 1167 |
z$c = 1/2[z$ml,z$mr]; |
| 1168 |
begingroup |
| 1169 |
save p; |
| 1170 |
path p; |
| 1171 |
p = fullcircle scaled h xscaled (l/h) shifted z$c; |
| 1172 |
draw p dashes; |
| 1173 |
endgroup |
| 1174 |
enddef; |
| 1175 |
|
| 1176 |
def drawdrum(suffix $)(expr l, h)(text str) = |
| 1177 |
save vdia; numeric vdia; |
| 1178 |
vdia := drumlid*l; % ellipse vertical diameter |
| 1179 |
save pf, ph; path pf, ph; % full & half ellipse paths |
| 1180 |
|
| 1181 |
% points on the basic rectangle |
| 1182 |
z$bl = z$; |
| 1183 |
z$tr = (x$+l, y$+h); |
| 1184 |
z$br = (x$tr, y$); |
| 1185 |
z$tl = (x$, y$tr); |
| 1186 |
z$ml = 1/2[z$bl,z$tl]; |
| 1187 |
z$mr = 1/2[z$br,z$tr]; |
| 1188 |
z$tc = 1/2[z$tl,z$tr]; % center of top rectangle line |
| 1189 |
z$bc = 1/2[z$bl,z$br]; |
| 1190 |
% draw box sides |
| 1191 |
draw z$tl--z$bl; draw z$tr--z$br; |
| 1192 |
|
| 1193 |
% points on top ellipse |
| 1194 |
z$T''' = z$tc; % ellipse center |
| 1195 |
ellipsepoints($T''', l, vdia); |
| 1196 |
z$tm = z$T'''.tm; |
| 1197 |
z$tml = z$T'''.tl; |
| 1198 |
z$tmr = z$T'''.tr; |
| 1199 |
|
| 1200 |
% points on bottom ellipse |
| 1201 |
z$B''' = z$bc; |
| 1202 |
ellipsepoints($B''', l, vdia); |
| 1203 |
z$bm = z$B'''.bm; |
| 1204 |
z$bml = z$B'''.bl; |
| 1205 |
z$bmr = z$B'''.br; |
| 1206 |
|
| 1207 |
% box center point |
| 1208 |
z$c = 1/2[z$T'''.bm, z$B'''.bm]; |
| 1209 |
|
| 1210 |
% draw top ellipse |
| 1211 |
pf = fullcircle scaled vdia xscaled (l/vdia) shifted z$T'''; |
| 1212 |
draw pf; |
| 1213 |
% draw bottom half ellipse |
| 1214 |
ph = (halfcircle rotated 180) scaled vdia xscaled (l/vdia) shifted z$B'''; |
| 1215 |
draw ph; |
| 1216 |
label(str, z$c); |
| 1217 |
enddef; |
| 1218 |
|
| 1219 |
def drawoutputbox(suffix $)(expr l, h)(text str) = |
| 1220 |
rectpoints($, l, h); |
| 1221 |
begingroup |
| 1222 |
save c; |
| 1223 |
pair c[]; |
| 1224 |
c1 = (x$br, y$br+1/8h); % right side of box is shorter |
| 1225 |
c2 = (x$bm, y$bm+1/16h); |
| 1226 |
% draw the tear |
| 1227 |
draw z$bl..c2{dir 45}..c1{dir -15}--z$tr--z$tl--cycle; |
| 1228 |
endgroup; |
| 1229 |
z$c = (x$bm, 1/2(y$bm+y$tm)); |
| 1230 |
label(str, z$c); |
| 1231 |
enddef; |
| 1232 |
|
| 1233 |
\def drawstickman(suffix $)(expr l, h) = |
| 1234 |
rectpoints($,l,h); |
| 1235 |
begingroup |
| 1236 |
save c; |
| 1237 |
pair c[]; |
| 1238 |
c1 = 8/24[z$bm,z$tm]; |
| 1239 |
c2 = 15/24[z$bm,z$tm]; |
| 1240 |
c3 = 18/24[z$bm,z$tm]; |
| 1241 |
c4 = 1/2[c3,z$tm]; |
| 1242 |
c6 = (x$bl, ypart(c2)); |
| 1243 |
c7 = (x$br, ypart(c2)); |
| 1244 |
draw z$bl--c1--z$br; % legs |
| 1245 |
draw c1--c3; % body |
| 1246 |
draw c6--c7; % arms |
| 1247 |
draw c3{right}..z$tm{left}..cycle; % head |
| 1248 |
endgroup; |
| 1249 |
enddef; |
| 1250 |
|