summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/flowchart/flowchart.dtx
blob: a6ca9bab3a79f22b59085396b7c3d54f1cbf2f35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
% \iffalse meta-comment
%
% Flowchart 3.3
% 19 March 2015
%
% flowchart.dtx
%
%    Documented LaTeX file for the flowchart package.
%
%    Run LaTeX on flowchart.ini to make the package's
%    flowchart.sty file.
%
%    Run LaTeX on this file to produce the package 
%    documentation.
%
% The flowchart package is an outcome of the Fluxion 
% project.
%
% Copyright (C) 2015 by Adrian P Robson
%     adrian.robson@nepsweb.co.uk
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either 
% version 1.3c of this license or (at your option) any later
% version. The latest version of this license is in
%    http://www.latex-project.org/lppl.txt
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Adrian Robson.
%
% This work consists of the files flowchart.dtx and 
%                                 flowchart.ins
% and the derived files           flowchart.sty and 
%                                 flowchart.pdf
% -----------------------------------------------------------
% \fi
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[2011/06/27]
%<package>\ProvidesPackage{flowchart}
%<package>[2015/03/19 3.3 Flowchart shapes for TikZ]
%<*driver>
\documentclass[10pt,a4paper]{ltxdoc}

\usepackage{flowchart}
\usetikzlibrary{arrows}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{textcomp}

\usepackage{fancyvrb}
\usepackage{enumitem}
\usepackage{url}
\usepackage{array}

\EnableCrossrefs
\CodelineIndex
\RecordChanges
%\OnlyDescription       % comment out for code implementation

