\typeout{%
pspictpg v0.5 Jan. 27, 1999}
%%----------------------------------------------------------------------
%%
%% Macros for using PostScript under the picture environment of latex.
%% Designed to work with dvips.
%%
%% Redefinition of the macros \line, \vector, \circle and \circle* of latex.
%% Contrary to the original macros, there are no restrictions on the value
%% of the arguments.
%%
%% Definition of new macros :
%% \setpsgray, \setpsdash
%% \drawline, \drawvector, \drawcircle, \drawdisk
%% \cbezier, \cbeziervector, \qbezier, \qbeziervector
%%
%% Definition of internal macros for gastex:
%% \r@cbezier, \r@qbezier, \r@loop.
%%
%% All macros use 
%% - the line width defined by the latex commands \thinline,
%%   \thickline or \linethickness
%% - the gray scale defined with \setpsgray (0=black, 1=white)
%% - colors with the color package
%% - the dash pattern defined with \setpsdash
%%
%% WARNING: If this package is to be used with the color package,
%% then the color package has to be loaded first, e.g.
%% \usepackage[usenames]{color}
%% \usepackage{pspictpg,gastex}
%%
%% Paul Gastin
%% LIAFA
%% Universite Paris 7
%% 2, place Jussieu
%% F-75251 Paris Cedex 05
%% email : Paul.Gastin@liafa.jussieu.fr
%% www : http://www.liafa.jussieu.fr/~gastin
%%
%%----------------------------------------------------------------------

\special{header=pspictpg.pro}

%% Set the dash pattern used for drawing postscript paths.
%% #2 is a sequence of distances (in pt) along the path which alternatively 
%% indicates lengths of drawing and of non-drawing.
%% The sequence of distances  is used circularly.
%% Optionally, the parameter #1 allow to start the pattern at some distance 
%% from its beginning
%% ex : \setpsdash() % continuous path
%%      \setpsdash(3) % dashs of length 3 and empty spaces of length 3
%%      \setpsdash(1 3) % looks like a sequence of dots
%%      \setpsdash(12 3 3 3) % alternation of long and short dashs
%%      \setpsdash[12](12) % we start with the empty space and not the dash
%%      \setpsdash[6](12) % we start in the middle of the first dash
\def\setpsdash{\@ifnextchar[{\i@setpsdash}{\i@setpsdash[0]}}
\def\i@setpsdash[#1](#2){\def\ps@dash{[#2] #1\space}}
\setpsdash() % continuous path

% The macros \color and \textcolor do not work properly under the picture 
% environment of latex. We need to define special versions of these macros 
% until the problem is fixed.
\@ifundefined{color}{}{
  \def\pcolor{\@killglue\color} % Does not work completely
  \def\pictcolor#1#2{\@killglue\textcolor{#1}{#2\@killglue}}}

% If we do not use the color package, we can still use gray scales.
\def\setpsgray#1{\def\ps@gray{#1\space}}
\setpsgray{0}

{\catcode`t=12\catcode`p=12\gdef\no@PT#1pt{#1}}
\def\strip@PT#1{\expandafter\no@PT\the#1\space}

\newdimen\dim@x \newdimen\dim@y

\def\init@ps{!BP
  \ps@dash setdash
  \@ifundefined{color}{\ps@gray setgray}{\current@color\space}
  \strip@PT\@wholewidth setlinewidth 
}

% Redefinition of latex \line(a,b){L}.
% Can be used with any values for a and b.
\def\line(#1,#2)#3{{%
  \@xarg #1\relax \@yarg #2\relax
  \dim@x=#3\unitlength
  \special{" \init@ps
    \the\@xarg\space \the\@yarg\space \strip@PT\dim@x !pslatexline}
}}

% Redefinition of latex \vector(a,b){L}.
% Can be used with any values for a and b.
\def\vector(#1,#2)#3{{%
  \@xarg #1\relax \@yarg #2\relax
  \dim@x=#3\unitlength
  \special{" \init@ps 
    \strip@PT\@wholewidth !setheadlength 
    \the\@xarg\space \the\@yarg\space \strip@PT\dim@x !pslatexvector}
}}

% redefinition of \circle of LaTeX 
% can be used with any diameter
\def\circle{\@ifnextchar*{\@idisk}{\@icircle}}
\def\@icircle#1{{%
  \dim@x=#1\unitlength
  \special{" \init@ps 
    \strip@PT\dim@x !pscircle}
}}
\def\@idisk*#1{{%
  \dim@x=#1\unitlength
  \special{" \init@ps 
    \strip@PT\dim@x !psdisk}
}}

%% \drawline:
%%     Line from (#1,#2) to (#3,#4). 
%%     Use current linewidth, psgray and psdash. 
%% ex: \drawline(10,70)(70,20)
%%
\def\drawline(#1,#2)(#3,#4){{%
  \dim@x=#3\unitlength \advance\dim@x by -#1\unitlength
  \dim@y=#4\unitlength \advance\dim@y by -#2\unitlength
  \put(#1,#2){\special{" \init@ps 
    \strip@PT\dim@x \strip@PT\dim@y !psline}}
}}

