From 90ae413a94da014dbf7a6a8ab584f7c668483a5a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 27 Feb 2014 00:01:50 +0000 Subject: pgf 3.0.0 git-svn-id: svn://tug.org/texlive/trunk@33057 c570f23f-e606-0410-a88d-b1316a301751 --- .../circuits/tikzlibrarycircuits.code.tex | 16 +- .../circuits/tikzlibrarycircuits.ee.code.tex | 30 +- .../tikzlibrarydatavisualization.code.tex | 1220 +++++++---- .../tikzlibrarydatavisualization.polar.code.tex | 543 ++++- .../graphs/tikzlibrarygraphs.basic.code.tex | 29 - .../libraries/graphs/tikzlibrarygraphs.code.tex | 2213 ++++++++++++++++++-- .../graphs/tikzlibrarygraphs.standard.code.tex | 112 + .../tikz/libraries/tikzexternalshared.code.tex | 319 ++- .../tikz/libraries/tikzlibrary3d.code.tex | 6 +- .../tikz/libraries/tikzlibraryangles.code.tex | 72 + .../tikz/libraries/tikzlibrarybabel.code.tex | 17 + .../tikz/libraries/tikzlibrarybackgrounds.code.tex | 12 +- .../tikz/libraries/tikzlibrarybending.code.tex | 15 + .../tikz/libraries/tikzlibrarycalc.code.tex | 101 +- .../tikz/libraries/tikzlibrarycalendar.code.tex | 18 +- .../tikz/libraries/tikzlibrarychains.code.tex | 8 +- .../tikz/libraries/tikzlibrarydecorations.code.tex | 14 +- .../libraries/tikzlibrarydecorations.text.code.tex | 693 +++++- .../tikz/libraries/tikzlibraryfit.code.tex | 92 +- .../tikz/libraries/tikzlibraryfolding.code.tex | 2028 +++++++++++++++++- .../libraries/tikzlibraryintersections.code.tex | 53 +- .../tikz/libraries/tikzlibrarymath.code.tex | 725 +++++++ .../tikz/libraries/tikzlibrarymatrix.code.tex | 21 +- .../tikz/libraries/tikzlibrarymindmap.code.tex | 26 +- .../tikz/libraries/tikzlibrarypetri.code.tex | 4 +- .../tikz/libraries/tikzlibraryquotes.code.tex | 88 + .../tikz/libraries/tikzlibrarysnakes.code.tex | 4 +- .../tikz/libraries/tikzlibraryspy.code.tex | 10 +- .../tikz/libraries/tikzlibrarysvg.path.code.tex | 8 +- .../generic/pgf/frontendlayer/tikz/tikz.code.tex | 1697 +++++++++++---- 30 files changed, 8866 insertions(+), 1328 deletions(-) delete mode 100644 Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.basic.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.standard.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybabel.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybending.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymath.code.tex create mode 100644 Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryquotes.code.tex (limited to 'Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz') diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.code.tex index 693da7c5907..e8aeabd2468 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.code.tex @@ -77,8 +77,8 @@ } } \newcount\tikz@lib@circ@count -\def\tikz@zero@text{0} -\def\tikz@one@text{1} +\def\tikz@zero@text{0.0} +\def\tikz@one@text{1.0} \def\tikz@lib@circ@compute@direction#1{% \tikz@scan@one@point\tikz@lib@circ@save@start(\tikztostart)% @@ -176,6 +176,7 @@ [annotation arrow,->] [label distance=#2,##1] #3 + \tikz@after@path% \egroup% } }, @@ -189,6 +190,7 @@ [annotation arrow,->] [label distance=#2,##1] #3 + \tikz@after@path% \egroup% } } @@ -251,13 +253,15 @@ \def\tikz@lib@circ@lab[#1]#2\pgf@stop#3#4{\tikzset{label={[every info/.try,every #4/.try,#1]$\mathrm{#2#3}$}}} \def\tikz@lib@circ@lab@sloped[#1]#2\pgf@stop#3#4{\tikzset{label={[every info/.try,every #4/.try,transform shape,#1]$\mathrm{#2#3}$}}} -\def\tikz@lib@circ@labp[#1]#2\pgf@stop#3#4{\tikzset{label={[every info/.try,every #4/.try,#1]below:$\mathrm{#2#3}$}}} -\def\tikz@lib@circ@lab@slopedp[#1]#2\pgf@stop#3#4{\tikzset{label={[every info/.try,every #4/.try,transform shape,#1]below:$\mathrm{#2#3}$}}} +\def\tikz@lib@circ@labp[#1]#2\pgf@stop#3#4{\tikzset{label={[label position=below,every info/.try,every #4/.try,#1]$\mathrm{#2#3}$}}} +\def\tikz@lib@circ@lab@slopedp[#1]#2\pgf@stop#3#4{\tikzset{label={[label +position=below,every info/.try,every #4/.try,transform shape,#1]$\mathrm{#2#3}$}}} \def\tikz@lib@circ@lab@plain[#1]#2\pgf@stop{\tikzset{label={[every info/.try,#1]#2}}} \def\tikz@lib@circ@lab@sloped@plain[#1]#2\pgf@stop{\tikzset{label={[every info/.try,transform shape,#1]#2}}} -\def\tikz@lib@circ@labp@plain[#1]#2\pgf@stop{\tikzset{label={[every info/.try,#1]below:#2}}} -\def\tikz@lib@circ@lab@slopedp@plain[#1]#2\pgf@stop{\tikzset{label={[every info/.try,transform shape,#1]below:#2}}} +\def\tikz@lib@circ@labp@plain[#1]#2\pgf@stop{\tikzset{label={[label position=below,every info/.try,#1]#2}}} +\def\tikz@lib@circ@lab@slopedp@plain[#1]#2\pgf@stop{\tikzset{label={[label +position=below,every info/.try,transform shape,#1]#2}}} diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.ee.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.ee.code.tex index 91641309ab5..d8337acefcd 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.ee.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/circuits/tikzlibrarycircuits.ee.code.tex @@ -127,29 +127,15 @@ (.2\tikzcircuitssizeunit,.65\tikzcircuitssizeunit) edge[line to] ++(-45:1.25\tikzcircuitssizeunit) (-.2\tikzcircuitssizeunit,.25\tikzcircuitssizeunit) edge[line to] ++(-45:1.25\tikzcircuitssizeunit) }, - adjustable/.style={ - append after command={% - \bgroup - [current point is local=true] - [every adjustable/.try] - [annotation arrow,->] - let \p1=(\tikzlastnode.north), \p2=(\tikzlastnode.south) in - [label distance=1.5\tikzcircuitssizeunit-.5*abs(\y2-\y1),#1] - (-1.5\tikzcircuitssizeunit,-1.5\tikzcircuitssizeunit) edge[line to] (1.5\tikzcircuitssizeunit,1.5\tikzcircuitssizeunit) - \egroup% - } + circuit declare annotation={adjustable}{1.5\tikzcircuitssizeunit} + { + [shift=(\tikzlastnode.center)] + (-1.5\tikzcircuitssizeunit,-1.5\tikzcircuitssizeunit) edge[line to] (1.5\tikzcircuitssizeunit,1.5\tikzcircuitssizeunit) }, - adjustable'/.style={ - append after command={% - \bgroup - [current point is local=true,yscale=-1] - [every adjustable/.try] - [annotation arrow,->] - let \p1=(\tikzlastnode.north), \p2=(\tikzlastnode.south) in - [label distance=1.5\tikzcircuitssizeunit-.5*abs(\y2-\y1),#1] - (-1.5\tikzcircuitssizeunit,-1.5\tikzcircuitssizeunit) edge[line to] (1.5\tikzcircuitssizeunit,1.5\tikzcircuitssizeunit) - \egroup% - } + circuit declare annotation={adjustable'}{1.5\tikzcircuitssizeunit} + { + [shift=(\tikzlastnode.center)] + (-1.5\tikzcircuitssizeunit,1.5\tikzcircuitssizeunit) edge[line to] (1.5\tikzcircuitssizeunit,-1.5\tikzcircuitssizeunit) } } diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.code.tex index c717e95cf7b..e181c3b97ab 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.code.tex,v 1.31 2010/09/15 22:27:36 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.code.tex,v 1.44 2013/07/19 13:16:48 tantau Exp $ \usepgfmodule{datavisualization} \usetikzlibrary{backgrounds} @@ -60,14 +60,29 @@ % /tikz/every data is executed for each data, which can be useful to % generally set, say, a certain data format. % -% "info" blocks. % -% Syntax: info [options] {code} +% "data set" blocks. +% +% Syntax: data set [options] {name} = { ... } +% Syntax: data set [options] {name} += { ... } +% Syntax: data set [options] {name} +% +% The first syntax allows you to define a data set. The data block +% inside {...} will be stored inside the data set +% "name". Subsequently, the data set can be referenced by using the +% third syntax. The second syntax allows you to extend the +% definition of an already defined data set. +% +% +% "info" and "info'" blocks. +% +% Syntax: info [options] {code} +% Syntax: info' [options] {code} +% +% A block starting with "info" or "info'" may contain any code. It +% will be executed after the visualization (info) or before the +% visualization (info'). % -% A block starting with "info" may contain any code. It -% will be executed after the visualization. In order to execute code -% at some other time (like, say, before the visualization), use -% options like "before visualization". % % Options blocks. % @@ -103,7 +118,7 @@ % var x: interval [0:3]; % func y = \value x*\value x; % } -% [before visualization={ +% [at begin visualization={ % \fill [black!10] (visualization cs:x=0,y=0) -- (visualization cs:x=3,y=9); % }] % info[red] @@ -121,6 +136,7 @@ \def\tikz@lib@datavisualization{ \begingroup% + \let\tikz@path@do@at@end=\relax% % Ok, first, start a new data visualization \pgfoonew \tikz@main@dv=new data visualization()% % Next, create a scope for the dv @@ -141,6 +157,7 @@ \tikz@main@dv.before visualization(% )% \tikz@main@dv.after visualization(% + \tikz@lib@dv@alias@dv@bb \pgfkeysvalueof{/tikz/data visualization/grid actions} \pgfkeysvalueof{/tikz/data visualization/subminor grid actions} \pgfkeysvalueof{/tikz/data visualization/minor grid actions} @@ -167,7 +184,7 @@ \pgfutil@ifnextchar i\tikz@lib@dv@handle@info{% \pgfutil@ifnextchar [\tikz@lib@dv@handle@options{% \pgfutil@ifnextchar \egroup\tikz@lib@dv@handle@endscope{% - \PackageError{tikz}{Semicolon expected}{}% + \tikzerror{Semicolon expected}% \endgroup% }% }% @@ -177,11 +194,12 @@ }% }% } -\def\tikz@lib@dv@parse@end{% +\def\tikz@lib@dv@parse@end;{% % Go! \tikz@main@dv.survey()% \tikz@main@dv.visualize()% \endgroup% + \tikz@path@do@at@end% } \def\tikz@lib@dv@handle@par\par{\tikz@lib@dv@parse@loop} @@ -196,27 +214,74 @@ } \def\tikz@lib@dv@beg@opt[#1]{% \pgfkeys{/pgf/data/.cd,/pgf/every data/.try,#1}% - \pgfkeysvalueof{/pgf/data visualization/obj}.add data({{\begingroup\pgfkeys{/pgf/data/.cd,/pgf/every data/.try,#1}}})% + \pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data({{\begingroup\pgfkeys{/pgf/data/.cd,/pgf/every data/.try,#1}}})}% \pgfutil@ifnextchar\bgroup{ \afterassignment\tikz@lib@dv@parse@loop% \let\tikz@dummy=%get rid of \bgroup }{% - \PackageError{pgf}{Opening brace expected}{}% + \tikzerror{Opening brace expected}% + \tikz@lib@dv@parse@loop% }% } \def\tikz@lib@dv@handle@endscope{% - \pgfkeysvalueof{/pgf/data visualization/obj}.add data(\endgroup)% + \pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data(\endgroup)}% \endgroup% \afterassignment\tikz@lib@dv@parse@loop% \let\tikz@dummy=%get rid of \egroup } -\def\tikz@lib@dv@handle@data data{\pgfdata} +\def\tikz@lib@dv@handle@data data{% + \pgfutil@ifnextchar g{\tikz@lib@dv@handle@data@group}{% + \pgfutil@ifnextchar p{\tikz@lib@dv@handle@data@point}{% + \pgfdata}}} + +\def\tikz@lib@dv@handle@data@group group{\pgfutil@ifnextchar[{\tikz@lib@dv@handle@data@group@opt}{\tikz@lib@dv@handle@data@group@opt[]}}%} + +\def\tikz@lib@dv@handle@data@group@opt[#1]#2{% + \pgfutil@ifnextchar={\tikz@lib@dv@handle@data@group@def{#1}{#2}}{% + \pgfutil@ifnextchar+{\tikz@lib@dv@handle@data@group@extend{#1}{#2}}{% + \tikz@lib@dv@handle@data@group@use{#1}{#2}}}} + +\def\tikz@lib@dv@handle@data@group@def#1#2={% + \pgfkeys{/pgf/data/new group=#2}% + \tikz@lib@dv@handle@data@group@extend{#1}{#2}+=% +} + +\def\tikz@lib@dv@handle@data@group@extend#1#2+={% + \pgfutil@ifnextchar\bgroup{ + \begingroup% + \pgfkeys{/pgf/data/store in group=#2}% + \pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data({{\begingroup\pgfkeys{/pgf/data/.cd,/pgf/every data/.try,#1}}})}% + \afterassignment\tikz@lib@dv@parse@loop% + \let\tikz@dummy=%get rid of \bgroup + }{% + \tikzerror{Opening brace expected}% + \tikz@lib@dv@parse@loop% + }% +} + +\def\tikz@lib@dv@handle@data@group@use#1#2{% + \pgfdata[#1,use group=#2]% +} + +\def\tikz@lib@dv@handle@data@point point{\pgfutil@ifnextchar[{\tikz@lib@dv@handle@data@point@opt}{\tikz@lib@dv@handle@data@point@opt[]}}%] +\def\tikz@lib@dv@handle@data@point@opt[#1]{% + \pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data({{\bgroup\pgfkeys{/data point/.cd,#1}\pgfdatapoint\egroup}})}% + \tikz@lib@dv@parse@loop% +} -\def\tikz@lib@dv@handle@info info{ +\def\tikz@lib@dv@handle@info info{% + \pgfutil@ifnextchar'{\tikz@lib@dv@handle@info@prime}{\tikz@lib@dv@handle@info@noprime}} +\def\tikz@lib@dv@handle@info@noprime{% \pgfutil@ifnextchar[{\tikz@lib@dv@handle@info@block@opt}{\tikz@lib@dv@handle@info@block@opt[]}}%} \def\tikz@lib@dv@handle@info@block@opt[#1]#2{% - \tikz@main@dv.after visualization({{\scope[#1]#2\endscope}})% + \tikz@main@dv.after visualization({\scope[#1]#2\endscope})% + \tikz@lib@dv@parse@loop +} +\def\tikz@lib@dv@handle@info@prime'{% + \pgfutil@ifnextchar[{\tikz@lib@dv@handle@info@block@opt@prime}{\tikz@lib@dv@handle@info@block@opt@prime[]}}%} +\def\tikz@lib@dv@handle@info@block@opt@prime[#1]#2{% + \tikz@main@dv.before visualization({\scope[#1]#2\endscope})% \tikz@lib@dv@parse@loop } @@ -229,17 +294,31 @@ % \tikzdatavisualizationset{ - before survey/.code=\tikz@main@dv.before survey({{#1}}), - after survey/.code=\tikz@main@dv.after survey({{#1}}), - before visualization/.code=\tikz@main@dv.before visualization({{#1}}), - after visualization/.code=\tikz@main@dv.after visualization({{#1}}), - at start survey/.code=\tikz@main@dv.at start survey({{#1}}), - at end survey/.code=\tikz@main@dv.at end survey({{#1}}), - at start visualization/.code=\tikz@main@dv.at start visualization({{#1}}), - at end visualization/.code=\tikz@main@dv.at end visualization({{#1}}), + before survey/.code=\tikz@main@dv.before survey({#1}), + after survey/.code=\tikz@main@dv.after survey({#1}), + before visualization/.code=\tikz@main@dv.before visualization({#1}), + after visualization/.code=\tikz@main@dv.after visualization({#1}), + at start survey/.code=\tikz@main@dv.at start survey({#1}), + at end survey/.code=\tikz@main@dv.at end survey({#1}), + at start visualization/.code=\tikz@main@dv.at start visualization({#1}), + at end visualization/.code=\tikz@main@dv.at end visualization({#1}), } +\def\tikz@lib@dv@alias@dv@bb{ + \pgfnodealias{data bounding box}{data visualization bounding box}% + \pgfkeys{/pgf/freeze local bounding box=data bounding box}% +} + +% +% The data point key +% +\tikzdatavisualizationset{ + data point/.code={ + \pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data({{\bgroup\pgfkeys{/data point/.cd,#1}\pgfdatapoint\egroup}})}% + } +} + % % Object setup @@ -409,7 +488,7 @@ % \tikzdatavisualizationset{% - new axis/.style={ + new axis base/.style={ new object={ class=scaling mapper, store=/tikz/data visualization/#1/scaling mapper, @@ -462,8 +541,6 @@ node styling/.style={% /utils/exec={\pgfkeysgetvalue{/tikz/data visualization/@node styling}\tikz@temp\expandafter\tikzset\expandafter{\tikz@temp}}}, node style/.style={/tikz/data visualization/@node styling/.append={,#1}}, - grid styling/.style=, - grid style/.style={grid styling/.append style={#1}}, % General extends (both axes, grid and ticks) low/.initial=0, high/.initial=0, @@ -483,20 +560,31 @@ @setup at setters, % Tick keys direction axis/.initial=, - value/.initial=, - pos/.initial=, + % Tick text modifiers + tick text low even padding/.initial=0pt, + tick text high even padding/.initial=0pt, + tick text low odd padding/.initial=0pt, + tick text high odd padding/.initial=0pt, + tick text odd padding/.style={tick text low odd padding={-#1},tick text high odd padding={#1}}, + tick text even padding/.style={tick text low even padding={-#1},tick text high even padding={#1}}, + tick text padding/.style={tick text odd padding={#1},tick text even padding={#1}}, + stack/.style={tick text even padding={#1}}, + stack'/.style={tick text odd padding={#1}}, + stack/.default=1em, + stack'/.default=1em, tick text at low/.is if=tikz@dv@min@tick@node, tick text at high/.is if=tikz@dv@max@tick@node, no tick text/.style={tick text at low=false,tick text at high=false}, + % every major ticks/.style={style={line cap=round},tick length=2pt}, - every minor ticks/.style={style={help lines,thin,line cap=round},tick length=1.4pt}, - every subminor ticks/.style={style={help lines,line cap=round},tick length=0.8pt}, + every minor ticks/.style={style={solid, help lines,thin,line cap=round},tick length=1.4pt}, + every subminor ticks/.style={style={solid, help lines,line cap=round},tick length=0.8pt}, clean ticks/.style={node style={fill=white}}, % Default grid styles - grid style={high=max,low=min}, - every major grid/.style={style={help lines,thin,black!25}}, - every minor grid/.style={style={help lines,black!25}}, - every subminor grid/.style={style={help lines,black!10}}, + every grid/.style={high=max,low=min}, + every major grid/.style={style={solid, help lines,thin,black!25}}, + every minor grid/.style={style={solid, help lines,black!25}}, + every subminor grid/.style={style={solid, help lines,black!10}}, at default ticks/.code={% \expandafter\pgfkeysalso\expandafter{\tikz@lib@dv@ticks@default@at}}, at ticks/.code={% @@ -549,21 +637,21 @@ rounded corners=1.5pt } }, - every visualizer label/.style={ + every data set label/.style={ every ticks, node style={ - font=\pgfutil@font@small + font=\pgfutil@font@small, } }, @color of visualizer labels/.style={text=black}, - every visualizer legend label/.style={ + every label in legend/.style={ node style={ - fill=none + fill=none, } }, every axis label/.style={ node style={% - font=\pgfutil@font@small + font=\pgfutil@font@small, } } } @@ -580,7 +668,15 @@ padding min/.style={\tikz@dv@axis/padding min={#1}}, padding max/.style={\tikz@dv@axis/padding max={#1}}, padding/.style={padding min={-#1},padding max={#1}}, - label/.style={\tikz@dv@axis/label={#1}}, + label/.code={% + \def\pgf@temp{#1}% + \ifx\pgf@temp\tikz@lib@dv@auto@attribute% + \tikzdatavisualizationset{\tikz@dv@axis/label/.expanded=$\noexpand\mathit{\pgfkeysvalueof{\tikz@dv@axis/attribute}}$}% + \else + \tikzdatavisualizationset{\tikz@dv@axis/label={#1}}% + \fi + }, + label/.default=\tikz@lib@dv@auto@attribute, % % Strategies % @@ -590,17 +686,9 @@ % Attribute setter % goto/.code={\tikz@dv@goto{\tikz@dv@axis}{#1}}, - % - % Modification of the range - % - include values/.style={% - /tikz/data visualization/before survey/.expanded={% - \noexpand\pgfkeysgetvalue{\tikz@dv@axis/scaling mapper}\noexpand\tikz@dv@axis@mapper% - \noexpand\foreach \noexpand\tikz@lib@dv@temp in {#1} {% - \noexpand\tikz@dv@axis@mapper.include in value(\noexpand\tikz@lib@dv@temp)% - }% - }% - }, + goto pos/.code={\tikz@dv@goto@pos{\tikz@dv@axis}{#1}}, + anchor at min/.code={\tikz@lib@dv@special@at{\tikz@dv@axis}{\tikz@dv@min@anchor}}, + anchor at max/.code={\tikz@lib@dv@special@at{\tikz@dv@axis}{\tikz@dv@max@anchor}}, % % Visualization setters % @@ -609,6 +697,7 @@ % Ticks settings % ticks/.style={\tikz@dv@axis/ticks at/.append={,#1}}, + ticks/.default=some, visualize ticks/.code=\expandafter\tikz@lib@dv@tv\expandafter{\tikz@dv@axis}{#1}, % % Grid settings @@ -617,11 +706,52 @@ grid/.default=at default ticks, visualize grid/.code=\expandafter\tikz@lib@dv@gv\expandafter{\tikz@dv@axis}{#1}, % + ticks and grid/.style={\tikz@dv@axis/ticks at/.append={,#1},\tikz@dv@axis/grid at/.append={,#1}}, + % % Visualizing axis labels % visualize label/.code=\expandafter\tikz@lib@dv@lv\expandafter{\tikz@dv@axis}{#1}, } +\def\tikz@lib@dv@auto@attribute{\tikz@lib@dv@auto@attribute} + + +% Range options +\tikzdatavisualizationset{ + axis options/.cd, + % + % Including a value in the range + % + include value/.style={% + /tikz/data visualization/before survey/.expanded={% + \noexpand\pgfkeysgetvalue{\tikz@dv@axis/scaling mapper}\noexpand\tikz@dv@axis@mapper% + \noexpand\foreach \noexpand\tikz@lib@dv@temp in {#1} {% + \noexpand\tikz@dv@axis@mapper.include in value(\noexpand\tikz@lib@dv@temp)% + }% + }% + }, + % + % Directly setting the min or max + % + min value/.style={ + /tikz/data visualization/at end survey/.expanded={% + \noexpand\pgfkeysgetvalue{\tikz@dv@axis/scaling mapper}\noexpand\tikz@dv@axis@mapper% + \noexpand\tikz@lib@dv@set\noexpand\tikz@dv@axis@mapper{#1}{min}% + } + }, + max value/.style={ + /tikz/data visualization/at end survey/.expanded={% + \noexpand\pgfkeysgetvalue{\tikz@dv@axis/scaling mapper}\noexpand\tikz@dv@axis@mapper% + \noexpand\tikz@lib@dv@set\noexpand\tikz@dv@axis@mapper{#1}{max}% + } + }, +} + +\def\tikz@lib@dv@set#1#2#3{% + \pgfdvmathenter{\pgf@dv@value}{#2}% + #1.get in range interval()% + \pgfdvinrangeinterval.let #3(\pgf@dv@value)% +} % Layer options \tikzdatavisualizationset{ @@ -664,15 +794,15 @@ } \def\tikz@dv@goto#1#2{% - \edef\pgf@temp{#2}% - \ifx\pgf@temp\tikz@lib@dv@padded@min@text% + \edef\pgf@@temp{#2}% + \ifx\pgf@@temp\tikz@lib@dv@padded@min@text% \pgfkeysvalueof{#1/scaling mapper}.set in to(min)% \pgfkeysvalueof{#1/scaling mapper}.get out()% \pgfkeysgetvalue{#1/padding min}\pgf@temp% \pgfmathparse{\pgf@temp}% \pgfkeyslet{/data point/\pgfdvout/offset}\pgfmathresult% \else% - \ifx\pgf@temp\tikz@lib@dv@padded@max@text% + \ifx\pgf@@temp\tikz@lib@dv@padded@max@text% \pgfkeysvalueof{#1/scaling mapper}.set in to(max)% \pgfkeysvalueof{#1/scaling mapper}.get out()% \pgfkeysgetvalue{#1/padding max}\pgf@temp% @@ -682,10 +812,21 @@ \pgfkeysvalueof{#1/scaling mapper}.set in to(#2)% \fi% \fi% -} +} + +\def\tikz@dv@goto@pos#1#2{% + \pgfkeyssetvalue{/data point/\pgfkeysvalueof{#1/attribute}/out pos}{#2}% +} \def\tikz@lib@dv@padded@min@text{padded min} \def\tikz@lib@dv@padded@max@text{padded max} + +\def\tikz@lib@dv@special@at#1#2{% + % Ok, calculate direction vector: + \tikzpointandanchordirection{\pgfkeysvalueof{#1/scaling mapper}.set in to(min)}{\pgfkeysvalueof{#1/scaling mapper}.set in to(max)} + \tikzset{anchor/.expanded=#2} +} + % Ticks visualization % @@ -743,19 +884,22 @@ {% \let\tikz@dv@at@list\pgfutil@empty% \let\tikz@dv@style@at@list\pgfutil@empty% + \pgfkeysgetvalue{#2/scaling mapper}\tikz@lib@dv@mapper + \expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@settings}% \scope[/tikz/data visualization/.cd,every ticks/.try,every #1 ticks/.try,#3]% % Setup options - \pgfkeysgetvalue{#2/scaling mapper}\tikz@lib@dv@mapper - \expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@settings}% \pgfkeysgetvalue{/tikz/data visualization/common}\tikz@temp \expandafter\tikzdatavisualizationset\expandafter{\tikz@temp} \pgfkeysgetvalue{/tikz/data visualization/#1}\tikz@temp \expandafter\tikzdatavisualizationset\expandafter{\tikz@temp} \pgfkeysgetvalue{/tikz/data visualization/\pgfkeysvalueof{/tikz/data visualization/direction axis}/scaling mapper}\pgf@dv@tick@dir@mapper % Ok, now it's time to draw the ticks! - \foreach \tikz@dv@tick@pos in \tikz@dv@at@list + \foreach \tikz@dv@tick@pos[count=\tikz@dv@tick@count] in \tikz@dv@at@list { \ifx\tikz@dv@tick@pos\pgfutil@empty + \c@pgf@counta=\tikz@dv@tick@count\relax% + \advance\c@pgf@counta by-1\relax% + \edef\tikz@dv@tick@count{\the\c@pgf@counta}% \else \expandafter\tikz@lib@dv@parse\tikz@dv@tick@pos\pgf@stop% \expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@tick@opt}% @@ -768,15 +912,40 @@ \xdef\pgf@dv@tick@dir{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}} % Now, show something: \tikz@lib@handle@at@style% - \scope[/tikz/data visualization/styling] - \pgf@process{\pgfpointadd{\pgf@dv@tick@origin}{\pgfpointscale{\pgfkeysvalueof{/tikz/data visualization/high}}{\pgf@dv@tick@dir}}} - \xdef\tikz@dv@max@tick{\the\pgf@x,\the\pgf@y} - \pgf@process{\pgfpointadd{\pgf@dv@tick@origin}{\pgfpointscale{\pgfkeysvalueof{/tikz/data visualization/low}}{\pgf@dv@tick@dir}}} - \xdef\tikz@dv@min@tick{\the\pgf@x,\the\pgf@y} - \scope[data visualization/ticks layer] \draw (\tikz@dv@min@tick) -- (\tikz@dv@max@tick); \endscope - \iftikz@dv@min@tick@node \scope[data visualization/ticks node layer] \path (\tikz@dv@min@tick) \tikz@dv@handle@tick{\tikz@dv@min@anchor}; \endscope \fi - \iftikz@dv@max@tick@node \scope[data visualization/ticks node layer] \path (\tikz@dv@max@tick) \tikz@dv@handle@tick{\tikz@dv@max@anchor}; \endscope\fi + \pgfkeysgetvalue{/tikz/data visualization/high}\tikz@dv@max@val% + \pgfkeysgetvalue{/tikz/data visualization/low}\tikz@dv@min@val% + \iftikz@dv@max@tick@node\pgfmathsetmacro\tikz@dv@max@val{% + \tikz@dv@max@val+(\pgfkeysvalueof{% + /tikz/data visualization/tick text high + \ifodd\tikz@dv@tick@count odd \else even \fi padding}% + )}% + \fi% + \iftikz@dv@min@tick@node\pgfmathsetmacro\tikz@dv@min@val{% + \tikz@dv@min@val+(\pgfkeysvalueof{% + /tikz/data visualization/tick text low + \ifodd\tikz@dv@tick@count odd \else even \fi padding}% + )}% + \fi% + \pgf@process{\pgfpointadd{\pgf@dv@tick@origin}{\pgfpointscale{\tikz@dv@max@val}{\pgf@dv@tick@dir}}} + \xdef\tikz@dv@max@tick{\the\pgf@x,\the\pgf@y} + \pgf@process{\pgfpointadd{\pgf@dv@tick@origin}{\pgfpointscale{\tikz@dv@min@val}{\pgf@dv@tick@dir}}} + \xdef\tikz@dv@min@tick{\the\pgf@x,\the\pgf@y} + \scope[data visualization/ticks layer] + \tikzdatavisualizationset{every \ifodd\tikz@dv@tick@count odd \else even \fi tick/.try} + \draw [/tikz/data visualization/styling] (\tikz@dv@min@tick) -- (\tikz@dv@max@tick); \endscope + \iftikz@dv@min@tick@node + \scope[data visualization/ticks node layer] + \tikzdatavisualizationset{every \ifodd\tikz@dv@tick@count odd \else even \fi tick/.try} + \path [/tikz/data visualization/styling] (\tikz@dv@min@tick) \tikz@dv@handle@tick{\tikz@dv@min@anchor}; + \endscope + \fi + \iftikz@dv@max@tick@node + \scope[data visualization/ticks node layer] + \tikzdatavisualizationset{every \ifodd\tikz@dv@tick@count odd \else even \fi tick/.try} + \path [/tikz/data visualization/styling] (\tikz@dv@max@tick) \tikz@dv@handle@tick{\tikz@dv@max@anchor}; + \endscope + \fi \fi } \endscope @@ -808,7 +977,7 @@ \pgfdvmathenter{\tikz@lib@dv@typesetnum}{\tikz@dv@tick@pos}% \pgfdvmathexitbyscientificformat{\tikz@lib@dv@typesetnum}{\tikz@lib@dv@typesetnum}% hmm... not sure about this... \pgfkeysvalueof{/tikz/data visualization/tick prefix}% - \pgfkeysvalueof{/tikz/data visualization/tick typesetter}{\tikz@lib@dv@typesetnum}% + \pgfkeys{/tikz/data visualization/tick typesetter=\tikz@lib@dv@typesetnum}% \pgfkeysvalueof{/tikz/data visualization/tick suffix}% } @@ -860,7 +1029,7 @@ % Help function \def\tikzpointandanchordirection#1#2{% % This function works like pgfpointdvdirection, but also computes - % appriate "min" and "max" anchors. + % appropriate "min" and "max" anchors. \pgf@process{\pgfpointdvdirection{#1}{#2}} { \pgf@ya=\pgf@y @@ -907,10 +1076,10 @@ {% \let\tikz@dv@at@list\pgfutil@empty \let\tikz@dv@style@at@list\pgfutil@empty - \scope[data visualization/grid layer,/tikz/data visualization/.cd,every #1 grid/.try,grid styling,grid styling/.style=,#3] + \pgfkeysgetvalue{#2/scaling mapper}\tikz@lib@dv@mapper + \let\tikz@lib@dv@ticks@default@at\pgfutil@empty% + \scope[data visualization/grid layer,/tikz/data visualization/.cd,every grid,every #1 grid/.try,#3] % Setup options - \pgfkeysgetvalue{#2/scaling mapper}\tikz@lib@dv@mapper - \let\tikz@lib@dv@ticks@default@at\pgfutil@empty% \pgfkeysgetvalue{#2/ticks at}\tikz@lib@dv@ticks@at% \expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@settings}% \pgfkeysgetvalue{/tikz/data visualization/common}\tikz@temp @@ -925,7 +1094,6 @@ \else \expandafter\tikz@lib@dv@parse\tikz@dv@grid@pos\pgf@stop% \expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@tick@opt}% - \tikzdatavisualizationset{grid styling}% \tikz@lib@dv@mapper.set in to(\tikz@dv@tick@pos)% \draw[/tikz/data visualization/styling] \pgfextra{ @@ -966,46 +1134,17 @@ \ifx\tikz@dv@lib@label\pgfutil@empty% % Great, nothing to do \else - \scope[/tikz/data visualization/.cd,every axis label/.try,#2] - \pgfkeysgetvalue{/tikz/data visualization/value}\tikz@lib@dv@at% - \pgfkeysgetvalue{/tikz/data visualization/pos}\tikz@lib@dv@pos% - \pgfkeysgetvalue{#1/scaling mapper}\tikz@dv@mapper - \ifx\tikz@lib@dv@pos\pgfutil@empty% - \ifx\tikz@lib@dv@at\pgfutil@empty% - % Well, hopefully the node options setup things correctly... - \else% - % Special treatment of "min" and "max" - \ifx\tikz@lib@dv@at\pgf@min@text% - \tikz@lib@dv@special@at{\tikz@dv@min@anchor} - \else \ifx\tikz@lib@dv@at\tikz@lib@dv@padded@min@text% - \tikz@lib@dv@special@at{\tikz@dv@min@anchor} - \else \ifx\tikz@lib@dv@at\pgf@max@text% - \tikz@lib@dv@special@at{\tikz@dv@max@anchor} - \else \ifx\tikz@lib@dv@at\tikz@lib@dv@padded@max@text% - \tikz@lib@dv@special@at{\tikz@dv@max@anchor} - \fi\fi\fi\fi% - \tikz@dv@goto{#1}{\tikz@lib@dv@at}% - \pgftransformshift{\pgfpointdvlocaldatapoint}% - \fi% - \else% - \tikz@dv@mapper.set in to(min)% - \pgftransformshift{\pgfpointscale{1-\tikz@lib@dv@pos}{\pgfpointdvlocaldatapoint}} - \tikz@dv@mapper.set in to(max)% - \pgftransformshift{\pgfpointscale{\tikz@lib@dv@pos}{\pgfpointdvlocaldatapoint}} - \fi + \scope[anchor=center,/tikz/data visualization/.cd,every axis label/.try,#2] \expandafter\tikz@lib@dv@parse@node\tikz@dv@lib@label\pgf@stop \endscope \fi } -\def\tikz@lib@dv@special@at#1{% - % Ok, calculate direction vector: - \tikzpointandanchordirection{\tikz@dv@mapper.set in to(min)}{\tikz@dv@mapper.set in to(max)} - \tikzset{anchor=#1} -} \def\tikz@lib@dv@parse@node{\pgfutil@ifnextchar[\tikz@lib@dv@parse@node@opt{\tikz@lib@dv@parse@node@opt[]}}%} \def\tikz@lib@dv@parse@node@opt[#1]#2\pgf@stop{ - \node [/tikz/data visualization/node styling,#1] {#2}; + \tikzdatavisualizationset{#1} + \pgftransformshift{\pgfpointdvlocaldatapoint}% + \node [/tikz/data visualization/node styling] {#2}; } @@ -1020,10 +1159,10 @@ minor steps between steps/.initial=, minor steps between steps/.default=9, phase/.initial=0, - tick typesetter/.initial=\pgfmathprintnumber, + tick typesetter/.code=\pgfmathprintnumber{#1}, tick prefix/.initial=, tick suffix/.initial=, - tick unit/.style={tick suffix={#1}},% this is an alias + tick unit/.style={tick suffix={$\,\rm#1$}},% this is an alias } \def\tikz@lib@dv@compute@at@linear{% @@ -1111,6 +1250,7 @@ standard about strategy/.style={about strategy={1.5/1.0,2.3/2.0,4/2.5,7/5,11/10}}, standard about strategy, euro about strategy/.style={about strategy={1.5/1.0,3/2.0,7/5,11/10}}, + decimal about strategy/.style={about strategy={3/1.0,11/10}}, half about strategy/.style={about strategy={2/1.0,7/5,11/10}}, quarter about strategy/.style={about strategy={1.8/1.0,4/2.5,7/5,11/10}}, int about strategy/.style={about strategy={1.5/1.0,2.5/2.0,3.5/3.0,4.5/4.0,7/5,11/10}}, @@ -1269,7 +1409,7 @@ \tikzdatavisualizationset{% new Cartesian axis/.style={ - new axis={#1}, + new axis base={#1}, new object={ class=linear transformer, store=/tikz/data visualization/#1/linear transformer, @@ -1277,7 +1417,7 @@ arg2 from key=/tikz/data visualization/#1/unit vector, }, #1/scaling/default/.initial=0 at 0 and 1 at 1cm, - #1/unit vector/.initial=, + #1/unit vector/.initial=\pgfqpoint{1pt}{0pt}, } } @@ -1285,8 +1425,6 @@ /tikz/data visualization/axis options/.cd, unit vector/.code=\tikz@scan@one@point\tikz@lib@dv@uv#1, length/.style={\tikz@dv@axis/scaling=min at 0 and max at #1}, - positive length/.style={\tikz@dv@axis/scaling=0 at 0 and max at #1}, - negative length/.style={\tikz@dv@axis/scaling=min at -#1 and 0 at 0}, unit length/.code={\tikz@dv@parse@unit@length{#1}}, power unit length/.style={\tikz@dv@axis/scaling=1 at 0 and 10 at #1} } @@ -1313,34 +1451,62 @@ % \tikzdatavisualizationset{ - new visualizer/.style 2 args={ - /pgf/data/#1/.style={/data point/visualizer=#1}, + new visualizer/.style n args={3}{ #1/.code={ \def\tikz@visualizer{#1}% \pgfkeys{/tikz/data visualization/visualizer options/.cd,##1} + \pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data(\pgfkeys{/data point/set=#1})}% }, /utils/exec={ \advance\tikzdvvisualizercounter by 1\relax - \edef\tikz@temp{/data point/visualizer/#1/.initial=\the\tikzdvvisualizercounter} + \edef\tikz@temp{/data point/set/#1/.initial=\the\tikzdvvisualizercounter} \expandafter\tikzset\expandafter{\tikz@temp} }, /data point/#1/execute at begin/.initial={ - \pgfkeyssetvalue{/data point/visualizer}{#1} + \pgfkeyssetvalue{/data point/set}{#1} \scope[ - /tikz/data visualization/every visualizer/.try, #2, - /utils/exec=\pgf@signalstyle.emit(), + /tikz/data visualization/every visualizer/.try, + /tikz/data visualization/visualizers/#1/signal, /tikz/data visualization/visualizers/#1/styling/.try] }, /data point/#1/execute at end/.initial={ \path; % invokes every path implicitly \endscope }, + /tikz/data visualization/visualizers/#1/signal/.code=\pgf@signalstyle.emit(), /tikz/data visualization/visualizers/#1/styling/.style=, + /tikz/data visualization/visualizers/#1/label in legend options/.style={#3}, }, - visualizer style sheet/.style={/data point/visualizer/.style sheet={#1}} + style sheet/.style={/data point/set/.style sheet={#1}}, + /pgf/data/set/.style={/data point/set=#1}, +} + +\tikzdatavisualizationset{ + new sub visualizer/.style n args={4}{ + #4/#1/.code={ + \def\tikz@visualizer{#4/#1}% + \pgfkeys{/tikz/data visualization/visualizer options/.cd,##1} + }, + /data point/#4/#1/execute at begin/.initial={ + \pgfkeyssetvalue{/data point/set}{#4} + \scope[ + #2, + /tikz/data visualization/every visualizer/.try, + /tikz/data visualization/visualizers/#4/signal, + /tikz/data visualization/visualizers/#4/styling/.try, + /tikz/data visualization/visualizers/#4/#1/styling/.try] + }, + /data point/#4/#1/execute at end/.initial={ + \path; % invokes every path implicitly + \endscope + }, + /tikz/data visualization/visualizers/#4/#1/styling/.style=, + /tikz/data visualization/visualizers/#4/#1/label in legend options/.style={#3}, + } } + \def\tikz@do@visualizer#1#2{% \tikzdatavisualizationset{ #2=#1 @@ -1351,16 +1517,19 @@ \newif\iftikz@dv@visualizer@label@inline -\tikzset{ - @set plot handler/.code={\let\tikz@plot@handler=#1}, - no lines/.style={@set plot handler=\pgfplothandlerdiscard,/utils/exec=\tikzdatavisualizationset{default label in legend mark}}, - smooth line/.style={@set plot handler=\pgfplothandlercurveto,/utils/exec=\tikzdatavisualizationset{default label in legend path}}, - smooth cycle/.style={@set plot handler=\pgfplothandlerclosedcurve,/utils/exec=\tikzdatavisualizationset{default label in legend closed path}}, - straight line/.style={@set plot handler=\pgfplothandlerlineto,/utils/exec=\tikzdatavisualizationset{default label in legend path}}, - straight cycle/.style={@set plot handler=\pgfplothandlerpolygon,/utils/exec=\tikzdatavisualizationset{default label in legend closed path}}, - polygon/.style={straight cycle=cycle},% alias - gapped line/.style={@set plot handler=\pgfplothandlergaplineto,/utils/exec=\tikzdatavisualizationset{default label in legend path}}, - gapped cycle/.style={@set plot handler=\pgfplothandlergapcycle,/utils/exec=\tikzdatavisualizationset{gapped circular label in legend line}} +\tikzdatavisualizationset{visualizer options/.cd, + @set/.style 2 args={ + /tikz/data visualization/visualizers/\tikz@visualizer/styling/.append style={/utils/exec={\let\tikz@dv@plot@handler=#1}}, + /tikz/data visualization/visualizers/\tikz@visualizer/label in legend options/.append style={#2} + }, + no lines/.style={@set={\pgfplothandlerdiscard}{default label in legend mark}}, + smooth line/.style={@set={\pgfplothandlercurveto}{default label in legend path}}, + smooth cycle/.style={@set={\pgfplothandlerclosedcurve}{default label in legend closed path}}, + straight line/.style={@set={\pgfplothandlerlineto}{default label in legend path}}, + straight cycle/.style={@set={\pgfplothandlerpolygon}{default label in legend closed path}}, + polygon/.style={straight cycle},% alias + gap line/.style={@set={\pgfplothandlergaplineto}{default label in legend path}}, + gap cycle/.style={@set={\pgfplothandlergapcycle}{gap circular label in legend line}} } @@ -1378,16 +1547,17 @@ \begingroup \def\tikz@visualizer{#1}% \pgfkeys{/tikz/data visualization/visualizer label options/.cd, - /tikz/data visualization/every label visualizer/.try, #2} \pgfkeysgetvalue{/tikz/data visualization/visualizer label options/text}\tikz@dv@temp@lab \def\tikz@tempa{ - \scope[/tikz/data visualization/visualizer label options/.cd, - /tikz/data visualization/every label visualizer/.try, + \scope[ + /utils/exec=\def\tikz@visualizer{#1},% + /tikz/data visualization/visualizer label options/.cd, #2] + \tikzdatavisualizationset{every data set label/.try} \path [ - /data point/visualizer=#1,/utils/exec=\pgf@signalstyle.emit(), - /tikz/data visualization/.cd,every visualizer label] + /data point/set=#1,/utils/exec=\pgf@signalstyle.emit(), + /tikz/data visualization/.cd,every label in data/.try] (label visualizer coordinate') -- (label visualizer coordinate) node [ @@ -1405,7 +1575,7 @@ \endgroup }, arg1/.expand once=\tikz@dv@label@attribute, - arg2/.expand once=\tikz@dv@label@threshold, + arg2=\tikz@dv@label@threshold, arg3/.expand once=\tikz@dv@label@code, arg4=\pgfdvvisualizerfilter{#1} }, @@ -1418,40 +1588,45 @@ \def\tikz@create@label@count#1{ \tikzdatavisualizationset{ new object={ - when=after survey, + when=before survey, store=/tikz/data visualization/visualizers/#1/count/obj, class=count, - arg1=visualizers/#1/count, - after creation={ - \tikzdvobj.set filter({% - \pgfkeysgetvalue{/data point/visualizer}\pgf@tempa% - \def\pgf@tempb{#1}% - \ifx\pgf@tempa\pgf@tempb% - \else - \pgfdvfilterpassedfalse% - \fi - }) - } + arg1=set/#1/count, + after creation={\tikzdvobj.set filter(\pgfdvvisualizerfilter{#1})} } } } \pgfkeys{ /tikz/data visualization/visualizer label options/.cd, - at/.code args={#1>=#2}{% + when/.code args={#1 is#2}{% \def\tikz@dv@label@attribute{#1}% \def\tikz@dv@label@threshold{#2}% }, index/.code={% - \edef\tikz@dv@label@attribute{visualizers/\tikz@visualizer/count}% + \edef\tikz@dv@label@attribute{set/\tikz@visualizer/count}% \def\tikz@dv@label@threshold{#1}% }, + pos/.code={% + \edef\tikz@dv@label@attribute{set/\tikz@visualizer/count}% + \pgfkeysvalueof{/tikz/data visualization/visualizers/\tikz@visualizer/count/obj}.get max(\tikz@lib@max) + \edef\tikz@dv@label@threshold{(#1*\tikz@lib@max)}% + }, + auto/.code={% + \edef\tikz@dv@label@attribute{set/\tikz@visualizer/count}% + \pgfkeysvalueof{/tikz/data visualization/visualizers/\tikz@visualizer/count/obj}.get max(\tikz@lib@max) + \edef\tikz@dv@label@threshold{({(\pgfkeysvalueof{/data point/set/\tikz@visualizer}-0.5)/\the\tikzdvvisualizercounter*\tikz@lib@max})} + }, text/.initial=, - text'/.style={text={#1},node style=swap}, + text'/.style={text={#1},node style=swap,/utils/exec=\def\tikz@lib@dv@pin@sign{-}}, node style/.style={/tikz/data visualization/node style={#1}}, text colored/.style=/tikz/data visualization/text colored, + pin angle/.store in=\tikz@lib@dv@pin@dir, + pin length/.style={node style={pin distance={#1}}}, } +\let\tikz@lib@dv@pin@sign\pgfutil@empty + \let\tikz@dv@label@attribute\pgfutil@empty \let\tikz@dv@label@threshold\pgfutil@empty \let\tikz@dv@label@code\pgfutil@empty @@ -1486,7 +1661,7 @@ \let\pgfdvendrow=\pgfmatrixendrow% \def\pgf@marshal{ \matrix[at/.expand once=\pgf@dv@at,matrix anchor/.expand - once=\pgf@dv@anchor,/tikz/data visualization/#1/styling] + once=\pgf@dv@anchor,/tikz/data visualization/#1/matrix node styling] } \expandafter\pgf@marshal\expandafter{\pgf@dv@temp}; } @@ -1500,7 +1675,7 @@ #1/@strategy/.initial=down then right, #1/anchor/.initial=west, #1/at/.initial=(data visualization bounding box.east), - #1/styling/.style={row sep=0pt,column sep=.8em}, + #1/matrix node styling/.style={row sep=0pt,column sep=.8em}, % % % @@ -1511,7 +1686,11 @@ }, #1={every new legend} }}}, - legend/.style={new legend=legend,legend={#1}} + new legend/.default=main legend, + legend/.style={ + new legend, + main legend={#1} + } } \def\tikz@do@legend@options#1#2{ @@ -1545,38 +1724,187 @@ % anchor/.style={\tikz@dv@legend/anchor={#1}}, at/.style={\tikz@dv@legend/at={#1}}, - right/.style={ + % Outer placements + right/.style={east outside}, + left/.style={west outside}, + above/.style={north outside}, + below/.style={south outside}, + east outside/.style={ columns=1, at={([xshift=.8em]data visualization bounding box.east)}, anchor=west, }, - left/.style={ + north east outside/.style={ + columns=1, + at={([xshift=.8em]data visualization bounding box.north east|- + data bounding box.north)}, + anchor=north west, + }, + south east outside/.style={ + columns=1, + at={([xshift=.8em]data visualization bounding box.south east |- + data bounding box.south)}, + anchor=south west, + }, + west outside/.style={ columns=1, + label style=text left, at={([xshift=-.8em]data visualization bounding box.west)}, anchor=east, }, - below/.style={ + north west outside/.style={ + columns=1, + label style=text left, + at={([xshift=-.8em]data visualization bounding box.north west |- + data bounding box.north)}, + anchor=north east, + }, + south west outside/.style={ + columns=1, + label style=text left, + at={([xshift=-.8em]data visualization bounding box.south west |- + data bounding box.south)}, + anchor=south east, + }, + south outside/.style={ rows=1, at={([yshift=-.5em]data visualization bounding box.south)}, anchor=north, }, - above/.style={ + north outside/.style={ rows=1, at={([yshift=.5em]data visualization bounding box.north)}, anchor=south, }, - every new legend/.style={right,label style=text right}, + every new legend/.style={east outside,label style=text right}, + % + % Inner placements + % + % First, styling + every legend inside/.style={ + opaque=white, + label style={node style={font=\pgfutil@font@footnotesize}} + }, + opaque/.style={ + matrix node style={ + inner sep=.333ex, + outer sep=.5ex, + rounded corners=3pt, + execute at begin cell={\tikzset{sharp corners}}, % get rid of + % rounded corners in cells of the + % legend matrix + fill=#1 + }, + }, + opaque/.default=white, + transparent/.style={matrix node style={fill=none}}, + % Second, the placements + north east inside/.style={ + columns=1, + at={([xshift=-.3em]data bounding box.north east)}, + anchor=north east, + every legend inside + }, + south west inside/.style={ + columns=1, + at={([xshift=.3em]data bounding box.south west)}, + anchor=south west, + every legend inside + }, + north west inside/.style={ + columns=1, + at={([xshift=.3em]data bounding box.north west)}, + anchor=north west, + every legend inside + }, + south east inside/.style={ + columns=1, + at={([xshift=-.3em]data bounding box.south east)}, + anchor=south east, + every legend inside + }, + west inside/.style={ + columns=1, + at={([xshift=.3em]data bounding box.west)}, + anchor=west, + every legend inside + }, + east inside/.style={ + columns=1, + at={([xshift=.3em]data bounding box.east)}, + anchor=east, + every legend inside + }, + north inside/.style={ + rows=1, + at={(data bounding box.north)}, + anchor=north, + every legend inside + }, + south inside/.style={ + rows=1, + at={(data bounding box.south)}, + anchor=south, + every legend inside + }, + % Additional inner placements + at values/.style={ + at={(visualization cs:#1)}, + anchor=center, + every legend inside + }, + right of/.style={ + at={(visualization cs:#1)}, + anchor=west, + every legend inside + }, + left of/.style={ + at={(visualization cs:#1)}, + anchor=east, + every legend inside + }, + above of/.style={ + at={(visualization cs:#1)}, + anchor=south, + every legend inside + }, + below of/.style={ + at={(visualization cs:#1)}, + anchor=north, + every legend inside + }, + above right of/.style={ + at={(visualization cs:#1)}, + anchor=south west, + every legend inside + }, + above left of/.style={ + at={(visualization cs:#1)}, + anchor=south east, + every legend inside + }, + below right of/.style={ + at={(visualization cs:#1)}, + anchor=north west, + every legend inside + }, + below left of/.style={ + at={(visualization cs:#1)}, + anchor=north east, + every legend inside + }, + % + % % % Label text styling % label style/.style={ - style={/tikz/data visualization/legend entry options/every label - in legend/.append style={#1}} + matrix node style={/tikz/data visualization/every label in legend/.append style={#1}} }, % % Styling % - style/.style={\tikz@dv@legend/styling/.append style={#1}}, + matrix node style/.style={\tikz@dv@legend/matrix node styling/.append style={#1}}, } @@ -1593,30 +1921,30 @@ } \def\tikz@dv@add@legend@entry#1#2{ - \tikz@main@dv.at start survey({{ + \tikz@main@dv.at start survey({ \pgfkeysgetvalue{/tikz/data visualization/#1/obj}\pgf@temp \pgf@temp.add entry(\tikz@dv@render@legend@entry{legend=#1,#2}) - }}) + }) } \def\tikz@dv@render@legend@entry#1{ - \pgfkeys{/tikz/data visualization/.cd, - every visualizer label, - every visualizer legend label - } - \pgfkeys{/tikz/data visualization/legend entry options/.cd,#1} + \pgfkeys{/tikz/data visualization/.cd,every data set label} + \pgfkeys{/tikz/data visualization/legend entry options/.cd, + /tikz/data visualization/every label in legend,#1}% \pgfkeysgetvalue{/tikz/data visualization/legend entry options/text}\tikz@dv@temp@lab \pgfkeysgetvalue{/tikz/data visualization/@node styling}\tikz@dv@temp@style \pgfkeysgetvalue{/tikz/data visualization/legend entry options/setup}\tikz@dv@temp@setup - \pgfkeysgetvalue{/tikz/data visualization/legend entry options/value visualizer}\tikz@dv@temp@visual - \pgfkeysgetvalue{/tikz/data visualization/legend entry options/value visualizer styling}\tikz@dv@temp@visual@styling + \pgfkeysgetvalue{/tikz/data visualization/legend entry options/visualizer in legend styling}\tikz@dv@temp@visual@styling \scope[/utils/exec=\expandafter\pgfkeysalso\expandafter{\tikz@dv@temp@setup}, /utils/exec=\pgf@signalstyle.emit()] \node[/tikz/data visualization/node styling, /utils/exec=\expandafter\pgfkeysalso\expandafter{\tikz@dv@temp@style}] {\tikz@dv@pre@height\tikz@dv@temp@lab\tikz@dv@post@height}; \scope[/utils/exec=\expandafter\pgfkeysalso\expandafter{\tikz@dv@temp@visual@styling}] - \tikz@dv@temp@visual + \iftikz@lib@dv@text@only + \else + \pgfkeysvalueof{/tikz/data visualization/legend entry options/visualizer in legend} + \fi \endscope \endscope } @@ -1633,66 +1961,84 @@ % text/.initial=, node style/.style={/tikz/data visualization/node style={#1}}, - legend/.initial=legend, + legend/.initial=main legend, setup/.initial=, - value visualizer/.initial=, - value visualizer styling/.initial=, - value visualizer style/.style={value visualizer styling/.append={,#1}}, - value visualizer macro/.initial=, + visualizer in legend/.initial=, + visualizer in legend styling/.initial=, + visualizer in legend style/.style={visualizer in legend styling/.append={,#1}}, % % Legend visualizers for plots % text right/.style={ node style={anchor=mid west,inner ysep=1pt,inner xsep=0pt,reset cm,xshift=.333em}, - value visualizer style={reset cm}, - value visualizer macro=\tikz@dv@legend@entry@as@example + visualizer in legend style={reset cm}, }, text left/.style={ node style={anchor=mid east,inner ysep=1pt,inner xsep=0pt,reset cm,xshift=-.333em,align=right}, - value visualizer style={reset cm,xscale=-1}, - value visualizer macro=\tikz@dv@legend@entry@as@example + visualizer in legend style={reset cm,xscale=-1}, }, text only/.style={ node style={anchor=mid west,inner ysep=1pt,inner xsep=0pt,reset cm,text=visualizer color}, - value visualizer style={}, - value visualizer macro=\relax, + /utils/exec=\tikz@lib@dv@text@onlytrue }, text colored/.style=/tikz/data visualization/text colored, } - +\let\tikz@lib@dv@pin@dir\pgfutil@empty +\newif\iftikz@lib@dv@text@only \pgfkeys{ /tikz/data visualization/visualizer options/.cd, label in legend/.code={\expandafter\tikz@dv@new@label@in@legend@for@visualizer\expandafter{\tikz@visualizer}{#1}}, - label in data/.code=\tikzdatavisualizationset{new label visualizer/.expand once=\expandafter{\tikz@visualizer}{#1}}, - style/.style={/tikz/data visualization/visualizers/\tikz@visualizer/styling/.append style={#1}}, + label in data/.code=\tikzdatavisualizationset{new label visualizer/.expand once=\expandafter{\tikz@visualizer}{auto,#1}}, + pin in data/.style={label in data={% + node style={% + /utils/exec={ + \ifx\tikz@lib@dv@pin@dir\pgfutil@empty + \pgf@process{\pgfpointnormalised{% + \pgfpointdiff% + {\pgfpointanchor{label visualizer coordinate}{center}}% + {\pgfpointanchor{label visualizer coordinate'}{center}}}}% + \pgf@x=-\pgf@x\relax% + \edef\tikz@lib@dv@temp@rot{\noexpand\pgfqpoint{\the\pgf@y}{\the\pgf@x}}% + \tikz@addtransform{\pgftransformshift{\pgfpointscale{\tikz@lib@dv@pin@sign\tikz@pin@distance}{\tikz@lib@dv@temp@rot}}} + \else% + \tikz@addtransform{\pgftransformshift{\pgfpointpolar{\tikz@lib@dv@pin@dir}{\tikz@lib@dv@pin@sign\tikz@pin@distance}}} + \fi% + }, + append after command={ + \bgroup + [current point is local=true] + (\tikzlastnode) edge [solid, every pin edge] (label visualizer coordinate) + \egroup% + }}, + ,#1}}, + style/.style={/tikz/data visualization/visualizers/\tikz@visualizer/styling/.append style={,#1}}, + label in legend options/.style={/tikz/data visualization/visualizers/\tikz@visualizer/label in legend options/.append style={,#1}}, + ignore style sheets/.style={/tikz/data visualization/visualizers/\tikz@visualizer/signal/.code=,/utils/exec=\advance\tikzdvvisualizercounter by -1\relax}, } \def\tikz@dv@new@label@in@legend@for@visualizer#1#2{ \tikzdatavisualizationset{ new legend entry={ - every legend entry/.try, - every label in legend/.try, - /tikz/data visualization/every label/.try, + visualizer in legend style={/tikz/data visualization/visualizers/#1/styling/.try}, + /tikz/data visualization/every label in legend/.try, + /tikz/.cd, + every label/.try, + /tikz/data visualization/legend entry options/.cd, + setup={/data point/set=#1}, + /tikz/data visualization/visualizers/#1/label in legend options/.try, #2, - setup={/data point/visualizer=#1}, - /utils/exec=\pgfkeysgetvalue{/tikz/data visualization/legend entry options/value visualizer macro}\tikz@dv@visualizer@macro, - value visualizer={ - \scope[/tikz/data visualization/visualizers/#1/styling/.try] - \def\tikz@visualizer{#1} - \tikz@dv@visualizer@macro - \endscope - } } } } \def\tikz@dv@legend@entry@as@example{ + \pgfkeysgetvalue{/data point/set}{\tikz@visualizer} \pgfkeysvalueof{/data point/\tikz@visualizer/execute at begin} - \tikz@plot@handler + \tikz@dv@plot@handler \pgfplotstreamstart - \pgfkeysgetvalue{/tikz/data visualization/label in legend line coordinates}{\tikz@dv@temp} + \pgfkeysgetvalue{/tikz/data visualization/legend entry options/label in legend line coordinates}{\tikz@dv@temp} \foreach \coordinate in \tikz@dv@temp { \pgfplotstreampoint{\expandafter\tikz@scan@one@point\expandafter\pgfutil@firstofone\coordinate} } \pgfplotstreamend @@ -1700,7 +2046,7 @@ \pgfkeysvalueof{/data point/\tikz@visualizer/execute at begin} \tikz@dv@plot@mark@maker \pgfplotstreamstart - \pgfkeysgetvalue{/tikz/data visualization/label in legend mark coordinates}{\tikz@dv@temp} + \pgfkeysgetvalue{/tikz/data visualization/legend entry options/label in legend mark coordinates}{\tikz@dv@temp} \foreach \coordinate in \tikz@dv@temp { \pgfplotstreampoint{\expandafter\tikz@scan@one@point\expandafter\pgfutil@firstofone\coordinate} } \pgfplotstreamend @@ -1709,7 +2055,9 @@ \tikzdatavisualizationset{ + legend entry options/.cd, label in legend line coordinates/.initial=, + label in legend rectangle coordinates/.initial={(-1ex,-.5ex),(-1ex,0.968ex),(0ex,0.968ex),(0ex,-.5ex)}, label in legend mark coordinates/.initial=, label in legend one mark/.style={ label in legend line coordinates={}, @@ -1720,7 +2068,7 @@ label in legend mark coordinates={(-3ex,-.3ex),(-1.5ex,.3ex),(0,0)}, }, straight label in legend line/.style={ - label in legend line coordinates={(-2em,0),(0,0)}, + label in legend line coordinates={(-2em,0),(-1.5em,0),(-.5em,0),(0,0)}, label in legend mark coordinates={(-1.5em,0),(-.5em,0)}, }, zig zag label in legend line/.style={ @@ -1730,20 +2078,16 @@ circular label in legend line/.style={ label in legend line coordinates={% ([xshift=-1em]0:.9em and .35ex),% - ([xshift=-1em]30:.9em and .35ex),% - ([xshift=-1em]60:.9em and .35ex),% + ([xshift=-1em]45:.9em and .35ex),% ([xshift=-1em]90:.9em and .35ex),% - ([xshift=-1em]120:.9em and .35ex),% - ([xshift=-1em]150:.9em and .35ex),% + ([xshift=-1em]135:.9em and .35ex),% ([xshift=-1em]180:.9em and .35ex),% - ([xshift=-1em]210:.9em and .35ex),% - ([xshift=-1em]240:.9em and .35ex), + ([xshift=-1em]225:.9em and .35ex),% ([xshift=-1em]270:.9em and .35ex),% - ([xshift=-1em]300:.9em and .35ex),% - ([xshift=-1em]330:.9em and .35ex)}, + ([xshift=-1em]315:.9em and .35ex)},% label in legend mark coordinates={([xshift=-1em]120:.9em and .35ex),([xshift=-1em]-60:.9em and .35ex)}, }, - gapped circular label in legend line/.style={ + gap circular label in legend line/.style={ label in legend line coordinates={% ([xshift=-1em,yshift=.2ex]90:1.4ex and 0.9ex),% ([xshift=-1em,yshift=.2ex]162:1.4ex and 0.9ex),% @@ -1779,30 +2123,40 @@ store=/tikz/data visualization/visualizers/#1, class=plot handler visualizer, arg1=#1, - arg2={\tikz@plot@handler,\tikz@dv@plot@mark@maker} + arg2={\tikz@dv@plot@handler,\tikz@dv@plot@mark@maker} }, new visualizer={#1}{% every path/.style={draw}, style={every mark/.append style={color=visualizer color}}, - straight line, + mark size=2pt, semithick, color=visualizer color, mark=none, /tikz/data visualization/every visualize as line/.try, - }, - /data point/visualizer=#1 + }{visualizer in legend=\tikz@dv@legend@entry@as@example}, + #1={straight line} }, visualize as line/.default=line, visualize as smooth line/.style={ visualize as line={#1}, - #1={style=smooth line} + #1={smooth line} }, visualize as smooth line/.default=line, visualize as scatter/.style={ - visualize as line={#1}, - #1={style=no lines, - /tikz/data visualization/every visualize as scatter/.try}, - visualizer style sheet=cross marks + new object={ + when=after survey, + store=/tikz/data visualization/visualizers/#1, + class=plot handler visualizer, + arg1=#1, + arg2={\tikz@dv@plot@mark@maker} + }, + new visualizer={#1}{% + mark=x, + mark size=2pt, + style={every mark/.append style={color=visualizer color}}, + /tikz/data visualization/every visualize as scatter/.try, + }{visualizer in legend=\tikz@dv@legend@entry@as@example}, + #1={no lines} }, visualize as scatter/.default=scatter } @@ -1812,32 +2166,62 @@ \let\tikz@transform=\pgfutil@empty% \tikzset{solid,shift only,every mark}% \tikz@options% - \pgfplothandlermark{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}} + \ifx\tikz@plot@mark\pgfutil@empty% + \pgfplothandlerdiscard + \else + \pgfplothandlermark{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}} + \fi } +% +% Rectangle visualizers +% + -% The following needs to be fixed... \tikzdatavisualizationset{ - new rectangles visualizer/.style={ + visualize as rectangles/.style={ new object={ + when=before survey, store=/tikz/data visualization/visualizers/#1, class=rectangle visualizer, - arg1 from key=/tikz/data visualization/#1/attribute 1, - arg2 from key=/tikz/data visualization/#1/attribute 2, - arg3=#1/use path + arg1=#1 }, - #1/attribute 1/.initial=x, - #1/attribute 2/.initial=y, - /data point/#1/use path/.initial=\pgfusepath{stroke}, - /data point/#1/style/.code=\pgfkeysalso{/data point/#1/use path={\path[every rectangles/.try,##1];}} + /data point/#1/attribute 1/.initial=x, + /data point/#1/attribute 2/.initial=y, + new visualizer={#1}{% + every path/.style={draw}, + semithick, + color=visualizer color, + /tikz/data visualization/every visualize as rectangles/.try, + }{visualizer in legend=\tikz@dv@legend@entry@as@rectangle}, + #1={} }, - rectangle visualizer/.default=rectangles + visualize as rectangles/.default=rectangles, + % + % + % + visualizer options/.cd, + attribute 1/.style={/data point/\tikz@visualizer/attribute 1=#1}, + attribute 2/.style={/data point/\tikz@visualizer/attribute 2=#1}, } +\def\tikz@dv@legend@entry@as@rectangle{ + \pgfkeysgetvalue{/data point/set}{\tikz@visualizer} + \pgfkeysvalueof{/data point/\tikz@visualizer/execute at begin} + \pgfplothandlerpolygon + \pgfplotstreamstart + \pgfkeysgetvalue{/tikz/data visualization/legend entry options/label in legend rectangle coordinates}{\tikz@dv@temp} + \foreach \coordinate in \tikz@dv@temp + { \pgfplotstreampoint{\expandafter\tikz@scan@one@point\expandafter\pgfutil@firstofone\coordinate} } + \pgfplotstreamend + \pgfkeysvalueof{/data point/\tikz@visualizer/execute at end} +} + + % @@ -1946,7 +2330,7 @@ \pgfdvdeclarestylesheet{strong colors} { - default style/.style={black}, + default style/.style={visualizer color=black}, 1/.style={visualizer color=black}, 2/.style={visualizer color=red!80!black}, 3/.style={visualizer color=blue!80!black}, @@ -1958,13 +2342,30 @@ \pgfdvdeclarestylesheet{cross marks} { - default style/.style={mark=x,every mark/.append style=thin,mark size=1.8pt}, - 1/.style={mark=x,every mark/.append style=thin,mark size=1.8pt}, - 2/.style={mark=+,every mark/.append style=thin,mark size=1.8pt}, - 3/.style={mark=Mercedes star,every mark/.append style=thin,mark size=1.8pt}, - 4/.style={mark=Mercedes star flipped,every mark/.append style=thin,mark size=1.8pt}, - 5/.style={mark=star,every mark/.append style=thin,mark size=1.8pt}, - 6/.style={mark=10-pointed star,every mark/.append style={line width=.3pt,mark size=1.6pt}} + default style/.style={mark=x,every mark/.append style=thin,mark size=2pt}, + 1/.style={mark=x,every mark/.append style=thin,mark size=2pt}, + 2/.style={mark=+,every mark/.append style=thin,mark size=2pt}, + 3/.style={mark=Mercedes star,every mark/.append style=thin,mark size=2pt}, + 4/.style={mark=Mercedes star flipped,every mark/.append style=thin,mark size=2pt}, + 5/.style={mark=star,every mark/.append style=thin,mark size=2pt}, + 6/.style={mark=10-pointed star,every mark/.append style={line width=.3pt,mark size=1.8pt}} +} + + +\pgfdvdeclarestylesheet{* mark} +{ + default style/.style={mark=*,every mark/.append style=thin,mark size=1.4pt}, +} + +\pgfdvdeclarestylesheet{dot mark} +{ + default style/.style={mark=*,every mark/.append style=thin,mark size=0.6pt}, +} + + +\pgfdvdeclarestylesheet{o mark} +{ + default style/.style={mark=o,every mark/.append style=thin,mark size=1.4pt}, } @@ -1994,9 +2395,10 @@ } } -\tikzdvdeclarestylesheetcolorseries{varying hue}{hsb}{.4,0.9,0.8}{.213,0,0} +\tikzdvdeclarestylesheetcolorseries{vary hue}{hsb}{.4,0.9,0.8}{.213,0,0} \tikzdvdeclarestylesheetcolorseries{shades of blue}{hsb}{.65,1.4,1}{0,-.4,-.0} \tikzdvdeclarestylesheetcolorseries{shades of red}{hsb}{0,1.4,1}{0,-.4,-.0} +\tikzdvdeclarestylesheetcolorseries{gray scale}{hsb}{0,0,-.34}{0,0,.34} @@ -2020,7 +2422,7 @@ new Cartesian axis=y axis, y axis={attribute=y,unit vector={(0cm,1pt)}} }, - xy axes/.style={x axis={#1},y axis={#1}}, + Xy axes/.style={x axis={#1},y axis={#1}}, uv Cartesian/.style={ new Cartesian axis=u axis, u axis={attribute=u,unit vector={(1pt,0cm)}}, @@ -2047,6 +2449,24 @@ +% +% Create a new axis system +% + +\tikzdatavisualizationset{ + new axis system/.style n args={4}{ + #1/.style={ + #2, + #1/.cd, + #3, + /tikz/data visualization/every #1/.try, + ##1, + /tikz/data visualization/.cd, + #4, + } + } +} + % The school book axes % @@ -2062,56 +2482,67 @@ % instance. \tikzdatavisualizationset{ - school book axes/.style={ + new axis system={school book axes}{% xy Cartesian, x axis={ - include values=0, + include value=0, + scaling=0 at 0 and \pgfkeysvalueof{/tikz/data visualization/school book axes/unit} at 1cm, visualize axis={y axis={goto=0},style=->,padded}, visualize ticks={common={y axis={goto=0},direction axis=y axis}, major={tick text at low, options at=0 as [{style={draw=none},no tick text}] }}, visualize grid={common={direction axis=y axis,padded}}, - ticks={step=1}, - padding=0.75em, - visualize label={visualize x axis label} + ticks={step=\pgfkeysvalueof{/tikz/data visualization/school book axes/unit}}, + padding=0.75em }, y axis={ - include values=0, + include value=0, + scaling=0 at 0 and \pgfkeysvalueof{/tikz/data visualization/school book axes/unit} at 1cm, visualize axis={x axis={goto=0},style=->,padded}, visualize ticks={ common={x axis={goto=0},direction axis=x axis}, major={tick text at low,options at=0 as [{high=0,low=0,style={draw=none},node style={anchor=north east}}]} }, visualize grid={common={direction axis=x axis,padded}}, - ticks={step=1}, - padding=0.75em, - visualize label={visualize y axis label} - }, - school book axes standard labels, - every school book axes/.try - } -} - - -% Possible axis positionings: - -\tikzdatavisualizationset{ - % + ticks={step=\pgfkeysvalueof{/tikz/data visualization/school book axes/unit}}, + padding=0.75em + } + }{% + standard labels + }{% + @make labels + }, + school book axes/.cd, + % Possible axis positionings: + % % Place labels at the ends of the axes - school book axes standard labels/.style={ - visualize x axis label/.style={ - value=padded max, - y axis={goto=0} - }, - visualize y axis label/.style={ - value=padded max, - x axis={goto=0} + % + standard labels/.style={ + /tikz/data visualization/@make labels/.style={ + x axis={ + visualize label={ + x axis={goto=padded max, anchor at max}, + y axis={goto=0} + } + }, + y axis={ + visualize label={ + y axis={goto=padded max, anchor at max}, + x axis={goto=0} + } + } } - } + }, + % + % Basic unit + % + unit/.initial=1, } + + % The scientific axes % % The scientific axes is a 2d plot that has a predetermined width and @@ -2119,154 +2550,163 @@ % this given rectangle. \tikzdatavisualizationset{ - scientific axes/width/.initial=5cm, - scientific axes/height/.initial=0.618*\pgfkeysvalueof{/tikz/data visualization/scientific axes/width},% golden ratio... - scientific axes/.style={ + new axis system={scientific axes}{% xy Cartesian, every axis/.append style={style={draw=black!50}}, every ticks/.append style={style={draw=black!50}}, x axis={ length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}, - ticks={some}, - visualize ticks={common={y axis={goto=padded min},direction axis=y axis,high=0pt},major={tick text at low}}, - visualize ticks={common={y axis={goto=padded max},direction axis=y axis,low=0pt}}, - visualize axis={y axis={goto=padded min},padded}, - visualize axis={y axis={goto=padded max},padded}, - visualize grid={common={direction axis=y axis,padded}}, - visualize label=visualize x axis label + ticks }, y axis={ length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}, - ticks={some}, - visualize ticks={common={x axis={goto=padded min},direction axis=x axis,high=0pt},major={tick text at low}}, - visualize ticks={common={x axis={goto=padded max},direction axis=x axis,low=0pt}}, - visualize axis={x axis={goto=padded min},padded}, - visualize axis={x axis={goto=padded max},padded}, - visualize grid={common={direction axis=x axis,padded}}, - visualize label=visualize y axis label - }, - scientific axes standard labels, - every scientific axes/.try + ticks + } + }{% + standard labels, + outer ticks, + }{% + @make axes, + @make labels }, - scientific inner axes/.style={ - xy Cartesian, - every axis/.append style={style={draw=black!50}}, - every ticks/.append style={style={draw=black!50}}, - x axis={ - length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}, - ticks={some}, - visualize ticks={common={y axis={goto=padded min},direction axis=y axis,low=0pt},major={tick text at low}}, - visualize ticks={common={y axis={goto=padded max},direction axis=y axis,high=0pt}}, - visualize axis={y axis={goto=padded min},padded}, - visualize axis={y axis={goto=padded max},padded}, - visualize grid={common={direction axis=y axis,padded}}, - visualize label=visualize x axis label - }, - y axis={ - length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}, - ticks={some}, - visualize ticks={common={x axis={goto=padded min},direction axis=x axis,low=0pt},major={tick text at low}}, - visualize ticks={common={x axis={goto=padded max},direction axis=x axis,high=0pt}}, - visualize axis={x axis={goto=padded min},padded}, - visualize axis={x axis={goto=padded max},padded}, - visualize grid={common={direction axis=x axis,padded}}, - visualize label=visualize y axis label - }, - scientific axes standard labels, - every scientific axes/.try + scientific axes/.cd, + width/.initial=5cm, + height/.initial=0.618*\pgfkeysvalueof{/tikz/data visualization/scientific axes/width},% golden ratio... + outer ticks/.style={ + /tikz/data visualization/@make axes/.style={ + x axis={ + visualize ticks={common={y axis={goto=padded min},direction axis=y axis,high=0pt},major={tick text at low}}, + visualize ticks={common={y axis={goto=padded max},direction axis=y axis,low=0pt}}, + visualize axis={y axis={goto=padded min},padded}, + visualize axis={y axis={goto=padded max},padded}, + visualize grid={common={direction axis=y axis,padded}}, + }, + y axis={ + visualize ticks={common={x axis={goto=padded min},direction axis=x axis,high=0pt},major={tick text at low}}, + visualize ticks={common={x axis={goto=padded max},direction axis=x axis,low=0pt}}, + visualize axis={x axis={goto=padded min},padded}, + visualize axis={x axis={goto=padded max},padded}, + visualize grid={common={direction axis=x axis,padded}}, + } + } }, - scientific clean axes/.style={ - xy Cartesian, - x axis={ - length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}, - ticks={some}, - visualize ticks={common={y axis={goto=padded min},direction axis=y axis,high=0pt},major={tick text at low}}, - visualize axis={y axis={goto=padded min}}, - visualize grid={common={direction axis=y axis}}, - visualize label=visualize x axis label, - grid={major={also at=min,also at=max}}, - }, - y axis={ - length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}, - ticks={some}, - visualize ticks={common={x axis={goto=padded min},direction axis=x axis,high=0pt},major={tick text at low}}, - visualize axis={x axis={goto=padded min}}, - visualize grid={common={direction axis=x axis}}, - visualize label=visualize y axis label, - grid={major={also at=min,also at=max}}, - }, - all axes={padding=.5em}, - scientific axes standard labels, - every scientific axes/.try + inner ticks/.style={ + /tikz/data visualization/@make axes/.style={ + x axis={ + visualize ticks={common={y axis={goto=padded min},direction axis=y axis,low=0pt},major={tick text at low}}, + visualize ticks={common={y axis={goto=padded max},direction axis=y axis,high=0pt}}, + visualize axis={y axis={goto=padded min},padded}, + visualize axis={y axis={goto=padded max},padded}, + visualize grid={common={direction axis=y axis,padded}}, + }, + y axis={ + visualize ticks={common={x axis={goto=padded min},direction axis=x axis,low=0pt},major={tick text at low}}, + visualize ticks={common={x axis={goto=padded max},direction axis=x axis,high=0pt}}, + visualize axis={x axis={goto=padded min},padded}, + visualize axis={x axis={goto=padded max},padded}, + visualize grid={common={direction axis=x axis,padded}}, + } + } }, -} - - - -% Possible axis positionings: - -\tikzdatavisualizationset{ + clean/.style={ + /tikz/data visualization/@make axes/.style={ + x axis={ + visualize ticks={common={y axis={goto=padded min},direction axis=y axis,high=0pt},major={tick text at low}}, + visualize axis={y axis={goto=padded min}}, + visualize axis={y axis={goto=min}, style={black!25, line cap=rect}}, + visualize axis={y axis={goto=max}, style={black!25, line cap=rect}}, + visualize grid={common={direction axis=y axis}}, + padding=.5em, + }, + y axis={ + visualize ticks={common={x axis={goto=padded min},direction axis=x axis,high=0pt},major={tick text at low}}, + visualize axis={x axis={goto=padded min}}, + visualize axis={x axis={goto=min}, style={black!25, line cap=rect}}, + visualize axis={x axis={goto=max}, style={black!25, line cap=rect}}, + visualize grid={common={direction axis=x axis}}, + padding=.5em + }, + } + }, + % Possible axis positionings: % % Place axes labels below and left, where left label is rotated % - scientific axes standard labels/.style={ - visualize x axis label/.style={ - % Horizontal position is middle of axis: - pos=0.5, - y axis={goto=padded min}, - % Vertical position comes from bounding box: - node style={ - at={(0,0 |- data visualization bounding box.south)}, - below + standard labels/.style={ + /tikz/data visualization/@make labels/.style={ + x axis={ + visualize label={ + x axis={goto pos=.5}, + % Vertical position comes from bounding box: + node style={ + at={(0,0 |- data visualization bounding box.south)}, + below + } + } + }, + y axis={ + visualize label={ + y axis={goto pos=.5}, + % Horizontal position comes from bounding box: + node style={ + at={(0,0 -| data visualization bounding box.west)}, + rotate=90, + above} + } } - }, - visualize y axis label/.style={% - % Vertical position is middle of axis: - pos=0.5, - x axis={goto=padded min}, - % Horizontal position comes from bounding box: - node style={ - at={(0,0 -| data visualization bounding box.west)}, - rotate=90, - above} } }, % % Place axes labels below and left, no rotation % - scientific axes upright labels/.style={ - scientific axes standard labels, - visualize y axis label/.style={% - % Vertical position is middle of axis: - pos=0.5, - x axis={goto=padded min}, - % Horizontal position comes from bounding box: - node style={ - at={(0,0 -| data visualization bounding box.west)}, - left + upright labels/.style={ + /tikz/data visualization/@make labels/.style={ + x axis={ + visualize label={ + x axis={goto pos=.5}, + % Vertical position comes from bounding box: + node style={ + at={(0,0 |- data visualization bounding box.south)}, + below + } + } + }, + y axis={ + visualize label={ + y axis={goto pos=.5}, + % Horizontal position comes from bounding box: + node style={ + at={(0,0 -| data visualization bounding box.west)}, + left + } + } } } }, % % Place axes at the ends of the axes % - scientific axes end labels/.style={ - visualize x axis label/.style={ - value=max, - y axis={goto=padded min}, - % Vertical position comes from bounding box: - node style={ - at={(0,0 -| data visualization bounding box.east)}, - right - } - }, - visualize y axis label/.style={ - value=max, - x axis={goto=padded min}, - % Horizontal position comes from bounding box: - node style={ - at={(0,0 |- data visualization bounding box.north)}, - above + end labels/.style={ + /tikz/data visualization/@make labels/.style={ + x axis={ + visualize label={ + y axis={goto=padded min}, + % Vertical position comes from bounding box: + node style={ + at={(0,0 -| data visualization bounding box.east)}, + right + } + } + }, + y axis={ + visualize label={ + x axis={goto=padded min}, + % Horizontal position comes from bounding box: + node style={ + at={(0,0 |- data visualization bounding box.north)}, + above + } + } } } } diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.polar.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.polar.code.tex index 8b4d99f49dd..1615f0d1bfc 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.polar.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.polar.code.tex @@ -7,21 +7,21 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.polar.code.tex,v 1.3 2008/11/24 18:31:22 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/datavisualization/tikzlibrarydatavisualization.polar.code.tex,v 1.8 2011/05/06 11:15:33 tantau Exp $ \usetikzlibrary{datavisualization} \usepgflibrary{datavisualization.polar} \tikzdatavisualizationset{% - new polar/.style={ - new axis=angle axis, - angle axis={attribute=angle}, - new axis=radius axis, - radius axis={attribute=radius}, - radius axis/scaling/default=0 at 0 and 1 at 1cm, + new polar axes/.style 2 args={ + new axis base=#1, + #1={attribute=angle}, + new axis base=#2, + #2={attribute=radius}, + #2/scaling/default=0 at 0 and 1 at 1cm, new object={ - store=/tikz/data visualization/polar transformer, + store=/tikz/data visualization/#1/polar transformer, class=polar transformer, arg1/.expanded=\pgfkeysvalueof{/tikz/data visualization/angle axis/attribute}/scaled, arg2/.expanded=\pgfkeysvalueof{/tikz/data visualization/radius axis/attribute}/scaled, @@ -30,28 +30,530 @@ }, /tikz/data visualization/#1/unit vector 0 degrees/.initial=\pgfqpoint{1pt}{0pt}, /tikz/data visualization/#1/unit vector 90 degrees/.initial=\pgfqpoint{0pt}{1pt}, - /tikz/data visualization/#1/unit vectors/.code 2 args={ - \def\tikz@dv@polar{/tikz/data visualization/#1} - \tikz@scan@one@point\tikz@lib@dv@polar@a##1 - \tikz@scan@one@point\tikz@lib@dv@polar@b##2 - } }, - new polar/.default=polar + new polar axes/.default={angle axis}{radius axis} } \def\tikz@lib@dv@polar@a#1{ - \pgfkeyssetvalue{\tikz@dv@polar/unit vector 0 degrees}{#1} + \pgfkeyssetvalue{\tikz@dv@axis/unit vector 0 degrees}{#1} } \def\tikz@lib@dv@polar@b#1{ - \pgfkeyssetvalue{\tikz@dv@polar/unit vector 90 degrees}{#1} + \pgfkeyssetvalue{\tikz@dv@axis/unit vector 90 degrees}{#1} +} + + + +% +% Scientific polar axes +% + +\tikzset{ + /tikz/data visualization/axis options/.cd, + unit vectors/.code 2 args={ + \tikz@scan@one@point\tikz@lib@dv@polar@a#1 + \tikz@scan@one@point\tikz@lib@dv@polar@b#2 + }, + degrees/.style={\tikz@dv@axis/scaling=0 at 0 and 1 at 1}, + radians/.style={\tikz@dv@axis/scaling=0 at 0 and 0.03141592653589793 at 1.8}, +} + + + +\tikzdatavisualizationset{ + new axis system={scientific polar axes}{% + new polar axes, + angle axis={attribute=angle}, + radius axis={attribute=radius}, + every axis/.append style={style={draw=black!50}}, + every ticks/.append style={style={draw=black!50}}, + }{% + 0 to 360,% + outer ticks, + }{% + @make axes, + scientific polar axes/@setup axes, + /utils/exec={ + \edef\pgf@marshal{\noexpand\tikzdatavisualizationset{\pgfkeysvalueof{/tikz/data visualization/@which visualize radius axis}/.list={\pgfkeysvalueof{/tikz/data visualization/\pgfkeysvalueof{/tikz/data visualization/@which radius axes at}}}}} + \pgf@marshal + }, + @make labels + }, + @which radius axes at/.initial=@inner radius axes at, + @which visualize radius axis/.initial=@visualize radius axis, + @inner radius axes at/.initial=, + @clean radius axes at/.initial=, + @visualize radius axis/.style 2 args={ + radius axis={ + visualize axis={angle axis={goto=#1},high=padded max,low=0}, + visualize ticks={ + common={angle axis={goto=#1}, direction axis=angle axis}, + major={tick text at #2, + options at=0 as [{style={draw=none},no tick text}] + } + } + } + }, + @visualize clean radius axis/.style n args={5}{ + radius axis={ + visualize axis={angle + axis={goto=#1},high=max,low=0,style={black!25,line cap=rect}}, + visualize axis={angle + axis={goto=#1},high=max,low=0,style={line cap=rect,#4}}, + visualize ticks={ + style={#4}, + common={angle axis={goto=#1}, direction axis=angle axis, #3=0}, + major={tick text at #2,#5} + } + } + }, + @visualize zero/.style={@inner visualize zero={#1}}, + @clean visualize zero/.style={}, + @inner visualize zero/.style={ + radius axis={ + visualize ticks={ + common={angle axis={goto=0}, direction axis=angle axis}, + major={tick text at low,low=0,high=0,at=0 as + [{style={draw=none},node style={anchor=#1}}] + } + } + } + }, + @degrees/.style={ + angle axis={degrees, ticks={step=15, tick suffix=$^\circ$, major={ + options at=360 as [{style={draw=none},no tick text}], + options at=-180 as [{style={draw=none},no tick text}]}}} + }, + @rad/.style={ + angle axis={radians, ticks={ + step=(pi/12), + node style={ + /pgf/number format/frac, + /pgf/number format/frac shift={1} + }, + tick typesetter/.code={% + \pgfmathsetmacro{\tikz@lib@dv@pol}{round(####1*3.819718634205488)/12}% + \pgfmathapproxequalto{\tikz@lib@dv@pol}{0}% + \ifdim\pgfmathresult pt=1.0pt% + $0$% + \else% + \pgfmathapproxequalto{\tikz@lib@dv@pol}{1}% + \ifdim\pgfmathresult pt=1.0pt% + $\pi$% + \else + \pgfmathapproxequalto{\tikz@lib@dv@pol}{-1}% + \ifdim\pgfmathresult pt=1.0pt% + $-\pi$% + \else% + \pgfmathprintnumber{\tikz@lib@dv@pol}$\pi$% + \fi% + \fi% + \fi% + }, + major={ + options at=6.2831985e0 as [{style={draw=none},no tick text}], + options at=6.2831192e0 as [{style={draw=none},no tick text}], + options at=6.2830794e0 as [{style={draw=none},no tick text}], + options at=6.2828787e0 as [{style={draw=none},no tick text}], + options at=6.2831598e0 as [{style={draw=none},no tick text}], + options at=-3.1415991e0 as [{style={draw=none},no tick text}], + options at=-3.1415802e0 as [{style={draw=none},no tick text}], + options at=-3.1415602e0 as [{style={draw=none},no tick text}], + options at=-3.14153961e0 as [{style={draw=none},no tick text}], + options at=-3.1414406e0 as [{style={draw=none},no tick text}], + } + } + } + }, + @make labels/.style={}, +} + +\tikzdatavisualizationset{ + scientific polar axes/.cd, + % + % + % + outer ticks/.style={ + /tikz/data visualization/@make axes/.style={ + radius axis={ + min value=0, + length=\pgfkeysvalueof{/tikz/data visualization/scientific polar axes/radius}, + padding=0em, + ticks={few}, + visualize grid={common={direction axis=angle axis,low=min,high=max}}, + }, + angle axis={ + visualize axis={radius axis={goto=padded max},low=min,high=max}, + visualize ticks={common={radius axis={goto=padded max},direction + axis=radius axis},common={low=0},major={tick text at high}}, + visualize grid={common={direction axis=radius axis},low=0,high=padded max}, + } + }, + /tikz/data visualization/@which radius axes at=@inner radius axes at, + /tikz/data visualization/@which visualize radius axis=@visualize radius axis, + /tikz/data visualization/@visualize zero/.style={@inner visualize zero={##1}}, + }, + inner ticks/.style={ + /tikz/data visualization/@make axes/.style={ + radius axis={ + min value=0, + length=\pgfkeysvalueof{/tikz/data visualization/scientific polar axes/radius}, + padding=0em, + ticks={few}, + visualize grid={common={direction axis=angle axis,low=min,high=max}}, + }, + angle axis={ + visualize axis={radius axis={goto=padded max},low=min,high=max}, + visualize ticks={common={radius axis={goto=padded max},direction + axis=radius axis},common={high=0},major={tick text at high}}, + visualize grid={common={direction axis=radius axis},low=0,high=padded max}, + } + }, + /tikz/data visualization/@which radius axes at=@inner radius axes at, + /tikz/data visualization/@which visualize radius axis=@visualize radius axis, + /tikz/data visualization/@visualize zero/.style={@inner visualize zero={##1}}, + }, + clean/.style={ + /tikz/data visualization/@make axes/.style={ + radius axis={ + min value=0, + length=\pgfkeysvalueof{/tikz/data visualization/scientific polar axes/radius}, + padding=.5em, + ticks={few}, + visualize grid={common={direction axis=angle axis,low=min,high=max}}, + }, + angle axis={ + padding=.5em, + visualize axis={radius axis={goto=max}, style={black!25, line cap=rect},low=min,high=max}, + visualize axis={radius axis={goto=padded max}, style={line cap=rect}, low=min,high=max}, + visualize ticks={common={radius axis={goto=padded max}, direction axis=radius axis},common={low=0},major={tick text at high}}, + visualize grid={common={direction axis=radius axis},low=0,high=max}, + } + }, + /tikz/data visualization/@which radius axes at=@clean radius axes at, + /tikz/data visualization/@which visualize radius axis=@visualize clean radius axis, + /tikz/data visualization/@visualize zero/.style={@clean visualize zero={##1}}, + }, + radius/.initial=3.25cm, + % + % First quadrant + % + 0 to pi half/.style={ + @setup axes/.style={ + angle axis={min value=0, max value=1.570796326794897}, + @rad, + @visualize zero=north east, + @inner radius axes at={{0}{low},{1.570796326794897}{high}}, + @clean radius axes at={% + {0}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {1.570796326794897}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{} + } + } + }, + 0 to 90/.style={ + @setup axes/.style={ + angle axis={min value=0, max value=90}, + @degrees, + @visualize zero=north east, + @inner radius axes at={{0}{low},{90}{high}}, + @clean radius axes at={% + {0}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {90}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{} + } + } + }, + quadrant/.style={ + @setup axes/.style={ + angle axis={scaling=min at 0 and max at 90, ticks}, + @visualize zero=north east, + @inner radius axes at={{min}{low},{max}{high}}, + @clean radius axes at={% + {min}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {max}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{} + } + } + }, + quadrant clockwise/.style={ + @setup axes/.style={ + angle axis={scaling=min at 90 and max at 0, ticks}, + @visualize zero=north east, + @inner radius axes at={{min}{low},{max}{high}}, + @clean radius axes at={% + {max}{high}{low}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {min}{low}{high}{xshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{} + } + } + }, + % + % Fourth quadrant + % + -pi half to 0/.style={ + @setup axes/.style={ + angle axis={min value=-1.570796326794897, max value=0}, + @rad, + @visualize zero=south east, + @inner radius axes at={{-1.570796326794897}{low},{0}{high}}, + @clean radius axes at={% + {-1.570796326794897}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {0}{high}{low}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{} + } + } + }, + -90 to 0/.style={ + @setup axes/.style={ + angle axis={min value=-90, max value=0}, + @degrees, + @visualize zero=south east, + @inner radius axes at={{-90}{low},{0}{high}}, + @clean radius axes at={% + {-90}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {0}{high}{low}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{} + } + } + }, + fourth quadrant/.style={ + @setup axes/.style={ + angle axis={scaling=min at -90 and max at 0, ticks}, + @visualize zero=south east, + @inner radius axes at={{min}{low},{max}{high}}, + @clean radius axes at={% + {min}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {max}{high}{low}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{} + } + } + }, + fourth quadrant clockwise/.style={ + @setup axes/.style={ + angle axis={scaling=min at 0 and max at -90, ticks}, + @visualize zero=south east, + @inner radius axes at={{min}{low},{max}{high}}, + @clean radius axes at={% + {max}{high}{low}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {min}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding max}}{} + } + } + }, + % + % Upper half + % + 0 to pi/.style={ + @setup axes/.style={ + angle axis={min value=0, max value=3.141592653589793}, + @rad, + @visualize zero=north, + @inner radius axes at={{0}{low},{1.570796326794897}{high},{3.141592653589793}{high}}, + @clean radius axes at={% + {0}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {3.141592653589793}{high}{low}{yshift=-\pgfkeysvalueof{/tikz/data + visualization/angle axis/padding max}}{options at=0 as + [{style={draw=none}, no tick text}]} + } + } + }, + 0 to 180/.style={ + @setup axes/.style={ + angle axis={min value=0, max value=180}, + @degrees, + @visualize zero=north, + @inner radius axes at={{0}{low},{90}{high},{180}{high}}, + @clean radius axes at={% + {0}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {180}{high}{low}{yshift=-\pgfkeysvalueof{/tikz/data + visualization/angle axis/padding max}}{options at=0 as + [{style={draw=none}, no tick text}]} + } + } + }, + upper half/.style={ + @setup axes/.style={ + angle axis={scaling=min at 0 and max at 180, ticks}, + @visualize zero=north, + @inner radius axes at={{min}{low},{max}{high}}, + @clean radius axes at={% + {min}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {max}{high}{low}{yshift=-\pgfkeysvalueof{/tikz/data + visualization/angle axis/padding max}}{options at=0 as + [{style={draw=none}, no tick text}]} + } + } + }, + upper half clockwise/.style={ + @setup axes/.style={ + angle axis={scaling=min at 180 and max at 0, ticks}, + @visualize zero=north, + @inner radius axes at={{min}{low},{max}{high}}, + @clean radius axes at={% + {min}{low}{high}{yshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {max}{high}{low}{yshift=-\pgfkeysvalueof{/tikz/data + visualization/angle axis/padding max}}{options at=0 as + [{style={draw=none}, no tick text}]} + } + } + }, + % + % Lower half + % + lower half/.style={ + @setup axes/.style={ + angle axis={scaling=min at -180 and max at 0, ticks}, + @visualize zero=south, + @inner radius axes at={{min}{low},{max}{high}}, + @clean radius axes at={% + {min}{low}{high}{yshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {max}{high}{low}{yshift=\pgfkeysvalueof{/tikz/data + visualization/angle axis/padding max}}{options at=0 as + [{style={draw=none}, no tick text}]} + } + } + }, + lower half clockwise/.style={ + @setup axes/.style={ + angle axis={scaling=min at 0 and max at -180, ticks}, + @visualize zero=south, + @inner radius axes at={{min}{low},{max}{high}}, + @clean radius axes at={% + {min}{low}{high}{yshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {max}{high}{low}{yshift=\pgfkeysvalueof{/tikz/data + visualization/angle axis/padding max}}{options at=0 as + [{style={draw=none}, no tick text}]} + } + } + }, + % + % Right half + % + -pi half to pi half/.style={ + @setup axes/.style={ + @rad, + angle axis={min value=-1.570796326794897, max value=1.570796326794897}, + @visualize zero=east, + @inner radius axes at={{0}{low},{1.570796326794897}{low},{-1.570796326794897}{high}}, + @clean radius axes at={% + {-1.570796326794897}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {1.570796326794897}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data + visualization/angle axis/padding max}}{options at=0 as + [{style={draw=none}, no tick text}]} + } + } + }, + -90 to 90/.style={ + @setup axes/.style={ + angle axis={min value=-90, max value=90}, + @degrees, + @visualize zero=east, + @inner radius axes at={{-90}{low},{0}{low},{90}{high}}, + @clean radius axes at={% + {-90}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {90}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data + visualization/angle axis/padding max}}{options at=0 as + [{style={draw=none}, no tick text}]} + } + } + }, + right half/.style={ + @setup axes/.style={ + angle axis={scaling=min at -90 and max at 90, ticks}, + @visualize zero=east, + @inner radius axes at={{min}{low},{max}{high}}, + @clean radius axes at={% + {min}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {max}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data + visualization/angle axis/padding max}}{options at=0 as + [{style={draw=none}, no tick text}]} + } + } + }, + right half clockwise/.style={ + @setup axes/.style={ + angle axis={scaling=min at 90 and max at -90, ticks}, + @visualize zero=east, + @inner radius axes at={{min}{low},{max}{high}}, + @clean radius axes at={% + {min}{low}{high}{xshift=\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {max}{high}{low}{xshift=-\pgfkeysvalueof{/tikz/data + visualization/angle axis/padding max}}{options at=0 as + [{style={draw=none}, no tick text}]} + } + } + }, + % + % Left half + % + left half/.style={ + @setup axes/.style={ + angle axis={scaling=min at 90 and max at 270, ticks}, + @visualize zero=west, + @inner radius axes at={{min}{low},{max}{high}}, + @clean radius axes at={% + {min}{low}{high}{xshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {max}{high}{low}{xshift=\pgfkeysvalueof{/tikz/data + visualization/angle axis/padding max}}{options at=0 as + [{style={draw=none}, no tick text}]} + } + } + }, + left half clockwise/.style={ + @setup axes/.style={ + angle axis={scaling=min at 270 and max at 90, ticks}, + @visualize zero=west, + @inner radius axes at={{min}{low},{max}{high}}, + @clean radius axes at={% + {min}{low}{high}{xshift=-\pgfkeysvalueof{/tikz/data visualization/angle axis/padding min}}{},% + {max}{high}{low}{xshift=\pgfkeysvalueof{/tikz/data + visualization/angle axis/padding max}}{options at=0 as + [{style={draw=none}, no tick text}]} + } + } + }, + % + % Full circle + % + 0 to 2pi/.style={ + @setup axes/.style={ + angle axis={min value=0, max value=6.283185307179586}, + @rad, + @visualize zero=north east, + @inner radius axes at={{0}{low},{1.570796326794897}{high},{3.141592653589793}{high},{4.71238898038469}{low}}, + @clean radius axes at={{0}{low}{high}{}{}} + } + }, + -pi to pi/.style={ + @setup axes/.style={ + angle axis={min value=-3.141592653589793, max value=3.141592653589793}, + @rad, + @visualize zero=north east, + @inner radius axes at={{0}{low},{1.570796326794897}{high},{3.141592653589793}{high},{-1.57079632679489}{low}}, + @clean radius axes at={{0}{low}{high}{}{}} + } + }, + 0 to 360/.style={ + @setup axes/.style={ + angle axis={min value=0, max value=360}, + @degrees, + @visualize zero=north east, + @inner radius axes at={{0}{low},{90}{high},{180}{high},{270}{low}}, + @clean radius axes at={{0}{low}{high}{}{}} + } + }, + -180 to 180/.style={ + @setup axes/.style={ + angle axis={min value=-180, max value=180}, + @degrees, + @visualize zero=north east, + @inner radius axes at={{0}{low},{90}{high},{180}{high},{-90}{low}}, + @clean radius axes at={{0}{low}{high}{}{}} + } + }, } + + +% +% Pie-charts -- still under construction... +% + \tikzset{ /tikz/data visualization/axis options/.cd, - deg/.style={\tikz@dv@axis/scaling=0 at 0 and 360 at 360}, - rad/.style={\tikz@dv@axis/scaling=0 at 0 and pi at 180}, - grad/.style={\tikz@dv@axis/scaling=0 at 0 and 400 at 360}, - percent/.style={\tikz@dv@axis/scaling=0 at 0 and 100 at 360}, + percent/.style={\tikz@dv@axis/scaling=0 at 0 and 1 at 3.6}, full circle/.style={\tikz@dv@axis/scaling=min at 0 and max at 360}, half circle/.style={\tikz@dv@axis/scaling=min at 0 and max at 180}, quarter circle/.style={\tikz@dv@axis/scaling=min at 0 and max at 90} @@ -59,4 +561,5 @@ + \endinput diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.basic.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.basic.code.tex deleted file mode 100644 index 7464369161c..00000000000 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.basic.code.tex +++ /dev/null @@ -1,29 +0,0 @@ -% Copyright 2010 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. - -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.basic.code.tex,v 1.1 2010/10/23 16:35:41 tantau Exp $ - - - -% -% This is jsut a place-holder -% - -\tikzset{graphs/n/.initial=1} - -\tikzdefgraph{K} -{ - \pgfkeysgetvalue{/tikz/graphs/n}\tikz@lib@graph@temp@n -} -{ - [connect as=clique] - \foreach \tikz@lib@graph@temp@i in {1,...,\tikz@lib@graph@temp@n} - { \tikz@lib@graph@temp@i [at=(\tikz@lib@graph@temp@i*360/\tikz@lib@graph@temp@n:2cm)] } -} - diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.code.tex index 32fd3a374a7..c82c98c7db7 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.code.tex @@ -1,4 +1,5 @@ % Copyright 2010 by Till Tantau +% Copyright 2011 by Jannis Pohlmann % % This file may be distributed and/or modified % @@ -7,19 +8,63 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.code.tex,v 1.1 2010/10/23 16:35:41 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.code.tex,v 1.43 2013/10/10 09:08:58 tantau Exp $ % % Interface keys % -\tikzset{ - graphs/new edge directed/.code n args={3}{\path (#1) edge[->,#3] (#2);}, - graphs/new edge undirected/.code n args={3}{\path (#1) edge[-,#3] (#2);}, - graphs/new edge bidirected/.code n args={3}{\path (#1) edge[<->,#3] (#2);}, - graphs/new edge back directed/.style n args={3}{new edge directed={#2}{#1}{#3}}, - graphs/default edge kind/.initial=undirected +\def\tikzgraphsset{\pgfqkeys{/tikz/graphs}} + +\tikzgraphsset{ + new ->/.code n args={4}{% + \path [->,every new ->/.try] + (#1\tikzgraphleftanchor) + edge[#3] #4 + (#2\tikzgraphrightanchor);}, + new --/.code n args={4}{ + \path [-,every new --/.try] + (#1\tikzgraphleftanchor) + edge[#3] #4 + (#2\tikzgraphrightanchor);}, + new <->/.code n args={4}{ + \path [<->,every new <->/.try] + (#1\tikzgraphleftanchor) + edge[#3] #4 + (#2\tikzgraphrightanchor);}, + new -!-/.code n args={4}{}, + new <-/.code n args={4}{% + \path [<-,every new <-/.try] + (#1\tikzgraphleftanchor) + edge[#3] #4 + (#2\tikzgraphrightanchor); + } +} + + +\def\tikz@lib@graph@store@anchor#1#2{% + \def\tikz@temp{#1} + \ifx\tikz@temp\pgfutil@empty% + \let#2\tikz@temp% + \else% + \def\tikz@temp{.#1} + \let#2\tikz@temp% + \fi% +} + +\tikzgraphsset{ + default edge kind/.initial=--, + --/.style={default edge kind=--}, + ->/.style={default edge kind=->}, + <-/.style={default edge kind=<-}, + <->/.style={default edge kind=<->}, + -!-/.style={default edge kind=-!-}, + default edge operator/.initial=matching and star, + left anchor/.code=\tikz@lib@graph@store@anchor{#1}{\tikzgraphleftanchor}, + right anchor/.code=\tikz@lib@graph@store@anchor{#1}{\tikzgraphrightanchor}, + left anchor=, + right anchor= } @@ -28,8 +73,8 @@ % it were declared there % -\tikzset{ - graphs/use existing nodes/.code=\tikz@lib@graph@alltrue +\tikzgraphsset{ + use existing nodes/.is if=tikz@lib@graph@all } \tikzset{ @@ -37,6 +82,7 @@ \expandafter\global\expandafter\let\csname tikz@lg@node@set #1\endcsname\pgfutil@empty% }, set/.code={ + \tikz@fig@mustbenamed% \expandafter\def\expandafter\tikz@alias\expandafter{\tikz@alias% \expandafter\def\expandafter\pgf@temp\expandafter{\csname tikz@lg@node@set #1\endcsname}% \expandafter\expandafter\expandafter\pgfutil@g@addto@macro\expandafter\pgf@temp\expandafter{\expandafter\tikz@lg@do\expandafter{\tikz@fig@name}}% @@ -47,17 +93,97 @@ \newif\iftikz@lib@graph@all +% +% Simple versus multi graphs +% +\tikzgraphsset{ + simple/.code={ + \iftikz@lib@graph@simple% + % is already simple, ignore + \else + \tikz@lib@graph@simpletrue% + \pgfkeysalso{operator=\tikz@lib@graph@simple@done}% + \fi% + }, + multi/.code={ + \tikz@lib@graph@simplefalse% + } +} + +\newif\iftikz@lib@graph@simple + +\def\tikz@lib@graph@set@simple@edge#1#2#3#4#5{% + % #1 = kind (<-, ->, ...) + % #2 = from + % #3 = to + % #4 = options + % #5 = edge nodes + % + % Ok, first, test, whether edge exists: + \ifcsname tikz@lg@e@#3@#2\endcsname% + \expandafter\global\expandafter\let\csname tikz@lg@e@#3@#2\endcsname\relax% reset + \fi% + \expandafter\gdef\csname tikz@lg@e@#2@#3\endcsname{\tikz@lib@graph@make@simple@edge{#1}{#2}{#3}{#4}{#5}}% +} + +\def\tikz@lib@graph@make@simple@edge#1#2#3#4#5{% + \pgfqkeys{/tikz/graphs}{new #1={#2}{#3}{#4}{#5}}% +} + + +\def\tikz@lib@graph@simple@done{% + \tikz@lib@graph@pack@node@list% + {% + \let\tikz@lg@do\tikz@lib@graph@simple@node% + \tikz@lib@graph@node@list + }% +} + +\def\tikz@lib@graph@simple@node#1{% + {% + \def\tikz@lib@graph@simple@from@node{#1}% + \let\tikz@lg@do\tikz@lib@graph@simple@other@node% + \tikz@lib@graph@node@list% + }% +} + +\def\tikz@lib@graph@simple@other@node#1{% + \ifcsname tikz@lg@e@\tikz@lib@graph@simple@from@node @#1\endcsname% + \csname tikz@lg@e@\tikz@lib@graph@simple@from@node @#1\endcsname% + \expandafter\global\expandafter\let\csname tikz@lg@e@\tikz@lib@graph@simple@from@node @#1\endcsname\relax% + \fi% +} + + % % Basic options % -\tikzset{ - graphs/@nodes styling/.style=, - graphs/nodes/.style={/tikz/graphs/@nodes styling/.append style={,#1}}, - graphs/@edges styling/.initial=, - graphs/edges/.style={/tikz/graphs/@edges styling/.append={,#1}}, - graphs/join/.initial=match, - graphs/connect as/.initial=, +\tikzgraphsset{ + @nodes styling/.style=, + nodes/.style={/tikz/graphs/@nodes styling/.append style={,#1}}, + @edges styling/.initial=, + edges/.style={/tikz/graphs/@edges styling/.append={,#1}}, + edge/.style={edges={#1}}, + @edges node/.initial=, + edge node/.style={/tikz/graphs/@edges node/.append={#1}}, + edge label/.style={/tikz/graphs/@edges node/.append={node[auto]{#1}}}, + edge label'/.style={/tikz/graphs/@edges node/.append={node[auto,swap]{#1}}}, + @operators/.initial=, + operator/.style={/tikz/graphs/@operators/.append={#1}}, + @extra group options/.style=, +} + + +\def\tikzgraphinvokeoperator#1{% + {% + \pgfkeyslet{/tikz/graphs/@operators}\pgfutil@empty% + \pgfkeys{/tikz/graphs/.cd,#1}% + \pgfkeysgetvalue{/tikz/graphs/@operators}\tikz@lib@graph@temp% + \global\let\tikz@lib@graph@temp\tikz@lib@graph@temp% + }% + \tikz@lib@graph@temp% + \global\let\tikz@lib@graph@temp\relax% } @@ -69,25 +195,159 @@ \pgfutil@ifnextchar[{\tikz@lib@graph@parser@}{\tikz@lib@graph@parser@[]}%] } -\long\def\tikz@lib@graph@parser@[#1]#2{% - \scope[graphs/.cd,every graph/.try,#1]% - \let\tikz@lib@graph@options\pgfutil@empty% - \let\tikz@lib@graph@node@list\pgfutil@empty% - \tikz@lib@graph@parse@group{#2}% - \let\tikz@lg@do=\tikz@lib@graph@cleanup% - \tikz@lib@graph@node@list% - \endscope% +\def\tikz@lib@graph@parser@[#1]{% + \setbox\tikz@whichbox=\hbox\bgroup% + \unhbox\tikz@whichbox% + \hbox\bgroup + \bgroup% + \pgfinterruptpath% + \scope[graphs/.cd,@graph drawing setup/.try,@operators=,every graph/.try,#1]% + \begingroup% + \iftikz@graph@quick% + \expandafter\tikz@lib@graphs@parse@quick@graph% + \else% + \expandafter\tikz@lib@graphs@normal@main% + \fi% +} + +\long\def\tikz@lib@graphs@normal@main#1{% + \pgfkeysgetvalue{/tikz/graphs/@operators}\tikz@lib@graph@outer@operators% + \let\tikz@lib@graph@options\pgfutil@empty% + \let\tikz@lib@graph@node@list\pgfutil@empty% + \pgfkeyssetvalue{/tikz/graphs/placement/depth}{0}% + \pgfkeyssetvalue{/tikz/graphs/placement/width}{0}% + \pgfkeyssetvalue{/tikz/graphs/placement/level}{0}% + \tikz@lib@graph@start@hint@group% + \tikz@lib@graph@parse@group{#1}% + \tikz@lib@graph@end@hint@group + \tikz@lib@graph@outer@operators% + \let\tikz@lg@do=\tikz@lib@graph@cleanup% + \tikz@lib@graph@node@list% + \tikz@lib@graph@main@done% +} + +\def\tikz@lib@graph@main@done{% + \endgroup% + \endscope% + \endpgfinterruptpath% + \egroup + \egroup% + \egroup% \tikz@lib@graph@parser@done% } -\long\def\tikz@lib@graph@parse@group#1{% + +\def\tikz@lib@graph@start@hint@group{% + \pgfkeyssetvalue{/tikz/graphs/placement/local depth}{0}% + \pgfkeyssetvalue{/tikz/graphs/placement/local width}{0}% + \pgfkeyssetvalue{/tikz/graphs/placement/chain count}{0}% + \pgfkeyssetvalue{/tikz/graphs/placement/element count}{0}% +} + +\def\tikz@lib@graph@end@hint@group{% + % Get local depth and width outside + \xdef\tikz@lib@graph@group@depth{\pgfkeysvalueof{/tikz/graphs/placement/local depth}} + \xdef\tikz@lib@graph@group@width{\pgfkeysvalueof{/tikz/graphs/placement/local width}} +} + +\def\tikz@lib@graph@hint@aftergroup{% + \pgfkeysgetvalue{/tikz/graphs/placement/width}\tikz@temp@h% + \pgfkeysgetvalue{/tikz/graphs/placement/local width}\tikz@temp@lh% + \pgfkeysgetvalue{/tikz/graphs/placement/local depth}\tikz@temp@lw% + \pgfmathsetmacro\tikz@temp@h{\tikz@lib@graph@group@width+\tikz@temp@h} + \pgfmathsetmacro\tikz@temp@lh{\tikz@lib@graph@group@width+\tikz@temp@lh} + \pgfmathsetmacro\tikz@temp@lw{max(\tikz@lib@graph@group@depth,\tikz@temp@lw)} + \pgfkeyslet{/tikz/graphs/placement/width}\tikz@temp@h% + \pgfkeyslet{/tikz/graphs/placement/local width}\tikz@temp@lh% + \pgfkeyslet{/tikz/graphs/placement/local depth}\tikz@temp@lw% + % + \pgfkeysgetvalue{/tikz/graphs/placement/element count}\tikz@temp% + \c@pgf@counta=\tikz@temp\relax% + \advance\c@pgf@counta by1\relax% + \edef\tikz@temp{\the\c@pgf@counta}% + \pgfkeyslet{/tikz/graphs/placement/element count}\tikz@temp% +} + +\def\tikz@lib@graph@placement@update{% + \pgfkeys{/tikz/graphs/placement/logical node depth/.expand once=\tikz@lib@graph@name} + \let\tikz@lib@graph@node@depth\pgfmathresult + \pgfkeys{/tikz/graphs/placement/logical node width/.expand once=\tikz@lib@graph@name} + \let\tikz@lib@graph@node@width\pgfmathresult + % This is a single node, so update the lengths accordingly + \pgfkeysgetvalue{/tikz/graphs/placement/width}\tikz@temp@h% + \pgfkeysgetvalue{/tikz/graphs/placement/local width}\tikz@temp@lh% + \pgfkeysgetvalue{/tikz/graphs/placement/local depth}\tikz@temp@lw% + \pgfmathsetmacro\tikz@temp@h{\tikz@lib@graph@node@width+\tikz@temp@h} + \pgfmathsetmacro\tikz@temp@lh{\tikz@lib@graph@node@width+\tikz@temp@lh} + \pgfmathsetmacro\tikz@temp@lw{max(\tikz@lib@graph@node@depth,\tikz@temp@lw)} + \pgfkeyslet{/tikz/graphs/placement/width}\tikz@temp@h% + \pgfkeyslet{/tikz/graphs/placement/local width}\tikz@temp@lh% + \pgfkeyslet{/tikz/graphs/placement/local depth}\tikz@temp@lw% + % + \pgfkeysgetvalue{/tikz/graphs/placement/element count}\tikz@temp% + \c@pgf@counta=\tikz@temp\relax% + \advance\c@pgf@counta by1\relax% + \edef\tikz@temp{\the\c@pgf@counta}% + \pgfkeyslet{/tikz/graphs/placement/element count}\tikz@temp% +} + +\def\tikz@lib@graph@placement@after@chain@update{% + \pgfkeysgetvalue{/tikz/graphs/placement/depth}\tikz@temp@w% + \pgfkeysgetvalue{/tikz/graphs/placement/local width}\tikz@temp@lh% + \pgfkeysgetvalue{/tikz/graphs/placement/local depth}\tikz@temp@lw% + \pgfmathsetmacro\tikz@temp@w{\tikz@lib@graph@chain@depth+\tikz@temp@w}% + \pgfmathsetmacro\tikz@temp@lw{\tikz@lib@graph@chain@depth+\tikz@temp@lw}% + \pgfmathsetmacro\tikz@temp@lh{max(\tikz@lib@graph@chain@width,\tikz@temp@lh)}% + \pgfkeyslet{/tikz/graphs/placement/depth}\tikz@temp@w% + \pgfkeyslet{/tikz/graphs/placement/local width}\tikz@temp@lh% + \pgfkeyslet{/tikz/graphs/placement/local depth}\tikz@temp@lw% + % + \pgfkeysgetvalue{/tikz/graphs/placement/chain count}\tikz@temp% + \c@pgf@counta=\tikz@temp\relax% + \advance\c@pgf@counta by1\relax% + \edef\tikz@temp{\the\c@pgf@counta}% + \pgfkeyslet{/tikz/graphs/placement/chain count}\tikz@temp% +} + + +% +% Parse a group +% + +\long\def\tikz@lib@graph@parse@group#1{ + \let\tikz@lib@graph@group@qa\pgfutil@empty% + \let\tikz@lib@graph@group@q\pgfutil@empty% \let\tikz@lib@graph@group@c\pgfutil@empty% \let\tikz@lib@graph@group@cont\pgfutil@empty% \let\tikz@lib@graph@group@conta\pgfutil@empty% - \tikz@lib@graph@par#1\par\pgf@stop@eogroup% + \tikz@lib@graph@group@check#1\par\pgf@stop@eogroup% +} + + + +% +% Start of a group +% +\def\tikz@lib@graph@group@check{% + \pgfutil@ifnextchar[\tikz@lib@graph@group@opt{\tikz@lib@graph@group@opt[]}%] +} + +\def\tikz@lib@graph@group@opt[#1]{% + \let\tikz@lib@graph@parse@extras\pgfutil@empty% + \tikzgraphsset{ + @operators=, + every group/.try, + @extra group options, + @extra group options/.style=,% + #1}% + \expandafter\tikz@lib@graph@par\tikz@lib@graph@parse@extras% +} + +\tikzgraphsset{ + parse/.code={\expandafter\def\expandafter\tikz@lib@graph@parse@extras\expandafter{\tikz@lib@graph@parse@extras#1}}, } @@ -96,19 +356,95 @@ % Remove \par % -\long\def\tikz@lib@graph@par#1\par{% +\def\tikz@lib@graph@par{% + \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@par@@}{\tikz@lib@graph@par@}% +} +\long\def\tikz@lib@graph@par@#1\par{% \pgfutil@ifnextchar\pgf@stop@eogroup{% - \expandafter\tikz@lib@graph@encloser\tikz@lib@graph@group@c#1[}{% + \expandafter\tikz@lib@graph@quotes\tikz@lib@graph@group@c#1"}{% \expandafter\def\expandafter\tikz@lib@graph@group@c\expandafter{\tikz@lib@graph@group@c#1}% \tikz@lib@graph@par% }% } +\long\def\tikz@lib@graph@par@@#1{% + \expandafter\def\expandafter\tikz@lib@graph@group@c\expandafter{\tikz@lib@graph@group@c{#1}}% + \tikz@lib@graph@par +} + + + +% +% Replace ..."..."... by ..."{...}"... +% +\def\tikz@lib@graph@quotes{% + \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@quotes@@}{\tikz@lib@graph@quotes@}% +}% +\def\tikz@lib@graph@quotes@#1"{% + \pgfutil@ifnextchar\pgf@stop@eogroup{% + \tikz@lib@graph@passon{#1}% + }{% + \expandafter\def\expandafter\tikz@lib@graph@group@q\expandafter{\tikz@lib@graph@group@q#1"}% + \tikz@lib@graph@quotes@cont% + }% +} + +\def\tikz@lib@graph@quotes@cont#1"#2"{% + \pgfutil@ifnextchar\pgf@stop@eogroup{% + \tikz@lib@graph@passon{{#1}"#2}}{% + \expandafter\def\expandafter\tikz@lib@graph@group@q\expandafter{\tikz@lib@graph@group@q{#1}"#2"}% + \tikz@lib@graph@quotes@cont}% +} + +\def\tikz@lib@graph@quotes@@#1{% + \expandafter\def\expandafter\tikz@lib@graph@group@q\expandafter{\tikz@lib@graph@group@q{#1}}% + \tikz@lib@graph@quotes% +} + + + +% +% Replace ..."..."... by ..."{...}"... (active version) +% +{ + \catcode`\"=13\relax + + \gdef\tikz@lib@graph@passon#1{\expandafter\tikz@lib@graph@quotesactive\tikz@lib@graph@group@q#1"}% + + \gdef\tikz@lib@graph@quotesactive{% + \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@quotesactive@@}{\tikz@lib@graph@quotesactive@}% + }% + \gdef\tikz@lib@graph@quotesactive@#1"{% + \pgfutil@ifnextchar\pgf@stop@eogroup{% + \expandafter\tikz@lib@graph@encloser\tikz@lib@graph@group@qa#1[% + }{% + \expandafter\def\expandafter\tikz@lib@graph@group@qa\expandafter{\tikz@lib@graph@group@qa#1"}% + \tikz@lib@graph@quotesactive@cont% + }% + } + + \gdef\tikz@lib@graph@quotesactive@cont#1"#2"{% + \pgfutil@ifnextchar\pgf@stop@eogroup{% + \expandafter\tikz@lib@graph@encloser\tikz@lib@graph@group@qa{#1}"#2[}{% + \expandafter\def\expandafter\tikz@lib@graph@group@qa\expandafter{\tikz@lib@graph@group@qa{#1}"#2"}% + \tikz@lib@graph@quotesactive@cont}% + } + + \gdef\tikz@lib@graph@quotesactive@@#1{% + \expandafter\def\expandafter\tikz@lib@graph@group@qa\expandafter{\tikz@lib@graph@group@qa{#1}}% + \tikz@lib@graph@quotesactive% + } +} + + % % Replace ...[...]... by ...[{...}]... % -\def\tikz@lib@graph@encloser#1[{% +\def\tikz@lib@graph@encloser{% + \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@encloser@@}{\tikz@lib@graph@encloser@}% +}% +\def\tikz@lib@graph@encloser@#1[{% \pgfutil@ifnextchar\pgf@stop@eogroup{% \expandafter\tikz@lib@graph@semi\tikz@lib@graph@group@cont#1;% }{% @@ -124,31 +460,31 @@ \tikz@lib@graph@encloser@cont}% } +\def\tikz@lib@graph@encloser@@#1{% + \expandafter\def\expandafter\tikz@lib@graph@group@cont\expandafter{\tikz@lib@graph@group@cont{#1}}% + \tikz@lib@graph@encloser% +} + + + % % Replace ; by , % -\def\tikz@lib@graph@semi#1;{% +\def\tikz@lib@graph@semi{% + \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@semi@@}{\tikz@lib@graph@semi@}% +} +\def\tikz@lib@graph@semi@#1;{% \pgfutil@ifnextchar\pgf@stop@eogroup{% - \expandafter\tikz@lib@graph@start@group\tikz@lib@graph@group@conta#1,}{% + \expandafter\tikz@lib@graph@main@parser\tikz@lib@graph@group@conta#1,}{% \expandafter\def\expandafter\tikz@lib@graph@group@conta\expandafter{\tikz@lib@graph@group@conta#1,}% \tikz@lib@graph@semi% }% } - - - -% -% Start of a group -% -\def\tikz@lib@graph@start@group{% - \pgfutil@ifnextchar[\tikz@lib@graph@start@group@opt{\tikz@lib@graph@start@group@opt[]}%] -} - -\def\tikz@lib@graph@start@group@opt[#1]{% - \pgfkeys{/tikz/graphs/.cd,connect as=,every group/.try,#1}% - \tikz@lib@graph@main@parser% +\def\tikz@lib@graph@semi@@#1{% + \expandafter\def\expandafter\tikz@lib@graph@group@conta\expandafter{\tikz@lib@graph@group@conta{#1}}% + \tikz@lib@graph@semi% } @@ -156,13 +492,26 @@ % Main parse % -\def\tikz@lib@graph@main@parser#1,{% +\def\tikz@lib@graph@main@parser{% \begingroup% + \pgfkeyssetvalue{/tikz/graphs/placement/local depth}{0}% + \pgfkeyssetvalue{/tikz/graphs/placement/local width}{0}% \let\tikz@lib@graph@stored@actions\pgfutil@empty% \let\tikz@lib@graph@node@list\pgfutil@empty% reset - \tikz@lib@graph@parse@one#1-\pgf@stop@eodashes% + \tikz@lib@graph@main@parser@start% +} +\def\tikz@lib@graph@main@parser@start{% + \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@protect@group}{\tikz@lib@graph@main@parser@cont}% +} + +\def\tikz@lib@graph@protect@group#1{% skip space + \pgfutil@ifnextchar\relax{\tikz@lib@graph@main@parser@cont{{#1}}}{\tikz@lib@graph@main@parser@cont{{#1}}}% } +\def\tikz@lib@graph@main@parser@cont{\tikz@lib@graph@check@quotes\tikz@lib@graph@main@parser@cont@normal} +\def\tikz@lib@graph@main@parser@cont@normal#1,{% + \tikz@lib@graph@parse@one#1-\pgf@stop@eodashes% +} \def\tikz@lib@graph@parse@one{% \pgfutil@ifnextchar\bgroup\tikz@lib@graph@scope\tikz@lib@graph@node% @@ -170,10 +519,134 @@ +% Special quoted nodes + +\def\tikz@lib@graph@check@quotes#1{% + \let\tikz@lib@graph@cont@quote#1% + \pgfutil@ifnextchar"{\begingroup\pgfkeys@temptoks{}\pgfutil@empty\tikz@lib@graph@quote@parser}{\tikz@lib@graph@check@quotes@active}% +} +{ + \catcode`\"=13\relax + \gdef\tikz@lib@graph@check@quotes@active{% + \pgfutil@ifnextchar"{\begingroup\pgfkeys@temptoks{}\pgfutil@empty\tikz@lib@graph@quote@parser@active}{\tikz@lib@graph@cont@quote}% + } + \gdef\tikz@lib@graph@quote@parser@active"#1"{% + \pgfkeys@temptoks\expandafter{\the\pgfkeys@temptoks #1}% + \pgfutil@ifnextchar"{\pgfkeys@temptoks\expandafter{\the\pgfkeys@temptoks "}\tikz@lib@graph@quote@parser@active}{\tikz@lib@graph@quote@parser@done}% + } +} + +\def\tikz@lib@graph@quote@parser"#1"{% + \pgfkeys@temptoks\expandafter{\the\pgfkeys@temptoks #1}% + \pgfutil@ifnextchar"{\pgfkeys@temptoks\expandafter{\the\pgfkeys@temptoks "}\tikz@lib@graph@quote@parser}{\tikz@lib@graph@quote@parser@done}% +} + +\def\tikz@lib@graph@quote@parser@done{% + {\expandafter\scantokens\expandafter{% + \expandafter\expandafter\expandafter\tikzlibgraphactivations\expandafter\expandafter\expandafter\tikzlibgraphdoedef\expandafter{\the\pgfkeys@temptoks}% + }}% + {\expandafter\scantokens\expandafter{\expandafter\tikzlibgraphactivationsbrace\expandafter\xdef\expandafter\tikzlibgraphreplaced\expandafter<\tikzlibgraphreplaced>\catcode`\}=2\relax}}% + \edef\tikzlibgraphreplaced{\expandafter\detokenize\expandafter{\tikzlibgraphreplaced}} + \pgfutil@ifnextchar/\tikz@lib@graph@quotes@slash\tikz@lib@graph@quotes@no@slash% +} +\def\tikz@lib@graph@quotes@no@slash{% + \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter% + \tikz@smuggle\expandafter\expandafter\expandafter{\expandafter\tikzlibgraphreplaced\expandafter/\expandafter{\the\pgfkeys@temptoks}}% + \expandafter\endgroup\expandafter\tikz@lib@graph@cont@quote\tikz@smuggle% +} +\def\tikz@lib@graph@quotes@slash/{% + \pgfutil@ifnextchar/% Ah, double slash... + {\tikz@lib@graph@quotes@no@slash/}{\expandafter\endgroup\expandafter\tikz@lib@graph@cont@quote\tikzlibgraphreplaced/}% +} +\def\tikzlibgraphdoedef{\xdef\tikzlibgraphreplaced} + +\def\tikz@lib@prepare@active#1#2#3{% + {% + \catcode`#1=13\relax% + \scantokens{\gdef\tikzlibgraphactivator{\def#2{@#3@}}}% + } + \pgfutil@g@addto@macro\tikzlibgraphactivations{\catcode`#1=13\relax} + \expandafter\pgfutil@g@addto@macro\expandafter\tikzlibgraphactivations\expandafter{\tikzlibgraphactivator} +} + +\let\tikzlibgraphactivations\pgfutil@empty + +% +% Remove \outer from \+ for plain TeX +% + +\outer\def\tikz@lib@outer@test{\tabalign} +\ifx\+\tikz@lib@outer@test + \def\+{\tabalign} +\fi + +\tikz@lib@prepare@active{\$}{$}{DOLLAR SIGN}% $ +\tikz@lib@prepare@active{\&}{&}{AMPERSAND}% +\tikz@lib@prepare@active{\^}{^}{CIRCUMFLEX ACCENT}% +\tikz@lib@prepare@active{\~}{~}{TILDE}% +\tikz@lib@prepare@active{\_}{_}{LOW LINE}% +\tikz@lib@prepare@active{\|}{|}{VERTICAL LINE}% +\tikz@lib@prepare@active{\[}{[}{LEFT SQUARE BRACKET}% +\tikz@lib@prepare@active{\]}{]}{RIGHT SQUARE BRACKET}% +\tikz@lib@prepare@active{\(}{(}{LEFT PARENTHESIS}% +\tikz@lib@prepare@active{\)}{)}{RIGHT PARENTHESIS}% +\tikz@lib@prepare@active{\/}{/}{SOLIDUS}% +\tikz@lib@prepare@active{\.}{.}{FULL STOP}% +\tikz@lib@prepare@active{\-}{-}{HYPHEN MINUS}% +\tikz@lib@prepare@active{\,}{,}{COMMA}% +\tikz@lib@prepare@active{\+}{+}{PLUS SIGN}% +\tikz@lib@prepare@active{\*}{*}{ASTERISK}% +\tikz@lib@prepare@active{\'}{'}{APOSTROPHE}% +\tikz@lib@prepare@active{\!}{!}{EXCLAMATION MARK}% +\tikz@lib@prepare@active{\"}{"}{QUOTATION MARK}% +\tikz@lib@prepare@active{\:}{:}{COLON}% +\tikz@lib@prepare@active{\;}{;}{SEMINCOLON}% +\tikz@lib@prepare@active{\<}{<}{LESS THAN SIGN}% +\tikz@lib@prepare@active{\=}{=}{EQUALS SIGN}% +\tikz@lib@prepare@active{\>}{>}{GREATER THAN SIGN}% +\tikz@lib@prepare@active{\?}{?}{QUESTION MARK}% +%\tikz@lib@prepare@active{\@}{@}{COMMERCIAL AT}% +\tikz@lib@prepare@active{\`}{`}{GRAVE ACCENT}% +{\catcode`\%=11\catcode`\#=11 +\tikz@lib@prepare@active{\%}{%}{PERCENT SIGN} +\tikz@lib@prepare@active{\#}{#}{NUMBER SIGN} +} + +\pgfutil@g@addto@macro\tikzlibgraphactivations{\catcode`\\=13\relax} +{ + \catcode`\|=0\relax + \catcode`\\=13\relax + |pgfutil@g@addto@macro|tikzlibgraphactivations{|def\{@REVERSE SOLIDUS@}} +} +{ + \gdef\tikzlibgraphscommercialat{@COMMERCIAL AT@} + \let\g=\pgfutil@g@addto@macro + \catcode`\@=13\relax + \g\tikzlibgraphactivations{\catcode`\@=13\relax\let@=\tikzlibgraphscommercialat} +} + +\def\tikzlibgraphactivationsbrace{% + \catcode`\{=13\relax% + \catcode`\}=13\relax% + \catcode`\<=1\relax% + \catcode`\>=2\relax% +} +{ + \catcode`\{=13\relax% + \catcode`\}=13\relax% + \catcode`\<=1\relax% + \catcode`\>=2\relax% + \pgfutil@g@addto@macro\tikzlibgraphactivationsbrace<\def{<@LEFT CURLY BRACE@>> %} + \pgfutil@g@addto@macro\tikzlibgraphactivationsbrace<\def}<@RIGHT CURLY BRACE@>> %{ +> % A normal node -\def\tikz@lib@graph@node#1-{% +% First, check for special quote syntax: + +\def\tikz@lib@graph@node{\tikz@lib@graph@check@quotes\tikz@lib@graph@node@normal} + +\def\tikz@lib@graph@node@normal#1-{% % Detect trailing < \tikz@lib@graph@@node#1<\pgf@stop% } @@ -186,7 +659,7 @@ % Syntax: node name [options] % % Grab node name - \tikz@lib@graph@grab@name#1[\pgf@stop% + \tikz@lib@graph@grab@name#1\pgf@stop% \tikz@lib@graph@stored@actions% \pgfutil@ifnextchar\pgf@stop@eodashes{% \tikz@lib@graph@graph@done% @@ -194,7 +667,7 @@ % % Now, get arrow kind % - \def\pgf@test{#2}% + \def\pgf@test{#2}% \ifx\pgf@test\pgfutil@empty% \expandafter\tikz@lib@graph@no@back@arrow% \else% @@ -206,30 +679,37 @@ \def\tikz@lib@graph@no@back@arrow{% \pgfutil@ifnextchar>\tikz@lib@graph@forward@arrow{% \pgfutil@ifnextchar-\tikz@lib@graph@undirected@arrow{% - \PackageError{graphs library}{One of the arrow types <-, --, ->, or <-> expected}{}% - \tikz@lib@graph@undirected@arrow% + \pgfutil@ifnextchar!\tikz@lib@graph@no@arrow{% + \tikzerror{One of the arrow types <-, --, ->, -!- or <-> expected}% + \tikz@lib@graph@undirected@arrow% + }% }% }% } \def\tikz@lib@graph@undirected@arrow-{% - \def\tikz@lib@graph@arrow@type{undirected}% + \def\tikz@lib@graph@arrow@type{--}% \tikz@lib@graph@after@arrow% } \def\tikz@lib@graph@forward@arrow>{% - \def\tikz@lib@graph@arrow@type{directed}% + \def\tikz@lib@graph@arrow@type{->}% \tikz@lib@graph@after@arrow% } \def\tikz@lib@graph@bi@arrow>{% - \def\tikz@lib@graph@arrow@type{bidirected}% + \def\tikz@lib@graph@arrow@type{<->}% + \tikz@lib@graph@after@arrow% +} + +\def\tikz@lib@graph@no@arrow!-{% + \def\tikz@lib@graph@arrow@type{-!-}% \tikz@lib@graph@after@arrow% } \def\tikz@lib@graph@back@arrow{% \pgfutil@ifnextchar>{\tikz@lib@graph@bi@arrow}{% - \def\tikz@lib@graph@arrow@type{back directed}% + \def\tikz@lib@graph@arrow@type{<-}% \tikz@lib@graph@after@arrow% }% } @@ -241,46 +721,62 @@ \def\tikz@lib@graph@after@arrow@opt[#1]{% % % Ok, first recolor - % - \pgfkeys{/tikz/graph node/recolor in by=in''} - \pgfkeys{/tikz/graph node/recolor out by=out'} + % + \tikzgraphinvokeoperator{recolor source by=source''} + \tikzgraphinvokeoperator{recolor target by=target'} % Save action for next node \expandafter\def\expandafter\tikz@lib@graph@stored@actions\expandafter{% \expandafter\tikz@lib@graph@joiner\expandafter{\tikz@lib@graph@arrow@type}{#1}}% + % + \tikzgdeventgroupcallback{descendants}% \tikz@lib@graph@parse@one% } \def\tikz@lib@graph@joiner#1#2{% - \pgfkeys{/tikz/graph node/recolor in by=in'} - \pgfkeys{/tikz/graph node/recolor in'' by=in} + \tikzgraphinvokeoperator{recolor source by=source'} + \tikzgraphinvokeoperator{recolor source'' by=source} {% + \tikz@enable@edge@quotes% \pgfkeyssetvalue{/tikz/graphs/default edge kind}{#1}% - \pgfkeys{/tikz/graphs/.cd,#2}% - \pgfkeysgetvalue{/tikz/graphs/join}\pgf@temp% - \expandafter\tikz@lg@do@connector\expandafter{\pgf@temp}% + \pgfkeys{/tikz/graphs/.cd,@operators=,% + /tikz/graphs/.unknown/.code=\tikz@lib@graph@unknown@edge@option{##1},#2}% + \pgfkeysgetvalue{/tikz/graphs/@operators}\pgf@temp% + \ifx\pgf@temp\pgfutil@empty% + \edef\pgf@temp{\noexpand\pgfkeys{/tikz/graphs/.cd,\pgfkeysvalueof{/tikz/graphs/default edge operator}}}% + \pgf@temp% + \pgfkeysgetvalue{/tikz/graphs/@operators}\pgf@temp% + \fi% + \pgf@temp% }% - \pgfkeys{/tikz/graph node/!in',/tikz/graph node/!out'} + \tikzgraphinvokeoperator{not source',not target'} +} + +\def\tikz@lib@graph@unknown@edge@option#1{% + \def\tikz@temp{/tikz/graphs/@edges styling/.append=} + \expandafter\expandafter\expandafter\pgfkeys% + \expandafter\expandafter\expandafter{\expandafter\tikz@temp\expandafter{\expandafter,\pgfkeyscurrentname={#1}}} } \def\tikz@lib@graph@graph@done\pgf@stop@eodashes{% + % Get local depth and width outside + \xdef\tikz@lib@graph@chain@depth{\pgfkeysvalueof{/tikz/graphs/placement/local depth}} + \xdef\tikz@lib@graph@chain@width{\pgfkeysvalueof{/tikz/graphs/placement/local width}} % Get node list outside... \expandafter% \endgroup% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\tikz@lib@graph@node@list% \expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list}% + % Compute new local depth and width of group... + \tikz@lib@graph@placement@after@chain@update + % \pgfutil@ifnextchar\pgf@stop@eogroup% \tikz@lib@graph@graph@group@done% \tikz@lib@graph@main@parser% } \def\tikz@lib@graph@graph@group@done\pgf@stop@eogroup{% - \pgfkeysgetvalue{/tikz/graphs/connect as}\tikz@lib@graph@group@connector - \expandafter\tikz@lg@do@connector\expandafter{\tikz@lib@graph@group@connector} -} - -\def\tikz@lg@do@connector#1{% - \tikzset{/tikz/connectors/.cd,#1} + \pgfkeysvalueof{/tikz/graphs/@operators}% } @@ -289,18 +785,42 @@ % Handle node % \def\tikz@lib@graph@grab@name{% - \pgfutil@ifnextchar\foreach\tikz@lib@graph@do@foreach\tikz@lib@graph@grab@name@@% + \pgfutil@ifnextchar\foreach\tikz@lib@graph@do@foreach\tikz@lib@graph@parse@node@text% +} + +\def\tikz@lib@graph@do@foreach\foreach#1in{% + \pgfutil@ifnextchar\bgroup{\tikz@lib@graph@do@foreach@normal{#1}}{\def\tikz@temp{#1}\tikz@lib@graph@do@foreach@macro}% +} +\def\tikz@lib@graph@do@foreach@macro#1{% + \expandafter\expandafter\expandafter\tikz@lib@graph@do@foreach@normal\expandafter\tikz@temp\expandafter{#1}% } -\def\tikz@lib@graph@do@foreach\foreach#1in#2#3[\pgf@stop{% +\def\tikz@lib@graph@do@foreach@normal#1#2#3\pgf@stop{% % Ok, we do a parse on a foreach loop. - % We have to make sure that we \begingroup \let\tikz@lib@graph@node@list@saved\pgfutil@empty% + \xdef\tikz@lib@graph@saved@placement{% + {\pgfkeysvalueof{/tikz/graphs/placement/local depth}}% + {\pgfkeysvalueof{/tikz/graphs/placement/local width}}% + {\pgfkeysvalueof{/tikz/graphs/placement/chain count}}% + {\pgfkeysvalueof{/tikz/graphs/placement/element count}}% + {\pgfkeysvalueof{/tikz/graphs/placement/width}}% + {\pgfkeysvalueof{/tikz/graphs/placement/depth}}% + }% \foreach #1 in {#2}% {% \let\tikz@lib@graph@node@list\tikz@lib@graph@node@list@saved% + \expandafter\tikz@lib@graph@setup@placement\tikz@lib@graph@saved@placement% \tikz@lib@graph@parse@group{#3}% + \xdef\tikz@lib@graph@saved@placement{% + {\pgfkeysvalueof{/tikz/graphs/placement/local depth}}% + {\pgfkeysvalueof{/tikz/graphs/placement/local width}}% + {\pgfkeysvalueof{/tikz/graphs/placement/chain count}}% + {\pgfkeysvalueof{/tikz/graphs/placement/element count}}% + {\pgfkeysvalueof{/tikz/graphs/placement/width}}% + {\pgfkeysvalueof{/tikz/graphs/placement/depth}}% + }% + % TODO: Need to also save hints! \global\let\tikz@lib@graph@node@list@saved\tikz@lib@graph@node@list% }% \expandafter% @@ -308,37 +828,179 @@ \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\tikz@lib@graph@node@list% \expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list@saved}% + \expandafter\tikz@lib@graph@setup@placement\tikz@lib@graph@saved@placement% +} + +\def\tikz@lib@graph@setup@placement#1#2#3#4#5#6{% + \pgfkeyssetvalue{/tikz/graphs/placement/local depth}{#1}% + \pgfkeyssetvalue{/tikz/graphs/placement/local width}{#2}% + \pgfkeyssetvalue{/tikz/graphs/placement/chain count}{#3}% + \pgfkeyssetvalue{/tikz/graphs/placement/element count}{#4}% + \pgfkeyssetvalue{/tikz/graphs/placement/width}{#5}% + \pgfkeyssetvalue{/tikz/graphs/placement/depth}{#6}% +} + +\def\tikz@lib@graph@parse@node@text#1\pgf@stop{% + % + % Ok, first test whether #1 contains "//" + % + \pgfutil@in@{//}{#1 } + \ifpgfutil@in@% + % Ok, a layout node: + \tikz@lib@parse@layout@node#1\pgf@stop% + \else% + \tikz@lib@graph@fake@nodefalse + \let\tikz@lib@graph@node@parsed\tikz@lib@graph@node@opt@normal% + \def\tikz@lib@graph@empty@node@parsed{\tikzgdeventcallback{node}{}}% + \tikz@lib@parse@normal@node#1[\pgf@stop% + \fi% +} + + +% +% Parse the normal part of a node (name and, possibly, text after slash) +% + +\def\tikz@lib@parse@normal@node#1[{ + % + % Test whether #1 contains "/" or "__" + % + \pgfutil@in@{/}{#1}% + \ifpgfutil@in@% + \tikz@lib@parse@node@with@slash#1\pgf@stop% + \else + \pgfutil@in@{__}{#1}% + \ifpgfutil@in@% + \tikz@lib@parse@node@with@doubleunder#1\pgf@stop% + \else + \pgfkeys@spdef\tikz@lib@graph@name@only{#1}% + \let\tikz@lib@graph@node@text\tikz@lib@graph@name@only% + \edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}% + \fi% + \fi% + \tikz@lib@graph@handle@node@cont% +} + +\def\tikz@lib@parse@node@with@slash#1/{ + \pgfkeys@spdef\tikz@lib@graph@name@only{#1}% + \ifx\tikz@lib@graph@name@only\pgfutil@empty% + \global\advance\tikz@fig@count by1\relax + \edef\tikz@lib@graph@name@only{tikz@f@\the\tikz@fig@count}% + \fi% + \edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}% + \pgfutil@ifnextchar"\tikz@lg@slash@quote{\pgfutil@ifnextchar\tikz@active@quotes@token\tikz@lg@slash@quote@active\tikz@lg@slash@cont} +} +\def\tikz@lg@slash@quote"#1"#2\pgf@stop{% + \iftikz@handle@active@nodes% + \def\tikz@lib@graph@node@text{\scantokens{#1}}% + \else + \def\tikz@lib@graph@node@text{#1}% + \fi% +} +{\catcode`\"=13\relax + \gdef\tikz@lg@slash@quote@active"#1"#2\pgf@stop{% + \iftikz@handle@active@nodes% + \def\tikz@lib@graph@node@text{\scantokens{#1}}% + \else + \def\tikz@lib@graph@node@text{#1}% + \fi% + } +} +\def\tikz@lg@slash@cont#1\pgf@stop{% + \iftikz@handle@active@nodes% + \def\tikz@lib@graph@node@text{\scantokens{#1}}% + \else + \def\tikz@lib@graph@node@text{#1}% + \fi% } +\def\tikz@lib@parse@node@with@doubleunder#1__{\tikz@lib@parse@node@with@slash{#1}/} -\def\tikz@lib@graph@grab@name@@#1[{% - \tikz@lib@graph@read#1\pgf@stop% - \let\tikz@lib@graph@as\tikz@lib@graph@as@default% +\def\tikz@lg@find@fresh@name{% + \edef\tikz@lib@graph@name@only{\tikz@lib@graph@name@only'}% + \edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}% + \tikz@lg@if@local@node{\tikz@lib@graph@name}{\tikz@lg@find@fresh@name}{}% +} + + +% +% We have now parsed everything up to the opening "[". We continue +% + +\def\tikz@lib@graph@handle@node@cont{% + \iftikz@lib@graph@fresh@node% + \tikz@lg@if@local@node{\tikz@lib@graph@name}{\tikz@lg@find@fresh@name}{}% + \fi% + \let\tikzgraphnodeas\tikzgraphnodeas@default% \pgfutil@ifnextchar\pgf@stop{% - \ifx\tikz@lib@graph@name\pgfutil@empty% + \ifx\tikz@lib@graph@name@only\pgfutil@empty% + \expandafter\tikz@lib@graph@node@empty@done% \else - \expandafter\tikz@lib@graph@noskip% + \expandafter\tikz@lib@graph@node@opt\expandafter[\expandafter]\expandafter[% \fi% }{\tikz@lib@graph@node@opt[}% } -\def\tikz@lib@graph@noskip{\tikz@lib@graph@node@opt[][}%] -\def\tikz@lib@graph@as@default{% - \let\tikzgraphnodename\tikz@lib@graph@name% +\def\tikzgraphnodeas@default{% \tikz@lib@graph@typesetter% } -\def\tikz@lib@graph@read#1\pgf@stop{% - \pgfkeys@spdef\tikz@lib@graph@name{#1}% - \edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name}% +\let\tikz@lib@graph@empty@node@parsed\relax% + +\def\tikz@lib@graph@node@opt[#1]#2[\pgf@stop{% + \tikz@lib@graph@node@parsed{#1}% } +\def\tikz@lib@graph@node@empty@done\pgf@stop{\tikz@lib@graph@empty@node@parsed} -\def\tikz@lib@graph@node@opt[#1]#2[\pgf@stop{% - \ifx\tikz@lib@graph@name\tikz@lib@graph@usetext +% +% Parse a layout node +% + +\def\tikz@lib@parse@layout@node#1//{% + \pgf@lib@graph@empty@layout@nodefalse% + \let\tikz@lib@graph@node@parsed\tikz@lib@layout@node@parsed% + \let\tikz@lib@graph@empty@node@parsed\tikz@lib@graph@empty@layout@node@parsed + \tikz@lib@parse@normal@node#1[\pgf@stop% +} + +\newif\ifpgf@lib@graph@empty@layout@node + +\def\tikz@lib@layout@node@parsed{% + \tikz@lib@layout@parse@rest% +} + +\def\tikz@lib@graph@empty@layout@node@parsed{% + \pgf@lib@graph@empty@layout@nodetrue + \tikz@lib@layout@parse@rest{}% +} + +\def\tikz@lib@layout@parse@rest#1{% + \def\tikz@lib@layout@node@options{#1}% + \pgfutil@ifnextchar[{\tikz@lib@layout@node@opt}{\tikz@lib@layout@node@opt[]}%} +} + +\def\tikz@lib@layout@node@parsed#1{% + \def\tikz@lib@layout@node@options{#1}% + \pgfutil@ifnextchar[{\tikz@lib@layout@node@opt}{\tikz@lib@layout@node@opt[]}%} +} + +\def\tikz@lib@layout@node@opt[#1]{% + \def\tikz@lib@layout@options{#1}% + \pgfutil@ifnextchar\bgroup{\tikz@lib@layout@start}{\tikzerror{Opening brace at beginning of sublayout expected}}% +} + + +% +% Typeset a normal node +% + +\def\tikz@lib@graph@node@opt@normal#1{% + \expandafter\tikz@lib@graph@test@use@list\tikz@lib@graph@name@only\pgf@stop + \iftikz@lib@graph@use@list% % Ok, make a list of the nodes stored in #1: \let\tikz@lg@temp\pgfutil@empty% - \foreach \tikz@lg@node@name in {#1} {\expandafter\tikz@lib@graph@handle@use\expandafter{\tikz@lg@node@name}} + \foreach \tikz@lg@node@name in \tikz@lib@graph@use@list {\expandafter\tikz@lib@graph@handle@use\expandafter{\tikz@lg@node@name}} % Ok, now add the nodes to the node list \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\tikz@lib@graph@node@list% @@ -348,26 +1010,70 @@ \let\tikz@lg@do\tikz@lib@graph@do@use% \tikz@lg@temp% \else% - \expandafter\ifx\csname tikz@lib@graph@def@\tikz@lib@graph@name\endcsname\relax% + \edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}% + \expandafter\ifx\csname tikz@lib@graph@def@\tikz@lib@graph@name@only\endcsname\relax% + \pgfkeysgetvalue{/tikz/graphs/placement/level}\tikz@temp% + \c@pgf@counta=\tikz@temp\relax% + \advance\c@pgf@counta by1\relax% + \edef\tikz@temp{\the\c@pgf@counta}% + \pgfkeyslet{/tikz/graphs/placement/level}\tikz@temp% + \tikzgraphsset{ + level/.try=\pgfkeysvalueof{/tikz/graphs/placement/level}, + level \pgfkeysvalueof{/tikz/graphs/placement/level}/.try + } {% \edef\tikz@lib@graph@node@list{\noexpand\tikz@lg@do{\tikz@lib@graph@name}}% + \global\tikz@lib@graph@node@createdfalse% + \pgfkeyslet{/tikz/graphs/@operators}\pgfutil@empty% + \tikz@lib@activate@source@target@edge@syntax% \tikz@lg@if@local@node{\tikz@lib@graph@name}% - {\tikzset{/tikz/graph node/.cd,in,out,#1}}% + {\tikz@lg@local@node@handle{#1}}% {% - \tikz@lg@init@color{\tikz@lib@graph@name}{\tikz@lgc@all@true\tikz@lgc@in@true\tikz@lgc@out@true}% + \tikz@lg@init@color{\tikz@lib@graph@name}{\tikz@lgc@all@true\tikz@lgc@source@true\tikz@lgc@target@true}% \iftikz@lib@graph@all% - \tikzset{/tikz/graph node/.cd,#1}% + \tikzgraphsset{#1}\pgfkeysvalueof{/tikz/graphs/@operators}% \else% - \node [name=\tikz@lib@graph@name,/tikz/graph - node/.cd,/tikz/graphs/@nodes styling,#1] - {\tikz@lib@graph@as};% + \pgfkeys{/tikz/graphs/placement/place}% + \let\tikzgraphnodetext\tikz@lib@graph@node@text% + \let\tikzgraphnodename\tikz@lib@graph@name@only% + \let\tikzgraphnodepath\tikz@lib@graph@path% + \let\tikzgraphnodefullname\tikz@lib@graph@name% + \iftikz@lib@graph@fake@node% + {% run options in protected mode... + \pgfkeys{ + /tikz/graphs/.cd,% + .unknown/.code=, + /tikz/graphs/@nodes styling,% + #1}% + \pgfkeysgetvalue{/tikz/graphs/@operators}\tikz@lib@graph@op@save% + \global\let\tikz@lib@graph@op@save\tikz@lib@graph@op@save% + }% + \else% + \node [% + name=\tikz@lib@graph@name,% + execute at end node={% + \pgfkeysgetvalue{/tikz/graphs/@operators}\tikz@lib@graph@op@save% + \global\let\tikz@lib@graph@op@save\tikz@lib@graph@op@save% + },% + graphs/redirect unknown to tikz, + /tikz/graphs/.cd,% + /tikz/graphs/@nodes styling,% + #1]% + {% + \tikzgraphnodeas% + };% + \fi% + \tikz@lib@graph@op@save\global\let\tikz@lib@graph@op@save\relax%% + \global\tikz@lib@graph@node@createdtrue% \fi }% }% + \iftikz@lib@graph@node@created\tikz@lib@graph@placement@update\fi% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\tikz@lib@graph@node@list% \expandafter\expandafter\expandafter{% \expandafter\tikz@lib@graph@node@list\expandafter\tikz@lg@do\expandafter{\tikz@lib@graph@name}}% + \iftikz@lib@graph@trie\tikzgraphsset{name=\tikz@lib@graph@name@only}\fi% \else % The name of the node is a graph name \tikz@lib@graph@handle@graph{#1}% @@ -375,51 +1081,227 @@ \fi% } -\def\tikz@lib@graph@handle@use#1{% - % Is #1 the name of a node set? - \expandafter\let\expandafter\pgf@temp\csname tikz@lg@node@set #1\endcsname - \ifx\pgf@temp\relax - \pgfutil@g@addto@macro\tikz@lg@temp{\tikz@lg@do{#1}} - \else% - \expandafter\pgfutil@g@addto@macro\expandafter\tikz@lg@temp\expandafter{\pgf@temp} - \fi -} - -\def\tikz@lib@graph@do@use#1{% - \tikz@lg@init@color{#1}{\tikz@lgc@all@true\tikz@lgc@in@true\tikz@lgc@out@true}% -} - -\def\tikz@lib@graph@usetext{use} +\newif\iftikz@lib@graph@fake@node -\def\tikz@lib@graph@typeset@def#1 as #2\pgf@stop{ - \def\tikz@lib@graph@typesetter#1\pgf@stop{#2} +\newif\iftikz@lib@graph@use@list +\def\tikz@lib@graph@test@use@list{% + \pgfutil@ifnextchar({\tikz@lib@graph@use@list@grap}{\tikz@lib@graph@test@use@list@done}%) } -\tikzset{ - graphs/typeset/.store in=\tikz@lib@graph@typesetter, - graphs/math nodes/.style={/tikz/graphs/typeset=$\tikzgraphnodename$}, - graphs/empty nodes/.style={/tikz/graphs/typeset=}, - graphs/typeset=\tikzgraphnodename -} +\def\tikz@lib@graph@test@use@list@done#1\pgf@stop{\tikz@lib@graph@use@listfalse} +\def\tikz@lib@graph@use@list@grap(#1)\pgf@stop{\def\tikz@lib@graph@use@list{#1}\tikz@lib@graph@use@listtrue} % -% Handle scope +% Typeset a layout node % -\def\tikz@lib@graph@scope#1{ + +\def\tikz@lib@layout@start#1#2\pgf@stop{% + \tikz@lib@ensure@gd@loaded% + % Parameters are: + % + % Node name is \tikz@lib@graph@name@only + % Node text is \tikz@lib@graph@node@text + % Node options are \tikz@lib@layout@node@options + % Layout options are \tikz@lib@layout@options + % Layout is #1 + % Rest is #2 (should be empty or just whitespace) + \tikz@lib@graph@fake@nodefalse% + \ifpgf@lib@graph@empty@layout@node% + \else% + \ifx\tikz@lib@graph@name\pgfutil@empty% + \tikzerror{Internal error: Node has no name, but it should!}% + \else + \tikz@lib@graph@fake@nodetrue% + \expandafter\tikz@lib@graph@node@opt@normal\expandafter{\tikz@lib@layout@node@options}% + \fi% + \fi% + \edef\tikz@lib@graph@name{\tikz@lib@graph@path\tikz@lib@graph@name@only}% + % + % Prepare tikz node options + % + \expandafter\expandafter\expandafter\def% + \expandafter\expandafter\expandafter\tikz@lib@layout@node@options\expandafter\expandafter\expandafter{\expandafter\tikz@lib@layout@startup@node@options\tikz@lib@layout@node@options,}% \begingroup + % Create a subgraph node, if name is given. + \iftikz@lib@graph@fake@node% + \expandafter\expandafter\expandafter% + \expandafter\expandafter\expandafter\expandafter\tikz@lib@make@subgraph@node% + \expandafter\expandafter\expandafter% + \expandafter\expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter\tikz@lib@graph@name% + \expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter{% + \expandafter\tikz@lib@graph@node@text\expandafter}\expandafter{\tikz@lib@layout@node@options} + \fi% + % + % Here comes the scope: + % + \expandafter\expandafter\expandafter\scope\expandafter\expandafter\expandafter[\expandafter\tikz@lib@layout@node@options@prefix\tikz@lib@layout@options] + \tikzgdeventgroupcallback{array}% \let\tikz@lib@graph@node@list\pgfutil@empty% - \tikz@lib@graph@parse@group{#1}% + \tikz@lib@graph@start@hint@group% + \tikz@lib@graph@parse@group{#1}% + \tikz@lib@graph@end@hint@group% + \def\tikz@lg@old@col{\tikz@lgc@source@true}% + \let\tikz@lg@new@col\pgfutil@empty% + \let\tikz@lg@do\tikz@lg@change@color% + \tikz@lib@graph@node@list% + \def\tikz@lg@old@col{\tikz@lgc@target@true}% + \tikz@lib@graph@node@list% \expandafter% + \endscope\expandafter% \endgroup% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\tikz@lib@graph@node@list% \expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list}% - \tikz@lib@graph@stored@actions% - \pgfutil@ifnextchar-{\tikz@lib@graph@scope@minus}{% + \tikz@lib@graph@hint@aftergroup% +} +\def\tikz@lib@make@subgraph@node#1#2#3{% + \pgfgdsubgraphnode{#1}{#3}{\pgfgdsubgraphnodecontents{#2}}% +} +\def\tikz@lib@layout@startup@node@options{% + /utils/exec=\tikzlibignorecomparisonsINTERNAL, + /tikz/graphs/.cd,% + redirect unknown to tikz,% + anchor=base,% + /tikz/every subgraph node/.try,% +} +\def\tikzlibignorecomparisonsINTERNAL{% + \pgfkeys{/handlers/first char syntax=true} + \pgfkeyssetvalue{/handlers/first char syntax/the character >}{\pgfutil@gobble}% + \pgfkeyssetvalue{/handlers/first char syntax/the character <}{\pgfutil@gobble}% +} +\def\tikz@lib@layout@node@options@prefix{graphs/.cd,} + +\ifx\tikz@lib@ensure@gd@loaded\pgfutil@undefined% +\def\tikz@lib@ensure@gd@loaded{\tikzerror{You must say \string\usetikzlibrary{graphdrawing} to use the (sub)layout syntax}} +\fi + +\def\tikz@lg@local@node@handle#1{% + % + % Handle late options and operators + \tikzgraphsset{source,target,.unknown/.code=,#1}% + \tikzgdlatenodeoptionacallback{\tikz@lib@graph@name}% + \node also[graphs/redirect unknown to tikz,/tikz/graphs/.cd,#1](\tikz@lib@graph@name);% + \pgfkeysvalueof{/tikz/graphs/@operators}% +} + +\tikzgraphsset{redirect unknown to tikz/.style={ + /tikz/graphs/.unknown/.code={% + \let\tikz@key\pgfkeyscurrentname% + \pgfkeys{tikz/.cd,\tikz@key={##1},/tikz/graphs/.cd}% + }} +} + +\def\tikz@lib@activate@source@target@edge@syntax{% + \pgfkeys{/handlers/first char syntax=true} + \pgfkeyssetvalue{/handlers/first char syntax/the character >}{\tikz@lg@parse@more}% + \pgfkeyssetvalue{/handlers/first char syntax/the character <}{\tikz@lg@parse@less}% +} + +\def\tikz@lg@parse@less#1{\tikz@lg@parse@less@#1\pgf@stop} +\def\tikz@lg@parse@less@<{\pgfutil@ifnextchar"{\tikz@lg@parse@quote{source}}{\tikz@lg@parse@noquote{source}}} +\def\tikz@lg@parse@more#1{\tikz@lg@parse@more@#1\pgf@stop} +\def\tikz@lg@parse@more@>{\pgfutil@ifnextchar"{\tikz@lg@parse@quote{target}}{\tikz@lg@parse@noquote{target}}} + +\def\tikz@lg@parse@noquote#1#2\pgf@stop{{\tikzgraphsset{#1 edge style={#2}}}} +\def\tikz@lg@parse@quote#1#2\pgf@stop{% + {\tikzgraphsset{/tikz/node quotes mean={#1 edge node={node [every edge quotes,##2]{##1}}},/utils/exec=\tikz@enable@node@quotes,#2}}% +} + +\tikzgraphsset{ + clear >/.style=target edge clear, + clear , - or <-> expected}{}% + \tikzerror{One of the arrow types <-, --, ->, -!-, or <-> expected}% }% }% } @@ -427,9 +1309,11 @@ \def\tikz@lib@graph@scope@minus-{ \pgfutil@ifnextchar>\tikz@lib@graph@forward@arrow{% \pgfutil@ifnextchar-\tikz@lib@graph@undirected@arrow{% - \pgfutil@ifnextchar\pgf@stop@eodashes\tikz@lib@graph@graph@done{% - \PackageError{graphs library}{One of the arrow types <-, --, ->, or <-> expected}{}% - \tikz@lib@graph@undirected@arrow% + \pgfutil@ifnextchar!\tikz@lib@graph@no@arrow{% + \pgfutil@ifnextchar\pgf@stop@eodashes\tikz@lib@graph@graph@done{% + \tikzerror{One of the arrow types <-, --, ->, -!-, or <-> expected}% + \tikz@lib@graph@undirected@arrow% + }% }% }% }% @@ -444,31 +1328,36 @@ % Predefining graphs % -\def\tikzdefgraph#1#2#3{% - \expandafter\def\csname tikz@lib@graph@def@#1\endcsname{\tikz@lib@graph@do@graph{#2}{#3}}% +\tikzgraphsset{ + declare/.code 2 args={\expandafter\def\csname tikz@lib@graph@def@#1\endcsname{\tikz@lib@graph@do@graph{#2}}}% } \def\tikz@lib@graph@handle@graph#1{% \begingroup% \let\tikz@lib@graph@node@list\pgfutil@empty% - \tikzset{graphs/.cd,#1}% - \csname tikz@lib@graph@def@\tikz@lib@graph@name\endcsname% + \tikzgraphsset{@extra group options/.style={#1}}% + \tikz@lib@graph@start@hint@group% + \csname tikz@lib@graph@def@\tikz@lib@graph@name@only\endcsname% + \tikz@lib@graph@end@hint@group% \expandafter% \endgroup% \expandafter\expandafter\expandafter\def% \expandafter\expandafter\expandafter\tikz@lib@graph@node@list% \expandafter\expandafter\expandafter{\expandafter\tikz@lib@graph@node@list\tikz@lib@graph@node@list}% + \tikz@lib@graph@hint@aftergroup% } -\def\tikz@lib@graph@do@graph#1#2{% - #1% - \tikz@lib@graph@parse@group{#2}% +\def\tikz@lib@graph@do@graph#1{% + \tikz@lib@graph@parse@group{#1}% } \let\tikz@lib@graph@path\pgfutil@empty -\tikzset{graphs/name/.code={% - \edef\tikz@lib@graph@path{#1\space\tikz@lib@graph@path}% +\tikzgraphsset{ + name separator/.store in=\tikz@lib@graph@name@separator, + name separator=\space, + name/.code={% + \edef\tikz@lib@graph@path{\tikz@lib@graph@path#1\tikz@lib@graph@name@separator}% }% } @@ -476,44 +1365,36 @@ % % Colors % - -\tikzset{ - graph node/.unknown/.code={% - \let\tikz@key\pgfkeyscurrentname% - \pgfkeys{/tikz/\tikz@key={#1}}% - }, - graph node/as/.code=\def\tikz@lib@graph@as{#1}% -} - - -\tikzset{% - new graph color/.style={% - /utils/exec=\expandafter\newif\csname iftikz@lgc@#1@\endcsname, - graph node/#1/.code={% +\def\tikz@lg@newif{\csname newif\endcsname} +\tikzgraphsset{ + as/.code=\def\tikzgraphnodeas{#1},% + color class/.style={% + /utils/exec=\expandafter\tikz@lg@newif\csname iftikz@lgc@#1@\endcsname, + #1/.style={operator={% \edef\tikz@lg@col{\expandafter\noexpand\csname tikz@lgc@#1@true\endcsname}% \let\tikz@lg@do\tikz@lg@colorize% \tikz@lib@graph@node@list% - }, - graph node/!#1/.code={% + }}, + not #1/.style={operator={% \edef\tikz@lg@old@col{\expandafter\noexpand\csname tikz@lgc@#1@true\endcsname}% - \def\tikz@lg@new@col{}% + \let\tikz@lg@new@col\pgfutil@empty% \let\tikz@lg@do\tikz@lg@change@color% \tikz@lib@graph@node@list% - }, - graph node/recolor #1 by/.code={% + }}, + recolor #1 by/.style={operator={% \edef\tikz@lg@old@col{\expandafter\noexpand\csname tikz@lgc@#1@true\endcsname}% \edef\tikz@lg@new@col{\expandafter\noexpand\csname tikz@lgc@##1@true\endcsname}% \let\tikz@lg@do\tikz@lg@change@color% \tikz@lib@graph@node@list% - }, - graph node/not #1/.style=!#1, + }}, + !#1/.style=not #1, }, - new graph color=in, - new graph color=in', - new graph color=in'', - new graph color=out, - new graph color=out', - new graph color=all + color class=source, + color class=source', + color class=source'', + color class=target, + color class=target', + color class=all } \def\tikz@lg@init@color#1#2{% @@ -522,6 +1403,8 @@ \def\tikz@lib@graph@cleanup#1{% \expandafter\global\expandafter\let\csname tikz@lgc@#1\endcsname\relax% + \ifcsname tikz@lgca@@#1\endcsname\expandafter\global\expandafter\let\csname tikz@lgca@@#1\endcsname\relax\fi% + \ifcsname tikz@lgcb@@#1\endcsname\expandafter\global\expandafter\let\csname tikz@lgcb@@#1\endcsname\relax\fi% } \def\tikz@lg@colorize#1{% @@ -583,7 +1466,54 @@ \def\tikz@lib@reset@temp{\let\pgf@temp\iffalse} +% +% Handle connection annotations +% +\def\tikz@lib@annotate@#1#2#3#4{% + \expandafter\ifx\csname tikz@lgc#1@@#2\endcsname\relax% + \expandafter\gdef\csname tikz@lgc#1@@#2\endcsname{{#3}{#4}}% + \else% + \expandafter\expandafter\expandafter\tikz@lib@annotate@read\csname tikz@lgc#1@@#2\endcsname{#3}{#4}% + \expandafter\global\expandafter\let\csname tikz@lgc#1@@#2\endcsname\pgf@temp% + \fi% +} +\def\tikz@lib@annotate@read#1#2#3#4{\def\pgf@temp{{#1,#3}{#2#4}}} +\tikzgraphsset{ + source edge style/.code=\tikz@lib@annotate@{a}{\tikz@lib@graph@name}{#1}{}, + source edge node/.code=\tikz@lib@annotate@{a}{\tikz@lib@graph@name}{}{#1}, + source edge clear/.code={ + \expandafter\global\expandafter\let\csname tikz@lgca@@\tikz@lib@graph@name\endcsname\relax% + }, + target edge style/.code=\tikz@lib@annotate@{b}{\tikz@lib@graph@name}{#1}{}, + target edge node/.code=\tikz@lib@annotate@{b}{\tikz@lib@graph@name}{}{#1}, + target edge clear/.code={% + \expandafter\global\expandafter\let\csname tikz@lgcb@@\tikz@lib@graph@name\endcsname\relax% + } +}% + + + +% Packing a node list: Replace the node list by a new node list where +% each node is mentioned at most once. + +\def\tikz@lib@graph@pack@node@list{% + {% + \let\tikz@lg@packed\pgfutil@empty% + \let\tikz@lg@do\tikz@lg@packer% + \tikz@lib@graph@node@list% + \expandafter + }\expandafter% + \def\expandafter\tikz@lib@graph@node@list\expandafter{\tikz@lg@packed}% +} + +\def\tikz@lg@packer#1{% + \expandafter\ifx\csname tikz@lg@p@#1\endcsname\pgf@stop% + \else% + \expandafter\let\csname tikz@lg@p@#1\endcsname\pgf@stop% + \expandafter\def\expandafter\tikz@lg@packed\expandafter{\tikz@lg@packed\tikz@lg@do{#1}} + \fi +} % % Color functions @@ -600,7 +1530,8 @@ % macro should take a single parameter, which will be set % to the node's name. -\def\tikzlibgraphforeachcolorednode#1#2{% +\def\tikzgraphforeachcolorednode#1#2{% + \tikz@lib@graph@pack@node@list% \expandafter\def\expandafter\iftikz@lib@graph@color@picker\expandafter{\csname iftikz@lgc@#1@\endcsname}% \let\tikz@lib@graph@action#2% \let\tikz@lg@do\tikz@lg@pick% @@ -619,6 +1550,7 @@ } + % Prepare a color % % #1 is the color name @@ -639,18 +1571,19 @@ % The bottom line of all this is that after a preparation you can % easily iterate over nodes having a certain color. If you wish to % iterate over a single color, it will be quicker and easier to call -% \tikzlibgraphforeachcolorednode, but if you need to iterate over two +% \tikzgraphforeachcolorednode, but if you need to iterate over two % colors simultaneously, it will be better to first prepare the color. -\def\tikzlibgraphpreparecolor#1#2#3{% +\def\tikzgraphpreparecolor#1#2#3{% \let\tikz@lib@graph@count#2% + \tikz@lib@graph@count0\relax \def\tikz@lib@graph@prefix{#3}% - \tikzlibgraphforeachcolorednode{#1}\tikz@lib@graph@prepare% + \tikzgraphforeachcolorednode{#1}\tikz@lib@graph@prepare% } \def\tikz@lib@graph@prepare#1{% \advance\tikz@lib@graph@count by1\relax% - \expandafter\def\csname \tikz@lib@graph@prefix\the\tikz@lib@graph@count\endcsname{#1}% + \expandafter\def\csname\tikz@lib@graph@prefix\the\tikz@lib@graph@count\endcsname{#1}% } @@ -660,18 +1593,24 @@ % The bipartite connector % -\tikzset{ - connectors/bipartite/.code 2 args={ +\tikzgraphsset{ + complete bipartite/.style 2 args={operator={ \def\tikz@lg@shoreb{#2}% - \tikzlibgraphforeachcolorednode{#1}\tikz@lib@graph@bipartite@outer + \tikzgraphforeachcolorednode{#1}\tikz@lib@graph@bipartite@outer + }}, + complete bipartite/.default={target'}{source'}, + induced complete bipartite/.style 2 args={ + induced independent set={#1}, + induced independent set={#2}, + complete bipartite={#1}{#2} }, - connectors/bipartite/.default={out'}{in'} + induced complete bipartite/.default={target'}{source'}, } \def\tikz@lib@graph@bipartite@outer#1{% \def\tikz@lib@graph@from{#1}% {% - \tikzlibgraphforeachcolorednode{\tikz@lg@shoreb}\tikz@lib@graph@bipartite@inner% + \tikzgraphforeachcolorednode{\tikz@lg@shoreb}\tikz@lib@graph@bipartite@inner% }% } @@ -682,25 +1621,51 @@ \fi% } -\def\tikz@lib@graph@default@new@edge{% +\def\tikz@lib@graph@default@new@edge#1#2{% \pgfkeysgetvalue{/tikz/graphs/@edges styling}\pgf@temp - \expandafter\tikz@lib@graph@default@new@edge@\expandafter{\pgf@temp}% + \pgfkeysgetvalue{/tikz/graphs/@edges node}\pgf@temp@b + \let\tikz@lib@add@temp\pgfutil@empty% + \tikz@lib@graph@add@edge@annotations{a}{#1} + \tikz@lib@graph@add@edge@annotations{b}{#2} + \expandafter\expandafter\expandafter\def% + \expandafter\expandafter\expandafter\pgf@temp% + \expandafter\expandafter\expandafter{\expandafter\pgf@temp\tikz@lib@add@temp}% + \expandafter\expandafter\expandafter\tikz@lib@graph@default@new@edge@% + \expandafter\expandafter\expandafter{\expandafter\pgf@temp\expandafter}\expandafter{\pgf@temp@b}{#1}{#2}% +} +\def\tikz@lib@graph@default@new@edge@#1#2#3#4{% + \iftikz@lib@graph@simple% + \edef\tikz@temp{{\pgfkeysvalueof{/tikz/graphs/default edge kind}}{#3}{#4}} + \expandafter\tikz@lib@graph@set@simple@edge\tikz@temp{#1}{#2}% + \else% + \pgfkeys{/tikz/graphs/.cd,new \pgfkeysvalueof{/tikz/graphs/default edge kind}={#3}{#4}{#1}{#2}}% + \fi% } -\def\tikz@lib@graph@default@new@edge@#1#2#3{% - \pgfkeys{/tikz/graphs/.cd,new edge \pgfkeysvalueof{/tikz/graphs/default edge kind}={#2}{#3}{#1}}% +\def\tikz@lib@graph@add@edge@annotations#1#2{% + \ifcsname tikz@lgc#1@@#2\endcsname% + \expandafter\let\expandafter\tikz@lg@temp@\csname tikz@lgc#1@@#2\endcsname% + \ifx\tikz@lg@temp@\relax\else + \expandafter\tikz@lib@graph@add@edge@annotations@\tikz@lg@temp@% + \let\tikz@lib@add@temp\tikz@lib@final@edge@style + \fi% + \fi% } +\def\tikz@lib@graph@add@edge@annotations@#1#2{ + \expandafter\def\expandafter\pgf@temp\expandafter{\pgf@temp,#1}% + \expandafter\def\expandafter\pgf@temp@b\expandafter{\pgf@temp@b#2}% +} +\def\tikz@lib@final@edge@style{,after source and target edge/.try} - % % The clique connector % -\tikzset{ - connectors/clique/.code={ - \tikzlibgraphpreparecolor{#1}\c@pgf@counta{tikz@lg}% - \tikz@lg@clique@loop% - }, - connectors/clique/.default=all +\tikzgraphsset{ + clique/.style={operator={ + \tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg}% + \tikz@lg@clique@loop% + }}, + clique/.default=all } \def\tikz@lg@clique@loop{% @@ -716,22 +1681,58 @@ \def\tikz@lg@clique@loop@inner{% \advance\c@pgf@countb by-1\relax% \ifnum\c@pgf@countb>0\relax% - \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@counta\endcsname}{\csname tikz@lg\the\c@pgf@countb\endcsname}% + \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{\csname tikz@lg\the\c@pgf@counta\endcsname}% \expandafter\tikz@lg@clique@loop@inner% \fi% } +% +% The independent set connector +% + +\tikzgraphsset{ + induced independent set/.style={operator={ + \pgfkeysgetvalue{/tikz/graphs/default edge kind}\tikz@lg@default% + \pgfkeyssetvalue{/tikz/graphs/default edge kind}{-!-}% + \tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg}% + \tikz@lg@indep@loop% + \pgfkeyslet{/tikz/graphs/default edge kind}\tikz@lg@default% + }}, + induced independent set/.default=all +} + +\def\tikz@lg@indep@loop{% + \ifnum\c@pgf@counta=0\relax% + \else + \c@pgf@countb=\c@pgf@counta\relax% + \tikz@lg@indep@loop@inner% + \advance\c@pgf@counta by-1\relax% + \expandafter\tikz@lg@indep@loop% + \fi% +} + +\def\tikz@lg@indep@loop@inner{% + \advance\c@pgf@countb by-1\relax% + \ifnum\c@pgf@countb>0\relax% + \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@counta\endcsname}{\csname tikz@lg\the\c@pgf@countb\endcsname}% + \expandafter\tikz@lg@indep@loop@inner% + \fi% +} + + % % The path connector % -\tikzset{ - connectors/path/.code={% - \let\tikz@lg@prev\relax% - \tikzlibgraphforeachcolorednode{#1}\tikz@lib@graph@path@do% - }, - connectors/path/.default=all +\tikzgraphsset{ + path/.style={operator={% + \let\tikz@lg@prev\relax% + \tikzgraphforeachcolorednode{#1}\tikz@lib@graph@path@do% + }}, + path/.default=all, + induced path/.style={induced independent set={#1},path={#1}}, + induced path/.default=all, } \def\tikz@lib@graph@path@do#1{% @@ -747,17 +1748,19 @@ % The cycle connector % -\tikzset{ - connectors/cycle/.code={% +\tikzgraphsset{ + cycle/.style={operator={% \let\tikz@lg@prev\relax% \let\tikz@lg@first\relax% - \tikzlibgraphforeachcolorednode{#1}\tikz@lib@graph@cycle@do% + \tikzgraphforeachcolorednode{#1}\tikz@lib@graph@cycle@do% \ifx\tikz@lg@first\relax% \else% \tikz@lib@graph@default@new@edge{\tikz@lg@prev}{\tikz@lg@first}% \fi% - }, - connectors/cycle/.default=all + }}, + cycle/.default=all, + induced cycle/.style={induced independent set={#1},cycle={#1}}, + induced cycle/.default=all, } \def\tikz@lib@graph@cycle@do#1{% @@ -774,68 +1777,98 @@ % -% The match connector +% The matching and star connector % -\tikzset{ - connectors/match/.code 2 args={ +\tikzgraphsset{ + matching and star/.style 2 args={operator=% {% - \tikzlibgraphpreparecolor{#1}\c@pgf@counta{tikz@lg} + \tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg} \c@pgf@countb=0\relax% \let\tikz@lg@prev\relax - \tikzlibgraphforeachcolorednode{#2}\tikz@lib@graph@match@do% - \tikz@lib@graph@match@rest% + \tikzgraphforeachcolorednode{#2}\tikz@lib@graph@flow@do% + \tikz@lib@graph@flow@rest% }% }, - connectors/match/.default={out'}{in'} + matching and star/.default={target'}{source'} } -\def\tikz@lib@graph@match@do#1{% +\def\tikz@lib@graph@flow@do#1{% \advance\c@pgf@countb by1\relax% \ifnum\c@pgf@countb>\c@pgf@counta\relax% \c@pgf@countb=\c@pgf@counta\relax% \fi% - \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{#1}% + \ifnum\c@pgf@countb>0\relax% + \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{#1}% + \fi% \def\tikz@lg@prev{#1}% } -\def\tikz@lib@graph@match@rest{% +\def\tikz@lib@graph@flow@rest{% \ifnum\c@pgf@countb<\c@pgf@counta\relax% - \advance\c@pgf@countb by1\relax% - \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{\tikz@lg@prev}% - \expandafter\tikz@lib@graph@match@rest% + \ifnum\c@pgf@countb>0\relax% + \advance\c@pgf@countb by1\relax% + \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{\tikz@lg@prev}% + \expandafter\tikz@lib@graph@flow@rest% + \fi% \fi% } +% +% The matching connector +% + +\tikzgraphsset{ + matching/.style 2 args={operator= + {% + \tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg} + \c@pgf@countb=0\relax% + \tikzgraphforeachcolorednode{#2}\tikz@lib@graph@matching@do% + }% + }, + matching/.default={target'}{source'} +} + +\def\tikz@lib@graph@matching@do#1{% + \advance\c@pgf@countb by1\relax% + \ifnum\c@pgf@countb>\c@pgf@counta\relax% + \else% + \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{#1}% + \fi% +} + + + + + % % The butterfly connector % -\tikzset{ - connectors/butterfly/.code={ +\tikzgraphsset{ + butterfly/.style={operator= {}{% - \pgfkeys{/tikz/connectors/butterfly/.cd,#1}% - \ifnum\pgfkeysvalueof{/tikz/connectors/butterfly/level}=0\relax% - \pgfkeysalso{/tikz/connectors/match={\pgfkeysvalueof{/tikz/connectors/butterfly/from}}{\pgfkeysvalueof{/tikz/connectors/butterfly/to}}}% + \pgfkeys{/tikz/graphs/butterfly/.cd,#1}% + \ifnum\pgfkeysvalueof{/tikz/graphs/butterfly/level}=0\relax% + \tikzgraphinvokeoperator{matching and star={\pgfkeysvalueof{/tikz/graphs/butterfly/from}}{\pgfkeysvalueof{/tikz/graphs/butterfly/to}}}% \else% {% - \tikzlibgraphpreparecolor{\pgfkeysvalueof{/tikz/connectors/butterfly/from}}\c@pgf@counta{tikz@lg} + \tikzgraphpreparecolor{\pgfkeysvalueof{/tikz/graphs/butterfly/from}}\c@pgf@counta{tikz@lg} \c@pgf@countb=0\relax% - \tikzlibgraphforeachcolorednode{\pgfkeysvalueof{/tikz/connectors/butterfly/to}}\tikz@lib@graph@butterfly@do% + \tikzgraphforeachcolorednode{\pgfkeysvalueof{/tikz/graphs/butterfly/to}}\tikz@lib@graph@butterfly@do% }% - \iftikz@butterfly@prime\else\pgfkeysalso{/tikz/connectors/match={\pgfkeysvalueof{/tikz/connectors/butterfly/from}}{\pgfkeysvalueof{/tikz/connectors/butterfly/to}}}\fi% + \iftikz@butterfly@prime\else\tikzgraphinvokeoperator{matching and star={\pgfkeysvalueof{/tikz/graphs/butterfly/from}}{\pgfkeysvalueof{/tikz/graphs/butterfly/to}}}\fi% \fi% }% }, - connectors/butterfly/.default=, - connectors/butterfly/level/.initial=1, - connectors/butterfly/from/.initial=out', - connectors/butterfly/to/.initial=in', - connectors/butterfly'/.code={% - {}{\tikz@butterfly@primetrue\pgfkeysalso{butterfly={#1}}}}, - connectors/butterfly'/.default=, + butterfly/.default=, + butterfly/level/.initial=1, + butterfly/from/.initial=target', + butterfly/to/.initial=source', + butterfly'/.style={operator={}{\tikz@butterfly@primetrue\pgfkeysalso{butterfly={#1}}}}, + butterfly'/.default=, } \newif\iftikz@butterfly@prime @@ -843,7 +1876,7 @@ \def\tikz@lib@graph@butterfly@do#1{% \advance\c@pgf@countb by1\relax% % Compute other side... - \c@pgf@countc=\pgfkeysvalueof{/tikz/connectors/butterfly/level}\relax% + \c@pgf@countc=\pgfkeysvalueof{/tikz/graphs/butterfly/level}\relax% {% % Computer countb mod (2level) \count0=\c@pgf@countc\relax% @@ -875,3 +1908,733 @@ + +% +% The no edges connector +% +\tikzgraphsset{no edges/.style={operator=\relax}} + + + + +% +% The grid connector +% +\tikzgraphsset{ + grid/.style={operator={ + \tikzgraphpreparecolor{#1}\c@pgf@counta{tikz@lg}% + \c@pgf@countb=0\relax% + \tikzgraphpreparewrapafter% + \tikz@lg@grid@loop% + }% + }, + grid/.default=all +} + +\def\tikzgraphpreparewrapafter{% + \pgfkeysgetvalue{/tikz/graphs/wrap after}\tikz@temp% + \ifnum\tikz@temp=0\relax% + \pgfmathparse{sqrt(\tikzgraphVnum)}% + \pgfmathint{\pgfmathresult}% + \edef\tikzgraphwrapafter{\pgfmathresult}% + \else% + \edef\tikzgraphwrapafter{\tikz@temp} + \fi% +} + +\def\tikz@lg@grid@loop{% + \ifnum\c@pgf@counta=0\relax% + \else% + \advance\c@pgf@countb by 1\relax% + \pgfmathmod{\c@pgf@countb-1}{\tikzgraphwrapafter}% + \pgfmathint{\pgfmathresult}% + \ifnum\pgfmathresult>0% + \pgfmathsubtract{\c@pgf@countb}{1}% + \pgfmathint{\pgfmathresult}% + \tikz@lib@graph@default@new@edge{\csname tikz@lg\the\c@pgf@countb\endcsname}{\csname tikz@lg\pgfmathresult\endcsname}% + \fi% + \pgfmathparse{\c@pgf@countb <= \tikzgraphwrapafter}% + \ifnum\pgfmathresult=0% + \pgfmathsubtract{\c@pgf@countb}{\tikzgraphwrapafter}% + \pgfmathint{\pgfmathresult}% + \tikz@lib@graph@default@new@edge{\csname tikz@lg\pgfmathresult\endcsname}{\csname tikz@lg\the\c@pgf@countb\endcsname}% + \fi% + \advance\c@pgf@counta by-1\relax% + \expandafter\tikz@lg@grid@loop% + \fi% +} + + + + +% Positioning +% +% It is not the job of the graph library to compute good positions for +% nodes in a graph. However, some basic support is provided for simple +% cases. +% +% The idea is at follows: Graphs are specified hierarchically. For +% instance, consider the following graph specification: +% +% graph { a, b, c -> d -> {e -> f -> g, h} -> i, j -> k } +% +% Here, we have the *group* {e->f->g,h} inside the larger graph +% specification. Each group consists of sequence of *chains* like +% e->f->g or j->k. +% +% In order to facilitate the automatic positioning of nodes, the graph +% library will provide you with information about the position of +% nodes inside their groups and chains. +% +% As a chain is being parsed, a counter stored in +% /tikz/graphs/placement/element count is available that is advanced for +% each element in the chain. +% +% Additionally, a counter stored in placement/width is +% available. This "logical" width is defined recursively as follows: The +% width of a single node is computed by calling the key +% placement/logical node width, which should return a real or logical +% width of the node passed as a parameter in the macor \pgfmathresult. The +% width of a chain is the sum of the widths of its elements. The +% width of a group is the maximum of the widths of its elements. +% +% +% Symmetrically, as a group is being constructed, a counter stored in +% placement/chain count is available that is advanced for each chain +% in the group. The number placement/depth is the defined +% recursively as follows: For a single node, the depth is +% computed by the key placement/logical node depth. The depth +% of a group is the sum of the depths of its elements. The depth of a +% chain is the maximum of the depth of its elements. +% +% +% The above keys get updated automatically. You should setup the key +% placement/compute position such that it uses the above keys to +% compute a good position for a new node based on the above +% keys. Typically, this key should execute node={shift=(...)} to setup +% the necessary shift for a new node. +% +% The key placement/compute position should not be called +% directly. Instead, the key placement/place should be used. This key +% has two effects: First, it calls placement/compute position. Second, +% it resets the length and normal counters. It will setup a completely +% new counting of lengths and counters inside the current scope. +% +% The placmenet/place key is executed automatically whenever a new +% node is automatically created. Furthermore, placement strategies +% will call this key. + +\tikzgraphsset{ + placement/.cd, + compute position/.code=\tikz@lib@graph@linear@pos, + place/.code={% + \pgfkeys{/tikz/graphs/placement/compute position}% + \aftergroup\tikz@lib@graph@reset@locals% + \pgfkeyssetvalue{/tikz/graphs/placement/element count}{0}% + \pgfkeyssetvalue{/tikz/graphs/placement/chain count}{0}% + \pgfkeyssetvalue{/tikz/graphs/placement/depth}{0}% + \pgfkeyssetvalue{/tikz/graphs/placement/width}{0}% + \pgfkeyssetvalue{/tikz/graphs/placement/local depth}{0}% + \pgfkeyssetvalue{/tikz/graphs/placement/local width}{0}% + }, + element count/.initial=0, + chain count/.initial=0, + depth/.initial=0, + width/.initial=0, + level/.initial=0, + logical node depth/.code=\def\pgfmathresult{1}, + logical node width/.code=\def\pgfmathresult{1}, +} + +\def\tikz@lib@graph@reset@locals{% + \gdef\tikz@lib@graph@group@depth{0}% + \gdef\tikz@lib@graph@group@width{0}% +} + + +% Arrange nodes evenly +% +% This strategy works as follows: You specify a "chain shift vector" +% and a "group shift vector". Then each new element on a chain is +% shifted by the chain shift vector relative to the previous element +% on the chain. Similarly for each new element of a group. + +\tikzgraphsset{ + Cartesian placement/.style={ + placement/place, + placement/compute position/.code=\tikz@lib@graph@linear@pos% + }, + chain shift/.initial={(1,0)}, + group shift/.initial={(0,-1)}, + grow right/.style={ + placement/place, + chain shift={(#1,0)}, + @auto anchor horizontal=center, + placement/logical node width/.code=\def\pgfmathresult{1} + }, + grow right/.default=1, + grow left/.style={ + placement/place, + chain shift={(-#1,0)}, + @auto anchor horizontal=center, + placement/logical node width/.code=\def\pgfmathresult{1} + }, + grow left/.default=1, + grow up/.style={ + placement/place, + chain shift={(0,#1)}, + @auto anchor horizontal=center, + placement/logical node width/.code=\def\pgfmathresult{1} + }, + grow up/.default=1, + grow down/.style={ + placement/place, + chain shift={(0,-#1)}, + @auto anchor vertical=center, + placement/logical node width/.code=\def\pgfmathresult{1} + }, + grow down/.default=1, + branch right/.style={ + placement/place, + group shift={(#1,0)}, + @auto anchor horizontal=center, + placement/logical node depth/.code=\def\pgfmathresult{1} + }, + branch right/.default=1, + branch left/.style={ + placement/place, + group shift={(-#1,0)}, + @auto anchor horizontal=center, + placement/logical node depth/.code=\def\pgfmathresult{1} + }, + branch left/.default=1, + branch up/.style={ + placement/place, + group shift={(0,#1)}, + @auto anchor vertical=center, + placement/logical node depth/.code=\def\pgfmathresult{1} + }, + branch up/.default=1, + branch down/.style={ + placement/place, + group shift={(0,-#1)}, + @auto anchor vertical=center, + placement/logical node depth/.code=\def\pgfmathresult{1} + }, + branch down/.default=1, + % + % Sep shifts + % + grow right sep/.style={ + Cartesian placement, + chain shift={(1pt,0)}, + @auto anchor horizontal=west, + placement/logical node width/.code=\tikz@lib@graph@width@sep{##1}{#1} + }, + grow right sep/.default=1em, + grow left sep/.style={ + Cartesian placement, + chain shift={(-1pt,0)}, + @auto anchor horizontal=east, + placement/logical node width/.code=\tikz@lib@graph@width@sep{##1}{#1} + }, + grow left sep/.default=1em, + grow up sep/.style={ + Cartesian placement, + chain shift={(0,1pt)}, + @auto anchor vertical=south, + placement/logical node width/.code=\tikz@lib@graph@depth@sep{##1}{#1} + }, + grow up sep/.default=1em, + grow down sep/.style={ + Cartesian placement, + chain shift={(0,-1pt)}, + @auto anchor vertical=north, + placement/logical node width/.code=\tikz@lib@graph@depth@sep{##1}{#1} + }, + grow down sep/.default=1em, + grow right sep/.style={ + Cartesian placement, + chain shift={(1pt,0)}, + @auto anchor horizontal=west, + placement/logical node width/.code=\tikz@lib@graph@width@sep{##1}{#1} + }, + % + branch right sep/.style={ + Cartesian placement, + group shift={(1pt,0)}, + @auto anchor horizontal=west, + placement/logical node depth/.code=\tikz@lib@graph@width@sep{##1}{#1} + }, + branch right sep/.default=1em, + branch left sep/.style={ + Cartesian placement, + group shift={(-1pt,0)}, + @auto anchor horizontal=east, + placement/logical node depth/.code=\tikz@lib@graph@width@sep{##1}{#1} + }, + branch left sep/.default=1em, + branch up sep/.style={ + Cartesian placement, + group shift={(0,1pt)}, + @auto anchor vertical=south, + placement/logical node depth/.code=\tikz@lib@graph@depth@sep{##1}{#1} + }, + branch up sep/.default=1em, + branch down sep/.style={ + Cartesian placement, + group shift={(0,-1pt)}, + @auto anchor vertical=north, + placement/logical node depth/.code=\tikz@lib@graph@depth@sep{##1}{#1} + }, + branch down sep/.default=1em, + % + @auto anchor horizontal/.style={ + nodes={anchor=\csname tikz@lib@graph@auto@\tikz@lib@graph@auto@h @\tikz@lib@graph@auto@v\endcsname}, + /utils/exec=\def\tikz@lib@graph@auto@h{#1} + }, + @auto anchor vertical/.style={ + nodes={anchor=\csname tikz@lib@graph@auto@\tikz@lib@graph@auto@h @\tikz@lib@graph@auto@v\endcsname}, + /utils/exec=\def\tikz@lib@graph@auto@v{#1} + }, + % + % + no placement/.style={ + placement/place, + placement/compute position/.code=% + } +} + +\def\tikz@lib@graph@auto@h{center} +\def\tikz@lib@graph@auto@v{center} + +\def\tikz@lib@graph@auto@center@center{center} +\def\tikz@lib@graph@auto@west@center{west} +\def\tikz@lib@graph@auto@east@center{east} +\def\tikz@lib@graph@auto@center@north{north} +\def\tikz@lib@graph@auto@west@north{north west} +\def\tikz@lib@graph@auto@east@north{north east} +\def\tikz@lib@graph@auto@center@south{south} +\def\tikz@lib@graph@auto@west@south{south west} +\def\tikz@lib@graph@auto@east@south{south east} + +\def\tikz@lib@graph@linear@pos{% + \pgfkeysgetvalue{/tikz/graphs/chain shift}\tikz@temp + \expandafter\tikz@scan@one@point\expandafter\pgf@process\tikz@temp + \pgf@process{\pgfpointscale{\pgfkeysvalueof{/tikz/graphs/placement/width}}{}}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgfkeysgetvalue{/tikz/graphs/group shift}\tikz@temp + \expandafter\tikz@scan@one@point\expandafter\pgf@process\tikz@temp + \pgf@process{\pgfpointscale{\pgfkeysvalueof{/tikz/graphs/placement/depth}}{}}% + \advance\pgf@xa by\pgf@x% + \advance\pgf@ya by\pgf@y% + \edef\tikz@lib@graph@shift{(\the\pgf@xa,\the\pgf@ya)} + \pgfkeys{/tikz/graphs/nodes/.expanded={shift={\tikz@lib@graph@shift}}} +} + + +\def\tikz@lib@graph@width@sep#1#2{% + \pgf@process{\pgfpointdiff{\pgfpointanchor{#1}{west}}{\pgfpointanchor{#1}{east}}}% + \pgfmathparse{#2+\the\pgf@x}% +} + +\def\tikz@lib@graph@depth@sep#1#2{% + \pgf@process{\pgfpointdiff{\pgfpointanchor{#1}{south}}{\pgfpointanchor{#1}{north}}}% + \pgfmathparse{#2+\the\pgf@y}% +} + + +% Circular arrangements +% +% This strategy works a bit like the arrange evenly strategy, but in +% polar coordinates. Both for the chains and the groups you specify a +% polar shift, which must be in the form "(delta degree:delta +% distance)". For each element in a chain, the delta degree is added +% to the chain degree, likewise for each element the delta distance is +% added. Similarly for groups. +% +% There is an initial degree and radius, stored in the key "phase" and +% "radius". + +\tikzgraphsset{, + circular placement/.style={ + placement/place, + placement/compute position/.code=\tikz@lib@graph@circular@pos,% + placement/logical node depth/.code=\def\pgfmathresult{1}, + placement/logical node width/.code=\def\pgfmathresult{1}, + }, + clockwise/.style={ + circular placement, + group polar shift={(-360/#1:0)} + }, + clockwise/.default=\tikzgraphVnum, + counterclockwise/.style={ + circular placement, + group polar shift={(360/#1:0)} + }, + counterclockwise/.default=\tikzgraphVnum, + chain polar shift/.initial={(0:1cm)}, + group polar shift/.initial={(60:0)}, + radius/.initial=1cm, + phase/.initial=90, +} + +\def\tikz@lib@graph@circular@pos{% + \pgfkeysgetvalue{/tikz/graphs/chain polar shift}\tikz@temp + \expandafter\tikz@lib@graph@decompose@polar\tikz@temp% + \pgf@process{\pgfpointscale{\pgfkeysvalueof{/tikz/graphs/placement/width}}{}}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgfkeysgetvalue{/tikz/graphs/group polar shift}\tikz@temp + \expandafter\tikz@lib@graph@decompose@polar\tikz@temp% + \pgf@process{\pgfpointscale{\pgfkeysvalueof{/tikz/graphs/placement/depth}}{}}% + \advance\pgf@xa by\pgf@x% + \advance\pgf@ya by\pgf@y% + \pgfmathparse{\pgfkeysvalueof{/tikz/graphs/radius}}% + \advance\pgf@ya by\pgfmathresult pt% + \pgfmathsetmacro\tikz@temp{\the\pgf@xa+\pgfkeysvalueof{/tikz/graphs/phase}}% + \edef\tikz@lib@graph@shift{(\tikz@temp:\the\pgf@ya)} + \pgfkeys{/tikz/graphs/nodes/.expanded={shift={\tikz@lib@graph@shift}}} +} + + +\def\tikz@lib@graph@decompose@polar(#1:#2){% + \pgfmathsetlength\pgf@x{#1}% + \pgfmathsetlength\pgf@y{#2}% +} + + +% Grid arrangements +% +\tikzgraphsset{ + grid placement/.style={ + placement/place, + placement/compute position/.code=\tikz@lib@graph@grid@pos,% + }, +} + + +\def\tikz@lib@graph@grid@pos{% + % + % Make sure to set \tikzgraphwrapafter before we compute + % the positions of nodes in the grid + % + \tikzgraphpreparewrapafter% + % + % find out the coordinate in the grid + % + \pgfkeysgetvalue{/tikz/graphs/placement/depth}\tikz@temp@depth% + \pgfkeysgetvalue{/tikz/graphs/placement/width}\tikz@temp@width% + \pgfmathsetmacro{\tikz@temp}{max(\tikz@temp@depth, \tikz@temp@width)}% + \pgfmathsetmacro{\tikz@temp@col}{mod(\tikz@temp,\tikzgraphwrapafter)}% + \pgfmathsetmacro{\tikz@temp@row}{div(\tikz@temp,\tikzgraphwrapafter)}% + % + % multiply row by the group shift and col by the chain shift + % + \pgfkeysgetvalue{/tikz/graphs/group shift}\tikz@temp% + \expandafter\tikz@scan@one@point\expandafter\tikz@lib@graph@grid@pos@a\tikz@temp% + \pgfkeysgetvalue{/tikz/graphs/chain shift}\tikz@temp% + \expandafter\tikz@scan@one@point\expandafter\tikz@lib@graph@grid@pos@b\tikz@temp% + % + % apply the shift + % + \edef\tikz@lib@graph@shift{(\the\pgf@xa,\the\pgf@ya)} + \pgfkeys{/tikz/graphs/nodes/.expanded={shift={\tikz@lib@graph@shift}}} +} + +\def\tikz@lib@graph@grid@pos@a#1{\pgf@process{\pgfpointscale{\tikz@temp@row}{#1}}\pgf@xa=\pgf@x\relax\pgf@ya=\pgf@y\relax} +\def\tikz@lib@graph@grid@pos@b#1{\pgf@process{\pgfpointscale{\tikz@temp@col}{#1}}% + \advance\pgf@xa by\pgf@x\relax + \advance\pgf@ya by\pgf@y\relax} + +\tikzgraphsset{ + % Grids: + wrap after/.initial=0, + % Node sets: + V/.code={% + \def\tikzgraphV{#1} + \c@pgf@counta=0\foreach \tikz@dummy in {#1} {\global\advance\c@pgf@counta by1\relax} + \edef\tikzgraphVnum{\the\c@pgf@counta} + }, + V={1}, + n/.style={V={1,...,#1},name shore V/.style={name=V}}, + W/.code={% + \def\tikzgraphW{#1} + \c@pgf@counta=0\foreach \tikz@dummy in {#1} {\global\advance\c@pgf@counta by1\relax} + \edef\tikzgraphWnum{\the\c@pgf@counta} + }, + W={1}, + m/.style={W={1,...,#1},name shore W/.style={name=W}}, + % Shores: + name shore V/.style=, + name shore W/.style=, +} + + + +% +% Quick graphs +% +% Parsing the graph syntax can take a lot of time for large +% graphs. This is mainly due to the transformation of commas and +% semicolons and all the internal bookkeeping. +% +% For large graphs, the quick graph syntax offers a greatly reduced +% syntax that will be processed much more quickly. This syntax is +% compatible with the normal graph syntax in the sense that all +% specifications written in the reduced syntax are also legal in the +% normal syntax, but not the other way round. +% +% The following rules apply: +% +% 1) A quick graph consists of a sequence of either nodes, edges sequences, or +% groups. These are separated by commas or semicolons. +% +% 2) Every node is of the form +% +% "node name"/"node text"[options] +% +% Here, the quotation marks are mandatory. The part '/"node text"' may +% be missing, in which case the node name is used as the node +% text. The options may also be missing. The node name may not contain +% any "funny" characters (unlike in the normal graph command). +% +% 3) Every edge is of the form +% +% ... ; +% +% Here, the are node specifications as described above, +% the is one of the four connectors "->", "<-", "--", and +% "<->", followed by optional options in square +% brackets. The semicolon may be replaced by a comma. +% +% 4) Every group is of the form +% +% { [options] lines }; +% +% The options are compulsory, the lines must be a sequence of nodes, +% edges, and groups as described above. The semicolon can, again, be +% replaced by a comma. +% +% +% Things that are allowed in the normal syntax, but not in the quick +% syntax, include: +% +% - Connecting a node and a group as in a->{b,c}. +% - Node names without quotation marks. +% - Using subgraphs (graph macros). +% - Using graph sets. +% - Using graph color classes. +% - Using anonymous nodes. +% - Using the "fresh nodes" option. +% - Using sublayouts. +% - Using the -!- edge connector. +% - Using the "simple" option. +% - Using edge annotations. +% +% Example: +% +% \graph [quick] { +% "a"/"$a$"[red] -> "b"[blue] -> "c"; +% "b" -> "d"; +% "c" ->[thick] "e"; +% { [same layer] "c", "d" }; +% }; +% +% + +\tikzgraphsset{quick/.is if=tikz@graph@quick} +\newif\iftikz@graph@quick + +\def\tikz@lib@graphs@parse@quick@graph{ + % Ok, we are before the initial brace. We open a group and start + % setting up some bookkeeping + \begingroup% + \global\tikz@qnode@count0\relax% + \let\tikzgraphnodepath\pgfutil@empty% + \tikz@q@outertrue% + \afterassignment\tikz@lib@graphs@quick@main\let\pgf@temp=% +} + +\newcount\tikz@qnode@count +\newif\iftikz@q@outer + +\def\tikz@lib@graphs@quick@main{% + \afterassignment\tikz@lib@graphs@quick@handle\let\pgf@let@token=% +} +\def\tikz@lib@graphs@quick@handle{% + \ifx\pgf@let@token"% + \expandafter\tikz@lib@graphs@quick@first@node% + \else% + \expandafter\tikz@lib@graphs@quick@other% + \fi% +} +\def\tikz@lib@graphs@quick@other{% + \let\tikz@next\tikz@lib@graphs@quick@error% + \ifx\pgf@let@token\egroup% + \let\tikz@next\tikz@lib@graphs@quick@end@group% + \else% + \ifx\pgf@let@token\bgroup% + \let\tikz@next\tikz@lib@graphs@quick@start@group% + \else% + \ifx\pgf@let@token\par% + \let\tikz@next\tikz@lib@graphs@quick@main% + \fi% + \fi + \fi% + \tikz@next% +} + +\def\tikz@lib@graphs@quick@error#1{\tikzerror{Unexpected token '\string#1' in quick graph syntax}\tikz@lib@graphs@quick@main} +\def\tikz@lib@graphs@quick@start@group{% + \pgfutil@ifnextchar[\tikz@lib@graphs@quick@start@group@{\tikzerror{Group + in quick graph syntax must start with options.}} +} + +\def\tikz@lib@graphs@quick@start@group@[#1]{% + \begingroup% + \tikz@q@outerfalse% + \tikzgraphsset{#1}% + \tikz@lib@graphs@quick@main% +} +\def\tikz@lib@graphs@quick@end@group{% + \iftikz@q@outer% + \endgroup% + % Ok, cleanup! + \pgfutil@loop% + \ifnum\tikz@qnode@count>0\relax% + \expandafter\global\expandafter\let\csname tikz@gr@q@@\csname tikz@gr@qn@@\the\tikz@qnode@count\endcsname\endcsname\relax% + \expandafter\global\expandafter\let\csname tikz@gr@qn@@\the\tikz@qnode@count\endcsname\relax% + \global\advance\tikz@qnode@count by-1\relax% + \pgfutil@repeat% + \expandafter\tikz@lib@graph@main@done% + \else% + \endgroup% + \expandafter\tikz@lib@graphs@end@group@% + \fi% +} +\def\tikz@lib@graphs@end@group@{% + \pgfutil@ifnextchar;{\expandafter\tikz@lib@graphs@quick@main\pgfutil@gobble}{% + \pgfutil@ifnextchar,{\expandafter\tikz@lib@graphs@quick@main\pgfutil@gobble}{% + \tikzerror{Graph groups in quick syntax must be followed by a semicolon or a comma.}% + }% + }% +} + + +\def\tikz@lib@graphs@quick@first@node{% + \let\tikz@quick@prev@node\relax% + \tikz@lib@graphs@quick@node% +} + +\def\tikz@lib@graphs@quick@node#1"{% + \def\tikzgraphnodename{#1}% + \pgfutil@ifnextchar/\tikz@lib@graphs@quick@text\tikz@lib@graphs@quick@notext% +} +\def\tikz@lib@graphs@quick@text/"#1"{% + \def\tikzgraphnodetext{#1}% + \tikz@lib@graphs@quick@opt% +} +\def\tikz@lib@graphs@quick@notext{% + \let\tikzgraphnodetext\tikzgraphnodename% + \tikz@lib@graphs@quick@opt% +} +\def\tikz@lib@graphs@quick@opt{% + \pgfutil@ifnextchar[\tikz@lib@graphs@quick@withopt{\tikz@lib@graphs@quick@withopt[]}%] +} +\def\tikz@lib@graphs@quick@withopt[#1]{% + % Test, whether node already exists + \expandafter\ifx\csname tikz@gr@q@@\tikzgraphnodename\endcsname\relax% + % New node + \global\advance\tikz@qnode@count by1\relax% + \expandafter\global\expandafter\let\csname tikz@gr@q@@\tikzgraphnodename\endcsname\pgfutil@empty% not relax + \expandafter\global\expandafter\let\csname tikz@gr@qn@@\the\tikz@qnode@count\endcsname\tikzgraphnodename% back pointer + \let\tikzgraphnodefullname\tikzgraphnodename% + \let\tikzgraphnodeas\tikzgraphnodeas@default% + \node [% + name=\tikzgraphnodename,% + graphs/redirect unknown to tikz, + /tikz/graphs/.cd,% + /tikz/graphs/@nodes styling,% + #1]% + {% + \tikzgraphnodeas% + };% + \else% + % + % Handle late options and operators + \tikzgdlatenodeoptionacallback{\tikzgraphnodename}% + \node also[graphs/redirect unknown to tikz,/tikz/graphs/.cd,#1](\tikzgraphnodename);% + \fi% + % Connect, if necessary + \tikz@lig@graph@quikc@make@edge@if@necessary% + \tikz@lib@graphs@quick@scan@after@node% +} + +\def\tikz@lig@graph@quikc@make@edge@if@necessary{% + \ifx\tikz@quick@prev@node\relax% + \else% + \tikz@lib@graphs@quick@make@edge% + \fi% +} + +\def\tikz@lib@graphs@quick@scan@after@node{% + \pgfutil@ifnextchar,\tikz@lib@graphs@quick@comma{% + \pgfutil@ifnextchar;\tikz@lib@graphs@quick@semi{% + \pgfutil@ifnextchar\egroup{\tikz@lib@graphs@quick@semi;}{% + \pgfutil@ifnextchar\par{\expandafter\tikz@lib@graphs@quick@scan@after@node\tikz@lib@graphs@quick@gobble@par}% + \tikz@lib@graphs@quick@connector}}}% +} +\long\def\tikz@lib@graphs@quick@gobble@par#1{}% + +\def\tikz@lib@graphs@quick@comma,{\tikz@lib@graphs@quick@main} +\def\tikz@lib@graphs@quick@semi;{\tikz@lib@graphs@quick@main} +\def\tikz@lib@graphs@quick@connector#1#2{% + \def\tikz@lib@graphs@quick@edge@kind{#1#2}% + \pgfutil@ifnextchar>\tikz@lib@graphs@back@edge{% + \pgfutil@ifnextchar[\tikz@lib@graphs@quick@connector@handle@opt{\tikz@lib@graphs@quick@connector@handle@opt[]}%] + }% +} +\def\tikz@lib@graphs@back@edge#1{% + \expandafter\def\expandafter\tikz@lib@graphs@quick@edge@kind\expandafter{\tikz@lib@graphs@quick@edge@kind#1}% + \pgfutil@ifnextchar[\tikz@lib@graphs@quick@connector@handle@opt{\tikz@lib@graphs@quick@connector@handle@opt[]}%] +} +\def\tikz@lib@graphs@quick@connector@handle@opt[#1]{% + \def\tikz@lib@graphs@quick@edge@options{#1}% + \let\tikz@quick@prev@node\tikzgraphnodename% + \tikz@lib@graphs@quick@scan@after@connector% +} +\def\tikz@lib@graphs@quick@scan@after@connector{% + \pgfutil@ifnextchar\par{\expandafter\tikz@lib@graphs@quick@scan@after@connector\tikz@lib@graphs@quick@gobble@par}{% + \pgfutil@ifnextchar"{\expandafter\tikz@lib@graphs@quick@node\pgfutil@gobble}{% + \tikzerror{Quotation marks expected after edge connector}% + }% + }% +} + +\def\tikz@lib@graphs@quick@make@edge{% + { + \expandafter\tikz@lib@graphs@quick@make@edge@styling\expandafter{\tikz@lib@graphs@quick@edge@options}% + \expandafter\expandafter\expandafter\tikz@lib@graphs@quick@make@edge@for% + \expandafter\expandafter\expandafter{\expandafter\tikz@quick@prev@node\expandafter}\expandafter{\tikzgraphnodename}% + } +} + +\def\tikz@lib@graphs@quick@make@edge@styling#1{% + \tikz@enable@edge@quotes% + \tikzgraphsset{.unknown/.code=\tikz@lib@graph@unknown@edge@option{##1},#1}% +} + +\def\tikz@lib@graphs@quick@make@edge@for#1#2{% + \pgfkeysgetvalue{/tikz/graphs/@edges styling}\pgf@tempa + \pgfkeysgetvalue{/tikz/graphs/@edges node}\pgf@temp@b + \expandafter\expandafter\expandafter\tikz@lib@graphs@quick@make@edge@for@with% + \expandafter\expandafter\expandafter{\expandafter\pgf@tempa\expandafter}\expandafter{\pgf@temp@b}{#1}{#2}% +} + +\def\tikz@lib@graphs@quick@make@edge@for@with#1#2#3#4{% + \tikzgraphsset{new \tikz@lib@graphs@quick@edge@kind={#3}{#4}{#1}{#2}}% +} + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.standard.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.standard.code.tex new file mode 100644 index 00000000000..a56702bcf96 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.standard.code.tex @@ -0,0 +1,112 @@ +% Copyright 2010 by Till Tantau +% Copyright 2011 by Jannis Pohlmann +% +% 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. + +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/graphs/tikzlibrarygraphs.standard.code.tex,v 1.9 2012/02/27 20:00:11 tantau Exp $ + + +% +% Basic graphs +% + + +\tikzgraphsset{ + % + % An independent set $V$ of nodes. + % + declare={subgraph I_n}% + { + \foreach \tikz@lib@graph@node@num in \tikzgraphV + { \tikz@lib@graph@node@num } + }, + % + % An two-shore independent set $V$ with shores V and W. + % + declare={subgraph I_nm}% + { + subgraph I_n [name shore V] -- [no edges] + subgraph I_n [name shore W, V/.expand once=\tikzgraphW] + }, + % + % The complete clique on $V$. + % + declare={subgraph K_n}% + { + [clique] + subgraph I_n + }, + % + % A complete bipartite graph with shores V and W. + % + declare={subgraph K_nm}% + { + [color class=shore V, + color class=shore W, + complete bipartite={shore V}{shore W}] + subgraph I_n [name shore V, shore V] -- [no edges] + subgraph I_n [name shore W, V/.expand once=\tikzgraphW, shore W] + }, + % + % A cycle with n nodes. + % + declare={subgraph C_n}% + { + [cycle] + subgraph I_n + }, + % + % A path with n nodes. + % + declare={subgraph P_n}% + { + [path] + subgraph I_n + }, + % + % A grid with n nodes. + % + declare={subgraph Grid_n}% + { + [grid] + subgraph I_n + }, + % + % A random graph according to the G_{n,p} model: For each pair of + % vertices there is an edge between them with probability p. + % + p/.initial=0.5, + declare={subgraph G_np}% + { + [/utils/exec={ + \pgfmathsetmacro\tikz@lib@lg@p{\pgfkeysvalueof{/tikz/graphs/p}} + \let\tikz@lib@gnp@edges\pgfutil@empty% + \foreach \tikz@lib@graph@node@a [count=\tikz@lib@g@count@a] in \tikzgraphV + \foreach \tikz@lib@graph@node@b [count=\tikz@lib@g@count@b] in \tikzgraphV + { + \ifnum\tikz@lib@g@count@a<\tikz@lib@g@count@b\relax + \pgfmathparse{rnd} + \ifdim\pgfmathresult pt<\tikz@lib@lg@p pt% + \ifx\tikz@lib@gnp@edges\pgfutil@empty + \xdef\tikz@lib@gnp@edges{\tikz@lib@graph@node@a--\tikz@lib@graph@node@b}% + \else + \xdef\tikz@lib@gnp@edges{\tikz@lib@gnp@edges,\tikz@lib@graph@node@a--\tikz@lib@graph@node@b}% + \fi + \fi + \fi + } + }] + \foreach \tikz@lg@temp in \tikz@lib@gnp@edges { + [parse/.expand once=\tikz@lg@temp] + } + }, +} + + + + diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex index 8c22215eda4..fc01637466b 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex @@ -26,8 +26,8 @@ \toksdef\t@tikzexternal@tmpa=0 \toksdef\t@tikzexternal@tmpb=1 -\newwrite\tikzexternal@outfile \newif\iftikzexternal@nestedflag +\newif\iftikzexternal@verboseuptodate \newif\iftikzexternal@verboseio \newif\iftikzexternal@genfigurelist \newif\iftikzexternal@onlynamed @@ -112,6 +112,9 @@ \pgfqkeys{/tikz/external}{ figure list/.is if=tikzexternal@genfigurelist, aux in dpth/.style={/pgf/images/aux in dpth=#1},% + disable dependency files/.code={% + \let\tikzexternalfiledependsonfile@ACTIVE=\tikzexternalfiledependsonfile + }, % 'mode' applies only if \jobname==real job name. mode/.is choice, mode/only graphics/.code = {% @@ -148,9 +151,11 @@ verbose IO/.default=true, verbose IO=true, verbose optimize/.is if=tikzexternal@verbose@optimize, + verbose up to date/.is if=tikzexternal@verboseuptodate, verbose/.style={ verbose IO=#1, verbose optimize=#1, + verbose up to date=#1, }, shell escape/.initial=-shell-escape, read main aux/.is if=pgfexternalreadmainaux, @@ -249,6 +254,12 @@ \expandafter\gdef\csname c@tikzext@no@#1\endcsname{0}% },% prefix/.code={\tikzsetexternalprefix{#1}}, + up to date check/.is choice, + up to date check/simple/.code={\def\tikzexternal@uptodate@mode{0}}, + % md5 relies on \pdfmdfivesum of pdftex. It uses 'diff' as fallback if we do not have that command. + up to date check/md5/.code={\def\tikzexternal@uptodate@mode{1}}, + up to date check/diff/.code={\def\tikzexternal@uptodate@mode{2}}, + up to date check=md5, } \def\tikzsetfigurename#1{\pgfkeyssetvalue{/tikz/external/figure name}{#1}}% @@ -325,6 +336,14 @@ } \def\tikzexternalize@hasbeencalled{0}% +\def\tikzifexternalizehasbeencalled#1#2{% + \if1\tikzexternalize@hasbeencalled + #1% + \else + #2% + \fi +}% + % If mode=`convert with system call', the boolean \ifpgfexternalreadmainaux % will be set depending on the current lock file. % @@ -710,6 +729,7 @@ \def\tikzexternalgetnextfilename#1{% \begingroup \let\tikzexternal@getnextfilename@advancecount\relax% NOP + \let\tikzexternal@getnextfilename@resetglobals=\relax% NOP \def\tikzexternal@protocol@to@file##1{}% NOP \tikzexternal@getnextfilename#1% \pgfmath@smuggleone#1% @@ -774,11 +794,15 @@ \fi \fi % + \tikzexternal@getnextfilename@resetglobals% + % + \tikzexternal@protocol@to@file#1% +}% + +\def\tikzexternal@getnextfilename@resetglobals{% % Reset global flags: \global\let\tikzexternal@nextfile=\pgfutil@empty \global\tikzexternalexportnexttrue - % - \tikzexternal@protocol@to@file#1% }% % #1: the image file name which should be protocolled. (can be a @@ -792,6 +816,11 @@ \else \pgfutil@ifundefined{tikzexternal@listmode@openedfile}{% \message{Opening '\tikzexternal@realjob.figlist' for writing.}% + \begingroup + \globaldefs=1 + % this gets round '\outer\newwrite' in plain TeX: + \csname newwrite\endcsname\tikzexternal@outfile + \endgroup \immediate\openout\tikzexternal@outfile=\tikzexternal@realjob.figlist\relax \gdef\tikzexternal@listmode@openedfile{1}% \if\tikzexternal@opmode5% mode='list and make' @@ -812,6 +841,9 @@ \def\tikzexternal@list@and@make@gentarget#1{% \tikzexternal@assemble@systemcall{#1}{\pgf@tempa}% + \def\tikzexternal@tempb{\pgfutilstrreplace{^^J}{^^J\tikzexternal@TABchar}}% + \expandafter\tikzexternal@tempb\expandafter{\pgf@tempa}% + \let\pgf@tempa=\pgfretval \iftikzexternal@verboseio \immediate\write16{Writing '#1' to '\tikzexternal@realjob.makefile'.}% \fi @@ -856,6 +888,7 @@ \def\tikzexternalmakefiledefaultdeprule{% \immediate\write\tikzexternal@outmakefile{\tikzexternal@PERCENTchar.\tikzexternaldepext:}% + \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar mkdir -p $(dir $@)}% \immediate\write\tikzexternal@outmakefile{\tikzexternal@TABchar touch $@ \tikzexternal@HASHchar\space will be filled later.}% }% @@ -868,14 +901,16 @@ % Will write something to the make file. If the makefile is not yet % opened, #1 will be written as soon as it *is* opened. \def\tikzexternalwritetomakefile#1{% - \pgfutil@ifundefined{tikzexternal@outmakefile}{% - \expandafter\gdef\expandafter\tikzexternal@outmakefile@pendingcommands\expandafter{% - \tikzexternal@outmakefile@pendingcommands + \if\tikzexternal@opmode5% mode='list and make' + \pgfutil@ifundefined{tikzexternal@outmakefile}{% + \expandafter\gdef\expandafter\tikzexternal@outmakefile@pendingcommands\expandafter{% + \tikzexternal@outmakefile@pendingcommands + \immediate\write\tikzexternal@outmakefile{#1}% + }% + }{% \immediate\write\tikzexternal@outmakefile{#1}% }% - }{% - \immediate\write\tikzexternal@outmakefile{#1}% - }% + \fi }% \def\tikzexternal@dep@file@name{} @@ -896,33 +931,67 @@ % could be auto-generated: empty file name means "picture % won't be externalized". Skip it. \else - \edef\tikzpicturedependsonfile@name{#1.\tikzexternaldepext}% - \ifx\tikzexternal@dep@file@name\tikzpicturedependsonfile@name - % file is open and ready. - \else - % create new output file. - \pgfutil@ifundefined{tikzexternal@dep@file}{% - \begingroup - % this makes \tikzexternal@dep@file global: - \globaldefs=1 - % this gets round '\outer\newwrite' in plain TeX: - \csname newwrite\endcsname\tikzexternal@dep@file - \endgroup - }{}% - \ifx\tikzexternal@dep@file@name\pgfutil@empty - \else - % it is already open. Close it. - \immediate\closeout\tikzexternal@dep@file - \fi - \global\let\tikzexternal@dep@file@name=\tikzpicturedependsonfile@name - \immediate\openout\tikzexternal@dep@file=\tikzexternal@dep@file@name\relax - \fi - \immediate\write\tikzexternal@dep@file{#1\tikzexternalimgextension: #2}% + % if we encounter any dependencies while we externalize a + % picture, we have to write these things into the image's .dep + % file. + \tikzifexternalizingcurrent + {\tikzexternalfiledependsonfile@append@to@dep@file{#1}{#2}}% + {\tikzexternalfiledependsonfile@append@to@makefile{#1}{#2}}% \fi \endgroup }% \def\tikzexternalfiledependsonfile#1#2{}% NO-OP until \tikzexternalize has been called. +% sub-routine of \tikzexternalfiledependsonfile which appends stuff to +% the pictures .dep file. +% +% The file #1.dep is generated during the externalization of #1. If +% you change and/or overwrite it in any other context, its information +% might get lost (because #1 won't be regenerated). +% +% Consequently, this here has to be called if and only if #1 is about +% to be externalized. +\def\tikzexternalfiledependsonfile@append@to@dep@file#1#2{% + % write every dependency which is defined *INSIDE* of the current + % picture into the .dep file of the current picture: + \tikzexternalgetcurrentfilename\tikzpicturedependsonfile@name + \edef\tikzpicturedependsonfile@name{\tikzpicturedependsonfile@name.\tikzexternaldepext}% + %\edef\tikzpicturedependsonfile@name{#1.\tikzexternaldepext}% + \ifx\tikzexternal@dep@file@name\tikzpicturedependsonfile@name + % file is open and ready. + \else + % create new output file. + \pgfutil@ifundefined{tikzexternal@dep@file}{% + \begingroup + % this makes \tikzexternal@dep@file global: + \globaldefs=1 + % this gets round '\outer\newwrite' in plain TeX: + \csname newwrite\endcsname\tikzexternal@dep@file + \endgroup + }{}% + \ifx\tikzexternal@dep@file@name\pgfutil@empty + \else + % it is already open. Close it. + \immediate\closeout\tikzexternal@dep@file + \fi + \global\let\tikzexternal@dep@file@name=\tikzpicturedependsonfile@name + \immediate\openout\tikzexternal@dep@file=\tikzexternal@dep@file@name\relax + \fi + \immediate\write\tikzexternal@dep@file{#1\tikzexternalimgextension: #2}% +} + +% sub-routine of \tikzexternalfiledependsonfile which appends stuff to +% the makefile of the current \jobname . +% +% This is used for dependencies which are recomputed by every run of +% tex; we must not write them into #1.dep (for reasons explained in +% the documentation of +% \tikzexternalfiledependsonfile@append@to@dep@file) +\def\tikzexternalfiledependsonfile@append@to@makefile#1#2{% + \edef\tikzexternal@temp{#1\tikzexternalimgextension: #2}% + \expandafter\tikzexternalwritetomakefile\expandafter{\tikzexternal@temp}% +} + % Adds a dependency for the NEXT picture which is about to be % externalized. If we are currently inside of a picture, the % dependency is added for this current picture. @@ -1064,7 +1133,7 @@ }% \long\def\tikzexternal@optimize@away@latex@env@close#1{% \iftikzexternal@verbose@optimize - \immediate\write16{The complete contents of \string\begin{tikzexternal@optimize@away@latex@env@} up to the next \end{tikzexternal@optimize@away@latex@env@} has been optimized away because it does not contribute to exported PDF. Use '/tikz/external/optimize=false' to disable this.}% + \immediate\write16{The complete contents of \string\begin{tikzexternal@optimize@away@latex@env@} up to the next \end{tikzexternal@optimize@away@latex@env@} has been optimized away because it does not contribute to the exported PDF. Use '/tikz/external/optimize=false' to disable this.}% \fi \endgroup % we still need to invoke \end{} in latex because \begin{} @@ -1104,6 +1173,7 @@ \immediate\write16{A tikzpicture has been optimized away. Use '/tikz/external/optimize=false' to disable this.}% \fi \tikzexternal@closeenvironments + \pgfkeysvalueof{/tikz/external/optimize away text/.@cmd}tikzpicture\pgfeov% } % Processes tikzpicture normally; without any externalization. @@ -1142,17 +1212,32 @@ \def\tikzexternal@forcegraphics{% \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@forcegraphics@@ } -\long\def\tikzexternal@forcegraphics@@#1{% +\long\def\tikzexternal@forcegraphics@@#1{\tikzexternal@forcegraphics@@@}% +\def\tikzexternal@forcegraphics@@@{% + \if5\tikzexternal@opmode + \let\tikz@refundefinedtrue@@=\G@refundefinedtrue + \gdef\G@refundefinedtrue{% + \tikz@refundefinedtrue@@ + \tikzexternal@forceremake@undefined@reference@handler + }% + \fi \expandafter\pgfincludeexternalgraphics\expandafter{\tikzexternal@curfilename}% + \global\let\G@refundefinedtrue=\tikz@refundefinedtrue@@ \tikzexternal@closeenvironments } +\def\tikzexternal@forceremake@undefined@reference@handler{% + \immediate\write16{===== 'mode=list and make': encountered undefined reference in current picture. Adding dependency to FORCEREMAKE. Rerun make to update the picture.' ========^^J}% + \tikzpicturedependsonfile{FORCEREMAKE}% +}% + % Simply replaces the complete picture by some placeholder text. % It is used by 'mode=list only' to reduce runtime. \def\tikzexternal@listmodepicture{% \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@listmodepicture@@ } -\long\def\tikzexternal@listmodepicture@@#1{% +\long\def\tikzexternal@listmodepicture@@#1{\tikzexternal@listmodepicture@@@} +\def\tikzexternal@listmodepicture@@@{% \pgfkeysvalueof{/tikz/external/image discarded text}% \tikzexternal@closeenvironments } @@ -1160,15 +1245,21 @@ % check if there is already a file. % In that case, use it. If not, skip it. \def\tikzexternal@list@and@makefile@mode@picture{% + \tikzexternal@TEXDIALECT@collectpicture\tikzexternal@list@and@makefile@mode@picture@ +}% +\long\def\tikzexternal@list@and@makefile@mode@picture@#1{% + % + \tikzexternal@check@uptodate@mode{#1}% + % \gdef\pgf@filename{}% \xdef\pgf@tempa{\noexpand\pgf@findfile\pgfsys@imagesuffixlist:+{\tikzexternal@curfilename}}% \pgf@tempa \ifx\pgf@filename\pgfutil@empty% % Note: since we have no 'GRAB' mode, we do not have to deal with optimization. % there is no graphics. - \expandafter\tikzexternal@listmodepicture + \expandafter\tikzexternal@listmodepicture@@@ \else - \expandafter\tikzexternal@forcegraphics + \expandafter\tikzexternal@forcegraphics@@@ \fi }% @@ -1193,6 +1284,9 @@ \def\endtikzpicture{% \tikzexternal@origendpicture \pgf@externalend + % + \tikzexternal@ensure@nonempty@floats + % \let\tikzpicture=\tikzexternal@tikzpicture@replacement \let\endtikzpicture=\tikzexternal@origendpicture \iftikzexternal@optimize @@ -1204,6 +1298,21 @@ \tikzpicture }% +% If a sequence of floats containing JUST tikzpictures is +% externalized, this results in EMPTY floats. Empty floats, in turn, +% can confuse latex; it thinks it did something wrong. +% +% Solution: Avoid empty floats by writing junk into it. +% +% Note that this method is only invoked if \ifpgf@external@grabshipout +% is true and if the text is OUTSIDE of the original shipout routine. +% In other words: this text is being thrown away. +% +% see +% http://tex.stackexchange.com/questions/54625/why-is-fixltx2e-incompatible-with-tikzexternalize +\def\tikzexternal@ensure@nonempty@floats{% + tikzexternal: picture has been externalized. This text is required to avoid empty floats. +}% % 1. Discards the current picture in this document. % 2. Checks whether an image exists already. If that is the case: acquire it. @@ -1270,7 +1379,7 @@ \endgroup }% \long\def\tikzexternal@externalizefig@systemcall@@#1{% - \tikzexternal@externalizefig@systemcall@uptodatecheck% + \tikzexternal@externalizefig@systemcall@uptodatecheck{#1}% \iftikzexternal@file@isuptodate \iftikzexternal@verboseio \immediate\write16{===== Image '\tikzexternal@curfilename' is up-to-date. ======}% @@ -1337,6 +1446,124 @@ \fi } +\pgfutil@IfUndefined{pdfmdfivesum}{% +}{% + % predefine to this value. This does only make sense for pdftex. + % note that the latex library for 'external' loads \usepackage{pdftexcmds} which \let's this to \pdf@mdfivesum: + \let\tikzexternal@mdfivesum=\pdfmdfivesum +}% + +\long\def\tikzexternal@computemdfivesum#1{% + \t@tikzexternal@tmpb={#1}% + \edef\tikzexternal@temp{\the\t@tikzexternal@tmpb}% + % \meaning results in a string of catcode 12 - which is expandable. + \edef\pgfretval{\tikzexternal@mdfivesum{\meaning\tikzexternal@temp}}% +} +\long\def\tikzexternal@computemdfivesum@diff@fallback#1{% + \t@tikzexternal@tmpb={#1}% + \edef\tikzexternal@temp{\the\t@tikzexternal@tmpb}% + % \meaning results in a string of catcode 12 - which is expandable. + \edef\pgfretval{\meaning\tikzexternal@temp}% +} + +% Will be set dynamically, depending on 'up to date check'. +% +% It expands to code such that \tikzexternallastkey contains the +% serialized version of '#1'. +% +% It is used as argument for \write{..} +% +% #1 the hash key to serialize. +% \def\tikzexternal@hashfct@serialize +\long\def\tikzexternal@hashfct@serialize@std#1{% + \noexpand\def\noexpand\tikzexternallastkey{#1}% +}% + +% serializes using temporary token registers. Necessary if #1 contains +% executable code. +\long\def\tikzexternal@hashfct@serialize@tok#1{% + \noexpand\begingroup + % in order to allow '#' inside of the body, we have to use token registers: + \noexpand\toks0={#1}% + \noexpand\xdef\noexpand\tikzexternallastkey{\noexpand\the\noexpand\toks0 }% + \noexpand\endgroup +}% + +\def\tikzexternal@check@uptodate@ext{.md5} + +\def\tikzexternal@check@uptodate@mode@warn@fallback{% + \message{! Package tikz Warning: The key 'up to date check=md5' is impossible, there is no macro to compute MD5. Falling back to 'up to date check=diff'.}% + % + % warn only once: + \global\let\tikzexternal@check@uptodate@mode@warn@fallback=\relax +}% + +% assigns the boolean \iftikzexternal@file@isuptodate +\long\def\tikzexternal@check@uptodate@mode#1{% + \if1\tikzexternal@uptodate@mode + % up to date check=md5: + % check if we CAN compute MD5 sums: + \pgfutil@IfUndefined{tikzexternal@mdfivesum}{% + % we cannot compute md5 sums - fallback to diff. + \tikzexternal@check@uptodate@mode@warn@fallback + \def\tikzexternal@uptodate@mode{2}% + }{}% + \fi + % + \ifcase\tikzexternal@uptodate@mode + % up to date check=simple + % nothing to do -- file existance is checked anyway. + \let\tikzexternal@hashfct=\pgfutil@empty + \let\tikzexternal@hashfct@serialize=\pgfutil@empty + \or + % up to date check=md5 + \let\tikzexternal@hashfct=\tikzexternal@computemdfivesum + \let\tikzexternal@hashfct@serialize=\tikzexternal@hashfct@serialize@std + \or + \let\tikzexternal@hashfct=\tikzexternal@computemdfivesum@diff@fallback + \let\tikzexternal@hashfct@serialize=\tikzexternal@hashfct@serialize@tok + \fi + \ifx\tikzexternal@hashfct\pgfutil@empty + \else + \tikzpicturedependsonfile{\tikzexternal@curfilename\tikzexternal@check@uptodate@ext}% + \tikzexternal@hashfct{#1}% + \let\tikzexternal@lastkey@new=\pgfretval + \begingroup + % no '@' token in this macro: avoid messing up the catcodes in input files: + \global\let\tikzexternallastkey=\pgfutil@empty + \openin\r@pgf@reada=\tikzexternal@curfilename\tikzexternal@check@uptodate@ext\relax % + \ifeof\r@pgf@reada + \else + % read first line... + \endlinechar=-1 % older versions did not have a '%' at the end-of-line. Avoid spurious spaces. + \read\r@pgf@reada to\pgf@tempa + % ... and execute it. + \pgf@tempa + % it should contain a definition of \tikzexternallastkey. + \fi + \closein\r@pgf@reada + % + \let\tikzexternal@lastkey=\tikzexternallastkey + \pgfmath@smuggleone\tikzexternal@lastkey + \endgroup + % normalize catcodes. Unfortunately, they cannot be expected to be the same. + % \meaning will use catcode 12 for each token: + \edef\tikzexternal@lastkey@normalized{\meaning\tikzexternal@lastkey}% + \edef\tikzexternal@lastkey@new@normalized{\meaning\tikzexternal@lastkey@new}% + \iftikzexternal@verboseuptodate + \immediate\write16{Up-to-date check of \tikzexternal@curfilename: new \tikzexternal@lastkey@new@normalized; old \tikzexternal@lastkey@normalized.^^J}% + \fi + \ifx\tikzexternal@lastkey@normalized\tikzexternal@lastkey@new@normalized + \tikzexternal@file@isuptodatetrue + \else + \tikzexternal@file@isuptodatefalse + \immediate\openout\w@pgf@writea=\tikzexternal@curfilename\tikzexternal@check@uptodate@ext\relax% + \immediate\write\w@pgf@writea{\tikzexternal@hashfct@serialize{\tikzexternal@lastkey@new}\tikzexternal@PERCENTchar}% + \immediate\closeout\w@pgf@writea + \fi + \fi +} + % Checks whether the current picture needs to be externalized. % % This is the case if @@ -1344,8 +1571,12 @@ % b) the picture has been invalidated manually. % % It returns \iftikzexternal@file@isuptodate accordingly. -\def\tikzexternal@externalizefig@systemcall@uptodatecheck{% +% #1: the picture-content +\long\def\tikzexternal@externalizefig@systemcall@uptodatecheck#1{% \tikzexternal@checkforceremake + \iftikzexternal@file@isuptodate + \tikzexternal@check@uptodate@mode{#1}% + \fi \iftikzexternal@file@isuptodate % check if there is already a file. % In that case, use it. If that is not the case, generate it and include it afterwards. @@ -1365,7 +1596,7 @@ \xdef\pgf@tempa{\noexpand\pgf@findfile\pgfsys@imagesuffixlist:+{\tikzexternal@curfilename}}% \pgf@tempa \ifx\pgf@filename\pgfutil@empty% - \PackageError{tikz}{Sorry, the system call '#1' did NOT result in a usable output file '\tikzexternal@curfilename' (expected one of \pgfsys@imagesuffixlist). Please verify that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or something like that. Or maybe the command simply failed? Error messages can be found in '\tikzexternal@curfilename.log'. If you continue now, I'll try to typeset the picture}% + \tikzerror{Sorry, the system call '#1' did NOT result in a usable output file '\tikzexternal@curfilename' (expected one of \pgfsys@imagesuffixlist). Please verify that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or something like that. Or maybe the command simply failed? Error messages can be found in '\tikzexternal@curfilename.log'. If you continue now, I'll try to typeset the picture}{}% \fi }% @@ -1375,18 +1606,18 @@ \begingroup \tikzexternal@assemble@systemcall{\pgfactualjobname}{\pgf@tempa}% \toks0=\expandafter{\pgf@tempa}% - \PackageError{tikz}{Sorry, image externalization failed: the resulting image was EMPTY. I tried to externalize '\pgfactualjobname', but it seems there is no such image in the document!? + \tikzerror{Sorry, image externalization failed: the resulting image was EMPTY. I tried to externalize '\pgfactualjobname', but it seems there is no such image in the document!? \if\tikzexternal@opmode4 ^^J \space\space You are currently using 'mode=convert with system call'. This problem can happen if the image (or one of the images preceeding it) was declared inside of a \string\label{} (i.e. in the .aux file): 'convert with system call' has no access to the main aux file.^^J \space\space Possible solutions in this case:^^J -\space\space a) Try using 'mode=list and make',^^J -\space\space b) Issue the externalization command '\the\toks0' *manually* (also check the preceeding externalized images, perhaps the file name sequence is not correct).^^J +\space\space (a) Try using 'mode=list and make',^^J +\space\space (b) Issue the externalization command '\the\toks0' *manually* (also check the preceeding externalized images, perhaps the file name sequence is not correct).^^J \space\space Repeat: the resulting image was EMPTY, your attention is required \else \if\tikzexternal@opmode5 ^^J \space\space You are currently using 'mode=list and make'. Possible solutions:^^J -\space\space a) Try to delete `\tikzexternal@realjob.makefile'. Perhaps it is not up-to-date.^^J -\space\space b) Perhaps pictures are declared inside of \string\label{} and the .aux file is not up-to-date. Re-run latex, perhaps re-generate the graphics as well.^^J +\space\space (a) Try to delete `\tikzexternal@realjob.makefile'. Perhaps it is not up-to-date.^^J +\space\space (b) Perhaps pictures are declared inside of \string\label{} and the .aux file is not up-to-date. Re-run latex, perhaps re-generate the graphics as well.^^J \space\space Repeat: the resulting image was EMPTY, your attention is required \fi \fi}% diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrary3d.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrary3d.code.tex index 3d2cecc732f..c6c998e4b6a 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrary3d.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrary3d.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrary3d.code.tex,v 1.1 2008/01/09 17:57:15 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrary3d.code.tex,v 1.2 2013/07/17 10:36:34 tantau Exp $ @@ -16,13 +16,13 @@ \tikzdeclarecoordinatesystem{xyz cylindrical} {% \pgfset{/tikz/cs/.cd,angle=0,radius=0,z=0,#1}% - \pgfpointcylindrical{\tikz@cs@angle}{\tikz@cs@radius}{\tikz@cs@z}% + \pgfpointcylindrical{\tikz@cs@angle}{\tikz@cs@xradius}{\tikz@cs@z}% } \tikzdeclarecoordinatesystem{xyz spherical} {% \pgfset{/tikz/cs/.cd,angle=0,radius=0,latitude=0,longitude=0,#1}% - \pgfpointspherical{\tikz@cs@angle}{\tikz@cs@latitude}{\tikz@cs@radius}% + \pgfpointspherical{\tikz@cs@angle}{\tikz@cs@latitude}{\tikz@cs@xradius}% } \pgfset{/tikz/cs/longitude/.store in=\tikz@cs@angle} diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex new file mode 100644 index 00000000000..2ac3ebc7b22 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex @@ -0,0 +1,72 @@ +% Copyright 2013 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. + +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryangles.code.tex,v 1.1 2013/08/28 15:24:27 tantau Exp $ + + +\tikzset{ + pics/angle/.style = { + setup code = \tikz@lib@angle@parse#1\pgf@stop, + background code = \tikz@lib@angle@background#1\pgf@stop, + foreground code = \tikz@lib@angle@foreground#1\pgf@stop, + }, + pics/angle/.default=A--B--C, + angle eccentricity/.initial=.6, + angle radius/.initial=5mm +} + +\def\tikz@lib@angle@background#1--#2--#3\pgf@stop{% + \path [name prefix ..] [pic actions, draw=none] (#2.center) + -- ++(\tikz@start@angle@temp:\tikz@lib@angle@rad pt) + arc [start angle=\tikz@start@angle@temp, end + angle=\tikz@end@angle@temp, radius=\tikz@lib@angle@rad pt] -- cycle; +} + +\def\tikz@lib@angle@foreground#1--#2--#3\pgf@stop{% + \path [name prefix ..] [pic actions, fill=none, shade=none] + ([shift={(\tikz@start@angle@temp:\tikz@lib@angle@rad pt)}]#2.center) + arc [start angle=\tikz@start@angle@temp, end + angle=\tikz@end@angle@temp, radius=\tikz@lib@angle@rad pt]; + \ifx\tikzpictext\relax\else% + \def\pgf@temp{\node()[name prefix + ..,at={([shift={({.5*\tikz@start@angle@temp+.5*\tikz@end@angle@temp}:\pgfkeysvalueof{/tikz/angle + eccentricity}*\tikz@lib@angle@rad pt)}]#2.center)}]} + \expandafter\pgf@temp\expandafter[\tikzpictextoptions]{\tikzpictext};% + \fi +} + + +\def\tikz@lib@angle@parse#1--#2--#3\pgf@stop{% + % Compute radius: + \pgfmathsetmacro\tikz@lib@angle@rad{\pgfkeysvalueof{/tikz/angle radius}} + \ifdim\tikz@lib@angle@rad pt>0pt\else\def\tikz@lib@angle@rad{12}\fi% + % Compute first coordinate: + \pgf@process{\pgfpointanchor{#2}{center}}% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@process{\pgfpointanchor{#1}{center}}% + \pgf@xb=\pgf@x% + \pgf@yb=\pgf@y% + \pgf@process{\pgfpointanchor{#3}{center}}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \advance\pgf@xb by-\pgf@xa% + \advance\pgf@yb by-\pgf@ya% + \advance\pgf@xc by-\pgf@xa% + \advance\pgf@yc by-\pgf@ya% + \pgfmathsetmacro{\tikz@start@angle@temp}{atan2(\the\pgf@yb,\the\pgf@xb)} + \pgfmathsetmacro{\tikz@end@angle@temp}{atan2(\the\pgf@yc,\the\pgf@xc)} + \ifdim\tikz@end@angle@temp pt<\tikz@start@angle@temp pt% + \pgfmathsetmacro{\tikz@start@angle@temp}{\tikz@start@angle@temp-360}% + \fi% +} + + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybabel.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybabel.code.tex new file mode 100644 index 00000000000..37b5ae20231 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybabel.code.tex @@ -0,0 +1,17 @@ +% Copyright 2013 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. + +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybabel.code.tex,v 1.1 2013/06/24 11:49:06 tantau Exp $ + +\tikzset{ + handle active characters in code, + handle active characters in nodes +} + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybackgrounds.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybackgrounds.code.tex index cd68855bbab..6302b629ae4 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybackgrounds.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybackgrounds.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybackgrounds.code.tex,v 1.2 2010/02/08 11:21:46 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybackgrounds.code.tex,v 1.3 2013/07/18 17:07:38 tantau Exp $ % Layers @@ -18,8 +18,14 @@ % Switch command \tikzset{on background layer/.style={ - execute at begin scope={\pgfonlayer{background}}, - execute at end scope={\endpgfonlayer}}} + execute at begin scope={% + \pgfonlayer{background}% + \let\tikz@options=\pgfutil@empty% + \tikzset{every on background layer/.try,#1}% + \tikz@options}, + execute at end scope={\endpgfonlayer} + } +} % Main style diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybending.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybending.code.tex new file mode 100644 index 00000000000..42a410ce4f5 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybending.code.tex @@ -0,0 +1,15 @@ +% Copyright 2013 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. + +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybending.code.tex,v 1.2 2013/09/17 22:00:21 tantau Exp $ + +\usepgfmodule{bending} +\tikzset{arrows=[flex]} + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarycalc.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarycalc.code.tex index 1a0ea356c24..703494d2a64 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarycalc.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarycalc.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarycalc.code.tex,v 1.6 2009/09/04 17:22:59 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarycalc.code.tex,v 1.9 2013/07/15 12:05:31 tantau Exp $ % % @@ -48,7 +48,7 @@ \pgfutil@ifnextchar\n{% \tikz@cc@handle@num% }{% - \PackageError{tikz}{``\string\p'' or ``\string\n'' expected}{}% + \tikzerror{``\string\p'' or ``\string\n'' expected}% }% }% } @@ -112,7 +112,7 @@ \pgfutil@ifnextchar-{% \tikz@cc@sub% }{% - \PackageError{tikz}{+ or - expected}{}% + \tikzerror{+ or - expected}% \tikz@cc@end$%$ }% }% @@ -177,24 +177,52 @@ % A coordinate can be followed by !...!(...) % -\def\tikz@cc@mid@checks{ +\def\tikz@cc@mid@checks{% + \ifnum\the\catcode`\!=\active\relax + \expandafter\tikz@cc@mid@checks@active + \else + \expandafter\tikz@cc@mid@checks@nonactive + \fi} + +\def\tikz@cc@mid@checks@nonactive{% \pgfutil@ifnextchar!{% - \tikz@cc@mid% + \tikz@cc@mid@nonactive% }{% - \advance\pgf@xa by\tikz@cc@factor\pgf@xb% - \advance\pgf@ya by\tikz@cc@factor\pgf@yb% - \tikz@cc@parse% continue + \advance\pgf@xa by\tikz@cc@factor\pgf@xb + \advance\pgf@ya by\tikz@cc@factor\pgf@yb + \tikz@cc@parse% }% } -\def\tikz@cc@mid!{% +\def\tikz@cc@mid@nonactive!{% \pgfutil@ifnextchar({% \tikz@scan@one@point\tikz@cc@project% }{% - \tikz@cc@mid@num% + \tikz@cc@mid@num@nonactive% }% } +\begingroup + \catcode`\!=\active + \gdef\tikz@cc@mid@checks@active{% + \pgfutil@ifnextchar!{% + \tikz@cc@mid@active% + }{% + \advance\pgf@xa by\tikz@cc@factor\pgf@xb + \advance\pgf@ya by\tikz@cc@factor\pgf@yb + \tikz@cc@parse% + }% + } + + \gdef\tikz@cc@mid@active!{% + \pgfutil@ifnextchar({% + \tikz@scan@one@point\tikz@cc@project% + }{% + \tikz@cc@mid@num@active% + }% + } +\endgroup + % % Partway case: (coord a)!number!(coord b) % @@ -202,7 +230,15 @@ % to b. This, (a)!0!(b) is (a), (a)!.5!(b) is the middle and (a)!1!(b) % is (b) % -\def\tikz@cc@mid@num#1!{% + +\def\tikz@cc@mid@num@nonactive#1!{\tikz@cc@mid@num{#1}} + +\begingroup + \catcode`\!=\active + \gdef\tikz@cc@mid@num@active#1!{\tikz@cc@mid@num{#1}} +\endgroup + +\def\tikz@cc@mid@num#1{% \pgfmathparse{#1}% \ifpgfmathunitsdeclared% \let\tikz@cc@mid@unit=\pgfmathresult% @@ -253,10 +289,27 @@ % Save in c \pgf@xc=\pgf@x% \pgf@yc=\pgf@y% - \expandafter\tikz@cc@scan@rot\expandafter\tikz@cc@after@project\tikz@cc@scan@ex% + \begingroup + \ifnum\the\catcode`\!=\active + \def\tikz@next{% + \endgroup + \expandafter\tikz@cc@scan@rot\expandafter\tikz@cc@after@project + \tikz@cc@scan@ex@active}% + \else + \def\tikz@next{% + \endgroup + \expandafter\tikz@cc@scan@rot\expandafter\tikz@cc@after@project + \tikz@cc@scan@ex@nonactive}% + \fi + \tikz@next% } -\def\tikz@cc@scan@ex!{} +\def\tikz@cc@scan@ex@nonactive!{} + +\begingroup + \catcode`\!=\active + \gdef\tikz@cc@scan@ex@active!{} +\endgroup \def\tikz@cc@after@project#1{% \pgf@process{#1}% @@ -284,16 +337,28 @@ \tikz@scan@one@point#1% normal }% { - \def\tikz@cc@scan@rot@cmd{#1} - \tikz@cc@scan@one@rot% + \def\tikz@cc@scan@rot@cmd{#1}% + \ifnum\the\catcode`\:=\active\relax + \expandafter\tikz@cc@scan@one@rot@active% + \else + \expandafter\tikz@cc@scan@one@rot@nonactive% + \fi }% } -\def\tikz@cc@scan@one@rot#1:{% +\def\tikz@cc@scan@one@rot@nonactive#1:{% \def\tikz@cc@scan@rot@angle{#1}% \tikz@scan@one@point\tikz@cc@handle@rot% } +\begingroup + \catcode`\:=\active + \gdef\tikz@cc@scan@one@rot@active#1:{% + \def\tikz@cc@scan@rot@angle{#1}% + \tikz@scan@one@point\tikz@cc@handle@rot% + } +\endgroup + \def\tikz@cc@handle@rot#1{% \pgf@process{#1}% % Ok, now we need to rotate x/y around xb/xb by ...rot@angle @@ -328,8 +393,8 @@ {% \tikzset{cs/.cd,#1}% \expandafter\ifx\csname tikz@tangent@\tikz@cs@type\endcsname\relax% - \PackageError{tikz}{I do not know how to compute the tangent to - a \tikz@cs@type}{}% + \tikzerror{I do not know how to compute the tangent to + a \tikz@cs@type}% \pgfpointorigin% \else% \expandafter\tikz@scan@one@point\expandafter\tikz@lib@do@tangent\tikz@cs@point% diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarycalendar.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarycalendar.code.tex index 09729059297..02b4f00bb6f 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarycalendar.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarycalendar.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarycalendar.code.tex,v 1.1 2008/01/09 17:57:15 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarycalendar.code.tex,v 1.3 2013/07/15 12:05:31 tantau Exp $ \pgfutil@usemodule{pgfcalendar} @@ -366,24 +366,24 @@ execute before day scope={\ifdate{day of month=1}{% } \def\tikz@lib@cal@scanner{% - \afterassignment\tikz@lib@cal@handle\let\@let@token=% + \afterassignment\tikz@lib@cal@handle\let\pgf@let@token=% } \def\tikz@lib@cal@handle{% \let\@next=\tikz@lib@cal@expand% - \ifx\@let@token;% + \ifx\pgf@let@token;% \let\@next=\tikz@lib@cal@stop% \else% - \ifx\@let@token(%) + \ifx\pgf@let@token(%) \let\@next=\tikz@lib@cal@name% \else% - \ifx\@let@token a% + \ifx\pgf@let@token a% \let\@next=\tikz@lib@cal@at% \else% - \ifx\@let@token[% + \ifx\pgf@let@token[% \let\@next=\tikz@lib@cal@option% \else% - \ifx\@let@token i% + \ifx\pgf@let@token i% \let\@next=\tikz@lib@cal@if% \fi% \fi% @@ -395,14 +395,14 @@ execute before day scope={\ifdate{day of month=1}{% \def\tikz@lib@cal@expand{% \advance\tikz@expandcount by -1% \ifnum\tikz@expandcount<0\relax% - \PackageError{tikz}{Giving up on this calendar}{}% + \tikzerror{Giving up on this calendar}% \let\@next=\tikz@lib@cal@end% \else% \let\@next=\tikz@lib@cal@@expand \fi% \@next} -\def\tikz@lib@cal@@expand{\expandafter\tikz@lib@cal@scanner\@let@token} +\def\tikz@lib@cal@@expand{\expandafter\tikz@lib@cal@scanner\pgf@let@token} \def\tikz@lib@cal@name#1){% diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarychains.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarychains.code.tex index 24019031a36..e2d12a0931a 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarychains.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarychains.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarychains.code.tex,v 1.5 2008/02/27 09:14:09 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarychains.code.tex,v 1.6 2013/07/15 12:05:31 tantau Exp $ \usetikzlibrary{positioning} @@ -29,7 +29,7 @@ \let\tikz@lib@current@chain=\tikz@lib@chain@name% \let\chainin=\tikz@lib@chainin% \else% - \PackageError{tikz}{Chain ``\tikz@lib@chain@name'' is already active}{}% + \tikzerror{Chain ``\tikz@lib@chain@name'' is already active}% \fi% }, continue chain/.default=, @@ -39,7 +39,7 @@ \let\tikz@lib@chain@name\tikz@lib@current@chain% \fi% \expandafter\ifx\csname tikz@lib@chain@exists@\tikz@lib@chain@name\endcsname\relax% - \PackageError{tikz}{Unknown chain ``#1''}{}% + \tikzerror{Unknown chain ``#1''}% \else% \let\tikz@lib@current@chain=\tikz@lib@chain@name% \expandafter\let\csname tikz@lib@chain@active@\tikz@lib@chain@name\endcsname=\pgfutil@empty% does not matter @@ -120,7 +120,7 @@ \let\tikz@lib@chain@name\tikz@lib@current@chain% \fi% \expandafter\ifx\csname tikz@lib@chain@exists@\tikz@lib@chain@name\endcsname\relax% - \PackageError{tikz}{Unknown chain ``\tikz@lib@chain@name''}{}% + \tikzerror{Unknown chain ``\tikz@lib@chain@name''}% \else% \c@pgf@counta\csname tikz@lib@chain@count@\tikz@lib@chain@name\endcsname\relax% \ifnum\c@pgf@counta=0\relax% diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarydecorations.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarydecorations.code.tex index 4ab723f711c..b27783b0009 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarydecorations.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarydecorations.code.tex @@ -55,14 +55,17 @@ \pgfdeclaremetadecoration{tikz@internal}{pre}{ \state{pre}[width=\pgfkeysvalueof{/pgf/decoration/pre length}, next state=main] { + \tikz@dec@trans \decoration{\pgfkeysvalueof{/pgf/decoration/pre}} } \state{main}[width=\pgfmetadecoratedremainingdistance-\pgfkeysvalueof{/pgf/decoration/post length}, next state=final] { + \tikz@dec@trans \decoration{\tikz@decoration@name} } \state{final} { + \tikz@dec@trans \decoration{\pgfkeysvalueof{/pgf/decoration/post}} } } @@ -87,12 +90,13 @@ % Now, we expect a brace. \pgfutil@ifnextchar\bgroup{% \begingroup% + \tikz@auto@end@pathfalse% \aftergroup\tikz@enddecoration% \afterassignment\tikz@scan@next@command% \let\tikz@lib@next% gobble \bgroup% }% {% - \PackageError{tikz}{A decoration must begin with a brace}{}% + \tikzerror{A decoration must begin with a brace}% \tikz@enddecoration% }% } @@ -103,8 +107,8 @@ {% \pgfifdecoration{\tikz@decoration@name}% {\tikz@lib@dec@startdecoration}% - {\PackageError{tikz}{Unknown (meta-)decoration '\tikz@decoration@name'. Perhaps you - misspelled it?}{}}% + {\tikzerror{Unknown (meta-)decoration '\tikz@decoration@name'. Perhaps you + misspelled it?}}% }% \ifx\pgfdecorateexistingpath\pgfutil@empty% \pgfpathmoveto{\pgfqpoint{\the\tikz@lastxsaved}{\the\tikz@lastysaved}}% @@ -147,8 +151,8 @@ \tikz@lib@dec@stopdecoration% } { - \PackageError{tikz}{Unknown (meta-)decoration '\tikz@decoration@name'. Perhaps - you misspelled it?}{} + \tikzerror{Unknown (meta-)decoration '\tikz@decoration@name'. Perhaps + you misspelled it?} } } \fi% diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarydecorations.text.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarydecorations.text.code.tex index e063ba185f0..b75fcc6a562 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarydecorations.text.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarydecorations.text.code.tex @@ -1,4 +1,4 @@ -% Copyright 2008 by Mark Wibrow +% Copyright 2013 by Mark Wibrow % % This file may be distributed and/or modified % @@ -10,4 +10,695 @@ \usetikzlibrary{decorations} \usepgflibrary{decorations.text} + +% Code for the `text effects along path' decoration + +% Some text constants +% To do: merge these with existing text constants +\def\tikz@lib@dec@te@space@text{space} +\def\tikz@lib@dec@align@left@text{left} +\def\tikz@lib@dec@align@right@text{right} +\def\tikz@lib@dec@align@center@text{center} +\def\tikz@lib@dec@te@none@text{none} + +% Some ifs +\newif\iftikz@lib@dec@te@pathfromtext +\newif\iftikz@lib@dec@te@segmentfromwidth +\newif\iftikz@lib@dec@te@scaletexttopath +\newif\iftikz@lib@dec@te@fittexttopath +\newif\iftikz@lib@dec@te@wordsep +\newif\iftikz@lib@dec@te@finalletter + + +% Utility macros +% To do: integrate with exisiting pgf macros +\def\tikz@lib@dec@te@addto@macro#1#2{% + \expandafter\def\expandafter#1\expandafter{#1#2}% +} + +\def\tikz@lib@dec@te@namelet#1#2{% + \expandafter\expandafter\expandafter\let\expandafter\expandafter\csname\expandafter#1\expandafter\endcsname\expandafter=\csname#2\endcsname% +} + +\def\tikz@lib@dec@te@advancecountmacro#1#2{% + \pgfutil@tempcnta=#1\relax% + \advance\pgfutil@tempcnta by#2\relax% + \edef#1{\the\pgfutil@tempcnta}% +} + +\def\tikz@lib@dec@te@advancedimenmacro#1#2{% + \pgf@x=#1\relax% + \advance\pgf@x by#2\relax% + \edef#1{\the\pgf@x}% +} + +% Macros for defining and updating text parameters +\def\tikz@lib@dec@te@start@parameters#1{% + \expandafter\let\csname tikz@lib@dec@te@character@#1\endcsname=\pgfutil@empty% +} + +\def\tikz@lib@dec@te@addto@parameters#1#2{% + \expandafter\tikz@lib@dec@te@addto@macro\expandafter% + {\csname tikz@lib@dec@te@character@#1\endcsname}{#2}% +} +\def\tikz@lib@dec@te@addmacroto@parameters#1#2{% + \def\tikz@lib@dec@te@marshal{\expandafter\tikz@lib@dec@te@addto@macro\expandafter% + {\csname tikz@lib@dec@te@character@#1\endcsname}}% + \expandafter\tikz@lib@dec@te@marshal\expandafter{\expandafter\def\expandafter#2\expandafter{#2}}% +} + +\def\tikz@lib@dec@te@getparameters#1{\csname tikz@lib@dec@te@character@#1\endcsname} + + + +\let\tikz@lib@dec@te@textoptions=\pgfutil@empty +\let\tikz@lib@dec@te@widthoptions=\pgfutil@empty +\let\tikz@lib@dec@te@charactercountvar=\pgfutil@empty +\let\tikz@lib@dec@te@charactertotalvar=\pgfutil@empty +\let\tikz@lib@dec@te@lettercountvar=\pgfutil@empty +\let\tikz@lib@dec@te@lettertotalvar=\pgfutil@empty +\let\tikz@lib@dec@te@wordcountvar=\pgfutil@empty +\let\tikz@lib@dec@te@wordctotalvar=\pgfutil@empty +\let\tikz@lib@dec@te@transformtext=\pgfutil@empty% + + +% Keys... lots of them... +\pgfkeys{/pgf/decoration/text effects/.cd, + .unknown/.code={\let\tikz@lib@dec@te@key@tmp=\pgfkeyscurrentname% + \pgfkeysalso{/tikz/\tikz@lib@dec@te@key@tmp={#1}}}, + path from text/.is if=tikz@lib@dec@te@pathfromtext, + path from text angle/.store in=\tikz@lib@dec@te@pathfromtextangle, + path from text angle=0, + fit text to path/.is if=tikz@lib@dec@te@fittexttopath, + characters/.style={/pgf/decoration/text effects/every character/.style={#1}}, + characters/.append/.code={\pgfkeysalso{/pgf/decoration/text effects/every character/.append style={#1}}}, + character widths/.code={\pgfkeysalso{/pgf/decoration/text effects/every character width/.style={#1}}}, + character widths/.append/.code={\pgfkeysalso{/pgf/decoration/text effects/every character width/.append style={#1}}}, + character count/.store in=\tikz@lib@dec@te@charactercountvar, + character count=, + character total/.store in=\tikz@lib@dec@te@charactertotalvar, + character total=, + letter count/.store in=\tikz@lib@dec@te@lettercountvar, + letter count=, + letter total/.store in=\tikz@lib@dec@te@lettertotalvar, + letter total=, + word count/.store in=\tikz@lib@dec@te@wordcountvar, + word count=, + word total/.store in=\tikz@lib@dec@te@wordtotalvar, + word total=, + % + style characters/.code args={#1 with #2}{\tikz@lib@dec@te@parse@stylecharacters{#1}{#2}}, + text along path/.style={ + inner xsep=0pt, + anchor=base, + transform shape + }, + segment from width/.is if=tikz@lib@dec@te@segmentfromwidth, + segment from width=true, + word separator/.code={% + \def\tikz@lib@dec@te@tmp{#1}% + \ifx\tikz@lib@dec@te@tmp\tikz@lib@dec@te@space@text% + \let\tikz@lib@dec@te@wordsep=\tikz@lib@dec@te@spacetoken% + \else% + \def\tikz@lib@dec@te@wordsep{#1} + \fi}, + word separator=space, + character command/.code={% + \def\tikz@lib@dec@te@tmp{#1}% + \ifx\tikz@lib@dec@te@tmp\pgfutil@empty% + \def\tikz@lib@dec@te@charactercommand{\tikz@lib@dec@te@charactertypesetonly}% + \else% + \def\tikz@lib@dec@te@charactercommand{#1}% + \fi% + }, + character command=, + every character width/.style={/pgf/decoration/text effects/every character/.try}, + every character/.style={}, + reverse text/.code={\tikz@lib@dec@te@addto@macro\tikz@lib@dec@te@transformtext% + {\tikz@lib@dec@te@reversetext}}, + group letters into words/.code={\tikz@lib@dec@te@addto@macro\tikz@lib@dec@te@transformtext% + {\tikz@lib@dec@te@groupletters}}, + group letters/.code={\tikz@lib@dec@te@addto@macro\tikz@lib@dec@te@transformtext% + {\tikz@lib@dec@te@groupletters}}, + replace characters/.code args={#1 with #2}{\tikz@lib@dec@te@parse@replacecharacters{#1}{#2}}, + scale text to path/.is if=tikz@lib@dec@te@scaletexttopath, + fit text to path/.is if=tikz@lib@dec@te@fittexttopath, + repeat text/.store in=\tikz@lib@dec@te@repeattext, + repeat text/.default=-1, + repeat text=0, +} + + +\def\tikz@lib@dec@te@charactertypesetonly#1{#1} + +\tikzset{% + text effects/.code={\pgfkeysalso{/pgf/decoration/text effects/.cd,#1}}, +} + + + + + + +% Prepare the decoration text +% +% This sets up all the character/letter/word, counts/totals +% and caluclates the default width of the characters/text +% (which may be modified later). +% +\def\tikz@lib@dec@te@preparetext{% + % Step 1: scan all the characters in the decoration text + \let\tikz@lib@dec@te@text=\pgfdecorationtext% + \tikz@lib@dec@te@scancharacters{% + \expandafter\let\csname tikz@lib@dec@te@character@\tikz@lib@dec@te@scancount @token\endcsname=% + \tikz@lib@dec@te@character% + }% + \let\tikz@lib@dec@te@charactertotalcount=\tikz@lib@dec@te@scancount% + % Step 2: reverse and/or group characters/letters. + \ifx\tikz@lib@dec@te@transformtext\pgfutil@empty% + \else% + \tikz@lib@dec@te@transformtext% + \fi% + % Step 3: get the character/letter/word counts + \def\tikz@lib@dec@te@charactercount{0}% + \def\tikz@lib@dec@te@wordcount{0}% + \def\tikz@lib@dec@te@wordsepcount{0}% + \def\tikz@lib@dec@te@lettercount{0}% + \def\tikz@lib@dec@te@lastcharacter{0}% + \pgfmathloop% + \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount% + \ifnum\tikz@lib@dec@te@lettercount>0\relax% + \tikz@lib@dec@te@addto@parameters{\tikz@lib@dec@te@lastcharactercount}{\tikz@lib@dec@te@finallettertrue}% + \fi + \else% + \expandafter\let\expandafter\tikz@lib@dec@te@character\expandafter=\csname tikz@lib@dec@te@character@\pgfmathcounter @token\endcsname% + \tikz@lib@dec@te@advancecountmacro{\tikz@lib@dec@te@charactercount}{1}% + \tikz@lib@dec@te@start@parameters{\tikz@lib@dec@te@charactercount}% + \tikz@lib@dec@te@addmacroto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@charactercount}% + \ifx\tikz@lib@dec@te@character\tikz@lib@dec@te@wordsep% + \tikz@lib@dec@te@advancecountmacro{\tikz@lib@dec@te@wordsepcount}{1}% + \ifnum\tikz@lib@dec@te@lettercount>0\relax% + \tikz@lib@dec@te@addto@parameters{\tikz@lib@dec@te@lastcharactercount}{\tikz@lib@dec@te@finallettertrue}% + \fi + \def\tikz@lib@dec@te@lettercount{0}% + \tikz@lib@dec@te@addto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@wordseptrue}% + \else + \ifnum\tikz@lib@dec@te@lettercount=0\relax% + \tikz@lib@dec@te@advancecountmacro\tikz@lib@dec@te@wordcount{1}% + \fi% + \tikz@lib@dec@te@addto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@finalletterfalse}% + \tikz@lib@dec@te@advancecountmacro{\tikz@lib@dec@te@lettercount}{1}% + \tikz@lib@dec@te@addto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@wordsepfalse}% + \expandafter\let\csname tikz@lib@dec@te@word \tikz@lib@dec@te@wordcount @lettercount\endcsname=\tikz@lib@dec@te@lettercount% + \fi% + \tikz@lib@dec@te@addmacroto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@lettercount}% + \tikz@lib@dec@te@addmacroto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@wordcount}% + \tikz@lib@dec@te@addmacroto@parameters{\tikz@lib@dec@te@charactercount}{\tikz@lib@dec@te@character}% + \let\tikz@lib@dec@te@lastcharactercount=\pgfmathcounter% + \repeatpgfmathloop% + \let\tikz@lib@dec@te@wordtotal=\tikz@lib@dec@te@wordcount% + % Step 4: add character/letter/word totals + \pgfmathloop + \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount% + \else% + \tikz@lib@dec@te@addmacroto@parameters{\pgfmathcounter}{\tikz@lib@dec@te@charactertotalcount}% + \tikz@lib@dec@te@addmacroto@parameters{\pgfmathcounter}{\tikz@lib@dec@te@wordtotal}% + \expandafter\let\expandafter\tikz@lib@dec@te@lettertotalcount\expandafter=\csname tikz@lib@dec@te@word \tikz@lib@dec@te@wordcount @lettercount\endcsname% + \tikz@lib@dec@te@addmacroto@parameters{\pgfmathcounter}{\tikz@lib@dec@te@lettertotalcount}% + \repeatpgfmathloop% + % Step 5: calculate the the text and character width + % but do not add to the parameters yet. + \def\tikz@lib@dec@te@textwidth{0pt}% + \pgfmathloop% + \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount% + \else% + \def\tikz@lib@dec@te@characterwidth{0pt}% + \tikz@lib@dec@te@getcharacterwidth{\pgfmathcounter}% + \expandafter\let\csname tikz@lib@dec@te@character@\pgfmathcounter @width\endcsname=\tikz@lib@dec@te@characterwidth% + \pgf@x=\tikz@lib@dec@te@characterwidth\relax% + \pgf@x=0.5\pgf@x% + \expandafter\edef\csname tikz@lib@dec@te@character@\pgfmathcounter @prewidth\endcsname{\the\pgf@x}% + \expandafter\edef\csname tikz@lib@dec@te@character@\pgfmathcounter @postwidth\endcsname{\the\pgf@x}% + \tikz@lib@dec@te@advancedimenmacro{\tikz@lib@dec@te@textwidth}{\tikz@lib@dec@te@characterwidth}% + \repeatpgfmathloop% +} + +% Does the category code of the space matter? +\def\tikz@lib@dec@te@spacetoken{ } + +\let\tikz@lib@dec@te@wordsep=\tikz@lib@dec@te@spacetoken + + +% Scan and count the characters in \tikz@lib@dec@te@text +% +% Create macros \tikz@lib@dec@te@character@@token containing +% the nth character. +% +% Total number of characters is store in +% \tikz@lib@dec@te@chractertotal@count +% +\def\tikz@lib@dec@te@scancharacters#1{% + \def\tikz@lib@dec@te@@@scancharacters@process{#1}% + \def\tikz@lib@dec@te@scancount{0}% + \expandafter\tikz@lib@dec@te@@scancharacters\tikz@lib@dec@te@text\tikz@lib@dec@te@scancharacters}% + +\def\tikz@lib@dec@te@@scancharacters{% + \futurelet\tikz@lib@dec@te@token\tikz@lib@dec@te@@@scancharacters} + +\def\tikz@lib@dec@te@@@scancharacters{% + \ifx\tikz@lib@dec@te@token\tikz@lib@dec@te@scancharacters% + \let\tikz@lib@dec@te@next=\tikz@lib@dec@te@@@@scancharacters% + \else% + \tikz@lib@dec@te@advancecountmacro\tikz@lib@dec@te@scancount{1}% + \ifx\tikz@lib@dec@te@token\pgfutil@sptoken% + \let\tikz@lib@dec@te@next=\tikz@lib@dec@te@@@scancharacters@space% + \else% + \ifx\tikz@lib@dec@te@token\bgroup% + \let\tikz@lib@dec@te@next=\tikz@lib@dec@te@@@scancharacters@bgroup% + \else% + \let\tikz@lib@dec@te@next=\tikz@lib@dec@te@@@scancharacters@normal% + \fi% + \fi% + \fi% + \tikz@lib@dec@te@next% +} + +\def\tikz@lib@dec@te@@@scancharacters@space{% + \let\tikz@lib@dec@te@character=\tikz@lib@dec@te@spacetoken% + \tikz@lib@dec@te@@@scancharacters@process% + \pgfutil@ifnextchar x\tikz@lib@dec@te@@scancharacters\tikz@lib@dec@te@@scancharacters% +} + +\def\tikz@lib@dec@te@@@scancharacters@bgroup#1{% + \def\tikz@lib@dec@te@character{{#1}}% + \tikz@lib@dec@te@@@scancharacters@process% + \tikz@lib@dec@te@@scancharacters% +} + +\def\tikz@lib@dec@te@@@scancharacters@normal#1{% + \def\tikz@lib@dec@te@character{#1}% + \tikz@lib@dec@te@@@scancharacters@process% + \tikz@lib@dec@te@@scancharacters% +} + + +\def\tikz@lib@dec@te@@@@scancharacters#1\tikz@lib@dec@te@scancharacters{} + + +% Reverse the order of the scanned chracters in the text +% (Actually reverse the ordering of the macros containing the characters) +\def\tikz@lib@dec@te@reversetext{% + \c@pgf@counta=\tikz@lib@dec@te@charactertotalcount% + \pgfmathloop% + \ifnum\pgfmathcounter>\c@pgf@counta% + \else% + \tikz@lib@dec@te@namelet{tikz@lib@dec@te@tmp}{tikz@lib@dec@te@character@\pgfmathcounter @token}% + \tikz@lib@dec@te@namelet{tikz@lib@dec@te@character@\pgfmathcounter @token}{tikz@lib@dec@te@character@\the\c@pgf@counta @token}% + \tikz@lib@dec@te@namelet{tikz@lib@dec@te@character@\the\c@pgf@counta @token}{tikz@lib@dec@te@tmp}% + \advance\c@pgf@counta by-1\relax% + \repeatpgfmathloop% +} + +% Group letters (i.e., anything that isn't the word separator) +% as single characters (words). +\def\tikz@lib@dec@te@groupletters{% + \c@pgf@counta=0\relax% + \let\tikz@lib@dec@te@tmp=\pgfutil@empty% + \let\tikz@lib@dec@te@@tmp=\pgfutil@empty% + \pgfmathloop% + \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount% + \ifx\tikz@lib@dec@te@@tmp\pgfutil@empty% + \else% + \advance\c@pgf@counta by1\relax% + \tikz@lib@dec@te@namelet{tikz@lib@dec@te@character@\the\c@pgf@counta @token}{tikz@lib@dec@te@@tmp}% + \fi% + \else% + \tikz@lib@dec@te@namelet{tikz@lib@dec@te@tmp}{tikz@lib@dec@te@character@\pgfmathcounter @token}% + \ifx\tikz@lib@dec@te@tmp\tikz@lib@dec@te@wordsep% + \advance\c@pgf@counta by1\relax% + \tikz@lib@dec@te@namelet{tikz@lib@dec@te@character@\the\c@pgf@counta @token}{tikz@lib@dec@te@@tmp}% + \let\tikz@lib@dec@te@@tmp=\pgfutil@empty% + \advance\c@pgf@counta by1\relax% + \tikz@lib@dec@te@namelet{tikz@lib@dec@te@character@\the\c@pgf@counta @token}{tikz@lib@dec@te@wordsep}% + \else% + \expandafter\tikz@lib@dec@te@addto@macro\expandafter{\expandafter\tikz@lib@dec@te@@tmp\expandafter}\expandafter{\tikz@lib@dec@te@tmp}% + \fi% + \repeatpgfmathloop% + \edef\tikz@lib@dec@te@charactertotalcount{\the\c@pgf@counta}% +} + + +% Get width of node containing only the current character. +\def\tikz@lib@dec@te@getcharacterwidth#1{% + \csname tikz@lib@dec@te@character@#1\endcsname% + \tikz@lib@dec@te@getoptions{every character width/.try}% + \let\tikz@lib@dec@te@lastcharacterwidth=\tikz@lib@dec@te@characterwidth% + \pgfpositionnodelater\tikz@lib@dec@te@@getcharacterwidth% + \pgfutil@ifundefined{tikz@lib@dec@te@character@replacements@\meaning\tikz@lib@dec@te@character @code}{% + \expandafter\node\expandafter[\tikz@lib@dec@te@options,scale=\tikz@lib@dec@scaledcharacterwidthfactor]% + {\hbox{\tikz@lib@dec@te@charactercommand{\tikz@lib@dec@te@character}}};% + \let\tikz@lib@dec@te@characterwidth=\tikz@lib@dec@te@characterwidth@tmp% + }{% + \tikz@lib@dec@te@getcharacter@replacementwidth{\tikz@lib@dec@te@character}% + \let\tikz@lib@dec@te@characterwidth=\tikz@lib@dec@te@character@replacementwidth% + }% +} + +% Update the character parameters with the widths. +\def\tikz@lib@dec@te@addwidthstoparameters{% + \pgfmathloop% + \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount% + \else% + \tikz@lib@dec@te@namelet{tikz@lib@dec@te@characterwidth}{tikz@lib@dec@te@character@\pgfmathcounter @width}% + \tikz@lib@dec@te@namelet{tikz@lib@dec@te@characterprewidth}{tikz@lib@dec@te@character@\pgfmathcounter @prewidth}% + \tikz@lib@dec@te@namelet{tikz@lib@dec@te@characterpostwidth}{tikz@lib@dec@te@character@\pgfmathcounter @postwidth}% + \tikz@lib@dec@te@addmacroto@parameters{\pgfmathcounter}{\tikz@lib@dec@te@characterwidth}% + \tikz@lib@dec@te@addmacroto@parameters{\pgfmathcounter}{\tikz@lib@dec@te@characterprewidth}% + \tikz@lib@dec@te@addmacroto@parameters{\pgfmathcounter}{\tikz@lib@dec@te@characterpostwidth}% + \repeatpgfmathloop% +} + +% Get the options to applied to a character node. + +\def\tikz@lib@dec@te@addoptions#1{% + \expandafter\def\expandafter\tikz@lib@dec@te@options\expandafter{\tikz@lib@dec@te@options,#1}% +} + +\def\tikz@lib@dec@te@getoptions#1{% + \let\tikz@lib@dec@te@lastcharactercommand=\tikz@lib@dec@te@charactercommand% + \def\tikz@lib@dec@te@options{/pgf/decoration/text effects/.cd}% + \tikz@lib@dec@te@addoptions{#1}% + \let\tikzdecorationcharactercount=\tikz@lib@dec@te@charactercount% + \let\tikzdecorationcharactertotal=\tikz@lib@dec@te@charactertotalcount% + \let\tikzdecorationlettercount=\tikz@lib@dec@te@lettercount% + \let\tikzdecorationlettertotal=\tikz@lib@dec@te@lettertotalcount% + \let\tikzdecorationwordcount=\tikz@lib@dec@te@wordcount% + \let\tikzdecorationwordtotal=\tikz@lib@dec@te@wordtotal% + \let\tikzdecorationcharacter=\tikz@lib@dec@te@character% + % + % Define the count variables (if required) + \ifx\tikz@lib@dec@te@charactercountvar\pgfutil@empty% + \else% + \expandafter\let\tikz@lib@dec@te@charactercountvar=\tikz@lib@dec@te@charactercount% + \fi% + % + \ifx\tikz@lib@dec@te@charactertotalvar\pgfutil@empty% + \else% + \expandafter\let\tikz@lib@dec@te@charactertotalvar=\tikz@lib@dec@te@charactertotalcount% + \fi% + % + \ifx\tikz@lib@dec@te@wordcountvar\pgfutil@empty% + \else% + \expandafter\let\tikz@lib@dec@te@wordcountvar=\tikz@lib@dec@te@wordcount% + \fi% + % + \ifx\tikz@lib@dec@te@wordtotalvar\pgfutil@empty% + \else% + \expandafter\let\tikz@lib@dec@te@wordtotalvar=\tikz@lib@dec@te@wordtotal% + \fi% + % + \ifx\tikz@lib@dec@te@lettercountvar\pgfutil@empty% + \else% + \expandafter\let\tikz@lib@dec@te@lettercountvar=\tikz@lib@dec@te@lettercount% + \fi% + % + \ifx\tikz@lib@dec@te@lettertotalvar\pgfutil@empty% + \else% + \expandafter\let\tikz@lib@dec@te@lettertotalvar=\tikz@lib@dec@te@lettetotal% + \fi% + % + \edef\tikz@lib@dec@te@tmp{character \tikz@lib@dec@te@charactercount/.try,% + character {\meaning\tikz@lib@dec@te@character}/.try}% + \expandafter\tikz@lib@dec@te@addoptions\expandafter{\tikz@lib@dec@te@tmp}% + \ifx\tikz@lib@dec@te@character\tikz@lib@dec@te@wordsep% + \tikz@lib@dec@te@addoptions{/pgf/decoration/text effects/every word separator/.try}% + \else% + \ifnum\tikz@lib@dec@te@wordcount>0\relax% + \edef\tikz@lib@dec@te@tmp{every word/.try, word \tikz@lib@dec@te@wordcount/.try}% + \expandafter\tikz@lib@dec@te@addoptions\expandafter{\tikz@lib@dec@te@tmp}% + \ifnum\tikz@lib@dec@te@lettercount>0\relax% + \edef\tikz@lib@dec@te@tmp{every letter/.try,every \tikz@lib@dec@te@lettercount\space letter/.try}% + \expandafter\tikz@lib@dec@te@addoptions\expandafter{\tikz@lib@dec@te@tmp}% + \ifnum\tikz@lib@dec@te@lettercount=1\relax% + \edef\tikz@lib@dec@te@tmp{every first letter/.try}% + \expandafter\tikz@lib@dec@te@addoptions\expandafter{\tikz@lib@dec@te@tmp}% + \fi% + \iftikz@lib@dec@te@finalletter% + \tikz@lib@dec@te@addoptions{every final letter/.try}% + \fi% + \fi% + \fi% + \fi% +} + +% Called by `late positioning' of the node +% to get the width of the bounding box +% of a character. +\def\tikz@lib@dec@te@@getcharacterwidth{% + \iftikz@lib@dec@te@segmentfromwidth% + \pgf@x=\pgfpositionnodelatermaxx\relax% + \advance\pgf@x by-\pgfpositionnodelaterminx\relax% + \else% + \pgf@x=\pgfpositionnodelatermaxy\relax% + \advance\pgf@x by-\pgfpositionnodelaterminy\relax% + \fi% + \xdef\tikz@lib@dec@te@characterwidth@tmp{\the\pgf@x}% +} + + +\def\tikz@lib@dec@te@drawcharacter{% + \csname tikz@lib@dec@te@character@\tikz@lib@dec@te@charactercount\endcsname% + \tikz@lib@dec@te@getoptions{every character/.try}% + \pgfpositionnodelater\relax% + \pgfutil@ifundefined{tikz@lib@dec@te@character@replacements@\meaning\tikz@lib@dec@te@character @code}{% + \expandafter\node\expandafter[\tikz@lib@dec@te@options, scale=\tikz@lib@dec@scaledcharacterwidthfactor]{\hbox{\tikz@lib@dec@te@charactercommand{\tikz@lib@dec@te@character}}};% + }{\tikz@lib@dec@te@drawcharacter@replacement{\tikz@lib@dec@te@character}}% +} + +% Replace the character #1 with a character@replacement +% +\def\tikz@lib@dec@te@drawcharacter@replacement#1{% + \pgfscope% + \expandafter\tikzset\expandafter{\tikz@lib@dec@te@options}% + \csname tikz@lib@dec@te@character@replacements@\meaning#1@code\endcsname% + \endpgfscope% +} + +% Get the width of the character@replacement associated with +% the character #1 +% +\newbox\tikz@lib@dec@te@box +\def\tikz@lib@dec@te@getcharacter@replacementwidth#1{% + \pgfinterruptpicture% + \setbox\tikz@lib@dec@te@box=\hbox{% + \pgfpicture + \expandafter\tikzset\expandafter{\tikz@lib@dec@te@options}% + \csname tikz@lib@dec@te@character@replacements@\meaning#1@code\endcsname% + \endpgfpicture}% + \xdef\tikz@lib@dec@te@character@replacementwidth{\the\wd\tikz@lib@dec@te@box}% + \endpgfinterruptpicture% +} + +\def\tikz@lib@dec@scaledcharacterwidthfactor{1}% + +% Set up the decoration +\def\tikz@lib@dec@te@state@setup@precomputation{% + \def\tikz@lib@te@alignshift{0pt}% + \iftikz@lib@dec@te@pathfromtext% + % The width of the text and characters has already been calculated. + \else% + \let\tikz@lib@dec@te@text=\pgfdecorationtext% + % Get the chracter tokens and the total number of characters. + \tikz@lib@dec@te@preparetext% + \iftikz@lib@dec@te@scaletexttopath% + % OK, *scaling* text to path is easy. + % Simply divide the path length by the text width to + % obtain the scaling factor which will be applied + % "at the last minute"... + \pgfmathdivide{\pgfdecoratedpathlength}{\tikz@lib@dec@te@textwidth}% + \let\tikz@lib@dec@scaledcharacterwidthfactor=\pgfmathresult% + \expandafter\pgfkeys\expandafter{\tikz@lib@dec@te@tmp}% + % ... and recalulate the (pre and post) widths. + \pgfmathloop + \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount% + \else% + \pgf@x=\csname tikz@lib@dec@te@character@\pgfmathcounter @prewidth\endcsname\relax% + \pgf@x=\tikz@lib@dec@scaledcharacterwidthfactor\pgf@x% + \expandafter\edef\csname tikz@lib@dec@te@character@\pgfmathcounter @prewidth\endcsname{\the\pgf@x}% + % + \pgf@x=\csname tikz@lib@dec@te@character@\pgfmathcounter @postwidth\endcsname\relax% + \pgf@x=\tikz@lib@dec@scaledcharacterwidthfactor\pgf@x% + \expandafter\edef\csname tikz@lib@dec@te@character@\pgfmathcounter @postwidth\endcsname{\the\pgf@x}% + \repeatpgfmathloop% + % Update parameters with thewidths. + \tikz@lib@dec@te@addwidthstoparameters% + \let\tikz@lib@dec@te@textwidth=\pgfdecoratedpathlength% + \else% + \iftikz@lib@dec@te@fittexttopath% + % *Fitting* text is less easy. + % The pre and post width of all except the first and last characters + % must be recalculated. + % Only the post width of the first character and the pre width + % of the final character are scaled as these characters should be + % fixed and the start and end of the path, respectively. + % + % We hope that the decoration engine is accurate enough to position + % the last word correctly. + \pgf@x=\pgfdecoratedpathlength% + \pgf@xa=\csname tikz@lib@dec@te@character@1@postwidth\endcsname\relax% + \pgf@xb=\csname tikz@lib@dec@te@character@\tikz@lib@dec@te@charactertotalcount @prewidth\endcsname\relax% + \advance\pgf@x by-\pgf@xa% + \advance\pgf@x by-\pgf@xb% + \pgf@y=\tikz@lib@dec@te@textwidth\relax% + \advance\pgf@y by-\pgf@xa% + \advance\pgf@y by-\pgf@xb% + % + \pgfmathdivide{\the\pgf@x}{\the\pgf@y}% + \let\tikz@lib@dec@characterwidthscale=\pgfmathresult% + \pgfmathloop + \ifnum\pgfmathcounter>\tikz@lib@dec@te@charactertotalcount\relax% + \else% + \ifnum\pgfmathcounter>1\relax% + \pgf@x=\csname tikz@lib@dec@te@character@\pgfmathcounter @prewidth\endcsname\relax% + \pgf@x=\tikz@lib@dec@characterwidthscale\pgf@x% + \expandafter\edef\csname tikz@lib@dec@te@character@\pgfmathcounter @prewidth\endcsname{\the\pgf@x}% + \fi% + \ifnum\pgfmathcounter<\tikz@lib@dec@te@charactertotalcount\relax% + \pgf@x=\csname tikz@lib@dec@te@character@\pgfmathcounter @postwidth\endcsname\relax% + \pgf@x=\tikz@lib@dec@characterwidthscale\pgf@x% + \expandafter\edef\csname tikz@lib@dec@te@character@\pgfmathcounter @postwidth\endcsname{\the\pgf@x}% + \fi% + \repeatpgfmathloop% + % Update parameters with widths. + \tikz@lib@dec@te@addwidthstoparameters% + \let\tikz@lib@dec@te@textwidth=\pgfdecoratedpathlength% + \else% + % Calculate the distance to move along the path for alignment. + \pgfkeysgetvalue{/pgf/decoration/text align/align}{\tikz@lib@dec@align}% + \ifx\tikz@lib@dec@align\tikz@lib@dec@align@center@text% + \pgf@x=\pgfdecoratedpathlength\relax% + \advance\pgf@x by-\tikz@lib@dec@te@textwidth\relax% + \ifdim\pgf@x<0pt\relax% + \pgf@x=0pt\relax% + \fi% + \divide\pgf@x by2\relax% + % Adjust the pre-width of the first character... + \pgf@xa=\csname tikz@lib@dec@te@character@1@prewidth\endcsname\relax% + \advance\pgf@xa by\pgf@x% + \expandafter\edef\csname tikz@lib@dec@te@character@1@prewidth\endcsname{\the\pgf@xa}% + % ...and the post-width of the last character. + \pgf@xa=\csname tikz@lib@dec@te@character@\tikz@lib@dec@te@charactertotalcount @postwidth\endcsname\relax% + \advance\pgf@xa by\pgf@x% + \expandafter\edef\csname tikz@lib@dec@te@character@\tikz@lib@dec@te@charactertotalcount @postwidth\endcsname{\the\pgf@xa}% + \else% + \ifx\tikz@lib@dec@align\tikz@lib@dec@align@right@text% + \pgf@x=\pgfdecoratedpathlength\relax% + \advance\pgf@x by-\tikz@lib@dec@te@textwidth\relax% + \ifdim\pgf@x<0pt\relax% + \pgf@x=0pt\relax% + \fi% + % Adjust the pre-width of the first character... + \pgf@xa=\csname tikz@lib@dec@te@character@1@prewidth\endcsname\relax% + \advance\pgf@xa by\pgf@x% + \expandafter\edef\csname tikz@lib@dec@te@character@1@prewidth\endcsname{\the\pgf@xa}% + \fi% + \fi% + \tikz@lib@dec@te@addwidthstoparameters% + \fi% + \fi% + \fi% +} + + +% Evil hack into the decoration code. +% +% If the path contains single move to and the `path from text' +% key is set to true. The width of the text is calcuated here +% and the (straight line) path automatically calculated. +% +\def\pgf@decorate@path@check@moveto#1{% + \expandafter\pgf@decorate@path@@check@moveto#1\pgf@decorate@stop\pgf@decorate@@stop} + +\def\pgf@decorate@token@stop{\pgf@decorate@stop}% +\def\pgf@decorate@path@@check@moveto#1#2#3#4\pgf@decorate@@stop#5#6{% + \def\pgf@decorate@temp{#4}% + \pgf@x=#2\relax% + \pgf@y=#3\relax% + \ifx\pgf@decorate@temp\pgf@decorate@token@stop% + \iftikz@lib@dec@te@pathfromtext% + % Get the start position... + \pgfextract@process\tikz@lib@dec@te@pathstart{}% + \tikz@lib@dec@te@preparetext% + \tikz@lib@dec@te@addwidthstoparameters% + % ... and create a lineto path of the correct length. + \pgfsetpath\pgfutil@empty% + \pgfpathmoveto{\tikz@lib@dec@te@pathstart}% + \pgfpathlineto{\pgfpointadd{\tikz@lib@dec@te@pathstart}% + {\pgfpointpolar{\tikz@lib@dec@te@pathfromtextangle}{\tikz@lib@dec@te@textwidth}}}% + \pgfgetpath\pgfdecoratedpath% + \pgfsetpath\pgfutil@empty% + \else% + #5% + \fi% + \else% + \tikz@lib@dec@te@pathfromtextfalse% + #6% + \fi% +} + + +\pgfdeclaredecoration{text effects along path}{setup}{ + \state{setup}[width=+0pt, next state=scan, persistent precomputation={% + \tikz@lib@dec@te@state@setup@precomputation% + \def\tikz@lib@dec@te@charactercount{0}% + }]{} + % +\state{scan}[width=+0pt, next state=pre token, persistent precomputation={% + \tikz@lib@dec@te@advancecountmacro\tikz@lib@dec@te@charactercount{1}% + % Usual switch to final state is based on distance. + % Here we also need it to be on the number of the + % current character. + \ifnum\tikz@lib@dec@te@charactercount>\tikz@lib@dec@te@charactertotalcount\relax% + \ifnum\tikz@lib@dec@te@repeattext=0\relax% + \def\pgf@decorate@next@state{final}% + \else% + \tikz@lib@dec@te@advancecountmacro\tikz@lib@dec@te@repeattext{-1}% + \def\tikz@lib@dec@te@charactercount{1}% + \fi% + \fi% + % Install parameters for this character. + \csname tikz@lib@dec@te@character@\tikz@lib@dec@te@charactercount\endcsname% +}]{} +% +\state{pre token}[width=+\tikz@lib@dec@te@characterprewidth, next state=token]{} +\state{token}[width=+0pt, next state=post token] +{% + \tikz@lib@dec@te@drawcharacter% +} +\state{post token}[width=+\tikz@lib@dec@te@characterpostwidth, next state=scan]{} +} + + +% Parse styles for individual characters +% #1 a string of characters (e.g., aieou{\"U}{\"a"}) +% #2 the options for to apply to each character. +% +\def\tikz@lib@dec@te@parse@stylecharacters#1#2{% + \def\tikz@lib@dec@te@text{#1}% + \tikz@lib@dec@te@scancharacters{% + \pgfkeysalso{/pgf/decoration/text effects/character {\meaning\tikz@lib@dec@te@character}/.style={#2}}% + }% +} + +% Parse replacment code for for individual characters +% #1 a string of characters (e.g., aieou{\"U}{\"a"}) +% #2 the code to execute to each character. +% +\def\tikz@lib@dec@te@parse@replacecharacters#1#2{% + \def\tikz@lib@dec@te@text{#1}% + \tikz@lib@dec@te@scancharacters{% + \expandafter\def\csname tikz@lib@dec@te@character@replacements@\meaning\tikz@lib@dec@te@character @code\endcsname{#2}% + }% +} + \endinput diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryfit.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryfit.code.tex index 2ae21de0420..ef6a88dc1a9 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryfit.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryfit.code.tex @@ -7,10 +7,10 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryfit.code.tex,v 1.3 2008/06/21 18:59:25 vibrovski Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryfit.code.tex,v 1.5 2013/07/12 17:33:49 tantau Exp $ \pgfkeys{/tikz/fit/.code=\tikz@lib@fit{#1}, - /tikz/rotate fit/.code=\def\tikz@lib@fit@rotate{#1}\pgfkeysalso{/tikz/rotate=#1} + /tikz/rotate fit/.code=\def\tikz@lib@fit@rotate{#1}\pgfkeysalso{/tikz/rotate=#1} } \def\tikz@lib@fit@rotate{0} @@ -37,31 +37,33 @@ \advance\pgf@xa by.5\pgf@x% \advance\pgf@ya by.5\pgf@y% \ifdim\tikz@lib@fit@rotate pt=0pt\relax% - \edef\tikz@node@at{\noexpand\pgfpoint{\the\pgf@xa}{\the\pgf@ya}}% + {% + \pgftransforminvert% + \pgf@pos@transform{\pgf@xa}{\pgf@ya}% + \global\pgf@xa\pgf@xa + \global\pgf@ya\pgf@ya + } \else% - \pgf@xc=\pgf@x% - \pgf@yc=\pgf@y% - {% - \pgf@xc=\pgf@xa% - \pgf@yc=\pgf@ya% - \pgfgettransform\tikz@lib@fit@transform% - \pgftransforminvert% - \pgf@pos@transform{\pgf@xc}{\pgf@yc}% - \pgftransformreset% - \pgftransformrotate{\tikz@lib@fit@rotate}% - \pgf@pos@transform{\pgf@xc}{\pgf@yc}% - \pgfsettransform\tikz@lib@fit@transform% - \pgf@pos@transform{\pgf@xc}{\pgf@yc}% - \global\pgf@x=\pgf@xc% - \global\pgf@y=\pgf@yc% - }% - \pgf@xa=\pgf@x% - \pgf@ya=\pgf@y% - \pgf@x=\pgf@xc% - \pgf@y=\pgf@yc% - \fi% - \edef\tikz@node@at{\noexpand\pgfpoint{\the\pgf@xa}{\the\pgf@ya}}% - \pgfkeysalso{/tikz/anchor=center,/tikz/text centered}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + {% + \pgf@xc=\pgf@xa% + \pgf@yc=\pgf@ya% + \pgftransforminvert% + \pgf@pos@transform{\pgf@xc}{\pgf@yc}% + \pgftransformreset% + \pgftransformrotate{\tikz@lib@fit@rotate}% + \pgf@pos@transform{\pgf@xc}{\pgf@yc}% + \global\pgf@x=\pgf@xc% + \global\pgf@y=\pgf@yc% + }% + \pgf@xa=\pgf@x% + \pgf@ya=\pgf@y% + \pgf@x=\pgf@xc% + \pgf@y=\pgf@yc% + \fi% + \edef\tikz@node@at{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% + \pgfkeysalso{/tikz/anchor=center,/tikz/text badly centered}% \pgfkeysalso{/tikz/text width/.expanded=\the\pgf@x}% \pgf@x=\pgf@y% \pgf@y=.5\pgf@y% @@ -90,25 +92,25 @@ } \def\tikz@lib@fit@adjust#1{% - \ifdim\tikz@lib@fit@rotate pt=0pt\relax% - \pgf@process{#1}% - \else% - {% - #1% - \pgf@xc=\pgf@x% - \pgf@yc=\pgf@y% - \pgfgettransform\tikz@lib@fit@transform% - \pgftransforminvert% - \pgf@pos@transform{\pgf@xc}{\pgf@yc}% - \pgftransformreset% - \pgftransformrotate{-\tikz@lib@fit@rotate}% - \pgf@pos@transform{\pgf@xc}{\pgf@yc}% - \pgfsettransform\tikz@lib@fit@transform% - \pgf@pos@transform{\pgf@xc}{\pgf@yc}% - \global\pgf@x=\pgf@xc% - \global\pgf@y=\pgf@yc% - }% - \fi% + \ifdim\tikz@lib@fit@rotate pt=0pt\relax% + \pgf@process{\pgfpointtransformed{#1}}% + \else% + {% + \pgf@process{\pgfpointtransformed{#1}}% + \pgf@xc=\pgf@x% + \pgf@yc=\pgf@y% + \pgfgettransform\tikz@lib@fit@transform% + \pgftransforminvert% + \pgf@pos@transform{\pgf@xc}{\pgf@yc}% + \pgftransformreset% + \pgftransformrotate{-\tikz@lib@fit@rotate}% + \pgf@pos@transform{\pgf@xc}{\pgf@yc}% + \pgfsettransform\tikz@lib@fit@transform% + \pgf@pos@transform{\pgf@xc}{\pgf@yc}% + \global\pgf@x=\pgf@xc% + \global\pgf@y=\pgf@yc% + }% + \fi% \ifdim\pgf@x<\pgf@xa% \pgf@xa=\pgf@x% \fi% diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryfolding.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryfolding.code.tex index 2ecdfeb11c7..1c45b6eac4d 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryfolding.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryfolding.code.tex @@ -1,4 +1,5 @@ % Copyright 2006 by Till Tantau +% Copyright 2013 by Nico Van Cleemput % % This file may be distributed and/or modified % @@ -7,7 +8,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryfolding.code.tex,v 1.1 2008/01/09 17:57:16 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryfolding.code.tex,v 1.3 2013/08/28 11:00:54 tantau Exp $ % @@ -18,6 +19,41 @@ \newdimen\tikz@lib@fold@length \tikz@lib@fold@length=2cm +% Faces +% ----- + +\def\tikz@lib@fold@triangle#1#2#3#4{% + \begin{scope}[xshift=.5\tikz@lib@fold@length,yshift=.28868\tikz@lib@fold@length] + #1 + \end{scope} + \begin{scope}[shift={(60:\tikz@lib@fold@length)},rotate=-60] + #2 + \end{scope} + \begin{scope}[xshift=\tikz@lib@fold@length,rotate=180] + #3 + \end{scope} + \begin{scope}[rotate=60] + #4 + \end{scope} +} + +\def\tikz@lib@fold@square#1#2#3#4#5{% + \begin{scope}[xshift=.5\tikz@lib@fold@length,yshift=.5\tikz@lib@fold@length] + #1 + \end{scope} + \begin{scope}[yshift=\tikz@lib@fold@length] + #2 + \end{scope} + \begin{scope}[xshift=\tikz@lib@fold@length,yshift=\tikz@lib@fold@length,rotate=-90] + #3 + \end{scope} + \begin{scope}[xshift=\tikz@lib@fold@length,rotate=180] + #4 + \end{scope} + \begin{scope}[rotate=90] + #5 + \end{scope} +} \def\tikz@lib@fold@pentagon#1#2#3#4#5#6{% \begin{scope}[xshift=.5\tikz@lib@fold@length,yshift=0.68819\tikz@lib@fold@length] @@ -40,13 +76,165 @@ \end{scope} } +\def\tikz@lib@fold@hexagon#1#2#3#4#5#6#7{% + \begin{scope} + [shift={(60:\tikz@lib@fold@length)}] + #1 + \end{scope} + \begin{scope} + [shift={(120:\tikz@lib@fold@length)}, + shift={(60:\tikz@lib@fold@length)}] + #2 + \end{scope} + \begin{scope} + [shift={(120:\tikz@lib@fold@length)}, + shift={(60:\tikz@lib@fold@length)}, + xshift=\tikz@lib@fold@length, + rotate=-60] + #3 + \end{scope} + \begin{scope} + [xshift=\tikz@lib@fold@length, + shift={(60:\tikz@lib@fold@length)}, + rotate=-120] + #4 + \end{scope} + \begin{scope} + [xshift=\tikz@lib@fold@length, + rotate=180] + #5 + \end{scope} + \begin{scope} + [rotate=120] + #6 + \end{scope} + \begin{scope} + [shift={(120:\tikz@lib@fold@length)}, + rotate=60] + #7 + \end{scope} +} + +\def\tikz@lib@fold@octagon#1#2#3#4#5#6#7#8#9{% + \begin{scope}[xshift=.5\tikz@lib@fold@length,yshift=1.20711\tikz@lib@fold@length] + #1 + \end{scope} + \begin{scope}[yshift=2.41421\tikz@lib@fold@length] + #2 + \end{scope} + \begin{scope}[xshift=\tikz@lib@fold@length,yshift=2.41421\tikz@lib@fold@length,rotate=-45] + #3 + \end{scope} + \begin{scope}[xshift=1.70711\tikz@lib@fold@length,yshift=1.70711\tikz@lib@fold@length,rotate=-90] + #4 + \end{scope} + \begin{scope}[xshift=1.70711\tikz@lib@fold@length,yshift=.70711\tikz@lib@fold@length,rotate=-135] + #5 + \end{scope} + \begin{scope}[xshift=\tikz@lib@fold@length,rotate=180] + #6 + \end{scope} + \begin{scope}[rotate=135] + #7 + \end{scope} + \begin{scope}[xshift=-.70711\tikz@lib@fold@length,yshift=.70711\tikz@lib@fold@length,rotate=90] + #8 + \end{scope} + \begin{scope}[xshift=-.70711\tikz@lib@fold@length,yshift=1.70711\tikz@lib@fold@length,rotate=45] + #9 + \end{scope} +} + +\def\tikz@lib@fold@decagon#1#2#3#4#5#6#7{% + \begin{scope}[shift={(72:1.61803\tikz@lib@fold@length)}] %decagon inside a circle with radius the golden ratio has side length 1 + #1 + \end{scope} + \begin{scope} + [shift={(36:\tikz@lib@fold@length)}, + shift={(72:\tikz@lib@fold@length)}, + shift={(108:\tikz@lib@fold@length)}, + shift={(144:\tikz@lib@fold@length)}] + #2 + \end{scope} + \begin{scope} + [xshift=\tikz@lib@fold@length, + shift={(36:\tikz@lib@fold@length)}, + shift={(72:\tikz@lib@fold@length)}, + shift={(108:\tikz@lib@fold@length)}, + shift={(144:\tikz@lib@fold@length)}, + rotate=-36] + #3 + \end{scope} + \begin{scope} + [xshift=\tikz@lib@fold@length, + shift={(36:\tikz@lib@fold@length)}, + shift={(72:\tikz@lib@fold@length)}, + shift={(108:\tikz@lib@fold@length)}, + rotate=-72] + #4 + \end{scope} + \begin{scope} + [xshift=\tikz@lib@fold@length, + shift={(36:\tikz@lib@fold@length)}, + shift={(72:\tikz@lib@fold@length)}, + rotate=-108] + #5 + \end{scope} + \begin{scope} + [xshift=\tikz@lib@fold@length, + shift={(36:\tikz@lib@fold@length)}, + rotate=-144] + #6 + \end{scope} + \begin{scope} + [xshift=\tikz@lib@fold@length, + rotate=180] + #7 + \end{scope} + \tikz@lib@fold@decagonbis +} + +\def\tikz@lib@fold@decagonbis#1#2#3#4{% + \begin{scope} + [rotate=144] + #1 + \end{scope} + \begin{scope} + [shift={(144:\tikz@lib@fold@length)}, + rotate=108] + #2 + \end{scope} + \begin{scope} + [shift={(144:\tikz@lib@fold@length)}, + shift={(108:\tikz@lib@fold@length)}, + rotate=72] + #3 + \end{scope} + \begin{scope} + [shift={(144:\tikz@lib@fold@length)}, + shift={(108:\tikz@lib@fold@length)}, + shift={(72:\tikz@lib@fold@length)}, + rotate=36] + #4 + \end{scope} +} \def\tikz@lib@fold@path{\draw[every fold](0,0) -- (\tikz@lib@fold@length,0pt);} \def\tikz@lib@fold@cut@path{\draw[every cut](0,0) -- (\tikz@lib@fold@length,0pt);} \def\tikz@lib@fold@ear@path{ + \path[every ear] (0,0) -- (.5\tikz@lib@fold@length,.2\tikz@lib@fold@length) --(\tikz@lib@fold@length,0pt) --(0,0) -- cycle; \draw[every fold](0,0) -- (\tikz@lib@fold@length,0pt); \draw[every cut] (0,0) -- (.5\tikz@lib@fold@length,.2\tikz@lib@fold@length) --(\tikz@lib@fold@length,0pt);} +\def\tikz@lib@fold@ear@custom@left@path#1{ + \path[every ear] (0,0) -- (#1:.66\tikz@lib@fold@length) -- (\tikz@lib@fold@length,0pt) --(0,0) -- cycle; + \draw[every fold](0,0) -- (\tikz@lib@fold@length,0pt); + \draw[every cut] (0,0) -- (#1:.66\tikz@lib@fold@length) -- (\tikz@lib@fold@length,0pt);} +\def\tikz@lib@fold@ear@custom@right@path#1{ + \path[every ear] (0,0) -- (\tikz@lib@fold@length,0pt) -- ++(-#1:-.66\tikz@lib@fold@length) --(0,0) -- cycle; + \draw[every fold](0,0) -- (\tikz@lib@fold@length,0pt); + \draw[every cut] (\tikz@lib@fold@length,0pt) -- ++(-#1:-.66\tikz@lib@fold@length) -- (0,0);} +\tikzstyle{every ear}=[] \tikzstyle{every cut}=[] \tikzstyle{every fold}=[help lines] @@ -62,6 +250,87 @@ \tikzoption{face 10}{\def\tikz@lib@fold@face@J{#1}} \tikzoption{face 11}{\def\tikz@lib@fold@face@K{#1}} \tikzoption{face 12}{\def\tikz@lib@fold@face@L{#1}} +\tikzoption{face 13}{\def\tikz@lib@fold@face@M{#1}} +\tikzoption{face 14}{\def\tikz@lib@fold@face@N{#1}} +\tikzoption{face 15}{\def\tikz@lib@fold@face@O{#1}} +\tikzoption{face 16}{\def\tikz@lib@fold@face@P{#1}} +\tikzoption{face 17}{\def\tikz@lib@fold@face@Q{#1}} +\tikzoption{face 18}{\def\tikz@lib@fold@face@R{#1}} +\tikzoption{face 19}{\def\tikz@lib@fold@face@S{#1}} +\tikzoption{face 20}{\def\tikz@lib@fold@face@T{#1}} +\tikzoption{face 21}{\def\tikz@lib@fold@face@U{#1}} +\tikzoption{face 22}{\def\tikz@lib@fold@face@V{#1}} +\tikzoption{face 23}{\def\tikz@lib@fold@face@W{#1}} +\tikzoption{face 24}{\def\tikz@lib@fold@face@X{#1}} +\tikzoption{face 25}{\def\tikz@lib@fold@face@Y{#1}} +\tikzoption{face 26}{\def\tikz@lib@fold@face@Z{#1}} +\tikzoption{face 27}{\def\tikz@lib@fold@face@AA{#1}} +\tikzoption{face 28}{\def\tikz@lib@fold@face@AB{#1}} +\tikzoption{face 29}{\def\tikz@lib@fold@face@AC{#1}} +\tikzoption{face 30}{\def\tikz@lib@fold@face@AD{#1}} +\tikzoption{face 31}{\def\tikz@lib@fold@face@AE{#1}} +\tikzoption{face 32}{\def\tikz@lib@fold@face@AF{#1}} +\tikzoption{face 33}{\def\tikz@lib@fold@face@AG{#1}} +\tikzoption{face 34}{\def\tikz@lib@fold@face@AH{#1}} +\tikzoption{face 35}{\def\tikz@lib@fold@face@AI{#1}} +\tikzoption{face 36}{\def\tikz@lib@fold@face@AJ{#1}} +\tikzoption{face 37}{\def\tikz@lib@fold@face@AK{#1}} +\tikzoption{face 38}{\def\tikz@lib@fold@face@AL{#1}} +\tikzoption{face 39}{\def\tikz@lib@fold@face@AM{#1}} +\tikzoption{face 40}{\def\tikz@lib@fold@face@AN{#1}} +\tikzoption{face 41}{\def\tikz@lib@fold@face@AO{#1}} +\tikzoption{face 42}{\def\tikz@lib@fold@face@AP{#1}} +\tikzoption{face 43}{\def\tikz@lib@fold@face@AQ{#1}} +\tikzoption{face 44}{\def\tikz@lib@fold@face@AR{#1}} +\tikzoption{face 45}{\def\tikz@lib@fold@face@AS{#1}} +\tikzoption{face 46}{\def\tikz@lib@fold@face@AT{#1}} +\tikzoption{face 47}{\def\tikz@lib@fold@face@AU{#1}} +\tikzoption{face 48}{\def\tikz@lib@fold@face@AV{#1}} +\tikzoption{face 49}{\def\tikz@lib@fold@face@AW{#1}} +\tikzoption{face 50}{\def\tikz@lib@fold@face@AX{#1}} +\tikzoption{face 51}{\def\tikz@lib@fold@face@AY{#1}} +\tikzoption{face 52}{\def\tikz@lib@fold@face@AZ{#1}} +\tikzoption{face 53}{\def\tikz@lib@fold@face@BA{#1}} +\tikzoption{face 54}{\def\tikz@lib@fold@face@BB{#1}} +\tikzoption{face 55}{\def\tikz@lib@fold@face@BC{#1}} +\tikzoption{face 56}{\def\tikz@lib@fold@face@BD{#1}} +\tikzoption{face 57}{\def\tikz@lib@fold@face@BE{#1}} +\tikzoption{face 58}{\def\tikz@lib@fold@face@BF{#1}} +\tikzoption{face 59}{\def\tikz@lib@fold@face@BG{#1}} +\tikzoption{face 60}{\def\tikz@lib@fold@face@BH{#1}} +\tikzoption{face 61}{\def\tikz@lib@fold@face@BI{#1}} +\tikzoption{face 62}{\def\tikz@lib@fold@face@BJ{#1}} +\tikzoption{face 63}{\def\tikz@lib@fold@face@BK{#1}} +\tikzoption{face 64}{\def\tikz@lib@fold@face@BL{#1}} +\tikzoption{face 65}{\def\tikz@lib@fold@face@BM{#1}} +\tikzoption{face 66}{\def\tikz@lib@fold@face@BN{#1}} +\tikzoption{face 67}{\def\tikz@lib@fold@face@BO{#1}} +\tikzoption{face 68}{\def\tikz@lib@fold@face@BP{#1}} +\tikzoption{face 69}{\def\tikz@lib@fold@face@BQ{#1}} +\tikzoption{face 70}{\def\tikz@lib@fold@face@BR{#1}} +\tikzoption{face 71}{\def\tikz@lib@fold@face@BS{#1}} +\tikzoption{face 72}{\def\tikz@lib@fold@face@BT{#1}} +\tikzoption{face 73}{\def\tikz@lib@fold@face@BU{#1}} +\tikzoption{face 74}{\def\tikz@lib@fold@face@BV{#1}} +\tikzoption{face 75}{\def\tikz@lib@fold@face@BW{#1}} +\tikzoption{face 76}{\def\tikz@lib@fold@face@BX{#1}} +\tikzoption{face 77}{\def\tikz@lib@fold@face@BY{#1}} +\tikzoption{face 78}{\def\tikz@lib@fold@face@BZ{#1}} +\tikzoption{face 79}{\def\tikz@lib@fold@face@CA{#1}} +\tikzoption{face 80}{\def\tikz@lib@fold@face@CB{#1}} +\tikzoption{face 81}{\def\tikz@lib@fold@face@CC{#1}} +\tikzoption{face 82}{\def\tikz@lib@fold@face@CD{#1}} +\tikzoption{face 83}{\def\tikz@lib@fold@face@CE{#1}} +\tikzoption{face 84}{\def\tikz@lib@fold@face@CF{#1}} +\tikzoption{face 85}{\def\tikz@lib@fold@face@CG{#1}} +\tikzoption{face 86}{\def\tikz@lib@fold@face@CH{#1}} +\tikzoption{face 87}{\def\tikz@lib@fold@face@CI{#1}} +\tikzoption{face 88}{\def\tikz@lib@fold@face@CJ{#1}} +\tikzoption{face 89}{\def\tikz@lib@fold@face@CK{#1}} +\tikzoption{face 90}{\def\tikz@lib@fold@face@CL{#1}} +\tikzoption{face 91}{\def\tikz@lib@fold@face@CM{#1}} +\tikzoption{face 92}{\def\tikz@lib@fold@face@CN{#1}} + \let\tikz@lib@fold@face@A=\pgfutil@empty \let\tikz@lib@fold@face@B=\pgfutil@empty @@ -75,69 +344,1734 @@ \let\tikz@lib@fold@face@J=\pgfutil@empty \let\tikz@lib@fold@face@K=\pgfutil@empty \let\tikz@lib@fold@face@L=\pgfutil@empty +\let\tikz@lib@fold@face@M=\pgfutil@empty +\let\tikz@lib@fold@face@N=\pgfutil@empty +\let\tikz@lib@fold@face@O=\pgfutil@empty +\let\tikz@lib@fold@face@P=\pgfutil@empty +\let\tikz@lib@fold@face@Q=\pgfutil@empty +\let\tikz@lib@fold@face@R=\pgfutil@empty +\let\tikz@lib@fold@face@S=\pgfutil@empty +\let\tikz@lib@fold@face@T=\pgfutil@empty +\let\tikz@lib@fold@face@U=\pgfutil@empty +\let\tikz@lib@fold@face@V=\pgfutil@empty +\let\tikz@lib@fold@face@W=\pgfutil@empty +\let\tikz@lib@fold@face@X=\pgfutil@empty +\let\tikz@lib@fold@face@Y=\pgfutil@empty +\let\tikz@lib@fold@face@Z=\pgfutil@empty +\let\tikz@lib@fold@face@AA=\pgfutil@empty +\let\tikz@lib@fold@face@AB=\pgfutil@empty +\let\tikz@lib@fold@face@AC=\pgfutil@empty +\let\tikz@lib@fold@face@AD=\pgfutil@empty +\let\tikz@lib@fold@face@AE=\pgfutil@empty +\let\tikz@lib@fold@face@AF=\pgfutil@empty +\let\tikz@lib@fold@face@AG=\pgfutil@empty +\let\tikz@lib@fold@face@AH=\pgfutil@empty +\let\tikz@lib@fold@face@AI=\pgfutil@empty +\let\tikz@lib@fold@face@AJ=\pgfutil@empty +\let\tikz@lib@fold@face@AK=\pgfutil@empty +\let\tikz@lib@fold@face@AL=\pgfutil@empty +\let\tikz@lib@fold@face@AM=\pgfutil@empty +\let\tikz@lib@fold@face@AN=\pgfutil@empty +\let\tikz@lib@fold@face@AO=\pgfutil@empty +\let\tikz@lib@fold@face@AP=\pgfutil@empty +\let\tikz@lib@fold@face@AQ=\pgfutil@empty +\let\tikz@lib@fold@face@AR=\pgfutil@empty +\let\tikz@lib@fold@face@AS=\pgfutil@empty +\let\tikz@lib@fold@face@AT=\pgfutil@empty +\let\tikz@lib@fold@face@AU=\pgfutil@empty +\let\tikz@lib@fold@face@AV=\pgfutil@empty +\let\tikz@lib@fold@face@AW=\pgfutil@empty +\let\tikz@lib@fold@face@AX=\pgfutil@empty +\let\tikz@lib@fold@face@AY=\pgfutil@empty +\let\tikz@lib@fold@face@AZ=\pgfutil@empty +\let\tikz@lib@fold@face@BA=\pgfutil@empty +\let\tikz@lib@fold@face@BB=\pgfutil@empty +\let\tikz@lib@fold@face@BC=\pgfutil@empty +\let\tikz@lib@fold@face@BD=\pgfutil@empty +\let\tikz@lib@fold@face@BE=\pgfutil@empty +\let\tikz@lib@fold@face@BF=\pgfutil@empty +\let\tikz@lib@fold@face@BG=\pgfutil@empty +\let\tikz@lib@fold@face@BH=\pgfutil@empty +\let\tikz@lib@fold@face@BI=\pgfutil@empty +\let\tikz@lib@fold@face@BJ=\pgfutil@empty +\let\tikz@lib@fold@face@BK=\pgfutil@empty +\let\tikz@lib@fold@face@BL=\pgfutil@empty +\let\tikz@lib@fold@face@BM=\pgfutil@empty +\let\tikz@lib@fold@face@BN=\pgfutil@empty +\let\tikz@lib@fold@face@BO=\pgfutil@empty +\let\tikz@lib@fold@face@BP=\pgfutil@empty +\let\tikz@lib@fold@face@BQ=\pgfutil@empty +\let\tikz@lib@fold@face@BR=\pgfutil@empty +\let\tikz@lib@fold@face@BS=\pgfutil@empty +\let\tikz@lib@fold@face@BT=\pgfutil@empty +\let\tikz@lib@fold@face@BU=\pgfutil@empty +\let\tikz@lib@fold@face@BV=\pgfutil@empty +\let\tikz@lib@fold@face@BW=\pgfutil@empty +\let\tikz@lib@fold@face@BX=\pgfutil@empty +\let\tikz@lib@fold@face@BY=\pgfutil@empty +\let\tikz@lib@fold@face@BZ=\pgfutil@empty +\let\tikz@lib@fold@face@CA=\pgfutil@empty +\let\tikz@lib@fold@face@CB=\pgfutil@empty +\let\tikz@lib@fold@face@CC=\pgfutil@empty +\let\tikz@lib@fold@face@CD=\pgfutil@empty +\let\tikz@lib@fold@face@CE=\pgfutil@empty +\let\tikz@lib@fold@face@CF=\pgfutil@empty +\let\tikz@lib@fold@face@CG=\pgfutil@empty +\let\tikz@lib@fold@face@CH=\pgfutil@empty +\let\tikz@lib@fold@face@CI=\pgfutil@empty +\let\tikz@lib@fold@face@CJ=\pgfutil@empty +\let\tikz@lib@fold@face@CK=\pgfutil@empty +\let\tikz@lib@fold@face@CL=\pgfutil@empty +\let\tikz@lib@fold@face@CM=\pgfutil@empty +\let\tikz@lib@fold@face@CN=\pgfutil@empty + + +\tikzstyle{numbered faces}=[% + face 1={\node{1};}, + face 2={\node{2};}, + face 3={\node{3};}, + face 4={\node{4};}, + face 5={\node{5};}, + face 6={\node{6};}, + face 7={\node{7};}, + face 8={\node{8};}, + face 9={\node{9};}, + face 10={\node{10};}, + face 11={\node{11};}, + face 12={\node{12};}, + face 13={\node{13};}, + face 14={\node{14};}, + face 15={\node{15};}, + face 16={\node{16};}, + face 17={\node{17};}, + face 18={\node{18};}, + face 19={\node{19};}, + face 20={\node{20};}, + face 21={\node{21};}, + face 22={\node{22};}, + face 23={\node{23};}, + face 24={\node{24};}, + face 25={\node{25};}, + face 26={\node{26};}, + face 27={\node{27};}, + face 28={\node{28};}, + face 29={\node{29};}, + face 30={\node{30};}, + face 31={\node{31};}, + face 32={\node{32};}, + face 33={\node{33};}, + face 34={\node{34};}, + face 35={\node{35};}, + face 36={\node{36};}, + face 37={\node{37};}, + face 38={\node{38};}, + face 39={\node{39};}, + face 40={\node{40};}, + face 41={\node{41};}, + face 42={\node{42};}, + face 43={\node{43};}, + face 44={\node{44};}, + face 45={\node{45};}, + face 46={\node{46};}, + face 47={\node{47};}, + face 48={\node{48};}, + face 49={\node{49};}, + face 50={\node{50};}, + face 51={\node{51};}, + face 52={\node{52};}, + face 53={\node{53};}, + face 54={\node{54};}, + face 55={\node{55};}, + face 56={\node{56};}, + face 57={\node{57};}, + face 58={\node{58};}, + face 59={\node{59};}, + face 60={\node{60};}, + face 61={\node{61};}, + face 62={\node{62};}, + face 63={\node{63};}, + face 64={\node{64};}, + face 65={\node{65};}, + face 66={\node{66};}, + face 67={\node{67};}, + face 68={\node{68};}, + face 69={\node{69};}, + face 70={\node{70};}, + face 71={\node{71};}, + face 72={\node{72};}, + face 73={\node{73};}, + face 74={\node{74};}, + face 75={\node{75};}, + face 76={\node{76};}, + face 77={\node{77};}, + face 78={\node{78};}, + face 79={\node{79};}, + face 80={\node{80};}, + face 81={\node{81};}, + face 82={\node{82};}, + face 83={\node{83};}, + face 84={\node{84};}, + face 85={\node{85};}, + face 86={\node{86};}, + face 87={\node{87};}, + face 88={\node{88};}, + face 89={\node{89};}, + face 90={\node{90};}, + face 91={\node{91};}, + face 92={\node{92};}] + +% The foldings defined here: + +\tikzset{ + pics/dodecahedron folding/.style = {code=\tikzfoldingdodecahedron[];}, + pics/tetrahedron folding/.style = {code=\tikzfoldingtetrahedron[];}, + pics/tetrahedron truncated folding/.style = {code=\tikzfoldingtruncatedtetrahedron[];}, + pics/cube folding/.style = {code=\tikzfoldingcube[];}, + pics/cube truncated folding/.style = {code=\tikzfoldingtruncatedcube[];}, + pics/octahedron folding/.style = {code=\tikzfoldingoctahedron[];}, + pics/octahedron truncated folding/.style = {code=\tikzfoldingtruncatedoctahedron[];}, + pics/dodecahedron folding/.style = {code=\tikzfoldingdodecahedron[];}, + pics/dodecahedron' folding/.style = {code=\tikzfoldingalternatedodecahedron[];}, + pics/cuboctahedron folding/.style = {code=\tikzfoldingoctahedron[];}, + pics/cuboctahedron truncated folding/.style = {code=\tikzfoldingtruncatedoctahedron[];}, + pics/icosahedron folding/.style = {code=\tikzfoldingicosahedron[];}, + pics/rhombicuboctahedron folding/.style = {code=\tikzfoldingrhombicuboctahedron[];}, + pics/snub cube folding/.style = {code=\tikzfoldingsnubcube[];}, + pics/icosidodecahedron folding/.style = {code=\tikzfoldingicosahedron[];} +} + + +% Platonic solids +% --------------- + \def\tikzfoldingdodecahedron#1[#2]#3;{% \begingroup% \tikzset{#2}% - \tikz@lib@fold@pentagon{\tikz@lib@fold@face@A} - { - \tikz@lib@fold@pentagon{\tikz@lib@fold@face@B} - { - \tikz@lib@fold@pentagon{\tikz@lib@fold@face@C}{\tikz@lib@fold@ear@path}{\tikz@lib@fold@ear@path}{\tikz@lib@fold@path}{\tikz@lib@fold@ear@path}{\tikz@lib@fold@ear@path} - } - {\tikz@lib@fold@ear@path} - {\tikz@lib@fold@path} - {\tikz@lib@fold@ear@path} - {\tikz@lib@fold@ear@path} + \tikz@lib@fold@pentagon + {\tikz@lib@fold@face@A} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@B} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@C} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@D} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@E} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@F} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@G} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@H} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@I} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@J} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@K} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@L} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + \endgroup +} + +%alternative dodecahedron: larger format possible + +\def\tikzfoldingalternatedodecahedron#1[#2]#3;{% + \begingroup% + \tikzset{#2}% + \tikz@lib@fold@pentagon + {\tikz@lib@fold@face@A} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@B} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@C} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@D} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@E} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@F} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@G} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + } + } + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@H} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@I} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@J} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@K} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@pentagon + {\tikz@lib@fold@face@L} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + \endgroup +} + + +%tetrahedron + +\def\tikzfoldingtetrahedron#1[#2]#3;{% + \begingroup% + \tikzset{#2}% + \tikz@lib@fold@triangle + {\tikz@lib@fold@face@A} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@B} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@C} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@D} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + \endgroup +} + +%cube + +\def\tikzfoldingcube#1[#2]#3;{% + \begingroup% + \tikzset{#2}% + \tikz@lib@fold@square{\tikz@lib@fold@face@A} { - \tikz@lib@fold@pentagon{\tikz@lib@fold@face@D} - { - \tikz@lib@fold@pentagon{\tikz@lib@fold@face@E}{\tikz@lib@fold@ear@path}{\tikz@lib@fold@ear@path}{\tikz@lib@fold@path}{\tikz@lib@fold@cut@path}{\tikz@lib@fold@ear@path} - } - {\tikz@lib@fold@ear@path} - {\tikz@lib@fold@path} - {\tikz@lib@fold@cut@path} - {\tikz@lib@fold@cut@path} + \tikz@lib@fold@square{\tikz@lib@fold@face@B} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} } { - \tikz@lib@fold@pentagon{\tikz@lib@fold@face@F} - { - \tikz@lib@fold@pentagon{\tikz@lib@fold@face@G}{\tikz@lib@fold@ear@path}{\tikz@lib@fold@ear@path}{\tikz@lib@fold@path}{\tikz@lib@fold@cut@path}{\tikz@lib@fold@ear@path} - } - {\tikz@lib@fold@ear@path} - {\tikz@lib@fold@path} - {\tikz@lib@fold@cut@path} - {\tikz@lib@fold@cut@path} + \tikz@lib@fold@square{\tikz@lib@fold@face@C} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} } { - \tikz@lib@fold@pentagon{\tikz@lib@fold@face@H} - { - \tikz@lib@fold@pentagon{\tikz@lib@fold@face@I}{\tikz@lib@fold@ear@path}{\tikz@lib@fold@ear@path}{\tikz@lib@fold@path}{\tikz@lib@fold@cut@path}{\tikz@lib@fold@ear@path} - } - {\tikz@lib@fold@ear@path} - {\tikz@lib@fold@path} - {\tikz@lib@fold@cut@path} - {\tikz@lib@fold@cut@path} + \tikz@lib@fold@square{\tikz@lib@fold@face@D} + { + \tikz@lib@fold@square{\tikz@lib@fold@face@E} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} } { - \tikz@lib@fold@pentagon{\tikz@lib@fold@face@J} - { - \tikz@lib@fold@pentagon{\tikz@lib@fold@face@K} + \tikz@lib@fold@square{\tikz@lib@fold@face@F} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + \endgroup +} + + +%octahedron + +\def\tikzfoldingoctahedron#1[#2]#3;{% + \begingroup% + \tikzset{#2}% + \tikz@lib@fold@triangle + {\tikz@lib@fold@face@A} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@B} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@C} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@D} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@E} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@F} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@G} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@H} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + \endgroup +} + + +%icosahedron + +\def\tikzfoldingicosahedron#1[#2]#3;{% + \begingroup% + \tikzset{#2}% + \tikz@lib@fold@triangle + {\tikz@lib@fold@face@A} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@B} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@C} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@D} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@E} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@F} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@G} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@H} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@I} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@J} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@K} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@L} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@M} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@N} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@O} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@P} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@Q} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@R} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@S} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@T} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + \endgroup +} + +% Archimedean solids +% ------------------ + +%truncated tetrahedron + +\def\tikzfoldingtruncatedtetrahedron#1[#2]#3;{% + \begingroup% + \tikzset{#2}% + \tikz@lib@fold@hexagon + {\tikz@lib@fold@face@A} + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@B} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@C} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@D} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@E} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@F} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@G} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@H} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + \endgroup +} + +%cuboctahedron + +\def\tikzfoldingcuboctahedron#1[#2]#3;{% + \begingroup% + \tikzset{#2}% + \tikz@lib@fold@square + {\tikz@lib@fold@face@A} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@B} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@C} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@D} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@E} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@F} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@G} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@H} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@I} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@J} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@K} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@L} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@M} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@N} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + \endgroup +} + +%truncated cube + +\def\tikzfoldingtruncatedcube#1[#2]#3;{% + \begingroup% + \tikzset{#2}% + \tikz@lib@fold@octagon + {\tikz@lib@fold@face@A} + {\tikz@lib@fold@octagon + {\tikz@lib@fold@face@B} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@C} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@D} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@E} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@F} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + } {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@octagon + {\tikz@lib@fold@face@G} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@H} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + } {\tikz@lib@fold@cut@path} - {\tikz@lib@fold@path} + {\tikz@lib@fold@octagon + {\tikz@lib@fold@face@I} + {\tikz@lib@fold@octagon + {\tikz@lib@fold@face@J} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@K} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@L} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } {\tikz@lib@fold@cut@path} - { - \tikz@lib@fold@pentagon{\tikz@lib@fold@face@L}{\tikz@lib@fold@cut@path}{\tikz@lib@fold@cut@path}{\tikz@lib@fold@path}{\tikz@lib@fold@cut@path}{\tikz@lib@fold@cut@path} + {\tikz@lib@fold@octagon + {\tikz@lib@fold@face@M} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@N} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@cut@path} + \endgroup +} + + +%truncated octahedron + +\def\tikzfoldingtruncatedoctahedron#1[#2]#3;{% + \begingroup% + \tikzset{#2}% + \tikz@lib@fold@hexagon + {\tikz@lib@fold@face@A} + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@B} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@C} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@D} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@square + {\tikz@lib@fold@face@E} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@F} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@G} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + } + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@H} + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@I} + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@J} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@square + {\tikz@lib@fold@face@K} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@L} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@M} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@square + {\tikz@lib@fold@face@N} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + \endgroup +} + + +%rhombicuboctahedron + +\def\tikzfoldingrhombicuboctahedron#1[#2]#3;{% + \begingroup% + \tikzset{#2}% + \tikz@lib@fold@square + {\tikz@lib@fold@face@A} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@B} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@C} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@D} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@E} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@F} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@G} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@H} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@I} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + } + {\tikz@lib@fold@square + {\tikz@lib@fold@face@J} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@K} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@L} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@M} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + } + {\tikz@lib@fold@square + {\tikz@lib@fold@face@N} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@O} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@square + {\tikz@lib@fold@face@P} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@Q} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@R} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@S} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@T} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + {\tikz@lib@fold@square + {\tikz@lib@fold@face@U} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@V} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@W} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@triangle + {\tikz@lib@fold@face@X} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + {\tikz@lib@fold@square + {\tikz@lib@fold@face@Y} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@Z} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + \endgroup +} + +%truncated cuboctahedron + +\def\tikzfoldingtruncatedcuboctahedron#1[#2]#3;{% + \begingroup% + \tikzset{#2}% + \tikz@lib@fold@square + {\tikz@lib@fold@face@A} + {\tikz@lib@fold@octagon + {\tikz@lib@fold@face@B} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@C} + {\tikz@lib@fold@octagon + {\tikz@lib@fold@face@D} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@E} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@F} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@custom@right@path{15}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@G} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@custom@left@path{15}} + {\tikz@lib@fold@ear@path} + } + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@H} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@I} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@J} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@custom@right@path{15}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@custom@left@path{15}} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@K} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@custom@right@path{15}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@custom@left@path{15}} + {\tikz@lib@fold@ear@path} + } + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@L} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@M} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@N} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@custom@right@path{15}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@custom@left@path{15}} + {\tikz@lib@fold@ear@path} } - } - {\tikz@lib@fold@cut@path} - {\tikz@lib@fold@path} - {\tikz@lib@fold@cut@path} - {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@octagon + {\tikz@lib@fold@face@O} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@P} + {\tikz@lib@fold@octagon + {\tikz@lib@fold@face@Q} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@R} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@S} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@T} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@custom@right@path{15}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@custom@left@path{15}} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@U} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@custom@right@path{15}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@custom@left@path{15}} + {\tikz@lib@fold@ear@path} + } + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@V} + {\tikz@lib@fold@octagon + {\tikz@lib@fold@face@W} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@square + {\tikz@lib@fold@face@X} + {\tikz@lib@fold@octagon + {\tikz@lib@fold@face@Y} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@hexagon + {\tikz@lib@fold@face@Z} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@custom@right@path{15}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@custom@left@path{15}} + {\tikz@lib@fold@ear@path} + } + \endgroup +} + +%snub cube + +\def\tikzfoldingsnubcube#1[#2]#3;{% + \begingroup% + \tikzset{#2}% + \tikz@lib@fold@square{\tikz@lib@fold@face@A} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@B} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@C} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@D} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + { + \tikz@lib@fold@square{\tikz@lib@fold@face@E} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@F} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@G} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@H} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@I} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@J} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@K} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@L} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@M} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + { + \tikz@lib@fold@square{\tikz@lib@fold@face@N} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@O} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@P} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@Q} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@R} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@S} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@T} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@U} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@V} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + { + \tikz@lib@fold@square{\tikz@lib@fold@face@W} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@X} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@Y} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@Z} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AA} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AB} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AC} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AD} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AE} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + { + \tikz@lib@fold@square{\tikz@lib@fold@face@AF} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AG} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AH} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AI} + { + \tikz@lib@fold@square{\tikz@lib@fold@face@AJ} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AK} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AL} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} } \endgroup } - +% icosidodecahedron + +\def\tikzfoldingicosidodecahedron#1[#2]#3;{% + \begingroup% + \tikzset{#2}% + \tikz@lib@fold@pentagon{\tikz@lib@fold@face@A} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@B} + { + \tikz@lib@fold@pentagon{\tikz@lib@fold@face@C} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@D} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@ear@custom@right@path{24}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@E} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@F} + { + \tikz@lib@fold@pentagon{\tikz@lib@fold@face@G} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@custom@right@path{24}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@H} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + { + \tikz@lib@fold@pentagon{\tikz@lib@fold@face@I} + {\tikz@lib@fold@ear@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@J} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@K} + {\tikz@lib@fold@ear@custom@right@path{24}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@L} + { + \tikz@lib@fold@pentagon{\tikz@lib@fold@face@M} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@N} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + { + \tikz@lib@fold@pentagon{\tikz@lib@fold@face@O} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@P} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + } + {\tikz@lib@fold@ear@custom@right@path{24}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@Q} + {\tikz@lib@fold@ear@custom@right@path{24}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + {\tikz@lib@fold@path} + { + \tikz@lib@fold@pentagon{\tikz@lib@fold@face@R} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@S} + { + \tikz@lib@fold@pentagon{\tikz@lib@fold@face@T} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@custom@right@path{24}} + {\tikz@lib@fold@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@U} + { + \tikz@lib@fold@pentagon{\tikz@lib@fold@face@V} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@custom@right@path{24}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@ear@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@W} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@X} + {\tikz@lib@fold@ear@custom@right@path{24}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@Y} + { + \tikz@lib@fold@pentagon{\tikz@lib@fold@face@Z} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@ear@custom@right@path{24}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + } + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AA} + { + \tikz@lib@fold@pentagon{\tikz@lib@fold@face@AB} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AC} + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + { + \tikz@lib@fold@pentagon{\tikz@lib@fold@face@AD} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AE} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + {\tikz@lib@fold@ear@path} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + {\tikz@lib@fold@cut@path} + } + } + {\tikz@lib@fold@ear@custom@right@path{24}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + { + \tikz@lib@fold@triangle{\tikz@lib@fold@face@AF} + {\tikz@lib@fold@ear@custom@right@path{24}} + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + } + {\tikz@lib@fold@path} + {\tikz@lib@fold@cut@path} + } + \endgroup +} diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryintersections.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryintersections.code.tex index dd842033fc8..e35633fc20d 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryintersections.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryintersections.code.tex @@ -9,23 +9,30 @@ \usepgflibrary{intersections} -\let\tikz@intersect@def=\def - \pgfkeys{% /tikz/name path global/.code={% - % it might have been more efficient to eliminate the storage macro - % \tikz@intersect@namedpaths. But I keep it maintain compatibility - % with mixed occurances of local/global names. - \let\tikz@intersect@def=\gdef - \pgfkeys{/tikz/name path={#1}}% + % reset any "old" variables inheritted from some other path + % - we do not accidentally want to append to an old path with the + % same name (or if someone provided the option twice)... + \expandafter\global\expandafter\let\csname tikz@intersect@path@name@#1\endcsname=\relax + \tikz@key@name@path{#1}{\gdef}% }, /tikz/name path local/.code={% - \let\tikz@intersect@def=\def \pgfkeys{/tikz/name path={#1}}% }, /tikz/name path/.code={% + % hm. Do we need this "reset old option" as in 'name path global' + % for this case as well? + \tikz@key@name@path{#1}{\def}% + }, +} + +% #1: the name to assign. +% #2: one of '\def' or '\gdef'. +\def\tikz@key@name@path#1#2{% \tikz@addmode{% - \pgfsyssoftpath@getcurrentpath\tikz@intersect@temppath% + \pgfsyssoftpath@getcurrentpath\tikz@intersect@temppath@round% + \pgfprocessround\tikz@intersect@temppath@round\tikz@intersect@temppath% \ifx\tikz@intersect@namedpaths\pgfutil@empty% \else% \tikz@intersect@namedpaths% @@ -37,28 +44,16 @@ \expandafter\expandafter\expandafter{\expandafter\tikz@intersect@temppath\tikz@intersect@temppath}% }% \fi% - \tikz@intersect@addto@path@names{#1}% + \tikz@intersect@addto@path@names{#1}{#2}% }% - } -} +}% -\def\tikz@intersect@addto@path@names#1{% - % FIXME : I have the impression that something is not correct - % here... the \tikz@intersect@def is not used correctly! - % if I am not mistaken, the \tikz@intersect@def will NOT be - % invoked until \tikz@intersect@namedpaths. CHECK IT - % It seems it works, but only partially. - \def\tikz@marshal{\expandafter\tikz@intersect@def\csname tikz@intersect@path@name@#1\endcsname}% +% #1: the name to assign. +% #2: one of '\def' or '\gdef'. +\def\tikz@intersect@addto@path@names#1#2{% + \edef\tikz@marshal{#2\expandafter\noexpand\csname tikz@intersect@path@name@#1\endcsname}% \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@marshal% \expandafter\expandafter\expandafter{\expandafter\tikz@marshal\expandafter{\tikz@intersect@temppath}}% - \ifx\tikz@intersect@def\gdef - % This here is to *ensure* that the \gdef is invoked. - % - % I think this solves the problem. - % - % Please revise this routine such that it works better. - \tikz@marshal - \fi \expandafter\pgfutil@g@addto@macro\expandafter\tikz@intersect@namedpaths\expandafter{\tikz@marshal}% } @@ -89,9 +84,9 @@ by=, #1}% \pgfutil@ifundefined{tikz@intersect@path@name@\tikz@intersect@path@a}{% - \PackageError{tikz}{I do not know the path named `\tikz@intersect@path@a'. Perhaps you misspelt it}{}}% + \tikzerror{I do not know the path named `\tikz@intersect@path@a'. Perhaps you misspelt it}}% {\pgfutil@ifundefined{tikz@intersect@path@name@\tikz@intersect@path@b}{% - \PackageError{tikz}{I do not know the path named `\tikz@intersect@path@b'. Perhaps you misspelt it}{}}% + \tikzerror{I do not know the path named `\tikz@intersect@path@b'. Perhaps you misspelt it}}% {% \pgfintersectionofpaths% {% diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymath.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymath.code.tex new file mode 100644 index 00000000000..8ccdc64493a --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymath.code.tex @@ -0,0 +1,725 @@ +% Copyright 2013 by Mark Wibrow +% +% 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. + + + +\edef\tikz@math@at@catcode{\the\catcode`\@} +\catcode`\@=11 + +\def\tikz@math@gobblespaces#1{\pgfutil@ifnextchar x{#1}{#1}} + +\def\tikz@math@meaning@macro{macro} +\def\tikz@math@meaning@dimen{dimen} +\def\tikz@math@meaning@count{count} +\def\tikz@math@meaning@null{null} + +\def\tikz@math@getmeaning#1{\expandafter\tikz@math@@getmeaning\meaning#1\tikz@math@getmeaning@stop} + +\def\tikz@math@@getmeaning#1#2#3#4#5\tikz@math@getmeaning@stop{% + \if#1u% undefined + \let\tikz@math@meaning=\tikz@math@meaning@macro% + \else% + \if#1m% + \let\tikz@math@meaning=\tikz@math@meaning@macro% + \else% + \if#2d% + \let\tikz@math@meaning=\tikz@math@meaning@dimen% + \else% + \if#2c% + \let\tikz@math@meaning=\tikz@math@meaning@count% + \else% + \if#3k% A skip. Treat like a dimen. + \let\tikz@math@meaning=\tikz@math@meaning@dimen% + \else% + \let\tikz@math@meaning=\tikz@math@meaning@null% + \fi% + \fi% + \fi% + \fi% + \fi% +} + +\def\tikz@math@firstoftwo#1#2{#1} +\def\tikz@math@secondoftwo#1#2{#2} + + +\def\tikz@math@getvarstring#1{% + \begingroup% + \escapechar=-1\relax% + \expandafter\tikz@math@@getvarstring\string#1\tikz@math} + +\def\tikz@math@@getvarstring#1\tikz@math#2{% + \endgroup% + \def#2{#1}% +} + +\long\def\tikz@math@collecttosemicolon@other#1#2;{% + \def\tikz@math@collected{#2}#1} +\def\tikz@math@semicolon@other{;}% + +{\catcode`\;=13 +\long\gdef\tikz@math@collecttosemicolon@active#1#2;{% + \def\tikz@math@collected{#2}#1} +\gdef\tikz@math@semicolon@active{;}% +} + + +\def\tikz@math@setvartype#1#2{% + \expandafter\let\csname tikz@math@var@vartype@\string#1\endcsname=#2% +} + + +\def\tikz@math@getvartype#1#2{% + \def\tikz@math@marshal{\let#1=}% + \expandafter\tikz@math@marshal\csname + tikz@math@var@vartype@\string#2\endcsname% +} + + + +\def\tikz@math@ifvarcoordinate#1{% + \expandafter\ifx\csname + tikz@math@var@vartype@\string#1\endcsname\tikz@math@keyword@coordinate% + \let\tikz@math@next=\tikz@math@firstoftwo% + \else% + \let\tikz@math@next=\tikz@math@secondoftwo% + \fi% + \tikz@math@next% +} + +\def\tikz@math@ifvarinteger#1{% + \expandafter\ifx\csname + tikz@math@var@vartype@\string#1\endcsname\tikz@math@keyword@integer% + \let\tikz@math@next=\tikz@math@firstoftwo% + \else% + \let\tikz@math@next=\tikz@math@secondoftwo% + \fi% + \tikz@math@next% +} + + +\def\tikz@math@setvarindexed#1{% + \expandafter\let\csname + tikz@math@var@subtype@\string#1\endcsname=\tikz@math@subtype@indexed% +} + +\def\tikz@math@clearvarindexed#1{% + \expandafter\let\csname tikz@math@var@subtype@\string#1\endcsname=\relax% +} + +\def\tikz@math@ifvarindexed#1{% + \expandafter\ifx\csname tikz@math@var@subtype@\string#1\endcsname\relax% + \let\tikz@math@next=\tikz@math@secondoftwo% + \else% + \let\tikz@math@next=\tikz@math@firstoftwo% + \fi% + \tikz@math@next% +} + +\def\tikz@math@stop{@} + +\let\tikz@math@parse@hook@before=\pgfutil@empty +\let\tikz@math@parse@hook@after=\pgfutil@empty + +\def\tikz@math{% + \ifnum\catcode`\;=13\relax% + \let\tikz@math@semicolon=\tikz@math@semicolon@active% + \let\tikz@math@collecttosemicolon=\tikz@math@collecttosemicolon@active% + \else% + \let\tikz@math@semicolon=\tikz@math@semicolon@other% + \let\tikz@math@collecttosemicolon=\tikz@math@collecttosemicolon@other% + \fi% + \tikz@math@parse@hook@before% + \tikz@@math} + + + + +\long\def\tikz@@math#1{% + \def\tikz@math@marshal{\tikz@math@parse#1}% + \expandafter\expandafter\expandafter\tikz@math@marshal\expandafter\tikz@math@stop\tikz@math@semicolon} + +\def\tikz@math@parse{\pgfutil@ifnextchar\bgroup\tikz@math@@parse@bgroup\tikz@math@@parse@nobgroup} + + +\def\tikz@math@@parse@bgroup{% + \tikz@math@collecttosemicolon{% + % MW: Don't know how reliable this test is. + \ifx\pgf@selectfontorig\tikz@math@undefined% + \begingroup\tikz@math@collected\endgroup% + \else% + \begingroup\csname nullfont\endcsname\tikz@math@collected\endgroup% + \fi\tikz@math@parse}} + + + +\def\tikz@math@@parse@nobgroup{\tikz@math@collecttosemicolon{\tikz@math@@parse@@nobgroup}} + +\def\tikz@math@@parse@@nobgroup{% + \let\tikz@math@tmp=\tikz@math@collected% + \ifx\tikz@math@tmp\tikz@math@stop% + \def\tikz@math@next{\expandafter\tikz@math@parse@finish\tikz@math@semicolon}% + \else% + \def\tikz@math@next{\expandafter\expandafter\expandafter\tikz@math@parse@keyword@check\expandafter\tikz@math@tmp\tikz@math@semicolon}% + \fi% + \tikz@math@next% +} + +\def\tikz@math@parse@finish{% + \tikz@math@collecttosemicolon{\tikz@math@parse@hook@after}% +} + + + +\newif\iftikz@math@let +\def\tikz@math@parse@keyword@check#1{% + \tikz@math@letfalse% + \tikz@math@getmeaning{#1}% + \ifx\tikz@math@meaning\tikz@math@meaning@null% + \let\tikz@math@next=\tikz@math@parse@keyword% + \else% + \let\tikz@math@next=\tikz@math@parse@nokeyword% + \fi% + \tikz@math@next#1} + + +\def\tikz@math@parse@keyword{% + \let\tikz@math@parsed@keyword=\pgfutil@empty% + \futurelet\tikz@math@parse@token\tikz@math@@parse@keyword} + +\def\tikz@math@@parse@keyword{% + \ifx\tikz@math@parse@token\pgfutil@sptoken% + \let\tikz@math@next=\tikz@math@@@parse@keyword% + \else% + \ifx\tikz@math@parse@token(% + \let\tikz@math@next=\tikz@math@@@parse@keyword% + \else% + \ifx\tikz@math@parse@token\bgroup% + \let\tikz@math@next=\tikz@math@@@parse@keyword% + \else% + \let\tikz@math@next=\tikz@math@@@@parse@keyword% + \fi% + \fi% + \fi% + \tikz@math@next} + +\def\tikz@math@error#1{\pgfutil@packageerror{tikz}{tikz math library: #1}{}} + +\def\tikz@math@@@parse@keyword{% + \expandafter\ifx\csname tikz@math@process@keyword@\tikz@math@parsed@keyword\endcsname\relax% + \expandafter\ifx\csname pgfmath\tikz@math@parsed@keyword\endcsname\relax% + \tikz@math@error{Unknown function or keyword '\tikz@math@parsed@keyword'}% + \else% + \def\tikz@math@next{\tikz@math@collecttosemicolon{\tikz@math@function@noassign}}% + \fi% + \else% + \expandafter\def\expandafter\tikz@math@next\expandafter{\csname tikz@math@process@keyword@\tikz@math@parsed@keyword\endcsname}% + \fi% + \tikz@math@next} + +\def\tikz@math@@@@parse@keyword#1{% + \edef\tikz@math@parsed@keyword{\tikz@math@parsed@keyword#1}% + \futurelet\tikz@math@parse@token\tikz@math@@parse@keyword% +} + +\def\tikz@math@function@noassign{% + \pgfmathparse{\tikz@math@parsed@keyword\tikz@math@collected}% + \tikz@math@parse% +} + + + + +\def\tikz@math@process@keyword@count{\tikz@math@collecttosemicolon{\tikz@math@process@keyword@@count}} +\def\tikz@math@process@keyword@@count{% +\def\tikz@math@assign@register{\csname newcount\endcsname}% +\expandafter\tikz@math@gobblespaces\expandafter\tikz@math@process@registers\tikz@math@collected,@,} + +\def\tikz@math@process@keyword@length{\tikz@math@collecttosemicolon{\tikz@math@process@keyword@@length}} +\def\tikz@math@process@keyword@@length{% +\def\tikz@math@assign@register{\csname newdimen\endcsname}% +\show\tikz@math@collected +\expandafter\tikz@math@gobblespaces\expandafter\tikz@math@process@registers\tikz@math@collected,@,} + + +\def\tikz@math@process@registers#1#2,{% + \def\tikz@math@var{#1}% + \ifx\tikz@math@var\tikz@math@stop% + \let\tikz@math@next=\tikz@math@parse% + \else% + \tikz@math@assign@register#1\relax% + \let\tikz@math@next=\tikz@math@process@registers% + \fi% + \tikz@math@gobblespaces\tikz@math@next% +} + + +\def\tikz@math@process@keyword@if#1then{% + \def\tikz@math@if@condition{#1}% + \tikz@math@gobblespaces\tikz@math@parse@if@iftrue% +} +\def\tikz@math@parse@if@iftrue#1{% + \def\tikz@math@if@trueaction{#1}% + \pgfutil@ifnextchar e{\tikz@math@parse@else}{\tikz@math@if@doif}} + +\def\tikz@math@parse@else else{\tikz@math@gobblespaces\tikz@math@if@doifelse} + +\def\tikz@math@if@doif{\tikz@math@collecttosemicolon{\tikz@math@if@@doif}} + +\def\tikz@math@if@@doif{% + \pgfmathparse{\tikz@math@if@condition}% + \ifdim\pgfmathresult pt=0pt\relax% + \else% + \expandafter\tikz@math\expandafter{\tikz@math@if@trueaction}% + \fi% + \tikz@math@parse% +} +\def\tikz@math@if@doifelse{\tikz@math@collecttosemicolon{\tikz@math@if@@doifelse}} +\def\tikz@math@if@@doifelse{% + \pgfmathparse{\tikz@math@if@condition}% + \let\tikz@math@if@falseaction=\tikz@math@collected% + \ifdim\pgfmathresult pt=0pt\relax% + \expandafter\tikz@math\expandafter{\tikz@math@if@falseaction}% + \else% + \expandafter\tikz@math\expandafter{\tikz@math@if@trueaction}% + \fi% + \tikz@math@parse% +} +\def\tikz@math@process@keyword@let{% + \tikz@math@lettrue% + \tikz@math@gobblespaces\tikz@math@parse@nokeyword% +} + + +\def\tikz@math@parse@nokeyword#1{% + \def\tikz@math@var{#1}% + \tikz@math@getvarstring{#1}\tikz@math@varstring% + \let\tikz@math@vartype=\pgfutil@empty% + \ifx\tikz@math@var\tikz@math@stop% + \let\tikz@math@next=\tikz@math@parse@finish% + \else% + \ifx\tikz@math@semicolon\tikz@math@var% + \let\tikz@math@next=\tikz@math@parse% + \else% + \let\tikz@math@next=\tikz@math@parse@index@check% + \fi% + \fi% + \tikz@math@next} + +\def\tikz@math@parse@index@check{% + \pgfutil@ifnextchar={\tikz@math@parse@noindex}{\tikz@math@parse@index}} + +\def\tikz@math@parse@noindex{% + \expandafter\tikz@math@clearvarindexed\tikz@math@var% + \let\tikz@math@current@index=\pgfutil@empty% + \tikz@math@parse@afterindex% +} + +\def\tikz@math@parse@index#1{% + \def\tikz@math@tmp{#1}% + \expandafter\tikz@math@setvarindexed\tikz@math@var% {} + \edef\tikz@math@current@index{#1}% + \tikz@math@parse@afterindex% +} +\def\tikz@math@parse@afterindex#1={\tikz@math@gobblespaces\tikz@math@parse@assignment}% + +\def\tikz@math@parse@assignment{\tikz@math@collecttosemicolon{\tikz@math@parse@@assignment}} +\def\tikz@math@parse@@assignment{% + \expandafter\expandafter\expandafter\tikz@math@doassignment\expandafter\expandafter\expandafter% + {\expandafter\tikz@math@var\expandafter}\expandafter{\tikz@math@collected}% + \tikz@math@parse% +} + +\def\tikz@math@dollar@char{$} +\def\tikz@math@dollar@char{$}% For annoying syntax highlighters + +\def\tikz@math@doassignment#1#2{% + \tikz@math@ifvarcoordinate{#1}{% + \def\tikz@math@var{#1}% Unfortunately, we must do this again. + \tikz@math@getvarstring{#1}\tikz@math@varstring% And this + \expandafter\pgfutil@in@\tikz@math@dollar@char{#2}% + \edef\tikz@math@expression{#2}% + \ifpgfutil@in@% + \expandafter\tikz@scan@one@point\expandafter\tikz@math@assign@coordinate\tikz@math@expression% + \else% + \expandafter\ifx\csname tikz@library@calc@loaded\endcsname\relax% + \expandafter\tikz@scan@one@point\expandafter\tikz@math@assign@coordinate\tikz@math@expression% + \else% + \expandafter\tikz@scan@one@point\expandafter\tikz@math@assign@coordinate\expandafter% + (\expandafter$\tikz@math@expression$)% + \fi% + \fi% + }{% + \iftikz@math@let% Not really a let + \ifx\tikz@math@current@index\pgfutil@empty% + \edef#1{#2}% + \else% + \edef\tikz@math@tmp{#2}% + \expandafter\expandafter\expandafter\tikz@math@assign@index\expandafter\expandafter\expandafter% + {\expandafter\tikz@math@varstring\expandafter}\expandafter{\tikz@math@tmp}% + \fi% + \tikz@math@letfalse% + \else% + \ifx\tikz@math@current@index\pgfutil@empty% + \tikz@math@getmeaning{#1}% + \ifx\tikz@math@meaning\tikz@math@meaning@dimen% + \pgfmathsetlength{#1}{#2}% + \let\tikz@math@last@assigned@value=\pgfmathresult% + \else% + \ifx\tikz@math@meaning\tikz@math@meaning@count% + \pgfmathsetcount{#1}{#2}% + \let\tikz@math@last@assigned@value=\pgfmathresult% + \else% + \tikz@math@ifvarinteger{#1}{\pgfmathparse{int(#2)}}{\pgfmathparse{#2}}% + \let\tikz@math@last@assigned@value=\pgfmathresult% + \let#1=\pgfmathresult% + \fi% + \fi% + \else% + \tikz@math@ifvarinteger{#1}{\pgfmathparse{int(#2)}}{\pgfmathparse{#2}}% + \expandafter\tikz@math@assign@index\expandafter{\tikz@math@varstring}\pgfmathresult% + \let\tikz@math@last@assigned@value=\pgfmathresult% + \fi% + \fi% + }% +} + + + +\def\tikz@math@assign@index#1#2{% + \expandafter\def\csname#1\endcsname##1{\csname + tikz@math@var@indexed@#1@##1\endcsname}% + \expandafter\edef\csname + tikz@math@var@indexed@#1@\tikz@math@current@index\endcsname{#2}\relax% +} + + + +\def\tikz@math@assign@coordinate#1{% + \pgf@process{#1}% + \ifx\tikz@math@current@index\pgfutil@empty% + \expandafter\edef\csname\tikz@math@varstring\endcsname{\the\pgf@x,\the\pgf@y}% + \expandafter\edef\csname\tikz@math@varstring x\endcsname{\the\pgf@x}% + \expandafter\edef\csname\tikz@math@varstring y\endcsname{\the\pgf@y}% + \else% + \expandafter\tikz@math@assign@index\expandafter{\tikz@math@varstring}{\the\pgf@x,\the\pgf@y}% + \expandafter\tikz@math@assign@index\expandafter{\tikz@math@varstring x}{\the\pgf@x}% + \expandafter\tikz@math@assign@index\expandafter{\tikz@math@varstring y}{\the\pgf@y}% + \fi% +} + + + +\def\tikz@math@keyword@coordinate{coordinate} +\def\tikz@math@process@keyword@coordinate{% + \let\tikz@math@vartype=\tikz@math@keyword@coordinate% + \tikz@math@gobblespaces\tikz@math@process@vartypes% +} + +\def\tikz@math@keyword@integer{integer} +\def\tikz@math@process@keyword@integer{% + \let\tikz@math@vartype=\tikz@math@keyword@integer% + \tikz@math@gobblespaces\tikz@math@process@vartypes% +} +\def\tikz@math@process@keyword@int{% + \tikz@math@process@keyword@integer% +} + +\def\tikz@math@keyword@real{real} +\def\tikz@math@process@keyword@real{% + \let\tikz@math@vartype=\tikz@math@keyword@real% + \tikz@math@gobblespaces\tikz@math@process@vartypes% +} + +\def\tikz@math@process@keyword@point{\tikz@math@process@keyword@coordinate} + + +\def\tikz@math@process@vartypes{\tikz@math@collecttosemicolon{\tikz@math@process@@vartypes}} + +\def\tikz@math@process@@vartypes{% + \expandafter\tikz@math@@process@vartypes\tikz@math@collected,@,\tikz@math% +} + +\def\tikz@math@@process@vartypes#1#2,{% + \def\tikz@math@var{#1}% + \tikz@math@getvarstring{#1}\tikz@math@varstring% + \ifx\tikz@math@var\tikz@math@stop% + \let\tikz@math@next=\tikz@math@@@process@vartypes% + \else% + \expandafter\tikz@math@setvartype\tikz@math@var\tikz@math@vartype% + \def\tikz@math@next{\tikz@math@gobblespaces\tikz@math@@process@vartypes}% + \fi% + \tikz@math@next% +} + +\def\tikz@math@process@keyword@print{\tikz@math@collecttosemicolon{\tikz@math@process@keyword@@print}} +\def\tikz@math@process@keyword@@print{% + \begingroup\tikz@math@collected\endgroup\tikz@math@parse% +} + +\def\tikz@math@@@process@vartypes#1\tikz@math{% + \tikz@math@parse% +} + +\newcount\tikz@math@for@depth + +\def\tikz@math@for@namedef#1{\expandafter\def\csname tikz@math@for@def@#1@\the\tikz@math@for@depth\endcsname} +\def\tikz@math@for@nameedef#1{\expandafter\edef\csname tikz@math@for@def@#1@\the\tikz@math@for@depth\endcsname} +\def\tikz@math@for@namelet#1{\expandafter\let\csname tikz@math@for@def@#1@\the\tikz@math@for@depth\endcsname} + +\def\tikz@math@for@namegetvalue#1#2{% + \def\tikz@math@marshal{\let#2=}% + \expandafter\tikz@math@marshal\csname tikz@math@for@def@#1@\the\tikz@math@for@depth\endcsname} + +\def\tikz@math@process@keyword@for{% + \tikz@math@for% +} + +\def\tikz@math@for@external{% + \ifnum\catcode`\;=13\relax% + \let\tikz@math@semicolon=\tikz@math@semicolon@active% + \let\tikz@math@collecttosemicolon=\tikz@math@collecttosemicolon@active% + \else% + \let\tikz@math@semicolon=\tikz@math@semicolon@other% + \let\tikz@math@collecttosemicolon=\tikz@math@collecttosemicolon@other% + \fi + \advance\tikz@math@for@depth by1\relax% + \tikz@math@for@namedef{execute}{\tikz@math@for@external@execute}% + \tikz@math@for@namedef{finished}{\relax}% + \tikz@math@gobblespaces\tikz@math@for@parsevar} + +\def\tikz@math@for@external@execute#1{#1} + +\def\tikz@math@for{% + \advance\tikz@math@for@depth by1\relax% + \tikz@math@for@namedef{execute}{\tikz@math}% + \tikz@math@for@namedef{finished}{\tikz@math@parse}% + \tikz@math@gobblespaces\tikz@math@for@parsevar} + + +\def\tikz@math@for@parsevar#1{% + \tikz@math@for@namedef{var}{#1}% + \tikz@math@for@parsein} + +\def\tikz@math@getindex#1{% + \tikz@math@@getindex#1\tikz@math@getindex\tikz@math@@getindex% +} + +\def\tikz@math@@getindex#1#2\tikz@math@@getindex{#1} + +\def\tikz@math@for@parsein#1in{% + \def\tikz@math@tmp{#1}% + \ifx\tikz@math@tmp\pgfutil@empty% + \tikz@math@for@namedef{index}{}% + \else% + \tikz@math@for@nameedef{index}{\tikz@math@getindex{#1}}% + \fi% + \tikz@math@gobblespaces\tikz@math@for@parselist% +} + + +\long\def\tikz@math@for@parselist#1{% + \edef\tikz@math@for@list{#1}% + \tikz@math@collecttosemicolon{\tikz@math@for@parseaction}} + +\def\tikz@math@for@parseaction{% + \tikz@math@for@namedef{prevvalue}{}% + \tikz@math@for@namedef{prevprevvalue}{}% + \tikz@math@for@namelet{action}=\tikz@math@collected% + \expandafter\tikz@math@for@scan\tikz@math@for@list,\tikz@math,\tikz@@math% +} + +\def\tikz@math@token{\tikz@math} + + +\def\tikz@math@for@scan#1,{% + \def\tikz@math@for@value{#1}% + \ifx\tikz@math@for@value\tikz@math@token% + \let\tikz@math@next=\tikz@math@for@scan@end% + \else% + \ifx\tikz@math@for@value\pgfutil@empty% + \let\tikz@math@next=\tikz@math@for@scan@end% + \else% + \pgfutil@in@{...}{#1}% + \ifpgfutil@in@% + \let\tikz@math@next=\tikz@math@for@scan@dots% + \else% + \tikz@math@for@namegetvalue{var}{\tikz@math@var}% + \tikz@math@for@namegetvalue{index}{\tikz@math@current@index}% + \tikz@math@for@namegetvalue{action}{\tikz@math@action}% + \expandafter\tikz@math@getvarstring\expandafter{\tikz@math@var}\tikz@math@varstring% + \expandafter\tikz@math@doassignment\expandafter{\tikz@math@var}{#1}% + \tikz@math@for@namelet{value}=\tikz@math@last@assigned@value% + \tikz@math@for@namegetvalue{execute}{\tikz@math@execute}% + \expandafter\tikz@math@execute\expandafter{\tikz@math@action}% + \tikz@math@for@namegetvalue{prevvalue}{\tikz@math@prevvalue}% + \tikz@math@for@namelet{prevprevvalue}=\tikz@math@prevvalue% + \tikz@math@for@namegetvalue{value}{\tikz@math@value}% + \tikz@math@for@namelet{prevvalue}=\tikz@math@value% + \let\tikz@math@next=\tikz@math@for@scan% + \fi% + \fi% + \fi% + \tikz@math@next% +} + +\newdimen\tikz@math@dimen + +\def\tikz@math@for@scan@dots#1,{% + \pgfmathparse{#1}\let\tikz@math@value=\pgfmathresult% + \tikz@math@for@nameedef{endvalue}{\tikz@math@value}% + \tikz@math@for@namegetvalue{prevvalue}{\tikz@math@prevvalue}% + \tikz@math@for@namegetvalue{prevprevvalue}{\tikz@math@prevprevvalue}% + \tikz@math@dimen=\tikz@math@prevvalue pt\relax% + \ifx\tikz@math@prevprevvalue\pgfutil@empty% + \ifdim\tikz@math@prevvalue pt<\tikz@math@value pt\relax%% + \def\tikz@math@step{1pt}% + \else% + \def\tikz@math@step{-1pt}% + \fi% + \else% + \tikz@math@dimen=\tikz@math@prevvalue pt\relax% + \advance\tikz@math@dimen by-\tikz@math@prevprevvalue pt\relax% + \edef\tikz@math@step{\the\tikz@math@dimen}% + \fi% + \ifdim\tikz@math@step<0pt\relax% + \tikz@math@for@namedef{comparitor}{<}% + \else% + \tikz@math@for@namedef{comparitor}{>}% + \fi% + \tikz@math@for@nameedef{step}{\tikz@math@step}% + \tikz@math@for@doloop% +} + +\def\tikz@math@for@doloop{% + \tikz@math@for@namegetvalue{prevvalue}{\tikz@math@prevvalue}% + \tikz@math@for@namegetvalue{step}{\tikz@math@step}% + \tikz@math@for@namegetvalue{comparitor}{\tikz@math@comparitor}% + \tikz@math@for@namegetvalue{endvalue}{\tikz@math@endvalue}% + \tikz@math@dimen=\tikz@math@prevvalue pt\relax% + \advance\tikz@math@dimen by\tikz@math@step\relax% + \ifdim\tikz@math@dimen\tikz@math@comparitor\tikz@math@endvalue pt\relax% + \let\tikz@math@next=\tikz@math@for@endloop% + \else% + \tikz@math@for@nameedef{value}{\pgfmath@tonumber{\tikz@math@dimen}}% + \tikz@math@for@namegetvalue{var}{\tikz@math@var}% + \expandafter\tikz@math@getvarstring\expandafter{\tikz@math@var}\tikz@math@varstring% + \tikz@math@for@namegetvalue{index}{\tikz@math@current@index}% + \tikz@math@for@namegetvalue{action}{\tikz@math@action}% + \tikz@math@for@namegetvalue{value}{\tikz@math@value}% + \expandafter\expandafter\expandafter\tikz@math@doassignment\expandafter\expandafter\expandafter% + {\expandafter\tikz@math@var\expandafter}\expandafter{\tikz@math@value}% + \tikz@math@for@namegetvalue{execute}{\tikz@math@execute}% + \expandafter\tikz@math@execute\expandafter{\tikz@math@action}% + \tikz@math@for@namegetvalue{prevvalue}{\tikz@math@prevvalue}% + \tikz@math@for@namelet{prevprevvalue}=\tikz@math@prevvalue% + \tikz@math@for@namegetvalue{value}{\tikz@math@value}% + \tikz@math@for@namelet{prevvalue}=\tikz@math@value% + \let\tikz@math@next=\tikz@math@for@doloop% + \fi% + \tikz@math@next% +} + +\def\tikz@math@for@endloop{% +\tikz@math@for@scan} + + + + +\def\tikz@math@for@scan@end#1\tikz@@math{% +\tikz@math@for@namegetvalue{finished}{\tikz@math@next}% +\advance\tikz@math@for@depth by-1\relax% +\tikz@math@next} + + + + + +\def\tikz@math@process@keyword@return{% + \tikz@math@collecttosemicolon{\pgfmathparse{\tikz@math@collected}\tikz@math@parse}} + +\def\tikz@math@process@keyword@function{\tikz@math@collecttosemicolon{\tikz@math@process@keyword@@function}} +\def\tikz@math@process@keyword@@function{% + \let\tikz@math@function@name=\pgfutil@empty% + \let\tikz@math@function@arguments=\pgfutil@empty% + \let\tikz@math@function@body=\pgfutil@empty% + \expandafter\expandafter\expandafter\tikz@math@@declarefunction\expandafter\tikz@math@collected\tikz@math@semicolon% +} + +\def\tikz@math@@declarefunction{% + \pgfutil@ifnextchar\bgroup\tikz@math@@@collectbody\tikz@math@@@declarefunction} + + +\def\tikz@math@@@declarefunction#1{% + \if#1(%) + \let\tikz@math@next=\tikz@math@@@collectarguments% + \else% + \expandafter\def\expandafter\tikz@math@function@name\expandafter{\tikz@math@function@name#1}% + \let\tikz@math@next=\tikz@math@@declarefunction% + \fi% + \tikz@math@next% +} +\def\tikz@math@@@collectarguments#1){% + \def\tikz@math@function@arguments{#1}% + \tikz@math@@declarefunction% +} + +\newtoks\tikz@math@toks +\tikz@math@toks={#} +\edef\tikz@math@char@hash{\the\tikz@math@toks} +\tikz@math@toks={} + +\def\tikz@math@@@collectbody{\tikz@math@collecttosemicolon{\tikz@math@@@@collectbody}} + +\def\tikz@math@@@@collectbody{% + \tikz@math@toks={}% + \c@pgf@counta=0\relax% + \ifx\tikz@math@function@arguments\pgfutil@empty% + \else% + \expandafter\tikz@math@createargumentlist\tikz@math@function@arguments,,% + \expandafter\tikz@math@addto@toks\expandafter{\tikz@math@collected}% + \fi% + \edef\tikz@math@local@temp{% + \noexpand\pgfmathdeclarefunction{\tikz@math@function@name}{\the\c@pgf@counta}% + {\noexpand\def\noexpand\return{0}\noexpand\tikz@math{\the\tikz@math@toks}}% + }% + \tikz@math@local@temp + \tikz@math@parse% +} + +\def\tikz@math@addto@toks#1{% + \expandafter\tikz@math@toks\expandafter{\the\tikz@math@toks#1}} + +\def\tikz@math@createargumentlist{% + \pgfutil@ifnextchar + x\tikz@math@@createargumentlist\tikz@math@@createargumentlist} + +\def\tikz@math@comma{,} +\def\tikz@math@@createargumentlist#1,{% + \def\tikz@math@tmp{#1}% + \ifx\tikz@math@tmp\pgfutil@empty% + \let\tikz@math@next=\relax% + \else% + \advance\c@pgf@counta by1\relax% + \tikz@math@addto@toks{#1=}% + \expandafter\expandafter\expandafter\tikz@math@addto@toks\expandafter\expandafter\expandafter% + {\expandafter\tikz@math@char@hash\the\c@pgf@counta;}% + \let\tikz@math@next=\tikz@math@createargumentlist% + \fi% + \tikz@math@next% +} + + + +\let\tikzmath=\tikz@math +\tikzset{evaluate/.code={\tikz@math{#1}}} +\let\tikzmathfor=\tikz@math@for@external + + +\catcode`\@=\tikz@math@at@catcode\relax diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymatrix.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymatrix.code.tex index f1f03c457dd..eb2d65a33fc 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymatrix.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymatrix.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymatrix.code.tex,v 1.2 2008/06/18 23:34:49 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymatrix.code.tex,v 1.4 2013/07/12 22:01:58 tantau Exp $ % A matrix of nodes contains a node in each cell. @@ -15,30 +15,29 @@ \tikzstyle{matrix of nodes}=[% matrix,% cells={anchor=base},% - nodes={% - execute at begin node=,% - execute at end node=, - name=\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn% - }, execute at begin cell=\tikz@lib@matrix@start@cell,% execute at end cell=\tikz@lib@matrix@end@cell,% - execute at empty cell=\tikz@lib@matrix@empty@cell + execute at empty cell=\tikz@lib@matrix@empty@cell, + execute at begin matrix=\iftikz@handle@active@code\tikz@orig@shorthands\fi,% ] -\def\tikz@lib@matrix@empty@cell{\iftikz@lib@matrix@empty\node{};\fi} +\def\tikz@lib@matrix@empty@cell{\iftikz@lib@matrix@empty\node[name=\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn]{};\fi} \newif\iftikz@lib@matrix@plain \def\tikz@lib@matrix@start@cell{% \pgfutil@ifnextchar|{\tikz@lib@matrix@with@options}{\tikz@lib@matrix@normal@start@cell}} -\def\tikz@lib@matrix@with@options|#1|{\tikz@lib@matrix@plainfalse\node#1\bgroup\tikz@lib@matrix@startup} +\def\tikz@lib@matrix@with@options|#1|{\tikz@lib@matrix@plainfalse\node% + [name=\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn]#1\bgroup\tikz@lib@matrix@startup} -\def\tikz@lib@matrix@normal@start@cell{\pgfutil@ifnextchar\let{\tikz@lib@matrix@check}{\tikz@lib@matrix@plainfalse\node\bgroup\tikz@lib@matrix@startup}}% +\def\tikz@lib@matrix@normal@start@cell{\pgfutil@ifnextchar\let{\tikz@lib@matrix@check}{\tikz@lib@matrix@plainfalse\node + [name=\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn]\bgroup\tikz@lib@matrix@startup}}% \def\tikz@lib@matrix@check#1{% evil hackery to find out about start of path - \pgfutil@ifnextchar\tikz@signal@path{\tikz@lib@matrix@plaintrue\let}{\tikz@lib@matrix@plainfalse\node\bgroup\tikz@lib@matrix@startup\let}% + \pgfutil@ifnextchar\tikz@signal@path{\tikz@lib@matrix@plaintrue\let}{\tikz@lib@matrix@plainfalse\node + [name=\tikzmatrixname-\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn]\bgroup\tikz@lib@matrix@startup\let}% } \def\tikz@lib@matrix@end@cell{% diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymindmap.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymindmap.code.tex index 981d747a3e5..4b6a952ac13 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymindmap.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymindmap.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymindmap.code.tex,v 1.9 2009/11/12 09:53:02 ludewich Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarymindmap.code.tex,v 1.10 2013/07/16 12:43:14 tantau Exp $ \usetikzlibrary{trees,decorations} @@ -98,7 +98,10 @@ \tikzstyle{circle connection bar}= [to path={ - \pgfextra{\tikz@compute@circle@radii\tikz@compute@segmentamplitude} + \pgfextra{% + \tikz@lib@mindmap@check{\tikztostart}% + \tikz@compute@circle@radii\tikz@compute@segmentamplitude% + } [every circle connection bar] decorate [decoration=circle connection bar] { -- (\tikztotarget) \tikztonodes} @@ -129,12 +132,31 @@ append after command={[fill=\tikz@concept@color,draw=none]} } + +% Check whether start and end are nodes! + +\def\tikz@lib@mindmap@check#1{% + \pgfutil@ifundefined{pgf@sh@ns@#1}% + {\tikzerror{You are attempting to connect two things by a circle + connection bar where one is not a node}}{% + \expandafter\ifx\csname pgf@sh@ns@#1\endcsname\tikz@lib@coordinate@text% + \tikzerror{You are attempting to connect node of shape + 'coordinate' by a circle connection bar. The shape should be + 'circle' or something similar, instead.} + \fi% + } +} + +\def\tikz@lib@coordinate@text{coordinate} + + % Switch color in a mindmap \tikzoption{circle connection bar switch color}{\tikz@parse@switch#1\pgf@unique} \def\tikz@parse@switch from (#1) to (#2)\pgf@unique{% \tikzset{to path={% \pgfextra{% + \tikz@lib@mindmap@check{\tikztostart}% \tikz@compute@circle@radii\tikz@compute@segmentamplitude% \global\let\tikz@lib@save@start=\tikztostart% \global\let\tikz@lib@save@target=\tikztotarget% diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarypetri.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarypetri.code.tex index 524bea7a28f..e67027eadfb 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarypetri.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarypetri.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarypetri.code.tex,v 1.2 2008/06/18 23:34:49 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarypetri.code.tex,v 1.3 2013/07/17 08:56:23 tantau Exp $ % Styles for places: @@ -59,7 +59,7 @@ \tikzoption{structured tokens}{% \tikzset{append after command={}% - {[children are tokens]child foreach \tikz@child@name in {#1} {node[token]{\tikz@child@name}}}}% + {[children are tokens]child foreach \tikzpetrichildname in {#1} {node[token]{\tikzpetrichildname}}}}% } diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryquotes.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryquotes.code.tex new file mode 100644 index 00000000000..4369b7e2dc2 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryquotes.code.tex @@ -0,0 +1,88 @@ +% Copyright 2011 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. + +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryquotes.code.tex,v 1.3 2013/08/28 15:24:27 tantau Exp $ + +\def\tikz@quote@parser#1{\tikz@quote@@parser#1\pgf@stop} +\def\tikz@quote@@parser"#1"{% + \pgfutil@ifnextchar\bgroup{% + \tikz@quote@@parser@group{#1}}{% + \pgfutil@ifnextchar'{% + \tikz@quote@@parser@apo{#1}}{% + \tikz@quote@@parser@normal{#1}}}} +\def\tikz@quote@@parser@apo#1'{% + \pgfutil@ifnextchar\bgroup{\tikz@quote@@parser@apo@group{#1}}{\tikz@quote@@parser@apo@normal{#1}}} +\def\tikz@quote@@parser@group#1#2#3\pgf@stop{% + \expandafter\def\expandafter\tikz@temp\expandafter{\tikz@quotes@as{#1}{#2}}% + \expandafter\pgfkeysalso\expandafter{\tikz@temp}% +} +\def\tikz@quote@@parser@normal#1#2\pgf@stop{% + \expandafter\def\expandafter\tikz@temp\expandafter{\tikz@quotes@as{#1}{#2}}% + \expandafter\pgfkeysalso\expandafter{\tikz@temp}% +} +\def\tikz@quote@@parser@apo@group#1#2#3\pgf@stop{% + \expandafter\def\expandafter\tikz@temp\expandafter{\tikz@quotes@as{#1}{',#2}}% + \expandafter\pgfkeysalso\expandafter{\tikz@temp}% +} +\def\tikz@quote@@parser@apo@normal#1#2\pgf@stop{% + \expandafter\def\expandafter\tikz@temp\expandafter{\tikz@quotes@as{#1}{',#2}}% + \expandafter\pgfkeysalso\expandafter{\tikz@temp}% +} + +\pgfkeys{/handlers/first char syntax=true} + +\def\tikz@enable@node@quotes{% + \pgfkeyssetvalue{/handlers/first char syntax/the character "}{\tikz@quote@parser}% + \let\tikz@quotes@as\tikz@node@quotes@as% +} +\def\tikz@enable@edge@quotes{% + \pgfkeyssetvalue{/handlers/first char syntax/the character "}{\tikz@quote@parser}% + \let\tikz@quotes@as\tikz@edge@quotes@as% +} +\def\tikz@enable@pic@quotes{% + \pgfkeyssetvalue{/handlers/first char syntax/the character "}{\tikz@quote@parser}% + \let\tikz@quotes@as\tikz@pic@quotes@as% +} + +\tikzset{ + node quotes mean/.code={\def\tikz@node@quotes@as##1##2{#1}}, + edge quotes mean/.code={\def\tikz@edge@quotes@as##1##2{#1}}, + pic quotes mean/.code={\def\tikz@pic@quotes@as##1##2{#1}}, + quotes mean pin/.style={node quotes mean={ + pin={[direction shorthands,every pin quotes/.try,##2]##1}}}, + quotes mean label/.style={node quotes mean={ + label={[direction shorthands,every label quotes/.try,##2]##1}}}, + quotes mean label, + edge quotes mean={edge node={node [every edge quotes,#2]{#1}}}, + pic quotes mean={pic text={#1},pic text options={every pic quotes/.try,#2}}, + every edge quotes/.style={auto}, + direction shorthands/.code={% + \pgfkeyslet{/tikz/above/.@cmd}\tikz@label@@above + \pgfkeyslet{/tikz/below/.@cmd}\tikz@label@@below + \pgfkeyslet{/tikz/left/.@cmd}\tikz@label@@left + \pgfkeyslet{/tikz/right/.@cmd}\tikz@label@@right + \pgfkeyslet{/tikz/above left/.@cmd}\tikz@label@@above@left + \pgfkeyslet{/tikz/above right/.@cmd}\tikz@label@@above@right + \pgfkeyslet{/tikz/below left/.@cmd}\tikz@label@@below@left + \pgfkeyslet{/tikz/below right/.@cmd}\tikz@label@@below@right + } +} + +\def\tikz@label@@above#1\pgfeov{\pgfkeysalso{label position=90,pin position=90}} +\def\tikz@label@@below#1\pgfeov{\pgfkeysalso{label position=-90,pin position=-90}} +\def\tikz@label@@left#1\pgfeov{\pgfkeysalso{label position=180,pin position=180}} +\def\tikz@label@@right#1\pgfeov{\pgfkeysalso{label position=0,pin position=0}} +\def\tikz@label@@above@left#1\pgfeov{\pgfkeysalso{label position=135,pin position=135}} +\def\tikz@label@@below@left#1\pgfeov{\pgfkeysalso{label position=-135,pin position=-135}} +\def\tikz@label@@above@right#1\pgfeov{\pgfkeysalso{label position=45,pin position=45}} +\def\tikz@label@@below@right#1\pgfeov{\pgfkeysalso{label position=-45,pin position=-45}} + + + +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarysnakes.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarysnakes.code.tex index 363beabe4c7..3fa9d3f8f46 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarysnakes.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarysnakes.code.tex @@ -7,9 +7,9 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarysnakes.code.tex,v 1.6 2008/02/05 13:08:05 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarysnakes.code.tex,v 1.7 2013/07/15 12:05:31 tantau Exp $ -\PackageWarning{tikz}{Snakes have been superseded by +\pgfwarning{Snakes have been superseded by decorations. Please use the decoration libraries instead of the snakes library} diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryspy.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryspy.code.tex index fd45a761535..099448c5165 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryspy.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryspy.code.tex @@ -7,7 +7,7 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryspy.code.tex,v 1.2 2009/12/04 11:59:38 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibraryspy.code.tex,v 1.4 2011/05/19 08:56:54 tantau Exp $ @@ -43,10 +43,10 @@ width/.style={minimum width=##1}, execute at begin scope={% \let\tikz@lib@spy@save=\tikz@lib@spy@collection% - \setbox\tikz@lib@spybox=\hbox\bgroup% + \setbox\tikz@lib@spybox=\hbox\bgroup\bgroup% \let\spy=\tikz@lib@spy@parse}, execute at end scope={% - \egroup% + \egroup\egroup% {% \copy\tikz@lib@spybox% \tikz@lib@spy@collection% @@ -99,13 +99,15 @@ }]{}; \node [alias=tikzspyinnode,inner sep=0pt,outer sep=0pt,at={#2},every spy in node/.try, path picture={\node[anchor=center,tikz@lib@reset@gs]{\nullfont% + \pgfpicture\relax\pgfsetbaseline{default}\pgfsettrimleft{default}\pgfsettrimright{default}% \pgftransformreset% \let\tikz@transform=\relax% \expandafter\tikzset\expandafter{\tikz@lib@spy@lens}% \pgflowlevelsynccm% \tikz@scan@one@point\tikz@lib@spy@shift#2% \pgflowlevelsynccm% - \copy\tikz@lib@spybox};}]#3{}; + \copy\tikz@lib@spybox% + \endpgfpicture};}]#3{}; \tikz@lib@spy@path \endscope } diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarysvg.path.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarysvg.path.code.tex index 0cee69a2fde..f0eae010424 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarysvg.path.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarysvg.path.code.tex @@ -7,16 +7,18 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarysvg.path.code.tex,v 1.1 2009/01/24 17:07:14 tantau Exp $ +\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarysvg.path.code.tex,v 1.2 2013/09/23 18:04:35 tantau Exp $ \usepgflibrary{svg.path} \def\tikz@svg@path vg{\pgfutil@ifnextchar[\tikz@svg@@path{\tikz@svg@@path[]}}%} -\def\tikz@svg@@path[#1]#2"#3"{% +\def\tikz@svg@@path[#1]{\pgfutil@ifnextchar"{\tikz@svg@@path@old{#1}}{\tikz@svg@@path@new{#1}}} +\def\tikz@svg@@path@new#1#2{\tikz@svg@@path@old{#1}"#2"} +\def\tikz@svg@@path@old#1"#2"{ {% \tikzset{#1}% - \pgfpathsvg{#3}% + \pgfpathsvg{#2}% }% { \pgftransforminvert diff --git a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex index e2a9cb2d649..f8c1e8792f4 100644 --- a/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex @@ -7,9 +7,11 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/tikz.code.tex,v 1.76 2010/10/13 09:20:31 ludewich Exp $ +\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/frontendlayer/tikz/tikz.code.tex,v 1.142 2013/12/13 15:11:58 tantau Exp $ +\def\tikzerror#1{\pgfutil@packageerror{tikz}{#1}{}} + % Always-present libraries (|\usepgflibrary| defined in % \file{pgfutil-common.tex}). \usepgflibrary{plothandlers} @@ -23,7 +25,9 @@ \newdimen\tikzsiblingdistance \newbox\tikz@figbox +\newbox\tikz@figbox@bg \newbox\tikz@tempbox +\newbox\tikz@tempbox@bg \newcount\tikztreelevel \newcount\tikznumberofchildren @@ -190,6 +194,11 @@ \tikzoption{opacity}{\tikz@addoption{\pgfsetstrokeopacity{#1}\pgfsetfillopacity{#1}}} +% Blend mode + +\tikzset{blend mode/.code={\tikz@addoption{\pgfsetblendmode{#1}}}} + + % Main color options \tikzoption{color}{% \tikz@addoption{% @@ -207,6 +216,7 @@ \fi% \pgfutil@colorlet{tikz@color}{#1}% \pgfutil@colorlet{.}{tikz@color}% + % \pgfsetcolor{.}% \pgfsys@color@reset@inordertrue% }% @@ -295,6 +305,99 @@ }% } +\tikzset{turn/.code={% + \pgf@x=0pt% + \pgf@y\pgf@x% + \pgf@process{\tikz@tangent}% + \advance\pgf@x by-\tikz@lastx% + \advance\pgf@y by-\tikz@lasty% + \pgfpointnormalised{}% x/y = normalised vector + \pgf@x=-\pgf@x% + \pgf@ya=-\pgf@y% + \pgftransformcm% + {\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@ya}}% + {\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@x}}{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}% + }% +} + +\def\tikz@tangent@lookup{% + \pgfgetpath\tikz@temp% + \pgfprocesspathextractpoints\tikz@temp% + \pgfpointsecondlastonpath% +} + +% Code for rotating the xyz coordinate system +% around the x, y, or z vector. +% +\def\tikz@xyz@rotate@let{% + \let\pgf@z=\pgf@yc + \let\pgf@za=\pgf@xc% +} + +\def\tikz@xyz@rotate@xyz@xaxis#1#2#3#4{% + \tikz@xyz@rotate@let% + \pgf@x=#1\relax% + \pgf@ya=#2\relax% + \pgf@za=#3\relax% + \pgfmathsin@{#4}\let\tikz@xyz@sin=\pgfmathresult% + \pgfmathcos@{#4}\let\tikz@xyz@cos=\pgfmathresult% + \pgf@y=\tikz@xyz@cos\pgf@ya% + \advance\pgf@y by-\tikz@xyz@sin\pgf@za% + \pgf@z=\tikz@xyz@sin\pgf@ya% + \advance\pgf@z by\tikz@xyz@cos\pgf@za% +} + +\def\tikz@xyz@rotate@xyz@yaxis#1#2#3#4{% + \tikz@xyz@rotate@let% + \pgf@xa=#1\relax% + \pgf@y=#2\relax% + \pgf@za=#3\relax% + \pgfmathsin@{#4}\let\tikz@xyz@sin=\pgfmathresult% + \pgfmathcos@{#4}\let\tikz@xyz@cos=\pgfmathresult% + \pgf@x=\tikz@xyz@cos\pgf@xa% + \advance\pgf@x by\tikz@xyz@sin\pgf@za% + \pgf@z=-\tikz@xyz@sin\pgf@xa% + \advance\pgf@z by\tikz@xyz@cos\pgf@za% +} + +\def\tikz@xyz@rotate@xyz@zaxis#1#2#3#4{% + \tikz@xyz@rotate@let% + \pgf@xa=#1\relax% + \pgf@ya=#2\relax% + \pgf@z=#3\relax% + \pgfmathsin@{#4}\let\tikz@xyz@sin=\pgfmathresult% + \pgfmathcos@{#4}\let\tikz@xyz@cos=\pgfmathresult% + \pgf@x=\tikz@xyz@cos\pgf@xa% + \advance\pgf@x by-\tikz@xyz@sin\pgf@ya% + \pgf@y=\tikz@xyz@sin\pgf@xa% + \advance\pgf@y by\tikz@xyz@cos\pgf@ya% +} + +\tikzset{rotate around x/.code={% + \tikz@xyz@rotate@let% + \tikz@xyz@rotate@xyz@xaxis{0pt}{1pt}{0pt}{#1}% + \pgfextract@process\tikz@xyz@rotate@yvec{\pgfpointxyz{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@z}}}% + \tikz@xyz@rotate@xyz@xaxis{0pt}{0pt}{1pt}{#1}% + \pgfsetzvec{\pgfpointxyz{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@z}}}% + \pgfsetyvec{\tikz@xyz@rotate@yvec}% + }, + rotate around y/.code={% + \tikz@xyz@rotate@let% + \tikz@xyz@rotate@xyz@yaxis{1pt}{0pt}{0pt}{#1}% + \pgfextract@process\tikz@xyz@rotate@xvec{\pgfpointxyz{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@z}}}% + \tikz@xyz@rotate@xyz@yaxis{0pt}{0pt}{1pt}{#1}% + \pgfsetzvec{\pgfpointxyz{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@z}}}% + \pgfsetxvec{\tikz@xyz@rotate@xvec}% + }, + rotate around z/.code={% + \tikz@xyz@rotate@let% + \tikz@xyz@rotate@xyz@zaxis{1pt}{0pt}{0pt}{#1}% + \pgfextract@process\tikz@xyz@rotate@xvec{\pgfpointxyz{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@z}}}% + \tikz@xyz@rotate@xyz@zaxis{0pt}{1pt}{0pt}{#1}% + \pgfsetyvec{\pgfpointxyz{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}{\pgf@sys@tonumber{\pgf@z}}}% + \pgfsetxvec{\tikz@xyz@rotate@xvec}% + } +} % Grid options \tikzoption{xstep}{\def\tikz@grid@x{#1}} @@ -325,7 +428,14 @@ \def\tikz@nonetext{none} \tikzoption{path only}[]{\let\tikz@mode=\pgfutil@empty} -\tikzoption{shade}[]{\tikz@addmode{\tikz@mode@shadetrue}} +\tikzset{ + shade/.is choice, + shade/.default=true, + shade/true/.code=\tikz@addmode{\tikz@mode@shadetrue}, + shade/false/.code=\tikz@addmode{\tikz@mode@shadefalse}, + shade/none/.code=\tikz@addmode{\tikz@mode@shadefalse}, +} + \tikzoption{fill}[]{% \edef\tikz@temp{#1}% \ifx\tikz@temp\tikz@nonetext% @@ -364,7 +474,7 @@ \tikzset{insert path/.code=\tikz@scan@next@command#1\pgf@stop} % Pattern options -\tikzset{pattern/.code=\PackageError{tikz}{You need to say \string\usetikzlibrary{patterns}}{}, +\tikzset{pattern/.code=\tikzerror{You need to say \string\usetikzlibrary{patterns}}, pattern color/.style=pattern} % Path pictures @@ -412,8 +522,10 @@ % Transparency groups \newif\iftikz@transparency@group -\tikzset{/tikz/transparency group/.is if=tikz@transparency@group} +\tikzset{/tikz/transparency group/.code=\tikz@transparency@grouptrue\def\tikz@transparency@group@options{isolated=true,#1}\let\tikz@blend@group\pgfutil@empty} +\tikzset{/tikz/blend group/.code=\tikz@transparency@grouptrue\def\tikz@transparency@group@options{isolated=true}\def\tikz@blend@group{\pgfsetblendmode{#1}}} +\let\tikz@blend@group\pgfutil@empty % Shading options \tikzoption{shading}{\def\tikz@shading{#1}\tikz@addmode{\tikz@mode@shadetrue}} @@ -475,7 +587,6 @@ % Pin options \tikzset{ - pin/.code={\pgfutil@ifnextchar[{\tikz@parse@pin}{\tikz@parse@pin[]}#1:\pgf@nil},%} pin distance/.store in=\tikz@pin@distance, pin distance=3ex, pin position/.store in=\tikz@pin@default@pos, @@ -489,34 +600,90 @@ }% } -\long\def\tikz@parse@pin[#1]#2:#3\pgf@nil{% +\tikzset{% + pin/.code={% + \begingroup + \ifnum\the\catcode`\:=\active\relax + \def\tikz@next{% + \endgroup + \tikz@parse@pin@active@i{#1}}% + \else + \def\tikz@next{% + \endgroup + \pgfutil@ifnextchar[%] + {\tikz@parse@pin@nonactive} + {\tikz@parse@pin@nonactive[]}#1:\pgf@nil}% + \fi + \tikz@next}} + +\begingroup + \catcode`\:=\active\relax + + \gdef\tikz@parse@pin@active@i#1{% + \pgfutil@ifnextchar[%] + {\tikz@parse@pin@active} + {\tikz@parse@pin@active[]}#1:\pgf@nil} + + \long\gdef\tikz@parse@pin@active[#1]#2:#3\pgf@nil{% + \def\tikz@temp{#3}% + \ifx\tikz@temp\pgfutil@empty + % no position, use default + \tikz@@parse@pin@active[#1]\tikz@pin@default@pos:#2:\pgf@nil% + \else + \tikz@@parse@pin@active[#1]#2:#3\pgf@nil% + \fi} + + \long\gdef\tikz@@parse@pin@active[#1]#2:#3:\pgf@nil{% + \tikzset{% + append after command = {% + \bgroup + [current point is local = true] + \pgfextra{\let\tikz@save@last@node=\tikzlastnode\tikz@node@is@a@labelfalse}% + node [every pin, + tikz@label@angle = #2, + #1, + append after command = {% + (\tikz@save@last@node) + edge [every pin edge, + tikz@pre@pin@edge, + tikz@pin@options] + (\tikzlastnode)}, + tikz@label@post = \tikz@pin@distance, + tikz@pin@post] {#3} + \egroup}}} +\endgroup + +\long\def\tikz@parse@pin@nonactive[#1]#2:#3\pgf@nil{% \def\tikz@temp{#3}% - \ifx\tikz@temp\pgfutil@empty% + \ifx\tikz@temp\pgfutil@empty % no position, use default - \tikz@@parse@pin[#1]\tikz@pin@default@pos:#2:\pgf@nil% - \else% - \tikz@@parse@pin[#1]#2:#3\pgf@nil% - \fi% -} - -\long\def\tikz@@parse@pin[#1]#2:#3:\pgf@nil{% - \tikzset{append after command={% - \bgroup - [current point is local=true] - \pgfextra{\let\tikz@save@last@node=\tikzlastnode}% - node [every pin,tikz@label@angle=#2,#1,% - append after command={(\tikz@save@last@node) edge[every pin edge,tikz@pre@pin@edge,tikz@pin@options] (\tikzlastnode)}, - tikz@label@post=\tikz@pin@distance,tikz@pin@post] - {#3} - \egroup% - }} -} + \tikz@@parse@pin@nonactive[#1]\tikz@pin@default@pos:#2:\pgf@nil% + \else + \tikz@@parse@pin@nonactive[#1]#2:#3\pgf@nil% + \fi} +\long\def\tikz@@parse@pin@nonactive[#1]#2:#3:\pgf@nil{% + \tikzset{% + append after command = {% + \bgroup + [current point is local = true] + \pgfextra{\let\tikz@save@last@node=\tikzlastnode\tikz@node@is@a@labelfalse}% + node [every pin, + tikz@label@angle = #2, + #1, + append after command = {% + (\tikz@save@last@node) + edge [every pin edge, + tikz@pre@pin@edge, + tikz@pin@options] + (\tikzlastnode)}, + tikz@label@post = \tikz@pin@distance, + tikz@pin@post] {#3} + \egroup}}} % Label and pin options \tikzset{ - label/.code={\pgfutil@ifnextchar[{\tikz@parse@label}{\tikz@parse@label[]}#1:\pgf@nil},%} label distance/.store in=\tikz@label@distance, label distance=0pt, label position/.store in=\tikz@label@default@pos, @@ -583,31 +750,86 @@ \newif\iftikz@label@simple% -\def\tikz@parse@label[#1]#2:#3\pgf@nil{% - \def\tikz@temp{#3}% - \ifx\tikz@temp\pgfutil@empty% +\tikzset{% + label/.code={% + \begingroup + \ifnum\the\catcode`\:=\active\relax + \def\tikz@next{% + \endgroup + \tikz@parse@label@active@i{#1}}% + \else + \def\tikz@next{% + \endgroup + \pgfutil@ifnextchar[%] + {\tikz@parse@label@nonactive} + {\tikz@parse@label@nonactive[]}#1:\pgf@nil}% + \fi + \tikz@next}} + +\begingroup + \catcode`\:=\active\relax + + \gdef\tikz@parse@label@active@i#1{% + \pgfutil@ifnextchar[%] + {\tikz@parse@label@active} + {\tikz@parse@label@active[]}#1:\pgf@nil} + + \gdef\tikz@parse@label@active[#1]#2:#3\pgf@nil{% + \def\tikz@temp{#3}% + \ifx\tikz@temp\pgfutil@empty % no position, use default - \tikz@@parse@label[#1]\tikz@label@default@pos:#2:\pgf@nil% - \else% - \tikz@@parse@label[#1]#2:#3\pgf@nil% - \fi% -} + \tikz@@parse@label@active[#1]\tikz@label@default@pos:#2:\pgf@nil% + \else + \def\tikz@temp{#2}% + \ifx\tikz@temp\pgfutil@empty + \tikz@@parse@label@active[#1]\tikz@label@default@pos:#3\pgf@nil% + \else + \tikz@@parse@label@active[#1]#2:#3\pgf@nil% + \fi + \fi + } -\def\tikz@@parse@label[#1]#2:#3:\pgf@nil{% - \tikzset{append after command={ - \bgroup - [current point is local=true] - \pgfextra{\let\tikz@save@last@fig@name=\tikz@last@fig@name}% - node - [every label,% - tikz@label@angle=#2,% - #1,% - tikz@label@post=\tikz@label@distance]% - {#3}% - \pgfextra{\global\let\tikz@last@fig@name=\tikz@save@last@fig@name}% - \egroup% - }} -} + \gdef\tikz@@parse@label@active[#1]#2:#3:\pgf@nil{% + \tikzset{% + append after command = {% + \bgroup + [current point is local=true] + \pgfextra{\let\tikz@save@last@fig@name=\tikz@last@fig@name\tikz@node@is@a@labelfalse} + node [every label, + tikz@label@angle = #2, + #1, + tikz@label@post = \tikz@label@distance] {\iftikz@handle@active@nodes\expandafter\scantokens\else\expandafter\pgfutil@firstofone\fi{#3}} + \pgfextra{\global\let\tikz@last@fig@name=\tikz@save@last@fig@name} + \egroup}}} +\endgroup + +\def\tikz@parse@label@nonactive[#1]#2:#3\pgf@nil{% + \def\tikz@temp{#3}% + \ifx\tikz@temp\pgfutil@empty + % no position, use default + \tikz@@parse@label@nonactive[#1]\tikz@label@default@pos:#2:\pgf@nil% + \else + \def\tikz@temp{#2}% + \ifx\tikz@temp\pgfutil@empty + \tikz@@parse@label@nonactive[#1]\tikz@label@default@pos:#3\pgf@nil% + \else + \tikz@@parse@label@nonactive[#1]#2:#3\pgf@nil% + \fi + \fi +} + +\def\tikz@@parse@label@nonactive[#1]#2:#3:\pgf@nil{% + \tikzset{% + append after command = {% + \bgroup + [current point is local=true] + \pgfextra{\let\tikz@save@last@fig@name=\tikz@last@fig@name\tikz@node@is@a@labelfalse} + node [every label, + tikz@label@angle = #2, + #1, + tikz@label@post = \tikz@label@distance] {\iftikz@handle@active@nodes\expandafter\scantokens\else\expandafter\pgfutil@firstofone\fi{#3}} + \pgfextra{\global\let\tikz@last@fig@name=\tikz@save@last@fig@name} + \egroup}}} \expandafter\def\csname tikz@label@angle@is@right\endcsname{\def\tikz@label@angle{0}} \expandafter\def\csname tikz@label@angle@is@above right\endcsname{\def\tikz@label@angle{45}} @@ -650,7 +872,24 @@ % General node options -\tikzoption{name}{\edef\tikz@fig@name{#1}} +\tikzset{ + name/.code={\edef\tikz@fig@name{\tikz@pp@name{#1}}},% + name prefix/.initial=,% + name suffix/.initial=% +} +\def\tikz@pp@name#1{\csname pgfk@/tikz/name prefix\endcsname#1\csname pgfk@/tikz/name suffix\endcsname} + + +\tikzset{ + node contents/.code=\def\tikz@node@content{#1}, + pic type/.code=\def\tikz@node@content{#1}, % alias +} + +\tikzset{ + behind path/.code=\def\tikz@whichbox{\tikz@figbox@bg}, + in front of path/.code=\def\tikz@whichbox{\tikz@figbox} +} +\def\tikz@whichbox{\tikz@figbox} \tikzoption{at}{\tikz@scan@one@point\tikz@set@at#1} \def\tikz@set@at#1{\def\tikz@node@at{#1}}% @@ -665,6 +904,17 @@ \def\tikzaddafternodepathoption#1{#1\tikzset{prefix after command={\pgfextra{#1}}}} \tikzset{after node path/.style={append after command={#1}}} + +% Pic options +\newif\iftikz@node@is@pic +\tikzset{pic text/.store in=\tikzpictext} +\let\tikzpictext\relax +\tikzset{pic text options/.store in=\tikzpictextoptions} +\let\tikzpictextoptions\pgfutil@empty + + +% Anchoring + \tikzoption{anchor}{\def\tikz@anchor{#1}\let\tikz@do@auto@anchor=\relax} \tikzoption{left}[]{\def\tikz@anchor{east}\tikz@possibly@transform{x}{-}{#1}} @@ -706,6 +956,14 @@ \def\tikz@extract@node@dist#1and#2\pgf@stop{% \def\tikz@extracted@node@distance{#1}} +\tikzset{ + transform shape nonlinear/.is choice, + transform shape nonlinear/.default=true, + transform shape nonlinear/true/.code=\let\tikz@nlt\relax, + transform shape nonlinear/false/.code=\def\tikz@nlt{\pgfapproximatenonlineartranslation}, + transform shape nonlinear=false +} + \tikzoption{transform shape}[true]{% \csname tikz@fullytransformed#1\endcsname% @@ -746,7 +1004,7 @@ \tikzoption{sloped}[true]{\csname pgfslopedattime#1\endcsname} \tikzoption{allow upside down}[true]{\csname pgfallowupsidedownattime#1\endcsname} -\tikzoption{pos}{\edef\tikz@time{#1}} +\tikzoption{pos}{\edef\tikz@time{#1}\ifx\tikz@time\pgfutil@empty\else\pgfmathsetmacro\tikz@time{\tikz@time}\fi} \tikzoption{auto}[]{\csname tikz@install@auto@anchor@#1\endcsname} \tikzoption{swap}[]{% @@ -757,6 +1015,8 @@ \def\tikz@auto@anchor@direction{left}% \fi% } +\tikzset{'/.style=swap} % shorthand + \def\tikz@install@auto@anchor@{\let\tikz@do@auto@anchor=\tikz@auto@anchor@on} \def\tikz@install@auto@anchor@false{\let\tikz@do@auto@anchor=\relax} @@ -775,30 +1035,34 @@ % Text options \tikzoption{text}{\def\tikz@textcolor{#1}} \tikzoption{font}{\def\tikz@textfont{#1}} +\tikzoption{node font}{\def\tikz@node@textfont{#1}} \tikzoption{text opacity}{\def\tikz@textopacity{#1}} \tikzoption{text width}{\def\tikz@text@width{#1}} \tikzoption{text height}{\def\tikz@text@height{#1}} \tikzoption{text depth}{\def\tikz@text@depth{#1}} \tikzoption{text ragged}[]% -{\def\tikz@text@action{\raggedright\rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax}} -\tikzoption{text badly ragged}[]{\def\tikz@text@action{\raggedright\relax}} +{\def\tikz@text@action{\pgfutil@raggedright\rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax}} +\tikzoption{text badly ragged}[]{\def\tikz@text@action{\pgfutil@raggedright\relax}} \tikzoption{text ragged left}[]% -{\def\tikz@text@action{\raggedleft\leftskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax}} -\tikzoption{text badly ragged left}[]{\def\tikz@text@action{\raggedleft\relax}} +{\def\tikz@text@action{\pgfutil@raggedleft\leftskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax}} +\tikzoption{text badly ragged left}[]{\def\tikz@text@action{\pgfutil@raggedleft\relax}} \tikzoption{text justified}[]{\def\tikz@text@action{\leftskip0pt\rightskip0pt\relax}} \tikzoption{text centered}[]{\def\tikz@text@action{% \leftskip0pt plus2em% \rightskip0pt plus2em% \spaceskip.3333em \xspaceskip.5em% \parfillskip=0pt% + \iftikz@warn@for@narrow@centered\else\hbadness10000\fi% \let\\=\@centercr% for latex \relax}} \tikzoption{text badly centered}[]% {\def\tikz@text@action{% \let\\=\@centercr% for latex \parfillskip=0pt% - \rightskip\@flushglue% - \leftskip\@flushglue\relax}} + \rightskip\pgfutil@flushglue% + \leftskip\pgfutil@flushglue\relax}} +\tikzset{badness warnings for centered text/.is if=tikz@warn@for@narrow@centered} +\newif\iftikz@warn@for@narrow@centered \let\tikz@text@width=\pgfutil@empty \let\tikz@text@height=\pgfutil@empty @@ -806,8 +1070,9 @@ \let\tikz@textcolor=\pgfutil@empty \let\tikz@textfont=\pgfutil@empty \let\tikz@textopacity=\pgfutil@empty +\let\tikz@node@textfont=\pgfutil@empty -\def\tikz@text@action{\raggedright\rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax} +\def\tikz@text@action{\pgfutil@raggedright\rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax} % Alignment @@ -832,57 +1097,22 @@ % Arrow options \tikzoption{arrows}{\tikz@processarrows{#1}} -\tikzoption{>}{% - \tikz@set@pointed{\csname pgf@arrows@invert#1\endcsname}{#1}% - \expandafter\tikz@processarrows\expandafter{\tikz@current@arrows}% -} + +\tikzoption{>}{\pgfdeclarearrow{name=<->,means={#1}}}% +\pgfdeclarearrow{name=|<->|, means={>[sep=0pt].|}} \tikzoption{shorten <}{\pgfsetshortenstart{#1}} \tikzoption{shorten >}{\pgfsetshortenend{#1}} -\def\tikz@set@pointed#1#2{% - \pgfutil@ifundefined{pgf@arrow@code@tikze@>@#2} - {% - \pgfarrowsdeclarealias{tikzs@<@#2}{tikze@>@#2}{#1}{#2}% - \pgfarrowsdeclarereversed{tikzs@>@#2}{tikze@<@#2}{#1}{#2}% - \pgfarrowsdeclarecombine*{tikz@|<@#2}{tikz@>|@#2}{#1}{#2}{|}{|}% - \pgfarrowsdeclaredouble[\pgflinewidth]{tikzs@<<@#2}{tikze@>>@#2}{#1}{#2}%<< - \pgfarrowsdeclarereversed{tikzs@>>@#2}{tikze@<<@#2}{tikzs@<<@#2}{tikze@>>@#2}%<< - }{}% - \pgfutil@namedef{tikz@special@arrow@start<}{tikzs@<@#2}% - \pgfutil@namedef{tikz@special@arrow@end>}{tikze@>@#2}% - \pgfutil@namedef{tikz@special@arrow@start>}{tikzs@>@#2}% - \pgfutil@namedef{tikz@special@arrow@end<}{tikze@<@#2}% - \pgfutil@namedef{tikz@special@arrow@start|<}{tikz@|<@#2}% - \pgfutil@namedef{tikz@special@arrow@end>|}{tikz@>|@#2}% - \pgfutil@namedef{tikz@special@arrow@start<<}{tikzs@<<@#2}% - \pgfutil@namedef{tikz@special@arrow@end>>}{tikze@>>@#2}%<< - \pgfutil@namedef{tikz@special@arrow@start>>}{tikzs@>>@#2}%<< - \pgfutil@namedef{tikz@special@arrow@end<<}{tikze@<<@#2}%<< -} - \def\tikz@processarrows#1{% \def\tikz@current@arrows{#1}% \def\tikz@temp{#1}% \ifx\tikz@temp\pgfutil@empty% \else% - \tikz@@processarrows#1\@nil - \fi% -} -\def\tikz@@processarrows#1-#2\@nil{% - \expandafter\ifx\csname tikz@special@arrow@start#1\endcsname\relax% - \pgfsetarrowsstart{#1} - \else% - \pgfsetarrowsstart{\csname tikz@special@arrow@start#1\endcsname}% - \fi% - \expandafter\ifx\csname tikz@special@arrow@end#2\endcsname\relax% - \pgfsetarrowsend{#2} - \else% - \pgfsetarrowsend{\csname tikz@special@arrow@end#2\endcsname}% + \pgfsetarrows{#1}% \fi% } -\tikz@set@pointed{\pgf@arrows@invertto}{to} \def\tikz@current@arrows{-} % Parabola options @@ -900,11 +1130,16 @@ % Axis options \tikzoption{domain}{\edef\tikz@plot@domain{#1}\expandafter\tikz@plot@samples@recalc\tikz@plot@domain\relax} \tikzoption{range}{\def\tikz@plot@range{#1}} +\tikzoption{yrange}{\def\tikz@plot@range{#1}} +\let\tikz@plot@range=\pgfutil@empty +\tikzoption{xrange}{\def\tikz@plot@xrange{#1}} +\let\tikz@plot@xrange=\pgfutil@empty % Plot options \tikzoption{smooth}[]{\let\tikz@plot@handler=\pgfplothandlercurveto} \tikzoption{smooth cycle}[]{\let\tikz@plot@handler=\pgfplothandlerclosedcurve} \tikzoption{sharp plot}[]{\let\tikz@plot@handler\pgfplothandlerlineto} +\tikzoption{sharp cycle}[]{\let\tikz@plot@handler\pgfplothandlerpolygon} \tikzoption{tension}{\pgfsetplottension{#1}} @@ -918,14 +1153,16 @@ \tikzoption{const plot}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlineto} \tikzoption{const plot mark left}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlineto} \tikzoption{const plot mark right}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlinetomarkright} +\tikzoption{const plot mark mid}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlinetomarkmid} \tikzoption{jump mark right}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkright} +\tikzoption{jump mark mid}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkmid} \tikzoption{jump mark left}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkleft} \tikzoption{raw gnuplot}[true]{\csname tikz@plot@raw@gnuplot#1\endcsname} \tikzoption{prefix}{\def\tikz@plot@prefix{#1}} \tikzoption{id}{\def\tikz@plot@id{#1}} -\tikzoption{samples}{\def\tikz@plot@samples{#1}\expandafter\tikz@plot@samples@recalc\tikz@plot@domain\relax} +\tikzoption{samples}{\pgfmathsetmacro\tikz@plot@samples{max(2,#1)}\expandafter\tikz@plot@samples@recalc\tikz@plot@domain\relax} \tikzoption{samples at}{\def\tikz@plot@samplesat{#1}} \tikzoption{parametric}[true]{\csname tikz@plot@parametric#1\endcsname} @@ -963,12 +1200,28 @@ \def\tikz@plot@var{\x} \def\tikz@plot@samplesat{-5,-4.5833333,...,5} \def\tikz@plot@samples@recalc#1:#2\relax{% + \begingroup \pgfmathparse{#1}% \let\tikz@temp@start=\pgfmathresult% \pgfmathparse{#2}% \let\tikz@temp@end=\pgfmathresult% - \pgfmathparse{\tikz@temp@start+(\tikz@temp@end-\tikz@temp@start)/(\tikz@plot@samples-1)}% - \edef\tikz@plot@samplesat{\tikz@temp@start,\pgfmathresult,...,\tikz@temp@end}% + \pgfmathsetmacro\tikz@temp@diff{(\tikz@temp@end-\tikz@temp@start)/(\tikz@plot@samples-1)}% + % + % this particular item is for backwards compatibility. + % Pgfplots <= 1.8 called 'samples' in a context where the 'fpu' was + % active... and I fear there is no simple solution to replace the + % new \ifdim below. Sorry. + \pgfkeys{/pgf/fpu/output format/fixed/.try}% + % + \pgfmathsetmacro\tikz@temp@diff@abs{abs(\tikz@temp@diff)}% + \ifdim\tikz@temp@diff@abs pt<0.0001pt\relax% + \edef\tikz@plot@samplesat{\tikz@temp@start,\tikz@temp@end}% + \else% + \pgfmathparse{\tikz@temp@start+\tikz@temp@diff}% + \edef\tikz@plot@samplesat{\tikz@temp@start,\pgfmathresult,...,\tikz@temp@end}% + \fi% + \pgfmath@smuggleone\tikz@plot@samplesat + \endgroup } @@ -979,11 +1232,24 @@ \newif\iftikz@plot@raw@gnuplot -% To options +% +% To and edge options +% \tikzoption{to path}{\def\tikz@to@path{#1}} \def\tikz@to@path{-- (\tikztotarget) \tikztonodes} +\tikzset{edge macro/.store in=\tikz@edge@macro} +\let\tikz@edge@macro\pgfutil@empty + +\tikzset{ + edge node/.code={ + \expandafter\def\expandafter\tikz@tonodes\expandafter{\tikz@tonodes #1} + }, + edge label/.style={/tikz/edge node={node[auto]{#1}}}, + edge label'/.style={/tikz/edge node={node[auto,swap]{#1}}} +} + % After command options \tikzset{ @@ -1003,6 +1269,10 @@ \newif\iftikz@child@missing \pgfkeys{/tikz/missing/.is if=tikz@child@missing} +\tikzset{edge from parent macro/.initial=\tikz@edge@from@parent@macro} +\def\tikz@edge@from@parent@macro#1#2{ + [style=edge from parent, #1, /utils/exec=\tikz@node@is@a@labeltrue] \tikz@edge@to@parent@path #2} + \tikzoption{edge from parent path}{\def\tikz@edge@to@parent@path{#1}} \tikzoption{parent anchor}{\def\tikzparentanchor{.#1}\ifx\tikzparentanchor\tikz@border@text\let\tikzparentanchor\pgfutil@empty\fi} @@ -1084,10 +1354,10 @@ % Snakes are in a lib: -\tikzset{snake/.code=\PackageError{tikz}{You need to say \string\usetikzlibrary{snakes}}{}} +\tikzset{snake/.code=\tikzerror{You need to say \string\usetikzlibrary{snakes}}} % Decorations -\tikzset{decorate/.code=\PackageError{tikz}{You need to load a decoration library}{}} +\tikzset{decorate/.code=\tikzerror{You need to load a decoration library}} % Matrix options \usepgfmodule{matrix} @@ -1108,6 +1378,15 @@ \let\tikz@ampersand@replacement=\pgfutil@empty +% Automatic shorthand management +\tikzset{% + handle active characters in code/.is if=tikz@handle@active@code, + handle active characters in nodes/.is if=tikz@handle@active@nodes, +} +\newif\iftikz@handle@active@code +\newif\iftikz@handle@active@nodes + + % Execute option \tikzoption{execute at begin picture}{\expandafter\def\expandafter\tikz@atbegin@picture\expandafter{\tikz@atbegin@picture#1}} \tikzoption{execute at end picture}{\expandafter\def\expandafter\tikz@atend@picture\expandafter{\tikz@atend@picture#1}} @@ -1117,6 +1396,8 @@ \tikzoption{execute at end to}{\expandafter\def\expandafter\tikz@atend@to\expandafter{\tikz@atend@to#1}} \tikzoption{execute at begin node}{\expandafter\def\expandafter\tikz@atbegin@node\expandafter{\tikz@atbegin@node#1}} \tikzoption{execute at end node}{\expandafter\def\expandafter\tikz@atend@node\expandafter{\tikz@atend@node#1}} +\tikzoption{execute at begin matrix}{\expandafter\def\expandafter\tikz@atbegin@matrix\expandafter{\tikz@atbegin@matrix#1}} +\tikzoption{execute at end matrix}{\expandafter\def\expandafter\tikz@atend@matrix\expandafter{\tikz@atend@matrix#1}} \tikzoption{execute at begin cell}{\expandafter\def\expandafter\tikz@atbegin@cell\expandafter{\tikz@atbegin@cell#1}} \tikzoption{execute at end cell}{\expandafter\def\expandafter\tikz@atend@cell\expandafter{\tikz@atend@cell#1}} \tikzoption{execute at empty cell}{\expandafter\def\expandafter\tikz@at@emptycell\expandafter{\tikz@at@emptycell#1}} @@ -1132,6 +1413,8 @@ \let\tikz@atbegin@cell=\pgfutil@empty \let\tikz@atend@cell=\pgfutil@empty \let\tikz@at@emptycell=\pgfutil@empty +\let\tikz@atbegin@matrix=\pgfutil@empty +\let\tikz@atend@matrix=\pgfutil@empty % Pre and post actions @@ -1211,11 +1494,17 @@ \tikzstyle{densely dashed}= [dash pattern=on 3pt off 2pt] \tikzstyle{loosely dashed}= [dash pattern=on 3pt off 6pt] \tikzstyle{dashdotted}= [dash pattern=on 3pt off 2pt on \the\pgflinewidth off 2pt] +\tikzstyle{dash dot}= [dash pattern=on 3pt off 2pt on \the\pgflinewidth off 2pt] \tikzstyle{densely dashdotted}= [dash pattern=on 3pt off 1pt on \the\pgflinewidth off 1pt] +\tikzstyle{densely dash dot}= [dash pattern=on 3pt off 1pt on \the\pgflinewidth off 1pt] \tikzstyle{loosely dashdotted}= [dash pattern=on 3pt off 4pt on \the\pgflinewidth off 4pt] +\tikzstyle{loosely dash dot}= [dash pattern=on 3pt off 4pt on \the\pgflinewidth off 4pt] \tikzstyle{dashdotdotted}= [dash pattern=on 3pt off 2pt on \the\pgflinewidth off 2pt on \the\pgflinewidth off 2pt] \tikzstyle{densely dashdotdotted}= [dash pattern=on 3pt off 1pt on \the\pgflinewidth off 1pt on \the\pgflinewidth off 1pt] \tikzstyle{loosely dashdotdotted}= [dash pattern=on 3pt off 4pt on \the\pgflinewidth off 4pt on \the\pgflinewidth off 4pt] +\tikzstyle{dash dot dot}= [dash pattern=on 3pt off 2pt on \the\pgflinewidth off 2pt on \the\pgflinewidth off 2pt] +\tikzstyle{densely dash dot dot}= [dash pattern=on 3pt off 1pt on \the\pgflinewidth off 1pt on \the\pgflinewidth off 1pt] +\tikzstyle{loosely dash dot dot}= [dash pattern=on 3pt off 4pt on \the\pgflinewidth off 4pt on \the\pgflinewidth off 4pt] \tikzstyle{transparent}= [opacity=0] @@ -1258,24 +1547,26 @@ \expandafter\pgfutil@in@\expandafter!\expandafter{\tikz@key}% \ifpgfutil@in@% % this is a color! - \expandafter\tikz@addoption\expandafter{\expandafter\pgfutil@color\expandafter{\tikz@key}}% + \expandafter\tikz@addoption\expandafter{\expandafter\tikz@compat@color@set\expandafter{\tikz@key}}% \edef\tikz@textcolor{\tikz@key}% \else% \pgfutil@doifcolorelse{\tikz@key} - { % - \expandafter\tikz@addoption\expandafter{\expandafter\pgfutil@color\expandafter{\tikz@key}}% + {% + \expandafter\tikz@addoption\expandafter{\expandafter\tikz@compat@color@set\expandafter{\tikz@key}}% \edef\tikz@textcolor{\tikz@key}% }% {% % Ok, second chance: This might be an arrow specification: - \expandafter\pgfutil@in@\expandafter-\expandafter{\tikz@key} + \expandafter\pgfutil@in@\expandafter-\expandafter{\tikz@key}% \ifpgfutil@in@% % Ah, an arrow spec! \expandafter\tikz@processarrows\expandafter{\tikz@key}% \else% % Ok, third chance: A shape! \expandafter\ifx\csname pgf@sh@s@\tikz@key\endcsname\relax% - \pgfkeys{/errors/unknown key={/tikz/\tikz@key}{#1}}% + \pgfkeys{/errors/unknown key/.expand + once=\expandafter{\expandafter/\expandafter t\expandafter + i\expandafter k\expandafter z\expandafter/\tikz@key}{#1}}% \else% \edef\tikz@shape{\tikz@key}% \fi% @@ -1284,35 +1575,60 @@ \fi% \fi% } +\def\tikz@compat@color@set#1{% + \pgfutil@color{#1}\pgfutil@colorlet{pgffillcolor}{#1}% + \expandafter\expandafter\expandafter\global% + \expandafter\expandafter\expandafter\let\expandafter\csname\expandafter\string\expandafter\color@pgffillcolor\expandafter\endcsname\csname\string\color@pgffillcolor\endcsname% + \expandafter\expandafter\expandafter\global% + \expandafter\expandafter\expandafter\let\expandafter\csname\expandafter\string\expandafter\color@pgfstrokecolor\expandafter\endcsname\csname\string\color@pgffillcolor\endcsname% +} +\def\tikz@startup@env{% + \ifnum\the\catcode`\;=\active\relax\expandafter\let\expandafter\tikz@origsemi\expandafter=\tikz@activesemicolon\fi% + \ifnum\the\catcode`\:=\active\relax\expandafter\let\expandafter\tikz@origcolon\expandafter=\tikz@activecolon\fi% + \ifnum\the\catcode`\|=\active\relax\expandafter\let\expandafter\tikz@origbar\expandafter=\tikz@activebar\fi% + \tikz@deactivatthings% + \iftikz@handle@active@code% + \tikz@switchoff@shorthands% + \fi% +} % % Main TikZ Environment % -\def\tikzpicture{\pgfutil@ifnextchar[\tikz@picture{\tikz@picture[]}}%} +\def\tikzpicture{% + \begingroup% + \tikz@startup@env% + \pgfutil@ifnextchar[\tikz@picture{\tikz@picture[]}}%} \def\tikz@picture[#1]{% \pgfpicture% \let\tikz@atbegin@picture=\pgfutil@empty% \let\tikz@atend@picture=\pgfutil@empty% \let\tikz@transform=\relax% \def\tikz@time{.5}% - \tikz@installcommands\scope[every picture,#1]% + \tikz@installcommands% + \scope[every picture,#1]% + \iftikz@handle@active@code% + \tikz@switchoff@shorthands% + \fi% \expandafter\tikz@atbegin@picture% \tikz@lib@scope@check% } \def\endtikzpicture{% \tikz@atend@picture% - \global\let\pgf@shift@baseline=\pgf@baseline% - \global\let\pgf@trimleft@final=\pgf@trimleft% - \global\let\pgf@trimright@final=\pgf@trimright% + \global\let\pgf@shift@baseline@smuggle=\pgf@baseline% + \global\let\pgf@trimleft@final@smuggle=\pgf@trimleft% + \global\let\pgf@trimright@final@smuggle=\pgf@trimright% \global\let\pgf@remember@smuggle=\ifpgfrememberpicturepositiononpage% + \pgf@remember@layerlist@globally \endscope% - \let\pgf@baseline=\pgf@shift@baseline% - \let\pgf@trimleft=\pgf@trimleft@final% - \let\pgf@trimright=\pgf@trimright@final% + \let\pgf@baseline=\pgf@shift@baseline@smuggle% + \let\pgf@trimleft=\pgf@trimleft@final@smuggle% + \let\pgf@trimright=\pgf@trimright@final@smuggle% \let\ifpgfrememberpicturepositiononpage=\pgf@remember@smuggle% - \endpgfpicture} + \pgf@restore@layerlist@from@global + \endpgfpicture\endgroup} % Inlined picture @@ -1327,29 +1643,52 @@ % The rectangle \tikz{\draw (0,0) rectangle (1em,1ex)} has width 1em and % height 1ex. -% This code does not work for some inline \tikz. For example -% \tikz\foreach \x in {1,...,10} \draw (\x,0) circle (0.4cm); -% makes tikz crash. -% Begin suspected code -% \def\tikz{\pgfutil@ifnextchar[{\tikz@opt}{\tikz@opt[]}} -% \def\tikz@opt[#1]{\tikzpicture[#1]\pgfutil@ifnextchar\bgroup{\tikz@}{\tikz@@}} -% \def\tikz@{\bgroup\tikz@auto@end@pathtrue\aftergroup\endtikzpicture\let\pgf@temp=} -% \def\tikz@@{\begingroup\def\tikz@path@do@at@end{\endgroup\endtikzpicture}} -% End suspected code -% Begin old code -\def\tikz{\pgfutil@ifnextchar[{\tikz@opt}{\tikz@opt[]}} -\def\tikz@opt[#1]{\tikzpicture[#1]\pgfutil@ifnextchar\bgroup{\tikz@}{\tikz@@}} -\def\tikz@#1{#1\endtikzpicture} + +\def\tikz{% + \begingroup% + \tikz@startup@env% + \pgfutil@ifnextchar[{\tikz@opt}{\tikz@opt[]}} +\def\tikz@opt[#1]{\tikzpicture[#1]\pgfutil@ifnextchar\bgroup{\tikz@}{\tikz@@single}} +\def\tikz@{\bgroup\tikz@auto@end@pathtrue\aftergroup\endtikzpicture\aftergroup\endgroup\let\pgf@temp=} +\def\tikz@@single#1{% + \expandafter\ifx\csname tikz@protected@command\string#1\endcsname\relax% + \expandafter\tikz@@% + \else% + \begingroup\def\tikz@path@do@at@end{\endgroup\endtikzpicture\endgroup}% + \fi% + #1% +} + +\expandafter\let\csname tikz@protected@command\string\draw\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\pattern\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\fill\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\filldraw\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\shade\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\shadedraw\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\clip\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\graph\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\useasboundingbox\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\node\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\coordinate\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\matrix\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\datavisualization\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\path\endcsname\pgfutil@empty +\expandafter\let\csname tikz@protected@command\string\pic\endcsname\pgfutil@empty + +% Comment by TT: I hope I fixed the \tikz \foreach problem. The new +% version will take a conservative approach and will only do fancy +% stuff when the next keyword after \tikz is one of the following: +% \draw, \fill, \filldraw, \graph, \matrix, \def\tikz@@{% \let\tikz@next=\tikz@collectnormalsemicolon% \ifnum\the\catcode`\;=\active\relax% \let\tikz@next=\tikz@collectactivesemicolon% \fi% \tikz@next} -\def\tikz@collectnormalsemicolon#1;{#1;\endtikzpicture} +\def\tikz@collectnormalsemicolon#1;{#1;\endtikzpicture\endgroup} { \catcode`\;=\active - \gdef\tikz@collectactivesemicolon#1;{#1;\endtikzpicture} + \gdef\tikz@collectactivesemicolon#1;{#1;\endtikzpicture\endgroup} } % End old code @@ -1374,7 +1713,7 @@ \tikz@transparency@groupfalse% \tikzset{every scope/.try,#1}% \tikz@options% - \iftikz@transparency@group\pgftransparencygroup\fi% + \iftikz@transparency@group\expandafter\pgftransparencygroup\expandafter[\tikz@transparency@group@options]\tikz@blend@group\fi% \expandafter\tikz@atbegin@scope% \tikz@lib@scope@check% } @@ -1386,6 +1725,31 @@ \tikz@lib@scope@check% } + +\def\tikz@scoped{\pgfutil@ifnextchar[{\tikz@scoped@opt}{\tikz@scoped@opt[]}} +\def\tikz@scoped@opt[#1]{\scope[#1]\pgfutil@ifnextchar\bgroup{\tikz@scoped@}{\tikz@scoped@@single}} +\def\tikz@scoped@{\bgroup\tikz@auto@end@pathtrue\aftergroup\endscope\let\pgf@temp=} +\def\tikz@scoped@@single#1{% + \expandafter\ifx\csname tikz@scoped@protected@command\string#1\endcsname\relax% + \expandafter\tikz@scoped@@% + \else% + \begingroup\def\tikz@scoped@path@do@at@end{\endgroup\endscope}% + \fi% + #1% +} +\def\tikz@scoped@@{% + \let\tikz@scoped@next=\tikz@scoped@collectnormalsemicolon% + \ifnum\the\catcode`\;=\active\relax% + \let\tikz@scoped@next=\tikz@scoped@collectactivesemicolon% + \fi% + \tikz@scoped@next} +\def\tikz@scoped@collectnormalsemicolon#1;{#1;\endscope} +{ + \catcode`\;=\active + \gdef\tikz@scoped@collectactivesemicolon#1;{#1;\endscope} +} + + % Install a shortcut command which is only valid inside of a % tikzpicture. % @@ -1396,7 +1760,7 @@ % #2: real command name \def\tikzaddtikzonlycommandshortcutlet#1#2{% \expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands - \let#1=#2 + \let#1=#2% }% }% @@ -1412,10 +1776,8 @@ % Install the abbreviated commands % \def\tikz@installcommands{% - \ifnum\the\catcode`\;=\active\relax\expandafter\let\expandafter\tikz@origsemi\expandafter=\tikz@activesemicolon\fi% - \ifnum\the\catcode`\:=\active\relax\expandafter\let\expandafter\tikz@origcolon\expandafter=\tikz@activecolon\fi% - \ifnum\the\catcode`\|=\active\relax\expandafter\let\expandafter\tikz@origbar\expandafter=\tikz@activebar\fi% \let\tikz@origscope=\scope% + \let\tikz@origscoped=\scoped% \let\tikz@origendscope=\endscope% \let\tikz@origstartscope=\startscope% \let\tikz@origstopscope=\stopscope% @@ -1430,15 +1792,15 @@ \let\tikz@origclip=\clip% \let\tikz@origuseasboundingbox=\useasboundingbox% \let\tikz@orignode=\node% + \let\tikz@origpic=\pic% \let\tikz@origcoordinate=\coordinate% \let\tikz@origmatrix=\matrix% \let\tikz@origcalendar=\calendar% \let\tikz@origdv=\datavisualization% \let\tikz@origgraph=\graph% % - \tikz@deactivatthings% - % \let\scope=\tikz@scope@env% + \let\scoped=\tikz@scoped% \let\endscope=\endtikz@scope@env% \let\startscope=\scope% \let\stopscope=\endscope% @@ -1455,16 +1817,17 @@ \def\graph{\path graph} \def\useasboundingbox{\path[use as bounding box]} \def\node{\tikz@path@overlay{node}} + \def\pic{\tikz@path@overlay{pic}} \def\coordinate{\tikz@path@overlay{coordinate}} \def\matrix{\tikz@path@overlay{node[matrix]}} \def\calendar{\tikz@lib@cal@calendar}% \def\datavisualization{\tikz@lib@datavisualization}% } \ifx\tikz@lib@cal@calendar\@undefined -\def\tikz@lib@cal@calendar{\PackageError{tikz}{You need to say \string\usetikzlibrary{calendar} to use the \string\calendar{} command}{}} +\def\tikz@lib@cal@calendar{\tikzerror{You need to say \string\usetikzlibrary{calendar} to use the \string\calendar{} command}} \fi \ifx\tikz@lib@datavisualization\@undefined -\def\tikz@lib@datavisualization{\PackageError{tikz}{You need to say \string\usetikzlibrary{datavisualization} to use the \string\datavisualization{} command}{}} +\def\tikz@lib@datavisualization{\tikzerror{You need to say \string\usetikzlibrary{datavisualization} to use the \string\datavisualization{} command}} \fi \def\tikz@path@overlay#1{% @@ -1473,10 +1836,8 @@ \def\tikz@path@overlayed#1<#2>{\path<#2> #1} \def\tikz@uninstallcommands{% - \ifnum\the\catcode`\;=\active\relax\expandafter\let\tikz@activesemicolon=\tikz@origsemi\fi% - \ifnum\the\catcode`\:=\active\relax\expandafter\let\tikz@activecolon=\tikz@origcolon\fi% - \ifnum\the\catcode`\|=\active\relax\expandafter\let\tikz@activebar=\tikz@origbar\fi% \let\scope=\tikz@origscope% + \let\scoped=\tikz@origscoped% \let\endscope=\tikz@origendscope% \let\startscope=\tikz@origstartscope% \let\stopscope=\tikz@origstopscope% @@ -1491,6 +1852,7 @@ \let\clip=\tikz@origclip% \let\useasboundingbox=\tikz@origuseasboundingbox% \let\node=\tikz@orignode% + \let\pic=\tikz@origpic% \let\coordinate=\tikz@origcoordinate% \let\matrix=\tikz@origmatrix% \let\calendar=\tikz@origcalendar% @@ -1517,16 +1879,49 @@ \gdef\tikz@activecolon{:}% \gdef\tikz@activebar{|}% \gdef\tikz@activequotes{"}% + \global\let\tikz@active@quotes@token="% \gdef\tikz@activeexlmark{!}% \gdef\tikz@deactivatthings{% \def;{\tikz@nonactivesemicolon}% \def:{\tikz@nonactivecolon}% \def|{\tikz@nonactivebar}% - \def!{\tikz@nonactiveexlmark}% + \def!{\tikz@nonactiveexlmark}% } } - +\let\tikz@orig@shorthands\pgfutil@empty +\def\tikz@switchoff@shorthands{% + \ifx\tikz@orig@shorthands\pgfutil@empty% + \edef\tikz@orig@shorthands{% + \catcode\noexpand`\noexpand\;\the\catcode`\;\relax% + \catcode\noexpand`\noexpand\:\the\catcode`\:\relax% + \catcode\noexpand`\noexpand\|\the\catcode`\|\relax% + \catcode\noexpand`\noexpand\!\the\catcode`\!\relax% + \catcode\noexpand`\noexpand\,\the\catcode`\,\relax% + \catcode\noexpand`\noexpand\<\the\catcode`\<\relax% + \catcode\noexpand`\noexpand\>\the\catcode`\>\relax% + \catcode\noexpand`\noexpand\"\the\catcode`\"\relax% + \catcode\noexpand`\noexpand\'\the\catcode`\'\relax% + \catcode\noexpand`\noexpand\-\the\catcode`\-\relax% + \catcode\noexpand`\noexpand\=\the\catcode`\=\relax% + \catcode\noexpand`\noexpand\.\the\catcode`\.\relax% + \catcode\noexpand`\noexpand\$\the\catcode`\$\relax% + }% + \catcode`\;12\relax% + \catcode`\:12\relax% + \catcode`\|12\relax% + \catcode`\!12\relax% + \catcode`\,12\relax% + \catcode`\<12\relax% + \catcode`\>12\relax% + \catcode`\"12\relax% + \catcode`\'12\relax% + \catcode`\-12\relax% + \catcode`\=12\relax% + \catcode`\.12\relax% + \catcode`\$3\relax% + \fi% +} @@ -1557,11 +1952,14 @@ \def\tikz@@command@path{% \edef\tikzscope@linewidth{\the\pgflinewidth}% \begingroup% + \setbox\tikz@figbox=\box\pgfutil@voidb@x% + \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x% \let\tikz@path@do@at@end=\tikz@lib@scope@check% \let\tikz@options=\pgfutil@empty% \let\tikz@mode=\pgfutil@empty% \let\tikz@moveto@waiting=\relax% \let\tikz@timer=\relax% + \let\tikz@tangent=\relax% \let\tikz@collected@onpath=\pgfutil@empty% \let\tikz@preactions=\pgfutil@empty% \let\tikz@postactions=\pgfutil@empty% @@ -1569,6 +1967,8 @@ \tikz@decoratepathfalse% \tikz@node@is@a@labelfalse% \tikz@expandcount=100\relax% + \pgf@path@lastx=0pt% + \pgf@path@lasty=0pt% \tikz@lastx=0pt% \tikz@lasty=0pt% \tikz@lastxsaved=0pt% @@ -1581,44 +1981,44 @@ \else% \tikz@invoke@collected@onpath% \fi% - \afterassignment\tikz@handle\let\@let@token=% + \afterassignment\tikz@handle\let\pgf@let@token=% } \newcount\tikz@expandcount % Central dispatcher for commands \def\tikz@handle{% \let\@next=\tikz@expand% - \ifx\@let@token(%) + \ifx\pgf@let@token(%) \let\@next=\tikz@movetoabs% \else% - \ifx\@let@token+% + \ifx\pgf@let@token+% \let\@next=\tikz@movetorel% \else% - \ifx\@let@token-% + \ifx\pgf@let@token-% \let\@next=\tikz@lineto% \else% - \ifx\@let@token.% + \ifx\pgf@let@token.% \let\@next=\tikz@dot% \else% - \ifx\@let@token r% + \ifx\pgf@let@token r% \let\@next=\tikz@rect% \else% - \ifx\@let@token n% + \ifx\pgf@let@token n% \let\@next=\tikz@fig% \else% - \ifx\@let@token[%] + \ifx\pgf@let@token[%] \let\@next=\tikz@parse@options% \else% - \ifx\@let@token c% + \ifx\pgf@let@token c% \let\@next=\tikz@cchar% \else% - \ifx\@let@token\bgroup% + \ifx\pgf@let@token\bgroup% \let\@next=\tikz@beginscope% \else% - \ifx\@let@token\egroup% + \ifx\pgf@let@token\egroup% \let\@next=\tikz@endscope% \else% - \ifx\@let@token;% + \ifx\pgf@let@token;% \let\@next=\tikz@finish% \else% \let\@next=\tikz@handle@more% @@ -1638,47 +2038,51 @@ % Continued... \def\tikz@handle@more{% - \ifx\@let@token a% + \ifx\pgf@let@token a% \let\@next=\tikz@arcA% \else% - \ifx\@let@token e% + \ifx\pgf@let@token e% \let\@next=\tikz@e@char% \else% - \ifx\@let@token g% + \ifx\pgf@let@token g% \let\@next=\tikz@g@char% \else% - \ifx\@let@token s% + \ifx\pgf@let@token s% \let\@next=\tikz@schar% \else% - \ifx\@let@token |% + \ifx\pgf@let@token |% \let\@next=\tikz@vh@lineto% \else% - \ifx\@let@token p% + \ifx\pgf@let@token p% \let\@next=\tikz@pchar% \pgfsetmovetofirstplotpoint% \else% - \ifx\@let@token t% + \ifx\pgf@let@token t% \let\@next=\tikz@to% \else% - \ifx\@let@token\pgfextra% + \ifx\pgf@let@token\pgfextra% \let\@next=\tikz@extra% \else% - \ifx\@let@token\foreach% + \ifx\pgf@let@token\foreach% \let\@next=\tikz@foreach% \else% - \ifx\@let@token\pgf@stop% - \let\@next=\relax% + \ifx\pgf@let@token f% + \let\@next=\tikz@fchar% \else% - \ifx\@let@token\par% - \let\@next=\tikz@scan@next@command% + \ifx\pgf@let@token\pgf@stop% + \let\@next=\relax% \else% - \ifx\@let@token d% - \let\@next=\tikz@decoration% + \ifx\pgf@let@token\par% + \let\@next=\tikz@scan@next@command% \else% - \ifx\@let@token l% - \let\@next=\tikz@l@char%\tikz@let@command% + \ifx\pgf@let@token d% + \let\@next=\tikz@decoration% \else% - \let\@next=\tikz@expand% + \ifx\pgf@let@token l% + \let\@next=\tikz@l@char%\tikz@let@command% + \else% + \let\@next=\tikz@expand% + \fi% \fi% \fi% \fi% @@ -1692,6 +2096,7 @@ \fi% \fi% \fi% + \ifx\@next\tikz@expand\else\tikz@expandcount=100\relax\fi% \@next% } @@ -1704,16 +2109,14 @@ } \def\tikz@lsystem{% - \PackageError{tikz}{You need to say \string\usetikzlibrary{lindenmayersystems} to - draw Lindenmayer systems}{} + \tikzerror{You need to say \string\usetikzlibrary{lindenmayersystems} to draw Lindenmayer systems} } \def\tikz@@lsystem{% - \PackageError{tikz}{You need to say \string\usetikzlibrary{lindenmayersystems} to - draw L-systems}{} + \tikzerror{You need to say \string\usetikzlibrary{lindenmayersystems} to draw L-systems} } -\def\tikz@pchar{\pgfutil@ifnextchar l{\tikz@plot}{\tikz@parabola}} +\def\tikz@pchar{\pgfutil@ifnextchar l{\tikz@plot}{\pgfutil@ifnextchar i{\tikz@subpicture}{\tikz@parabola}}} \def\tikz@cchar{% \pgfutil@ifnextchar i{\tikz@circle}% {\pgfutil@ifnextchar h{\tikz@children}{\tikz@cochar}}}% @@ -1729,24 +2132,27 @@ \def\tikz@g@char r{\pgfutil@ifnextchar i{\tikz@grid}{\tikz@graph}} % svg syntax -% svg[options] "..." +% svg[options] {...} \def\tikz@svg@path{% - \PackageError{tikz}{You need to say \string\usetikzlibrary{svg.path} to - use the svg path command}{} + \tikzerror{You need to say \string\usetikzlibrary{svg.path} to use the svg path command} } \def\tikz@finish{% % Rendering pipeline % - % Step 1: Decorate path + % Step 1: The path background box + % + \box\tikz@figbox@bg% + % + % Step 2: Decorate path % \iftikz@decoratepath% \tikz@lib@dec@decorate@path% \fi% % - % Step 1: Preactions + % Step 3: Preactions % \pgfsyssoftpath@getcurrentpath\tikz@actions@path% \edef\tikz@restorepathsize{% @@ -1757,7 +2163,7 @@ }% \tikz@preactions% % - % Reset modes + % Step 4: Reset modes % \let\tikz@path@picture=\pgfutil@empty% \tikz@mode@fillfalse% @@ -1776,20 +2182,27 @@ \iftikz@mode@fade@path% \tikz@addoption{% \iftikz@fade@adjust% - \pgfsetfadingforcurrentpath{\tikz@path@fading}{\tikz@do@fade@transform}% + \iftikz@mode@draw% + \pgfsetfadingforcurrentpathstroked{\tikz@path@fading}{\tikz@do@fade@transform}% + \else% + \pgfsetfadingforcurrentpath{\tikz@path@fading}{\tikz@do@fade@transform}% + \fi% \else% \pgfsetfading{\tikz@path@fading}{\tikz@do@fade@transform}% \fi% \tikz@mode@fade@pathfalse% no more fading... }% \fi% - % Rendering pipeline % - % Step 2: Install scope fading + % Step 5: Install scope fading % \iftikz@mode@fade@scope% \iftikz@fade@adjust% - \pgfsetfadingforcurrentpath{\tikz@scope@fading}{\tikz@do@fade@transform}% + \iftikz@mode@draw% + \pgfsetfadingforcurrentpathstroked{\tikz@scope@fading}{\tikz@do@fade@transform}% + \else% + \pgfsetfadingforcurrentpath{\tikz@scope@fading}{\tikz@do@fade@transform}% + \fi% \else% \pgfsetfading{\tikz@scope@fading}{\tikz@do@fade@transform}% \fi% @@ -1805,7 +2218,7 @@ \tikz@options% \fi% % - % Step 4: Do a fill if shade or a path picture follows. + % Step 6: Do a fill if shade or a path picture follows. % \iftikz@mode@fill% \iftikz@mode@shade% @@ -1828,7 +2241,7 @@ \fi% \fi% % - % Step 5: Do a shade if necessary. + % Step 7: Do a shade if necessary. % \iftikz@mode@shade% \pgfsyssoftpath@getcurrentpath\tikz@temppath @@ -1838,7 +2251,7 @@ \tikz@mode@shadefalse% no more shading... \fi% % - % Step 5a: Do a path picture if necessary. + % Step 8: Do a path picture if necessary. % \ifx\tikz@path@picture\pgfutil@empty% \else% @@ -1866,7 +2279,7 @@ \let\tikz@path@picture=\pgfutil@empty% \fi% % - % Step 6: Double stroke, if necessary + % Step 9: Double stroke, if necessary % \iftikz@mode@draw% \iftikz@mode@double% @@ -1877,17 +2290,17 @@ \fi% \fi% % - % Step 7: Do stroke/fill/clip as needed + % Step 10: Do stroke/fill/clip as needed % \edef\tikz@temp{\noexpand\pgfusepath{% \iftikz@mode@fill fill,\fi% \iftikz@mode@draw draw,\fi% - \iftikz@mode@clip clip,\fi% + \iftikz@mode@clip clip\fi% }}% \tikz@temp% \tikz@mode@fillfalse% no more filling % - % Step 8: Double stroke, if necessary + % Step 11: Double stroke, if necessary % \iftikz@mode@draw% \iftikz@mode@double% @@ -1897,22 +2310,22 @@ \fi% \tikz@mode@drawfalse% no more stroking % - % Step 9: Postactions + % Step 12: Postactions % \tikz@postactions% % - % Step 10: Add labels and nodes + % Step 13: Add labels and nodes % \box\tikz@figbox% % - % Step 11: Close option brace + % Step 14: Close option brace % \ifx\tikz@options\pgfutil@empty% \else% \endgroup% \pgfsys@endscope% \iftikz@mode@clip% - \PackageError{tikz}{Extra options not allowed for clipping path command.}{}% + \tikzerror{Extra options not allowed for clipping path command.}% \fi% \fi% \iftikz@mode@clip% @@ -1934,6 +2347,7 @@ {% \pgfsys@beginscope% \setbox\tikz@figbox=\box\pgfutil@voidb@x% + \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x% \path[#1];% do extra path \pgfsyssoftpath@setcurrentpath\tikz@actions@path% restore \tikz@restorepathsize% @@ -1945,6 +2359,7 @@ {% \pgfsys@beginscope% \setbox\tikz@figbox=\box\pgfutil@voidb@x% + \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x% \tikz@restorepathsize% \path[#1]\pgfextra{\pgfsyssoftpath@setcurrentpath\tikz@actions@path};% do extra path \pgf@resetpathsizes% @@ -1958,7 +2373,7 @@ \def\tikz@expand{% \advance\tikz@expandcount by -1% \ifnum\tikz@expandcount<0\relax% - \PackageError{tikz}{Giving up on this path. Did you forget a semicolon?}{}% + \tikzerror{Giving up on this path. Did you forget a semicolon?}% \let\@next=\tikz@finish% \else% \let\@next=\tikz@@expand @@ -1966,7 +2381,7 @@ \@next} \def\tikz@@expand{% - \expandafter\tikz@scan@next@command\@let@token} + \expandafter\tikz@scan@next@command\pgf@let@token} @@ -1981,6 +2396,8 @@ } \def\tikz@@endscope{% \global\setbox\tikz@tempbox=\box\tikz@figbox% + \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg% + \global\let\tikz@tangent@temp\tikz@tangent% \edef\tikz@marshal{% \tikz@lastx=\the\tikz@lastx% \tikz@lasty=\the\tikz@lasty% @@ -2004,6 +2421,8 @@ \expandafter% \endgroup\tikz@marshal% \setbox\tikz@figbox=\box\tikz@tempbox% + \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg% + \let\tikz@tangent\tikz@tangent@temp% \tikz@scan@next@command} @@ -2018,33 +2437,50 @@ \def\pgfextra{pgfextra} -% Syntax for \foreach: +% Syntax for foreach: +% +% foreach \var in {list} {path text} +% +% or +% % \foreach \var in {list} {path text} % % Example: % % \draw (0,0) \foreach \x in {1,2,3} {-- (\x,0) circle (1cm)} -- (5,5); +\def\tikz@fchar oreach{\tikz@foreach} + \def\tikz@foreach{% \def\pgffor@beginhook{% \tikz@lastx=\tikz@foreach@save@lastx% \tikz@lasty=\tikz@foreach@save@lasty% \tikz@lastxsaved=\tikz@foreach@save@lastxsaved% \tikz@lastysaved=\tikz@foreach@save@lastysaved% - \setbox\tikz@figbox=\box\tikz@tempbox\expandafter\tikz@scan@next@command\pgfutil@firstofone}% + \setbox\tikz@figbox=\box\tikz@tempbox% + \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg% + \expandafter\tikz@scan@next@command\pgfutil@firstofone}% \def\pgffor@endhook{\pgfextra{% \xdef\tikz@foreach@save@lastx{\the\tikz@lastx}% \xdef\tikz@foreach@save@lasty{\the\tikz@lasty}% \xdef\tikz@foreach@save@lastxsaved{\the\tikz@lastxsaved}% \xdef\tikz@foreach@save@lastysaved{\the\tikz@lastysaved}% - \global\setbox\tikz@tempbox=\copy\tikz@figbox\pgfutil@gobble}}% + \global\setbox\tikz@tempbox=\box\tikz@figbox% + \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg% + \pgfutil@gobble}}% \def\pgffor@afterhook{% \tikz@lastx=\tikz@foreach@save@lastx% \tikz@lasty=\tikz@foreach@save@lasty% \tikz@lastxsaved=\tikz@foreach@save@lastxsaved% \tikz@lastysaved=\tikz@foreach@save@lastysaved% - \setbox\tikz@figbox=\box\tikz@tempbox\tikz@scan@next@command}% - \global\setbox\tikz@tempbox=\copy\tikz@figbox% + \let\pgffor@beginhook\relax% + \let\pgffor@endhook\relax% + \let\pgffor@afterhook\relax% + \setbox\tikz@figbox=\box\tikz@tempbox% + \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg% + \tikz@scan@next@command}% + \global\setbox\tikz@tempbox=\box\tikz@figbox% + \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg% \xdef\tikz@foreach@save@lastx{\the\tikz@lastx}% \xdef\tikz@foreach@save@lasty{\the\tikz@lasty}% \xdef\tikz@foreach@save@lastxsaved{\the\tikz@lastxsaved}% @@ -2085,7 +2521,7 @@ \tikz@make@last@position{#1}% \iftikz@shapeborder% % ok, the moveto will have to wait. flag that we have a moveto in - % wainting: + % waiting: \edef\tikz@moveto@waiting{\tikz@shapeborder@name}% \else% \pgfpathmoveto{\tikz@last@position}% @@ -2126,7 +2562,9 @@ % Collecting labels on the path % -\def\tikz@collect@coordinate@onpath#1coordinate{% +\def\tikz@collect@coordinate@onpath#1c{% + \pgfutil@ifnextchar y{\tikz@cycle@expander@add#1}{\tikz@collect@coordinate@onpath@{#1}}} +\def\tikz@collect@coordinate@onpath@#1oordinate{% \pgfutil@ifnextchar[{\tikz@@collect@coordinate@opt#1}{\tikz@@collect@coordinate@opt#1[]}}%} \def\tikz@@collect@coordinate@opt#1[#2]{% \pgfutil@ifnextchar({\tikz@@collect@coordinate#1[#2]}{% @@ -2134,30 +2572,61 @@ \def\tikz@@collect@coordinate#1[#2](#3){% \tikz@collect@label@onpath#1node[shape=coordinate,#2](#3){}} +\newif\iftikz@collect@pic + \def\tikz@collect@label@onpath#1node{% \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath node}% - \tikz@collect@label@scan#1} - -\def\tikz@collect@label@scan#1{% - \pgfutil@ifnextchar({\tikz@collect@paran#1}% - {\pgfutil@ifnextchar[{\tikz@collect@options#1}% - {\pgfutil@ifnextchar\bgroup{\tikz@collect@arg#1}% - {#1}}}% + \let\tikz@collect@cont#1% + \tikz@collect@picfalse% + \tikz@collect@label@scan} + +\def\tikz@collect@pic@onpath#1pic{% + \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath pic}% + \let\tikz@collect@cont#1 + \tikz@collect@pictrue% + \tikz@collect@label@scan} + +\def\tikz@collect@label@scan{% + \pgfutil@ifnextchar f{\tikz@collect@nodes}{% + \pgfutil@ifnextchar({\tikz@collect@paran}% + {\pgfutil@ifnextchar[{\tikz@collect@options}% + {\pgfutil@ifnextchar\bgroup{\tikz@collect@arg}% + {\tikz@collect@cont}}}}% }%}} -\def\tikz@collect@paran#1(#2){% - \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath(#2)}% - \tikz@collect@label@scan#1% +\def\tikz@collect@nodes foreach#1in{% + \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath foreach#1in}% + \pgfutil@ifnextchar\bgroup\tikz@collect@nodes@group\tikz@collect@nodes@one% } -\def\tikz@collect@options#1[#2]{% - \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath[#2]}% - \tikz@collect@label@scan#1% +\def\tikz@collect@nodes@one#1{% + \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath #1}% + \tikz@collect@label@scan% } -\def\tikz@collect@arg#1#2{% - \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath{#2}}% - #1% +\def\tikz@collect@nodes@group#1{% + \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath{#1}}% + \tikz@collect@label@scan% } +\def\tikz@collect@paran#1){% + \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath#1)}% + \tikz@collect@label@scan% +} +\def\tikz@collect@options#1]{% + \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath#1]}% + \tikz@collect@label@scan% +} +\def\tikz@collect@arg#1{% + \iftikz@handle@active@nodes% + \iftikz@collect@pic% + \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath{#1}}% + \else% + \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath{\scantokens{#1}}}% + \fi% + \else% + \expandafter\def\expandafter\tikz@collected@onpath\expandafter{\tikz@collected@onpath{#1}}% + \fi% + \tikz@collect@cont% +} \def\tikz@invoke@collected@onpath{% \tikz@node@is@a@labeltrue% @@ -2168,6 +2637,15 @@ } +% +% Macros for the cycle command +% + +\def\tikz@cycle@expander#1{\pgfutil@ifnextchar c{\tikz@cycle@expander@{#1}}{#1}} +\def\tikz@cycle@expander@#1c{\pgfutil@ifnextchar y{\tikz@cycle@expander@add{#1}}{#1c}} +\def\tikz@cycle@expander@add#1ycle{#1(current subpath start)--cycle} + + % Syntax for lineto: @@ -2182,8 +2660,11 @@ \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@lineto@mid}% {% \pgfutil@ifnextchar c{\tikz@close}{% - \pgfutil@ifnextchar p{\pgfsetlinetofirstplotpoint\expandafter\tikz@plot\pgfutil@gobble}% - {\tikz@scan@one@point{\tikz@@lineto}}}}} + \pgfutil@ifnextchar p{\tikz@lineto@plot@or@pic}{\tikz@scan@one@point{\tikz@@lineto}}}}} +\def\tikz@lineto@plot@or@pic p{% + \pgfutil@ifnextchar i{\tikz@collect@pic@onpath\tikz@lineto@mid p}{% + \pgfsetlinetofirstplotpoint\tikz@plot}% +} \def\tikz@@lineto#1{% % Record the starting point for later labels on the path: \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}} @@ -2205,6 +2686,7 @@ \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% \fi% \let\tikz@timer=\tikz@timer@line% + \let\tikz@tangent\tikz@timer@start% \tikz@scan@next@command% } @@ -2236,14 +2718,15 @@ % -| \def\tikz@hv@lineto{% - \pgfutil@ifnextchar n - {\tikz@collect@label@onpath\tikz@hv@lineto} + \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@hv@lineto}{ + \pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@hv@lineto}% {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikz@hv@lineto}% - {\tikz@scan@one@point{\tikz@@hv@lineto}}}} + {\tikz@scan@one@point{\tikz@@hv@lineto}}}}} \def\tikz@@hv@lineto#1{% \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% \pgf@yc=\tikz@lasty% \tikz@make@last@position{#1}% + \edef\tikz@tangent{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\pgf@yc}}% \tikz@flush@moveto@toward{\pgfqpoint{\tikz@lastx}{\pgf@yc}}\pgf@x\pgf@yc% \iftikz@shapeborder% % ok, target is a shape. have to work now: @@ -2270,14 +2753,15 @@ \def\tikz@vh@lineto-{\tikz@vh@lineto@next} \def\tikz@vh@lineto@next{% - \pgfutil@ifnextchar n - {\tikz@collect@label@onpath\tikz@vh@lineto@next} + \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@vh@lineto@next}{% + \pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@vh@lineto@next}% {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikz@vh@lineto@next}% - {\tikz@scan@one@point\tikz@@vh@lineto}}} + {\tikz@scan@one@point\tikz@@vh@lineto}}}} \def\tikz@@vh@lineto#1{% \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% \pgf@xc=\tikz@lastx% \tikz@make@last@position{#1}% + \edef\tikz@tangent{\noexpand\pgfqpoint{\the\pgf@xc}{\the\tikz@lasty}}% \tikz@flush@moveto@toward{\pgfqpoint{\pgf@xc}{\tikz@lasty}}\pgf@xc\pgf@y% \iftikz@shapeborder% % ok, target is a shape. have to work now: @@ -2306,9 +2790,13 @@ {\tikz@@close c}}% \def\tikz@@close cycle{% \tikz@flush@moveto% + \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}} + \tikz@make@last@position{\expandafter\pgfpoint\pgfsyssoftpath@lastmoveto}% \tikz@path@close{\expandafter\pgfpoint\pgfsyssoftpath@lastmoveto}% \def\pgfstrokehook{}% - \let\tikz@timer=\@undefined% + \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \let\tikz@timer=\tikz@timer@line% + \let\tikz@tangent\tikz@timer@start% \tikz@scan@next@command% } @@ -2339,17 +2827,18 @@ \def\tikz@to@or@edge{\pgfutil@ifnextchar[\tikz@@to@or@edge{\tikz@@to@or@edge[]}}%} \def\tikz@@to@or@edge[#1]{% - \def\tikz@@to@local@options{[#1]}% + \def\tikz@@to@local@options{#1}% \let\tikz@collected@onpath=\pgfutil@empty% \tikz@@to@collect% } \def\tikz@@to@collect{% \pgfutil@ifnextchar(\tikz@@to@or@edge@coordinate%) {\pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@@to@collect}% - {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikz@@to@collect}% - {\pgfutil@ifnextchar +{\tikz@scan@one@point\tikz@@to@or@edge@math}% - {\PackageError{tikz}{(, +, coordinate, or node expected}{}%) - \tikz@@to@or@edge@coordinate()}}}}% + {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@@to@collect}% + {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikz@@to@collect}% + {\pgfutil@ifnextchar +{\tikz@scan@one@point\tikz@@to@or@edge@math}% + {\tikzerror{(, +, coordinate, pic, or node expected}%) + \tikz@@to@or@edge@coordinate()}}}}}% } \def\tikz@@to@or@edge@coordinate({% @@ -2376,34 +2865,43 @@ } \def\tikz@do@edge{% - \setbox\tikz@figbox=\hbox\bgroup% - \unhbox\tikz@figbox% - \hbox\bgroup - \bgroup% - \pgfinterruptpath% - \pgfscope% - \let\tikz@transform=\pgfutil@empty% - \let\tikz@options=\pgfutil@empty% - \let\tikz@tonodes=\tikz@collected@onpath% - \def\tikztonodes{{\pgfextra{\tikz@node@is@a@labeltrue}\tikz@tonodes}}% - \let\tikz@collected@onpath=\pgfutil@empty% - \tikz@options% - \tikz@transform% - % Typeset node: - \let\tikz@after@path\pgfutil@empty% - \tikz@atbegin@to% - \path[style=every edge]\tikz@@to@local@options(\tikztostart)\tikz@to@path - \pgfextra{\global\let\tikz@after@path@smuggle=\tikz@after@path};% - \tikz@atend@to% - \endpgfscope% - \endpgfinterruptpath% - \egroup + \ifx\tikz@edge@macro\pgfutil@empty% + \setbox\tikz@whichbox=\hbox\bgroup% + \unhbox\tikz@whichbox% + \hbox\bgroup + \bgroup% + \pgfinterruptpath% + \pgfscope% + \let\tikz@transform=\pgfutil@empty% + \let\tikz@options=\pgfutil@empty% + \let\tikz@tonodes=\tikz@collected@onpath% + \def\tikztonodes{{\pgfextra{\tikz@node@is@a@labeltrue}\tikz@tonodes}}% + \let\tikz@collected@onpath=\pgfutil@empty% + \tikz@options% + \tikz@transform% + \let\tikz@transform=\relax% + % Typeset node: + \let\tikz@after@path\pgfutil@empty% + \tikz@atbegin@to% + \tikz@enable@edge@quotes% + \path[style=every edge]\expandafter[\tikz@@to@local@options](\tikztostart)\tikz@to@path + \pgfextra{\global\let\tikz@after@path@smuggle=\tikz@after@path};% + \tikz@atend@to% + \endpgfscope% + \endpgfinterruptpath% + \egroup + \egroup% \egroup% - \egroup% - \global\setbox\tikz@tempbox=\copy\tikz@figbox% - \endgroup% - \setbox\tikz@figbox=\box\tikz@tempbox% - \expandafter\tikz@scan@next@command\tikz@after@path% + \global\setbox\tikz@tempbox=\box\tikz@whichbox% + \expandafter\endgroup% + \expandafter\setbox\tikz@whichbox=\box\tikz@tempbox% + \else% + \expandafter\expandafter\expandafter\tikz@edge@macro% + \expandafter\expandafter\expandafter{\expandafter\tikz@@to@local@options\expandafter}\expandafter{\tikz@collected@onpath}% + \endgroup% + \let\tikz@after@path@smuggle=\pgfutil@empty% + \fi% + \expandafter\tikz@scan@next@command\tikz@after@path@smuggle% } \def\tikz@do@to{% @@ -2414,7 +2912,8 @@ {% \pgfextra{\let\tikz@after@path\pgfutil@empty}% \pgfextra{\tikz@atbegin@to}% - [style=every to]\tikz@@to@local@options\tikz@to@path% + \pgfextra{\tikz@enable@edge@quotes}% + [style=every to]\expandafter[\tikz@@to@local@options]\tikz@to@path% \pgfextra{\tikz@atend@to}% \pgf@stop% \expandafter\tikz@scan@next@command\expandafter% @@ -2443,8 +2942,7 @@ \def\tikz@lib@graph@parser{\pgfutil@ifnextchar[\tikz@graph@error{\tikz@graph@error[]}}%] \def\tikz@graph@error[#1]#2{% - \PackageError{tikz}{You need to say \string\usetikzlibrary{graph} in - order to use the graph syntax}{}% + \tikzerror{You need to say \string\usetikzlibrary{graphs} in order to use the graph syntax}% \tikz@lib@graph@parser@done% } @@ -2460,8 +2958,23 @@ \def\tikz@edgetoparent from parent{\pgfutil@ifnextchar[\tikz@@edgetoparent{\tikz@@edgetoparent[]}}%} \def\tikz@@edgetoparent[#1]{% \let\tikz@edge@to@parent@needed=\pgfutil@empty% - \tikz@node@is@a@labeltrue% - \tikz@scan@next@command [style=edge from parent,#1] \tikz@edge@to@parent@path% + \def\tikz@edgetoparent@options{#1}% + \begingroup% + \let\tikz@collected@onpath=\pgfutil@empty% + \tikz@edgetoparentcollect% +} +\def\tikz@edgetoparentcollect{ + \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@edgetoparentcollect}% + {% + \expandafter% + \endgroup% + \expandafter\tikz@edgetoparent@rollout\expandafter{\tikz@collected@onpath}% + } +} + +\def\tikz@edgetoparent@rollout#1{% + \pgfkeysgetvalue{/tikz/edge from parent macro}\tikz@etop@temp + \expandafter\tikz@scan@next@command\expandafter\tikz@etop@temp\expandafter{\tikz@edgetoparent@options}{#1}% } @@ -2472,9 +2985,10 @@ \def\tikz@dot.{\tikz@@dot}% \def\tikz@@dot{% - \pgfutil@ifnextchar n% - {\tikz@collect@label@onpath\tikz@@dot}% - {\pgfutil@ifnextchar c{\tikz@curveto@double}{\tikz@curveto@auto}}} + \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@@dot}{% + \pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@@dot}% + {\pgfutil@ifnextchar c{\tikz@curveto@double}{\tikz@curveto@auto}}}% +} \def\tikz@curveto@double co{% \pgfutil@ifnextchar o{\tikz@collect@coordinate@onpath\tikz@@dot co} @@ -2485,6 +2999,8 @@ \def\tikz@curveA#1{% \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% {% + \tikz@lastxsaved=\tikz@lastx% + \tikz@lastysaved=\tikz@lasty% \tikz@make@last@position{#1}% \xdef\tikz@curve@first{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% }% @@ -2503,16 +3019,16 @@ \def\tikz@curveCdot.{% \ifx\@next.% \else% - \PackageError{tikz}{Dot expected}{}% + \tikzerror{Dot expected}% \fi% \tikz@updatecurrenttrue% \tikz@curveCcheck% } \def\tikz@curveCcheck{% - \pgfutil@ifnextchar n% - {\tikz@collect@label@onpath\tikz@curveCcheck} + \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@curveCcheck}{% + \pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@curveCcheck}% {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikz@curveCcheck} - {\tikz@scan@one@point\tikz@curveC}}% + {\tikz@scan@one@point\tikz@curveC}}}% } \def\tikz@curveC#1{% \tikz@make@last@position{#1}% @@ -2552,7 +3068,8 @@ \let\tikz@timer@end=\tikz@curve@third \let\tikz@moveto@waiting=\relax% \fi% - \let\tikz@timer=\tikz@timer@curve% + \let\tikz@timer=\tikz@timer@curve% + \let\tikz@tangent=\tikz@curve@second% \tikz@scan@next@command% } @@ -2564,13 +3081,13 @@ \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% \tikz@@rect}% \def\tikz@@rect{% - \pgfutil@ifnextchar n - {\tikz@collect@label@onpath\tikz@@rect} + \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@@rect}{% + \pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@@rect}% {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikz@@rect}% { \pgf@xa=\tikz@lastx\relax% \pgf@ya=\tikz@lasty\relax% - \tikz@scan@one@point\tikz@rectB}}} + \tikz@scan@one@point\tikz@rectB}}}} \def\tikz@rectB#1{% \tikz@make@last@position{#1}% \edef\tikz@timer@end{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% @@ -2585,6 +3102,7 @@ \pgfpathclose% \pgfpathmoveto{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}% \def\pgfstrokehook{}% + \let\tikz@tangent\relax% \tikz@scan@next@command% } @@ -2599,9 +3117,10 @@ \pgfutil@ifnextchar[{\tikz@gridA}{\tikz@gridA[]}}%} \def\tikz@gridA[#1]{% \def\tikz@grid@options{#1}% - \tikz@scan@one@point\tikz@gridB}% + \tikz@cycle@expander{\tikz@scan@one@point\tikz@gridB}}% \def\tikz@gridB#1{% \tikz@make@last@position{#1}% + \let\tikz@tangent\relax% {% \let\tikz@after@path\pgfutil@empty% \expandafter\tikzset\expandafter{\tikz@grid@options} @@ -2636,6 +3155,7 @@ \tikz@flush@moveto% \pgfutil@ifnextchar[{\tikz@@plot}{\tikz@@plot[]}}%} \def\tikz@@plot[#1]{% + \let\tikz@tangent\tikz@tangent@lookup% \begingroup% \let\tikz@after@path\pgfutil@empty% \let\tikz@options=\pgfutil@empty% @@ -2644,7 +3164,7 @@ \pgfutil@ifnextchar f{\tikz@plot@f}% {\pgfutil@ifnextchar c{\tikz@plot@scan@points}% {\pgfutil@ifnextchar ({\tikz@plot@expression}{% - \PackageError{tikz}{Cannot parse this plotting data}{}% + \tikzerror{Cannot parse this plotting data}% \endgroup}}}} \def\tikz@plot@f f{\pgfutil@ifnextchar i{\tikz@plot@file}{\tikz@plot@function}} @@ -2670,11 +3190,16 @@ \def\tikz@plot@data{\pgfplotgnuplot[\tikz@plot@filename]{% set samples \tikz@plot@samples; set parametric; - plot [t=\tikz@plot@domain] #1}}% + plot [t=\tikz@plot@domain] + [\tikz@plot@xrange] + [\tikz@plot@range] + #1}}% \else% \def\tikz@plot@data{\pgfplotgnuplot[\tikz@plot@filename]{% set samples \tikz@plot@samples; - plot [x=\tikz@plot@domain] #1}}% + plot [x=\tikz@plot@domain] + \ifx\tikz@plot@range\pgfutil@empty\else[\tikz@plot@range]\fi + #1}}% \fi% \fi% \tikz@@@plot% @@ -2700,8 +3225,8 @@ \ifx\tikz@plot@mark\pgfutil@empty% \else% % Marks are drawn after the path. - \setbox\tikz@figbox=\hbox{% - \unhbox\tikz@figbox% + \setbox\tikz@whichbox=\hbox{% + \unhbox\tikz@whichbox% \hbox{{% \pgfinterruptpath% \pgfscope% @@ -2720,10 +3245,10 @@ }}% }% \fi% - \global\setbox\tikz@tempbox=\copy\tikz@figbox% + \global\setbox\tikz@tempbox=\box\tikz@whichbox% \global\let\tikz@after@path@smuggle=\tikz@after@path - \endgroup% - \setbox\tikz@figbox=\box\tikz@tempbox% + \expandafter\endgroup% + \expandafter\setbox\tikz@whichbox=\box\tikz@tempbox% \tikz@make@last@position{\tikz@@@temp}% \expandafter\tikz@scan@next@command\tikz@after@path@smuggle% } @@ -2740,8 +3265,9 @@ % Syntax for cosine curves: % cos -\def\tikz@cosine s{\tikz@scan@one@point\tikz@@cosine} +\def\tikz@cosine s{\tikz@cycle@expander{\tikz@scan@one@point\tikz@@cosine}} \def\tikz@@cosine#1{% + \let\tikz@tangent\tikz@tangent@lookup% \tikz@flush@moveto% \pgf@process{#1}% \pgf@xc=\pgf@x% @@ -2759,8 +3285,9 @@ % Syntax for sine curves: % sin -\def\tikz@sine in{\tikz@scan@one@point\tikz@@sine} +\def\tikz@sine in{\tikz@cycle@expander{\tikz@scan@one@point\tikz@@sine}} \def\tikz@@sine#1{% + \let\tikz@tangent\tikz@tangent@lookup% \tikz@flush@moveto% \pgf@process{#1}% \pgf@xc=\pgf@x% @@ -2779,15 +3306,16 @@ % Syntax for parabolas: % parabola[options] bend \def\tikz@parabola arabola{% + \let\tikz@tangent\tikz@tangent@lookup% \pgfutil@ifnextchar[{\tikz@parabola@options}{\tikz@parabola@options[]}}%} \def\tikz@parabola@options[#1]{% \def\tikz@parabola@option{#1}% - \pgfutil@ifnextchar b{\tikz@parabola@scan@bend}{\tikz@scan@one@point\tikz@parabola@semifinal}} + \pgfutil@ifnextchar b{\tikz@parabola@scan@bend}{\tikz@cycle@expander{\tikz@scan@one@point\tikz@parabola@semifinal}}} \def\tikz@parabola@scan@bend bend{\tikz@scan@one@point\tikz@parabola@scan@bendB} \def\tikz@parabola@scan@bendB#1{% \def\tikz@parabola@bend{#1}% - \tikz@scan@one@point\tikz@parabola@semifinal% + \tikz@cycle@expander{\tikz@scan@one@point\tikz@parabola@semifinal}% } \def\tikz@parabola@semifinal#1{% \tikz@flush@moveto% @@ -2832,6 +3360,7 @@ \def\tikz@circle ircle{\tikz@flush@moveto\tikz@@circle} \def\tikz@ellipse llipse{\tikz@flush@moveto\tikz@@circle} \def\tikz@@circle{% + \let\tikz@tangent\relax% \pgfutil@ifnextchar(\tikz@@@circle {\pgfutil@ifnextchar[\tikz@circle@opt{%]) \advance\tikz@expandcount by -10\relax% go down quickly @@ -2883,13 +3412,13 @@ \pgfpathellipse{\pgfpointorigin}{% \pgfqpoint{\tikz@ellipse@x pt}{0pt}}{\pgfpoint{0pt}{\tikz@ellipse@y pt}}% \else% - \PackageError{tikz}{You cannot mix dimensions and dimensionless values in an ellipse}{}% + \tikzerror{You cannot mix dimensions and dimensionless values in an ellipse}% \fi% \else% \pgfmathparse{#2}% \let\tikz@ellipse@y=\pgfmathresult% \ifpgfmathunitsdeclared% - \PackageError{tikz}{You cannot mix dimensions and dimensionless values in an ellipse}{}% + \tikzerror{You cannot mix dimensions and dimensionless values in an ellipse}% \else% \pgfpathellipse{\pgfpointorigin}{% \pgfpointxy{\tikz@ellipse@x}{0}}{\pgfpointxy{0}{\tikz@ellipse@y}}% @@ -2937,11 +3466,13 @@ \ifx\tikz@e\pgfutil@empty% \pgfmathsetmacro\tikz@e{\tikz@s+\tikz@d} \fi% - \fi + \fi% + \xdef\pgf@marshal{\noexpand% \tikz@do@arc{\tikz@s}{\tikz@e} {\pgfkeysvalueof{/tikz/x radius}} - {\pgfkeysvalueof{/tikz/y radius}} + {\pgfkeysvalueof{/tikz/y radius}}}% }% + \pgf@marshal% \tikz@arcfinal% } @@ -2964,6 +3495,10 @@ \tikz@do@arc{#1}{#2}{#3}{#4}% } \def\tikz@do@arc#1#2#3#4{% + \let\tikz@tangent\tikz@tangent@lookup% + \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \edef\tikz@timer@start@angle{#1}% + \edef\tikz@timer@end@angle{#2}% \pgfmathparse{#3}% \let\tikz@arc@x=\pgfmathresult% \ifpgfmathunitsdeclared% @@ -2973,17 +3508,23 @@ \tikz@@@arcfinal{\pgfpatharc{#1}{#2}{\tikz@arc@x pt and \tikz@arc@y pt}} {\pgfpointpolar{#1}{\tikz@arc@x pt and \tikz@arc@y pt}} {\pgfpointpolar{#2}{\tikz@arc@x pt and \tikz@arc@y pt}}% + \edef\tikz@timer@zero@axis{\noexpand\pgfqpoint{\tikz@arc@x pt}{0pt}} + \edef\tikz@timer@ninety@axis{\noexpand\pgfqpoint{0pt}{\tikz@arc@y pt}} \else% - \PackageError{tikz}{You cannot mix dimensions and dimensionless values in an arc}{}% + \tikzerror{You cannot mix dimensions and dimensionless values in an arc}% \fi% \else% \pgfmathparse{#4}% \let\tikz@arc@y=\pgfmathresult% \ifpgfmathunitsdeclared% - \PackageError{tikz}{You cannot mix dimensions and dimensionless values in an arc}{}% + \tikzerror{You cannot mix dimensions and dimensionless values in an arc}% \else% \tikz@@@arcfinal{\pgfpatharcaxes{#1}{#2}{\pgfpointxy{\tikz@arc@x}{0}}{\pgfpointxy{0}{\tikz@arc@y}}} {\pgfpointpolarxy{#1}{\tikz@arc@x and \tikz@arc@y}}{\pgfpointpolarxy{#2}{\tikz@arc@x and \tikz@arc@y}}% + \pgf@process{\pgfpointxy{\tikz@arc@x}{0}} + \edef\tikz@timer@zero@axis{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}} + \pgf@process{\pgfpointxy{0}{\tikz@arc@y}} + \edef\tikz@timer@ninety@axis{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}} \fi% \fi% } @@ -3005,6 +3546,7 @@ \advance\tikz@lasty by\pgf@y% \tikz@lastxsaved=\tikz@lastx% \tikz@lastysaved=\tikz@lasty% + \let\tikz@timer=\tikz@timer@arc% \tikz@scan@next@command% } @@ -3037,20 +3579,28 @@ % Syntax for nodes: -% node[options] (node name) {label text} +% node foreach \var in {list} ... [options] (node name) at (pos) {label text} % -% all of [options], (node name) and {label text} are optional. There -% can be multiple options before the label text as in -% node[draw] (a) [rotate=10] {text} +% all of [options], (node name), at(pos), and foreach are +% optional. There can be multiple options and the ordering is not +% important as in node[draw] (a) [rotate=10] {text}, *except* that all +% foreach statements must come first. % % A label text always ``ends'' the node. +% \def\tikz@fig ode{% + \pgfutil@ifnextchar a\tikz@test@also{ + \pgfutil@ifnextchar f{\tikz@nodes@start}\tikz@normal@fig}} +\def\tikz@test@also a{\pgfutil@ifnextchar l\tikz@node@also{\tikz@normal@fig a}}% +\def\tikz@normal@fig{% \edef\tikz@save@line@width{\the\pgflinewidth}% \begingroup% \let\tikz@fig@name=\pgfutil@empty% \begingroup% \tikz@is@matrixfalse% \let\nodepart=\tikz@nodepart% + \let\tikz@atbegin@scope=\pgfutil@empty% + \let\tikz@atend@scope=\pgfutil@empty% \let\tikz@do@after@node=\tikz@scan@next@command% \let\tikz@options=\pgfutil@empty% \let\tikz@after@path=\pgfutil@empty% @@ -3061,9 +3611,12 @@ \let\tikz@postactions=\pgfutil@empty% \let\tikz@alias=\pgfutil@empty% \def\tikz@node@at{\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}% + \let\tikz@time@for@matrix\tikz@time% + \let\tikz@node@content\relax% + \pgfgetpath\tikzpathuptonow% \iftikz@node@is@a@label% \else% - \let\tikz@time=\pgfutil@empty% + \let\tikz@time\pgfutil@empty% \fi% \tikz@node@reset@hook% \tikzset{every node/.try}% @@ -3073,7 +3626,7 @@ {\pgfutil@ifnextchar({\tikz@fig@scan@name} {\pgfutil@ifnextchar[{\tikz@fig@scan@options}% {\pgfutil@ifnextchar\bgroup{\tikz@fig@main}% - {\PackageError{tikz}{A node must have a (possibly empty) label text}{}% + {\tikzerror{A node must have a (possibly empty) label text}% \tikz@fig@main{}}}}}}%}} \def\tikz@fig@scan@at at{% \tikz@scan@one@point\tikz@@fig@scan@at} @@ -3083,17 +3636,26 @@ \pgfkeysvalueof{/tikz/name/.@cmd}#1\pgfeov% CF : this is now ALWAYS consistent with 'name=' option; allows overrides. \tikz@@scan@fig}% % make it \long to allow \par in "pin" options etc: -\long\def\tikz@fig@scan@options[#1]{\tikzset{#1}\tikz@@scan@fig}% +\long\def\tikz@fig@scan@options[#1]{\iftikz@node@is@pic\tikz@enable@pic@quotes\else\tikz@enable@node@quotes\fi\tikzset{#1}\ifx\tikz@node@content\relax\expandafter\tikz@@scan@fig\else\tikz@expand@node@contents\fi}% +\def\tikz@expand@node@contents{% + \expandafter\tikz@@scan@fig\expandafter{\tikz@node@content}% +} \let\tikz@node@reset@hook=\pgfutil@empty% \let\tikz@node@begin@hook=\pgfutil@empty% -\def\tikz@fig@main{\afterassignment\tikz@@fig@main\let\next=} +\def\tikz@fig@main{% + \iftikz@node@is@pic% + \tikz@node@is@picfalse% + \expandafter\tikz@subpicture@handle% + \else% + \afterassignment\tikz@@fig@main\expandafter\let\expandafter\next\expandafter=% + \fi} \def\tikz@@fig@main{% \pgfutil@ifundefined{pgf@sh@s@\tikz@shape}% - {\PackageError{tikz}% - {Unknown shape ``\tikz@shape.'' Using ``rectangle'' instead}{}% + {\tikzerror{Unknown shape ``\tikz@shape.'' Using ``rectangle'' instead}% \def\tikz@shape{rectangle}}% {}% \tikzset{every \tikz@shape\space node/.try}% + \tikz@node@textfont% \tikz@node@begin@hook% \iftikz@is@matrix% \let\tikz@next=\tikz@do@matrix% @@ -3102,7 +3664,12 @@ \fi% \tikz@next% } +\let\tikz@nodepart@list\pgfutil@empty \def\tikz@do@fig{% + % Ok, reset all node part boxes + \pgfutil@for\tikz@temp:=\tikz@nodepart@list\do{% + \expandafter\setbox\csname pgfnodepart\tikz@temp box\endcsname=\box\pgfutil@voidb@x% + }% \setbox\pgfnodeparttextbox=\hbox% \bgroup% \tikzset{every text node part/.try}% @@ -3112,12 +3679,13 @@ \pgfsetstrokeopacity{\tikz@textopacity}% \fi% \pgfinterruptpicture% - \tikz@textfont% \ifx\tikz@text@width\pgfutil@empty% + \tikz@textfont% \else% \begingroup% \pgfmathsetlength{\pgf@x}{\tikz@text@width}% \pgfutil@minipage[t]{\pgf@x}\leavevmode\hbox{}% + \tikz@textfont% \tikz@text@action% \fi% \tikz@atbegin@node% @@ -3129,15 +3697,23 @@ \fi% \pgfsetcolor{.}% \setbox\tikz@figbox=\box\pgfutil@voidb@x% + \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x% \tikz@uninstallcommands% + \iftikz@handle@active@code% + \tikz@orig@shorthands% + \let\tikz@orig@shorthands\pgfutil@empty% + \fi% + \ifnum\the\catcode`\;=\active\relax\expandafter\let\tikz@activesemicolon=\tikz@origsemi\fi% + \ifnum\the\catcode`\:=\active\relax\expandafter\let\tikz@activecolon=\tikz@origcolon\fi% + \ifnum\the\catcode`\|=\active\relax\expandafter\let\tikz@activebar=\tikz@origbar\fi% \aftergroup\tikz@fig@collectresetcolor% \tikz@halign@check% \ignorespaces% } \def\tikz@fig@collectresetcolor{% - \pgfutil@ifnextchar\reset@color% - {\reset@color\afterassignment\tikz@fig@collectresetcolor\let\tikz@temp=}% - {\tikz@fig@boxdone}% + % Hacks for special packages that mess with \aftergroup + \pgfutil@ifnextchar\reset@color% hack for color package + {\reset@color\afterassignment\tikz@fig@collectresetcolor\let\tikz@temp=}\tikz@fig@boxdone% } \def\tikz@fig@boxdone{% \tikz@atend@node% @@ -3158,14 +3734,15 @@ \tikzset{every matrix/.try}% \tikz@node@transformations% \tikz@fig@mustbenamed% - \setbox\tikz@figbox=\hbox\bgroup% - \setbox\pgfutil@tempboxa=\copy\tikz@figbox% - \unhbox\pgfutil@tempboxa% + \setbox\tikz@whichbox=\hbox\bgroup% + \unhbox\tikz@whichbox% \hbox\bgroup\bgroup% \pgfinterruptpath% \pgfscope% + \ifx\tikz@time\pgfutil@empty\let\tikz@time\tikz@time@for@matrix\fi% \tikz@options% \setbox\tikz@figbox=\box\pgfutil@voidb@x% + \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x% \let\tikzmatrixname=\tikz@fig@name% \edef\tikz@m@anchor{\ifx\tikz@matrix@anchor\pgfutil@empty\tikz@anchor\else\tikz@matrix@anchor\fi}% \expandafter\pgfutil@in@\expandafter{\expandafter.\expandafter}\expandafter{\tikz@m@anchor}% @@ -3221,10 +3798,12 @@ \tikz@at@emptycell% \pgfsys@endscope% }% + \tikz@atbegin@matrix% \aftergroup\tikz@do@matrix@cont}% \bgroup% } -\def\tikz@do@matrix@cont{% +\def\tikz@do@matrix@cont{% + \tikz@atend@matrix% \endpgfscope \endpgfinterruptpath% \egroup\egroup% @@ -3270,16 +3849,17 @@ % % Node transformation % - \tikz@node@transformations - % - \setbox\tikz@figbox=\hbox{% - \setbox\pgfutil@tempboxa=\copy\tikz@figbox% - \unhbox\pgfutil@tempboxa% + \tikz@node@transformations% + \tikz@nlt% + % + \setbox\tikz@whichbox=\hbox{% + \unhbox\tikz@whichbox% \hbox{{% \pgfinterruptpath% \pgfscope% \tikz@options% \setbox\tikz@figbox=\box\pgfutil@voidb@x% + \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x% \pgfmultipartnode{\tikz@shape}{\tikz@anchor}{\tikz@fig@name}{% \pgfutil@tempdima=\pgflinewidth% {\begingroup\tikz@finish}% @@ -3303,7 +3883,7 @@ \fi% } -\def\tikz@node@transformations{ +\def\tikz@node@transformations{% % % Possibly, we are ``online'' % @@ -3325,22 +3905,35 @@ \global\let\tikz@last@fig@name=\tikz@fig@name% \global\let\tikz@after@path@smuggle=\tikz@after@path% % shift box outside group - \global\setbox\tikz@tempbox=\copy\tikz@figbox% + \global\setbox\tikz@tempbox=\box\tikz@figbox% + \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg% \endgroup\endgroup% \setbox\tikz@figbox=\box\tikz@tempbox% - \pgflinewidth=\tikz@save@line@width% + \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg% + \global\pgflinewidth=\tikz@save@line@width% + \tikz@do@after@path@smuggle% + \tikz@do@after@node% +} +\let\tikz@fig@continue@orig=\tikz@fig@continue + +\def\tikz@do@after@node{\tikz@scan@next@command} + +\def\tikz@do@after@path@smuggle{% \let\tikz@to@last@fig@name=\tikz@last@fig@name% \let\tikz@to@use@whom=\tikz@to@use@last@fig@name% \let\tikzlastnode=\tikz@last@fig@name% \ifx\tikz@after@path@smuggle\pgfutil@empty% \else% - \tikz@scan@next@command{\tikz@after@path@smuggle}\pgf@stop% + \ifpgflatenodepositioning% + \expandafter\expandafter\expandafter\tikz@call@late% + \expandafter\expandafter\expandafter{\expandafter\tikz@last@fig@name\expandafter}\expandafter{\tikz@after@path@smuggle}% + \else% + \tikz@scan@next@command{\tikz@after@path@smuggle}\pgf@stop% + \fi% \fi% - \tikz@do@after@node% } -\let\tikz@fig@continue@orig=\tikz@fig@continue -\def\tikz@do@after@node{\tikz@scan@next@command} +\def\tikz@call@late#1#2{\pgfnodepostsetupcode{#1}{\path[late options={name={#1},append after command={#2}}];}} \newif\iftikz@do@align @@ -3361,7 +3954,8 @@ \expandafter\tikz@start@align% \fi% } -\def\tikz@align@newline{\unskip\pgfutil@ifnextchar[\tikz@@align@newline{\tikz@@align@newline[0pt]}}%} +\def\tikz@align@newline{\pgfutil@protect\tikz@align@newline@} +\def\tikz@align@newline@{\unskip\pgfutil@ifnextchar[\tikz@@align@newline{\tikz@@align@newline[0pt]}}%} \def\tikz@@align@newline[#1]{\egroup\tikz@align@continue\pgfmathparse{#1}\let\tikz@align@temp=\pgfmathresult\tikz@start@align}% % Two safe boxes for alignment: \let\tikz@align@aligned@box=\pgfnodeparttextbox @@ -3399,6 +3993,16 @@ \let\tikz@@align@continue=\pgfutil@empty +\def\tikz@node@also lso{\pgfutil@ifnextchar[\tikz@node@also@opt{\tikz@node@also@opt[]}} +\def\tikz@node@also@opt[#1]{ + \pgfutil@ifnextchar(%) + {\tikz@node@also@opt@cont[#1]}% + {\tikzerror{Syntax error in node also: ``('' expected.}% + \tikz@scan@next@command}% +} +\def\tikz@node@also@opt@cont[#1](#2){\tikzset{late options={name=#2,#1}}\tikz@scan@next@command} + + % Syntax for parts of nodes: % node ... {... \nodepart[options]{name} ... \nodepart{name} ...} @@ -3414,18 +4018,29 @@ } \def\tikz@nodepart@continue{% \global\let\tikz@fig@continue=\tikz@fig@continue@orig% + \ifx\tikz@nodepart@list\pgfutil@empty% + \let\tikz@nodepart@list\tikz@nodepart@name% + \else% + \edef\tikz@nodepart@list{\tikz@nodepart@list,\tikz@nodepart@name}% + \fi% % Now start new box: \expandafter\setbox\csname pgfnodepart\tikz@nodepart@name box\endcsname=\hbox% \bgroup% \tikzset{every \tikz@nodepart@name\space node part/.try}% \expandafter\tikzset\expandafter{\tikz@nodepart@options}% + \ifx\tikz@textopacity\pgfutil@empty% + \else% + \pgfsetfillopacity{\tikz@textopacity}% + \pgfsetstrokeopacity{\tikz@textopacity}% + \fi% \pgfinterruptpicture% - \tikz@textfont% \ifx\tikz@text@width\pgfutil@empty% + \tikz@textfont% \else% \begingroup% - \pgfmathsetlength{\pgf@x}{\tikz@text@width}% + \pgfmathsetlength{\pgf@x}{\tikz@text@width}% \pgfutil@minipage[t]{\pgf@x}\leavevmode\hbox{}% + \tikz@textfont% \tikz@text@action% \fi% \bgroup% @@ -3436,13 +4051,92 @@ \fi% \pgfsetcolor{.}% \setbox\tikz@figbox=\box\pgfutil@voidb@x% + \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x% \tikz@uninstallcommands% + \iftikz@handle@active@code% + \tikz@orig@shorthands% + \let\tikz@orig@shorthands\pgfutil@empty% + \fi% + \ifnum\the\catcode`\;=\active\relax\expandafter\let\tikz@activesemicolon=\tikz@origsemi\fi% + \ifnum\the\catcode`\:=\active\relax\expandafter\let\tikz@activecolon=\tikz@origcolon\fi% + \ifnum\the\catcode`\|=\active\relax\expandafter\let\tikz@activebar=\tikz@origbar\fi% \tikz@atbegin@node% \aftergroup\tikz@fig@collectresetcolor% \tikz@halign@check% \ignorespaces% } + +% +% Node foreach +% + +\def\tikz@nodes@start{% + \let\tikz@nodes@list\pgfutil@empty% + \iftikz@node@is@pic% + \def\tikz@nodes@collect{pic }% + \else% + \def\tikz@nodes@collect{node }% + \fi% + \tikz@nodes% +} +\def\tikz@nodes foreach{\pgfutil@ifnextchar x\tikz@nodes@\tikz@nodes@}% get rid of spaces +\def\tikz@nodes@#1in{% + \expandafter\def\expandafter\tikz@nodes@list\expandafter{\tikz@nodes@list\foreach#1in}% + \pgfutil@ifnextchar\bgroup\tikz@nodes@group\tikz@nodes@one% +} +\def\tikz@nodes@one#1{% + \expandafter\def\expandafter\tikz@nodes@list\expandafter{\tikz@nodes@list#1}% + \pgfutil@ifnextchar f\tikz@nodes\tikz@nodes@scan% +} +\def\tikz@nodes@group#1{% + \expandafter\def\expandafter\tikz@nodes@list\expandafter{\tikz@nodes@list{#1}}% + \pgfutil@ifnextchar f\tikz@nodes\tikz@nodes@scan% +} +\def\tikz@nodes@scan{% + \pgfutil@ifnextchar a{\tikz@nodes@at}% + {\pgfutil@ifnextchar({\tikz@nodes@name}% + {\pgfutil@ifnextchar[{\tikz@nodes@opt}% + {\pgfutil@ifnextchar\bgroup{\tikz@nodes@main}% + {\tikzerror{Nodes must have a (possibly empty) label text}% + \tikz@fig@main{}}}}}}%}} +\def\tikz@nodes@at at#1){% + \expandafter\def\expandafter\tikz@nodes@collect\expandafter{\tikz@nodes@collect at#1)}% + \tikz@nodes@scan}% +\def\tikz@nodes@name#1){% + \expandafter\def\expandafter\tikz@nodes@collect\expandafter{\tikz@nodes@collect#1)}% + \tikz@nodes@scan}% +\def\tikz@nodes@opt#1]{% + \expandafter\def\expandafter\tikz@nodes@collect\expandafter{\tikz@nodes@collect#1]}% + \tikz@nodes@scan}% +\def\tikz@nodes@main#1{% + \iftikz@handle@active@nodes% + \iftikz@node@is@pic% + \expandafter\def\expandafter\tikz@nodes@collect\expandafter{\tikz@nodes@collect{#1}}% + \else% + \expandafter\def\expandafter\tikz@nodes@collect\expandafter{\tikz@nodes@collect{\scantokens{#1}}}% + \fi% + \else% + \expandafter\def\expandafter\tikz@nodes@collect\expandafter{\tikz@nodes@collect{#1}}% + \fi% + % Ok, got everything. + % Now, start building parse text. + \global\setbox\tikz@tempbox=\box\tikz@figbox% + \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg% + \tikz@nodes@list{% + \setbox\tikz@figbox=\box\tikz@tempbox% + \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg% + \expandafter\tikz@scan@next@command\tikz@nodes@collect\pgfextra\relax% + \global\setbox\tikz@tempbox=\box\tikz@figbox% + \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg% + }% + \setbox\tikz@figbox=\box\tikz@tempbox% + \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg% + \tikz@scan@next@command% +} + + + % % "late" options can be used to "redo" a node % @@ -3463,23 +4157,18 @@ \let\tikz@transform=\pgfutil@empty% \tikz@decoratepathfalse% \tikz@node@reset@hook% - \tikzset{every node/.try,#1}% + \tikz@enable@node@quotes% + \tikzset{every node/.try,#1}% \ifx\tikz@fig@name\pgfutil@empty% - \PackageError{tikz}{Late options must reference some existing - node}{}% + \tikzerror{Late options must reference some existing node}% \fi% \tikz@node@begin@hook% \tikz@alias% + \tikzgdlatenodeoptionacallback{\tikz@fig@name}% \global\let\tikz@last@fig@name=\tikz@fig@name% \global\let\tikz@after@path@smuggle=\tikz@after@path% \endgroup% - \let\tikz@to@last@fig@name=\tikz@last@fig@name% - \let\tikz@to@use@whom=\tikz@to@use@last@fig@name% - \let\tikzlastnode=\tikz@last@fig@name% - \ifx\tikz@after@path@smuggle\pgfutil@empty% - \else% - \tikz@scan@next@command{\tikz@after@path@smuggle}\pgf@stop% - \fi% + \tikz@do@after@path@smuggle% } @@ -3555,7 +4244,13 @@ } - +% +% Callbacks: Please see the documentation of the graph drawing +% lib for info on these callbacks +% +\def\tikzgdeventcallback#1#2{} +\def\tikzgdeventgroupcallback#1{} +\def\tikzgdlatenodeoptionacallback#1{} % Syntax for trees: % node {...} child [options] {...} child [options] {...} ... @@ -3595,39 +4290,48 @@ \long\def\tikz@children@collected{% \begingroup% \advance\tikztreelevel by 1\relax% + \tikzgdeventgroupcallback{descendants}% \let\tikz@options=\pgfutil@empty% \let\tikz@transform=\pgfutil@empty% \tikzset{level/.try=\the\tikztreelevel,level \the\tikztreelevel/.try}% \tikz@transform% + \let\tikz@transform=\relax% \let\tikzparentnode=\tikz@last@fig@name% - % Transform to center of node - \pgftransformshift{\pgfpointanchor{\tikzparentnode}{\tikz@growth@anchor}}% + \ifx\tikz@grow\relax\else% + % Transform to center of node + \pgftransformshift{\pgfpointanchor{\tikzparentnode}{\tikz@growth@anchor}}% + \fi% \tikznumberofcurrentchild=0\relax% \tikz@children@list% - \global\setbox\tikz@tempbox=\copy\tikz@figbox% + \global\setbox\tikz@tempbox=\box\tikz@figbox% + \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg% \endgroup% \setbox\tikz@figbox=\box\tikz@tempbox% + \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg% \tikz@scan@next@command% } - % Syntax for children: % % child [all children options] foreach \var in {values} [child options] {...} \def\tikz@childrennodes[#1]#2#3#4{% \c@pgf@counta=\tikznumberofcurrentchild\relax% \setbox\tikz@tempbox=\box\tikz@figbox% + \setbox\tikz@tempbox@bg=\box\tikz@figbox@bg% \foreach#2in{#3}{% \tikznumberofcurrentchild=\c@pgf@counta\relax% \setbox\tikz@figbox=\box\tikz@tempbox% + \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg% \tikz@childnode[#1]{#4}% % we must now make the current child number and the figbox survive % the group \global\c@pgf@counta=\tikznumberofcurrentchild\relax% \global\setbox\tikz@tempbox=\box\tikz@figbox% + \global\setbox\tikz@tempbox@bg=\box\tikz@figbox@bg% }% \tikznumberofcurrentchild=\c@pgf@counta\relax% \setbox\tikz@figbox=\box\tikz@tempbox% + \setbox\tikz@figbox@bg=\box\tikz@tempbox@bg% } @@ -3644,9 +4348,10 @@ \advance\tikznumberofcurrentchild by1\relax% {\tikzset{every child/.try,#1}\expandafter}% \iftikz@child@missing% + \tikzgdeventcallback{node}{}% \else% - \setbox\tikz@figbox=\hbox\bgroup% - \unhbox\tikz@figbox% + \setbox\tikz@whichbox=\hbox\bgroup% + \unhbox\tikz@whichbox% \hbox\bgroup\bgroup% \pgfinterruptpath% \pgfscope% @@ -3654,6 +4359,7 @@ \tikzset{every child/.try,#1}% \tikz@options% \tikz@transform% + \let\tikz@transform=\relax% \tikz@grow% % Typeset node: \edef\tikz@parent@node@name{[name=\tikzparentnode-\the\tikznumberofcurrentchild,style=every child node]}% @@ -3669,7 +4375,7 @@ \ifx\tikz@child@node@rest\pgfutil@empty% \path edge from parent;% \else% - \path (0,0) \tikz@child@node@rest \tikz@edge@to@parent@needed;% + \path \tikz@child@node@rest \tikz@edge@to@parent@needed;% \fi% }% \endpgfscope% @@ -3682,9 +4388,17 @@ \def\tikz@parse@child@node{% \pgfutil@ifnextchar n{\tikz@parse@child@node@n}% {\pgfutil@ifnextchar c{\tikz@parse@child@node@c}% - {\tikz@parse@child@node@rest}}} -\def\tikz@parse@child@node@rest#1\pgf@stop{\def\tikz@child@node@rest{#1}} -\def\tikz@parse@child@node@c c{\pgfutil@ifnextchar o{\tikz@parse@child@node@co}{\tikz@parse@child@node@rest c}} + {\pgfutil@ifnextchar\pgf@stop\tikz@parse@child@node@rest\tikz@parse@child@node@expand}}} +\def\tikz@parse@child@node@expand{% + \advance\tikz@expandcount by-1\relax% + \ifnum\tikz@expandcount<0\relax% + \expandafter\tikz@parse@child@node@rest% + \else% + \expandafter\expandafter\expandafter\tikz@parse@child@node% + \fi% +} +\def\tikz@parse@child@node@rest#1\pgf@stop{\tikz@expandcount=100\relax\def\tikz@child@node@rest{#1}} +\def\tikz@parse@child@node@c c{\tikz@expandcount=100\pgfutil@ifnextchar o{\tikz@parse@child@node@co}{\tikz@parse@child@node@rest c}} \def\tikz@parse@child@node@co o{\pgfutil@ifnextchar o{\tikz@parse@child@node@coordinate}{\tikz@parse@child@node@rest co}} \def\tikz@parse@child@node@coordinate ordinate{% \pgfutil@ifnextchar ({\tikz@@parse@child@node@coordinate}{% @@ -3706,7 +4420,7 @@ \expandafter\expandafter\expandafter{\expandafter\tikz@child@node@text@pre\tikz@marshal}% \tikz@parse@child@node@rest% } -\def\tikz@parse@child@node@n node{% +\def\tikz@parse@child@node@n node{\tikz@expandcount=100% \let\tikz@child@node@text=\pgfutil@empty% \tikz@p@c@s}% \def\tikz@p@c@s{% @@ -3714,7 +4428,7 @@ {\pgfutil@ifnextchar ({\tikz@p@c@s@paran} {\pgfutil@ifnextchar [{\tikz@p@c@s@bra} {\pgfutil@ifnextchar \bgroup{\tikz@p@c@s@group} - {\PackageError{tikz}{Cannot parse this node}{}}}}}}%}} + {\tikzerror{Cannot parse this node}}}}}}%}} \def\tikz@p@c@s@at at#1({% \tikz@scan@one@point\tikz@p@c@s@at@math(% } @@ -3732,8 +4446,13 @@ \expandafter\def\expandafter\tikz@child@node@text\expandafter{\tikz@child@node@text[#1]} \tikz@p@c@s} \def\tikz@p@c@s@group#1{% - \expandafter\def\expandafter\tikz@child@node@text\expandafter{\tikz@child@node@text{#1}} - \tikz@parse@child@node@rest} + \iftikz@handle@active@nodes% + \expandafter\def\expandafter\tikz@child@node@text\expandafter{\tikz@child@node@text{\scantokens{#1}}}% + \else% + \expandafter\def\expandafter\tikz@child@node@text\expandafter{\tikz@child@node@text{#1}} + \fi% + \tikz@parse@child@node@rest% +} @@ -3746,10 +4465,10 @@ \pgfutil@ifnextchar[{\tikz@lib@decoration}{\tikz@lib@decoration[]}%] } -\def\tikz@lib@decoration[#1]#2{\PackageError{tikz}{You need to load a decoration library}{}} +\def\tikz@lib@decoration[#1]#2{\tikzerror{You need to load a decoration library}} % The decorate path command: -\def\tikz@lib@dec@decorate@path{\PackageError{tikz}{You need to load a decoration library}{}} +\def\tikz@lib@dec@decorate@path{\tikzerror{You need to load a decoration library}} @@ -3759,10 +4478,121 @@ % let \p1 = (coordinate), \p2 = (coordinate),... in % \def\tikz@let@command et#1in{% - \PackageError{tikz}{You need to say \string\usetikzlibrary{calc} to use the let command}{}% + \tikzerror{You need to say \string\usetikzlibrary{calc} to use the let command}% } +% +% Syntax for pictures: +% +% as for nodes, but with "pic" instead of "node" +% +\newif\iftikz@node@is@pic +\def\tikz@subpicture ic{\tikz@node@is@pictrue\tikz@scan@next@command node} +\def\tikz@subpicture@handle#1{% + \pgfkeys@spdef\tikz@temp{#1}% + \expandafter\tikz@subpicture@handle@\expandafter{\tikz@temp}% +} +\def\tikz@subpicture@handle@#1{ + \pgfkeys{/tikz/pics/.cd,#1} + \tikz@node@transformations% + \let\tikz@transform=\relax% + \let\tikz@picmode\tikz@mode% + \tikzset{name prefix ../.style/.expanded={/tikz/name prefix=\pgfkeysvalueof{/tikz/name prefix}}}% + \ifx\tikz@fig@name\pgfutil@empty\else% + \tikzset{name prefix/.prefix/.expanded=\tikz@fig@name}% + \fi% + \pgfkeysvalueof{/tikz/pics/setup code}% + \pgfkeysgetvalue{/tikz/pics/code}{\tikz@pic@code} + \ifx\tikz@pic@code\pgfutil@empty\else% + \setbox\tikz@whichbox=\hbox\bgroup% + \unhbox\tikz@whichbox% + \hbox\bgroup + \bgroup% + \pgfinterruptpath% + \pgfscope% + \tikz@options% + \setbox\tikz@figbox=\box\pgfutil@voidb@x% + \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x% + \tikz@atbegin@scope% + \scope[every pic/.try]% + \tikz@pic@code% + \endscope% + \tikz@atend@scope% + \endpgfscope% + \endpgfinterruptpath% + \egroup + \egroup% + \egroup% + \fi% + \pgfkeysgetvalue{/tikz/pics/foreground code}{\tikz@pic@code} + \ifx\tikz@pic@code\pgfutil@empty\else% + \setbox\tikz@figbox=\hbox\bgroup% + \unhbox\tikz@figbox% + \hbox\bgroup + \bgroup% + \pgfinterruptpath% + \pgfscope% + \tikz@options% + \setbox\tikz@figbox=\box\pgfutil@voidb@x% + \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x% + \tikz@atbegin@scope% + \scope[every front pic/.try]% + \tikz@pic@code% + \endscope% + \tikz@atend@scope% + \endpgfscope% + \endpgfinterruptpath% + \egroup + \egroup% + \egroup% + \fi% + \pgfkeysgetvalue{/tikz/pics/background code}{\tikz@pic@code} + \ifx\tikz@pic@code\pgfutil@empty\else% + \setbox\tikz@figbox@bg=\hbox\bgroup% + \unhbox\tikz@figbox@bg% + \hbox\bgroup + \bgroup% + \pgfinterruptpath% + \pgfscope% + \tikz@options% + \setbox\tikz@figbox=\box\pgfutil@voidb@x% + \setbox\tikz@figbox@bg=\box\pgfutil@voidb@x% + \tikz@atbegin@scope% + \scope[every behind pic/.try]% + \tikz@pic@code% + \endscope% + \tikz@atend@scope% + \endpgfscope% + \endpgfinterruptpath% + \egroup + \egroup% + \egroup% + \fi% + \tikz@node@finish% +} +\tikzset{ + pic actions/.code=\tikz@addmode{\tikz@picmode} +} + +% Setting up the picture codes: +\tikzset{ + pics/setup code/.initial=, + pics/code/.initial=, + pics/background code/.initial=, + pics/foreground code/.initial= +} + +% Defining pictures: + +\def\tikzdeclarepic#1#2{\pgfkeys{/tikz/#1/.cd,#2}} + +\pgfkeysdef{/handlers/.pic}{% + \edef\pgf@temp{\pgfkeyscurrentpath}% + \edef\pgf@temp{\expandafter\tikz@smuggle@pics@in\pgf@temp\pgf@stop}% + \expandafter\pgfkeys\expandafter{\pgf@temp/.style={code={#1}}} +} +\def\tikz@smuggle@pics@in/tikz/#1\pgf@stop{/tikz/pics/#1} % % Timers @@ -3827,6 +4657,27 @@ } +\def\tikz@timer@arc{% + \pgfmathcos@{\tikz@timer@start@angle}% + \let\tikz@angle@cos\pgfmathresult% + \pgfmathsin@{\tikz@timer@start@angle}% + \let\tikz@angle@sin\pgfmathresult% + \pgftransformarcaxesattime{\tikz@time}{% + \pgfpointdiff{% + \pgfpointadd{% + \pgfpointscale{\tikz@angle@cos}{\tikz@timer@zero@axis}% + }{% + \pgfpointscale{\tikz@angle@sin}{\tikz@timer@ninety@axis}% + }% + }% + {\tikz@timer@start}% + }% + {\tikz@timer@zero@axis}% + {\tikz@timer@ninety@axis}% + {\tikz@timer@start@angle}{\tikz@timer@end@angle}% +} + + % % Coordinate systems @@ -3885,14 +4736,14 @@ \expandafter\ifx\csname pgf@sh@ns@\tikz@cs@node\endcsname\tikz@coordinate@text% \else \aftergroup\tikz@shapebordertrue% - \edef\tikz@shapeborder@name{\tikz@cs@node}% + \edef\tikz@shapeborder@name{\tikz@pp@name{\tikz@cs@node}}% \fi% - \pgfpointanchor{\tikz@cs@node}{center}% + \pgfpointanchor{\tikz@pp@name{\tikz@cs@node}}{center}% \else% - \pgfpointanchor{\tikz@cs@node}{\tikz@cs@angle}% + \pgfpointanchor{\tikz@pp@name{\tikz@cs@node}}{\tikz@cs@angle}% \fi% \else% - \pgfpointanchor{\tikz@cs@node}{\tikz@cs@anchor}% + \pgfpointanchor{\tikz@pp@name{\tikz@cs@node}}{\tikz@cs@anchor}% \fi% } @@ -3905,7 +4756,7 @@ \def\tikz@cs@unpack#1#2#3{% \expandafter\ifx\csname pgf@sh@ns@#3\endcsname\relax% - \PackageError{tikz}{Undefined node ``#3''}{}% + \tikzerror{Undefined node ``#3''}% \else% \def#1{#3}% \edef#2{\csname pgf@sh@ns@#3\endcsname}% @@ -3921,9 +4772,9 @@ {% \tikzset{cs/.cd,#1}% \expandafter\ifx\csname tikz@intersect@\tikz@cs@type@a @and@\tikz@cs@type@b\endcsname\relax% - \PackageError{tikz}{I do not know how to compute the intersection + \tikzerror{I do not know how to compute the intersection of a \tikz@cs@type@a and a \tikz@cs@type@b. Try saying - \string\usetikzlibrary{calc}}{}% + \string\usetikzlibrary{calc}}% \pgfpointorigin% \else% \csname tikz@intersect@\tikz@cs@type@a @and@\tikz@cs@type@b\endcsname% @@ -4047,7 +4898,7 @@ }% } \def\tikz@@scanexpand#1{\expandafter\tikz@scan@one@point\expandafter#1} -\def\tikz@@scangiveup#1{\PackageError{tikz}{Cannot parse this coordinate}{}#1{\pgfpointorigin}} +\def\tikz@@scangiveup#1{\tikzerror{Cannot parse this coordinate}#1{\pgfpointorigin}} \def\tikz@scan@@absolute#1({% \pgfutil@ifnextchar[% uhoh... options! {\def\tikz@scan@point@recall{#1}\tikz@scan@options}% @@ -4073,7 +4924,19 @@ \tikz@marshal% } +\def\tikz@ensure@dollar@catcode{% + \ifnum\catcode`\$=3 % + \else + \tikzerror{Sorry, some package has redefined the meaning of the + math-mode dollar sign. This is incompatible with tikz and its calc + library and might cause unrecoverable errors}% + % only show error once: + \global\let\tikz@ensure@dollar@catcode=\relax + \fi +}% + \def\tikz@@@scan@@absolute#1({% + \tikz@ensure@dollar@catcode \pgfutil@ifnextchar{$}%$ {\tikz@parse@calculator#1(} {\tikz@scan@no@calculator#1(}% @@ -4118,15 +4981,14 @@ } \def\tikz@parse@calculator#1($#2$){% - \PackageError{tikz}{You need to say \string\usetikzlibrary{calc} for - coordinate calculation}{}% + \tikzerror{You need to say \string\usetikzlibrary{calc} for coordinate calculation}% #1{\pgfpointorigin}% } \def\tikz@parse@coordinatesystem#1(#2 cs:#3){% \let\tikz@return@coordinate=\pgfpointorigin% \pgfutil@ifundefined{tikz@parse@cs@#2} - {\PackageError{tikz}{Unknown coordinate system '#2'}{}} + {\tikzerror{Unknown coordinate system '#2'}} {\csname tikz@parse@cs@#2\endcsname(#3)}% \expandafter#1\expandafter{\tikz@return@coordinate}% } @@ -4140,15 +5002,15 @@ \def\tikz@parse@polar#1(#2:#3){% \pgfutil@ifundefined{tikz@polar@dir@#2} - {\tikz@@parse@polar#1(#2:#3)} - {\tikz@@parse@polar#1(\csname tikz@polar@dir@#2\endcsname:#3)}% + {\tikz@@parse@polar#1({#2}:{#3})} + {\tikz@@parse@polar#1(\csname tikz@polar@dir@#2\endcsname:{#3})}% } \def\tikz@@parse@polar#1(#2:#3){% \pgfutil@in@{ and }{#3}% \ifpgfutil@in@% - \edef\tikz@args{(#2:#3)}% + \edef\tikz@args{({#2}:#3)}% \else% - \edef\tikz@args{(#2:#3 and #3)}% + \edef\tikz@args{({#2}:{#3} and {#3})}% \fi% \expandafter\tikz@@@parse@polar\expandafter#1\tikz@args% } @@ -4159,13 +5021,13 @@ \iftikz@isdimension% \def\tikz@next{#1{\pgfpointpolar{#2}{#3 and #4}}}% \else% - \PackageError{tikz}{You cannot mix dimension and dimensionless values for polar coordinates}{} + \tikzerror{You cannot mix dimension and dimensionless values for polar coordinates} \def\tikz@next{#1{\pgfpointorigin}}% \fi% \else% \tikz@checkunit{#4}% \iftikz@isdimension% - \PackageError{tikz}{You cannot mix dimension and dimensionless values for polar coordinates}{} + \tikzerror{You cannot mix dimension and dimensionless values for polar coordinates} \def\tikz@next{#1{\pgfpointorigin}}% \else% \def\tikz@next{#1{\pgfpointpolarxy{#2}{#3 and #4}}}% @@ -4246,7 +5108,7 @@ \expandafter\ifx\csname pgf@sh@ns@#2\endcsname\tikz@coordinate@text% \else \tikz@shapebordertrue% - \def\tikz@shapeborder@name{#2}% + \def\tikz@shapeborder@name{\tikz@pp@name{#2}}% \fi% \fi% \edef\tikz@marshal{\noexpand#1{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}}% @@ -4254,7 +5116,7 @@ } \def\tikz@calc@anchor#1.#2\tikz@stop{% - \pgfpointanchor{#1}{#2}% + \pgfpointanchor{\tikz@pp@name{#1}}{#2}% } @@ -4276,10 +5138,10 @@ \fi% \fi% \tikz@next#1(#2)} -\def\tikz@parse@hvboth#1(#2 -| #3){\tikz@parse@vhdone#1(#3|-#2)} -\def\tikz@parse@hvleft#1(#2 -|#3){\tikz@parse@vhdone#1(#3|-#2)} -\def\tikz@parse@hvright#1(#2-| #3){\tikz@parse@vhdone#1(#3|-#2)} -\def\tikz@parse@hvdone#1(#2-|#3){\tikz@parse@vhdone#1(#3|-#2)} +\def\tikz@parse@hvboth#1(#2 -| #3){\tikz@parse@vhdone#1({#3}|-{#2})} +\def\tikz@parse@hvleft#1(#2 -|#3){\tikz@parse@vhdone#1({#3}|-{#2})} +\def\tikz@parse@hvright#1(#2-| #3){\tikz@parse@vhdone#1({#3}|-{#2})} +\def\tikz@parse@hvdone#1(#2-|#3){\tikz@parse@vhdone#1({#3}|-{#2})} \def\tikz@parse@vh#1(#2){% \pgfutil@in@{ |- }{#2}% @@ -4299,9 +5161,9 @@ \fi% \fi% \tikz@next#1(#2)} -\def\tikz@parse@vhboth#1(#2 |- #3){\tikz@parse@vhdone#1(#2|-#3)} -\def\tikz@parse@vhleft#1(#2 |-#3){\tikz@parse@vhdone#1(#2|-#3)} -\def\tikz@parse@vhright#1(#2|- #3){\tikz@parse@vhdone#1(#2|-#3)} +\def\tikz@parse@vhboth#1(#2 |- #3){\tikz@parse@vhdone#1({#2}|-{#3})} +\def\tikz@parse@vhleft#1(#2 |-#3){\tikz@parse@vhdone#1({#2}|-{#3})} +\def\tikz@parse@vhright#1(#2|- #3){\tikz@parse@vhdone#1({#2}|-{#3})} \def\tikz@parse@vhdone#1(#2|-#3){% {% \tikz@@@scan@@absolute\tikz@parse@vh@mid(#2)% @@ -4363,6 +5225,17 @@ } + +% +% Quote handling +% + +\let\tikz@enable@node@quotes\relax +\let\tikz@enable@edge@quotes\relax +\let\tikz@enable@pic@quotes\relax + + + % Loading further libraries % Include a library file. @@ -4377,6 +5250,10 @@ % % For the convenience of Context users, both round and square brackets % are possible for the argument. +% +% If no file tikzlibraryX.code.tex exists, the file +% pgflibraryX.code.tex is tried instead. If this file, also, does not +% exist, an error message is printed. % % Example: % @@ -4388,20 +5265,32 @@ \def\use@@tikzlibrary#1{% \edef\pgf@list{#1}% \pgfutil@for\pgf@temp:=\pgf@list\do{% - \expandafter\pgfkeys@spdef\expandafter\pgf@temp\expandafter{\pgf@temp}% - \ifx\pgf@temp\pgfutil@empty - \else - \expandafter\ifx\csname tikz@library@\pgf@temp @loaded\endcsname\relax% - \expandafter\global\expandafter\let\csname tikz@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% - \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@} - \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|} - \catcode`\@=11 - \catcode`\|=12 - \input tikzlibrary\pgf@temp.code.tex - \catcode`\@=\csname tikz@library@#1@atcode\endcsname - \catcode`\|=\csname tikz@library@#1@barcode\endcsname - \fi% - \fi + \expandafter\pgfkeys@spdef\expandafter\pgf@temp\expandafter{\pgf@temp}% + \ifx\pgf@temp\pgfutil@empty + \else + \expandafter\ifx\csname tikz@library@\pgf@temp @loaded\endcsname\relax% + \expandafter\global\expandafter\let\csname tikz@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% + \expandafter\edef\csname tikz@library@#1@atcode\endcsname{\the\catcode`\@} + \expandafter\edef\csname tikz@library@#1@barcode\endcsname{\the\catcode`\|} + \expandafter\edef\csname tikz@library@#1@dollarcode\endcsname{\the\catcode`\$} + \catcode`\@=11 + \catcode`\|=12 + \catcode`\$=3 + \pgfutil@InputIfFileExists{tikzlibrary\pgf@temp.code.tex}{}{ + \pgfutil@IfFileExists{pgflibrary\pgf@temp.code.tex}{% + \expandafter\usepgflibrary\expandafter{\pgf@temp}% + }{% + \tikzerror{I did not find the tikz library + '\pgf@temp'. I looked for files named + tikzlibrary\pgf@temp.code.tex and + pgflibrary\pgf@temp.code.tex, but neither + could be found in the current texmf trees.} + }}% + \catcode`\@=\csname tikz@library@#1@atcode\endcsname + \catcode`\|=\csname tikz@library@#1@barcode\endcsname + \catcode`\$=\csname tikz@library@#1@dollarcode\endcsname + \fi% + \fi }% } -- cgit v1.2.3