diff options
author | Karl Berry <karl@freefriends.org> | 2009-12-31 01:26:26 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-12-31 01:26:26 +0000 |
commit | 01294f46bb60e2b571fe1cc4b8a4428366240d8b (patch) | |
tree | 9a247291b962904733ebfd2e6e5748bba9d24ca7 /Master/texmf-dist/tex/latex/tikz-timing/tikz-timing-counters.sty | |
parent | 824638c603c772ef55ee6b4f8b3c1e8b680abe5b (diff) |
tikz-timing update (30dec09)
git-svn-id: svn://tug.org/texlive/trunk@16537 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tikz-timing/tikz-timing-counters.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-timing/tikz-timing-counters.sty | 226 |
1 files changed, 194 insertions, 32 deletions
diff --git a/Master/texmf-dist/tex/latex/tikz-timing/tikz-timing-counters.sty b/Master/texmf-dist/tex/latex/tikz-timing/tikz-timing-counters.sty index e81d3412b68..ba5131cbe02 100644 --- a/Master/texmf-dist/tex/latex/tikz-timing/tikz-timing-counters.sty +++ b/Master/texmf-dist/tex/latex/tikz-timing/tikz-timing-counters.sty @@ -27,13 +27,14 @@ %% \RequirePackage{svn-prov}[2009/05/03] \ProvidesPackageSVN[tikz-timing-counters] - {$Id: tikz-timing.dtx 1580 2009-12-09 11:14:01Z martin $} - [v0.7 + {$Id: tikz-timing.dtx 1647 2009-12-28 14:18:14Z martin $} + [v0.7a TikZ-Timing Library for counter values] \GetFileInfoSVN*% \RequirePackage{tikz-timing}[\filedate]% \DefineFileInfoSVN +\newif\if@tikztiming@counter@wraps \tikzset{% timing/new counter/.style={timing/counter/new={#1}}, @@ -41,57 +42,218 @@ new/.code={\tikztiming@counter@new{#1}}, new/.value required, opt/.cd, - char/.estore in=\tikztiming@counter@char, - reset char/.estore in=\tikztiming@counter@resetchar, - base/.estore in=\tikztiming@counter@base, - half width char/.estore in=\tikztiming@counter@hwchar, + char/.initial=, char/.value required, + reset char/.initial=, reset char/.value required, - base/.value required, + reset type/.is choice, + reset type/width/.code={\def\tikztiming@resettype{0}}, + reset type/arg/.code={\def\tikztiming@resettype{1}}, + reset type/both/.code={\def\tikztiming@resettype{2}}, + reset type/Both/.code={\def\tikztiming@resettype{3}}, + half width char/.initial=, half width char/.value required, + base/.initial=10, + base/.value required, + increment/.initial=1, + increment/.value required, + max value/.initial=, + max value/.value required, + min value/.initial=, + min value/.value required, + wraps/.is if=@tikztiming@counter@wraps, + digits/.initial=, + digits/.value required, + fg style/.initial=, + bg style/.initial=, + text style/.initial=, + text format/.initial=, + fg style/.value required, + bg style/.value required, + text style/.value required, + text format/.value required, +} +\def\tikztiming@counter@textformat{}% +\def\tikztimingcounter#1{% + \csname tikztiming@counter@#1\endcsname +} +\def\tikztimingsetcounter#1#2{% + \begingroup + \pgfmathtruncatemacro\@tempa{#2}% + \expandafter\global\expandafter\let\csname tikztiming@counter@#1\endcsname\@tempa + \endgroup } \def\tikztiming@counter@new#1{% - \let\tikztiming@counter@char\empty - \let\tikztiming@counter@resetchar\empty - \def\tikztiming@counter@base{10}% - \let\tikztiming@counter@hwchar\relax + \begingroup + \def\tikztiming@resettype{0}% \pgfqkeys{/tikz/timing/counter/opt}{#1}% - \ifx\tikztiming@counter@char\empty + \tikzset{timing/counter/opt/char/.get=\counterchar}% + \ifx\counterchar\empty \PackageError{tikz-timing-counters}{Counter character must be given using - the 'char' key!}% + the 'char' key!}{}{}{}% + \endgroup \else + \pgfkeys{/tikz/timing/counter/opt/min value/.get=\min}% + \pgfkeys{/tikz/timing/counter/opt/max value/.get=\max}% + \if@tikztiming@counter@wraps + \ifx\min\empty + \def\min{0}% + \fi + \ifx\max\empty + \PackageError{tikz-timing-counters}{The option 'wraps' needs the option 'max value' to be set!}{}{}{}% + \fi + \def\@tempb{% + \noexpand\tikztiming@counter@wrap% + {\expandafter\unexpanded\expandafter{\min}}% + {\expandafter\unexpanded\expandafter{\max}}% + }% + \else + \ifx\min\empty + \ifx\max\empty + \let\@tempb\empty + \else + \def\@tempb{% + \noexpand\tikztiming@counter@maxsat% + {\expandafter\unexpanded\expandafter{\max}}% + }% + \fi + \else + \ifx\max\empty + \def\@tempb{% + \noexpand\tikztiming@counter@minsat% + {\expandafter\unexpanded\expandafter{\min}}% + }% + \else + \def\@tempb{% + \noexpand\tikztiming@counter@minmaxsat% + {\expandafter\unexpanded\expandafter{\min}}% + {\expandafter\unexpanded\expandafter{\max}}% + }% + \fi + \fi + \fi + \pgfkeys{/tikz/timing/counter/opt/fg style/.get=\fgstyle}% + \pgfkeys{/tikz/timing/counter/opt/bg style/.get=\bgstyle}% + \pgfkeys{/tikz/timing/counter/opt/text style/.get=\textstyle}% + \pgfkeys{/tikz/timing/counter/opt/text format/.get=\textformat}% + \pgfkeys{/tikz/timing/counter/opt/increment/.get=\increment}% \edef\@tempa{% - \noexpand\tikztiming@counter@new@{\tikztiming@counter@char}{\tikztiming@counter@base}% - {\tikztiming@counter@hwchar}{\tikztiming@counter@resetchar}% + \noexpand\tikztiming@counter@new@ + {\pgfkeysvalueof{/tikz/timing/counter/opt/char}}% + {\pgfkeysvalueof{/tikz/timing/counter/opt/base}}% + {\pgfkeysvalueof{/tikz/timing/counter/opt/half width char}}% + {\pgfkeysvalueof{/tikz/timing/counter/opt/reset char}}% + {\pgfkeysvalueof{/tikz/timing/counter/opt/digits}}% + {\expandafter\unexpanded\expandafter{\increment}}% + {\@tempb}% + {\min}% + {\tikztiming@resettype}% + {\expandafter\unexpanded\expandafter{\fgstyle}}% + {\expandafter\unexpanded\expandafter{\bgstyle}}% + {\expandafter\unexpanded\expandafter{\textstyle}}% + {\expandafter\unexpanded\expandafter{\textformat}}% }% + \expandafter\expandafter\expandafter\endgroup \expandafter\@tempa \fi } -\def\tikztiming@counter@new@#1#2#3#4{% - \newcounter{tikztiming@counter@#1}% - \tikzset{timing/counter/#1/.append style={}}% - \tikztimingmetachar{#1}[1]{##1D{[timing/counter/#1]\tikztiming@counter@vs{#1}{#2}}}% - \ifx\tikztiming@counter@hwchar\empty\else - \ifx\tikztiming@counter@hwchar\relax +\def\tikztiming@counter@new@#1#2#3#4#5#6#7#8#9{% + \ifx\empty#8\empty + \@namedef{tikztiming@counter@#1}{0}% + \else + \expandafter + \pgfmathtruncatemacro\csname tikztiming@counter@#1\endcsname{#8}% + \fi + \tikztimingmetachar{#1}[1]{ { [timing/counter/#1] ##1D{[timing/counter/#1/text]\tikztiming@counter@vs{#1}{#2}{#5}{#6}{#7}} } }% + \ifx\empty#3\empty \tikztiming@iflower{#1}{}% {\lowercase{\tikztimingmetachar{#1}}[1]% - {##1d{[timing/counter/#1]\tikztiming@counter@vs{#1}{#2}}}}% - \else - \tikztimingmetachar{#3}[1]{##1d{[timing/counter/#1]\tikztiming@counter@vs{#1}{#2}}}% + { { [timing/counter/#1] ##1d{[timing/counter/#1/text]\tikztiming@counter@vs{#1}{#2}{#5}{#6}{#7}}} }% + }% + \else + \tikztimingmetachar{#3}[1]{% + { [timing/counter/#1] ##1d{[timing/counter/#1/text]\tikztiming@counter@vs{#1}{#2}{#5}{#6}{#7}} }% + }% + \fi + \ifx\empty#4\empty\else + \ifcase0#9\relax + \tikztimingmetachar{#4}[1]{[|/utils/exec=\tikztiming@counter@reset{#1}{##1}|]}% + \or + \tikztimingmetachar{#4}[2]{[|/utils/exec=\tikztimingsetcounter{#1}{##2}|]}% + \or + \uppercase{\tikztimingmetachar{#4}}[1]{[|/utils/exec=\tikztiming@counter@reset{#1}{##1}|]}% + \lowercase{\tikztimingmetachar{#4}}[2]{[|/utils/exec=\tikztimingsetcounter{#1}{##2}|]}% + \or + \lowercase{\tikztimingmetachar{#4}}[1]{[|/utils/exec=\tikztiming@counter@reset{#1}{##1}|]}% + \uppercase{\tikztimingmetachar{#4}}[2]{[|/utils/exec=\tikztimingsetcounter{#1}{##2}|]}% \fi \fi - \ifx\tikztiming@counter@resetchar\empty\else - \tikztimingmetachar{#4}[1]{[|/utils/exec=\tikztiming@counter@reset{#1}{##1}|]}% + \tikztiming@counter@new@@{#1}% +} +\def\tikztiming@counter@new@@#1#2#3#4#5{% + \tikzset{timing/counter/#1/.style={}}% + \ifx\empty#2\empty\else + \tikzset{timing/counter/#1/.append style={% + /tikz/timing/d/.style={#2}% + }}% + \fi + \ifx\empty#3\empty\else + \tikzset{timing/counter/#1/.append style={% + /tikz/timing/d/background/.style={#3}% + }}% + \fi + \tikzset{timing/counter/#1/text/.style={#4}}% + \ifx\empty#5\empty\else + \tikzset{timing/counter/#1/.append style={% + /utils/exec={\def\tikztiming@counter@textformat{#5}}% + }}% \fi } \def\tikztiming@counter@reset#1#2{% - \pgfmathsetcounter{tikztiming@counter@#1}{round((#2)/\tikztiming@wscale)}% - \setcounter{tikztiming@counter@#1}{\value{tikztiming@counter@#1}}% + \begingroup + \pgfmathtruncatemacro\@tempa{round((#2)/\tikztiming@wscale)}% + \expandafter\global\expandafter\let\csname tikztiming@counter@#1\endcsname\@tempa + \endgroup +} +\def\tikztiming@counter@vs#1#2#3#4#5{% + \begingroup + \ifx\empty#3\empty\else + \pgfmathsetbasenumberlength{#3}% + \fi + \ifnum#2=10 + \expandafter\expandafter\expandafter\tikztiming@counter@textformat + \expandafter\expandafter\expandafter{\csname tikztiming@counter@#1\endcsname}% + \else + \pgfmathdectoBase\pgfmathresult{\@nameuse{tikztiming@counter@#1}}{#2}% + \expandafter\tikztiming@counter@textformat\expandafter{\pgfmathresult}% + \fi + \edef\N{\@nameuse{tikztiming@counter@#1}}% + \pgfmathtruncatemacro\N{\N + #4}% + #5% + \expandafter\global\expandafter\let\csname tikztiming@counter@#1\endcsname\N + \endgroup +} +\def\tikztiming@counter@minsat#1{% + \pgfmathtruncatemacro\MIN{#1}% + \ifnum\N<\MIN \let\N\MIN \fi +} +\def\tikztiming@counter@maxsat#1{% + \pgfmathtruncatemacro\MAX{#1}% + \ifnum\N>\MAX \let\N\MAX \fi } -\def\tikztiming@counter@vs#1#2{% - \pgfmathdectoBase\pgfmathresult{\value{tikztiming@counter@#1}}{#2}% - \pgfmathresult - \stepcounter{tikztiming@counter@#1}% +\def\tikztiming@counter@minmaxsat#1#2{% + \tikztiming@counter@minsat{#1}% + \tikztiming@counter@maxsat{#2}% +} +\def\tikztiming@counter@wrap#1#2{% + \pgfmathtruncatemacro\MIN{#1}% + \pgfmathtruncatemacro\MAX{#2}% + \ifnum\N>\MAX + \pgfmathtruncatemacro\N{\MIN + (\N-\MAX-1)}% + \fi + \ifnum\N<\MIN + \pgfmathtruncatemacro\N{\MAX - (\MIN-\N+1)}% + \fi } \RequirePackage{pgfopts} \ProcessPgfOptions{/tikz/timing/counter} |