summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex')
-rw-r--r--Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex110
1 files changed, 110 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex b/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex
new file mode 100644
index 00000000000..928ae336e95
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/tikz-qtree/pgfsubpic.tex
@@ -0,0 +1,110 @@
+% pgfsubpic.tex
+% Version 1, 22 Dec 2009
+
+% Copyright 2009 by David Chiang
+
+% This program is free software; you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation; either version 2 of the License, or
+% (at your option) any later version.
+
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+
+% You should have received a copy of the GNU General Public License along
+% with this program; if not, write to the Free Software Foundation, Inc.,
+% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+\newdimen\pgf@subpicminx
+\newdimen\pgf@subpicminy
+\newdimen\pgf@subpicmaxx
+\newdimen\pgf@subpicmaxy
+
+% Special virtual node for current subpicture's bounding box
+\expandafter\def\csname pgf@sh@ns@current subpicture\endcsname{rectangle}
+\expandafter\def\csname pgf@sh@np@current subpicture\endcsname{%
+ \def\southwest{\pgfqpoint{\pgf@subpicminx}{\pgf@subpicminy}}%
+ \def\northeast{\pgfqpoint{\pgf@subpicmaxx}{\pgf@subpicmaxy}}%
+}
+\expandafter\def\csname pgf@sh@nt@current subpicture\endcsname{{1}{0}{0}{1}{0pt}{0pt}}
+\expandafter\def\csname pgf@sh@pi@current subpicture\endcsname{\pgfpictureid}
+
+% Create a pgfpicture inside an hbox for delayed placement
+\def\pgfsubpicture{%
+\global\setbox\pgf@hbox=\hbox\bgroup
+\pgfinterruptpicture%
+\pgfpicture%
+}
+
+\def\endpgfsubpicture{
+\global\pgf@subpicminx=\pgf@picminx
+\global\pgf@subpicminy=\pgf@picminy
+\global\pgf@subpicmaxx=\pgf@picmaxx
+\global\pgf@subpicmaxy=\pgf@picmaxy
+\global\edef\subpictureid{\pgfpictureid}%
+\pgfsetbaseline{\pgf@picminy}%
+\endpgfpicture%
+\endpgfinterruptpicture%
+\egroup
+}
+
+% Place a previously-created subpicture, lining up its origin with the current origin
+\def\pgfplacesubpicture{
+\pgfscope
+% expand current bounding box to accommodate subpicture
+\pgfpathmoveto{\pgfpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}%
+\pgfpathlineto{\pgfpoint{\the\pgf@subpicmaxx}{\the\pgf@subpicmaxy}}%
+\pgfusepath{use as bounding box}%
+% save relative position of subpicture inside containing picture
+\pgfpointorigin
+\pgf@pos@transform{\pgf@x}{\pgf@y}%
+\expandafter\xdef\csname pgf@subpic@\subpictureid @x\endcsname{\the\pgf@x}%
+\expandafter\xdef\csname pgf@subpic@\subpictureid @y\endcsname{\the\pgf@y}%
+\expandafter\xdef\csname pgf@subpic@\subpictureid @p\endcsname{\pgfpictureid}%
+% align origin of subpicture with origin
+\pgftransformshift{\pgfpoint{\the\pgf@subpicminx}{\the\pgf@subpicminy}}%
+\pgfqboxsynced{\pgf@hbox}%
+\endpgfscope
+}
+
+% Hook onto existing macro \pgf@shape@interpictureshift.
+% This is called whenever we look up an anchor of a node.
+% This hook recursively checks to see if the node's picture
+% is a subpicture of another, and if so, adjusts its position accordingly.
+\let\orig@pgf@shape@interpictureshift\pgf@shape@interpictureshift
+\def\unwind@subpic#1{%
+% is #1 the current picture?
+\edef\subpicid{#1}%
+\ifx\subpicid\pgfpictureid
+% yes, we're done
+\else
+% does #1 have a parent picture?
+\expandafter\ifx\csname pgf@subpic@#1@p\endcsname\relax
+% no, the original node was not inside the current picture
+\fallback
+\else
+% yes, apply shift and move up to parent picture
+\global\advance\pgf@x by \csname pgf@subpic@#1@x\endcsname
+\global\advance\pgf@y by \csname pgf@subpic@#1@y\endcsname
+\unwind@subpic{\csname pgf@subpic@#1@p\endcsname}%
+\fi
+\fi
+}
+\def\pgf@shape@interpictureshift#1{%
+\edef\fallback{\pgf@x=\the\pgf@x\pgf@y=\the\pgf@y\noexpand\orig@pgf@shape@interpictureshift{#1}}%
+\unwind@subpic{\csname pgf@sh@pi@#1\endcsname}%
+}
+
+\def\pgfnodedelete#1{%
+\expandafter\global\expandafter\let\csname pgf@sh@ns@#1\endcsname\relax
+\expandafter\global\expandafter\let\csname pgf@sh@np@#1\endcsname\relax
+\expandafter\global\expandafter\let\csname pgf@sh@nt@#1\endcsname\relax
+\expandafter\global\expandafter\let\csname pgf@sh@pi@#1\endcsname\relax
+\expandafter\global\expandafter\let\csname pgf@sh@ma@#1\endcsname\relax
+}
+
+\def\pgfnodeifexists#1#2#3{%
+\expandafter\ifx\csname pgf@sh@ns@#1\endcsname\relax#3\else#2\fi
+}