% Copyright 2011 by Alain Matthes
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.


\def\fileversion{1.16 c}
\def\filedate{2011/06/01}  


%<--------------------------------------------------------------------------–>
%                                         tkzText
%<--------------------------------------------------------------------------–>
\newif\iftkz@node\tkz@nodefalse  

\def\tkz@parsenode#1{%
\tkz@getvirg#1,\@nil
\iftkz@node  
\else
  \tkz@getfromcart#1\@nil   
\fi  
}   
\def\tkz@getvirg#1,#2\@nil{%
\ifx\tkzempty#2\tkzempty%
   \tkz@nodetrue 
\else
   \tkz@nodefalse  
\fi
}      


\def\tkzText{\pgfutil@ifnextchar[{\tkz@Text}{\tkz@Text[]}}
\def\tkz@Text[#1](#2)#3{%
 \begingroup
 \tkz@parsenode{#2} 
 \iftkz@node \node[#1] at (#2){#3}; 
 \else
 \FPadd{\ptxa}{\tkz@absc}{-\tkz@init@xorigine}
 \FPadd{\ptya}{\tkz@ord}{-\tkz@init@yorigine}
 \FPdiv{\ptxa}{\ptxa}{\tkz@init@xstep}
 \FPdiv{\ptya}{\ptya}{\tkz@init@ystep}
  \node[#1] at (\ptxa,\ptya){#3};% 
  \fi
\endgroup
}%
% %<--------------------------------------------------------------------------–>
% %                                    légende
% %<--------------------------------------------------------------------------–>
\newif\iftkz@legend@line
\pgfkeys{
/tkzlegend/.cd,  
line/.is if                 = tkz@legend@line,
line/.default               = true,
/tkzlegend/.unknown/.code   = {\let\searchname=\pgfkeyscurrentname
                              \pgfkeysalso{\searchname/.try=#1,
                                   /tikz/\searchname/.retry=#1}}  
}

\def\tkzLegend{\pgfutil@ifnextchar[{\tkz@Legend}{\tkz@Legend[]}} 
\def\tkz@Legend[#1](#2,#3)#4{%
\pgfkeys{/tkzlegend/.cd,
line=false}  
 \pgfqkeys{/tkzlegend}{#1}
 \begingroup  
\c@pgfmath@counta=0 %
\FPadd{\ptxa}{#2}{-\tkz@init@xorigine}
\FPadd{\ptya}{#3}{-\tkz@init@yorigine}
\FPdiv{\ptxa}{\ptxa}{\tkz@init@xstep}
\FPdiv{\ptya}{\ptya}{\tkz@init@ystep}
\node[/tkzlegend/.cd,#1] at (\ptxa,\ptya) {%
\begin{tikzpicture}
   \foreach \motif/\size/\col/\mtext in {#4}{%
       \iftkz@legend@line
          \draw[color      = \col,
                line width = \size,
                style      = \motif,
                text       = \tkz@mainlinecolor]%
          (0cm ,\the\c@pgfmath@counta ex)--%
               (\tkz@legend@line@len,\the\c@pgfmath@counta ex) 
       \else  
          \draw plot[mark size    = \size,%
                     mark         = \motif,%
                     mark options = {color=\col}]%
           coordinates{(0 ex,\the\c@pgfmath@counta ex)}%
         \fi
           node[right=1ex] {\mtext};
          \global\advance\c@pgfmath@counta by 3 %  
       }% 

\end{tikzpicture}%
};% 
\endgroup
}   

%<--------------------------------------------------------------------------–>
%                                 hline  pb  avec line
%<--------------------------------------------------------------------------–>
\def\tkzHLine{\pgfutil@ifnextchar[{\tkz@HLine}{\tkz@HLine[]}}  
\def\tkz@HLine[#1]#2{%
 \begingroup
    \FPeval{\tkz@valy}{(#2)}%
    \FPadd{\tkz@ptya}{\tkz@valy}{-\tkz@init@yorigine}
    \FPdiv{\tkz@ptya}{\tkz@ptya}{\tkz@init@ystep}
    \draw[#1] (\tkz@xa,\tkz@ptya)--(\tkz@xb,\tkz@ptya);%
\endgroup
}
%<--------------------------------------------------------------------------–>
%                                 hlines  pb  avec line
%<--------------------------------------------------------------------------–>
\def\tkzHLines{\pgfutil@ifnextchar[{\tkz@HLines}{\tkz@HLines[]}}  
\def\tkz@HLines[#1]#2{%
 \begingroup 
 \foreach \tkz@vy in {#2}{%
   \FPeval\my@tkz@vy{\tkz@vy}
   \tkz@HLine[#1]{\my@tkz@vy}}   
\endgroup
}  
%<--------------------------------------------------------------------------->
%                                      vline
%<--------------------------------------------------------------------------->
\def\tkzVLine{\pgfutil@ifnextchar[{\tkz@VLine}{\tkz@VLine[]}}
\def\tkz@VLine[#1]#2{%
\begingroup
  \FPeval\tkz@valx{(#2)}%
  \FPadd{\tkz@ptxa}{\tkz@valx}{-\tkz@init@xorigine}
  \FPdiv{\tkz@ptxa}{\tkz@ptxa}{\tkz@init@xstep}
  \draw[#1](\tkz@ptxa,\tkz@ya)--(\tkz@ptxa,\tkz@yb);
\endgroup
}  

%<--------------------------------------------------------------------------->
%                                      vlines
%<--------------------------------------------------------------------------->
\def\tkzVLines{\pgfutil@ifnextchar[{\tkz@VLines}{\tkz@VLines[]}}
\def\tkz@VLines[#1]#2{%
\begingroup  
 \foreach \tkz@vx in {#2}{%  
   \FPeval\my@tkz@vx{\tkz@vx}
   \tkz@VLine[#1]{\my@tkz@vx}}  
\endgroup
} 
%<--------------------------------------------------------------------------–>
\def\tkzHTick{\pgfutil@ifnextchar[{\tkz@HTick}{\tkz@HTick[]}}  
\def\tkz@HTick[#1]#2{%
 \begingroup  
    \FPeval\tkz@ptxa{(#2)}% 
    \FPround\tkz@ptxa\tkz@ptxa{5}   
    \FPclip\tkz@ptxa\tkz@ptxa
    \FPadd\tkz@ptxa\tkz@ptxa{-\tkz@init@xorigine}
    \FPdiv\tkz@ptxa\tkz@ptxa{\tkz@init@xstep} 
    \draw plot[mark style,#1] coordinates {(\tkz@ptxa,0)};  
\endgroup
}
\def\tkzHTicks{\pgfutil@ifnextchar[{\tkz@HTicks}{\tkz@HTicks[]}}  
\def\tkz@HTicks[#1]#2{%
 \begingroup 
\foreach \tkz@hy in {#2} {\tkz@HTick[#1]{\tkz@hy}}
\endgroup
}
%<--------------------------------------------------------------------------–>
\def\tkzVTick{\pgfutil@ifnextchar[{\tkz@VTick}{\tkz@VTick[]}}  
\def\tkz@VTick[#1]#2{%
 \begingroup
    \FPeval\tkz@ptya{(#2)}%
    \FPround\tkz@ptya\tkz@ptya{5}%
    \FPclip\tkz@ptya\tkz@ptya
    \FPadd\tkz@ptya\tkz@ptya{-\tkz@init@yorigine}%
    \FPdiv\tkz@ptya\tkz@ptya{\tkz@init@ystep}%
    \draw plot[mark style,#1] coordinates {(0,\tkz@ptya)};
\endgroup
}
%<--------------------------------------------------------------------------–>
\def\tkzVTicks{\pgfutil@ifnextchar[{\tkz@VTicks}{\tkz@VTicks[]}}  
\def\tkz@VTicks[#1]#2{%
\begingroup 
\foreach \tkz@hy in {#2} {\tkz@VTick[#1]{\tkz@hy}}
\endgroup
} 
\endinput