% 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.

\RequirePackage{pgfrcs}

\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/latex/pgf/compatibility/pgfheaps.sty,v 1.3 2006/10/11 15:22:27 tantau Exp $

\RequirePackage{pgf}

\PackageWarning{pgfheaps}{This package is obsolete.}

\ProcessOptions

%
% Package for drawing heap diagrams.
%

\newdimen\pgf@heapx
\newdimen\pgf@heapy




% Construct the path of a heap.
% 
% #1 = Position of heap label.
% #2 = Position of left base
% #3 = Position of right base
% 
% Example:
%
% \pgfheappath{\pgfxy(1,0)}{\pgfxy(-1,0)}{\pgfxy(1,0)}
% \pgffill

\def\pgfheappath#1#2#3{%
  \pgfdiff{#2}{#3}%
  \pgf@heapx=-.25\pgf@x%
  \pgf@heapy=-.25\pgf@y%
  \pgfmoveto{#2}%
  \pgfbezier%
    {\pgfpartway{0.5}{#2}{\pgfrelative{#1}{\pgfpoint{\pgf@heapx}{\pgf@heapy}}}}%
    {\pgfrelative{#1}{\pgfpoint{\pgf@heapx}{\pgf@heapy}}}%
    {#1}%
  \pgf@heapx=-\pgf@heapx%
  \pgf@heapy=-\pgf@heapy%  
  \pgfbezier%
    {\pgfrelative{#1}{\pgfpoint{\pgf@heapx}{\pgf@heapy}}}%
    {\pgfpartway{0.5}{#3}{\pgfrelative{#1}{\pgfpoint{\pgf@heapx}{\pgf@heapy}}}}%
    {#3}%
  \ignorespaces}


% Draw a heap label. 
% 
% #1 = Position of heap label.
% #2 = Label text.
% 
% Example:
%
% \pgfheaplabel{\pgfxy(1,0)}{Class P}

\def\pgfheaplabel#1#2{%
  \setbox\pgf@hbox=\hbox{\pgfinterruptpicture#2\endpgfinterruptpicture}%
  \pgf@heapy=\ht\pgf@hbox%
  \pgfputat{\pgfrelative{#1}{\pgfpoint{0pt}{-2\pgf@heapy}}}{\pgfbox[center,base]{#2}}%
  \ignorespaces}


% Draw a labeled heap. 
% 
% #1 = Position of heap label.
% #2 = Position of left base
% #3 = Position of right base
% #4 = Label text.
% 
% Example:
%
% \pgfheaplabeled{\pgfxy(1,0)}{\pgfxy(-1,0)}{\pgfxy(1,0)}{Class P}

\def\pgfheaplabeled#1#2#3#4{%
  \pgfheaplabel{#1}{#4}%
  \pgfheappath{#1}{#2}{#3}%
  \pgfstroke%
  \ignorespaces}



% Draw a labeled heap. 
% 
% #1 = Height of the label
% #2 = Left and right extension of the base.
% #3 = Label text.
% 
% Example:
%
% \pgfheaplabeledcentered{1cm}{1cm}{Class P}

\def\pgfheaplabeledcentered#1#2#3{%
  \pgfheaplabeled{\pgfpoint{0pt}{#1}}{\pgfpoint{-#2}{0pt}}{\pgfpoint{#2}{0pt}}{#3}\ignorespaces}

\endinput
