| 1 |
% ====================================================== |
| 2 |
% compatibility with PGF 2.10 |
| 3 |
% ====================================================== |
| 4 |
% |
| 5 |
%%% This file is a copy of some part of PGF/Tikz. |
| 6 |
%%% It has been copied here to provide : |
| 7 |
%%% - compatibility with older PGF versions |
| 8 |
%%% - availability of PGF contributions by Christian Feuersaenger |
| 9 |
%%% which are necessary or helpful for pgfplots. |
| 10 |
%%% |
| 11 |
%%% It contains a couple of patches such that selected changes which |
| 12 |
%%% are also part of PGF/TikZ (and can be found in the development |
| 13 |
%%% version of PGF/TikZ) are available within pgfplots. |
| 14 |
%%% |
| 15 |
%%% Typically, these modifications have been done by the pgfplots team |
| 16 |
%%% as contribution to PGf/TIKZ |
| 17 |
% |
| 18 |
% Support for the contents of this file will NOT be done by the PGF/TikZ team. |
| 19 |
% Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction |
| 20 |
% with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything: |
| 21 |
% This file comes without any warranty as the rest of pgfplots; there is no obligation for help. |
| 22 |
\def\pgfdeclarelayer#1{% |
| 23 |
\pgfutil@ifundefined{pgf@layerbox@#1}{% |
| 24 |
\expandafter\expandafter\csname pgf@newbox\endcsname\csname pgf@layerbox@#1\endcsname% |
| 25 |
\expandafter\expandafter\csname pgf@newbox\endcsname\csname pgf@layerboxsaved@#1\endcsname% |
| 26 |
}{}% |
| 27 |
} |
| 28 |
|
| 29 |
\def\tikz@key@name@path@wrong#1#2{% |
| 30 |
\tikz@addmode{% |
| 31 |
\pgfsyssoftpath@getcurrentpath\tikz@intersect@temppath@round% |
| 32 |
\pgfprocessround\tikz@intersect@temppath@round\tikz@intersect@temppath% |
| 33 |
\ifx\tikz@intersect@namedpaths\pgfutil@empty% |
| 34 |
\else% |
| 35 |
\tikz@intersect@namedpaths% |
| 36 |
\pgfutil@ifundefined{tikz@intersect@path@name@#1}{}% |
| 37 |
{% |
| 38 |
\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@intersect@@temppath% |
| 39 |
\expandafter\expandafter\expandafter{\csname tikz@intersect@path@name@#1\endcsname}% |
| 40 |
\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\tikz@intersect@temppath% |
| 41 |
\expandafter\expandafter\expandafter{\expandafter\tikz@intersect@temppath\tikz@intersect@temppath}% |
| 42 |
}% |
| 43 |
\fi% |
| 44 |
\tikz@intersect@addto@path@names{#1}{#2}% |
| 45 |
}% |
| 46 |
}% |
| 47 |
|
| 48 |
\def\tikz@key@name@path@new#1#2{% |
| 49 |
\tikz@addmode{% |
| 50 |
\pgfsyssoftpath@getcurrentpath\tikz@intersect@temppath@round% |
| 51 |
\pgfprocessround\tikz@intersect@temppath@round\tikz@intersect@temppath% |
| 52 |
\ifx\tikz@intersect@namedpaths\pgfutil@empty% |
| 53 |
\else% |
| 54 |
\tikz@intersect@namedpaths% |
| 55 |
\fi% |
| 56 |
\tikz@intersect@addto@path@names{#1}{#2}% |
| 57 |
}% |
| 58 |
}% |
| 59 |
|
| 60 |
\ifx\tikz@key@name@path@wrong\tikz@key@name@path |
| 61 |
\let\tikz@key@name@path=\tikz@key@name@path@new |
| 62 |
\fi |
| 63 |
|
| 64 |
\def\pgfutil@insertatbegincurrentpagefrombox@WRONG#1{% |
| 65 |
\global\setbox\pgfutil@abb\hbox{\unhbox\pgfutil@abb#1}% |
| 66 |
} |
| 67 |
|
| 68 |
% needed for dvipdfmx and shader=interp |
| 69 |
\def\pgfutil@insertatbegincurrentpagefrombox@FIXED#1{% |
| 70 |
\edef\pgf@temp{\the\wd\pgfutil@abb}% |
| 71 |
\global\setbox\pgfutil@abb\hbox{% |
| 72 |
\unhbox\pgfutil@abb |
| 73 |
% |
| 74 |
% the order in which \pgfutil@insertatbegincurrentpagefrombox |
| 75 |
% matters unless we make the following -shift! |
| 76 |
% To see this, consider writing two such statements. The second |
| 77 |
% one will (naturally) be placed more to the right, although there |
| 78 |
% is no apparent reason why it should. |
| 79 |
% |
| 80 |
% CF observed problems when placing patterns in XObjects without |
| 81 |
% this skip (dvipdfmx driver for pgfplots shader=interp) |
| 82 |
\hskip-\pgf@temp\relax |
| 83 |
#1% |
| 84 |
}% |
| 85 |
} |
| 86 |
\expandafter\ifx\csname pgfutil@insertatbegincurrentpagefrombox\endcsname\pgfutil@insertatbegincurrentpagefrombox@WRONG |
| 87 |
\let\pgfutil@insertatbegincurrentpagefrombox=\pgfutil@insertatbegincurrentpagefrombox@FIXED |
| 88 |
\fi |
| 89 |
|
| 90 |
% ====================================================== |
| 91 |
% compatibility with PGF 2.0 |
| 92 |
% ====================================================== |
| 93 |
\def\pgfutil@gobble@until@relax#1\relax{} |
| 94 |
|
| 95 |
\expandafter\ifx\csname w@pgf@writea\endcsname\relax |
| 96 |
\csname newwrite\endcsname\w@pgf@writea |
| 97 |
\fi |
| 98 |
|
| 99 |
\expandafter\ifx\csname r@pgf@reada\endcsname\relax |
| 100 |
\csname newread\endcsname\r@pgf@reada |
| 101 |
\fi |
| 102 |
\let\pgfutil@inputcheck=\r@pgf@reada |
| 103 |
|
| 104 |
\pgfutil@ifundefined{pgf@texdist@protect}{% |
| 105 |
\def\pgf@texdist@protect{}% |
| 106 |
}{} |
| 107 |
|
| 108 |
% from pgfutil-common.tex: |
| 109 |
|
| 110 |
% Usage: |
| 111 |
% \pgfutilstrreplace{<token>}{<replacement>}{<string>} |
| 112 |
% |
| 113 |
% -> will assign the modified string into \pgfretval. |
| 114 |
% |
| 115 |
% #1: the string to search (one or more tokens) |
| 116 |
% #2: zero, one or more tokens which will be inserted instead of '#1'. |
| 117 |
% #3: the string to search in |
| 118 |
\long\def\pgfutilstrreplace#1#2#3{% |
| 119 |
\def\pgfretval{}% |
| 120 |
\long\def\pgfutil@search@and@replace@@##1#1##2\pgf@EOI{% |
| 121 |
\expandafter\def\expandafter\pgfretval\expandafter{\pgfretval ##1#2}% |
| 122 |
\pgfutil@search@and@replace@loop{#1}{##2}% |
| 123 |
}% |
| 124 |
\pgfutil@search@and@replace@loop{#1}{#3}% |
| 125 |
} |
| 126 |
\long\def\pgfutil@search@and@replace@loop#1#2{% |
| 127 |
\pgfutil@in@{#1}{#2}% |
| 128 |
\ifpgfutil@in@ |
| 129 |
\def\pgf@loc@TMPa{\pgfutil@search@and@replace@@ #2\pgf@EOI}% |
| 130 |
\else |
| 131 |
\expandafter\def\expandafter\pgfretval\expandafter{\pgfretval #2}% |
| 132 |
\let\pgf@loc@TMPa=\relax |
| 133 |
\fi |
| 134 |
\pgf@loc@TMPa |
| 135 |
}% |
| 136 |
% Solves a linear equation system of size 2x2 using gauss elimination. |
| 137 |
% |
| 138 |
% It employs TeX register arithmetics to do so. |
| 139 |
% #1: should contain 4 sets of braces with matrix entries, |
| 140 |
% {<a11>}{<a12>} |
| 141 |
% {<a21>}{<a22>} |
| 142 |
% where each entry should be a number without unit. |
| 143 |
% #2: should contain 2 sets of braces with the right-hand-side, |
| 144 |
% {<r1>}{<r2>} |
| 145 |
% where each entry should be a number without unit. |
| 146 |
% |
| 147 |
% It will assign \pgfmathresult to contain two sets of braces with the |
| 148 |
% result. |
| 149 |
% |
| 150 |
% Example: |
| 151 |
% \pgfutilsolvetwotwoleq{ |
| 152 |
% {0.24}{1} |
| 153 |
% {-0.97}{0} |
| 154 |
% }{ |
| 155 |
% {-7} |
| 156 |
% {18} |
| 157 |
% } |
| 158 |
% -> yields \pgfmathresult={−18.55618}{−2.54642} |
| 159 |
% |
| 160 |
% The algorithm employs column pivotisation. |
| 161 |
\def\pgfutilsolvetwotwoleq#1#2{% |
| 162 |
\begingroup |
| 163 |
\dimendef\aa=0 |
| 164 |
\dimendef\ab=1 |
| 165 |
\dimendef\ba=2 |
| 166 |
\dimendef\bb=3 |
| 167 |
\dimendef\ra=4 |
| 168 |
\dimendef\rb=5 |
| 169 |
\dimendef\tmpa=6 |
| 170 |
\dimendef\tmpb=7 |
| 171 |
\edef\pgf@temp{#1}% |
| 172 |
\expandafter\pgfutilsolvetwotwoleq@A\pgf@temp |
| 173 |
\edef\pgf@temp{#2}% |
| 174 |
\expandafter\pgfutilsolvetwotwoleq@r\pgf@temp |
| 175 |
% |
| 176 |
\pgfutilsolvetwotwoleq@ifislarger\aa\ba{% |
| 177 |
% identity "permutation": |
| 178 |
\def\Pa{a}% |
| 179 |
\def\Pb{b}% |
| 180 |
}{% |
| 181 |
% permutation matrix: switch rows! |
| 182 |
\def\Pa{b}% |
| 183 |
\def\Pb{a}% |
| 184 |
}% |
| 185 |
% \pivot := 1/aa |
| 186 |
\pgfmathreciprocal@ |
| 187 |
{\csname m\Pa a\endcsname}% |
| 188 |
\let\pivot=\pgfmathresult |
| 189 |
% |
| 190 |
% \factor := 1/aa * ba |
| 191 |
\csname \Pb a\endcsname=\pivot\csname \Pb a\endcsname |
| 192 |
\edef\factor{\expandafter\pgf@sys@tonumber\csname \Pb a\endcsname}% |
| 193 |
% |
| 194 |
% bb -= ba/aa * ab |
| 195 |
\tmpa=-\factor\csname \Pa b\endcsname |
| 196 |
\advance\csname \Pb b\endcsname by\tmpa |
| 197 |
% |
| 198 |
% rb -= ba/aa * ra |
| 199 |
\tmpa=-\factor\csname r\Pa\endcsname |
| 200 |
\advance\csname r\Pb\endcsname by\tmpa |
| 201 |
% |
| 202 |
% xb := rb / bb (the modified rb and modified bb!) |
| 203 |
\pgfmathdivide@ |
| 204 |
{\expandafter\pgf@sys@tonumber\csname r\Pb\endcsname} |
| 205 |
{\expandafter\pgf@sys@tonumber\csname \Pb b\endcsname}% |
| 206 |
\expandafter\let\csname pgfmathresult\Pb\endcsname=\pgfmathresult |
| 207 |
% |
| 208 |
% ra -= xb * ab |
| 209 |
\tmpa=\csname pgfmathresult\Pb\endcsname\csname \Pa b\endcsname |
| 210 |
\advance\csname r\Pa\endcsname by-\tmpa |
| 211 |
% |
| 212 |
% xa := 1/aa * ra (the modified ra!) |
| 213 |
\tmpa=\pivot\csname r\Pa\endcsname |
| 214 |
\expandafter\edef\csname pgfmathresult\Pa\endcsname{\pgf@sys@tonumber\tmpa}% |
| 215 |
% |
| 216 |
\edef\pgfmathresult{% |
| 217 |
{\csname pgfmathresult\Pa\endcsname}% |
| 218 |
{\csname pgfmathresult\Pb\endcsname}% |
| 219 |
}% |
| 220 |
\pgfmath@smuggleone\pgfmathresult |
| 221 |
\endgroup |
| 222 |
}% |
| 223 |
\def\pgfutilsolvetwotwoleq@ifislarger#1#2#3#4{% |
| 224 |
\tmpa=#1 |
| 225 |
\ifdim\tmpa<0pt |
| 226 |
\multiply\tmpa by-1 |
| 227 |
\fi |
| 228 |
\tmpb=#2 |
| 229 |
\ifdim\tmpb<0pt |
| 230 |
\multiply\tmpb by-1 |
| 231 |
\fi |
| 232 |
\ifdim\tmpa>\tmpb |
| 233 |
#3% |
| 234 |
\else |
| 235 |
#4% |
| 236 |
\fi |
| 237 |
}% |
| 238 |
\def\pgfutilsolvetwotwoleq@A#1#2#3#4{% |
| 239 |
\def\maa{#1}\def\mab{#2}% |
| 240 |
\def\mba{#3}\def\mbb{#3}% |
| 241 |
\aa=#1pt \ab=#2pt |
| 242 |
\ba=#3pt \bb=#4pt |
| 243 |
} |
| 244 |
\def\pgfutilsolvetwotwoleq@r#1#2{% |
| 245 |
\ra=#1pt \rb=#2pt |
| 246 |
}% |
| 247 |
|
| 248 |
|
| 249 |
%%%%%%% |
| 250 |
%%%%%%% |
| 251 |
|
| 252 |
% from pgfmoduleshapes.code.tex: |
| 253 |
% Invoke an anchor |
| 254 |
\def\pgf@sh@reanchor#1#2{% |
| 255 |
\pgfutil@ifundefined{pgf@anchor@#1@#2}% |
| 256 |
{% |
| 257 |
\pgfutil@ifundefined{pgf@anchor@generic@#2}{% |
| 258 |
\pgfmathsetcounter{pgf@counta}{#2}% |
| 259 |
\csname pgf@anchor@#1@border\endcsname{\pgfqpointpolar{\c@pgf@counta}{1pt}}% |
| 260 |
}{% |
| 261 |
\csname pgf@anchor@generic@#2\endcsname{#1}% |
| 262 |
}% |
| 263 |
}% |
| 264 |
{\csname pgf@anchor@#1@#2\endcsname}% |
| 265 |
} |
| 266 |
|
| 267 |
% Defines a generic anchor, i.e. one which gets the associated shape |
| 268 |
% as first argument. |
| 269 |
% |
| 270 |
% #1: the anchor name. |
| 271 |
% #2: the code of the anchor. It may depend upon '##1', the shape's |
| 272 |
% name. |
| 273 |
% |
| 274 |
% The anchor will be defined locally in the current TeX scope. |
| 275 |
\def\pgfdeclaregenericanchor#1#2{% |
| 276 |
\expandafter\def\csname pgf@anchor@generic@#1\endcsname##1{#2}% |
| 277 |
}% |
| 278 |
|
| 279 |
% from pgfcoretransformations.code.tex : |
| 280 |
\def\pgfgettransformentries#1#2#3#4#5#6{% |
| 281 |
\edef#1{\pgf@pt@aa}% |
| 282 |
\edef#2{\pgf@pt@ab}% |
| 283 |
\edef#3{\pgf@pt@ba}% |
| 284 |
\edef#4{\pgf@pt@bb}% |
| 285 |
\edef#5{\the\pgf@pt@x}% |
| 286 |
\edef#6{\the\pgf@pt@y}% |
| 287 |
}% |
| 288 |
\def\pgfsettransformentries#1#2#3#4#5#6{% |
| 289 |
\pgfsettransform{{#1}{#2}{#3}{#4}{#5}{#6}}% |
| 290 |
}% |
| 291 |
|
| 292 |
% pgfutil@loop (from plain.tex) |
| 293 |
|
| 294 |
\def\pgfutil@loop#1\pgfutil@repeat{\def\pgfutil@body{#1}\pgfutil@iterate} |
| 295 |
\def\pgfutil@iterate{\pgfutil@body \let\pgfutil@next\pgfutil@iterate \else\let\pgfutil@next\relax\fi \pgfutil@next} |
| 296 |
\let\pgfutil@repeat=\fi % this makes \loop...\if...\repeat skippable |
| 297 |
|
| 298 |
\def\pgfqpointxy#1#2{% |
| 299 |
\pgf@x=#1\pgf@xx% |
| 300 |
\advance\pgf@x by #2\pgf@yx% |
| 301 |
\pgf@y=#1\pgf@xy% |
| 302 |
\advance\pgf@y by #2\pgf@yy} |
| 303 |
\def\pgfqpointxyz#1#2#3{% |
| 304 |
\pgf@x=#1\pgf@xx% |
| 305 |
\advance\pgf@x by #2\pgf@yx% |
| 306 |
\advance\pgf@x by #3\pgf@zx% |
| 307 |
\pgf@y=#1\pgf@xy% |
| 308 |
\advance\pgf@y by #2\pgf@yy% |
| 309 |
\advance\pgf@y by #3\pgf@zy} |
| 310 |
\def\pgfcoordinate#1#2{% |
| 311 |
\edef\pgf@temp{#1}% |
| 312 |
\ifx\pgf@temp\pgfutil@empty% do nothing |
| 313 |
\else% |
| 314 |
\pgf@process{\pgfpointtransformed{#2}}% |
| 315 |
\expandafter\gdef\csname pgf@sh@ns@#1\endcsname{coordinate}% |
| 316 |
\expandafter\xdef\csname pgf@sh@np@#1\endcsname{% |
| 317 |
\noexpand\def\noexpand\centerpoint{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}% |
| 318 |
} |
| 319 |
\expandafter\gdef\csname pgf@sh@nt@#1\endcsname{{1}{0}{0}{1}{0pt}{0pt}}% |
| 320 |
\expandafter\global\expandafter\let\csname pgf@sh@ma@#1\endcsname\pgfutil@empty% |
| 321 |
\expandafter\gdef\csname pgf@sh@pi@#1\endcsname{\pgfpictureid}% |
| 322 |
\fi% |
| 323 |
} |
| 324 |
% A "quick" variant of \pgfpointscale which doesn't invoke the math parser for '#1'. |
| 325 |
% #1 must be a number without units, no registers are accepted. |
| 326 |
\def\pgfqpointscale#1#2{% |
| 327 |
\pgf@process{#2}% |
| 328 |
\pgf@x=#1\pgf@x% |
| 329 |
\pgf@y=#1\pgf@y% |
| 330 |
} |
| 331 |
% ====================================================== |
| 332 |
|
| 333 |
\def\pgfutilensuremath#1{% |
| 334 |
\ifmmode#1\else$#1$\fi |
| 335 |
} |
| 336 |
\def\tikzifinpicture#1#2{% |
| 337 |
\pgfutil@ifundefined{filldraw}{#2}{#1}% |
| 338 |
}% |
| 339 |
|
| 340 |
\def\tikz@fig@scan@name(#1){% |
| 341 |
\pgfkeysvalueof{/tikz/name/.@cmd}#1\pgfeov% CF : this is now ALWAYS consistent with 'name=' option; allows overrides. |
| 342 |
\tikz@@scan@fig}% |
| 343 |
|
| 344 |
\tikzoption{ybar}[]{\let\tikz@plot@handler=\pgfplothandlerybar} |
| 345 |
\tikzoption{xbar}[]{\let\tikz@plot@handler=\pgfplothandlerxbar} |
| 346 |
\tikzoption{ybar interval}[]{\let\tikz@plot@handler=\pgfplothandlerybarinterval} |
| 347 |
\tikzoption{xbar interval}[]{\let\tikz@plot@handler=\pgfplothandlerxbarinterval} |
| 348 |
\tikzoption{const plot}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlineto} |
| 349 |
\tikzoption{const plot mark left}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlineto} |
| 350 |
\tikzoption{const plot mark right}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlinetomarkright} |
| 351 |
\tikzoption{const plot mark mid}[]{\let\tikz@plot@handler=\pgfplothandlerconstantlinetomarkmid} |
| 352 |
\tikzoption{jump mark right}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkright} |
| 353 |
\tikzoption{jump mark left}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkleft} |
| 354 |
\tikzoption{jump mark mid}[]{\let\tikz@plot@handler=\pgfplothandlerjumpmarkmid} |
| 355 |
|
| 356 |
\def\tikz@plot@samples{25} |
| 357 |
\def\tikz@plot@domain{-5:5} |
| 358 |
\def\tikz@plot@var{\x} |
| 359 |
\def\tikz@plot@samplesat{-5,-4.5833333,...,5} |
| 360 |
|
| 361 |
\tikzoption{mark}{ |
| 362 |
\def\tikz@plot@mark{#1}% |
| 363 |
\def\tikz@temp{none}% this check is relatively new |
| 364 |
\ifx\tikz@temp\tikz@plot@mark |
| 365 |
\let\tikz@plot@mark=\pgfutil@empty |
| 366 |
\fi |
| 367 |
} |
| 368 |
|
| 369 |
% the 'pt' suffix is new: |
| 370 |
\pgfdeclareplotmark{ball} |
| 371 |
{% |
| 372 |
\def\tikz@shading{ball}% |
| 373 |
\shade (0pt,0pt) circle (\pgfplotmarksize);% |
| 374 |
} |
| 375 |
|
| 376 |
% the 'every mark' style is new: |
| 377 |
\tikzset{ |
| 378 |
no marks/.style={mark=none},% |
| 379 |
every mark/.style={}, |
| 380 |
mark options/.style={% |
| 381 |
every mark/.style={#1}% |
| 382 |
}} |
| 383 |
\def\tikz@@@plot{% |
| 384 |
\def\pgfplotlastpoint{\pgfpointorigin}% |
| 385 |
\tikz@plot@handler% |
| 386 |
\tikz@plot@data% |
| 387 |
\global\let\tikz@@@temp=\pgfplotlastpoint% |
| 388 |
\ifx\tikz@plot@mark\pgfutil@empty% |
| 389 |
\else% |
| 390 |
% Marks are drawn after the path. |
| 391 |
\setbox\tikz@figbox=\hbox{% |
| 392 |
\unhbox\tikz@figbox% |
| 393 |
\hbox{{% |
| 394 |
\pgfinterruptpath% |
| 395 |
\pgfscope% |
| 396 |
\let\tikz@options=\pgfutil@empty% |
| 397 |
\let\tikz@transform=\pgfutil@empty% |
| 398 |
\tikzset{every mark}% |
| 399 |
\tikz@options% |
| 400 |
\ifx\tikz@mark@list\pgfutil@empty% |
| 401 |
\pgfplothandlermark{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}}% |
| 402 |
\else |
| 403 |
\pgfplothandlermarklisted{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}}{\tikz@mark@list}% |
| 404 |
\fi |
| 405 |
\tikz@plot@data% |
| 406 |
\endpgfscope |
| 407 |
\endpgfinterruptpath% |
| 408 |
}}% |
| 409 |
}% |
| 410 |
\fi% |
| 411 |
\global\setbox\tikz@tempbox=\copy\tikz@figbox% |
| 412 |
%\global\let\tikz@after@path@smuggle=\tikz@after@path |
| 413 |
\endgroup% |
| 414 |
\setbox\tikz@figbox=\box\tikz@tempbox% |
| 415 |
\tikz@make@last@position{\tikz@@@temp}% |
| 416 |
%\expandafter\tikz@scan@next@command\tikz@after@path@smuggle% |
| 417 |
\tikz@scan@next@command% |
| 418 |
} |
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
% ====================================================== |
| 424 |
|
| 425 |
|
| 426 |
\newif\ifpgfmathcomparison |
| 427 |
|
| 428 |
% Assigns \pgfmathresult to 1.0 if #1 ~= #1. |
| 429 |
% |
| 430 |
% It will also set the boolean \ifpgfmathcomparison accordingly |
| 431 |
% (globally). |
| 432 |
\def\pgfmathapproxequalto#1#2{% |
| 433 |
\edef\pgfmath@marshal{% |
| 434 |
\noexpand\pgfmathparse{#2} |
| 435 |
\noexpand\let\noexpand\pgfmath@arg\noexpand\pgfmathresult% |
| 436 |
\noexpand\pgfmathparse{#1}% |
| 437 |
}% |
| 438 |
\pgfmath@marshal% |
| 439 |
\pgfmathapproxequalto@{\pgfmathresult}{\pgfmath@arg}} |
| 440 |
\def\pgfmathapproxequalto@#1#2{% |
| 441 |
\begingroup% |
| 442 |
\pgfmath@x#1pt% |
| 443 |
\pgfmath@y#2pt% |
| 444 |
\advance\pgfmath@x-\pgfmath@y% |
| 445 |
\ifdim\pgfmath@x<0pt |
| 446 |
\multiply\pgfmath@x by-1 |
| 447 |
\fi |
| 448 |
\ifdim\pgfmath@x<0.0001pt\relax% |
| 449 |
\def\pgfmathresult{1.0}% |
| 450 |
\global\pgfmathcomparisontrue |
| 451 |
\else% |
| 452 |
\def\pgfmathresult{0.0}% |
| 453 |
\global\pgfmathcomparisonfalse |
| 454 |
\fi% |
| 455 |
\pgfmath@smuggleone\pgfmathresult |
| 456 |
\endgroup% |
| 457 |
} |
| 458 |
|
| 459 |
\newif\ifpgfmarktext@usetikznode |
| 460 |
\pgfkeys{ |
| 461 |
/pgf/text mark/.initial=p, |
| 462 |
/pgf/text mark style/.initial=, |
| 463 |
/pgf/text mark as node/.is if=pgfmarktext@usetikznode, |
| 464 |
/pgf/text mark as node/.default=true, |
| 465 |
% |
| 466 |
% backw. compat: the extra search path confuses the '.unknown' |
| 467 |
% handlers, so this here is deprecated: |
| 468 |
/pgf/text mark/style/.style={/pgf/text mark style={#1}},% |
| 469 |
/pgf/text mark/as node/.style={/pgf/text mark as node=#1},% |
| 470 |
}% |
| 471 |
|
| 472 |
\pgfdeclareplotmark{text} |
| 473 |
{ |
| 474 |
\pgfkeysgetvalue{/pgf/text mark style}\pgfmarktext@style |
| 475 |
\pgfkeysgetvalue{/pgf/text mark}\pgfmarktext@ |
| 476 |
\ifpgfmarktext@usetikznode |
| 477 |
\expandafter\node\expandafter[\pgfmarktext@style]{\pgfmarktext@}; |
| 478 |
\else |
| 479 |
\expandafter\pgftext\expandafter[\pgfmarktext@style]{\pgfmarktext@}% |
| 480 |
\fi |
| 481 |
} |
| 482 |
|
| 483 |
% A fix for the overlay option and matrices: |
| 484 |
\def\pgf@matrix@startcell{% |
| 485 |
% |
| 486 |
% Step 1: Init the list of nodes for this cell |
| 487 |
% |
| 488 |
\let\pgf@nodecallback=\pgf@matrix@nodecallback% |
| 489 |
% |
| 490 |
% Step 2: Setup the bounding box |
| 491 |
% |
| 492 |
\pgfinterruptboundingbox% |
| 493 |
% |
| 494 |
% Step 3: Reset the transformation matrix |
| 495 |
% |
| 496 |
\pgftransformreset% |
| 497 |
% |
| 498 |
% Step 4: Collect everything in a cell box |
| 499 |
% |
| 500 |
\setbox\pgf@matrix@cell=\hbox\bgroup\bgroup% |
| 501 |
% make sure that cell pictures are not affected if matrizes have |
| 502 |
% 'overlay' option on: |
| 503 |
\pgf@relevantforpicturesizetrue |
| 504 |
\pgfsys@beginpicture% |
| 505 |
\normalbaselines% |
| 506 |
% Find out whether the cell is empty: |
| 507 |
\pgfutil@ifnextchar\let% |
| 508 |
{% ok, candidate, check following symbol |
| 509 |
\afterassignment\pgf@matrix@empty@check\let\pgf@matrix@temp=% get rid of \let |
| 510 |
}% |
| 511 |
{% no, not empty |
| 512 |
\pgf@matrix@empty@cell@false% |
| 513 |
\pgfmatrixbegincode% |
| 514 |
}% |
| 515 |
} |
| 516 |
|
| 517 |
% From pgfmoduleplot.code.tex: |
| 518 |
{ |
| 519 |
\catcode`\%=12 |
| 520 |
\catcode`\"=12 |
| 521 |
\xdef\pgf@gnuplot@head@pgf@two@oo#1{set terminal table; set output "#1.table"; set format "%.5f"} |
| 522 |
\ifx\pgf@gnuplot@head\pgf@gnuplot@head@pgf@two@oo |
| 523 |
\xdef\pgf@gnuplot@head#1{set table "#1.table"; set format "%.5f"} |
| 524 |
\else |
| 525 |
\xdef\pgf@gnuplot@head{set table \noexpand\pgf@plottablefile@quoted; set format "%.5f"} |
| 526 |
\fi |
| 527 |
} |
| 528 |
|
| 529 |
% From pgfcorescopes.code.tex: |
| 530 |
\def\pgfresetboundingbox{% |
| 531 |
\global\pgf@picmaxx=-16000pt\relax% |
| 532 |
\global\pgf@picminx=16000pt\relax% |
| 533 |
\global\pgf@picmaxy=-16000pt\relax% |
| 534 |
\global\pgf@picminy=16000pt\relax% |
| 535 |
}% |
| 536 |
|
| 537 |
% from pgfcorepathconstruct.code.tex: |
| 538 |
|
| 539 |
|
| 540 |
\def\pgfpatharctomaxstepsize{45} |
| 541 |
|
| 542 |
% A specialized arc operation for an arc on an (axis--parallel) ellipse. |
| 543 |
% |
| 544 |
% In contrast to \pgfpatharc, it explicitly interpolates start- and end points. |
| 545 |
% |
| 546 |
% In contrast to \pgfpatharcto, this routine is numerically stable and |
| 547 |
% quite fast since it relies on a lot of precomputed information. |
| 548 |
% |
| 549 |
% #1 center of ellipse |
| 550 |
% #2 angle of last path position inside of the ellipse |
| 551 |
% #3 end angle |
| 552 |
% #4 end point (a \pgfpoint) |
| 553 |
% #5 xradius |
| 554 |
% #6 yradius |
| 555 |
% #7 the ratio xradius/yradius of the ellipse |
| 556 |
% #8 the ratio yradius/xradius of the ellipse |
| 557 |
% Example: |
| 558 |
% \def\cx{1cm}% center x |
| 559 |
% \def\cy{1cm}% center y |
| 560 |
% \def\startangle{0}% |
| 561 |
% \def\endangle{45}% |
| 562 |
% \def\a{5cm}% xradius |
| 563 |
% \def\b{10cm}% yradius |
| 564 |
% \pgfmathparse{\a/\b}\let\abratio=\pgfmathresult |
| 565 |
% \pgfmathparse{\b/\a}\let\baratio=\pgfmathresult |
| 566 |
% |
| 567 |
% \pgfpathmoveto{\pgfpoint{\cx+\a*cos(\startangle)}{\cy+\b*sin(\startangle)}}% |
| 568 |
% \pgfpatharctoprecomputed |
| 569 |
% {\pgfpoint{\cx}{\cy}} |
| 570 |
% {\startangle} |
| 571 |
% {\endangle} |
| 572 |
% {\pgfpoint{\cx+\a*cos(\endangle)}{\cy+\b*sin(\endangle)}}% |
| 573 |
% {\a} |
| 574 |
% {\b} |
| 575 |
% {\abratio} |
| 576 |
% {\baratio} |
| 577 |
% |
| 578 |
\def\pgfpatharctoprecomputed#1#2#3#4#5#6#7#8{% |
| 579 |
\begingroup |
| 580 |
% Implementation idea: |
| 581 |
% |
| 582 |
% let |
| 583 |
% m = center (#1) |
| 584 |
% \gamma_0 = start angle |
| 585 |
% \gamma_1 = end angle |
| 586 |
% a = x radius |
| 587 |
% b = y radius |
| 588 |
% |
| 589 |
% an axis parallel ellipse is parameterized by |
| 590 |
% C(\gamma) = m + ( a cos(\gamma), b sin(\gamma) ), \gamma in [0,360]. |
| 591 |
% |
| 592 |
% Now, consider the segment \gamma(t), |
| 593 |
% \gamma:[0,1] -> [\gamma_0,\gamma_1], |
| 594 |
% t -> \gamma_0 + t(\gamma_1 - \gamma_0) |
| 595 |
% and |
| 596 |
% C(\gamma(t)) which is defined on [0,1]. |
| 597 |
% |
| 598 |
% I'd like to approximate the arc by one or more cubic bezier |
| 599 |
% splines which interpolate through the last and first provided |
| 600 |
% points. |
| 601 |
% |
| 602 |
% In general, a Bezier spline C:[0,1] -> \R of order n fulfills |
| 603 |
% C'(0) = n ( P_1 - P_0 ), |
| 604 |
% C'(1) = n ( P_n - P_{n-1} ). |
| 605 |
% For n=3 and given P_0 and P_3, I can directly compute P_1 and P_2 once I know |
| 606 |
% the derivatives at t=0 and t=1. |
| 607 |
% |
| 608 |
% The derivatives in our case are |
| 609 |
% ( C \circ \gamma )'(t) = C'[\gamma(t)] * \gamma'(t) |
| 610 |
% = ( -a pi/180 sin(\gamma(t)), b pi/180 cos(\gamma(t)) ) * (\gamma_1 - \gamma_0). |
| 611 |
% The pi/180 comes into play since we are working with degrees. |
| 612 |
% |
| 613 |
% Expression (C\circ\gamma)'(0) using P_0 and (C \circ \gamma)'(1) |
| 614 |
% using P_3 yields the expressions |
| 615 |
% (C \circ \gamma)'(0) = |
| 616 |
% pi/180 * (\gamma_1 - \gamma_0)* [ - a/b(P_0^y - my), b/a (P_0^x - mx) ] |
| 617 |
% (C \circ \gamma)'(1) = |
| 618 |
% pi/180 * (\gamma_1 - \gamma_0)* [ - a/b(P_3^y - my), b/a (P_3^x - mx) ] |
| 619 |
% |
| 620 |
% defining |
| 621 |
% scaleA = a/b * pi / (3*180) * (\gamma_1 - \gamma_0) |
| 622 |
% and |
| 623 |
% scaleB = b/a * pi / (3*180) * (\gamma_1 - \gamma_0) |
| 624 |
% yields the direct expressions for the intermediate bezier |
| 625 |
% control points |
| 626 |
% |
| 627 |
% P_1 = [ |
| 628 |
% P_0^x - scaleA* ( P_0^y -my), |
| 629 |
% P_0^y + scaleB* ( P_0^x -mx) ] |
| 630 |
% and |
| 631 |
% P_2 = [ |
| 632 |
% P_3^x + scaleA* ( P_3^y -my), |
| 633 |
% P_3^y - scaleB* ( P_3^x -mx) ]. |
| 634 |
% |
| 635 |
% This works fast, with few operations, if |
| 636 |
% - a/b and b/a are known in advance |
| 637 |
% - P_0 and P_3 are known in advance |
| 638 |
% - \gamma_0 and \gamma_1 are known. |
| 639 |
% |
| 640 |
% It is also reliable if (\gamma_1 - \gamma_0) is small |
| 641 |
% |
| 642 |
\pgf@process{#1}% |
| 643 |
\edef\pgfpath@center@x{\the\pgf@x}% |
| 644 |
\edef\pgfpath@center@y{\the\pgf@y}% |
| 645 |
\def\pgfpath@completearcend{#4}% |
| 646 |
% compute scale (#3-#2) * pi/(3*180) = (#3 - #2) * pi/27 * 1/20 |
| 647 |
% splitting pi/(3*180) into two scales has higher TeX accuracy |
| 648 |
\pgf@xa=#2pt |
| 649 |
\pgf@xb=#3pt |
| 650 |
\edef\pgfpath@startangle{#2pt}% |
| 651 |
\edef\pgfpath@endangle{\pgf@sys@tonumber\pgf@xb}% |
| 652 |
% |
| 653 |
\pgf@ya=\pgf@xb |
| 654 |
\advance\pgf@ya by-\pgf@xa |
| 655 |
% |
| 656 |
\ifx\pgfpatharctomaxstepsize\pgfutil@empty |
| 657 |
\def\pgfpath@N{1}% |
| 658 |
\pgf@xc=\pgf@ya |
| 659 |
\else |
| 660 |
\pgf@xc=\pgf@ya% compute N = floor((gamma_1 - gamma_0) / max) +1 |
| 661 |
\ifdim\pgf@xc<0pt |
| 662 |
\multiply\pgf@xc by-1 |
| 663 |
\fi |
| 664 |
\divide\pgf@xc by\pgfpatharctomaxstepsize\relax |
| 665 |
\afterassignment\pgfutil@gobble@until@relax |
| 666 |
\c@pgf@counta=\the\pgf@xc\relax |
| 667 |
\advance\c@pgf@counta by1 |
| 668 |
\edef\pgfpath@N{\the\c@pgf@counta}% |
| 669 |
% |
| 670 |
\pgf@xc=\pgf@ya |
| 671 |
\divide\pgf@xc by\c@pgf@counta |
| 672 |
\fi |
| 673 |
% |
| 674 |
\edef\pgfpath@h{\pgf@sys@tonumber\pgf@xc}% |
| 675 |
% |
| 676 |
%\message{pgfpathellipse: using N =\pgfpath@N\space spline points y0 = \pgfpath@startangle, y0+i*h, yN=\pgfpath@endangle, i=1,...,(\pgfpath@N-1), with h=\pgfpath@h\space mesh width (total arc angle \pgf@sys@tonumber\pgf@ya).}% |
| 677 |
% |
| 678 |
% |
| 679 |
\pgf@xc=0.116355283466289\pgf@xc % pi/27 |
| 680 |
\divide\pgf@xc by20 |
| 681 |
\pgf@xa=#7\pgf@xc |
| 682 |
\edef\pgfpath@scale@A{\pgf@sys@tonumber\pgf@xa}% |
| 683 |
\pgf@xa=#8\pgf@xc |
| 684 |
\edef\pgfpath@scale@B{\pgf@sys@tonumber\pgf@xa}% |
| 685 |
% |
| 686 |
% compute intermediate spline segments for |
| 687 |
% i = 1,...,N-1 |
| 688 |
% this is a no-op for N=1. |
| 689 |
\c@pgf@countd=1 |
| 690 |
\pgfutil@loop |
| 691 |
\ifnum\c@pgf@countd<\pgfpath@N\relax |
| 692 |
% |
| 693 |
\pgf@xa=\pgfpath@startangle % compute \pgf@xa = y_0 + i*h |
| 694 |
\pgf@xb=\pgfpath@h pt |
| 695 |
\multiply\pgf@xb by\c@pgf@countd |
| 696 |
\advance\pgf@xa by\pgf@xb |
| 697 |
\edef\pgfpath@angle@i{\pgf@sys@tonumber\pgf@xa}% |
| 698 |
%\message{angle \the\c@pgf@countd: \pgfpath@angle@i...}% |
| 699 |
% |
| 700 |
\pgfpatharcofellipse@{% |
| 701 |
\pgfpoint |
| 702 |
{\pgfpath@center@x + #5*cos(\pgfpath@angle@i)} |
| 703 |
{\pgfpath@center@y + #6*sin(\pgfpath@angle@i)} |
| 704 |
}% |
| 705 |
% |
| 706 |
\advance\c@pgf@countd by1 |
| 707 |
\pgfutil@repeat |
| 708 |
% |
| 709 |
% compute final spline segment. It only differs insofar as the |
| 710 |
% final point is already known explicitly and should be |
| 711 |
% interpolated without additional math error. |
| 712 |
%\message{angle \pgfpath@N: \pgfpath@endangle...}% |
| 713 |
\pgfpatharcofellipse@{\pgfpath@completearcend}% |
| 714 |
\endgroup |
| 715 |
}% |
| 716 |
\def\pgfpatharcofellipse@#1{% |
| 717 |
\begingroup |
| 718 |
\pgf@process{#1}% |
| 719 |
\edef\pgfpath@endpt{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% |
| 720 |
% |
| 721 |
\pgfpathcurveto{ |
| 722 |
\begingroup |
| 723 |
\global\pgf@x=\pgf@path@lastx |
| 724 |
\global\pgf@y=\pgf@path@lasty |
| 725 |
\pgf@xa=\pgf@x \advance\pgf@xa by-\pgfpath@center@x |
| 726 |
\pgf@ya=\pgf@y \advance\pgf@ya by-\pgfpath@center@y |
| 727 |
\global\advance\pgf@x by-\pgfpath@scale@A\pgf@ya |
| 728 |
\global\advance\pgf@y by \pgfpath@scale@B\pgf@xa |
| 729 |
\endgroup |
| 730 |
}{% |
| 731 |
\begingroup |
| 732 |
\pgfpath@endpt |
| 733 |
\pgf@xa=\pgf@x \advance\pgf@xa by-\pgfpath@center@x |
| 734 |
\pgf@ya=\pgf@y \advance\pgf@ya by-\pgfpath@center@y |
| 735 |
\global\advance\pgf@x by \pgfpath@scale@A\pgf@ya |
| 736 |
\global\advance\pgf@y by-\pgfpath@scale@B\pgf@xa |
| 737 |
\endgroup |
| 738 |
}{% |
| 739 |
\pgfpath@endpt |
| 740 |
}% |
| 741 |
\endgroup |
| 742 |
} |
| 743 |
|
| 744 |
% bugfix for pgf 2.10, pgfmathfunctions.basic.code.tex : |
| 745 |
% |
| 746 |
\newif\ifpgfmath@divide@period |
| 747 |
\def\pgfmathdivide@#1#2{% |
| 748 |
\begingroup% |
| 749 |
\pgfmath@x=#1pt\relax% |
| 750 |
\pgfmath@y=#2pt\relax% |
| 751 |
\let\pgfmath@sign=\pgfmath@empty% |
| 752 |
\ifdim0pt=\pgfmath@y% |
| 753 |
\pgfmath@error{You've asked me to divide `#1' by `#2', % |
| 754 |
but I cannot divide any number by `#2'}% |
| 755 |
\fi% |
| 756 |
\afterassignment\pgfmath@xa% |
| 757 |
\c@pgfmath@counta\the\pgfmath@y\relax% |
| 758 |
\ifdim0pt=\pgfmath@xa% |
| 759 |
\divide\pgfmath@x by\c@pgfmath@counta% |
| 760 |
\else% |
| 761 |
\ifdim0pt>\pgfmath@x% |
| 762 |
\def\pgfmath@sign{-}% |
| 763 |
\pgfmath@x=-\pgfmath@x% |
| 764 |
\fi% |
| 765 |
\ifdim0pt>\pgfmath@y% |
| 766 |
\expandafter\def\expandafter\pgfmath@sign\expandafter{\pgfmath@sign-}% |
| 767 |
\pgfmath@y=-\pgfmath@y% |
| 768 |
\fi% |
| 769 |
\ifdim1pt>\pgfmath@y% |
| 770 |
\pgfmathreciprocal@{\pgfmath@tonumber{\pgfmath@y}}% |
| 771 |
\pgfmath@x=\pgfmath@sign\pgfmathresult\pgfmath@x% |
| 772 |
\else% |
| 773 |
\def\pgfmathresult{0}% |
| 774 |
\pgfmath@divide@periodtrue% |
| 775 |
\c@pgfmath@counta=0\relax% |
| 776 |
\pgfmathdivide@@% |
| 777 |
\pgfmath@x=\pgfmath@sign\pgfmathresult pt\relax% |
| 778 |
\fi% |
| 779 |
\fi% |
| 780 |
\pgfmath@returnone\pgfmath@x% |
| 781 |
\endgroup% |
| 782 |
} |
| 783 |
\def\pgfmath@small@number{0.00002} |
| 784 |
\def\pgfmathdivide@@{% |
| 785 |
\let\pgfmath@next=\relax% |
| 786 |
\ifdim\pgfmath@small@number pt<\pgfmath@x% |
| 787 |
\ifdim\pgfmath@small@number pt<\pgfmath@y% |
| 788 |
\ifdim\pgfmath@y>\pgfmath@x% |
| 789 |
\ifpgfmath@divide@period% |
| 790 |
\expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult.}% |
| 791 |
\pgfmath@divide@periodfalse% |
| 792 |
\fi% |
| 793 |
\pgfmathdivide@dimenbyten\pgfmath@y% |
| 794 |
\ifdim\pgfmath@y>\pgfmath@x% |
| 795 |
\expandafter\def\expandafter\pgfmathresult\expandafter{\pgfmathresult0}% |
| 796 |
\fi% |
| 797 |
\else% |
| 798 |
\c@pgfmath@counta=\pgfmath@x% |
| 799 |
\c@pgfmath@countb=\pgfmath@y% |
| 800 |
\divide\c@pgfmath@counta by\c@pgfmath@countb% |
| 801 |
\pgfmath@ya=\c@pgfmath@counta\pgfmath@y% |
| 802 |
\advance\pgfmath@x by-\pgfmath@ya% |
| 803 |
\def\pgfmath@next{% |
| 804 |
\toks0=\expandafter{\pgfmathresult}% |
| 805 |
\edef\pgfmathresult{\the\toks0 \the\c@pgfmath@counta}% |
| 806 |
}% |
| 807 |
\ifpgfmath@divide@period |
| 808 |
\else |
| 809 |
% we are behind the period. It may happen that the |
| 810 |
% result is more than one digit - in that case, |
| 811 |
% introduce special handling: |
| 812 |
\ifnum\c@pgfmath@counta>9 % |
| 813 |
\expandafter\pgfmathdivide@advance@last@digit\pgfmathresult CCCCC\@@ |
| 814 |
\advance\c@pgfmath@counta by-10 % |
| 815 |
\ifnum\c@pgfmath@counta=0 |
| 816 |
\let\pgfmath@next=\relax |
| 817 |
\fi |
| 818 |
\fi |
| 819 |
\fi |
| 820 |
\pgfmath@next |
| 821 |
\fi% |
| 822 |
\let\pgfmath@next=\pgfmathdivide@@% |
| 823 |
\fi% |
| 824 |
\fi% |
| 825 |
\pgfmath@next% |
| 826 |
} |
| 827 |
|
| 828 |
% advances the last digit found in the number. Any missing digits are |
| 829 |
% supposed to be filled with 'C'. |
| 830 |
\def\pgfmathdivide@advance@last@digit#1.#2#3#4#5#6#7\@@{% |
| 831 |
\pgfmath@ya=\pgfmathresult pt % |
| 832 |
\if#2C% |
| 833 |
\pgfmath@xa=1pt % |
| 834 |
\else |
| 835 |
\if#3C% |
| 836 |
\pgfmath@xa=0.1pt % |
| 837 |
\else |
| 838 |
\if#4C% |
| 839 |
\pgfmath@xa=0.01pt % |
| 840 |
\else |
| 841 |
\if#5C% |
| 842 |
\pgfmath@xa=0.001pt % |
| 843 |
\else |
| 844 |
\if#6C% |
| 845 |
\pgfmath@xa=0.0001pt % |
| 846 |
\else |
| 847 |
\pgfmath@xa=0.00001pt % |
| 848 |
\fi |
| 849 |
\fi |
| 850 |
\fi |
| 851 |
\fi |
| 852 |
\fi |
| 853 |
\advance\pgfmath@ya by\pgfmath@xa |
| 854 |
\edef\pgfmathresult{\pgfmath@tonumber@notrailingzero\pgfmath@ya}% |
| 855 |
}% |
| 856 |
|
| 857 |
{ |
| 858 |
\catcode`\p=12 |
| 859 |
\catcode`\t=12 |
| 860 |
\gdef\Pgf@geT@NO@TRAILING@ZERO#1.#2pt{% |
| 861 |
#1.% |
| 862 |
\ifnum#2=0 \else #2\fi |
| 863 |
} |
| 864 |
} |
| 865 |
\def\pgfmath@tonumber@notrailingzero#1{\expandafter\Pgf@geT@NO@TRAILING@ZERO\the#1} |