% Read in by FEYNMANDOC:  FEYNMANDOC4D.  Called by FD4D.COM
%\chapter{Advanced Features con't Storing Pictures}
%
%\subsection{Phantom Commands}
\subsubsection{Storing Lines}

Why would one wish to store a single particle line?  It might
be that diagram has the same line repeated over and over commencing
from different starting points.  The user may simply like a particular
line style and length and want to always use it (for instance an \bs E
\bs FLIPPEDFLAT gluon five loops in length).
To store a line under the name \verb@<line name>@ the basic command is:
\begin{verbatim}
\drawandsaveline `<line name>' as <the same arguments as \drawline>
\end{verbatim}
Note the `...' around the name (which must commence with a backslash).  
As an example one could have
\begin{verbatim}
\drawandsaveline `\cutephoton' as \photon[\S\LONGPHOTON](-2000,500)[7]
\end{verbatim}
which would draw a photon as if
\begin{verbatim}
\drawline\photon[\S\LONGPHOTON](-2000,500)[7]
\end{verbatim}
had appeared but save it under the name \bs cutephoton.

To utilize the saved line one enters
\begin{verbatim}
\drawoldpic<line name>(x,y)
\end{verbatim}
where (x,y) is the co-ordinate to draw the line from.  For example
\begin{verbatim}
\drawandsaveline `\cutephoton' as \photon[\S\LONGPHOTON](-2000,500)[7]
\drawline\fermion[\E\REG](\pbackx,\pbacky)[6500]
\drawoldpic\cutephoton(1500,\pbacky)
\drawoldpic\cutephoton(2500,\pbacky)
\drawoldpic\cutephoton(3500,\pbacky)
\end{verbatim}
\bs drawoldpic re-assigns the values of \bs pfrontx,y; \bs pmidx,y and
\bs pbackx,y but does {\bf not} alter any other existing 
paramenters such as \bs plengthx, \bs gluonbacky or \bs photoncount.
(\bs pfrontx,\bs pfronty) are assigned the (x,y) values and 
(\bs pbackx,\bs pbacky) are incremented by the {\it current} values of
\bs plengthx and \bs plengthy.
Subsequent usage of \bs drawoldpic costs no additional internal \TeX\ memory
resources.  The above example would draw:

\begin{picture}(12000,18000)
\drawandsaveline `\cutephoton' as \photon[\S\LONGPHOTON](0,18000)[7]
\drawline\fermion[\E\REG](\pbackx,\pbacky)[6500]
\drawoldpic\cutephoton(1500,\pbacky)
\drawoldpic\cutephoton(2500,\pbacky)
\drawoldpic\cutephoton(3500,\pbacky)
\end{picture}
\vskip -0.1in
The storage space for \bs cutephoton will be reclaimed following the
\verb@\end{picture}@ statement.  Two other features exist to draw lines.
At any time, while in picture mode, the last line drawn via the
\ddrawline\ command is stored under the name `\bs lastline' and may
be freely used.  \bs lastline is replaced when \ddrawline\ is
next encountered.  Note that you may never use the same name twice
when storing a line.
To illustrate the use of \bs lastline, a portion of the previous example could
be produced using:
\begin{verbatim}
\drawline\fermion[\E\REG](0,16000)[6500]
\drawline\photon[\S\LONGPHOTON](1500,\pbacky)[7]
\drawoldpic\lastline(2500,\pfronty)
\drawoldpic\lastline(3500,\pfronty)
\end{verbatim}
to wit

\begin{picture}(12000,14000)
\drawline\fermion[\E\REG](0,12000)[6500]
\drawline\photon[\S\LONGPHOTON](1500,\pbacky)[7]
\drawoldpic\lastline(2500,\pfronty)
\drawoldpic\lastline(3500,\pfronty)
\end{picture}

One may also store a line {\it after} it has been drawn by using the
\bs {\it saveas} command.
The statements:
\begin{verbatim}
\drawline\photon[\S\LONGPHOTON](0,18000)[7]
\saveas `\cutephoton'
\end{verbatim}
would be equivalent to the statement
\begin{verbatim}
\drawandsaveline `\cutephoton' as \photon[\S\LONGPHOTON](0,18000)[7]
\end{verbatim}
The latter statement is superior, however, since \bs saveas actually
re-draws the line (in a phantom mode) and thus uses twice as much of
\TeX's resources.  Thus \bs saveas should be avoided and has been 
mentioned merely for completeness.  Since it saves the last line drawn
it is most useful when used subsequent to a \ddrawvertex\ statement.

\subsubsection{Storing Pictures}

It frequently happens that a picture, or part of a picture,
needs to replicated.  In many instances it is only the labels which
need to be changed.  The general \LaTeX\ command for saving objects is
\begin{verbatim}

\savebox{<box name>}(<box width>,<box height>)[<position>]{<object>}

\end{verbatim}
This saves the `object' in a `box' but does not draw it directly.
To draw it the \bs drawoldpic command may again be used as shown below.
The box name must begin with a backslash (\bs).  The width and height
will be in centipoints.  The ``position'' argument is optional
and may be ignored.  If so the picture will be centred in the box.
Other options are {\tt [tr] [br] [tl] [bl]} which will position the
picture in a corner of the named box, and {\tt [t] [b] [l] [r]}
which will place the picture along a side.   The `object' in this case
is a picture commencing with \verb@\begin{picture}@ and terminating
with \verb@\end{picture}@.  Just as variable names must be 
initialized so must box names.  Prior to the \bs savebox a command
\verb@\global\newsavebox<name>@ must appear and this name must not be used 
again.  The saved picture takes the form:
\newpage
\begin{verbatim}
\global\newsavebox{\Brehmsstrahlung}
      .
      .
      .
\savebox{\Brehmsstrahlung}(10000,14000)[tl]{
\begin{picture}(10000,140000)(2000,3000)
      .
      .
      .
\end{picture}
}  % end of \savebox
      .
      .
      .
\begin{picture}(18000,22000)
...(various Feynman commands)
\drawoldpic\Brehmsstrahlung(\pbackx,\pbacky)
\global\advance\pbackx by 2000
\drawoldpic\Brehmsstrahlung(\pbackx,\pbacky)
\global\advance\pbackx by 2000
\drawoldpic\Brehmsstrahlung(\pbackx,\pbacky)
...(various Feynman commands)
\end{picture}

\end{verbatim}
with further possible uses in other diagrams.  Of course the picture could
be merely stored and directly used as an entire diagram.
\LaTeX\ keeps the stored box around thereafter occupying valuable
storage space.  Thus when one is done with the stored picture the command
\begin{verbatim}
\sbox{\Brehmsstrahlung}{}
\end{verbatim}
will clear the space.  The box will continue to exist and new objects
may be stored in it without a further \bs newsavebox statement.
One is cautioned that positioning the old picture within a new picture
may require some experimentation since the box sizes may not match.
The other caution is that \TeX's resources tend to become
exhausted with a bewildering rapidity which limits the size
of stored pictures.
The following is a simple example.
\begin{verbatim}

\global\newsavebox{\ESHOWER}
\savebox{\ESHOWER}(0,0)[tl]{
\begin{picture}(0,0)
\drawline\photon[\SE\REG](0,0)[8]
\drawline\fermion[\E\REG](\photonbackx,\photonbacky)[2000]
\drawline\fermion[\S\REG](\photonbackx,\photonbacky)[2000]
\end{picture}
}   % end savebox
\begin{picture}(15000,5000)
\drawline\fermion[\E\REG](0,5000)[15000]
\drawoldpic\ESHOWER(0,5000)
\drawoldpic\ESHOWER(5000,5000)
\drawoldpic\ESHOWER(10000,5000)
\end{picture}
\sbox{\ESHOWER}{}

\end{verbatim}
producing
\vskip 0.1in
\global\newsavebox{\ESHOWER}
\savebox{\ESHOWER}(0,0)[tl]{
\begin{picture}(0,0)
\drawline\photon[\SE\REG](0,0)[8]
\drawline\fermion[\E\REG](\photonbackx,\photonbacky)[2000]
\drawline\fermion[\S\REG](\photonbackx,\photonbacky)[2000]
\end{picture}
}   % end savebox
\begin{picture}(15000,5000)
\drawline\fermion[\E\REG](0,5000)[15000]
\drawoldpic\ESHOWER(0,5000)
\drawoldpic\ESHOWER(5000,5000)
\drawoldpic\ESHOWER(10000,5000)
\end{picture}
\sbox{\ESHOWER}{}

\vskip 0.4in
Note the \bs sbox used to empty the box.  
Also note the trick of storing a box of zero dimension.
This greatly simplifies the positioning of stored diagram.
One might expect that
the gluon branches (together with labelling) in
the cover diagram were generated this way.  Alas there was insufficient
memory to store them (gluon vertices are particularly expensive)
and they were drawn by duplicating the statements.  This saved storage
space at the expense of CPU.
One may also store boxes within boxes.  Thus the entire three-photon
diagram above could have been stored and re-used.  Indeed this is
the basic technique used in constructing lines and vertices.
