% pb-xy.sty: Xypic arrow enhancements for pb-diagram.sty
% Author: Bill Richter <richter@math.nwu.edu>
% Version Number: 5.0
% Version Date: 20 Oct 1998
%
% Copyright (c) 1998 by Bill Richter
%
%	This program is free software; you can redistribute it and/or modify
%	it under the terms of the GNU General Public License as published by
%	the Free Software Foundation; either version 2 of the License, or
%	(at your option) any later version.
%
%	This program is distributed in the hope that it will be useful,
%	but WITHOUT ANY WARRANTY; without even the implied warranty of
%	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%	GNU General Public License for more details.
%
%	You should have received a copy of the GNU General Public License
%	along with this program; if not, write to the Free Software
%	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
%
% This style file should be loaded as follows:
%	\usepackage[cmtip,arrow]{xy}
%	\usepackage{pb-diagram,pb-xy}
%
% This code adds to the "diagram" environment the use of
% Xypic fancy arrow heads and tails, as well as additional arrow
% directions.  Most of the options defined here can be
% combined arbitrarily.
%

\makeatother
\def\PBXYarat{\ar@}%
\makeatletter

\newcount\PBXYxsize
\newcount\PBXYysize

\def\pbxy@tail{{}}%
\def\pbxy@mid{-}%
\def\pbxy@head{>}%

\@namedef{dgo@}{%
   \let\dg@VECTOR=\PBXYvector
   \def\pbxy@tail{{}}\def\pbxy@mid{-}\def\pbxy@head{>}%
   \dg@LBLPOS=\dgARROWPARTS \divide\dg@LBLPOS\tw@}% from pb-diagram.sty

\@namedef{dgo@-}{\def\pbxy@head{{}}}%
\@namedef{dgo@!}{\def\pbxy@mid{{}}\def\pbxy@head{{}}%
	\let\dg@VECTOR=\dg@novector}% from pb-diagram.sty
