% Copyright 2008 by Till Tantau and others Wibrow
%
% 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.



%
% Base shapes
%
% These shapes are identical to the shapes without "ee", only an "input"
% and an "output" anchor have been added at the left and right end.

\pgfdeclareshape{rectangle ee}
{
  \inheritsavedanchors[from=rectangle] 
  \inheritanchorborder[from=rectangle]
  \inheritanchor[from=rectangle]{north}
  \inheritanchor[from=rectangle]{north west}
  \inheritanchor[from=rectangle]{north east}
  \inheritanchor[from=rectangle]{center}
  \inheritanchor[from=rectangle]{west}
  \inheritanchor[from=rectangle]{east}
  \inheritanchor[from=rectangle]{mid}
  \inheritanchor[from=rectangle]{mid west}
  \inheritanchor[from=rectangle]{mid east}
  \inheritanchor[from=rectangle]{base}
  \inheritanchor[from=rectangle]{base west}
  \inheritanchor[from=rectangle]{base east}
  \inheritanchor[from=rectangle]{south}
  \inheritanchor[from=rectangle]{south west}
  \inheritanchor[from=rectangle]{south east}
  \inheritbackgroundpath[from=rectangle]
  % New:
  \anchor{input}{
    \pgf@process{\northeast}%
    \pgf@ya=.5\pgf@y%
    \pgf@process{\southwest}%
    \pgf@y=.5\pgf@y%
    \advance\pgf@y by \pgf@ya%
  }
  \anchor{output}{%
    \pgf@process{\southwest}%
    \pgf@ya=.5\pgf@y%
    \pgf@process{\northeast}%
    \pgf@y=.5\pgf@y%
    \advance\pgf@y by \pgf@ya%
  }
}

\pgfdeclareshape{circle ee}
{
  \inheritsavedanchors[from=circle] 
  \inheritanchorborder[from=circle]
  \inheritanchor[from=circle]{north}
  \inheritanchor[from=circle]{north west}
  \inheritanchor[from=circle]{north east}
  \inheritanchor[from=circle]{center}
  \inheritanchor[from=circle]{west}
  \inheritanchor[from=circle]{east}
  \inheritanchor[from=circle]{mid}
  \inheritanchor[from=circle]{mid west}
  \inheritanchor[from=circle]{mid east}
  \inheritanchor[from=circle]{base}
  \inheritanchor[from=circle]{base west}
  \inheritanchor[from=circle]{base east}
  \inheritanchor[from=circle]{south}
  \inheritanchor[from=circle]{south west}
  \inheritanchor[from=circle]{south east}
  \inheritbackgroundpath[from=circle]
  % New:
  \anchor{input}{\centerpoint\advance\pgf@x by-\radius}
  \anchor{output}{\centerpoint\advance\pgf@x by\radius}
}



%
% Current direction indicator. This shape uses the current setting of
% the current direction arrow tip for the arrow. The shape is a
% rectangle around the arrow tip. 
%

\pgfdeclareshape{direction ee}
{
  \savedanchor\northeast{
    \pgf@x=0pt%
    % Height is given by minimum height/2
    \pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/minimum height}}%
    \pgf@y=.5\pgf@y
  }
  \savedanchor\southwest{
    % Left border is given by left extend
    \pgfarrowtotallength{\pgfkeysvalueof{/pgf/direction ee arrow}}%
    \pgf@x=-\pgf@x%
    % Height is given by minimum height/2
    \pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/minimum height}}%
    \pgf@y=-.5\pgf@y
  }

  \inheritanchor[from=rectangle ee]{center}
  \inheritanchor[from=rectangle ee]{north}
  \inheritanchor[from=rectangle ee]{south}
  \inheritanchor[from=rectangle ee]{east}
  \inheritanchor[from=rectangle ee]{west}
  \inheritanchor[from=rectangle ee]{north east}
  \inheritanchor[from=rectangle ee]{north west}
  \inheritanchor[from=rectangle ee]{south east}
  \inheritanchor[from=rectangle ee]{south west}
  \inheritanchor[from=rectangle ee]{input}
  \inheritanchor[from=rectangle ee]{output}
  \inheritanchorborder[from=rectangle ee]
  \nodeparts{}% no text

  \behindbackgroundpath{
    \pgf@process{\southwest}
    \pgf@xa=\pgf@x
    \pgf@process{\northeast}
    \pgf@xb=\pgf@x
    \pgfpathmoveto{\pgfqpoint{\pgf@xa}{0pt}}
    \pgfpathlineto{\pgfqpoint{\pgf@xb}{0pt}}
    \pgfusepathqstroke
  }

  \beforebackgroundpath{
    {
      \pgfsys@beginscope
      \pgfarrowdraw{\pgfkeysvalueof{/pgf/direction ee arrow}}%
      \pgfsys@endscope
    }
  }
}

\pgfkeys{
  /pgf/direction ee arrow/.initial=direction ee,
}



% Special arrow for ee directions:

\pgfarrowsdeclare{direction ee}{direction ee}
{
  \pgfmathsetlength\pgfutil@tempdima{\pgfgetarrowoptions{direction ee}}%
  \pgfutil@tempdima=.5\pgfutil@tempdima
  \pgfarrowsleftextend{+-\pgfutil@tempdima}
  \pgfarrowsrightextend{+\pgfutil@tempdima}
}
{
  \pgfmathsetlength\pgfutil@tempdima{\pgfgetarrowoptions{direction ee}}%
  \pgfsetdash{}{+0pt}
  \pgfsetroundjoin
  \pgfpathmoveto{\pgfqpoint{-0.5\pgfutil@tempdima}{0.38268343237\pgfutil@tempdima}}
  \pgfpathlineto{\pgfqpoint{0.5\pgfutil@tempdima}{0\pgfutil@tempdima}}
  \pgfpathlineto{\pgfqpoint{-0.5\pgfutil@tempdima}{-0.38268343237\pgfutil@tempdima}}
  \pgfpathclose
  \pgfusepathqfillstroke
}

\pgfsetarrowoptions{direction ee}{4pt}





\endinput

