%	grafix.tex
%		defines QDRIVE \grafix and \grafixnobox macros
%		to embed filename etc. into
%		output .DVI file in a form that QDRIVE understands
%		Copied from Talaris 'Appendix B' in QDRIVE documentation.
%		modified for Belonis' QPOST postprocessor
%		puts SPECIALGOESHERE and 5 parameters each terminated with
%		comma at upper left corner of outline box
%
%	Note: this does not use \centerline to center the box,
%		so it is easy to position non-centered if desired.
%
%  calling sequence
%	\grafix vertical_size,horizontal_size,overlay_type,{file-spec},page
%	\grafixnobox  (plot included without surrounding box)
%  example of use:
%	\grafix 2in,4in,vector,{overlay.qms},1
%	reserves 2inch vertical by 4inch horizontal area for vector plot
%	from page 1 of file OVERLAY.QMS
%  note:
%	inches, points, centimeters are the only supported dimensions
%	page number is currently ignored (always uses 1st page of plot file)
%
%   3-NOV-1985 Belonis modified to properly handle \magnification.
%       Coincidentally removed restriction on dimensions since all translated
%	to points (but for documentation reasons, may test for \mag=1000
%	and not do math so dimension restriction may return).
%
%
\def\grafix#1,#2,#3,#4,#5{\vbadness 10000
    \setbox1\vbox{\vbox to #1{\hbox to #2{}} % create empty box of right size
                          \vbadness 1000} %
    \special{*#3,#4,#5} % A marker for QDRIVE to find in .DVI file
% box and put rules around it
     \vbox{\hrule
            \hbox{\vrule\hskip 1pt %
                        \vbox{\vskip 1pt %
% insert the string for the QPOST processor to find, but make it zero size
% so TeX doesn't get confused about position.  Typewriter so no ligatures.
\dimen0=#1 \divide\dimen0 by 1000 \multiply\dimen0 by \mag % pass magnified size
\dimen2=#2 \divide\dimen2 by 1000 \multiply\dimen2 by \mag %
\vbox to 0pt{\rlap{ %
    \tt SPECIALGOESHERE\the\dimen0,\the\dimen2,#3,#4,#5,}\vss}% zero size marker
                              \box1 % insert the empty box
                              \vskip 1pt} %
                        \hskip 1pt %
                   \vrule}
            \hrule}}
%
\def\grafixnobox#1,#2,#3,#4,#5{\vbadness 10000
    \setbox1\vbox{\vbox to #1{\hbox to #2{}} % create empty box of right size
                          \vbadness 1000} %
    \special{*#3,#4,#5} % A marker for QDRIVE to find in .DVI file
% box and DON'T put rules around it
     \vbox{
            \hbox{\hskip 1pt %
                        \vbox{\vskip 1pt %
% insert the string for the QPOST processor to find, but make it zero size
% so TeX doesn't get confused about position.
\dimen0=#1 \divide\dimen0 by 1000 \multiply\dimen0 by \mag % pass magnified size
\dimen2=#2 \divide\dimen2 by 1000 \multiply\dimen2 by \mag %
\vbox to 0pt{\rlap{ %
    \tt SPECIALGOESHERE\the\dimen0,\the\dimen2,#3,#4,#5,}\vss}% zero size marker
                              \box1 % insert the empty box
                              \vskip 1pt} %
                        \hskip 1pt %
                   }
            }}
