% 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.13 c}
\def\filedate{2011/01/19}

%<--------------------------------------------------------------------------–>
%                               Setup   Segment
%<--------------------------------------------------------------------------–>

%<--------------------------------------------------------------------------–>
%                             draw      segment  (s)
%<--------------------------------------------------------------------------–>                              
\def\tkzDrawSegment{\pgfutil@ifnextchar[{\tkz@DrawSegment}{%
                                         \tkz@DrawSegment[]}} 
\def\tkz@DrawSegment[#1](#2,#3){%    
\begingroup
 \draw[line style,add=0 and 0,#1] (#2) to (#3); 
\endgroup   
}%    

\def\tkz@multiDrawSeg#1 #2\@nil{%
 \protected@edef\tkz@temp{
   \noexpand \tkzDrawSegment[\tkz@optseg](#1)}\tkz@temp%   
   \def\tkz@nextArg{#2}%
   \ifx\tkzutil@empty\tkz@nextArg
     \let\next\@gobble
   \fi
   \next#2\@nil
} 
\def\tkzDrawSegments{\pgfutil@ifnextchar[{\tkz@DrawSegments}{%
                                         \tkz@DrawSegments[]}}
\def\tkz@DrawSegments[#1](#2){% 
\global\edef\tkz@optseg{#1} 
\begingroup
   \let\next\tkz@multiDrawSeg
   \next#2 \@nil %    
\endgroup
}
%<-------------------------------------------------------------------------–> 
%<-------------------------------------------------------------------------–> 
\pgfkeys{tkzmarkoptions/.cd,
pos/.code        = {\global\def\tkz@mkpos{#1}},
color/.code      = {\global\def\tkz@mkcolor{#1}},
mark/.code       = {\global\def\tkz@mark{#1}},
size/.code       = {\global\def\tkz@mksize{#1}},
/tkzmarkoptions/.unknown/.code   = {\let\searchname=\pgfkeyscurrentname
                                \pgfkeysalso{\searchname/.try=#1,
                                 /tikz/\searchname/.retry=#1}
                                 } 
}  

\def\tkzMarkSegment{\pgfutil@ifnextchar[{\tkz@MarkSegment}{%
                                        \tkz@MarkSegment[]}}
\def\tkz@MarkSegment[#1](#2,#3){%
\pgfkeys{tkzmarkoptions/.cd,
         size   = 4pt,
         color  = \tkz@mk@color,
         pos    = .5,
         mark   = none}
\pgfqkeys{/tkzmarkoptions}{#1}

\global\def\tkz@mymark{%
  \pgfsetplotmarksize{\tkz@mksize}
  \pgfuseplotmark{\tkz@mark}
}
\begin{scope} [decoration={ markings,mark=at position \tkz@mkpos with \tkz@mymark}] 
\path [\tkz@mkcolor,postaction={decorate}] (#2) -- (#3);
\end{scope}
} 
%<--------------------------------------------------------------------------–>
%<--------------------------------------------------------------------------–>
% multiple
\def\tkz@multiMS#1 #2\@nil{%
 \protected@edef\tkz@temp{
   \noexpand \tkzMarkSegment[\tkz@optsg](#1)}\tkz@temp%
   \def\tkz@nextArg{#2}%
   \ifx\tkzutil@empty\tkz@nextArg
     \let\next\@gobble
   \fi
   \next#2\@nil
}
%<--------------------------------------------------------------------------–>
\def\tkzMarkSegments{\pgfutil@ifnextchar[{\tkz@MarkSegments}{%
                                          \tkz@MarkSegments[]}}
\def\tkz@MarkSegments[#1](#2){% 
\global\edef\tkz@optsg{#1} 
  \begingroup
   \let\next\tkz@multiMS
   \next#2 \@nil %    
\endgroup 
} 
%<--------------------------------------------------------------------------–>
%<------------------------- Label on segment -------------------------------–>
%<--------------------------------------------------------------------------–>
\def\tkzLabelSegment{\pgfutil@ifnextchar[{\tkz@LabelSegment}{%
                                        \tkz@LabelSegment[]}}
\def\tkz@LabelSegment[#1](#2,#3)#4{%
\begingroup    
\path  (#2) to node[above,#1]{#4} (#3) ;  
\endgroup 
} 
%<--------------------------------------------------------------------------–>
%<--------------------------------------------------------------------------–>
% multiple
\def\tkz@multiLS#1 #2\@nil{%
 \protected@edef\tkz@temp{
   \noexpand \tkzLabelSegment[\tkz@optls](#1){\tkz@labelseg}}\tkz@temp%
   \def\tkz@nextArg{#2}%
   \ifx\tkzutil@empty\tkz@nextArg
     \let\next\@gobble
   \fi
   \next#2\@nil
}
%<--------------------------------------------------------------------------–>
\def\tkzLabelSegments{\pgfutil@ifnextchar[{\tkz@LabelSegments}{%
                                           \tkz@LabelSegments[]}}
\def\tkz@LabelSegments[#1](#2)#3{% 
\global\edef\tkz@optls{#1}
\global\def\tkz@labelseg{#3}
  \begingroup
   \let\next\tkz@multiLS
   \next#2 \@nil %    
\endgroup 
} 
%<--------------------------------------------------------------------------–>
%                                 PolySeg
%<--------------------------------------------------------------------------–>
\def\tkzDrawPolySeg{\pgfutil@ifnextchar[{\tkz@DrawPolySeg}{%
                                         \tkz@DrawPolySeg[]}}
\def\tkz@DrawPolySeg[#1](#2,#3){% 
\begingroup
\draw[#1] (#2) 
    \foreach \tkz@pt in {#3}{--(\tkz@pt)};% 
\endgroup
}   
\endinput