%% \drawvector:
%%     Vector from (#1,#2) to (#3,#4). 
%%     Use current linewidth, psgray and psdash. 
%% ex: \drawvector(10,70)(70,20)
%%
\def\drawvector(#1,#2)(#3,#4){{%
  \dim@x=#3\unitlength \advance\dim@x by -#1\unitlength
  \dim@y=#4\unitlength \advance\dim@y by -#2\unitlength
  \put(#1,#2){\special{" \init@ps 
    \strip@PT\@wholewidth !setheadlength 
    \strip@PT\dim@x \strip@PT\dim@y !psvect}}
}}

% circle centered in (#1,#2) with diameter #3
\def\drawcircle(#1,#2)(#3){{%
  \dim@x=#3\unitlength
  \put(#1,#2){\special{" \init@ps 
    \strip@PT\dim@x !pscircle}}
}}

% disk centered in (#1,#2) with diameter #3 filled accordingly to setpsgray
\def\drawdisk(#1,#2)(#3){{%
  \dim@x=#3\unitlength
  \put(#1,#2){\special{" \init@ps 
    \strip@PT\dim@x !psdisk}}
}}


%% \cbezier:
%%     Cubic B�zier curve.
\def\cbezier(#1,#2)(#3,#4)(#5,#6)(#7,#8){{%
  \dim@x=#1\unitlength \edef\@csxa{\strip@PT\dim@x}
  \dim@x=#2\unitlength \edef\@csya{\strip@PT\dim@x}
  \dim@x=#3\unitlength \edef\@csxb{\strip@PT\dim@x}
  \dim@x=#4\unitlength \edef\@csyb{\strip@PT\dim@x}
  \dim@x=#5\unitlength \edef\@csxc{\strip@PT\dim@x}
  \dim@x=#6\unitlength \edef\@csyc{\strip@PT\dim@x}
  \dim@x=#7\unitlength \edef\@csxd{\strip@PT\dim@x}
  \dim@x=#8\unitlength \edef\@csyd{\strip@PT\dim@x}
  \put(0,0){\special{" \init@ps 
    false % no arrowhead
    \@csxa \@csya \@csxb \@csyb \@csxc \@csyc \@csxd \@csyd !pscbezier
  }}
}}

%% \cbeziervector:
%%     Cubic B�zier vector.
\def\cbeziervector(#1,#2)(#3,#4)(#5,#6)(#7,#8){{%
  \dim@x=#1\unitlength \edef\@csxa{\strip@PT\dim@x}
  \dim@x=#2\unitlength \edef\@csya{\strip@PT\dim@x}
  \dim@x=#3\unitlength \edef\@csxb{\strip@PT\dim@x}
  \dim@x=#4\unitlength \edef\@csyb{\strip@PT\dim@x}
  \dim@x=#5\unitlength \edef\@csxc{\strip@PT\dim@x}
  \dim@x=#6\unitlength \edef\@csyc{\strip@PT\dim@x}
  \dim@x=#7\unitlength \edef\@csxd{\strip@PT\dim@x}
  \dim@x=#8\unitlength \edef\@csyd{\strip@PT\dim@x}
  \put(0,0){\special{" \init@ps 
    \strip@PT\@wholewidth !setheadlength 
    true % arrowhead requested
    \@csxa \@csya \@csxb \@csyb \@csxc \@csyc \@csxd \@csyd !pscbezier
  }}
}}

%% \qbezier:
%%     Quadratic B�zier curve.
\def\qbezier(#1,#2)(#3,#4)(#5,#6){{%
  \dim@x=#1\unitlength \edef\@csxa{\strip@PT\dim@x}
  \dim@x=#2\unitlength \edef\@csya{\strip@PT\dim@x}
  \dim@x=#3\unitlength \edef\@csxb{\strip@PT\dim@x}
  \dim@x=#4\unitlength \edef\@csyb{\strip@PT\dim@x}
  \dim@x=#5\unitlength \edef\@csxc{\strip@PT\dim@x}
  \dim@x=#6\unitlength \edef\@csyc{\strip@PT\dim@x}
  \put(0,0){\special{" \init@ps 
    false % no arrowhead
    \@csxa \@csya \@csxb \@csyb \@csxc \@csyc !psqbezier
  }}
}}

%% \qbeziervector:
%%     Quadratic B�zier vector.
\def\qbeziervector(#1,#2)(#3,#4)(#5,#6){{%
  \dim@x=#1\unitlength \edef\@csxa{\strip@PT\dim@x}
  \dim@x=#2\unitlength \edef\@csya{\strip@PT\dim@x}
  \dim@x=#3\unitlength \edef\@csxb{\strip@PT\dim@x}
  \dim@x=#4\unitlength \edef\@csyb{\strip@PT\dim@x}
  \dim@x=#5\unitlength \edef\@csxc{\strip@PT\dim@x}
  \dim@x=#6\unitlength \edef\@csyc{\strip@PT\dim@x}
  \put(0,0){\special{" \init@ps 
    \strip@PT\@wholewidth !setheadlength 
    true % arrowhead requested
    \@csxa \@csya \@csxb \@csyb \@csxc \@csyc !psqbezier
  }}
}}