\@namedef{dgo@..}{\def\pbxy@mid{.}}%
\@namedef{dgo@--}{\def\pbxy@mid{--}}%	
\@namedef{dgo@<>}{\def\pbxy@tail{<}\def\pbxy@head{>}}%
\@namedef{dgo@=}{\def\pbxy@mid{2{-}}\def\pbxy@head{{}}}%
\@namedef{dgo@'}{\def\pbxy@head{^{>}}}%
\@namedef{dgo@`}{\def\pbxy@head{_{>}}}%
\@namedef{dgo@A}{\def\pbxy@head{>>}}%
\@namedef{dgo@V}{\def\pbxy@tail{>}}%
\@namedef{dgo@J}{\def\pbxy@tail{^{(}}}%
\@namedef{dgo@L}{\def\pbxy@tail{_{(}}}%
\@namedef{dgo@S}{\def\pbxy@mid{~}}%
\@namedef{dgo@T}{\def\pbxy@tail{|}}%

\def\PBXYvector(#1,#2)#3{%
   \PBXYxsize#3\relax
   \ifnum#1<\z@\multiply\PBXYxsize\m@ne\fi
   \PBXYysize\PBXYxsize\relax
   \ifnum#1=\z@
      \PBXYxsize\z@
      \ifnum#2<\z@\multiply\PBXYysize\m@ne\fi
   \else
      \multiply\PBXYysize#2\relax\divide\PBXYysize#1\relax
   \fi
   \edef\PBXYarrow{\noexpand\PBXYarat{\pbxy@tail\pbxy@mid\pbxy@head}}%
   \ifnum#1<\z@
      \makebox(\PBXYxsize,\PBXYysize){%
         \begin{xy} 0;<\unitlength,\z@>:%
            \PBXYarrow(\PBXYxsize,\PBXYysize)%
         \end{xy}%
      }%
   \else
      {\begin{xy} <\unitlength,\z@>:%
         \PBXYarrow(\PBXYxsize,\PBXYysize)%
      \end{xy}}%
   \fi
}

\def\dgt@nee{\dg@DX=\tw@ \dg@DY=\@ne \dg@SIZE=\tw@}%
\def\dgt@see{\dg@DX=\tw@ \dg@DY=\m@ne \dg@SIZE=\tw@}%
\def\dgt@nww{\dg@DX=-\tw@ \dg@DY=\@ne \dg@SIZE=\tw@}%
\def\dgt@sww{\dg@DX=-\tw@ \dg@DY=\m@ne \dg@SIZE=\tw@}%
\def\dgt@neee{\dg@DX=\thr@@ \dg@DY=\@ne \dg@SIZE=\thr@@}%
\def\dgt@nnne{\dg@DX=\@ne \dg@DY=\thr@@ \dg@SIZE=\@ne}%
\def\dgt@nnnw{\dg@DX=\m@ne \dg@DY=\thr@@ \dg@SIZE=\@ne}%
\def\dgt@nwww{\dg@DX=-\thr@@ \dg@DY=\@ne \dg@SIZE=\thr@@}%
\def\dgt@swww{\dg@DX=-\thr@@ \dg@DY=\m@ne \dg@SIZE=\thr@@}%
\def\dgt@sssw{\dg@DX=\m@ne \dg@DY=-\thr@@ \dg@SIZE=\@ne}%
\def\dgt@ssse{\dg@DX=\@ne \dg@DY=-\thr@@ \dg@SIZE=\@ne}%
\def\dgt@seee{\dg@DX=\thr@@ \dg@DY=\m@ne \dg@SIZE=\thr@@}%
\def\dgt@nneee{\dg@DX=\thr@@ \dg@DY=\tw@ \dg@SIZE=\thr@@}%
\def\dgt@nnnee{\dg@DX=\tw@ \dg@DY=\thr@@ \dg@SIZE=\tw@}%
\def\dgt@nnnww{\dg@DX=-\tw@ \dg@DY=\thr@@ \dg@SIZE=\tw@}%
\def\dgt@nnwww{\dg@DX=-\thr@@ \dg@DY=\tw@ \dg@SIZE=\thr@@}%
\def\dgt@sswww{\dg@DX=-\thr@@ \dg@DY=-\tw@ \dg@SIZE=\thr@@}%
\def\dgt@sssww{\dg@DX=-\tw@ \dg@DY=-\thr@@ \dg@SIZE=\tw@}%
\def\dgt@sssee{\dg@DX=\tw@ \dg@DY=-\thr@@ \dg@SIZE=\tw@}%
\def\dgt@sseee{\dg@DX=\thr@@ \dg@DY=-\tw@ \dg@SIZE=\thr@@}%

% approximate aspect ratio by half-integer betw 1/2 and 4
%
\def\dggeometry{
   \dg@ZTEMP=\dg@XGRID \multiply\dg@ZTEMP\tw@
   \ifnum\dg@YGRID=\z@ \dg@ZTEMP=\tw@
   \else \divide\dg@ZTEMP\dg@YGRID \fi
   \ifnum\dg@ZTEMP>8\relax \dg@ZTEMP=8\relax \fi
   \ifnum\dg@ZTEMP<\@ne \dg@ZTEMP=\@ne \fi
   \unitlength=1sp\relax
   \ifnum\dg@ZTEMP<\tw@
      % round aspect ratio up toward 2:2, widen rect
      \advance\dg@ZTEMP\@ne
      \multiply\unitlength\dg@YGRID
      \dg@XGRID=\dg@ZTEMP \dg@YGRID=\tw@
      \dg@rmcommondiv\tw@\dg@XGRID\dg@YGRID
      \divide\unitlength\dg@YGRID
   \else
      % round aspect ratio down toward 2:2, tallen rect
      \multiply\unitlength\dg@XGRID
      \dg@XGRID=\dg@ZTEMP \dg@YGRID=\tw@
      \dg@rmcommondiv\tw@\dg@XGRID\dg@YGRID
      \divide\unitlength\dg@XGRID
   \fi
   \divide\unitlength\@m\relax}%

