%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%                                                                     %%%%
%%%%                        P  S  M  A  C                                %%%%
%%%%                                                                     %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Revision of macros prepared by Glenn Gribble  (7/14/86).            %%%%
% 2/23/90 make compatible with NeXT Radical Eye dvips3.6
% 12/15/89.1 prepare for general usage
% 1/5/89 make "[" other catcode for [begin/end]
% 12/28/88 remove arg to SPE/SPB
% 11/20/88 2. another attempt to resolve citMAT diagnostic, true begin/end;
%     use arg w/ SPE/SPB
% 12/2/87.1 10/28/87.1 use new version of dvips


\catcode`\@=11 % make @ a letter for internal macros
%
%
% These are special macros that allow for rotation and scaling.  
% Warning:  As of 7-14-86, there is a bug in the DVIPS software that
%           causes characters to come out VERY big when these macros
%           are used.  To fix this problem, replace \psRotSave with
%           \hskip1pt\psRotSave\hskip-1pt.
%
{\catcode`\[=12 \gdef\psRotSave{\special{ps::[begin]
   /citMAT matrix currentmatrix def }}
 \gdef\psRotUnSave{\special{ps::[end] }}}
\def\psRotate#1{\special{ps: currentpoint neg exch neg exch currentpoint
translate #1 neg rotate translate }}% negated the angle with Radical Eye dvips
\def\psUnRotate{\special{ps: citMAT setmatrix }}
\def\psScale#1{\special{ps: #1 #1 scale }}
\def\psScalexy#1#2{\special{ps: #1 #2 scale }}
%
%
% Allocate a few registers for later stuff.
%
\newdimen\xsc@le \newdimen\ysc@le
\newdimen\xs@ze  \newdimen\ys@ze
\newdimen\x@ff   \newdimen\y@ff
\newread\UNTILfile  % channel for testing existence of .ps and .lbl files
\newif\ifTEXLBL \TEXLBLtrue % true if the .lbl file should be read

\newif\ifUfil@  % true if file was successfully opened
% #1=file name;  test file availability,  true if available
\def\Ufil@#1{\openin\UNTILfile=#1 \ifeof\UNTILfile\Ufil@false\else\Ufil@true\fi
  \closein\UNTILfile}
\def\pspic@ #1 #2 #3\,{\xs@ze=#1\ys@ze=#2\Ufil@{#3.ps}%
  \vbox to \ys@ze{\offinterlineskip 
    \hbox to\xs@ze{\hfill
      \ifUfil@\special{ps: currentpoint /GPOSY exch def /GPOSX exch def}%
      \else\message{File: #3.ps Not Found.}\fi}
    \vfill % reference point above=max(x,y); below=min(x,y)
    \ifUfil@
      \hbox to \xs@ze{\special{ps: plotfile ./until.pro}%
                      \special{ps: plotfile #3.ps }%
        \ifTEXLBL \Ufil@{#3.lbl}%
          \ifUfil@ \input#3.lbl \psRotUnSave
          \else \message{File: #3.lbl Not Found.}\fi
        \fi\hfill}
    \fi}}

\def\pspic#1{\pspic@ #1\,}

\def\FIGSIZE#1#2{\xsc@le=\xs@ze\divide\xsc@le by #1
   \ysc@le=\ys@ze\divide\ysc@le by #2
   \ifdim\ysc@le>\xsc@le \ysc@le=\xsc@le \else\xsc@le=\ysc@le\fi
   \x@ff=\xsc@le \multiply\x@ff by#1\advance\x@ff by -\xs@ze
   \y@ff=\ysc@le \multiply\y@ff by#2\advance\y@ff by -\ys@ze
   \divide\x@ff by -2
   \divide\y@ff by -2
   \psRotSave
   }

%   \message{ Yscale=\the\ysc@le Xscale=\the\xsc@le}%
%   \message{ Yoff=\the\y@ff Xoff=\the\x@ff}%
%   \message{ Yoff=\the\y@ff Xoff=\the\x@ff}%
% xoff := (xsize - (#1*xscale) ) / 2;
% yoff := (ysize - (#1*yscale) ) / 2;
% \message{ Yscale=\the\ysc@le Xscale=\the\xsc@le}%

%
% LBL macro parameters:
%   #5=x position, #6=y position
%   #7=tex string, #8=rotation (counterclockwise degrees)
%   #1=\hss on left #2=\hss on right
%   #3=\vss on top  #4=\vss on bottom
%
%\def\LBL#1#2#3#4#5#6#7#8{\vbox to0pt{\vskip-\y@ff\vskip-#6\ysc@le\ifnum#3=1\vss\fi%
%\hbox to0pt{\hskip\x@ff\hskip#5\xsc@le\hbox to 0pt{\ifnum#1=1\hss\fi#7\ifnum#2=1\hss\fi}%
%\hskip-#5\xsc@le\hskip-\x@ff}\ifnum#4=1\vss\fi\vskip#6\ysc@le\vskip\y@ff}}

\def\LBL#1#2#3#4#5#6#7#8{\vbox to0pt{\vskip-\y@ff\vskip-#6\ysc@le
   \hbox to0pt{\hskip\x@ff\hskip#5\xsc@le
      \psRotate{#8}%
         \vbox to0pt{\ifnum#3=1 \vss\fi
            \setbox0=\hbox to0pt{\ifnum#1=1 \hss\fi#7\ifnum#2=1\hss\fi}
            \dp0=0pt\box0
            \ifnum#4=1 \vss\fi}%
%      \hskip1pt\psUnRotate\hskip-1pt
      \psUnRotate
      \hskip-#5\xsc@le\hskip-\x@ff}
\vskip#6\ysc@le\vskip\y@ff}}%

\def\TUL{\LBL0101}\def\TUC{\LBL1101}\def\TUR{\LBL1001}
\def\TCL{\LBL0111}\def\TCC{\LBL1111}\def\TCR{\LBL1011}
\def\TLL{\LBL0110}\def\TLC{\LBL1110}\def\TLR{\LBL1010}

\catcode`\@=12 % @ is no longer a letter

% End /DOCUMENT/TEX/PSMAC.TEXT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