%%----------------------------------------------------------------------
%%
%% The following macros are specific for gastex.

%% Restricted cubic B�zier curve.
%%
%% The actual parameter list for \r@cbezier must be of the form
%% (#1,#2,#3)(#4,#5)(#6,#7)(#8,#9,#10).
%%
%% (#1,#2), (#4,#5), (#6,#7), (#8,#9) are the control points of the
%% B�zier curve. The curve is only drawn outside the disks of
%% diameter #3 and #10 centered on (#1,#2) and (#8,#9).
%%
%% If \@arrowtrue, an arrowhead is added to the curve.
%%
%% Since TeX only allows 9 parameters, we have to split the command in 2.

\def\r@cbezier(#1,#2,#3)(#4,#5)(#6,#7){%
  \dim@x=#1\unitlength \edef\@csxa{\strip@PT\dim@x}
  \dim@x=#2\unitlength \edef\@csya{\strip@PT\dim@x}
  \dim@x=#3\unitlength \edef\@csdiama{\strip@PT\dim@x}
  \dim@x=#4\unitlength \edef\@csxb{\strip@PT\dim@x}
  \dim@x=#5\unitlength \edef\@csyb{\strip@PT\dim@x}
  \dim@x=#6\unitlength \edef\@csxc{\strip@PT\dim@x}
  \dim@x=#7\unitlength \edef\@csyc{\strip@PT\dim@x}
  \r@cbeziertwo
}
\def\r@cbeziertwo(#1,#2,#3){%
  \dim@x=#1\unitlength \edef\@csxd{\strip@PT\dim@x}
  \dim@x=#2\unitlength \edef\@csyd{\strip@PT\dim@x}
  \dim@x=#3\unitlength \edef\@csdiamd{\strip@PT\dim@x}
  \put(0,0){\special{" \init@ps 
    \if@arrow
      \strip@PT\@wholewidth !setheadlength 
      true
    \else
      false
    \fi
    \@csdiama 2 div \@csdiamd 2 div
    \@csxa \@csya \@csxb \@csyb \@csxc \@csyc  \@csxd \@csyd !ps_r_cbezier
  }}
}

%% Restricted quadratic B�zier curve.
%%
%% (#1,#2), (#4,#5), (#6,#7) are the control points of the B�zier curve.
%% The curve is only drawn outside the disks of diameter #3 and #8
%% centered on (#1,#2) and (#6,#7).
%%
%% If \@arrowtrue, an arrowhead is added to the curve.

\def\r@qbezier(#1,#2,#3)(#4,#5)(#6,#7,#8){{%
  \dim@x=#1\unitlength \edef\@csxa{\strip@PT\dim@x}
  \dim@x=#2\unitlength \edef\@csya{\strip@PT\dim@x}
  \dim@x=#3\unitlength \edef\@csdiama{\strip@PT\dim@x}
  \dim@x=#4\unitlength \edef\@csxb{\strip@PT\dim@x}
  \dim@x=#5\unitlength \edef\@csyb{\strip@PT\dim@x}
  \dim@x=#6\unitlength \edef\@csxc{\strip@PT\dim@x}
  \dim@x=#7\unitlength \edef\@csyc{\strip@PT\dim@x}
  \dim@x=#8\unitlength \edef\@csdiamc{\strip@PT\dim@x}
  \put(0,0){\special{" \init@ps 
    \if@arrow
      \strip@PT\@wholewidth !setheadlength 
      true
    \else
      false
    \fi
    \@csdiama 2 div \@csdiamc 2 div
    \@csxa \@csya \@csxb \@csyb \@csxc \@csyc !ps_r_qbezier
  }}
}}

%% Restricted cubic Bezier loop.
%%
%% Draw a loop outside the disk of diameter #5 centered on (#3,#4).
%% #2 is the diameter of the loop.
%% #1 is the angle in degree defining direction of the loop.
%%
%% If \@arrowtrue, an arrowhead is added to the curve.

\def\r@loop(#1,#2)(#3,#4,#5){{%
  \dim@x=#3\d@my@unit \edef\@csxa{\strip@PT\dim@x}
  \dim@x=#4\d@my@unit \edef\@csya{\strip@PT\dim@x}
  \dim@x=#5\d@my@unit \edef\@csdiama{\strip@PT\dim@x}
  \dim@x=#2\d@my@unit \edef\@csdiaml{\strip@PT\dim@x}
  \put(0,0){\special{" \init@ps 
    \if@arrow
      \strip@PT\@wholewidth !setheadlength 
      true
    \else
      false
    \fi
    #1 \@csdiaml 2 div \@csdiama 2 div \@csxa \@csya !ps_r_loop
  }}
}}

\endinput
