% tkz-obj-eu-axesmin.tex    
% Copyright 2024  Alain Matthes
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
% This work has the LPPL maintenance status “maintained”.
% The Current Maintainer of this work is Alain Matthes.

\def\fileversion{5.10c}
\def\filedate{2024/04/19} 
\typeout{2024/04/19 5.10c tkz-obj-eu-axesmin}   

\makeatletter
\def\removedot#1.{#1}
\newcommand\tkzgetinteger[1]{\expandafter\tkz@getinteger#1.\@nil}
\def\tkz@getinteger#1.#2\@nil{%
  \ifx\empty#2\empty
    \tkz@integertrue
  \else
  \ifnum\removedot#2=0   
    \tkz@integertrue
   \else 
     \tkz@integerfalse
   \fi
  \fi
}

%<--------------------------------------------------------------------------–>
%              Setup   axe
%<--------------------------------------------------------------------------–>
\pgfkeys{tkzaxis/.cd,
      line width/.code      = \xdef\tkz@sua@lw{#1},
      color/.code           = \xdef\tkz@sua@color{#1},
      tickwd/.code          = \xdef\tkz@sua@tickwd{#1},
      ticka/.code           = \xdef\tkz@sua@ticka{#1},
      tickb/.code           = \xdef\tkz@sua@tickb{#1},
      line width            = \tkz@init@lw,
      color                 = \tkz@init@color,
      tickwd                = \tkz@init@tickwd,
      ticka                 = \tkz@init@ticka,
      tickb                 = \tkz@init@tickb
} 

\def\tkzSetUpAxis{\pgfutil@ifnextchar[{\tkz@SetUpAxis}{\tkz@SetUpAxis[]}} 
\def\tkz@SetUpAxis[#1]{%
\begingroup
\pgfqkeys{/tkzaxis}{#1}
\global\let\tkz@init@lw\tkz@sua@lw
\global\let\tkz@init@gradsize\tkz@sua@gradsize 
\global\let\tkz@init@color\tkz@sua@color 
\global\let\tkz@init@tickwd\tkz@sua@tickwd 
\global\let\tkz@init@ticka\tkz@sua@ticka 
\global\let\tkz@init@tickb\tkz@sua@tickb  
\endgroup
}
%<--------------------------------------------------------------------------–>
%                 tkzDrawX      todo améliorer les unités
% sans doute à revoir loop from 0 to i then calcul dans la boucle de la position
% et de l'affichage
%<--------------------------------------------------------------------------–>
\pgfkeys{%
  /tkzdrawX/.cd,
  color/.store in            = \tkz@X@color,
  label/.store in            = \tkz@X@label,
  right space/.store in      = \tkz@axe@rxspace,
  left space/.store in       = \tkz@axe@lxspace,
  step/.code                 = {\edef\tkz@posnext{\fpeval{#1}}},
  color                      = \tkz@init@color,
  label                      = \tkz@init@xlabel,
  step                       = \tkz@init@xstep,
  right space                = \tkz@init@rightspace, %???
  left space                 = \tkz@init@leftspace,
  noticks/.is if             = tkz@X@noticks,
  noticks/.default           = true,
  noticks                    = true,
  tickwd/.store in           = \tkz@X@tickwd,
  tickup/.store in           = \tkz@X@tickup,
  tickdn/.store in           = \tkz@X@tickdn,
  tickwd                     = \tkz@init@tickwd,
  tickup                     = \tkz@init@ticka,
  tickdn                     = \tkz@init@tickb,
   /tkzdrawX/.search also={/tikz}, 
  }

\def\tkzDrawX{\pgfutil@ifnextchar[{\tkz@DrawX}{\tkz@DrawX[]}}
\def\tkz@DrawX[#1]{
\begingroup%
\pgfqkeys{/tkzdrawX}{#1}
\edef\tkz@posmax{\fpeval{trunc(\tkz@xb,\tkz@init@xdec)}}
\edef\tkz@posmin{\fpeval{trunc(\tkz@xa,\tkz@init@xdec)}}
\edef\tkz@xbsup{\fpeval{\tkz@xb+\tkz@axe@rxspace}}
\edef\tkz@xainf{\fpeval{\tkz@xa-\tkz@axe@lxspace}}
\path (\tkz@xainf,0)--(\tkz@xbsup,0) node(tkz@xline){};
\draw[xaxe style,
      color = \tkz@X@color, 
      /tkzdrawX/.cd, #1] (\tkz@xainf,0)--(\tkz@xbsup,0)
                        node[ xlabel style, 
                           /tkzdrawX/.cd, 
                          #1]{\tkz@X@label};
 \iftkz@X@noticks
 \else
  \edef\tkz@posmax{\fpeval{trunc(\tkz@posmax,\tkz@init@xdec)}}   
  \edef\tkz@posnext{\fpeval{\tkz@posnext/\tkz@init@xstep+\tkz@posmin}}
     \foreach \pos in {\tkz@posmin,...,\tkz@posmax}{%
         \edef\tkz@pos{\fpeval{\pos*1}}% ???
         \draw[ color         = \tkz@X@color,
                line width    = \tkz@X@tickwd,
                shift         = {(\tkz@pos,0)}]%
                (0pt,\tkz@X@tickup)--(0pt,-\tkz@X@tickdn);
           }
 \fi
\endgroup
}
%<--------------------------------------------------------------------------–>
%                 tkzDrawY      todo améliorer les unités
%<--------------------------------------------------------------------------–>
\pgfkeys{%
  /tkzdrawY/.cd,
  color/.store in            = \tkz@Y@color,
  label/.store in            = \tkz@Y@label, 
  up space/.store in         = \tkz@axe@uyspace, 
  down space/.store in       = \tkz@axe@dyspace,
  step/.code                 = {\edef\tkz@posnext{\fpeval{#1}}},  
  color                      = \tkz@init@color,
  label                      = \tkz@init@ylabel,
  step                       = \tkz@init@ystep,
  up space                   = \tkz@init@upspace,
  down space                 = \tkz@init@downspace,
  noticks/.is if             = tkz@Y@noticks,
  noticks/.default           = true,
  noticks                    = true,
  tickwd/.store in           = \tkz@Y@tickwd,
  ticklt/.store in           = \tkz@Y@ticklt,
  tickrt/.store in           = \tkz@Y@tickrt,
  tickwd                     = \tkz@init@tickwd,
  ticklt                     = \tkz@init@tickb,
  tickrt                     = \tkz@init@ticka,
   /tkzdrawY/.search also={/tikz},    
        }
                                     
\def\tkzDrawY{\pgfutil@ifnextchar[{\tkz@DrawY}{\tkz@DrawY[]}}
\def\tkz@DrawY[#1]{%
\begingroup
\pgfkeys{/tkzdrawY/.cd,step = \tkz@init@ystep}
\pgfqkeys{/tkzdrawY}{#1}
\edef\tkz@posmax{\fpeval{trunc(\tkz@yb,\tkz@init@ydec)}}
\edef\tkz@posmin{\fpeval{trunc(\tkz@ya,\tkz@init@ydec)}}
\edef\tkz@ybsup{\fpeval{\tkz@yb+\tkz@axe@uyspace}}
\edef\tkz@yainf{\fpeval{\tkz@ya-\tkz@axe@dyspace}}
\path (0,\tkz@yainf)--(0,\tkz@ybsup) node(tkz@yline){};
\draw[color = \tkz@Y@color,
      yaxe style,/tkzdrawY/.cd,#1] (0,\tkz@yainf)--(0,\tkz@ybsup)
      node[ylabel style,/tkzdrawY/.cd,#1]{\tkz@Y@label};
 \iftkz@Y@noticks
 \else 
    \edef\tkz@posmax{\fpeval{trunc(\tkz@posmax,\tkz@init@ydec)}}    
    \edef\tkz@posnext{\fpeval{\tkz@posnext/\tkz@init@ystep+\tkz@posmin}}
   \foreach \tkz@pos in {\tkz@posmin,\tkz@posnext,...,\tkz@posmax}{% 
     \draw[color = \tkz@Y@color,
           line width = \tkz@Y@tickwd,
           shift       = {(0,\tkz@pos)}]% 
            (\tkz@Y@tickrt,0pt)--(-\tkz@Y@ticklt,0pt);}
    
 \fi        
\endgroup}
\makeatother
\endinput