\newcommand{\mnote}[1]
{\marginpar{\scriptsize \raggedright #1 }}

\def\tikzname{Ti\emph{k}Z} 

\begin{document}
\DocInput{flowchart.dtx}
\end{document}
%</driver>
% \fi
%
%^^A-------------------------------------------------------------------
%^^A     Change log...
%^^A-------------------------------------------------------------------
%^^A
%^^A 27 January 2013
%^^A Original
%    \changes{v3.1}{2014/01/27}{
%    Installation has been converted to dtx format, 
%    and the {\tt flowchart.sty} is generated by the 
%    {\tt flowchart.ins} file.
%    It replaces version 2.4 of the package, and 
%    uses version 2.1 of the makeshape package.
%    }
%^^A
%^^A 28 January 2013
%^^A Original
%    \changes{v3.2}{2014/01/28}{
%       The decision shape has been improved. }
%^^A
%^^A 19 March 2015
%^^A Original
%    \changes{v3.3}{2015/03/19}{
%      An error in the documentation's sample code has been corrected.
%    }
%^^A
%^^A-------------------------------------------------------------------
% 
% \CheckSum{0} ^^A no checksum for development
%^^A \CheckSum{59}
% \CharacterTable
%  {Upper-case    \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
%   Lower-case    \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
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \GetFileInfo{flowchart.sty}
%
% \title{The {\tt flowchart} package\thanks{
%    This document corresponds to \textsf{flowchart}~\fileversion, 
%    dated~\filedate.}\\[0.5ex] 
% Flowchart Shapes for \tikzname}
%
% \author{Adrian P. Robson\thanks{\texttt{adrian.robson@nepsweb.co.uk}}}
% \date{19 March 2015}
%
% \maketitle
%
%^^A \tableofcontents
% 
%^^A-------------------------------------------------------------------
%^^A     Start report body
%^^A-------------------------------------------------------------------
%
% \section{Introduction}
%
% This package provides shapes for drawing program flowcharts.
% They are based on the classic \emph{IBM Flowcharting Template}, 
% which conforms to ISO~1028:1973, with some IBM extensions. 
% (this has since been revised by ISO 5807:1985).
%
% At the moment, there is only a limited selection of the standard symbols, 
% but other symbols might be added in the future.
%
% This package requires that |makeshape| \cite{makeshape} and of course 
% PGF/\tikzname{} \cite{pgfMan} are also installed .
%
% \section{The Symbols}\label{symbols}
%
% The package provides the following symbols as defined in the ISO standard:
%
% \def\colA{3.2cm}
% \def\colB{8cm}
%
% \def\swide{2.8cm}
% \def\pht{1.3cm}
% \def\dht{1.8cm}
% \def\ppht{\pht}
% \def\sht{\pht}
% \def\tht{0.75cm}
%
%^^A - process symbol
% \vspace{3mm}
% \noindent
% \begin{tabular}{m{\colA} m{\colB}}
% \begin{tikzpicture}[>=latex',font={\sf \small}]
% \node (process1) at (0,0) [draw, process,
%    minimum width=\swide, 
%    minimum height=\pht] {PROCESS}; %PROCESS
% \end{tikzpicture}
% & 
% {\bf Process} -- Any processing function; or defined operations causing change in value, 
%   form or location of information.\\
% \end{tabular}
% 
%^^A - decision symbol
% \vspace{3mm}
% \noindent
% \begin{tabular}{m{\colA} m{\colB}}
% \begin{tikzpicture}[>=latex',font={\sf \small}]
% \node at (0,0) [draw, decision, %aspect=1.5,
% minimum width=\swide, 
% minimum height=\dht] {DECISION};
% \end{tikzpicture}
% & 
% {\bf Decision} -- A decision or switching-type operation that determines 
%    which of a number of alternative paths are followed.\\
% \end{tabular}
%
%^^A - predefined process symbol
% \vspace{5mm}
% \noindent
% \begin{tabular}{m{\colA} m{\colB}}
% \begin{tikzpicture}[>=latex',font={\sf \small}]
% \node at (0,0) [draw, predproc, align=left,
% minimum width=\swide, 
% minimum height=\ppht] {Predefined\\
%                        Process};
% \end{tikzpicture}
% & 
% {\bf Predefined Process} -- One or more named operations or program steps specified 
%    in a subroutine or another set of flowcharts.\\
% \end{tabular}
%
%^^A - storage symbol
% \vspace{5mm}
% \noindent
% \begin{tabular}{m{\colA} m{\colB}}
% \hspace*{-1.85mm}
% \begin{tikzpicture}[>=latex',font={\sf \small}]
% \node at (0,0) [draw, storage,
%    minimum width=\swide, 
%    minimum height=\sht] {STORAGE};
% \end{tikzpicture}
% & 
% {\bf Storage} -- Input or output using any kind of online storage.\\
%
% \end{tabular}
%
%^^A - terminal symbol
% \vspace{4mm}
% \noindent
% \begin{tabular}{m{\colA} m{\colB}}
% \begin{tikzpicture}[>=latex',font={\sf \small}]
% \node at (0,0) [ draw, terminal,
% minimum width=\swide, 
% minimum height=\tht] {TERMINAL};
% \end{tikzpicture}
% & 
% {\bf Terminal} -- A terminal point in a flowchart: start, stop, halt delay or interrupt. 
%    It may show exit from a closed subroutine.\\
% \end{tabular}
%
% \section{Usage} 
%
% The example below uses all of the symbols given in \S\ref{symbols}, 
% and shows how they can be laid out and connected with \tikzname: 
%
% \begin{center}
% \begin{tikzpicture}[>=latex',font={\sf \small}]
%
% \def\smbwd{2cm}
%
% \node (terminal1) at (0,0) [draw, terminal,
%    minimum width=\smbwd,
%    minimum height=0.5cm] {START};
%
% \node (predproc1) at (0,-1.5) [draw, predproc, align=left,
%    minimum width=\smbwd, 
%    minimum height=1cm] {GET\\ DATA};
%
% \node (decide1) at (0,-3.5) [draw, decision,
%    minimum width=\smbwd, 
%    minimum height=1cm] {C$<$3};
%
% \node (storage1) at (0,-5.5) [draw, storage,
%    minimum width=\smbwd, 
%    minimum height=1cm] {STORE};
%
% \node (process1) at (3,-5.5) [draw, process,
%    minimum width=\smbwd, 
%    minimum height=1cm] {PROCESS};
%
% \coordinate (point1) at (0,-6.75);
%
% \node (terminal2) at (0,-7.75) [draw, terminal, 
%    minimum width=\smbwd, 
%    minimum height=0.5cm] {END};
%
% \draw[->] (terminal1) -- (predproc1); 
% \draw[->] (predproc1) -- (decide1); 
% \draw[->] (decide1) -| node[above]{YES} (process1); 
% \draw[->] (decide1) -- (storage1); 
% \draw[->] (process1) |- (point1); 
% \draw[->] (storage1) -- (point1) -- (terminal2); 
%
% \end{tikzpicture}
% \end{center}
%
% It needs the following in the document's preamble: 
%
% \begin{VerbatimOut}[gobble=5]{\jobname.tmp}
%    \usepackage{flowchart}
%    \usetikzlibrary{arrows}
% \end{VerbatimOut}
% \VerbatimInput[]{\jobname.tmp}
%
% \noindent
% The \tikzname{} package is included in |flowchart|, so it does not have to be explicitly loaded.
% However, any |\usetikzlibrary| commands that are needed must be placed after 
% |\loadpackage{flowchart}|.
%
% The flowchart above is produced by the following |tikzpicture| environment:
%
% \begin{VerbatimOut}[gobble=1]{\jobname.tmp}
% \begin{tikzpicture}[>=latex',font={\sf \small}]
%
% \def\smbwd{2cm}
%
% \node (terminal1) at (0,0) [draw, terminal,
%    minimum width=\smbwd,
%    minimum height=0.5cm] {START};
%
% \node (predproc1) at (0,-1.5) [draw, predproc, align=left,
%    minimum width=\smbwd, 
%    minimum height=1cm] {GET\\ DATA};
%
% \node (decide1) at (0,-3.5) [draw, decision,
%    minimum width=\smbwd, 
%    minimum height=1cm] {C$<$3};
%
% \node (storage1) at (0,-5.5) [draw, storage,
%    minimum width=\smbwd, 
%    minimum height=1cm] {STORE};
%
% \node (process1) at (3,-5.5) [draw, process,
%    minimum width=\smbwd, 
%    minimum height=1cm] {PROCESS};
%
% \coordinate (point1) at (0,-6.75);
%
% \node (terminal2) at (0,-7.75) [draw, terminal, 
%    minimum width=\smbwd, 
%    minimum height=0.5cm] {END};
%
% \draw[->] (terminal1) -- (predproc1); 
% \draw[->] (predproc1) -- (decide1); 
% \draw[->] (decide1) -| node[above]{YES} (process1); 
% \draw[->] (decide1) -- (storage1); 
% \draw[->] (process1) |- (point1); 
% \draw[->] (storage1) -- (point1) -- (terminal2); 
%
% \end{tikzpicture}
% \end{VerbatimOut}
% \VerbatimInput[numbers=left]{\jobname.tmp}
%
% \subsection{Symbols}
%
% The flow chart symbols are created as nodes, as shown in lines 5-7, 
% which defines a |terminal| shape.
% The minimum dimension keys should be used to create consistently sized symbols.
% In particular, a defined value should be used for the width in all symbols.
% So |\smbwd| is defined on line 3, and used in lines 6, 10, 14, 18, 22, and 28.
%
% \subsection{Layout}
%
% In this example, we have used absolute coordinates to position the diagram's nodes.
% This works well for small flowcharts, but relative positioning might be better for larger diagrams.
%
% \subsection{Connectors}
%
% The shapes are connected by drawing lines between them as shown in lines 31-36 of the example. 
% Here, unqualified node names are used, 
% but explicit anchor names such as |(nodename.north east)| could be used instead.
%
% It can sometimes be convenient to place a connector at an arbitrary point on a shape.
% The |(nodename.45)| notation achieves this, where the number gives the angle from the centre of the 
% shape to the connecting point on its boundary.
%
% Right angled connections are traditionally used in flowcharts, and these are created with 
% the \verb+-|+ and \verb+|-+ notations shown in lines 33 and 35 of the example.
%
% Joining connectors is best done by declaring a named coordinate, and using it as the meeting point.
% In the example, a coordinate called |point1| is declared on line 25, 
% and then used in line 35 and 36 % to connect |process1| and |storage1| to |terminal2|.
%
%^^A-------------------------------------------------------------------
%^^A                            References
%^^A-------------------------------------------------------------------
%
% \def\mybib{
%   \begin{thebibliography}{9}
%     \raggedright
%     \bibitem{makeshape}
%       Adrian P. Robson,
%      \emph{The makeshape package
%       and a method for creating custom shapes in PGF}, 2013.
%       Available as {\tt makeshape.pdf} from \url{ctan.org}.
%     \bibitem{pgfMan}
%       Till Tantau, 
%       \emph{The TikZ and PGF Packages, Manual for version 2.10}, 
%       2010.
%       Available as {\tt pgfmanual.pdf} from \url{ctan.org}.
%   \end{thebibliography}
% }
%
%^^A-------------------------------------------------------------------
%^^A     Start code implementation
%^^A-------------------------------------------------------------------
%
% \StopEventually{\mybib}
%^^A \StopEventually{\mybib \PrintChanges}
%^^A    -> Run pdfLaTeX flowchart.dtx
%^^A           makeindex -s gglo.ist -o flowchart.gls flowchart.glo
%^^A           pdfLaTeX flowchart.dtx
%
% \section{Implementation}
%
% The implementation of |flowchart.sty| uses the |makeshape| package, 
% which provides support for custom PGF shapes. 
% With this, we have only have to create boundary and anchor path macros, 
% and anchor points for each shape. 
%
% There are three pairs of keys that have to be accommodated by PGF shapes:
% inner and outer separation, and minimum dimensions.
% The |makeshape| package has corrected text box macros |\ctbnex| and |\ctbney|, 
% which automatically handle inner separation; 
% and the PGF keys |\pgfshapeouterxsep|, |\pgfshapeouterysep|, |\pgfshapeminheight| and 
% |\pgfshapeminwidth|, which give the outer separation and minimum dimensions of the shape.
%
% \subsection{Preamble}
% The |makeshape| package provides the |tikz| package. However, the |shapes| library is also needed:
%
%    \begin{macrocode}
\RequirePackage{makeshape}
\RequirePackage{tikz}
\usetikzlibrary{shapes}
%    \end{macrocode}
%
%^^A ************************************************************
%^^A * Predefined Process shape starts
%^^A ************************************************************
% \subsection{Predproc Shape}
%
% This is the Predefined Process symbol.
%
% \subsubsection{Anchor and background paths}\label{predprocpaths}
%
%
% These macros define the paths that are used by the |makeshape| |setpaths| command in 
% the shape's |\pgfdeclareshape| macro, which is described in \S\ref{predprocShape}.
%
% \begin{macro}{\band}
%    The shape's side band size is an internal constant:
%    \begin{macrocode}
\def\band{10pt}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\predprocAnchorpath}
%    The |\predprocAnchorpath| macro defines the shape's \emph{anchor path}. 
%    It `draws' the path on which the shape's calculated anchor points lay.
%    It is very similar to first part of |\predproc@shape| that draws the outer path, 
%    but it corrects for outer separation and does not draw any side bands.
%    \begin{macrocode}
\def\predprocAnchorpath{
%    \end{macrocode}
%
%    First, get the corrected text box's NE corner using |\ctbnex| and |\ctbney|, 
%    then make room for the side band.
%    \begin{macrocode}
   \pgf@xa=\ctbnex
   \pgf@ya=\ctbney
   \advance\pgf@xa by \band
%    \end{macrocode}
%    Correct for minimum dimensions and outer separation:
%    \begin{macrocode}
   \mincorrect{\pgf@xa}{\pgfshapeminwidth}
   \advance\pgf@xa\pgfshapeouterxsep
   \mincorrect{\pgf@ya}{\pgfshapeminheight}
   \advance\pgf@ya\pgfshapeouterysep
%    \end{macrocode}
%
%    Finally, draw the anchor path, which is a rectangle,  
%    using the values in |\pgf@xa| and |\pgf@ya| that were calculated above:
%    \begin{macrocode}
   \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
   \pgfpathlineto{\pgfpoint{\pgf@xa}{-\pgf@ya}}
   \pgfpathlineto{\pgfpoint{-\pgf@xa}{-\pgf@ya}}
   \pgfpathlineto{\pgfpoint{-\pgf@xa}{\pgf@ya}}
   \pgfpathclose
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\predprocBackground}
%     The |\predprocBackground| macro draws the shape's path, including its side band.
%     It is used in the shape's |\backgroundpath| macro.
%    \begin{macrocode}
\def\predprocBackground{
%    \end{macrocode}
%
%    First, get the corrected text box's NE corner using |\ctbnex| and |\ctbney|, 
%    then make room for the side band.
%    \begin{macrocode}
   \pgf@xa=\ctbnex
   \pgf@ya=\ctbney
   \advance\pgf@xa by \band
%    \end{macrocode}
%    Correct for minimum dimensions but \emph{do not add} outer separation:
%    \begin{macrocode}
   \mincorrect{\pgf@xa}{\pgfshapeminwidth}
   \mincorrect{\pgf@ya}{\pgfshapeminheight}
%    \end{macrocode}
%
%    Finally, draw the outer shape, which is a rectangle, 
%    using the values in |\pgf@xa| and |\pgf@ya| that were calculated above:
%    \begin{macrocode}
   \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
   \pgfpathlineto{\pgfpoint{\pgf@xa}{-\pgf@ya}}
   \pgfpathlineto{\pgfpoint{-\pgf@xa}{-\pgf@ya}}
   \pgfpathlineto{\pgfpoint{-\pgf@xa}{\pgf@ya}}
   \pgfpathclose
%    \end{macrocode}
%
%    Finally, we draw the inner shape, which completes the shape with its side bands.
%    The x-coordinate is aligned on the right side band position, then the side bands are drawn:
%    \begin{macrocode}
   \advance\pgf@xa by -\band
   \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
   \pgfpathlineto{\pgfpoint{\pgf@xa}{-\pgf@ya}}
   \pgfpathmoveto{\pgfpoint{-\pgf@xa}{\pgf@ya}}
   \pgfpathlineto{\pgfpoint{-\pgf@xa}{-\pgf@ya}}
}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Predproc shape declaration}\label{predprocShape}
%
% \begin{macro}{\pgfdeclareshape}
% \begin{macro}{predproc}
%    This is the |\pgfdeclareshape| declaration for the |predproc| shape. 
%    \begin{macrocode}
\pgfdeclareshape{predproc}{
%    \end{macrocode}
% The path macros defined in \S\ref{predprocpaths} are used as follows
% with the |setpaths| command provided by the |makeshape| package to draw the 
% shape and make boundary intersection calculations.
%    \begin{macrocode}
   \setpaths{\predprocAnchorpath}{\predprocBackground}
%    \end{macrocode}
%
% \begin{macro}{\savedanchor}
% \begin{macro}{\northeast}
% The |\northeast| saved anchor is used to define the position of the NE corner of the shape.
% The calculation is similar that used in the anchor path described in \S\ref{predprocpaths},
% and corrects for inner and outer separation, and minimum dimensions.
% It returns the coordinates of the point in |\pgf@x| and |\pgf@y|.
%    \begin{macrocode}
   \savedanchor{\northeast}{
      \pgf@x = \ctbnex
      \advance\pgf@x by \band
      \mincorrect{\pgf@x}{\pgfshapeminwidth}
      \advance\pgf@x\pgfshapeouterxsep
      \pgf@y = \ctbney
      \mincorrect{\pgf@y}{\pgfshapeminheight}
      \advance\pgf@y\pgfshapeouterysep
   }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\anchor}
% \begin{macro}{north}
% \begin{macro}{north east}
% \begin{macro}{east}
% \begin{macro}{south east}
% \begin{macro}{south}
% \begin{macro}{south west}
% \begin{macro}{west}
% \begin{macro}{north west}
%    There are some standard anchors, which  
%    are all based on the |\northeast| saved anchor:
%    \begin{macrocode}
   \anchor{north}{ \northeast \pgf@x=0pt }
   \anchor{north east}{ \northeast }
   \anchor{east}{ \northeast \pgf@y=0pt }
   \anchor{south east}{ \northeast \pgf@y=-\pgf@y }
   \anchor{south}{ \northeast \pgf@x=0pt \pgf@y=-\pgf@y }
   \anchor{south west}{ \northeast \pgf@x=-\pgf@x \pgf@y=-\pgf@y }
   \anchor{west}{ \northeast \pgf@x=-\pgf@x \pgf@y=0pt }
   \anchor{north west}{ \northeast \pgf@x=-\pgf@x }
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%    \begin{macrocode}
}
%    \end{macrocode}
% \end{macro} ^^A end predproc 
% \end{macro} ^^A end \pgfdeclareshape
%
%^^A ************************************************************
%^^A * Predefined Process shape ends
%^^A ************************************************************
%
%^^A ************************************************************
%^^A *   Storage shape starts
%^^A ************************************************************
% \subsection{Storage Shape}
%
% \subsubsection{Support Macros}
%
% \begin{macro}{\storagepath}
%    The |storage| shape's background path is defined in |\storagepath|. 
%    It requires the following register to be set:
%
%    \begin{tabular}{ll}
%     |\pgf@x|  & x coordinate of NE corner excluding outer separation\\
%     |\pgf@y|  & y coordinate of NE corner excluding outer separation\\
%     |\pgf@xc| & arc offset for y coordinate 
%    \end{tabular}
%
%\medskip
% The NE corner is stored in |\pgf@xa| and |\pgf@ya| and
% and the SW corner is put in |\pgf@xb| and |\pgf@yb|.
% The SW x-coordinate has to be moved right by the arc offset to compensate for the 
% curve of the shapes west side.  
%    \begin{macrocode}
\def\storagepath{
   \pgf@xa=\pgf@x \pgf@ya=\pgf@y
   \pgf@xb=-\pgf@xa \pgf@yb=-\pgf@ya
   \advance\pgf@xb by \pgf@xc
%    \end{macrocode}
%    The shape is drawn from its SW corner moving counter clockwise.
%    The radius for the arcs is the height.
%    \begin{macrocode}
   \pgfpathmoveto{\pgfpoint{\pgf@xb}{\pgf@yb}}
   \pgfpatharc{210}{150}{2*\pgf@ya} 
   \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@ya}}
   \pgfpatharc{150}{210}{2*\pgf@ya}
   \pgfpathclose
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\arcoffset}
%    The |storage| shape's arc offset is calculated by the |\arcoffset| macro.
%    The required arc offset is $b$, and the shape's height is  $h$ in the diagram below. 
%    \medskip
% 
%    \begin{tabular}{cc}
%      \begin{tikzpicture}
%         \def\sht{4cm}
%         \def\oset{0.536cm}
%         \def\a{\sht+\oset}
%         \draw[] (0,0) -- (-\sht,0);
%         \draw[] (-\sht,0) arc (0:40:-\sht); 
%         \draw[] (-\sht,0) arc (180:140:\sht); 
%         \draw[] (-\a,-\sht*0.5) -- (-\a,\sht*0.5);
%         \draw[] (-\a,\sht*0.5) -- (0,0);
%         \draw[] (-\a,\sht*0.5) -- ++(-1,0);
%         \draw[] (-\a,-\sht*0.5) -- ++(-1,0);
%         \node at (-2cm,1.5cm) [] {$h$};
%         \node at (-3.1cm,0.7cm) [] {$h/2$};
%         \node at (-2cm,-0.2cm) [] {$a$};
%         \node at (-3.7cm,-0.2cm) [] {$b$};
%     \end{tikzpicture}
%    &
%    \begin{minipage}[b]{6.5cm}
%      \begin{eqnarray}
%         h^2 &=& a^2 + \left(\frac{h}{2}\right)^2 \nonumber\\[3pt]
%         a^2 &=& h^2 - \frac{h^2}{4} = \frac{3h^2}{4} \nonumber\\[2pt]
%           a &=& h \sqrt{3/4}\\[2ex]
%           b &=& h - a = h - h \sqrt{3/4}  \nonumber\\[2pt]
%             &=& h(1 - \sqrt{3/4}) \approx 0.134h \label{equoffset} \\\nonumber
%      \end{eqnarray}
%    \end{minipage}
%    \end{tabular}
% 
%    \bigskip
%    \noindent
%    The macro's parameters are:
%
%    \begin{tabular}{ll}
%      |#1|  & the calculated arc offset\\
%      |#2|  & half the height\\
%    \end{tabular}
%
%    \medskip\noindent
%    Equation \ref{equoffset} given above is implemented as follows:
%    \begin{macrocode}
\def\arcoffset#1#2{
   \pgfmathsetlength#1{0.134*2*#2}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\storageParams}
%    The |\storageParams| macro calculates reference values for the shape 
%    with no outer separation.
%    The following have values assigned after it is called:
%
%    \begin{tabular}{ll}
%     |\pgf@x|  & x-coordinate of NE corner excluding outer separation\\
%     |\pgf@y|  & y-coordinate of NE corner excluding outer separation\\
%     |\pgf@xc| & arc offset for y-coordinate 
%    \end{tabular}
%
% \medskip
%   First get the shape's corrected text box:
%    \begin{macrocode}
\def\storageParams{
   \pgf@xa=\ctbnex
   \pgf@ya=\ctbney
%    \end{macrocode}
%    Correct for minimum height but not for outer separation.
%    \begin{macrocode}
   \mincorrect{\pgf@ya}{\pgfshapeminheight}
%    \end{macrocode}
%    Calculate the room needed for the side arc, which is one of the macro's outputs, 
%    and use it to change the x-coordinate:
%    \begin{macrocode}
   \arcoffset{\pgf@xc}{\pgf@ya}
   \advance\pgf@xa by \pgf@xc
%    \end{macrocode}
%    Finally, correct for minimum width and set the output registers:
%    \begin{macrocode}
   \mincorrect{\pgf@xa}{\pgfshapeminwidth}
   \pgf@x=\pgf@xa
   \pgf@y=\pgf@ya
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\storageParamsOuter}
%    The |\storageParamsOuter| macro calculates reference values for the shape 
%    with its outer separation included.
%    The following have values assigned after it is called:
%    \begin{tabular}{ll}
%     |\pgf@x|  & x coordinate of NE corner including outer separation\\
%     |\pgf@y|  & y coordinate of NE corner including outer separation\\
%     |\pgf@xc| & arc offset for y coordinate 
%    \end{tabular}
%
%    \medskip
%    Its implementation has a lot in common with |\storageParams|.
%    First, get the NE corner of the corrected text box:
%    \begin{macrocode}
\def\storageParamsOuter{
   \pgf@xa=\ctbnex
   \pgf@ya=\ctbney
%    \end{macrocode}
%    Correct for minimum height and outer separation:
%    \begin{macrocode}
   \mincorrect{\pgf@ya}{\pgfshapeminheight}
   \advance\pgf@ya\pgfshapeouterysep
%    \end{macrocode}
%    Calculate the arc offset, which is an output, and make room for the side curve:
%    \begin{macrocode}
   \arcoffset{\pgf@xc}{\pgf@ya}
   \advance\pgf@xa by \pgf@xc
%    \end{macrocode}
%    Finally, correct for minimum width and outer separation. Then set the output registers:
%    \begin{macrocode}
   \mincorrect{\pgf@xa}{\pgfshapeminwidth}
   \advance\pgf@xa\pgfshapeouterxsep
   \pgf@x=\pgf@xa
   \pgf@y=\pgf@ya
}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Anchor and background paths}\label{storagepaths}
%
% The anchor and background path macros both use |\storagepath|, but with with different parameters.
% The output registers of the macros |\storageParams| and |\storageParamsOuter|  
% are compatible with the inputs of |\storagepath|.
%
% \begin{macro}{\storageAnchorpath}
%    The |\storageAnchorpath| macro defines the shape's \emph{anchor path}. 
%    It `draws' the path on which the shape's calculated anchor points lay.
%    This is similar to the background path but it is corrected for outer separation 
%    and minimum dimensions.
%    \begin{macrocode}
\def\storageAnchorpath{
   \storageParamsOuter
   \storagepath
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\storageBackground}
%    The |\storageBackground| macro draws the path that is the outer boundary of the 
%    |storage| shape. This excludes outer separation but corrects for minimum height and width.
%    \begin{macrocode}
\def\storageBackground{
   \storageParams 
   \storagepath
}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Storage shape declaration}
%
% \begin{macro}{\pgfdeclareshape}
% \begin{macro}{storage}
%    This is the |\pgfdeclareshape| declaration for the |storage| shape. 
%    \begin{macrocode}
\pgfdeclareshape{storage}{
%    \end{macrocode}
% The path macros defined in \S\ref{storagepaths} are used 
% with the |setpaths| command provided by the |makeshape| package to draw the 
% shape and make boundary intersection calculations:
%    \begin{macrocode}
   \setpaths{\storageAnchorpath}{\storageBackground}
%    \end{macrocode}
%
% \begin{macro}{\savedanchor}
% \begin{macro}{\northeast}
% There are two saved anchors defined for the |storage| shape.
% The |\northeast| saved anchor is used to define the position of the NE corner of the shape.
% The calculation is similar that used in the anchor path described in \S\ref{storagepaths},
% and corrects for inner and outer separation, and minimum dimensions.
% It returns the coordinates of the point in |\pgf@x| and |\pgf@y|, 
% and its implementation is trivial since |\storageParamsOuter| does the required work.
%    \begin{macrocode}
   \savedanchor{\northeast}{
      \storageParamsOuter 
   }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\savedanchor}
% \begin{macro}{\northeast}
% The |\northeastArc| saved anchor is similar, but corrects for the arc offset.
%
%    \begin{macrocode}
   \savedanchor{\northeastArc}{
      \storageParamsOuter
      \advance\pgf@x by -\pgf@xc
   }
%    \end{macrocode}
% \end{macro}
% \end{macro}
% 
% \begin{macro}{\anchor}
% \begin{macro}{north}
% \begin{macro}{north east}
% \begin{macro}{east}
% \begin{macro}{south east}
% \begin{macro}{south}
% \begin{macro}{south west}
% \begin{macro}{west}
% \begin{macro}{north west}
%    The standard anchors are defined. 
%    These are based on the |\northeast| and |\northeastArc| saved anchors:
%    \begin{macrocode}
   \anchor{north}{ \northeast \pgf@x=0pt }
   \anchor{north east}{ \northeast }
   \anchor{east}{ \northeastArc \pgf@y=0pt }
   \anchor{south east}{ \northeast \pgf@y=-\pgf@y }
   \anchor{south}{ \northeast \pgf@x=0pt \pgf@y=-\pgf@y }
   \anchor{south west}{ \northeastArc \pgf@x=-\pgf@x \pgf@y=-\pgf@y }
   \anchor{west}{ \northeast \pgf@x=-\pgf@x \pgf@y=0pt }
   \anchor{north west}{ \northeastArc \pgf@x=-\pgf@x }
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\anchor}
% \begin{macro}{north}
% \begin{macro}{north east}
% \begin{macro}{east}
%   Three additional anchors are defined that follow the shape's bounding rectangle. 
%    \begin{macrocode}
   \anchor{east r}{ \northeast \pgf@y=0pt }
   \anchor{north west r}{ \northeast \pgf@x=-\pgf@x }
   \anchor{south west r}{ \northeast \pgf@x=-\pgf@x \pgf@y=-\pgf@y }
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%    \begin{macrocode}
}
%    \end{macrocode}
% \end{macro} ^^A end storage 
% \end{macro} ^^A end \pgfdeclareshape
%
%^^A ************************************************************
%^^A * Storage shape ends
%^^A ************************************************************
%
%^^A ************************************************************
%^^A * Process shape starts
%^^A ************************************************************
% \subsection{Process Shape}
%
% \begin{macro}{\pgfdeclareshape}
% \begin{macro}{process}
%    The {\tt process} shape is simply implemented  
%    by inheriting relevant anchors and paths from the standard |rectangle| shape
%    without any changes:
%    \begin{macrocode}
\pgfdeclareshape{process}{
   \inheritsavedanchors[from=rectangle] 
   \inheritanchor[from=rectangle]{center}
   \inheritanchor[from=rectangle]{text}
   \inheritanchor[from=rectangle]{north}
   \inheritanchor[from=rectangle]{north east}
   \inheritanchor[from=rectangle]{east}
   \inheritanchor[from=rectangle]{south east}
   \inheritanchor[from=rectangle]{south}
   \inheritanchor[from=rectangle]{south west}
   \inheritanchor[from=rectangle]{west}
   \inheritanchor[from=rectangle]{north west}
   \inheritbackgroundpath[from=rectangle]
   \inheritanchorborder[from=rectangle]
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%^^A ************************************************************
%^^A * Process shape ends
%^^A ************************************************************
%
%^^A ************************************************************
%^^A * Decision shape starts
%^^A ************************************************************
% \subsection{Decision Shape}
%
% \subsubsection{Support Macros}
%
% Two macros |\decisionref| and |\decisionrefout| give a reference point for the |decision| shape.
% The default shape is a rotated square which touches the corrected text box.
% The location and calculation of the default reference point is illustrated below:
%
%    \begin{center}
%      \begin{tikzpicture}
%
%         ^^A - Axis
%         \draw [dotted] (0,0) -- +(3cm,0) -- +(-3cm,0)  +(0,3cm) -- +(0,-1cm);
%
%         ^^A - draw line
%         \draw [] (0,2.5cm) -- (2.5cm,0);
%
%         ^^A East point
%         \node at (3.4cm,-0.3cm) [] {$(0,x_t + y_t)$};
%         \draw [] (2.5cm,0) circle (2pt);
%
%         ^^A North point
%         \node at (-1cm,2.5cm) [] {$(y_t + x_t,0)$};
%         \draw [] (0,2.5cm) circle (2pt);
%         \node at (-0.6cm,1.8cm) [outer sep=-2pt] (angletxt) {$45^\circ$};          
%         \node at (0.15cm,2.1cm) [coordinate] (anglepnt) {};
%         \draw [->] (angletxt) -- (anglepnt);
%
%         ^^A Reference point
%         \draw [dotted] (0,2.5cm) -- +(3,0);
%         \draw [dotted] (2.5cm,0) -- +(0,3);
%         \node at (3.7cm,2.7cm) [] {\sf \small reference point};
%         \node at (3.9cm,2.2cm) [] {$(y_t+x_t,x_t+y_t)$};
%         \draw (2.5cm,2.5cm) circle (2pt);
%         \draw (2.5cm,2.5cm) -- +(4pt,0) -- +(-4pt,0) +(0,4pt) -- +(0,-4pt);
%
%         ^^A - Corrected text box
%         \node at (-1.5cm,0.7cm) [] {\sf \small corrected text box};
%         \node at (2.5cm,0.7cm) [rectangle,draw,fill,white,minimum height=12pt] {};
%         \node at (2.6cm,0.7cm) [] {$(x_t,y_t)$};
%         \draw [] (2cm,0.5cm) circle (2pt);
%         \node at (0,0)
%            [rectangle, draw,
%             minimum width=4cm,
%             minimum height=1cm,
%            ] (ctb) {};
%
%     \end{tikzpicture}
%    \end{center}
%    \vspace{-2ex}
%
% \begin{macro}{\decisionrefout}
%    The |\decisionrefout| macro gives a reference point on the bounding rectangle of 
%    the |decision| shape.
%    Inner and outer separation are included, and it is corrected for the shape's minimum dimensions. 
%    On completion, the coordinates of the point are in |\pgf@xa| and |\pgf@ya|.
%
%    First, the coordinates of the corrected text box are put into some registers: 
%    \begin{macrocode}
\def\decisionrefout{
   \pgf@xa=\ctbnex
   \pgf@ya=\ctbney
   \pgf@xb=\ctbnex
   \pgf@yb=\ctbney
%    \end{macrocode}
%    The reference point's x-coordinates is calculated and corrected for minimum width, 
%    and outer x-separation:
%    \begin{macrocode}
   \advance\pgf@xa by \pgf@yb
   \mincorrect{\pgf@xa}{\pgfshapeminwidth}
   \advance\pgf@xa by \pgfshapeouterxsep
%    \end{macrocode}
%    Then the calculation and correction is repeated for the y-coordinate:
%    \begin{macrocode}
   \advance\pgf@ya by \pgf@xb
   \mincorrect{\pgf@ya}{\pgfshapeminheight}
   \advance\pgf@ya by \pgfshapeouterysep
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\decisionref}
%    The |\decisionref| macro is almost the same as |\decisionrefout| 
%    but has no correction for outer separation.
%    Again, the coordinates of the point are in |\pgf@xa| and |\pgf@ya|  on completion:
%    \begin{macrocode}
\def\decisionref{
   \pgf@xa=\ctbnex
   \pgf@ya=\ctbney
   \pgf@xb=\ctbnex
   \pgf@yb=\ctbney
   \advance\pgf@xa by \pgf@yb
   \mincorrect{\pgf@xa}{\pgfshapeminwidth}
   \advance\pgf@ya by \pgf@xb
   \mincorrect{\pgf@ya}{\pgfshapeminheight}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\decisionpath}
%    The |\decisionpath| macro draws the |\decision| shape's path. 
%    It expects the reference point coordinates to be in |\pgf@xa| and |\pgf@ya|. 
%    The path is drawn clockwise starting at the top:
%    \begin{macrocode}
\def\decisionpath{
   \def\refx{\pgf@xa}
   \def\refy{\pgf@ya}
   \pgfpathmoveto{\pgfpoint{0}{\refy}}
   \pgfpathlineto{\pgfpoint{\refx}{0}}
   \pgfpathlineto{\pgfpoint{0}{-\refy}}
   \pgfpathlineto{\pgfpoint{-\refx}{0}}
   \pgfpathclose
}
%    \end{macrocode}
% \end{macro}
%
%\subsubsection{Anchor and background paths}\label{decisionpaths}
%
% \begin{macro}{\decisionanchor}
% The |\decisionanchor| macro is the anchor path for the shape's |setpath|:
%    \begin{macrocode}
\def\decisionanchor{
   \decisionrefout
   \decisionpath
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\decisionborder}
% The |\decisionborder| macro is the border path for the shape's |setpath|:
%    \begin{macrocode}
\def\decisionborder{
   \decisionref
   \decisionpath
}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Decision shape declaration}
%
% \begin{macro}{\pgfdeclareshape}
% \begin{macro}{decision}
%    This is the |\pgfdeclareshape| declaration for the |decision| shape.
%    \begin{macrocode}
\pgfdeclareshape{decision}{
%    \end{macrocode}
% The path macros defined in \S\ref{terminalpaths} are used 
% with the |setpaths| command provided by the |makeshape| package to draw the 
% shape and make boundary intersection calculations:
%    \begin{macrocode}
   \setpaths{\decisionanchor}{\decisionborder}
%    \end{macrocode}
%
% There are three saved anchors defined for the |decision| shape.
% They have to correct for inner and outer separation, and minimum dimensions;
% and return the coordinates of the point in |\pgf@x| and |\pgf@y|. 
% However, this is simplified because |\decisionrefout| does the required work.
% \begin{macro}{\savedanchor}
% \begin{macro}{\north}
%    The |\north| saved anchor uses the y-coordinate of the reference point:
%    \begin{macrocode}
   \savedanchor{\north}{
      \decisionrefout
      \pgf@x = 0pt
      \pgf@y = \pgf@ya
   }
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\savedanchor}
% \begin{macro}{\north}
%    The |\east| saved anchor uses the x-coordinate of the reference point:
%    \begin{macrocode}
   \savedanchor{\east}{
      \decisionrefout
      \pgf@x = \pgf@xa
      \pgf@y = 0pt
   }
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\savedanchor}
% \begin{macro}{\northeast}
%    The |\northeast| saved anchor uses the both coordinates of the reference point to 
%    calculate the required point:
%    \begin{macrocode}
   \savedanchor{\northeast}{
      \decisionrefout
      \divide\pgf@xa by 2
      \divide\pgf@ya by 2
      \pgf@x = \pgf@xa
      \pgf@y = \pgf@ya
   }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\anchor}
% \begin{macro}{north}
% \begin{macro}{north east}
% \begin{macro}{east}
% \begin{macro}{south east}
% \begin{macro}{south}
% \begin{macro}{south west}
% \begin{macro}{west}
% \begin{macro}{north west}
%    The standard anchors are defined. 
%    These are based on the |\north| |\east| and |\northeast| saved anchors:
%    \begin{macrocode}
   \anchor{north}{ \north }
   \anchor{north east}{ \northeast }
   \anchor{east}{ \east }
   \anchor{south east}{ \northeast \pgf@y=-\pgf@y }
   \anchor{south}{ \north \pgf@y=-\pgf@y }
   \anchor{south west}{ \northeast \pgf@x=-\pgf@x \pgf@y=-\pgf@y }
   \anchor{west}{ \east \pgf@x=-\pgf@x }
   \anchor{north west}{ \northeast \pgf@x=-\pgf@x }
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%    \begin{macrocode}
}
%    \end{macrocode}
% \end{macro} ^^A end decision 
% \end{macro} ^^A end \pgfdeclareshape
%
%^^A ************************************************************
%^^A * Decision shape ends
%^^A ************************************************************
%
%^^A ************************************************************
%^^A * Terminal shape starts
%^^A ************************************************************
% \subsection{Terminal Shape}
%
% \subsubsection{Support Macros}
%
% Two macros |\terminalrefneout| and |\terminalrefne| give a reference point on the 
% boundary surface of the |terminal| shape.
%
%    \begin{center}
%      \begin{tikzpicture}
%         ^^A - Axis
%         \draw [dotted] (0,0) -- +(2cm,0) -- +(-2cm,0)  +(0,1cm) -- +(0,-1cm);
%         ^^A - Terminal shape
%         \node (terminal) at (0,0) [draw,terminal,minimum height=1cm, minimum width=3cm] {};
%         ^^ A - Reference point
%         \draw (terminal.north east) circle (2pt);
%         \node at (1.7cm,0.8cm) [] {\sf \small reference point};
%         \draw [dotted] (terminal.north east) -- +(0,-1.5cm) -- +(0,0.2cm);
%     \end{tikzpicture}
%    \end{center}
%    \vspace{-2ex}
%
% \begin{macro}{\terminalrefneout}
%    The |\terminalrefneout| macro gives a reference point on the boundary surface of 
%    the |terminal| shape.
%    Inner and outer separation are included, and it is corrected for the shape's minimum dimensions. 
%    On completion, the coordinates of the point are in |\pgf@xa| and |\pgf@ya|.
%
%    First, the coordinates of the corrected text box are obtained, 
%    and then the width of the rounded end is add to the x-coordinate to get the bounding
%    dimensions:
%    \begin{macrocode}
\def\terminalrefneout{
   \pgf@xa=\ctbnex
   \pgf@ya=\ctbney
   \advance\pgf@xa by \pgf@ya
%    \end{macrocode}
%    Then these bounding coordinates are corrected for minimum dimensions, and outer separation:
%    \begin{macrocode}
   \mincorrect{\pgf@xa}{\pgfshapeminwidth}
   \advance\pgf@xa\pgfshapeouterxsep
   \mincorrect{\pgf@ya}{\pgfshapeminheight}
   \advance\pgf@ya\pgfshapeouterysep
%    \end{macrocode}
%    Finally, the corrected x-coordinate is reduced by the width of the rounded end to give 
%    the required reference point:
%    \begin{macrocode}
   \advance\pgf@xa by -\pgf@ya   
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\terminalrefne}
%    The |\terminalrefne| macro is almost the same as |\terminalrefneout| 
%    but has no correction for outer separation.
%    Again, the coordinates of the point are in |\pgf@xa| and |\pgf@ya|  on completion:
%    \begin{macrocode}
\def\terminalrefne{
   \pgf@xa=\ctbnex
   \pgf@ya=\ctbney
   \advance\pgf@xa by \pgf@ya
   \mincorrect{\pgf@xa}{\pgfshapeminwidth}
   \mincorrect{\pgf@ya}{\pgfshapeminheight}
   \advance\pgf@xa by -\pgf@ya   
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\terminalpath}
%    The |\terminalpath| macro draws the |terminal| shape's path. 
%    It expects the reference point coordinates to be in |\pgf@xa| and |\pgf@ya|. 
%    The path is drawn anticlockwise:
%    \begin{macrocode}
\def\terminalpath{
   \def\refx{\pgf@xa}
   \def\refy{\pgf@ya}
   \def\radius{\refy}
   \pgfpathmoveto{\pgfpoint{\refx}{\refy}}
   \pgfpathlineto{\pgfpoint{-\refx}{\refy}}
   \pgfpatharc{90}{270}{\radius}
   \pgfpathlineto{\pgfpoint{\refx}{-\refy}}
   \pgfpatharc{270}{360}{\radius}
   \pgfpatharc{0}{90}{\radius}
   \pgfpathclose
}
%    \end{macrocode}
% \end{macro}
%
%\subsubsection{Anchor and background paths}\label{terminalpaths}
%
% \begin{macro}{\terminalanchor}
% The |\terminalanchor| macro is the anchor path for the shape's |setpath|:
%    \begin{macrocode}
\def\terminalanchor{
   \terminalrefneout
   \terminalpath
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\terminalborder}
% The |\terminalborder| macro is the border path for the shape's |setpath|:
%    \begin{macrocode}
\def\terminalborder{
   \terminalrefne
   \terminalpath
}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Terminal shape declaration}
%
% \begin{macro}{\pgfdeclareshape}
% \begin{macro}{terminal}
%    This is the |\pgfdeclareshape| declaration for the |terminal| shape.
%    \begin{macrocode}
\pgfdeclareshape{terminal}{
%    \end{macrocode}
% The path macros defined in \S\ref{terminalpaths} are used 
% with the |setpaths| command provided by the |makeshape| package to draw the 
% shape and make boundary intersection calculations:
%    \begin{macrocode}
   \setpaths{\terminalanchor}{\terminalborder} 
%    \end{macrocode}
%
% \begin{macro}{\savedanchor}
% \begin{macro}{\northeast}
%    There are two saved anchors defined for the |terminal| shape.
%    The |\northeast| saved anchor gives the position of the shape's `reference point' used above.
%    It corrects for inner and outer separation, and minimum dimensions.
%    It returns the coordinates of the point in |\pgf@x| and |\pgf@y|, 
%    and its implementation is simple since |\terminalrefneout| does the required work. 
%    \begin{macrocode}
   \savedanchor{\northeast}{
      \terminalrefneout
      \pgf@x = \pgf@xa
      \pgf@y = \pgf@ya
   }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\savedanchor}
% \begin{macro}{\northeastBB}
%    The |\northeastBB| macro gives the coordinates of the NE corner of the shape's 
%    bounding rectangle in |\pgf@x| and |\pgf@y|. 
%    It corrects for inner and outer separation, and minimum dimensions.
%    It is obtain by adding the width of the shape's round end to the x-coordinate of the 
%    reference point:
%    \begin{macrocode}
   \savedanchor{\northeastBB}{
      \terminalrefneout
      \advance \pgf@xa by \pgf@ya
      \pgf@x = \pgf@xa
      \pgf@y = \pgf@ya
   }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\anchor}
% \begin{macro}{north}
% \begin{macro}{north east}
% \begin{macro}{east}
% \begin{macro}{south east}
% \begin{macro}{south}
% \begin{macro}{south west}
% \begin{macro}{west}
% \begin{macro}{north west}
%    The standard anchors are defined. 
%    These are based on the |\northeast| and |\northeastBB| saved anchors:
%    \begin{macrocode}
   \anchor{north}{ \northeast \pgf@x=0pt }
   \anchor{north east}{ \northeast }
   \anchor{east}{ \northeastBB \pgf@y=0pt }
   \anchor{south east}{ \northeast \pgf@y=-\pgf@y }
   \anchor{south}{ \northeast \pgf@x=0pt \pgf@y=-\pgf@y }
   \anchor{south west}{ \northeast \pgf@x=-\pgf@x \pgf@y=-\pgf@y }
   \anchor{west}{ \northeastBB \pgf@x=-\pgf@x \pgf@y=0pt }
   \anchor{north west}{ \northeast \pgf@x=-\pgf@x }
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\anchor}
% \begin{macro}{north east r}
% \begin{macro}{south east r}
% \begin{macro}{south west r}
% \begin{macro}{north west r}
%    Four additional anchors are defined that follow the shape's bounding rectangle. 
%    \begin{macrocode}
   \anchor{north east r}{\northeastBB}
   \anchor{south east r}{\northeastBB \pgf@y=-\pgf@y}
   \anchor{south west r}{\northeastBB \pgf@x=-\pgf@x \pgf@y=-\pgf@y}
   \anchor{north west r}{\northeastBB \pgf@x=-\pgf@x}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%    \begin{macrocode}
}
%    \end{macrocode}
% \end{macro} ^^A end terminal
% \end{macro} ^^A end \pgfdeclareshape
%
%^^A ************************************************************
%^^A * Terminal shape ends
%^^A ************************************************************
%
% \Finale
\endinput