% Copyright 2006 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/systemlayer/pgfsyssoftpath.code.tex,v 1.4 2006/10/16 22:32:59 tantau Exp $


% This package provides the pgf system path abstraction layer. This
% layer is used to construct paths first ``abstractly.'' These
% abstract paths can still be modified, before they are ``made
% concrete.'' 
%
% An abstract path consists of a sequence of basic building blocks,
% each of which is a tuple consisting of two numbers (specifying a
% coordinate) and a token. Possible tokens are:
%
% 1. moveto
% 2. lineto
% 3. rectcorner
% 4. rectsize
% 5. curvetosupporta
% 6. curvetosupportb
% 7. curveto
% 8. closepath
% 9. specialround
%
% A curveto must always be preceeded by a curvetosupporta and a
% curvetosupportb. A non-empty path must always begin with a
% moveto. The coordinates of a closepath are non-specified, currently, 
% but they might be set to the coordinate of the path segment start,
% in the future.



\let\pgfsyssoftpath@currentpath=\pgfutil@empty
% The current path

\def\pgfsyssoftpath@lastmoveto{{0pt}{0pt}}

% Add a moveto element to the current path
\def\pgfsyssoftpath@moveto#1#2{%
  \edef\pgfsyssoftpath@temp{{%
    \noexpand\pgfsyssoftpath@movetotoken{#1}{#2}%
  }}%
  \expandafter\pgfutil@g@addto@macro\expandafter\pgfsyssoftpath@currentpath\pgfsyssoftpath@temp%
  \xdef\pgfsyssoftpath@lastmoveto{{#1}{#2}}%
}

% Add a lineto element to the current path
\def\pgfsyssoftpath@lineto#1#2{%
  \edef\pgfsyssoftpath@temp{{%
    \noexpand\pgfsyssoftpath@linetotoken{#1}{#2}%
  }}%
 \expandafter\pgfutil@g@addto@macro\expandafter\pgfsyssoftpath@currentpath\pgfsyssoftpath@temp%
}

% Add curveto elements to the current path
\def\pgfsyssoftpath@curveto#1#2#3#4#5#6{%
  \edef\pgfsyssoftpath@temp{{%
    \noexpand\pgfsyssoftpath@curvetosupportatoken{#1}{#2}%
    \noexpand\pgfsyssoftpath@curvetosupportbtoken{#3}{#4}%
    \noexpand\pgfsyssoftpath@curvetotoken{#5}{#6}%
  }}%
 \expandafter\pgfutil@g@addto@macro\expandafter\pgfsyssoftpath@currentpath\pgfsyssoftpath@temp%
}

% Add rectanlge elements to the current path
\def\pgfsyssoftpath@rect#1#2#3#4{%
  \edef\pgfsyssoftpath@temp{{%
    \noexpand\pgfsyssoftpath@rectcornertoken{#1}{#2}%
    \noexpand\pgfsyssoftpath@rectsizetoken{#3}{#4}%
  }}%
 \expandafter\pgfutil@g@addto@macro\expandafter\pgfsyssoftpath@currentpath\pgfsyssoftpath@temp%
}

% Add closepath element to the current path
\def\pgfsyssoftpath@closepath{%
  \edef\pgfsyssoftpath@temp{{%
    \noexpand\pgfsyssoftpath@closepathtoken\pgfsyssoftpath@lastmoveto%
  }}%
  \expandafter\pgfutil@g@addto@macro\expandafter\pgfsyssoftpath@currentpath\pgfsyssoftpath@temp%
}

% Add special element to the current path
\def\pgfsyssoftpath@specialround#1#2{%
  \edef\pgfsyssoftpath@temp{{%
    \noexpand\pgfsyssoftpath@specialroundtoken{#1}{#2}%
  }}%
 \expandafter\pgfutil@g@addto@macro\expandafter\pgfsyssoftpath@currentpath\pgfsyssoftpath@temp%
}


% Getting and setting the current path
\def\pgfsyssoftpath@getcurrentpath#1{%
  \let#1=\pgfsyssoftpath@currentpath%
}

\def\pgfsyssoftpath@setcurrentpath#1{%
  \global\let\pgfsyssoftpath@currentpath=#1%
}


% Invoking the current path
\def\pgfsyssoftpath@invokecurrentpath{%
  \pgfsyssoftpath@currentpath%
}

\def\pgfsyssoftpath@flushcurrentpath{%
  \pgfsyssoftpath@invokecurrentpath%
  \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
}

% Marshallers
\def\pgfsyssoftpath@movetotoken#1#2{\pgfsys@moveto{#1}{#2}}
\def\pgfsyssoftpath@linetotoken#1#2{\pgfsys@lineto{#1}{#2}}
\def\pgfsyssoftpath@rectcornertoken#1#2#3#4#5{\pgfsys@rect{#1}{#2}{#4}{#5}} % #3 = \pgfsyssoftpath@rectsizetoken
\def\pgfsyssoftpath@curvetosupportatoken#1#2#3#4#5#6#7#8{\pgfsys@curveto{#1}{#2}{#4}{#5}{#7}{#8}}
\def\pgfsyssoftpath@closepathtoken#1#2{\pgfsys@closepath}
\let\pgfsyssoftpath@specialroundtoken=\pgfutil@gobbletwo


\endinput

%%% Local Variables: 
%%% mode: latex
%%% End: 
