% \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
