% \iffalse
% --------------------------------------------------------------------
%<*utils>
% \fi
% 
% \subsubsection{Pictures in compound nodes}
%
% \begin{Macro}{\wg@pic}
%   The macro \cs{wg@pic} will render a \texttt{pic}. This is used by
%   the \texttt{natoapp6cs}, \texttt{chit}, and \texttt{hex} node
%   shapes extensively.
%
%   The arguments are
%   \begin{enumerate}
%   \item Prefix
%   \item Position
%   \item Fixed options
%   \item User options
%   \item Picture. 
%   \end{enumerate}
%
%   That is, the macro expects calls like 
%   \begin{Syntax}
%     \cs{wg@pic}\oarg{options}\meta{picture}\cs{@endwg@pic}\marg{prefix}\marg{position}\marg{options}
%   \end{Syntax}
%
%    Note the \cs{@endwg@pic} at the end of the call to swallow up
%    \meta{picture}.   Typically this macro is used as
%
%    \begin{Syntax}
%      \cs{edef}\cs{args}\{\meta{something}\}
%      \cs{expandafter}\cs{wg@pic}\cs{args}\cs{@endwg@pic}\marg{prefix}\parg{position}\marg{options}
%    \end{Syntax}
%
%    where \meta{something} typically expands to \oarg{user
%    option}\meta{picture}
%
%    First, the top-level macro \cs{wg@pic} that looks for user
%    options.
%    
%    \begin{macrocode}
\def\wg@pic{%
  \@ifnextchar[{\wg@@pic}{\wg@@pic[]}%]
}
%    \end{macrocode}
%
% This macro then forwards to \cs{wg@@pic} to gobble up
% \meta{picture}.
%
% \begin{enumerate}
% \item User options
% \item Arguments
% \end{enumerate}
% 
%    \begin{macrocode}
\def\wg@@pic[#1]#2\@endwg@pic{%
  \wg@dbg{2}{Options: `#1', picture: `#2'}%
  \wg@@@pic{#1}{#2}%
}
%    \end{macrocode}
% 
% \begin{enumerate}
% \item User options
% \item Arguments
% \item Prefix
% \item Coordinates
% \item Fixed options
% \end{enumerate}
% 
%    \begin{macrocode}
\def\wg@@@pic#1#2#3#4#5{%
  \ifx|#2|\wg@dbg{3}{No picture given}%
  \else%
    \wg@dbg{3}{^^JWG Pic:
      ^^J  User options:  #1
      ^^J  Picture:       #2
      ^^J  Prefix:        #3
      ^^J  Coordinates:   #4
      ^^J  Fixed options: #5}%
    % \wg@dbg{2}{\string\pic[#5,#1] at (#4) {#3#2}}%
    \pic[#5,#1] at (#4) {#3#2};%
    \ifwg@s@ve%
      \pgf@relevantforpicturesizetrue%
      \begin{getbbl}%
        \pic[draw=none,fill=none,transform shape] at (#4) {#3#2};%
      \end{getbbl}%
      \wg@dbg{5}{Clipping to local bounding box}%
      \clip (L.south west) rectangle (L.north east);%
      \pgf@relevantforpicturesizefalse \global\wg@s@vefalse%
    \fi
  \fi%
  \wg@dbg{3}{End of WG Pic}
}
%    \end{macrocode}
% \end{Macro}
% 
%
% \begin{Macro}{\wg@pic@all}
%
%   This macro sets all pictures in a list.
%   
%   \begin{enumerate}
%   \item List
%   \item Prefix
%   \item Position
%   \item Styles
%   \end{enumerate}
%
%
%    \begin{macrocode}
\def\wg@pic@all#1#2#3#4{%
  \wg@dbg{2}{WG picture loop
    ^^J  List:    \meaning#1
    ^^J  Prefix:  `#2'
    ^^J  Position: `#3'
    ^^J  Styles:   `#4'}
  \foreach \p in #1{%
    \wg@dbg{2}{WG picture element: \meaning\p}%
    \expandafter\wg@pic\p\@endwg@pic {#2}{#3}{#4}%
  }%
}
%    \end{macrocode}
% \end{Macro}
% 
% \iffalse
% --------------------------------------------------------------------
% \fi
% 
% \subsubsection{Nodes in compound nodes}
%
% \begin{Macro}{\wg@node}
%   The macro \cs{wg@node} will render a \texttt{node}. This can be
%   used by the \texttt{natoapp6cs}, \texttt{chit}, and \texttt{hex}
%   node shapes.
%
%   The arguments are
%   \begin{enumerate}
%   \item Prefix
%   \item Position
%   \item Fixed options
%   \item User options
%   \item Body. 
%   \end{enumerate}
%
%   That is, the macro expects calls like 
%   \begin{Syntax}
%     \cs{wg@node}\oarg{options}\meta{body}\cs{@endwg@node}\marg{prefix}\marg{position}\marg{options}
%   \end{Syntax}
%
%    Note the \cs{@endwg@node} at the end of the call to swallow up
%    \meta{body}.   Typically this macro is used as
%
%    \begin{Syntax}
%      \cs{edef}\cs{args}\{\meta{something}\}
%      \cs{expandafter}\cs{wg@node}\cs{args}\cs{@endwg@node}\marg{prefix}\parg{position}\marg{options}
%    \end{Syntax}
%
%    where \meta{something} typically expands to \oarg{user
%    option}\meta{body}
%
%    First, the top-level macro \cs{wg@node} that looks for user
%    options.
%    
%    \begin{macrocode}
\def\wg@node{%
  \@ifnextchar[{\wg@@node}{\wg@@node[]}%]
}
%    \end{macrocode}
%
% This macro then forwards to \cs{wg@@node} to gobble up
% \meta{body}.
%
% \begin{enumerate}
% \item User options
% \item Arguments
% \end{enumerate}
% 
%    \begin{macrocode}
\def\wg@@node[#1]#2\@endwg@node{%
  \wg@dbg{2}{Options: `#1', body: `#2'}%
  \wg@@@node{#1}{#2}%
}
%    \end{macrocode}
% 
% \begin{enumerate}
% \item User options
% \item Arguments
% \item Prefix
% \item Coordinates
% \item Fixed options
% \end{enumerate}
% 
%    \begin{macrocode}
\def\wg@@@node#1#2#3#4#5{%
  \ifx|#2|\wg@dbg{3}{No body given}%
  \else%
    \wg@dbg{3}{^^JWG Pic:
      ^^J  User options:  #1
      ^^J  Body:          #2
      ^^J  Prefix:        #3
      ^^J  Coordinates:   #4
      ^^J  Fixed options: #5}%
    % \wg@dbg{2}{\string\pic[#5,#1] at (#4) {#3#2}}%
    \node[#5,#1] at (#4) {#3#2};%
  \fi%
  \wg@dbg{3}{End of WG Node}
}
%    \end{macrocode}
% \end{Macro}
% 
%
% \begin{Macro}{\wg@node@all}
%
%   This macro sets all pictures in a list.
%   
%   \begin{enumerate}
%   \item List
%   \item Prefix
%   \item Position
%   \item Styles
%   \end{enumerate}
%
%
%    \begin{macrocode}
\def\wg@node@all#1#2#3#4{%
  \wg@dbg{2}{WG picture loop
    ^^J  List:    \meaning#1
    ^^J  Prefix:  `#2'
    ^^J  Position: `#3'
    ^^J  Styles:   `#4'}
  \foreach \p in #1{%
    \wg@dbg{2}{WG picture element: \meaning\p}%
    \expandafter\wg@node\p\@endwg@node {#2}{#3}{#4}%
  }%
}
%    \end{macrocode}
% \end{Macro}
% 
% \iffalse
% --------------------------------------------------------------------
%</utils>
%\fi