Debian Codegraph @

texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.code.tex

raw
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{pgfcorescopes.code.tex}
11
12 % Globals
13
14 \newbox\pgfpic
15 \newbox\pgf@hbox
16
17 \newbox\pgf@layerbox@main
18
19 \newcount\pgf@picture@serial@count
20
21
22
23 % This if decides whether the position of pictures on the page is
24 % protocolled or not. Normally,
25 % this is switched off as it works only with certain drivers and it
26 % causes external files to be written. When switched on, the position
27 % of pgfpictures are protocolled and can be referenced using
28 % \pgfsys@getposition{XXX} where XXX is the value of \pgfpictureid
29 % inside the picture.
30 \newif\ifpgfrememberpicturepositiononpage
31
32
33
34
35 % Scopes
36
37
38 % Pgf scope environment. All changes of the graphic state are local to
39 % the scope.
40 %
41 % Example:
42 %
43 % \begin{pgfscope}
44 % \pgfsetlinewidth{3pt}
45 % \pgfline{\pgfxy(0,0)}{\pgfxy(3,3)}
46 % \end{pgfscope}
47
48 \def\pgfscope{%
49 \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
50 \pgfsys@beginscope%
51 \pgf@resetpathsizes%
52 \edef\pgfscope@linewidth{\the\pgflinewidth}%
53 \let\pgfscope@stroke@color=\pgf@strokecolor@global%
54 \let\pgfscope@fill@color=\pgf@fillcolor@global%
55 \begingroup}
56 \def\endpgfscope{%
57 \endgroup%
58 \global\pgflinewidth=\pgfscope@linewidth%
59 \global\let\pgf@strokecolor@global=\pgfscope@stroke@color%
60 \global\let\pgf@fillcolor@global=\pgfscope@fill@color%
61 \pgfsys@endscope}
62
63
64
65
66 % Quickly insert a box can contain normal TeX text at the origin.
67 %
68 % #1 = box of width/height and depth 0pt
69 %
70 % Example:
71 %
72 % \pgfqbox{\mybox}
73
74 \def\pgfqbox#1{%
75 \pgfsys@hbox#1%
76 }
77
78
79 % Insert a box that can contain normal TeX text at the origin, but
80 % with the current coordinate transformation matrix synced with the
81 % low-level transformation matrix.
82 %
83 % #1 = box of width/height and depth 0pt
84 %
85 % In essence, this command does the same as if you first said
86 % \pgflowlevelsynccm and then \pgfqbox. However, pgf will use a
87 % ``TeX-translation'' for the translation part of the transformation
88 % cm. This will ensure that hyperlinks ``survive'' at least
89 % translations.
90 %
91 % Example:
92 %
93 % \pgfqboxsynced{\mybox}
94
95 \def\pgfqboxsynced#1{%
96 \pgfsys@hboxsynced#1%
97 }
98
99
100 % Puts some text in a box and inserts it with the current
101 % transformations applied.
102 %
103 % #1 = List of optional positioning. Possible values are ``left'', ``right'',
104 % ``top'', ``bottom'' and ``base''.
105 % #2 = TeX text. May contain verbatims.
106 %
107 % Example:
108 %
109 % \pgftransformshift{\pgfpoint{1cm}{0cm}}
110 % \pgftext{Hello World!}
111
112 \def\pgftext{\pgfutil@ifnextchar[\pgf@text{\pgf@text[]}}%
113 \def\pgf@text[#1]{%
114 \def\pgf@text@options{#1}%
115 \pgf@maketext\pgf@after@text}
116 \def\pgf@after@text{%
117 {%
118 \def\pgf@text@hshift{center}%
119 \def\pgf@text@vshift{center}%
120 \expandafter\pgf@text@setkeys\expandafter{\pgf@text@options}%
121 \csname pgf@halign\pgf@text@hshift\endcsname%
122 \csname pgf@valign\pgf@text@vshift\endcsname%
123 %
124 \pgfapproximatenonlineartransformation%
125 % Protocol sizes:
126 \pgf@process{\pgfpointtransformed{\pgfqpoint{0pt}{\dp\pgf@hbox}}}%
127 \pgf@protocolsizes{\pgf@x}{\pgf@y}%
128 \pgf@process{\pgfpointtransformed{\pgfqpoint{\wd\pgf@hbox}{\dp\pgf@hbox}}}%
129 \pgf@protocolsizes{\pgf@x}{\pgf@y}%
130 \pgf@process{\pgfpointtransformed{\pgfqpoint{0pt}{\ht\pgf@hbox}}}%
131 \pgf@protocolsizes{\pgf@x}{\pgf@y}%
132 \pgf@process{\pgfpointtransformed{\pgfqpoint{\wd\pgf@hbox}{\ht\pgf@hbox}}}%
133 \pgf@protocolsizes{\pgf@x}{\pgf@y}%
134 \pgfqboxsynced{\pgf@hbox}%
135 }%
136 }
137 \def\pgf@text@setkeys{\pgfqkeys{/pgf/text}}%
138
139 \pgfkeys{/pgf/text/left/.code=\def\pgf@text@hshift{left}}
140 \pgfkeys{/pgf/text/center/.code=}
141 \pgfkeys{/pgf/text/right/.code=\def\pgf@text@hshift{right}}
142 \pgfkeys{/pgf/text/top/.code=\def\pgf@text@vshift{top}}
143 \pgfkeys{/pgf/text/bottom/.code=\def\pgf@text@vshift{bottom}}
144 \pgfkeys{/pgf/text/base/.code=\def\pgf@text@vshift{base}}
145 \pgfkeys{/pgf/text/at/.cd,.code=\pgftransformshift{#1},.value required}
146 \pgfkeys{/pgf/text/x/.cd,.code=\pgftransformxshift{#1},.value required}
147 \pgfkeys{/pgf/text/y/.cd,.code=\pgftransformyshift{#1},.value required}
148 \pgfkeys{/pgf/text/rotate/.cd,.code=\pgftransformrotate{#1},.value required}
149
150 \def\pgf@halignleft{}% do nothing
151 \def\pgf@haligncenter{\pgftransformxshift{+-.5\wd\pgf@hbox}}
152 \def\pgf@halignright{\pgftransformxshift{+-\wd\pgf@hbox}}%
153 \def\pgf@valignbase{}% do nothing
154 \def\pgf@valignbottom{\pgftransformyshift{+\dp\pgf@hbox}}%
155 \def\pgf@valigncenter{\pgftransformyshift{+.5\dp\pgf@hbox}\pgftransformyshift{+-.5\ht\pgf@hbox}}%
156 \def\pgf@valigntop{\pgftransformyshift{+-\ht\pgf@hbox}}%
157
158
159 % Internal function for creating a hbox.
160 \def\pgf@maketext#1{%
161 \def\pgf@@maketextafter{#1}%
162 \setbox\pgf@hbox=\hbox\bgroup%
163 \pgfinterruptpicture%
164 \bgroup%
165 \aftergroup\pgf@collectresetcolor%
166 \let\next=%
167 }
168 \def\pgf@collectresetcolor{%
169 \pgfutil@ifnextchar\reset@color%
170 {\reset@color\afterassignment\pgf@collectresetcolor\let\pgf@temp=}%
171 {\pgf@textdone}%
172 }
173 \def\pgf@textdone{%
174 \endpgfinterruptpicture%
175 \egroup%
176 \pgf@@maketextafter%
177 }
178
179 \long\def\pgf@makehbox#1{%
180 \setbox\pgf@hbox=\hbox{{%
181 \pgfinterruptpicture%
182 #1%
183 \endpgfinterruptpicture%
184 }}}
185
186
187
188 % Picture environment
189 %
190 % Example:
191 %
192 % \begin{pgfpicture}
193 % \pgfsetendarrow{\pgfarrowto}
194 % \pgfpathmoveto{\pgfpointxy{-0.9}{0.2}}
195 % \pgfpathlineto{\pgfpointxy{0.9}{0.4}}
196 % \pgfusepath{stroke}
197 % \end{pgfpicture}
198
199 \def\pgfresetboundingbox{%
200 \global\pgf@picmaxx=-16000pt\relax%
201 \global\pgf@picminx=16000pt\relax%
202 \global\pgf@picmaxy=-16000pt\relax%
203 \global\pgf@picminy=16000pt\relax%
204 }%
205
206 \def\pgfpicture{%
207 \begingroup%
208 \pgfpicturetrue%
209 \global\advance\pgf@picture@serial@count by1\relax%
210 \edef\pgfpictureid{pgfid\the\pgf@picture@serial@count}%
211 \let\pgf@nodecallback=\pgfutil@gobble%
212 \pgf@picmaxx=-16000pt\relax%
213 \pgf@picminx=16000pt\relax%
214 \pgf@picmaxy=-16000pt\relax%
215 \pgf@picminy=16000pt\relax%
216 \pgf@relevantforpicturesizetrue%
217 \pgf@resetpathsizes%
218 \pgfutil@ifnextchar\bgroup\pgf@oldpicture\pgf@picture}
219 \def\pgf@oldpicture#1#2#3#4{%
220 \pgfmathsetlength\pgf@picminx{#1}%
221 \pgfmathsetlength\pgf@picminy{#2}%
222 \pgfmathsetlength\pgf@picmaxx{#3}%
223 \pgfmathsetlength\pgf@picmaxy{#4}%
224 \pgf@relevantforpicturesizefalse%
225 \pgf@picture}
226
227 \def\pgf@picture{%
228 \setbox\pgfpic\hbox to0pt\bgroup%
229 \begingroup%
230 \pgfsys@beginpicture%
231 \pgfsys@beginscope%
232 \begingroup%
233 \pgfsetcolor{.}%
234 \pgfsetlinewidth{0.4pt}%
235 \pgftransformreset%
236 \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
237 \begingroup%
238 \let\pgf@setlengthorig=\setlength%
239 \let\pgf@addtolengthorig=\addtolength%
240 \let\pgf@selectfontorig=\selectfont%
241 \let\setlength=\pgf@setlength%
242 \let\addtolength=\pgf@addtolength%
243 \let\selectfont=\pgf@selectfont%
244 \nullfont\spaceskip0pt\xspaceskip0pt%
245 \tracinglostchars=%
246 \ifnum\tracinglostchars>2 2\else\tracinglostchars\fi
247 \setbox\pgf@layerbox@main\hbox to0pt\bgroup%
248 \begingroup%
249 }
250 \def\endpgfpicture{%
251 \ifpgfrememberpicturepositiononpage%
252 \hbox to0pt{\pgfsys@markposition{\pgfpictureid}}%
253 \fi%
254 % ok, now let's position the box
255 \ifdim\pgf@picmaxx=-16000pt\relax%
256 % empty picture. make size 0.
257 \global\pgf@picmaxx=0pt\relax%
258 \global\pgf@picminx=0pt\relax%
259 \global\pgf@picmaxy=0pt\relax%
260 \global\pgf@picminy=0pt\relax%
261 \fi%
262 % Shift baseline outside:
263 \pgf@relevantforpicturesizefalse%
264 \pgf@process{\pgf@baseline}%
265 \xdef\pgf@shift@baseline{\the\pgf@y}%
266 %
267 \pgf@process{\pgf@trimleft}%
268 \global\advance\pgf@x by-\pgf@picminx
269 % prepare \hskip\pgf@trimleft@final.
270 % note that \pgf@trimleft@final is also queried
271 % by the pgf image externalization.
272 \xdef\pgf@trimleft@final{-\the\pgf@x}%
273 %
274 \pgf@process{\pgf@trimright}%
275 \global\advance\pgf@x by-\pgf@picmaxx
276 % prepare \hskip\pgf@trimright@final.
277 % note that \pgf@trimright@final is also queried
278 % by the pgf image externalization.
279 \xdef\pgf@trimright@final{\the\pgf@x}%
280 %
281 \pgf@remember@layerlist@globally
282 \endgroup%
283 \hss%
284 \egroup%
285 \pgf@restore@layerlist@from@global
286 \pgf@insertlayers%
287 \endgroup%
288 \pgfsys@discardpath%
289 \endgroup%
290 \pgfsys@endscope%
291 \pgfsys@endpicture%
292 \endgroup%
293 \hss
294 \egroup%
295 \pgfsys@typesetpicturebox\pgfpic%
296 \endgroup%
297 }
298
299 \def\pgf@remember@layerlist@globally{%
300 \global\let\pgf@layerlist@=\pgf@layerlist
301 }%
302 \def\pgf@restore@layerlist@from@global{%
303 \let\pgf@layerlist=\pgf@layerlist@
304 }%
305 \def\pgf@insertlayers{%
306 \box\pgf@layerbox@main%
307 }
308
309 \def\pgf@selectfont{\pgf@selectfontorig\nullfont}
310
311 \def\pgf@setlength#1#2{% these will be used only when \nullfont is active
312 \begingroup% keep font setting local
313 \pgfutil@selectfont% restore font
314 \pgf@setlengthorig#1{#2}% calculate dimension (possibly using calc)
315 \expandafter%
316 \endgroup%
317 \expandafter#1\expandafter=\the#1\relax}
318 \def\pgf@addtolength#1#2{%
319 \begingroup% keep font setting local
320 \pgfutil@selectfont% restore font
321 \pgf@addtolengthorig#1{#2}% calculate dimension (possibly using calc)
322 \expandafter%
323 \endgroup%
324 \expandafter#1\expandafter=\the#1\relax}
325
326
327 % Sets the baseline at the y-coordinate of a given point
328 %
329 % #1 = point
330 %
331 % Sets the baseline of the picture to the y-coordinate of a given
332 % point. However, the point will be evaluated *at the end of the
333 % picture*.
334 %
335 % Example:
336 %
337 % \pgfsetbaselinepointlater{\pgfpointanchor{mynode}{base}}
338
339 \def\pgfsetbaselinepointlater#1{\def\pgf@baseline{#1}}
340
341
342 % Sets the baseline at the y-coordinate of a given point, now
343 %
344 % #1 = point
345 %
346 % Sets the baseline of the picture to the y-coordinate of a given
347 % point.
348 %
349 % Example:
350 %
351 % \pgfsetbaselinepointnow{\pgfpoint{1cm}{2pt}}
352
353 \def\pgfsetbaselinepointnow#1{%
354 \pgf@process{#1}%
355 \edef\pgf@setter@baseline{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
356 \pgfsetbaselinepointlater{\pgf@setter@baseline}%
357 }
358
359 \def\pgf@default@text{default}%
360
361 % Sets the baseline
362 %
363 % #1 = baseline
364 %
365 % Sets the baseline of the picture. Default is the lower border, which
366 % is the same as \pgf@picminy
367 %
368 % Example:
369 %
370 % \pgfsetbaseline{1cm+2pt}
371 % \pgfsetbaseline{default}% resets to default value
372
373 \def\pgfsetbaseline#1{%
374 \def\pgf@temp{#1}%
375 \ifx\pgf@temp\pgf@default@text
376 \pgfsetbaseline{\pgf@picminy}%
377 \else
378 \pgfsetbaselinepointlater{\pgfpoint{0pt}{#1}}%
379 \fi
380 }
381 \pgfsetbaseline{\pgf@picminy}
382
383 % controls how the image externalization implements trim:
384 \newif\ifpgf@trim@lowlevel
385 \pgfkeys{
386 /pgf/trim lowlevel/.is if=pgf@trim@lowlevel,
387 /pgf/trim lowlevel/.default=true,
388 }
389
390 % Same as the y-baseline for horizontal alignment.
391 % The effect is different, though: it is some kind of trimming which
392 % leaves the bounding box intact.
393 \def\pgfsettrimleftpointlater#1{\def\pgf@trimleft{#1}}
394 \def\pgfsettrimleftpointnow#1{%
395 \pgf@process{#1}%
396 \edef\pgf@setter@baseline{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
397 \pgfsettrimleftpointlater{\pgf@setter@baseline}%
398 }
399 % \pgfsettrimleft{<x coord>}
400 % or
401 % \pgfsettrimleft{default}
402 \def\pgfsettrimleft#1{%
403 \def\pgf@temp{#1}%
404 \ifx\pgf@temp\pgf@default@text
405 \pgfsettrimleft{\pgf@picminx}
406 \else
407 \pgfsettrimleftpointlater{\pgfpoint{#1}{0pt}}%
408 \fi
409 }
410 \pgfsettrimleft{\pgf@picminx}
411
412 \def\pgfsettrimrightpointlater#1{\def\pgf@trimright{#1}}
413 \def\pgfsettrimrightpointnow#1{%
414 \pgf@process{#1}%
415 \edef\pgf@setter@baseline{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
416 \pgfsettrimrightpointlater{\pgf@setter@baseline}%
417 }
418 % \pgfsettrimright{<x coord>}
419 % or
420 % \pgfsettrimright{default}
421 \def\pgfsettrimright#1{%
422 \def\pgf@temp{#1}%
423 \ifx\pgf@temp\pgf@default@text
424 \pgfsettrimright{\pgf@picmaxx}%
425 \else
426 \pgfsettrimrightpointlater{\pgfpoint{#1}{0pt}}%
427 \fi
428 }
429 \pgfsettrimright{\pgf@picmaxx}
430
431
432 % Interrupt path
433 %
434 % Description:
435 %
436 % The environment can be used to insert some drawing commands while
437 % constructing a path. The drawing commands inside the environment
438 % will not interfere with the path being constructed ``outside.''
439 % However, you must ward against graphic state changes using a scope.
440 %
441 % Example: Draw two parallel lines
442 %
443 % \pgfmoveto{\pgfpoint{0cm}{0cm}}
444 % \begin{pgfinterruptpath}
445 % \pgfmoveto{\pgfpoint{1cm}{0cm}}
446 % \pgfmoveto{\pgfpoint{1cm}{1cm}}
447 % \pgfusepath{stroke}
448 % \end{pgfinterruptpath}
449 % \pgflineto{\pgfpoint{0cm}{1cm}}
450 % \pgfusepath{stroke}
451
452 \def\pgfinterruptpath
453 {%
454 \begingroup%
455 % save all sorts of things...
456 \edef\pgf@interrupt@savex{\the\pgf@path@lastx}%
457 \edef\pgf@interrupt@savey{\the\pgf@path@lasty}%
458 \pgf@getpathsizes\pgf@interrupt@pathsizes%
459 \pgfsyssoftpath@getcurrentpath\pgf@interrupt@path%
460 \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
461 \let\pgf@interrupt@lastmoveto=\pgfsyssoftpath@lastmoveto%
462 \begingroup%
463 }
464 \def\endpgfinterruptpath
465 {%
466 \endgroup%
467 \pgfsyssoftpath@setcurrentpath\pgf@interrupt@path%
468 \pgf@setpathsizes\pgf@interrupt@pathsizes%
469 \global\pgf@path@lastx\pgf@interrupt@savex%
470 \global\pgf@path@lasty\pgf@interrupt@savey%
471 \global\let\pgfsyssoftpath@lastmoveto\pgf@interrupt@lastmoveto%
472 \endgroup%
473 }
474
475
476
477 % Interrupt bounding box
478 %
479 % Description:
480 %
481 % The environment can be used to temporarily setup a new bounding box
482 % computation. The bounding box will be made empty at the beginning of
483 % the environment and will be reset to its old value after the
484 % environment.
485 %
486 % Example:
487 %
488 % \begin{pgfinterruptboundinbox}
489 % \pgfmoveto{\pgfpoint{1cm}{0cm}}
490 % \pgfmoveto{\pgfpoint{1cm}{1cm}}
491 % \pgfusepath{stroke}
492 % \end{pgfinterruptboundinbox}
493
494 \def\pgfinterruptboundingbox
495 {%
496 \begingroup%
497 \edef\pgf@interrupt@savemaxx{\the\pgf@picmaxx}%
498 \edef\pgf@interrupt@saveminx{\the\pgf@picminx}%
499 \edef\pgf@interrupt@savemaxy{\the\pgf@picmaxy}%
500 \edef\pgf@interrupt@saveminy{\the\pgf@picminy}%
501 \pgf@picmaxx=-16000pt\relax%
502 \pgf@picminx=16000pt\relax%
503 \pgf@picmaxy=-16000pt\relax%
504 \pgf@picminy=16000pt\relax%
505 \pgf@size@hookedfalse%
506 \let\pgf@path@size@hook=\pgfutil@empty%
507 }
508 \def\endpgfinterruptboundingbox
509 {%
510 \global\pgf@picmaxx=\pgf@interrupt@savemaxx%
511 \global\pgf@picmaxy=\pgf@interrupt@savemaxy%
512 \global\pgf@picminx=\pgf@interrupt@saveminx%
513 \global\pgf@picminy=\pgf@interrupt@saveminy%
514 \endgroup%
515 }
516
517
518
519
520 % Creates an id scope.
521 %
522 % Description:
523 %
524 % An id scope is not (conceptually) a graphic scope, but a scope that
525 % has a unique name or "id". This id can be used as a reference point
526 % for instance for a hyperlink or for an animation (currently, only
527 % SVG supports ids, all other drivers ignore id scopes).
528 %
529 % Prior to using \pgfidscope, call \pgfuseid to install an
530 % id (and possibly \pgfusetype). The scope will then get this id and,
531 % likely, a graphic scope is installed. If \pgfuseid has not been
532 % called or if you try to call \pgfidscope again for the same id,
533 % nothing happens (except for a \TeX\ group being established).
534
535 \def\pgfidscope{\pgfsys@begin@idscope}
536 \def\endpgfidscope{\pgfsys@end@idscope}
537
538 \let\startpgfidscope\pgfidscope
539 \let\stoppgfidscope\pgfendidscope
540
541
542
543
544 % Use an id on the next graphic object
545 %
546 % #1 = a name
547 %
548 % The next scope or path can be the target of an animation command or
549 % a hyperlink.
550
551 \def\pgfuseid#1{%
552 \edef\pgf@temp{#1}%
553 \ifx\pgf@temp\pgfutil@empty%
554 \else%
555 \pgf@lookup@id{#1}%
556 \pgfsys@use@id{\pgf@next@id}%
557 \expandafter\xdef\csname pgf@id@names@#1\endcsname{{\pgf@next@id}{}}%
558 \fi%
559 }
560
561 \def\pgf@lookup@id#1{%
562 \expandafter\let\expandafter\pgf@id@name\csname pgf@id@names@#1\endcsname%
563 \ifx\pgf@id@name\relax%
564 \let\pgf@prev@id\pgfutil@empty%
565 \let\pgf@next@id\pgfutil@empty%
566 \else%
567 \expandafter\pgf@id@parse\pgf@id@name%
568 \fi%
569 \ifx\pgf@next@id\pgfutil@empty%
570 \pgfsys@new@id\pgf@next@id%
571 \expandafter\xdef\csname pgf@id@names@#1\endcsname{{\pgf@prev@id}{\pgf@next@id}}%
572 \fi%
573 }
574 \def\pgf@id@parse#1#2{%
575 \def\pgf@prev@id{#1}%
576 \def\pgf@next@id{#2}%
577 }
578
579
580
581 % Clear the current id
582 %
583 % Description:
584 %
585 % Sets the current id to be empty so that it cannot be referenced.
586
587 \def\pgfclearid{%
588 \pgfsys@clear@id%
589 }
590
591
592 % Get the id that will be given to a name upon the next use
593 %
594 % #1 = a macro
595 % #2 = a name
596 %
597 % Description:
598 %
599 % #1 will get the id that will be used by \pgfuseid next time for the
600 % given name.
601
602 \def\pgfidrefnextuse#1#2{%
603 \edef\pgf@temp{#2}\ifx\pgf@temp\pgfutil@empty\pgferror{Missing name reference for ``\string#1''}\fi%
604 \pgf@lookup@id{#2}%
605 \let#1\pgf@next@id%
606 }
607
608
609 % Get the id was last used
610 %
611 % #1 = a macro
612 % #2 = a name
613 %
614 % Description:
615 %
616 % #1 will get the id that was last used by \pgfuseid for #2.
617
618 \def\pgfidrefprevuse#1#2{%
619 \edef\pgf@temp{#2}\ifx\pgf@temp\pgfutil@empty\pgferror{Missing name reference for ``\string#1''}\fi%
620 \pgf@lookup@id{#2}%
621 \let#1\pgf@prev@id%
622 }
623
624
625 % Use a type
626 %
627 % #1 = an id type; when starting with a dot, it is added to the
628 % current type.
629 %
630 % The next scope or path can be the target of an animation command or
631 % a hyperlink.
632
633 \def\pgfusetype#1{%
634 \edef\pgf@temp{#1}%
635 \expandafter\pgfutil@ifnextchar\expandafter.\expandafter\pgf@id@use@type@add\expandafter\pgf@id@use@type@replace\pgf@temp\pgf@stop
636 }
637 \def\pgf@id@use@type@add.#1\pgf@stop{\pgfsys@append@type{#1}}
638 \def\pgf@id@use@type@replace#1\pgf@stop{\pgfsys@use@type{#1}}
639
640 % Push the current type on a global stack
641 %
642 % Description:
643 %
644 % The current type is pushed onto a global type stack. It can be
645 % restored using \pgfpoptype.
646
647 \def\pgfpushtype{\pgfsys@push@type}
648
649
650 % Pop a type from the type stack
651 %
652 % Description:
653 %
654 % Restores the most current value from the type stack.
655
656 \def\pgfpoptype{\pgfsys@pop@type}
657
658
659
660
661 % Alias an id locally or globally
662 %
663 % #1 = the alias name
664 % #2 = a existing id name
665 %
666 % Description:
667 %
668 % Creates an alias of a name
669
670 \def\pgfaliasid#1#2{%
671 \expandafter\let\expandafter\pgf@temp\csname pgf@id@names@#2\endcsname%
672 \expandafter\let\csname pgf@id@names@#1\endcsname\pgf@temp%
673 }
674 \def\pgfgaliasid#1#2{%
675 \expandafter\let\expandafter\pgf@temp\csname pgf@id@names@#2\endcsname%
676 \expandafter\global\expandafter\let\csname pgf@id@names@#1\endcsname\pgf@temp%
677 }
678
679
680 % Check whether a name has been forward-referenced
681 %
682 % #1 = a name
683 % #2 = what to do, when has been forward-referenced
684 % #3 = what to do otherwise
685 %
686 % Description:
687 %
688 % Depending on whether #1 has been forward-referenced, #2 or #3 will be executed.
689
690 \def\pgfifidreferenced#1#2#3{%
691 \expandafter\let\expandafter\pgf@id@name\csname pgf@id@names@#1\endcsname%
692 \ifx\pgf@id@name\relax%
693 #3%
694 \else
695 \expandafter\pgf@id@parse\pgf@id@name%
696 \ifx\pgf@next@id\pgfutil@empty%
697 #3%
698 \else%
699 #2%
700 \fi%
701 \fi%
702 }
703
704
705 % Interrupts a picture
706 %
707 % Description:
708 %
709 % This environment interrupts a picture and temporarily returns to
710 % normal TeX mode. All sorts of things are saved and restored by this
711 % environment.
712 %
713 % WARNING: Using this environment in conjunction with low level
714 % transformations can *strongly* upset the typesetting. Typically, the
715 % contents of this environment should have size/height/depth 0pt in
716 % the end.
717 %
718 % WARNING: This environment should only be used inside typesetting a
719 % box and this box must in turn be inserted using \pgfqbox.
720 %
721 % Example: Draw two parallel lines
722 %
723 % \pgfmoveto{\pgfpoint{0cm}{0cm}}
724 % \setbox\mybox=\hbox{
725 % \begin{pgfinterruptpicture}
726 % This is normal text.
727 % \begin{pgfpicture} % a subpicture
728 % \pgfmoveto{\pgfpoint{1cm}{0cm}}
729 % \pgfmoveto{\pgfpoint{1cm}{1cm}}
730 % \pgfusepath{stroke}
731 % \end{pgfpicture}
732 % More text.
733 % \end{pgfinterruptpicture}
734 % }
735 % \ht\mybox=0pt
736 % \wd\mybox=0pt
737 % \dp\mybox=0pt
738 % \pgfqbox{\mybox}%
739 % \pgfpathlineto{\pgfpoint{0cm}{1cm}}
740 % \pgfusepath{stroke}
741
742 \def\pgfinterruptpicture
743 {%
744 \begingroup%
745 \csname tikz@inside@picturefalse\endcsname%
746 \pgfinterruptboundingbox%
747 \pgftransformreset%
748 \pgfinterruptpath%
749 \ifx\pgf@selectfontorig\@undefined%
750 \else%
751 \let\setlength\pgf@setlengthorig%
752 \let\addtolength\pgf@addtolengthorig%
753 \let\selectfont\pgf@selectfontorig%
754 \fi%
755 \pgfutil@selectfont%
756 \pgfpicturefalse%
757 \let\pgf@positionnodelater@macro\relax%
758 \pgf@savelayers%
759 }
760 \def\endpgfinterruptpicture
761 {%
762 \pgf@restorelayers%
763 \endpgfinterruptpath%
764 \endpgfinterruptboundingbox%
765 \endgroup%
766 }
767
768 \let\pgf@savelayers=\relax
769 \let\pgf@restorelayers=\relax
770
771 \endinput