Debian Codegraph @

texmf-dist/tex/generic/pgf/libraries/shapes/pgflibraryshapes.callouts.code.tex

raw
1 % Copyright 2018 by Mark Wibrow
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 \usepgflibrary{shapes.symbols}%
11
12 % Keys for callouts
13 %
14 % Common to all callouts:
15 % /pgf/callout absolute pointer
16 % /pgf/callout relative pointer
17 %
18 % ellipse callout only:
19 % /pgf/callout pointer arc
20 %
21 % rectangle callout only:
22 % /pgf/callout pointer width
23 %
24 % cloud callout only:
25 % /pgf/callout pointer start size
26 % /pgf/callout pointer end size
27 % /pgf/callout pointer segments
28 %
29 \newif\ifpgf@lib@callout@absolutepointer
30 \pgfkeys{/pgf/.cd,
31 callout pointer arc/.initial=15,
32 callout pointer width/.initial=.25cm,
33 callout pointer start size/.initial=.2 of callout,
34 callout pointer end size/.initial=.1 of callout,
35 callout pointer segments/.initial=2,
36 callout absolute pointer/.code={\pgf@lib@callout@makeabsolutepointer{#1}},
37 callout relative pointer/.code={\pgf@lib@callout@makerelativepointer{#1}},
38 callout pointer shorten/.initial=0cm,
39 }%
40
41
42
43 \def\pgf@lib@callout@makeabsolutepointer#1{%
44 \pgf@lib@callout@absolutepointertrue%
45 {%
46 \pgftransformshift{#1}%
47 \pgfmultipartnode{coordinate}{center}{pgf@lib@callout@pointer}{}%
48 }%
49 }%
50
51 \def\pgf@lib@callout@makerelativepointer#1{%
52 \pgf@lib@callout@absolutepointerfalse%
53 \def\pgf@lib@callout@relativepointer{#1}%
54 }%
55 \pgfkeys{/pgf/callout relative pointer=\pgfpointpolar{300}{.5cm}}%
56
57
58 % Shape ellipse callout
59 %
60 %
61 \pgfdeclareshape{ellipse callout}{%
62 \savedmacro\ellipsecalloutpoints{%
63 %
64 % Get the larger of the outer sep.
65 %
66 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
67 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
68 \ifdim\pgf@x>\pgf@y%
69 \edef\outersep{\the\pgf@x}%
70 \else%
71 \edef\outersep{\the\pgf@y}%
72 \fi%
73 \addtosavedmacro\outersep%
74 %
75 % Calculate the node dimensions...
76 %
77 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
78 \advance\[email protected]\wd\pgfnodeparttextbox%
79 \[email protected]\pgf@x%
80 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/minimum width}}%
81 \ifdim\pgf@x<.5\pgf@xa%
82 \[email protected]\pgf@xa%
83 \fi%
84 %
85 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
86 \advance\[email protected]\ht\pgfnodeparttextbox%
87 \advance\[email protected]\dp\pgfnodeparttextbox%
88 \[email protected]\pgf@y%
89 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/minimum height}}%
90 \ifdim\pgf@y<.5\pgf@ya%
91 \[email protected]\pgf@ya%
92 \fi%
93 %
94 % ...without outer sep...
95 %
96 \edef\xpathradius{\the\pgf@x}%
97 \edef\ypathradius{\the\pgf@y}%
98 %
99 % ...and width outer sep.
100 %
101 \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
102 \edef\xradius{\the\pgf@x}%
103 \pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
104 \edef\yradius{\the\pgf@y}%
105 %
106 \addtosavedmacro\xradius%
107 \addtosavedmacro\xpathradius%
108 \addtosavedmacro\yradius%
109 \addtosavedmacro\ypathradius%
110 %
111 \pgfmathsetmacro\pointerarc{\pgfkeysvalueof{/pgf/callout pointer arc}}%
112 \addtosavedmacro\pointerarc%
113 %
114 \pgfextract@process\centerpoint{%
115 \[email protected]\wd\pgfnodeparttextbox%
116 \[email protected]\ht\pgfnodeparttextbox%
117 \advance\[email protected]\dp\pgfnodeparttextbox%
118 }%
119 %
120 % Get the relative pointer.
121 %
122 \ifpgf@lib@callout@absolutepointer%
123 \else%
124 \pgfextract@process\calloutpointer{%
125 \pgfextract@process\borderpoint{%
126 \expandafter\pgfpointborderellipse\expandafter{\pgf@lib@callout@relativepointer}{\pgfqpoint{\xpathradius}{\ypathradius}}%
127 }%
128 \pgfmathanglebetweenpoints{\pgfpointorigin}{\borderpoint}%
129 \let\pointerangle\pgfmathresult%
130 \expandafter\pgf@process\expandafter{\pgf@lib@callout@relativepointer}%
131 \pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}%
132 \edef\pointerradius{\pgfmathresult pt}%
133 \pgfpointadd{\borderpoint}{\pgfqpointpolar{\pointerangle}{\pointerradius}}%
134 \pgf@xa\pgf@x%
135 \pgf@ya\pgf@y%
136 \centerpoint%
137 \advance\pgf@x\pgf@xa%
138 \advance\pgf@y\pgf@ya%
139 }%
140 %
141 \addtosavedmacro\calloutpointer%
142 \pgf@lib@callouts@shortenpointer%
143 \pgf@lib@ellipsecallout@getpoints%
144 \addtosavedmacro\calloutpointeranchor%
145 \addtosavedmacro\beforecalloutangle%
146 \addtosavedmacro\aftercalloutangle%
147 \fi%
148 }%
149 \savedanchor\centerpoint{%
150 \[email protected]\wd\pgfnodeparttextbox%
151 \[email protected]\ht\pgfnodeparttextbox%
152 \advance\[email protected]\dp\pgfnodeparttextbox%
153 }%
154 \savedanchor\midpoint{%
155 \[email protected]\wd\pgfnodeparttextbox%
156 \pgfmathsetlength\pgf@y{+.5ex}%
157 }%
158 \savedanchor\basepoint{%
159 \[email protected]\wd\pgfnodeparttextbox%
160 \pgf@y0pt\relax%
161 }%
162 \anchor{center}{\centerpoint}%
163 \anchor{mid}{\midpoint}%
164 \anchor{mid east}{%
165 \ellipsecalloutpoints%
166 \pgfmathpointintersectionoflineandarc{\midpoint\advance\pgf@x\xradius}{\midpoint}%
167 {\centerpoint}{270}{450}{\xradius and \yradius}%
168 }%
169 \anchor{mid west}{%
170 \ellipsecalloutpoints%
171 \pgfmathpointintersectionoflineandarc{\midpoint\advance\pgf@x-\xradius}{\midpoint}%
172 {\centerpoint}{90}{270}{\xradius and \yradius}%
173 }%
174 \anchor{base}{\basepoint}%
175 \anchor{base east}{%
176 \ellipsecalloutpoints%
177 \pgfmathpointintersectionoflineandarc{\basepoint\advance\pgf@x\xradius}{\basepoint}%
178 {\centerpoint}{270}{450}{\xradius and \yradius}%
179 }%
180 \anchor{base west}{%
181 \ellipsecalloutpoints%
182 \pgfmathpointintersectionoflineandarc{\basepoint\advance\pgf@x-\xradius}{\basepoint}%
183 {\centerpoint}{90}{270}{\xradius and \yradius}%
184 }%
185 \anchor{north}{%
186 \ellipsecalloutpoints%
187 \centerpoint%
188 \advance\pgf@y\yradius\relax%
189 }%
190 \anchor{south}{%
191 \ellipsecalloutpoints%
192 \centerpoint%
193 \advance\pgf@y-\yradius\relax%
194 }%
195 \anchor{east}{%
196 \ellipsecalloutpoints%
197 \centerpoint%
198 \advance\pgf@x\xradius\relax%
199 }%
200 \anchor{west}{%
201 \ellipsecalloutpoints%
202 \centerpoint%
203 \advance\pgf@x-\xradius\relax%
204 }%
205 \anchor{north west}{%
206 \ellipsecalloutpoints%
207 \pgf@xa\xradius\relax%
208 \pgf@ya\yradius\relax%
209 \centerpoint%
210 \advance\[email protected]\pgf@ya%
211 \advance\[email protected]\pgf@xa%
212 }%
213 \anchor{north east}{%
214 \ellipsecalloutpoints%
215 \pgf@xa\xradius\relax%
216 \pgf@ya\yradius\relax%
217 \centerpoint%
218 \advance\[email protected]\pgf@ya%
219 \advance\[email protected]\pgf@xa%
220 }%
221 \anchor{south west}{%
222 \ellipsecalloutpoints%
223 \pgf@xa\xradius\relax%
224 \pgf@ya\yradius\relax%
225 \centerpoint%
226 \advance\[email protected]\pgf@ya%
227 \advance\[email protected]\pgf@xa%
228 }%
229 \anchor{south east}{%
230 \ellipsecalloutpoints%
231 \pgf@xa\xradius\relax%
232 \pgf@ya\yradius\relax%
233 \centerpoint%
234 \advance\[email protected]\pgf@ya%
235 \advance\[email protected]\pgf@xa%
236 }%
237 \anchor{pointer}{%
238 \ellipsecalloutpoints%
239 \calloutpointeranchor%
240 }%
241 \backgroundpath{%
242 \ellipsecalloutpoints%
243 \ifpgf@lib@callout@absolutepointer%
244 \pgfextract@process\calloutpointer{%
245 \pgfpointanchor{pgf@lib@callout@pointer}{center}%
246 }%
247 \pgf@lib@callouts@shortenpointer%
248 \pgf@lib@ellipsecallout@getpoints%
249 \calloutpointeranchor%
250 \ifx\pgf@node@name\pgfutil@empty%
251 \else%
252 \edef\pgf@sh@@temp{\noexpand\expandafter\noexpand\pgfutil@g@addto@macro\noexpand\csname pgf@sh@np@\pgf@node@name\noexpand\endcsname}%
253 \edef\pgf@sh@@@temp{%
254 \noexpand\def\noexpand\calloutpointeranchor{%
255 \noexpand\pgf@x\the\pgf@x%
256 \noexpand\pgf@y\the\pgf@y%
257 }%
258 }%
259 \expandafter\pgf@sh@@temp\expandafter{\pgf@sh@@@temp}
260 \fi%
261 \fi%
262 \pgfpathmoveto{\calloutpointer}%
263 \pgfpathlineto{\aftercalloutpointer}%
264 \ifdim\aftercalloutangle pt<\beforecalloutangle pt\relax%
265 \pgfpatharc{\aftercalloutangle}{\beforecalloutangle}{\xpathradius and \ypathradius}%
266 \else%
267 \pgfpatharc{\aftercalloutangle}{360}{\xpathradius and \ypathradius}%
268 \pgfpatharc{0}{\beforecalloutangle}{\xpathradius and \ypathradius}%
269 \fi%
270 \pgfpathclose%
271 }%
272 \anchorborder{%
273 \pgfextract@process\externalpoint{}%
274 \ellipsecalloutpoints%
275 \pgfpointadd{\pgfpointborderellipse{\externalpoint}{\pgfpoint{\xradius}{\yradius}}%
276 }{\centerpoint}%
277 }%
278 }%
279
280 % Internal macro for calculating the points for the
281 % ellipse callout pointer.
282 %
283 % The following must be set up:
284 %
285 % \centerpoint - the center of the ellipse.
286 % \calloutpointer - the location of the callout point.
287 % \pointerarc - the width of the pointer.
288 % \xpathradius - the x radius of the ellipse.
289 % \ypathradius - the y radius of the ellipse.
290 %
291 \def\pgf@lib@ellipsecallout@getpoints{%
292 \pgfextract@process\borderpoint{%
293 \pgfpointborderellipse{%
294 \centerpoint%
295 \pgf@xa\pgf@x%
296 \pgf@ya\pgf@y%
297 \calloutpointer%
298 \advance\pgf@x-\pgf@xa%
299 \advance\pgf@y-\pgf@ya%
300 }{\pgfqpoint{\xpathradius}{\ypathradius}}%
301 }%
302 \pgfmathangleonellipse{\borderpoint}{\xpathradius and \ypathradius}%
303 \pgfutil@tempdima\pointerarc pt\relax%
304 \pgfutil@tempdimb\pgfmathresult pt\relax%
305 \advance\[email protected]\pgfutil@tempdima%
306 \ifdim\pgfutil@tempdimb<0pt\relax%
307 \advance\pgfutil@tempdimb360pt\relax%
308 \fi%
309 \edef\beforecalloutangle{\pgfmath@tonumber{\pgfutil@tempdimb}}%
310 \advance\pgfutil@tempdimb\pgfutil@tempdima%
311 \ifdim\pgfutil@tempdimb<360pt\relax%
312 \else%
313 \advance\pgfutil@tempdimb-360pt\relax%
314 \fi%
315 \edef\aftercalloutangle{\pgfmath@tonumber{\pgfutil@tempdimb}}%
316 %
317 \pgfextract@process\beforecalloutpointer{%
318 \pgfpointadd{\centerpoint}{%
319 \pgfpointpolar{\beforecalloutangle}{\xpathradius and \ypathradius}%
320 }%
321 }%
322 \pgfextract@process\aftercalloutpointer{%
323 \pgfpointadd{\centerpoint}{%
324 \pgfpointpolar{\aftercalloutangle}{\xpathradius and \ypathradius}%
325 }%
326 }%
327 %
328 % Calculate the pointer anchor.
329 %
330 \pgf@lib@callouts@pointeranchor%
331 }%
332
333
334 % If the callout pointer is very pointed and stroked, the anchor will be
335 % miles away from the end of the pointer which will (typically) be
336 % bevelled.
337 % Using outer sep=0pt is one solution, however, another is provided
338 % using this special key:
339 %
340 % /pgf/callout pointer anchor aspect
341 %
342 % which takes a value from 0 (ignore any outer sep) to 1 (use
343 % the full outer sep).
344
345 \pgfkeys{/pgf/callout pointer anchor aspect/.initial=1}%
346
347 % Internal macro for calculating the anchor for the callout pointer.
348 %
349 % Requires the following to be set up (points are anti-clockwise)
350 %
351 % \beforecalloutpointer - point on the border before the callout pointer
352 % \calloutpointer
353 % \aftercalloutpointer - point on the border after the callout pointer
354 % \outersep - the largest of the outer xsep or ysep.
355 %
356 \def\pgf@lib@callouts@pointeranchor{%
357 \pgfutil@tempdimb\outersep\relax%
358 %
359 \pgfmathanglebetweenlines{\calloutpointer}{\aftercalloutpointer}{\calloutpointer}{\beforecalloutpointer}%
360 \pgfmathdivide@{\pgfmathresult}{2}%
361 \pgfutil@tempdima\pgfmathresult pt\relax%
362 \pgfmathcosec@{\pgfmathresult}%
363 \pgfutil@tempdimb\pgfmathresult\pgfutil@tempdimb%
364 \pgfmathanglebetweenpoints{\calloutpointer}{\aftercalloutpointer}%
365 \advance\pgfutil@tempdima\pgfmathresult pt\relax%
366 \advance\pgfutil@tempdima180pt\relax%
367 %
368 \pgfextract@process\calloutpointeranchor{%
369 \pgfpointadd{%
370 \pgfmathparse{\pgfkeysvalueof{/pgf/callout pointer anchor aspect}}%
371 \pgfutil@tempdimb\pgfmathresult\pgfutil@tempdimb%
372 \pgfqpointpolar{\pgfmath@tonumber{\pgfutil@tempdima}}{\the\pgfutil@tempdimb}%
373 }{%
374 \calloutpointer%
375 }%
376 }%
377 }%
378
379 \def\pgf@lib@callouts@shortenpointer{%
380 \pgfextract@process\calloutpointer{%
381 \pgfmathanglebetweenpoints{\calloutpointer}{\centerpoint}%
382 \let\angle\pgfmathresult%
383 \pgfmathsin@{\angle}%
384 \let\sinpointerangle\pgfmathresult%
385 \pgfmathcos@{\angle}%
386 \let\cospointerangle\pgfmathresult%
387 \pgfpointadd{\calloutpointer}{%
388 \pgfmathsetlength\pgfutil@tempdima{\pgfkeysvalueof{/pgf/callout pointer shorten}}%
389 \pgf@x\cospointerangle\pgfutil@tempdima%
390 \pgf@y\sinpointerangle\pgfutil@tempdima%
391 }%
392 }%
393 }%
394
395
396 \pgfdeclareshape{rectangle callout}{%
397 \savedmacro\rectanglecalloutpoints{%
398 %
399 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}%
400 \advance\[email protected]\wd\pgfnodeparttextbox%
401 \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/minimum width}}%
402 \ifdim\pgf@x<.5\pgf@xa%
403 \[email protected]\pgf@xa%
404 \fi%
405 \edef\xtemp{\the\pgf@x}%
406 \pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
407 %
408 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}%
409 \advance\[email protected]\ht\pgfnodeparttextbox%
410 \advance\[email protected]\dp\pgfnodeparttextbox%
411 \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/minimum height}}%
412 \ifdim\pgf@y<.5\pgf@ya%
413 \[email protected]\pgf@ya%
414 \fi%
415 \edef\ytemp{\the\pgf@y}%
416 \pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
417 %
418 \edef\xlength{\the\pgf@x}%
419 \edef\ylength{\the\pgf@y}%
420 \addtosavedmacro\xlength%
421 \addtosavedmacro\ylength%
422 %
423 \pgfmathsetlengthmacro\pointerwidth{\pgfkeysvalueof{/pgf/callout pointer width}}%
424 \addtosavedmacro\pointerwidth%
425 %
426 \pgfextract@process\centerpoint{%
427 \[email protected]\wd\pgfnodeparttextbox%
428 \[email protected]\ht\pgfnodeparttextbox%
429 \advance\[email protected]\dp\pgfnodeparttextbox%
430 }%
431 %
432 % Process the relative callout pointer.
433 %
434 \ifpgf@lib@callout@absolutepointer%
435 \else%
436 \pgfextract@process\calloutpointer{%
437 \pgfextract@process\borderpoint{%
438 \expandafter\pgfpointborderrectangle\expandafter{\pgf@lib@callout@relativepointer}%
439 {\pgfqpoint{\xtemp}{\ytemp}}%
440 }%
441 \pgfmathanglebetweenpoints{\pgfpointorigin}{\borderpoint}%
442 \let\pointerangle\pgfmathresult%
443 \expandafter\pgf@process\expandafter{\pgf@lib@callout@relativepointer}%
444 \pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}%
445 \edef\pointerradius{\pgfmathresult pt}%
446 \pgfpointadd{\borderpoint}{\pgfqpointpolar{\pointerangle}{\pointerradius}}%
447 \pgf@xa\pgf@x%
448 \pgf@ya\pgf@y%
449 \centerpoint%
450 \advance\pgf@x\pgf@xa%
451 \advance\pgf@y\pgf@ya%
452 }%
453 \pgf@lib@callouts@shortenpointer%
454 \addtosavedmacro\calloutpointer%
455 \pgf@lib@rectanglecallout@pointer%
456 \addtosavedmacro\calloutpointeranchor%
457 \addtosavedmacro\beforecalloutpointer%
458 \addtosavedmacro\aftercalloutpointer%
459 \addtosavedmacro\firstpoint%
460 \addtosavedmacro\secondpoint%
461 \addtosavedmacro\thirdpoint%
462 \addtosavedmacro\fourthpoint%
463 \fi%
464 }%
465 \savedanchor\centerpoint{%
466 \[email protected]\wd\pgfnodeparttextbox%
467 \[email protected]\ht\pgfnodeparttextbox%
468 \advance\[email protected]\dp\pgfnodeparttextbox%
469 }%
470 \savedanchor\basepoint{%
471 \[email protected]\wd\pgfnodeparttextbox%
472 \pgf@y0pt\relax%
473 }%
474 \savedanchor\midpoint{%
475 \[email protected]\wd\pgfnodeparttextbox%
476 \pgfmathsetlength\pgf@y{+.5em}%
477 }%
478 \anchor{center}{\centerpoint}%
479 \anchor{mid}{\midpoint}%
480 \anchor{mid east}{%
481 \rectanglecalloutpoints%
482 \midpoint%
483 \advance\pgf@x\xlength\relax%
484 }%
485 \anchor{mid west}{%
486 \rectanglecalloutpoints%
487 \midpoint%
488 \advance\pgf@x-\xlength\relax%
489 }%
490 \anchor{base}{\basepoint}%
491 \anchor{base east}{%
492 \rectanglecalloutpoints%
493 \basepoint%
494 \advance\pgf@x\xlength\relax%
495 }%
496 \anchor{base west}{%
497 \rectanglecalloutpoints%
498 \basepoint%
499 \advance\pgf@x-\xlength\relax%
500 }%
501 \anchor{north}{%
502 \rectanglecalloutpoints%
503 \centerpoint%
504 \advance\pgf@y\ylength\relax%
505 }%
506 \anchor{south}{%
507 \rectanglecalloutpoints%
508 \centerpoint%
509 \advance\pgf@y-\ylength\relax%
510 }%
511 \anchor{east}{%
512 \rectanglecalloutpoints%
513 \centerpoint%
514 \advance\pgf@x\xlength\relax%
515 }%
516 \anchor{west}{%
517 \rectanglecalloutpoints%
518 \centerpoint%
519 \advance\pgf@x-\xlength\relax%
520 }%
521 \anchor{north east}{%
522 \rectanglecalloutpoints%
523 \centerpoint%
524 \advance\pgf@x\xlength\relax%
525 \advance\pgf@y\ylength\relax%
526 }%
527 \anchor{south west}{%
528 \rectanglecalloutpoints%
529 \centerpoint%
530 \advance\pgf@x-\xlength\relax%
531 \advance\pgf@y-\ylength\relax%
532 }%
533 \anchor{south east}{%
534 \rectanglecalloutpoints%
535 \centerpoint%
536 \advance\pgf@x\xlength\relax%
537 \advance\pgf@y-\ylength\relax%
538 }%
539 \anchor{north west}{%
540 \rectanglecalloutpoints%
541 \centerpoint%
542 \advance\pgf@x-\xlength\relax%
543 \advance\pgf@y\ylength\relax%
544 }%
545 \anchor{pointer}{%
546 \rectanglecalloutpoints%
547 \calloutpointeranchor%
548 }%
549 \backgroundpath{%
550 \rectanglecalloutpoints%
551 \pgf@x\xlength\relax%
552 \pgf@y\ylength\relax%
553 \pgfmathaddtolength\pgf@x{-\pgfkeysvalueof{/pgf/outer xsep}}%
554 \pgfmathaddtolength\pgf@y{-\pgfkeysvalueof{/pgf/outer ysep}}%
555 \edef\xtemp{\the\pgf@x}%
556 \edef\ytemp{\the\pgf@y}%
557 %
558 % The absolute pointer must be calculated here because the
559 % anchor of the shape (which is calculated after the saved
560 % macros and points) affects how the pointer joins the
561 % main rectangle.
562 %
563 \ifpgf@lib@callout@absolutepointer%
564 \pgfextract@process\calloutpointer{%
565 \pgfpointanchor{pgf@lib@callout@pointer}{center}%
566 }%
567 \pgf@lib@callouts@shortenpointer%
568 \pgfmathsetlengthmacro\pointerwidth{\pgfkeysvalueof{/pgf/callout pointer width}}%
569 \pgf@lib@rectanglecallout@pointer%
570 %
571 % \pgf@node@name = the shape name (from \pgfmultipartnode)
572 %
573 \ifx\pgf@node@name\pgfutil@empty%
574 \else%
575 %
576 % Now hack an extra saved anchor \calloutpointeranchor,
577 % with the new anchor for the callout pointer.
578 %
579 \edef\pgf@sh@@temp{\noexpand\expandafter\noexpand\pgfutil@g@addto@macro\noexpand\csname pgf@sh@np@\pgf@node@name\noexpand\endcsname}%
580 \edef\pgf@sh@@@temp{%
581 \noexpand\def\noexpand\calloutpointeranchor{%
582 \noexpand\pgf@x\the\pgf@x%
583 \noexpand\pgf@y\the\pgf@y%
584 }%
585 }%
586 \expandafter\pgf@sh@@temp\expandafter{\pgf@sh@@@temp}%
587 \fi%
588 \fi%
589 {%
590 \pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}%
591 \pgfpathmoveto{\beforecalloutpointer}%
592 }%
593 \pgfpathlineto{\calloutpointer}%
594 {%
595 \pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}%
596 \pgfpathlineto{\aftercalloutpointer}%
597 }%
598 {%
599 \pgftransformshift{\centerpoint}%
600 \pgfpathlineto{\firstpoint}%
601 \pgfpathlineto{\secondpoint}%
602 \pgfpathlineto{\thirdpoint}%
603 \pgfpathlineto{\fourthpoint}%
604 {%
605 \pgfsetcornersarced{\pgfqpoint{0pt}{0pt}}%
606 \pgfpathclose%
607 }%
608 }
609 }%
610 \anchorborder{%
611 \pgfextract@process\externalpoint{}%
612 \rectanglecalloutpoints%
613 \pgfpointadd{\centerpoint}%
614 {%
615 \pgfpointborderrectangle{\pgfpointadd{\centerpoint}{\externalpoint}}%
616 {\pgfqpoint{\xlength}{\ylength}}%
617 }%
618 }%
619 }%
620
621
622
623 % \pgf@lib@rectanglecallout@pointer
624 %
625 % Internal macro for calculations relating to the rectangle callout.
626 %
627 % Requires the following to be set up:
628 %
629 % \calloutpointer - the location of the callout point.
630 % \xtemp - the half width of the rectangle
631 % \ytemp - the half height of the rectangle
632 % \pointerwidth - the width of the pointer.
633 %
634 \def\pgf@lib@rectanglecallout@pointer{%
635 %
636 % Ensure that the pointer never connects to the main shape
637 % too near to a corner. This is done for two reasons:
638 % 1. It can look ugly.
639 % 2. If the corners are rounded, a mess can result.
640 %
641 \pgfextract@process\borderpoint{%
642 \pgfpointborderrectangle{%
643 \centerpoint%
644 \pgf@xa\pgf@x%
645 \pgf@ya\pgf@y%
646 \calloutpointer%
647 \advance\pgf@x-\pgf@xa%
648 \advance\pgf@y-\pgf@ya%
649 }{\pgfqpoint{\xtemp}{\ytemp}}%
650 }%
651 \pgfmathanglebetweenpoints{\pgfpointorigin}{\borderpoint}%
652 \let\borderangle\pgfmathresult%
653 %
654 \pgfutil@tempdima\pointerwidth\relax%
655 \pgf@xa\xtemp\relax%
656 \advance\pgf@xa-\pgfutil@tempdima%
657 \pgf@ya\ytemp\relax%
658 \advance\pgf@ya-\pgfutil@tempdima%
659 %
660 \pgf@process{%
661 \pgfutil@ifundefined{pgf@corner@arc}{\pgfpointorigin}{%
662 \expandafter\pgfqpoint\pgf@corner@arc}%
663 }%
664 \advance\pgf@xa-\pgf@x%
665 \advance\pgf@ya-\pgf@y%
666 %
667 \borderpoint%
668 \pgf@xb\pgf@x%
669 \pgf@yb\pgf@y%
670 %
671 \pgf@xc0pt\relax%
672 \pgf@yc0pt\relax%
673 %
674 \pgfmathanglebetweenpoints{\pgfpointorigin}{\pgfqpoint{\xtemp}{\ytemp}}%
675 \ifdim\borderangle pt<\pgfmathresult pt\relax%
676 \[email protected]\pgfutil@tempdima%
677 \ifdim\pgf@yb>\pgf@ya%
678 \pgf@yb\pgf@ya%
679 \fi%
680 %
681 % Establish the order for drawing the rectangle corners.
682 %
683 \edef\firstpoint{\noexpand\pgfqpoint{\xtemp}{\ytemp}}%
684 \edef\secondpoint{\noexpand\pgfqpoint{-\xtemp}{\ytemp}}%
685 \edef\thirdpoint{\noexpand\pgfqpoint{-\xtemp}{-\ytemp}}%
686 \edef\fourthpoint{\noexpand\pgfqpoint{\xtemp}{-\ytemp}}%
687 \else%
688 \pgfmathanglebetweenpoints{\pgfpointorigin}{\pgfqpoint{-\xtemp}{\ytemp}}%
689 \ifdim\borderangle pt<\pgfmathresult pt\relax%
690 \[email protected]\pgfutil@tempdima%
691 \ifdim\pgf@xb>\pgf@xa%
692 \pgf@xb\pgf@xa%
693 \else%
694 \ifdim\pgf@xb<-\pgf@xa%
695 \pgf@xb-\pgf@xa%
696 \fi%
697 \fi%
698 \edef\firstpoint{\noexpand\pgfqpoint{-\xtemp}{\ytemp}}%
699 \edef\secondpoint{\noexpand\pgfqpoint{-\xtemp}{-\ytemp}}%
700 \edef\thirdpoint{\noexpand\pgfqpoint{\xtemp}{-\ytemp}}%
701 \edef\fourthpoint{\noexpand\pgfqpoint{\xtemp}{\ytemp}}%
702 \else%
703 \pgfmathanglebetweenpoints{\pgfpointorigin}{\pgfqpoint{-\xtemp}{-\ytemp}}%
704 \ifdim\borderangle pt<\pgfmathresult pt\relax%
705 \[email protected]\pgfutil@tempdima%
706 \ifdim\pgf@yb>\pgf@ya%
707 \pgf@yb\pgf@ya%
708 \else%
709 \ifdim\pgf@yb<-\pgf@ya%
710 \pgf@yb-\pgf@ya%
711 \fi%
712 \fi%
713 \edef\firstpoint{\noexpand\pgfqpoint{-\xtemp}{-\ytemp}}%
714 \edef\secondpoint{\noexpand\pgfqpoint{\xtemp}{-\ytemp}}%
715 \edef\thirdpoint{\noexpand\pgfqpoint{\xtemp}{\ytemp}}%
716 \edef\fourthpoint{\noexpand\pgfqpoint{-\xtemp}{\ytemp}}%
717 \else%
718 \pgfmathanglebetweenpoints{\pgfpointorigin}{\pgfqpoint{\xtemp}{-\ytemp}}%
719 \ifdim\borderangle pt<\pgfmathresult pt\relax%
720 \[email protected]\pgfutil@tempdima%
721 \ifdim\pgf@xb>\pgf@xa%
722 \pgf@xb\pgf@xa%
723 \else%
724 \ifdim\pgf@xb<-\pgf@xa%
725 \pgf@xb-\pgf@xa%
726 \fi%
727 \fi%
728 \edef\firstpoint{\noexpand\pgfqpoint{\xtemp}{-\ytemp}}%
729 \edef\secondpoint{\noexpand\pgfqpoint{\xtemp}{\ytemp}}%
730 \edef\thirdpoint{\noexpand\pgfqpoint{-\xtemp}{\ytemp}}%
731 \edef\fourthpoint{\noexpand\pgfqpoint{-\xtemp}{-\ytemp}}%
732 \else%
733 \[email protected]\pgfutil@tempdima%
734 \ifdim\pgf@yb<-\pgf@ya%
735 \pgf@yb-\pgf@ya%
736 \fi%
737 \edef\firstpoint{\noexpand\pgfqpoint{\xtemp}{\ytemp}}%
738 \edef\secondpoint{\noexpand\pgfqpoint{-\xtemp}{\ytemp}}%
739 \edef\thirdpoint{\noexpand\pgfqpoint{-\xtemp}{-\ytemp}}%
740 \edef\fourthpoint{\noexpand\pgfqpoint{\xtemp}{-\ytemp}}%
741 \fi%
742 \fi%
743 \fi%
744 \fi%
745 \pgfextract@process\beforecalloutpointer{%
746 \centerpoint%
747 \advance\pgf@x\pgf@xb%
748 \advance\pgf@y\pgf@yb%
749 \advance\pgf@x-\pgf@xc%
750 \advance\pgf@y-\pgf@yc%
751 }%
752 \pgfextract@process\aftercalloutpointer{%
753 \centerpoint%
754 \advance\pgf@x\pgf@xb%
755 \advance\pgf@y\pgf@yb%
756 \advance\pgf@x\pgf@xc%
757 \advance\pgf@y\pgf@yc%
758 }%
759 %
760 % Now calculate the pointer anchor.
761 %
762 \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}%
763 \pgfmathsetlength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}%
764 \ifdim\pgf@x>\pgf@y%
765 \edef\outersep{\the\pgf@x}%
766 \else%
767 \edef\outersep{\the\pgf@y}%
768 \fi%
769 \pgf@lib@callouts@pointeranchor%
770 }%
771
772
773 % Internal macro for parsing the size of
774 % the cloud callout pointer.
775 %
776 % \pgf@x and \pgf@y should be set up as the
777 % width and height of the main shape.
778 %
779 % \pgf@xa and \pgf@ya are returned appropriately.
780 %
781 \def\pgf@lib@callout@setpointersize#1{%
782 \edef\pgf@lib@callout@temp{#1}%
783 \edef\pgf@marshall{\noexpand\pgfutil@in@{of callout}{\pgf@lib@callout@temp}}%
784 \pgf@marshall%
785 \ifpgfutil@in@%
786 \expandafter\pgf@xa\expandafter\pgf@lib@callout@setpointerrelativesize%
787 \pgf@lib@callout@temp\pgf@lib@stop\pgf@x%
788 \expandafter\pgf@ya\expandafter\pgf@lib@callout@setpointerrelativesize%
789 \pgf@lib@callout@temp\pgf@lib@stop\pgf@y%
790 \else%
791 \edef\pgf@marshall{\noexpand\pgfutil@in@{and}{\pgf@lib@callout@temp}}%
792 \pgf@marshall%
793 \ifpgfutil@in@%
794 \expandafter\pgf@lib@callout@setpointerbothsizes\pgf@lib@callout@temp\pgf@lib@stop%
795 \else%
796 \pgfmathsetlength\pgf@xa{#1}%
797 \pgfmathsetlength\pgf@ya{#1}%
798 \fi%
799 \fi%
800 }%
801 \def\pgf@lib@callout@setpointerrelativesize#1of callout#2\pgf@lib@stop{#1}%
802 \def\pgf@lib@callout@setpointerbothsizes#1and#2\pgf@lib@stop{%
803 \pgfmathsetlength\pgf@xa{#2}%
804 \pgfmathsetlength\pgf@ya{#2}%
805 }%
806
807 % Shape: cloud callout.
808 %
809 \pgfdeclareshape{cloud callout}{%
810 \savedanchor\calloutpointer{%
811 \pgfutil@ifundefined{pgf@sh@s@cloud}{%
812 \pgferror{I cannot find the cloud shape. Please load the `symbol shapes' library}}{}%
813 \pgf@sh@s@cloud%
814 \pgf@sh@savedmacros%
815 %
816 \pgfextract@process\centerpoint{%
817 \[email protected]\wd\pgfnodeparttextbox%
818 \[email protected]\ht\pgfnodeparttextbox%
819 \advance\[email protected]\dp\pgfnodeparttextbox%
820 }%
821 \ifpgf@lib@callout@absolutepointer%
822 \else%
823 \pgfextract@process\calloutpointer{%
824 \pgfextract@process\borderpoint{%
825 \expandafter\pgfpointborderellipse\expandafter{\pgf@lib@callout@relativepointer}%
826 {\pgfqpoint{\xouterradius}{\youterradius}}%
827 }%
828 \pgfmathanglebetweenpoints{\pgfpointorigin}{\borderpoint}%
829 \let\pointerangle\pgfmathresult%
830 \expandafter\pgf@process\expandafter{\pgf@lib@callout@relativepointer}%
831 \pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}%
832 \edef\pointerradius{\pgfmathresult pt}%
833 \pgfpointadd{\borderpoint}{\pgfqpointpolar{\pointerangle}{\pointerradius}}%
834 \pgf@xa\pgf@x%
835 \pgf@ya\pgf@y%
836 \centerpoint%
837 \advance\pgf@x\pgf@xa%
838 \advance\pgf@y\pgf@ya%
839 }%
840 \pgf@lib@callouts@shortenpointer%
841 \fi%
842 }%
843 \anchor{pointer}{%
844 \calloutpointer%
845 }%
846 \inheritsavedanchors[from=cloud]%
847 \inheritanchor[from=cloud]{center}%
848 \inheritanchor[from=cloud]{base}%
849 \inheritanchor[from=cloud]{mid}%
850 \inheritanchor[from=cloud]{north}%
851 \inheritanchor[from=cloud]{south}%
852 \inheritanchor[from=cloud]{east}%
853 \inheritanchor[from=cloud]{west}%
854 \inheritanchor[from=cloud]{north east}%
855 \inheritanchor[from=cloud]{south west}%
856 \inheritanchor[from=cloud]{south east}%
857 \inheritanchor[from=cloud]{north west}%
858 \inheritanchorborder[from=cloud]%
859 \backgroundpath{%
860 \pgf@sh@bg@cloud%
861 \ifpgf@lib@callout@absolutepointer%
862 \pgfextract@process\calloutpointer{%
863 \pgfpointanchor{pgf@lib@callout@pointer}{center}%
864 }%
865 \ifx\pgf@node@name\pgfutil@empty%
866 \else%
867 \edef\pgf@sh@@temp{\noexpand\expandafter\noexpand\pgfutil@g@addto@macro\noexpand\csname pgf@sh@np@\pgf@node@name\noexpand\endcsname}%
868 \edef\pgf@sh@@@temp{%
869 \noexpand\def\noexpand\calloutpointeranchor{%
870 \noexpand\pgf@x\the\pgf@x%
871 \noexpand\pgf@y\the\pgf@y%
872 }%
873 }%
874 \expandafter\pgf@sh@@temp\expandafter{\pgf@sh@@@temp}
875 \fi%
876 \fi%
877 %
878 \pgfextract@process\borderpoint{%
879 \pgfpointadd{%
880 \pgfpointborderellipse{\pgfpointdiff{\centerpoint}{\calloutpointer}}%
881 {\pgfqpoint{\xouterradius}{\youterradius}}%
882 }{\centerpoint}%
883 }%
884 \pgf@lib@callouts@shortenpointer%
885 \pgfmathanglebetweenpoints{\calloutpointer}{\centerpoint}%
886 \let\angle\pgfmathresult%
887 \pgfmathsin@{\angle}%
888 \let\sinpointerangle\pgfmathresult%
889 \pgfmathcos@{\angle}%
890 \let\cospointerangle\pgfmathresult%
891 %
892 \pgf@x\xouterradius\relax%
893 \[email protected]\pgf@x%
894 \pgf@y\yinnerradius\relax%
895 \[email protected]\pgf@y%
896 \pgf@lib@callout@setpointersize{\pgfkeysvalueof{/pgf/callout pointer start size}}%
897 \pgf@xb\pgf@xa%
898 \pgf@yb\pgf@ya%
899 \pgf@lib@callout@setpointersize{\pgfkeysvalueof{/pgf/callout pointer end size}}%
900 \advance\pgf@xb-\pgf@xa%
901 \advance\pgf@yb-\pgf@ya%
902 %
903 \pgfmathsetcount\c@pgf@counta{\pgfkeysvalueof{/pgf/callout pointer segments}}%
904 \divide\pgf@xb\c@pgf@counta%
905 \divide\pgf@yb\c@pgf@counta%
906 %
907 \pgf@process{\pgfpointdiff{\borderpoint}{\calloutpointer}}%
908 \pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}%
909 \pgfutil@tempdima\pgfmathresult pt\relax%
910 \divide\pgfutil@tempdima\c@pgf@counta%
911 %
912 \pgfutil@tempdimb0pt\relax%
913 \pgfmathloop%
914 \ifnum\pgfmathcounter>\c@pgf@counta%
915 \else%
916 {%
917 \[email protected]\pgf@xa%
918 \[email protected]\pgf@ya%
919 \edef\tempxradius{\the\pgf@xa}%
920 \edef\tempyradius{\the\pgf@ya}%
921 \pgfpathellipse%
922 {%
923 \calloutpointer%
924 \advance\pgf@x\cospointerangle\pgfutil@tempdimb%
925 \advance\pgf@y\sinpointerangle\pgfutil@tempdimb%
926 }%
927 {\pgfqpoint{\tempxradius}{0pt}}{\pgfqpoint{0pt}{\tempyradius}}%
928 }%
929 \advance\pgf@xa\pgf@xb%
930 \advance\pgf@ya\pgf@yb%
931 \advance\pgfutil@tempdimb\pgfutil@tempdima%
932 \repeatpgfmathloop%
933 }%
934 %
935 % Hack the puff anchors for the callout.
936 %
937 \expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@cloud callout\endcsname{%
938 \c@pgf@counta\puffs\relax%
939 \pgfmathloop%
940 \ifnum\c@pgf@counta>0\relax%
941 \pgfutil@ifundefined{pgf@anchor@cloud callout@puff\space\the\c@pgf@counta}{%
942 \expandafter\xdef\csname pgf@anchor@cloud callout@puff\space\the\c@pgf@counta\endcsname{%
943 \noexpand\pgf@sh@@cloudpuffanchor{\the\c@pgf@counta}%
944 }%
945 }{\c@pgf@counta0\relax}%
946 \advance\c@pgf@counta-1\relax%
947 \repeatpgfmathloop%
948 }%
949 }%
950
951 \endinput