From e62f8e9bbbd4c6360b4f2b054505c13c5cfc05e7 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 30 Dec 2010 23:50:24 +0000 Subject: tikz-qtree git-svn-id: svn://tug.org/texlive/trunk@20895 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex | 39 ++++++++++++++----- Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex | 44 ++++++++++------------ .../texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex | 18 ++++++--- 3 files changed, 60 insertions(+), 41 deletions(-) (limited to 'Master/texmf-dist/tex/latex/tikz-qtree') diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex b/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex index 4acd7d57b28..baa35846ff0 100644 --- a/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex +++ b/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex @@ -22,9 +22,6 @@ % - nodes in subpictures are tracked if the subpicture is placed with arbitrary transforms % - new \pgffitsubpicture macro to transform a subpicture (preserving aspect) to fit in a desired box -% To do: -% - speed up interpictureshift hook by promoting subsubpictures - \newdimen\pgf@subpicminx \newdimen\pgf@subpicminy \newdimen\pgf@subpicmaxx @@ -70,32 +67,54 @@ % saved subpictures are local to the current group \def\pgfsavesubpicture#1{% -\expandafter\setbox\csname pgf@subpic@hbox@#1\endcsname\copy\pgf@hbox +\expandafter\setbox\csname pgf@subpic@hbox@#1\endcsname\box\pgf@hbox +\csname pgf@subpic@minx@#1\endcsname\pgf@subpicminx +\csname pgf@subpic@miny@#1\endcsname\pgf@subpicminy +\csname pgf@subpic@maxx@#1\endcsname\pgf@subpicmaxx +\csname pgf@subpic@maxy@#1\endcsname\pgf@subpicmaxy +\expandafter\edef\csname pgf@subpic@id@#1\endcsname{\subpictureid}% +} + +% place current subpicture into named subpicture +\def\pgfmergesubpicture#1{% +\begin{pgfsubpicture} +% place current subpicture +\pgfplacesubpicture +% override containing picture +\expandafter\xdef\csname pgf@sh@pi@\subpictureid\endcsname{\csname pgf@subpic@id@#1\endcsname}% +% copy contents of #1 +\pgfrestoresubpicture{#1} +\pgflowlevelobj{\pgftransformshift{\pgfqpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}}{\pgfqbox\pgf@hbox} +\pgfpathrectanglecorners{\pgfqpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}{\pgfqpoint{\the\pgf@subpicmaxx}{\the\pgf@subpicmaxy}}% +\pgfusepath{use as bounding box}% +% +\end{pgfsubpicture} +\expandafter\setbox\csname pgf@subpic@hbox@#1\endcsname\box\pgf@hbox \csname pgf@subpic@minx@#1\endcsname\pgf@subpicminx \csname pgf@subpic@miny@#1\endcsname\pgf@subpicminy \csname pgf@subpic@maxx@#1\endcsname\pgf@subpicmaxx \csname pgf@subpic@maxy@#1\endcsname\pgf@subpicmaxy -\expandafter\edef\csname pgf@subpic@id@#1\endcsname{\subpictureid} +% but don't save the new picture id, keep the existing one } \def\pgfrestoresubpicture#1{% -\edef\act{\global\noexpand\setbox\pgf@hbox\noexpand\copy\csname pgf@subpic@hbox@#1\endcsname}\act +\edef\act{\global\noexpand\setbox\pgf@hbox\noexpand\box\csname pgf@subpic@hbox@#1\endcsname}\act \expandafter\global\expandafter\pgf@subpicminx\csname pgf@subpic@minx@#1\endcsname \expandafter\global\expandafter\pgf@subpicminy\csname pgf@subpic@miny@#1\endcsname \expandafter\global\expandafter\pgf@subpicmaxx\csname pgf@subpic@maxx@#1\endcsname \expandafter\global\expandafter\pgf@subpicmaxy\csname pgf@subpic@maxy@#1\endcsname -\xdef\subpictureid{\csname pgf@subpic@id@#1\endcsname} +\xdef\subpictureid{\csname pgf@subpic@id@#1\endcsname}% } % Place a previously-created subpicture, lining up its origin with the current origin \def\pgfplacesubpicture{ \pgfscope % expand current bounding box to accommodate subpicture -\pgfpathrectanglecorners{\pgfpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}{\pgfpoint{\the\pgf@subpicmaxx}{\the\pgf@subpicmaxy}}% +\pgfpathrectanglecorners{\pgfqpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}{\pgfqpoint{\the\pgf@subpicmaxx}{\the\pgf@subpicmaxy}}% \pgfusepath{use as bounding box}% % % make the subpicture a node in the containing picture -\expandafter\gdef\csname pgf@sh@ns@\subpictureid\endcsname{rectangle} +\expandafter\gdef\csname pgf@sh@ns@\subpictureid\endcsname{rectangle}% \expandafter\xdef\csname pgf@sh@np@\subpictureid\endcsname{% \noexpand\def\noexpand\southwest{\noexpand\pgfqpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}% \noexpand\def\noexpand\northeast{\noexpand\pgfqpoint{\the\pgf@subpicmaxx}{\the\pgf@subpicmaxy}}% @@ -105,7 +124,7 @@ \expandafter\xdef\csname pgf@sh@pi@\subpictureid\endcsname{\pgfpictureid}% % % align origin of subpicture with origin -\pgftransformshift{\pgfpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}% +\pgftransformshift{\pgfqpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}% \pgfqboxsynced{\pgf@hbox}% \endpgfscope } diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex b/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex index a3fca8b0b48..8173ed13cb8 100644 --- a/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex +++ b/Master/texmf-dist/tex/latex/tikz-qtree/pgftree.tex @@ -87,7 +87,7 @@ \def\pgftree#1{% \def\nodename{r}% -#1 +#1% \pgfplacesubpicture } @@ -100,7 +100,6 @@ % Token 2n in the sequence draws the nth subtree. Its root must be named \nodename. \pgfnewsubpicture{children} -\pgfnewsubpicture{child} \newdimen\pgftree@lastchildx \newdimen\pgftree@lastchildy @@ -109,30 +108,26 @@ \pgftree@savechildx=\pgftree@childx \pgftree@savechildy=\pgftree@childy \pgftree@savechildi=\pgftree@childi -% Build subpicture with all the children and their subtrees. Save it in "children" +% Build subpicture with all the children and their subtrees {\pgftree@childx=0pt% \pgftree@childy=0pt% \pgftree@childi=0% \process@children #2}% -\ifnum\pgftree@childi>0% \begin{pgfsubpicture}% -% Create root node -#1 +% Create node +#1% +\ifnum\pgftree@childi>0% % Place children % move down \levelsep {\pgftransformshift{\pgftree@levelshift}% % center so that parent is midway between origins of first and last children -\pgftransformshift{\pgfpointscale{-0.5}{\pgfpoint{\the\pgftree@childx}{\the\pgftree@childy}}}% -\pgfplacesubpicture} +\pgftransformshift{\pgfpointscale{-0.5}{\pgfqpoint{\the\pgftree@childx}{\the\pgftree@childy}}}% +\pgfplacesubpicture}% % Draw the edges {\pgftree@childi=0% \process@edges #2}% -\end{pgfsubpicture}% -\else % leaf node -\begin{pgfsubpicture}% -#1 -\end{pgfsubpicture}% \fi +\end{pgfsubpicture}% \global\pgftree@childi=\pgftree@savechildi \global\pgftree@childx=\pgftree@savechildx \global\pgftree@childy=\pgftree@savechildy @@ -144,34 +139,33 @@ \global\pgftree@childx\pgftree@lastchildx \global\pgftree@childy\pgftree@lastchildy \global\pgftree@childi\pgftree@childi +\ifnum\pgftree@childi>0% \pgfrestoresubpicture{children}% pass children back to caller +\fi }% {\@process@children}% } \def\@process@children#1#2{% #1 is the edge, #2 is the child -% Build the current child and save it as "child" +% Build the current child {\edef\nodename{\parentnodename-\the\pgftree@childi}% #2}% -\pgfsavesubpicture{child}% -\begin{pgfsubpicture} -% Place previous children (if any) -\ifnum\pgftree@childi>0% -\pgfrestoresubpicture{children}% -\pgfplacesubpicture -\fi +\begin{pgfsubpicture}% % Place current child -\pgfrestoresubpicture{child}% \ifnum\pgftree@childi>0% the first child is always at 0 \pgftree@presiblingshift \global\advance\pgftree@childx\pgf@x \global\advance\pgftree@childy\pgf@y \fi +{\pgftransformshift{\pgfqpoint{\the\pgftree@childx}{\the\pgftree@childy}}% +\pgfplacesubpicture}% \global\pgftree@lastchildx\pgftree@childx \global\pgftree@lastchildy\pgftree@childy -{\pgftransformshift{\pgfpoint{\the\pgftree@childx}{\the\pgftree@childy}}% -\pgfplacesubpicture}% \pgftree@postsiblingshift \global\advance\pgftree@childx\pgf@x \global\advance\pgftree@childy\pgf@y -\end{pgfsubpicture}% % Save the augmented row of children back into "children" +\end{pgfsubpicture} +\ifnum\pgftree@childi>0% +\pgfmergesubpicture{children} +\else \pgfsavesubpicture{children}% +\fi \advance\pgftree@childi by 1% \process@children } diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex b/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex index 09282e63e09..8e8d09f2c47 100644 --- a/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex +++ b/Master/texmf-dist/tex/latex/tikz-qtree/tikz-qtree.tex @@ -1,5 +1,5 @@ % tikz-qtree.tex -% Version 1.1, 25 Dec 2009 +% Version 1.11, 25 Dec 2010 % Copyright (C) 2002, 2009 by David Chiang @@ -17,6 +17,9 @@ % with this program; if not, write to the Free Software Foundation, Inc., % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +% New in version 1.11: +% - make options compatible with standard tikz trees + % New in version 1.1: % - sideways trees @@ -148,13 +151,16 @@ \def\roof@edge@right#1#2{(#1.east) -- (#2.north west) -- (#2.south west) -- cycle} %%% Options - -\tikzoption{level distance}{\pgfmathsetlength\levelsep{#1}} -\tikzoption{sibling distance}{\pgfmathsetlength\subtreesep{#1}} % different semantics +\pgfkeysgetvalue{/tikz/level distance/.@cmd}{\orig@leveldistance} +\tikzoption{level distance}{\pgfmathsetlength\levelsep{#1}\orig@leveldistance#1\pgfeov} +\pgfkeysgetvalue{/tikz/sibling distance/.@cmd}{\orig@siblingdistance} +\tikzoption{sibling distance}{\pgfmathsetlength\subtreesep{#1}\orig@siblingdistance#1\pgfeov} % different semantics % I don't really like this scheme -\tikzoption{grow}{\csname grow@#1\endcsname} -\tikzoption{grow'}{\csname growprime@#1\endcsname} +\pgfkeysgetvalue{/tikz/grow/.@cmd}{\orig@grow} +\tikzoption{grow}{\csname grow@#1\endcsname\orig@grow#1\pgfeov} +\pgfkeysgetvalue{/tikz/grow'/.@cmd}{\orig@growprime} +\tikzoption{grow'}{\csname growprime@#1\endcsname\orig@growprime#1\pgfeov} \def\grow@up{\def\leveldirection{up}\def\siblingdirection{left}} \def\grow@down{\def\leveldirection{down}\def\siblingdirection{right}} \def\growprime@up{\def\leveldirection{up}\def\siblingdirection{right}} -- cgit v1.2.3