Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/FlowchartDefs.m4def

raw
1 divert(-1)
2 FlowchartDefs.m4def
3 Google: flowchart display symbols
4 `Some flow-chart macros with minimal
5 decoration.
6
7 In the following, every block (subchart) is
8 in [] brackets, with .N, .S, .E and .W
9 internally defined. Follow this convention
10 if you create compound constructs.
11
12 Generally, the first argument is one
13 or more strings; the second adjusts
14 the size, and the third can be used
15 to add color, dashed lines, labels,
16 or other embellishements. Default is
17 grey fill if arg3 is blank.'
18
19 define(`FlowchartDefs_')
20
21 `Default sizes:'
22 define(`flowboxwid',linewid*2)
23 define(`flowboxht',linewid*0.75)
24 define(`flowarrowht',linewid*0.5)
25
26 `Fbox( "text", wid expr ht expr, attributes )
27 The basic task box: arg1 may be 1 or more
28 text strings. Attributes include box
29 line and fill specs. To adjust the box
30 size to the size of the typeset text, see
31 the \boxdims macro in the manual. Example:
32 Fbox("$x < 1$",,
33 shaded rgbstring(0.46,0.53,0.63))'
34 define(`Fbox',`[ boxwid = flowboxwid; boxht = flowboxht
35 Box: box `$2' ifelse(`$3',,`fill_(fillval)',`$3') `$1'
36 N: Box.n; S:Box.s; E:Box.e; W: Box.w
37 `$4']')
38
39 `Fdelay("text",wid expr ht expr,attributes)'
40 define(`Fdelay',`[ boxwid = flowboxwid; boxht = flowboxht
41 Box: box invis `$2'
42 N: Box.n; S: Box.s; E: Box.e; W: Box.w
43 arc from Box.se-(Box.ht/2,0) to Box.ne-(Box.ht/2,0) \
44 with .c at Box.e-(Box.ht/2,0) `$3'
45 line to Box.nw to Box.sw to Box.se-(Box.ht/2,0) `$3'
46 ifelse(`$1',,,`$1' at Box)
47 `$4']')
48
49 `Fdisplay("text",wid expr ht expr,attributes)'
50 define(`Fdisplay',`[ boxwid = flowboxwid; boxht = flowboxht
51 Box: box invis `$2'
52 N: Box.n; S: Box.s; E: Box.e; W: Box.w
53 NE: Box.ne-(Box.ht/4,0); SE: (NE,Box.s)
54 NW: Box.nw+(Box.ht/2,0); SW: (NW,Box.s)
55 ifelse(`$3',,,`
56 box wid NE.x-NW.x ht Box.ht with .ne at NE `$3' invis
57 line from W to NW then to SW then to W `$3' invis ')
58 arc from SE to NE with .c at E-(Box.ht*2/3,0) `$3'
59 line to NW `$3'
60 arc from NW to W with .c at (NW,Box)+(Box.ht/4,-Box.ht/4) `$3'
61 arc from W to SW with .c at (NW,Box)+(Box.ht/4,Box.ht/4) `$3'
62 line to SE `$3'
63 ifelse(`$1',,,`$1' at Box)
64 `$4']')
65
66 `Fstored("text",wid expr ht expr,attributes)'
67 define(`Fstored',`[ boxwid = flowboxwid; boxht = flowboxht
68 Box: box invis `$2'
69 r = Box.ht*7/8; d = r - sqrt(r^2-(Box.ht/2)^2)
70 N: Box.n; S: Box.s; E: Box.e-(d,0); W: Box.w
71 NW: Box.nw+(d,0); SW: (NW,Box.s); NE: Box.ne; SE: Box.se
72 ifelse(`$3',,,`
73 box wid NE.x-NW.x ht Box.ht with .nw at NW `$3' invis ')
74 arc from NW to SW with .c at Box.w+(r,0) `$3'; round
75 line to SE; round
76 arc cw to NE with .c at E+(r,0) fill_(1); round
77 line to NW `$3'; round
78 ifelse(`$1',,,`$1' at Box)
79 `$4']')
80
81 `Fconnect("text",
82 wid expr ht expr[:U|D|L|R|angle], attributes)'
83 define(`Fconnect',`[ boxht = flowboxht; boxwid = boxht
84 define(`m4wh',`m4Leftstr(`$2')')dnl
85 define(`m4wid',`patsubst(patsubst(m4wh, ht .*),^wid ,)')dnl
86 ifelse(m4wid,,`define(`m4wid',boxwid)')dnl
87 define(`m4ht',`patsubst(m4wh,.* *ht *,)')dnl
88 ifelse(m4ht,,`define(`m4ht',boxht)')dnl
89 define(`m4cpt',`m4Rightstr(`$2')')dnl
90 setdir_(ifelse(m4cpt,,`ifdef(`m4a_',rp_ang*rtod_,0)',m4cpt))
91 # {Box: [lbox(m4wid,m4ht,invis)]}
92 W: Here; NW: vec_(0,m4ht/2); N: vec_(m4wid/2,m4ht/2); NE: vec_(m4wid,m4ht/2)
93 SW: vec_(0,-m4ht/2); S: vec_(m4wid/2,-m4ht/2); SE: vec_(m4wid,-m4ht/2)
94 E: vec_(m4wid,0); C: 3/8 between W and E
95 line from 1/2 between NW and N \
96 to NW to SW to S to E to N to 1/2 between NW and N `$3'
97 ifelse(`$1',,,`$1' at C)
98 `$4'; resetdir_ ]')
99
100 `Fdata("text",wid expr ht expr,
101 xslant,attributes)'
102 define(`Fdata',`[ boxwid = flowboxwid; boxht = flowboxht
103 Box: box invis `$2'
104 xs = ifelse(`$3',,flowboxht/6,`($3)/2')
105 NE: Box.ne+(xs,0); SE: Box.se-(xs,0)
106 NW: Box.nw+(xs,0); SW: Box.sw-(xs,0)
107 N: Box.n; E: Box.e; S: Box.s; W: Box.w
108 line from N to NE then to SE then to SW then to NW then to N \
109 ifelse(`$4',,`fill_(fillval)',`$4')
110 ifelse(`$1',,,`$1' at Box)
111 `$5']')
112
113 `Fprep("text",wid expr ht expr,attributes)'
114 define(`Fprep',`[ boxwid = flowboxwid; boxht = flowboxht
115 Box: box invis `$2'
116 NE: Box.ne-(flowboxht/4,0); E: Box.e; SE: (NE,Box.s); N: Box.n
117 NW: Box.nw+(flowboxht/4,0); W: Box.w; SW: (NW,Box.s); S: Box.s
118 line from N to NE to E to SE to SW to W to NW to N \
119 ifelse(`$3',,`fill_(fillval)',`$3')
120 ifelse(`$1',,,`$1' at Box)
121 `$4']')
122
123 `Fkeyboard("text",wid expr ht expr,attributes)'
124 define(`Fkeyboard',`[ boxwid = flowboxwid; boxht = flowboxht
125 Box: box invis `$2'
126 NW: Box.nw-(0,min(Box.ht/4,Box.wid/16)); W: Box.w; SW: Box.sw; S: Box.s
127 NE: Box.ne+(0,min(Box.ht/4,Box.wid/16)); E: Box.e; SE: Box.se; N: 0.5 between NW and NE
128 line from N to NE to SE to SW to NW to N ifelse(`$3',,`fill_(fillval)',`$3')
129 ifelse(`$1',,,`$1' at Box)
130 `$4']')
131
132 `Fdocument("text",wid expr ht expr,attributes)'
133 define(`Fdocument',`[ boxwid = flowboxwid; boxht = flowboxht
134 Box: box invis `$2'; Q: move from Box.sw to Box.se
135 NE: Box.ne; E: Box.e; SE: Box.se-(0,Box.ht/4); N: Box.n
136 NW: Box.nw; W: Box.w; SW: Box.sw-(0,Box.ht/4); S: Box.s-(0,Box.ht/4)
137 line from SE to NE to NW to SW `$3'
138 arc to S with .c at (0.5 between SW and S) + (0,Box.ht) `$3'
139 arc to SE with .c at (0.5 between S and SE) -(0,Box.ht) cw \
140 ifelse(`$3',,,``$3' shaded rgbstring(1,1,1)')
141 ifelse(`$1',,,`$1' at Box)
142 `$4']')
143
144 `Fkeying("text",wid expr ht expr,attributes)'
145 define(`Fkeying',`[ boxwid = flowboxwid; boxht = flowboxht
146 Box: box `$2' invis
147 hsq = (Box.wid/2)^2-(Box.ht/2)^2
148 if hsq > 0 then { d = Box.wid/2-sqrt(hsq) } else { d = 0 }
149 W: Box.w; NW: Box.nw+(d,0); N: Box.n; NE: Box.ne-(d,0)
150 E: Box.e; SE: Box.se-(d,0); S: Box.s; SW: Box.sw+(d,0)
151 if hsq >= 0 then { x = 0 } else { x = sqrt(-hsq) }
152 box wid NE.x-NW.x ht N.y-S.y `$3' invis at Box
153 arc from SE to NE with .c at Box - (x,0) `$3'; round(,,`$3')
154 line to NW `$3'; round(,,`$3')
155 arc to SW with .c at Box + (x,0) `$3'; round(,,`$3')
156 line to SE `$3'; round(,,`$3')
157 ifelse(`$1',,,`$1' at Box)
158 `$4']')
159
160 `If-then
161 Ftest( "text", wid expr ht expr, attributes )'
162 define(`Ftest',`[boxwid = flowboxwid*0.8; boxht = flowboxht*1.4
163 Box: box `$2' invis
164 N: Box.n; S: Box.s; E: Box.e; W: Box.w
165 line from 0.5 between last box.n and last box.e to last box.e to last box.s \
166 to last box.w to last box.n to 0.5 between last box.n and last box.e \
167 ifelse(`$3',,`fill_(fillval)',`$3')
168 ifelse(`$1',,,`$1' at Box)
169 `$4']')
170
171 `Fcase: case statement
172 Fcase(wid expr ht expr,
173 "Test string 1"[:attributes],task, ...,
174 "Test string n"[:attributes],task )'
175 `arg1 adjusts the size of the tests
176 The optional attributes for each string apply
177 to the Ftest containing the string.
178 The Ftest blocks are labeled Test1, Test2, ...
179 A task is a flow subchart with internal
180 names .E and .S defined. The tasks are
181 labeled Task1, Task2, ... '
182 define(`Fcase',`[ down; S: Here; sx = S.x
183 Fcaseloop_(1,$@)
184 ifelse(`$2',,`E:S; W:S; N:S',
185 `E:(sx+linewid/2,Task1.E.y); W:Test1.W; N:Test1.N')
186 Fcasearrow_(1,$@)
187 arrow from E to (E,S) then to S ]')
188
189 define(`Fcaseloop_',`ifelse(`$3',,,
190 `Test`$1': Ftest(patsubst(`$3',":.*,"),`$2',
191 ifinstr(`$3',":,`patsubst(`$3',.*":,)')) with .N at S
192 Task`$1': `$4' with .nw at Test`$1'.E+(linewid/2,min(Test`$1'.ht,flowboxht)/2)
193 arrow right linewid/4 from Test`$1'.E \
194 then down Test`$1'.E.y-Task`$1'.W.y then to Task`$1'.W
195 S: (Test`$1'.S.x,min(Test`$1'.S.y,Task`$1'.S.y)-linewid/3)
196 ifelse(`$5',,`line',`arrow') from Test`$1'.S to S
197 sx = max(sx,Task`$1'.E.x)
198 Fcaseloop_(incr($1),`$2',shift(shift(shift(shift($@)))))')')
199 define(`Fcasearrow_',`ifelse(`$3',,,
200 `arrow from Task`$1'.E to (E,Task`$1'.E)
201 Fcasearrow_(incr($1),,shift(shift(shift(shift($@)))))')')
202
203 `while statement with explicit test
204 Fwhiledo("test text", wid x ht y,
205 attributes, task spec )
206 The task structure is given label Task '
207 define(`Fwhiledo',`[ down
208 Test: Ftest(`$1',`$2',`$3')
209 arrow right linewid/2 from Test.E
210 Task: `$4' with .W at Here
211 E: Task.E; W: Test.w; S: Test.S
212 arrow up max(linewid/4,Test.n.y-Task.n.y+arrowht*1.5) \
213 from Task.N then left Task.x-Test.x
214 N: Here
215 arrow to Test.n
216 `$5']')
217
218 `repeat statement with explicit test
219 Frepeatuntil("test",wid x ht y,
220 attributes, task spec )
221 The task structure is given label Task '
222 define(`Frepeatuntil',`[ N: Here
223 Task: ifelse(`$4',,Here,`$4' with .N at N)
224 W: Task.W
225 arrow from Task.S down linewid/3
226 Test: Ftest(`$1',`$2',`$3')
227 E: Task.E+(linewid/2+max(0,Test.e.x-Task.e.x),0)
228 arrow from Test.e to (E,Test) then to E then to Task.E
229 S: Test.S
230 `$5']')
231
232 `if-then-else
233 Fifthenelse( "test", wid x ht y, attributes,
234 left tasks, right tasks)
235 The left task structure is given label
236 Ltask and the right task structure is
237 given label Rtask '
238 define(`Fifthenelse',`[ Test: Ftest(`$1',`$2',`$3')
239 N: Test.N
240 Ltask: ifelse(`$4',,`Test.S; W:Test.W; LS:Ltask',
241 `$4 with .ne at ((Test.W.x+Test.x)/2,Test.S.y)
242 W: Ltask.W; LS:Ltask.S
243 arrow from Test.W to (Ltask.N,Test.W) then to Ltask.N')
244 Rtask: ifelse(`$5',,`Test.S; E:Test.E; RS:Rtask',
245 `$5 with .nw at ((Test.E.x+Test.x)/2,Test.S.y)
246 E: Rtask.E; RS: Rtask.S
247 arrow from Test.E to (Rtask.N,Test.E) then to Rtask.N')
248 S: (Test.x,min(LS.y,RS.y)-linewid/3)
249 arrow from LS to (LS,S)
250 arrow from RS to (RS,S)
251 line to (LS,Here)
252 `$6']')
253 divert(0)dnl