| 1 |
% Copyright 2019 by Till Tantau |
| 2 |
% |
| 3 |
% This file may be distributed and/or modified |
| 4 |
% |
| 5 |
% 1. under the LaTeX Project Public License and/or |
| 6 |
% 2. under the GNU Public License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
\ProvidesFileRCS{tikzlibraryspy.code.tex} |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
% Spy styles |
| 15 |
|
| 16 |
\tikzset{ |
| 17 |
spy using outlines/.style={ |
| 18 |
spy scope={ |
| 19 |
every spy on node/.style={very thin,draw}, |
| 20 |
every spy in node/.style={thick,draw}, |
| 21 |
#1 |
| 22 |
} |
| 23 |
}, |
| 24 |
spy using overlays/.style={ |
| 25 |
spy scope={ |
| 26 |
every spy on node/.style={fill,fill opacity=0.2,text opacity=1}, |
| 27 |
every spy in node/.style={fill,fill opacity=0.2,text opacity=1}, |
| 28 |
#1 |
| 29 |
} |
| 30 |
}, |
| 31 |
connect spies/.style={ |
| 32 |
spy connection path={\draw[thin] (tikzspyonnode) -- (tikzspyinnode);} |
| 33 |
} |
| 34 |
}% |
| 35 |
|
| 36 |
\newbox\tikz@lib@spybox |
| 37 |
|
| 38 |
\let\tikz@lib@spy@collection=\pgfutil@empty% |
| 39 |
|
| 40 |
\tikzset{spy scope/.style={ |
| 41 |
size/.style={minimum size={##1}}, |
| 42 |
height/.style={minimum height={##1}}, |
| 43 |
width/.style={minimum width={##1}}, |
| 44 |
execute at begin scope={% |
| 45 |
\let\tikz@lib@spy@save=\tikz@lib@spy@collection% |
| 46 |
\setbox\tikz@lib@spybox=\hbox\bgroup\bgroup% |
| 47 |
\let\spy=\tikz@lib@spy@parse}, |
| 48 |
execute at end scope={% |
| 49 |
\egroup\egroup% |
| 50 |
{% |
| 51 |
\copy\tikz@lib@spybox% |
| 52 |
\tikz@lib@spy@collection% |
| 53 |
}% |
| 54 |
\global\let\tikz@lib@spy@collection=\tikz@lib@spy@save% |
| 55 |
},% |
| 56 |
tikz@lib@spy@style/.style={#1}, |
| 57 |
tikz@lib@reset@gs |
| 58 |
}, |
| 59 |
lens/.store in=\tikz@lib@spy@lens, |
| 60 |
lens=, |
| 61 |
magnification/.style={lens={scale={#1}}}, |
| 62 |
spy connection path/.store in=\tikz@lib@spy@path, |
| 63 |
spy connection path= |
| 64 |
}% |
| 65 |
|
| 66 |
\tikzset{ |
| 67 |
tikz@lib@reset@gs/.style={black,thin,solid,opaque,line cap=butt,line join=miter} |
| 68 |
}% |
| 69 |
|
| 70 |
\def\tikz@lib@spy@parse{% |
| 71 |
\pgfutil@ifnextchar[{\tikz@lib@spy@parse@opt}{\tikz@lib@spy@parse@opt[]}%] |
| 72 |
}% |
| 73 |
\def\tikz@lib@spy@parse@opt[#1]{ |
| 74 |
\pgfutil@ifnextchar x{\tikz@lib@spy@parse@opta[#1]}{\tikz@lib@spy@parse@opta[#1]}%] |
| 75 |
}% |
| 76 |
\def\tikz@lib@spy@parse@opta[#1]on#2in node#3;{% |
| 77 |
\pgfutil@g@addto@macro\tikz@lib@spy@collection{\tikz@lib@spy@do{#1}{#2}{#3}}% |
| 78 |
}% |
| 79 |
|
| 80 |
\def\tikz@lib@spy@do#1#2#3{% |
| 81 |
\scope[tikz@lib@spy@style,#1] |
| 82 |
\node [alias=tikzspyonnode,inner sep=0pt,outer sep=0pt,every spy on node/.try, |
| 83 |
/utils/exec={ |
| 84 |
{% |
| 85 |
\let\tikz@transform=\relax |
| 86 |
\pgftransformreset% |
| 87 |
\expandafter\tikzset\expandafter{\tikz@lib@spy@lens} |
| 88 |
\pgftransforminvert% |
| 89 |
\pgfgettransformentries\a\b\c\d\e\f% |
| 90 |
\global\let\pgf@lib@svg@a=\a% |
| 91 |
\global\let\pgf@lib@svg@b=\b% |
| 92 |
\global\let\pgf@lib@svg@c=\c% |
| 93 |
\global\let\pgf@lib@svg@d=\d% |
| 94 |
}% |
| 95 |
\tikz@addtransform{% |
| 96 |
\tikz@scan@one@point\pgftransformshift#2% |
| 97 |
\pgftransformcm{\pgf@lib@svg@a}{\pgf@lib@svg@b}{\pgf@lib@svg@c}{\pgf@lib@svg@d}{\pgfpointorigin}% |
| 98 |
} |
| 99 |
}]{}; |
| 100 |
\expandafter\pgfutil@switch\expandafter\pgfutil@ifstrequal\expandafter{\tikz@anchor}{% |
| 101 |
{north} {\def\tikz@spy@anchor{south}}% |
| 102 |
{north east}{\def\tikz@spy@anchor{south west}}% |
| 103 |
{east} {\def\tikz@spy@anchor{west}}% |
| 104 |
{south east}{\def\tikz@spy@anchor{north west}}% |
| 105 |
{south} {\def\tikz@spy@anchor{north}}% |
| 106 |
{south west}{\def\tikz@spy@anchor{north east}}% |
| 107 |
{west} {\def\tikz@spy@anchor{east}}% |
| 108 |
{north west}{\def\tikz@spy@anchor{south east}}% |
| 109 |
}{}{\def\tikz@spy@anchor{center}}% |
| 110 |
\node [alias=tikzspyinnode,inner sep=0pt,outer sep=0pt,at={#2},every spy in node/.try, |
| 111 |
path picture={\node[anchor=\tikz@spy@anchor,tikz@lib@reset@gs]{\nullfont% |
| 112 |
\pgfpicture\relax\pgfsetbaseline{default}\pgfsettrimleft{default}\pgfsettrimright{default}% |
| 113 |
\pgftransformreset% |
| 114 |
\let\tikz@transform=\relax% |
| 115 |
\expandafter\tikzset\expandafter{\tikz@lib@spy@lens}% |
| 116 |
\pgflowlevelsynccm% |
| 117 |
\tikz@scan@one@point\tikz@lib@spy@shift#2% |
| 118 |
\pgflowlevelsynccm% |
| 119 |
\copy\tikz@lib@spybox% |
| 120 |
\endpgfpicture};}]#3{}; |
| 121 |
\tikz@lib@spy@path |
| 122 |
\endscope |
| 123 |
}% |
| 124 |
|
| 125 |
\def\tikz@lib@spy@shift#1{% |
| 126 |
\pgf@process{#1}% |
| 127 |
\pgf@x=-\pgf@x% |
| 128 |
\pgf@y=-\pgf@y% |
| 129 |
\pgftransformshift{}% |
| 130 |
}% |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
\endinput |