Debian Codegraph @

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

raw
1 % Copyright 2006, 2018 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{pgfcorearrows.code.tex}
11
12
13
14 % Define a new (meta) arrow or a shorthand
15 %
16 % #1 = key--value pairs
17 %
18 % Description:
19 %
20 % This command is used to define a new arrow tip kind. For more
21 % details on the description of the keys, please see the pgfmanual.
22 %
23 % name = Name of the arrow. If the name contains a dash
24 % (hyphen), the text before the hyphen is the start name
25 % and the text behind it the end name.
26 %
27 % means = If set, none of the below options may be
28 % given. The effect is that whenever the arrow is
29 % used, it gets replaced by this "text", which is
30 % parsed by the parser.
31 %
32 % setup code = Code that does "precomputations". These will be
33 % executed only once for each combination of the
34 % dependencies. At the end of this code, you can use
35 % \savethe and \save to "save" computed values, which
36 % will then be available inside the "code". Values needed
37 % only for the "... end" keys and the convex hull do not
38 % need to be saved since these are also executed only
39 % once.
40 % drawing code = Code for drawing the arrow. When the cache key is set to
41 % true, which is the default, the code will be protocolled
42 % and the resulting code is inserted using \pgflowlevelobj.
43 % cache = Boolean that decides whether the arrow can be cached. The
44 % default is true, so you have to say cache=false to switch
45 % caching off. In this case, each time the arrow is drawn,
46 % its code is simply executed. This allows you to put things
47 % like text or shadings in arrow tips.
48 % bending mode = Can be set to "orthogonal", "polar", or
49 % "none". Defaults to "orthogonal".
50 % defaults = A list of "default" options for the arrow tip. These
51 % are executed as if they were given to the arrow tip in
52 % brackets. This is useful for setting up default values.
53 % parameters = A list of comma-separated macro names on whose values
54 % the appearance of the arrow tip depends. When an arrow
55 % tip is used, these macros are expanded. If an
56 % arrow tip was already installed with the same macro
57 % names (and caching is true), the cached code is
58 % used. Note that when you use dimensions here, add \the.
59 %
60 % Inside the setup code, the following macros are available:
61 %
62 % \pgfarrowssettipend
63 % The code should draw an arrow pointing "right along the x
64 % axis". The "tip" key specifies how far the arrow goes
65 % along the x axis, that is, it should be the x coordinate
66 % of the very tip of the arrow. In previous versions this
67 % was called the "right extend". The value passed to this
68 % key should be some code that sets the dimension
69 % "\pgfarrowresult", which is \let to be equal to
70 % \pgf@x. A \relax will be added after the code provided
71 % here, so you can write things like "\pgfarrowresult=1pt".
72 % \pgfarrowssetbackend
73 % The leftmost x-coordinate that is still part of the
74 % arrow tip (the "back end" of the arrow"). This coordinate
75 % will be used when multiple arrow tips are
76 % composed. Defaults to 0pt.
77 % \pgfarrowssetlineend
78 % The x-coordinate where a line should stop inside the arrow
79 % tip so that it gets "obscured" by the arrow. Defaults to 0pt.
80 % \pgfarrowssetvisualtipend
81 % When the arrow tip is drawn in flex mode, it is rotated
82 % such that the x-coordinates of "visual tip end" and "visual
83 % back end" lie on the path. Defaults to \pgfarrowssettipend.
84 % \pgfarrowssetvisualbackend
85 % See above. Defaults to \pgfarrowssetbackend
86
87 \def\pgfdeclarearrow#1{%
88 \let\pgf@decl@arrow@defaults\pgfutil@empty%
89 \let\pgf@decl@arrow@means\relax%
90 \let\pgf@decl@arrow@code\relax%
91 \pgfkeys{/pgf/@arrows decl/.cd,
92 name=,
93 setup code=,
94 cache=true,
95 bending mode=orthogonal,
96 parameters=,%
97 #1%
98 }%
99 \ifx\pgf@decl@arrow@name@end\pgfutil@empty%
100 \pgferror{Declaring unnamed arrow}%
101 \else%
102 \pgf@arrow@letter{name@end}%
103 \pgf@arrow@letter{name@start}%
104 \expandafter\let\csname pgf@ar@start@\pgf@decl@arrow@name@start\endcsname\pgf@decl@arrow@name@end%
105 \expandafter\let\expandafter\pgf@old@code\csname pgf@ar@code@\pgf@decl@arrow@name@end\endcsname%
106 \expandafter\let\expandafter\pgf@old@means\csname pgf@ar@means@\pgf@decl@arrow@name@end\endcsname%
107 \ifx\pgf@decl@arrow@code\relax%
108 \ifx\pgf@decl@arrow@means\relax%
109 \pgferror{You must set either the 'means' or the drawing code' keys for arrow tip '\pgf@decl@arrow@name@end'}%
110 \else%
111 \ifx\pgf@old@code\relax%
112 \let\pgf@arrow@tip@sequence\pgfutil@empty%
113 \let\pgf@arrow@translate\relax%
114 \expandafter\let\expandafter\pgf@arrows@direct\csname pgf@arrows@direct@name@end@\pgf@decl@arrow@means\endcsname%
115 \ifx\pgf@arrows@direct\relax%
116 \let\pgf@arrows@options\pgfutil@empty%
117 \expandafter\pgfarrows@initial@parser\pgf@decl@arrow@means[]\pgf@stop%
118 \else%
119 \let\pgf@arrow@tip@sequence\pgf@arrows@direct%
120 \fi%
121 \pgf@arrow@letter@\pgf@arrow@tip@sequence{means}%
122 \expandafter\let\csname pgf@ar@code@\pgf@decl@arrow@name@end\endcsname\relax%
123 \else%
124 \pgferror{Arrow tip '\pgf@decl@arrow@name@end' was already
125 defined with key 'drawing code' previously and you cannot change this}%
126 \fi%
127 \fi%
128 \else%
129 \ifx\pgf@decl@arrow@means\relax%
130 \ifx\pgf@old@means\relax%
131 \pgf@arrow@letter{code}%
132 \pgf@arrow@letter{defaults}%
133 \pgf@arrow@letter{setup}%
134 \pgf@arrow@letter{bending@mode}%
135 \pgf@arrow@letter{par}%
136 \expandafter\let\csname pgf@ar@do@cache@\pgf@decl@arrow@name@end\endcsname\pgf@decl@arrow@cache%
137 \else%
138 \pgferror{Arrow tip '\pgf@decl@arrow@name@end' was already
139 defined with key 'means' previously and you cannot change this}%
140 \fi%
141 \else%
142 \pgferror{You cannot set both the 'means' and also the 'drawing code'
143 keys for arrow tip '\pgf@decl@arrow@name@end'}%
144 \fi%
145 \fi%
146 \fi%
147 }
148
149 \def\pgf@arrow@letter#1{%
150 \expandafter\pgf@arrow@letter@\expandafter{\csname pgf@decl@arrow@#1\endcsname}{#1}%
151 }
152 \def\pgf@arrow@letter@#1#2{%
153 \expandafter\let\csname pgf@ar@#2@\pgf@decl@arrow@name@end\endcsname#1%
154 }
155
156 \pgfkeys{
157 /pgf/@arrows decl/.cd,
158 name/.code={%
159 \pgfutil@in@-{#1}%
160 \ifpgfutil@in@%
161 \pgf@arrows@name@decomp#1\pgf@stop%
162 \else%
163 \def\pgf@decl@arrow@name@end{#1}\let\pgf@decl@arrow@name@start\pgf@decl@arrow@name@end%
164 \fi},
165 means/.store in=\pgf@decl@arrow@means,
166 setup code/.store in=\pgf@decl@arrow@setup,
167 drawing code/.store in=\pgf@decl@arrow@code,
168 cache/.store in=\pgf@decl@arrow@cache,
169 bending mode/.is choice,
170 bending mode/none/.code=\let\pgf@decl@arrow@bending@mode\pgfutil@empty,
171 bending mode/orthogonal/.code=\def\pgf@decl@arrow@bending@mode{\pgfpointcurvilinearbezierorthogonal},
172 bending mode/polar/.code=\def\pgf@decl@arrow@bending@mode{\pgfpointcurvilinearbezierpolar},
173 parameters/.store in=\pgf@decl@arrow@par,
174 defaults/.code={%
175 \let\pgf@arrows@options\pgfutil@empty%
176 \pgfkeys{/pgf/arrow keys/.cd,#1}%
177 \let\pgf@decl@arrow@defaults\pgf@arrows@options%
178 }
179 }
180
181 \def\pgf@arrows@name@decomp#1-#2\pgf@stop{%
182 \def\pgf@decl@arrow@name@start{#1}%
183 \def\pgf@decl@arrow@name@end{#2}%
184 }
185
186
187 % Handler for defining arrow tips:
188 %
189 % Description:
190 %
191 % When you write "my name/.tip = arrow spec", this has the same
192 % effect as writing \pgfdeclarearrow{name = my name, means = arrow spec}.
193
194 \pgfkeys{/handlers/.tip/.code=%
195 \expandafter\expandafter\expandafter\pgf@arrows@unravel\pgfkeyscurrentpath/\pgf@stop%
196 \expandafter\pgf@arrows@key@call\expandafter{\pgf@arrows@unravelled}{#1}}
197 \def\pgf@arrows@unravel#1/{\pgfutil@ifnextchar\pgf@stop{\def\pgf@arrows@unravelled{#1}\pgfutil@gobble}{\pgf@arrows@unravel}}
198 \def\pgf@arrows@key@call#1#2{\pgfdeclarearrow{name={#1},means={#2}}}
199
200
201
202
203 % Draw an arrow
204 %
205 % #1 = arrow specification
206 %
207 % Description:
208 %
209 % Draws the arrow in the given specification (and "end"
210 % specification). The arrow will be drawn such that it touches the
211 % origin "from the left", that is, the arrow will lie completely in
212 % the half plane with negative $x$ values and the tip will end exactly
213 % at the origin.
214
215 \def\pgfarrowdraw#1{%
216 {%
217 \pgfsetarrowsend{#1}%
218 \pgf@arrow@compute@shortening\pgf@end@tip@sequence%
219 \pgf@arrow@draw@arrow\pgf@end@tip@sequence\pgf@xb%
220 }%
221 }
222
223
224
225 % Compute the length of an arrow
226 %
227 % #1 = arrow specification
228 %
229 % Description:
230 %
231 % In \pgf@x, this will return the total length of the arrow given as
232 % #1, in \pgf@xa it will return the distance from the tip to the line
233 % end.
234
235 \def\pgfarrowtotallength#1{%
236 {%
237 \pgfsetarrowsend{#1}%
238 \pgf@arrow@compute@shortening\pgf@end@tip@sequence%
239 \expandafter\expandafter\expandafter%
240 }%
241 \expandafter\expandafter\expandafter\pgf@x\expandafter\the\expandafter\pgf@xb\expandafter\pgf@xa\the\pgf@xa%
242 }
243
244
245
246
247
248 % Sets the end arrow tip
249 %
250 % #1 = An arrow specification
251 %
252 % Description:
253 %
254 % An "arrow specification" is a sequence of names of meta arrow tips
255 % together with options in brackets. In detail:
256 %
257 % In #1, consider the text from the start up to the first bracket. If
258 % this text is the name of a (meta) arrow tip, we use this arrow tip
259 % with the provided options. If it is the name of a arrow tip
260 % shorthand, this shorthand is expanded and the options are applied to
261 % each arrow tip inside the shorthand. If the text is neither or the
262 % above, the first letter of text is treated as a shorthand without
263 % options.
264 %
265 % The special arrow tip "." is used to indicate the end of the line.
266 %
267 % \pgfsetarrowsend{stealth[reversed]}
268 % \pgfsetarrowsend{stealth[length=1pt] . stealth[length=2pt]}
269 % \pgfsetarrowsend{>>>}
270 % \pgfsetarrowsend{>.>}
271
272 \def\pgfsetarrowsend#1{%
273 \let\pgf@arrow@tip@sequence\pgfutil@empty%
274 \pgf@arrows@translatefalse%
275 \expandafter\let\expandafter\pgf@arrows@direct\csname pgf@arrows@direct@name@end@#1\endcsname%
276 \ifx\pgf@arrows@direct\relax%
277 \edef\pgf@marshal{\noexpand\pgfarrows@initial@parser#1[]\noexpand\pgf@stop}%
278 \pgf@marshal%
279 \else%
280 \let\pgf@arrow@tip@sequence\pgf@arrows@direct%
281 \fi%
282 \let\pgf@end@tip@sequence\pgf@arrow@tip@sequence%
283 }
284
285 \newif\ifpgf@arrows@translate
286
287 \def\pgfarrows@initial@parser{%
288 \pgfutil@ifnextchar[\pgfarrows@initial@parser@{\pgfarrows@initial@parser@[]}}%}
289
290 \def\pgfarrows@initial@parser@[#1]{%
291 \let\pgf@arrows@options\pgfutil@empty%
292 \pgfkeys{/pgf/arrow keys/.cd,#1}%
293 \let\pgf@arrows@options@initial\pgf@arrows@options%
294 \pgfarrows@parser%
295 }
296
297 \def\pgfarrows@parser#1[{%
298 \pgfkeys@spdef\pgf@temp{#1}%
299 \ifx\pgf@temp\pgfutil@empty%
300 \let\pgf@next\pgf@arrows@empty%
301 \else%
302 \ifx\pgf@temp\pgf@dot@text%
303 \let\pgf@next\pgf@arrows@dot@parsed%
304 \else%
305 \let\pgf@untranslated\pgf@temp%
306 \ifpgf@arrows@translate%
307 \pgf@arrow@swapper%
308 \fi%
309 % Now, let's see what we do with this...
310 \expandafter\ifx\csname pgf@ar@code@\pgf@temp\endcsname\relax
311 \expandafter\ifx\csname pgf@ar@means@\pgf@temp\endcsname\relax
312 % #1 should start with a single-char shorthands
313 \let\pgf@next\pgf@arrows@single@char@parser%
314 \let\pgf@temp\pgf@untranslated%
315 \else%
316 % #1 is a shorthand!
317 \let\pgf@next\pgf@arrows@shorthand@parsed%
318 \fi%
319 \else%
320 % #1 is a meta arrow!
321 \let\pgf@next\pgf@arrows@meta@parsed%
322 \fi%
323 \fi%
324 \fi%
325 \expandafter\pgf@next\pgf@temp[%
326 }
327
328 \def\pgf@arrows@empty[#1]{%
329 \pgfutil@ifnextchar\pgf@stop\pgf@arrows@parser@done\pgfarrows@parser%
330 }
331
332 \def\pgf@arrows@single@char@parser#1{%
333 \def\pgf@temp{#1}%
334 \ifx\pgf@temp\pgf@dot@text%
335 \let\pgf@next\pgf@arrows@dot@parsed%
336 \else%
337 \let\pgf@untranslated\pgf@temp%
338 \ifpgf@arrows@translate%
339 \pgf@arrow@swapper%
340 \fi%
341 \expandafter\ifx\csname pgf@ar@code@\pgf@temp\endcsname\relax
342 \expandafter\ifx\csname pgf@ar@means@\pgf@temp\endcsname\relax
343 \let\pgf@temp\pgf@untranslated%
344 \let\pgf@next\pgf@arrows@unknown%
345 \else%
346 \let\pgf@next\pgf@arrows@shorthand@parsed%
347 \fi%
348 \else%
349 \let\pgf@next\pgf@arrows@meta@parsed%
350 \fi
351 \fi
352 \expandafter\pgf@next\pgf@temp[]%
353 }
354 \def\pgf@arrows@unknown#1[]#2[#3]{%
355 \pgferror{Unknown arrow tip kind '#1#2'}%
356 }
357
358 \def\pgf@arrows@meta@parsed#1[#2]{%
359 % Ok, run the keys #2. This will add commands to \pgf@arrows@options:
360 %
361 \let\pgf@arrows@options\pgf@arrows@options@initial%
362 \pgfkeys{/pgf/arrow keys/.cd,#2}%
363 % Append the arrow and its options to the arrow tip sequence:
364 \expandafter\pgf@arrows@meta@set\expandafter{\pgf@arrows@options}{#1}{\pgf@arrow@handle}%
365 \pgfutil@ifnextchar\pgf@stop\pgf@arrows@parser@done\pgfarrows@parser%
366 }
367
368 \def\pgf@arrows@parser@done#1{%
369 }
370
371 \def\pgf@arrows@dot@parsed#1[#2]{%
372 \pgf@arrows@append@to@tips{\pgf@arrow@handle@dot}%
373 \pgfutil@ifnextchar\pgf@stop\pgf@arrows@parser@done\pgfarrows@parser%
374 }
375
376 \def\pgf@arrows@meta@set#1#2#3{%
377 \pgf@arrows@append@to@tips{#3{#2}{#1}}%
378 }
379 \def\pgf@arrows@append@to@tips#1{%
380 \let\pgf@tempa\pgf@arrow@tip@sequence%
381 \def\pgf@tempb{#1}%
382 \ifpgf@arrows@translate%
383 \let\pgf@tempa\pgf@tempb%
384 \let\pgf@tempb\pgf@arrow@tip@sequence%
385 \fi%
386 \expandafter\expandafter\expandafter\def%
387 \expandafter\expandafter\expandafter\pgf@arrow@tip@sequence%
388 \expandafter\expandafter\expandafter{\expandafter\pgf@tempa\pgf@tempb}%
389 }
390
391 \def\pgf@arrows@shorthand@parsed#1[#2]{%
392 \let\pgf@arrows@options\pgf@arrows@options@initial%
393 \pgfkeys{/pgf/arrow keys/.cd,#2}%
394 \ifx\pgf@arrows@options\pgfutil@empty%
395 \expandafter\pgf@arrows@append@to@tips\expandafter{%
396 \expandafter\pgf@arrow@handle@shorthand@empty\expandafter{\csname pgf@ar@means@#1\endcsname}}%
397 \else%
398 \expandafter\expandafter\expandafter\pgf@arrows@meta@set\expandafter\expandafter\expandafter{%
399 \expandafter\pgf@arrows@options\expandafter}\expandafter{\csname pgf@ar@means@#1\endcsname}{\pgf@arrow@handle@shorthand}%
400 \fi%
401 \pgfutil@ifnextchar\pgf@stop\pgf@arrows@parser@done\pgfarrows@parser%
402 }
403
404
405 % General handler:
406
407 \def\pgf@arrow@handle@shorthand@empty#1{#1}
408
409 \def\pgf@arrow@handle@shorthand#1#2{%
410 \def\pgf@temp@opt{#2}%
411 \expandafter\expandafter\expandafter\def%
412 \expandafter\expandafter\expandafter\pgf@arrows@nested@options@temp%
413 \expandafter\expandafter\expandafter{\expandafter\pgf@temp@opt\pgf@arrows@nested@options}%
414 \expandafter\let\expandafter\pgf@arrows@nested@options\expandafter\pgf@arrows@nested@options@temp%
415 \expandafter#1% all these expandafters to avoid creating groups, but having the options nest
416 \expandafter\def\expandafter\pgf@arrows@nested@options\expandafter{\pgf@arrows@nested@options}%
417 }
418
419 \let\pgf@arrows@nested@options\pgfutil@empty
420
421
422
423
424 % Sets the start arrow tip
425 %
426 % #1 = An arrow specification
427 %
428 % Description:
429 %
430 % This works like \pgfsetarrowsend, only the order of the tips in the
431 % arrow specification is reversed and the "reversed names" are used.
432 %
433 % \pgfsetarrowsend{<<}
434 % \pgfsetarrowsend{>.>}
435
436 \def\pgfsetarrowsstart#1{%
437 \let\pgf@arrow@tip@sequence\pgfutil@empty%
438 \pgf@arrows@translatetrue%
439 \expandafter\let\expandafter\pgf@arrows@direct\csname pgf@arrows@direct@name@start@#1\endcsname%
440 \ifx\pgf@arrows@direct\relax%
441 \edef\pgf@marshal{\noexpand\pgfarrows@initial@parser#1[]\noexpand\pgf@stop}%
442 \pgf@marshal%
443 \else%
444 \let\pgf@arrow@tip@sequence\pgf@arrows@direct%
445 \fi%
446 \let\pgf@start@tip@sequence\pgf@arrow@tip@sequence%
447 }
448
449 \def\pgf@arrow@swapper{%
450 \expandafter\let\expandafter\pgf@temp\csname pgf@ar@start@\pgf@temp\endcsname%
451 \ifx\pgf@temp\relax%
452 \def\pgf@temp{undefined}%
453 \fi%
454 }
455
456 \let\pgf@start@tip@sequence\pgfutil@empty
457 \let\pgf@end@tip@sequence\pgfutil@empty
458
459
460 \expandafter\def\csname pgf@arrows@direct@name@start@\endcsname{}
461 \expandafter\def\csname pgf@arrows@direct@name@end@\endcsname{}
462
463
464 % Predefined lengths and ifs
465
466 \newdimen\pgfarrowsep
467
468 \newif\ifpgfarrowswap
469 \newif\ifpgfarrowreversed
470 \newif\ifpgfarrowharpoon
471 \newif\ifpgfarrowopen
472
473 \let\pgf@arrows@stroke@color\pgfutil@empty
474 \let\pgf@arrows@fill@color\pgfutil@empty
475
476 \def\pgfarrows@length@scale{1}
477 \def\pgfarrows@width@scale{1}
478 \def\pgfarrows@slant{0}
479
480 \let\pgfarrows@scale@list\pgfutil@empty
481 \def\pgfarrowsaddtolengthscalelist#1{\expandafter\def\expandafter\pgfarrows@scale@list\expandafter{\pgfarrows@scale@list#1\pgfarrows@length@scale#1}}
482 \def\pgfarrowsaddtowidthscalelist#1{\expandafter\def\expandafter\pgfarrows@scale@list\expandafter{\pgfarrows@scale@list#1\pgfarrows@width@scale#1}}
483
484 \pgfkeys{
485 /pgf/arrow keys/.cd,
486 scale/.code={%
487 \pgfmathparse{#1}%
488 \expandafter\pgfarrowsaddtooptions\expandafter{\expandafter\def\expandafter\pgfarrows@length@scale\expandafter{\pgfmathresult}}%
489 \expandafter\pgfarrowsaddtooptions\expandafter{\expandafter\def\expandafter\pgfarrows@width@scale\expandafter{\pgfmathresult}}%
490 },
491 scale length/.code={\pgfmathparse{#1}\expandafter\pgfarrowsaddtooptions\expandafter{\expandafter\def\expandafter\pgfarrows@length@scale\expandafter{\pgfmathresult}}},
492 scale width/.code={\pgfmathparse{#1}\expandafter\pgfarrowsaddtooptions\expandafter{\expandafter\def\expandafter\pgfarrows@width@scale\expandafter{\pgfmathresult}}},
493 slant/.code={\pgfmathparse{#1}\expandafter\pgfarrowsaddtooptions\expandafter{\expandafter\def\expandafter\pgfarrows@slant\expandafter{\pgfmathresult}}},
494 sep/.code={
495 \pgfarrowsthreeparameters{#1}%
496 \expandafter\pgfarrowsaddtooptions\expandafter{\expandafter\pgfarrowslinewidthdependent\pgfarrowstheparameters\pgfarrowsep\pgf@x}%
497 },
498 sep/.default=0.88pt .3 1,
499 %
500 swap/.code=\pgfarrowsaddtooptions{\ifpgfarrowswap\pgfarrowswapfalse\else\pgfarrowswaptrue\fi},
501 reversed/.code=\pgfarrowsaddtooptions{\ifpgfarrowreversed\pgfarrowreversedfalse\else\pgfarrowreversedtrue\fi},
502 harpoon/.is choice,
503 harpoon/.default=true,
504 harpoon/true/.code=\pgfarrowsaddtooptions{\pgfarrowharpoontrue},
505 harpoon/false/.code=\pgfarrowsaddtooptions{\pgfarrowharpoonfalse},
506 left/.style={harpoon},
507 right/.style={harpoon,swap},
508 %
509 color/.code=\pgfarrowsaddtooptions{\def\pgf@arrows@stroke@color{#1}},
510 fill/.code={%
511 \def\pgf@temp{#1}%
512 \ifx\pgf@temp\pgf@nonetext%
513 \pgfarrowsaddtooptions{\pgfarrowopentrue}%
514 \else\ifx\pgf@temp\pgfutil@empty
515 \pgfarrowsaddtooptions{\pgfarrowopenfalse}%
516 \else
517 \pgfarrowsaddtooptions{\pgfarrowopenfalse\def\pgf@arrows@fill@color{#1}}%
518 \fi\fi
519 },
520 fill/.default=,
521 open/.style={fill=none},
522 .unknown/.code={
523 \expandafter\pgfutil@in@\expandafter!\expandafter{\pgfkeyscurrentname}%
524 \ifpgfutil@in@%
525 % this is a color!
526 \expandafter\pgfarrowsaddtooptions\expandafter{\expandafter\def\expandafter\pgf@arrows@stroke@color\expandafter{\pgfkeyscurrentname}}%
527 \else%
528 \pgfutil@doifcolorelse{\pgfkeyscurrentname}
529 {%
530 \expandafter\pgfarrowsaddtooptions\expandafter{\expandafter\def\expandafter\pgf@arrows@stroke@color\expandafter{\pgfkeyscurrentname}}%
531 }
532 {%
533 \edef\pgf@temp{\pgfkeyscurrentname}%
534 \pgfkeys{/errors/unknown key/.expand once=\expandafter{\pgf@temp}{#1}}%
535 }
536 \fi
537 }
538 }
539 \def\pgf@nonetext{none}
540
541 \def\pgfarrowsaddtooptions#1{\expandafter\def\expandafter\pgf@arrows@options\expandafter{\pgf@arrows@options#1}}
542 \def\pgfarrowsaddtolateoptions#1{\expandafter\def\expandafter\pgf@arrows@options\expandafter{\pgf@arrows@options\pgf@arrows@add@to@late@options{#1}}}
543 \def\pgf@arrows@add@to@late@options#1{\expandafter\def\expandafter\pgf@arrows@late@options\expandafter{\pgf@arrows@late@options#1}}
544
545
546
547 \def\pgfarrowsthreeparameters#1{%
548 \pgfarrowsthreeparameters@#1 +0 +0 +0 \pgf@stop%
549 }
550 \def\pgfarrowsthreeparameters@#1 #2 #3 #4\pgf@stop{%
551 \pgfmathsetlength\pgf@x{#1}%
552 \pgfmathsetmacro\pgf@temp@a{#2}%
553 \pgfmathsetmacro\pgf@temp@b{#3}%
554 \edef\pgfarrowstheparameters{{\the\pgf@x}{\pgf@temp@a}{\pgf@temp@b}}%
555 }
556
557 \def\pgfarrowsfourparameters#1{%
558 \pgfarrowsfourparameters@#1 +0 +0 +0 \pgf@stop%
559 }
560 \def\pgfarrowsfourparameters@#1:#2 #3 #4 #5\pgf@stop{%
561 \pgfmathsetmacro\pgf@temp@z{#1}%
562 \pgfmathsetlength\pgf@x{#2}%
563 \pgfmathsetmacro\pgf@temp@a{#3}%
564 \pgfmathsetmacro\pgf@temp@b{#4}%
565 \edef\pgfarrowstheparameters{{\pgf@temp@z}{\the\pgf@x}{\pgf@temp@a}{\pgf@temp@b}}%
566 }
567
568 \def\pgfarrows@angle@setup#1#2#3#4{%
569 \pgfarrowslinewidthdependent{#2}{#3}{#4}
570 \pgf@xc\pgf@x
571 \pgf@yc#1 pt%
572 \[email protected]\pgf@yc%
573 \pgfpointpolar{\pgf@yc}{\pgf@xc}
574 \pgfarrowlength\pgf@x%
575 \pgf@y2\pgf@y%
576 \expandafter\pgf@arrows@add@to@late@options\expandafter{\expandafter\pgfarrowwidth\the\pgf@y}%
577 }
578
579 \def\pgfarrows@angle@setup@prime#1{%
580 \pgf@yc#1 pt %
581 \pgf@yc=0.5\pgf@yc
582 \pgfmathtan@{\pgf@sys@tonumber\pgf@yc}%
583 \pgfarrowwidth\pgfmathresult\pgfarrowlength%
584 \pgfarrowwidth2\pgfarrowwidth%
585 }
586
587 \def\pgfarrowslinewidthdependent#1#2#3{%
588 \pgf@x#1%
589 \ifdim\pgfinnerlinewidth>0pt%
590 \pgf@arrows@inner@line@width@dep{#2}{#3}%
591 \else%
592 \advance\pgf@x by#2\pgflinewidth%
593 \fi%
594 }
595 \def\pgf@arrows@inner@line@width@dep#1#2{%
596 % #1*((1-#2/2)*full line width - (#2/2) * inner line width)
597 % Compute "real" line width
598 \pgf@xa\pgflinewidth%
599 \[email protected]\pgflinewidth%
600 \pgf@xb#2\pgf@xb%
601 \advance\pgf@xa by\pgf@xb%
602 \pgf@xb\pgfinnerlinewidth%
603 \[email protected]\pgf@xb
604 \advance\pgf@xa by#2\pgf@xb%
605 \advance\pgf@x by#1\pgf@xa%
606 }
607
608
609 \def\pgfarrowslengthdependent#1#2#3#4{%
610 #4#1%
611 \advance#4by#2\pgfarrowlength%
612 \advance#4by#3\pgflinewidth%
613 }
614
615
616
617 % Build the full name:
618
619 \def\pgf@arrow@fullname#1{pgf@@ar@#1@\the\pgflinewidth @\pgfinnerlinewidth @\ifpgfarrowreversed r\fi @\pgf@arrows@stroke@color @\pgf@arrows@fill@color @\csname pgf@ar@par@#1\endcsname}
620 \def\pgf@arrow@id@count{0}%
621
622 % Compute the arrow id of an arrow
623 %
624 % #1 = arrow name
625 % #2 = options
626 %
627 % Description:
628 %
629 % Returns the an id in \pgf@arrow@id that identifies the instantiation
630 % of the given arrow. If the arrow was not instantiated, this happens now.
631
632 \def\pgfarrows@getid#1#2{%
633 % Execute options:
634 \let\pgf@arrows@late@options\pgfutil@empty%
635 % 1. Defaults:
636 \csname pgf@ar@defaults@#1\endcsname%
637 % 2. Scope:
638 \pgf@arrows@options@scope
639 % 3. Local:
640 #2\relax%
641 % 4. Nested:
642 \pgf@arrows@nested@options%
643 % 5. Last options:
644 \pgf@arrows@late@options%
645 % 6. Scaling:
646 \pgfarrows@scale@list%
647 % Now, test:
648 \expandafter\global\expandafter\let\expandafter\pgf@arrow@id\csname\pgf@arrow@fullname{#1}\endcsname\relax%
649 \ifx\pgf@arrow@id\relax%
650 \pgf@arrows@instantiate{#1}
651 \fi%
652 }
653
654 \def\pgf@arrows@instantiate#1{%
655 % Not defined. Rats!
656 % Allocate new id:
657 \pgfutil@tempcnta\pgf@arrow@id@count\relax%
658 \advance\pgfutil@tempcnta by1\relax%
659 \xdef\pgf@arrow@id@count{\the\pgfutil@tempcnta}%
660 \expandafter\global\expandafter\let\csname\pgf@arrow@fullname{#1}\endcsname\pgf@arrow@id@count%
661 \global\let\pgf@arrow@id\pgf@arrow@id@count%
662 {%
663 \pgfclearid%
664 \csname pgf@ar@setup@#1\endcsname%
665 % Handle reversal
666 \ifpgfarrowreversed%
667 % Compute transformation:
668 \pgf@arrows@handle@reverse%
669 \fi%
670 % Save computed values
671 \expandafter\global\expandafter\let\csname pgf@ar@saves@\pgf@arrow@id\endcsname\pgf@arrows@saves%
672 \expandafter\global\expandafter\let\csname pgf@ar@hull@\pgf@arrow@id\endcsname\pgf@arrows@convexhull%
673 \expandafter\xdef\csname pgf@ar@ends@\pgf@arrow@id\endcsname{{\pgf@arrows@the@tipend}{\pgf@arrows@the@backend}{\pgf@arrows@the@lineend}}%
674 \expandafter\xdef\csname pgf@ar@visual@\pgf@arrow@id\endcsname{{\pgf@arrows@the@visualtipend}{\pgf@arrows@the@visualbackend}{}}%
675 % Save code (needed for bending)
676 \edef\pgf@arrow@code{%
677 \ifpgfarrowreversed\noexpand\pgftransformxscale{-1}\fi%
678 \expandafter\noexpand\csname pgf@ar@code@#1\endcsname%
679 }%
680 \expandafter\global\expandafter\let\csname pgf@ar@inst@code@\pgf@arrow@id\endcsname\pgf@arrow@code%
681 % Should we cache?
682 \expandafter\ifx\csname pgf@ar@do@cache@#1\endcsname\pgf@truetext%
683 \pgfsysprotocol@getcurrentprotocol\pgf@arrow@temp%
684 {%
685 \pgfinterruptpath%
686 \let\pgfusepath=\pgf@nousepath@here%
687 \pgf@relevantforpicturesizefalse%
688 \pgftransformreset%
689 \pgfsysprotocol@setcurrentprotocol\pgfutil@empty%
690 \pgfsysprotocol@bufferedtrue%
691 \pgfscope%
692 \pgf@arrow@code%
693 \endpgfscope%
694 \pgfsysprotocol@getcurrentprotocol\pgf@@arrow@temp%
695 \expandafter\gdef\expandafter\pgf@arrow@code\expandafter{\expandafter\pgfsysprotocol@literal\expandafter{\pgf@@arrow@temp}}%
696 \endpgfinterruptpath%
697 }%
698 \pgfsysprotocol@setcurrentprotocol\pgf@arrow@temp%
699 \fi%
700 \expandafter\global\expandafter\let\csname pgf@ar@cache@\pgf@arrow@id\endcsname\pgf@arrow@code%
701 }%
702 }
703 \def\pgf@truetext{true}
704
705 % Ok, now run setup:
706 \def\pgf@arrows@copy@tipend{\pgf@arrows@the@tipend}
707 \def\pgf@arrows@copy@backend{\pgf@arrows@the@backend}
708 \def\pgf@arrows@copy@lineend{\pgf@arrows@the@lineend}
709 \def\pgf@arrows@zeropt{0pt}%
710
711 \let\pgf@arrows@saves\pgfutil@empty%
712 \let\pgf@arrows@convexhull\pgfutil@empty%
713 \let\pgf@arrows@the@tipend\pgf@arrows@zeropt%
714 \let\pgf@arrows@the@backend\pgf@arrows@zeropt%
715 \let\pgf@arrows@the@lineend\pgf@arrows@zeropt%
716 \let\pgf@arrows@the@visualtipend\pgf@arrows@copy@tipend%
717 \let\pgf@arrows@the@visualbackend\pgf@arrows@copy@backend%
718
719
720 \def\pgf@arrows@handle@reverse{%
721 \pgf@x\pgf@arrows@the@visualtipend\pgf@x-\pgf@x%
722 \pgf@y\pgf@arrows@the@visualbackend\pgf@y-\pgf@y
723 \edef\pgf@arrows@the@visualtipend{\the\pgf@y}%
724 \edef\pgf@arrows@the@visualbackend{\the\pgf@x}%
725 \pgf@x\pgf@arrows@the@tipend\pgf@x-\pgf@x%
726 \pgf@y\pgf@arrows@the@backend\pgf@y-\pgf@y
727 \edef\pgf@arrows@the@tipend{\the\pgf@y}%
728 \edef\pgf@arrows@the@backend{\the\pgf@x}%
729 \pgf@x\pgf@arrows@the@lineend\pgf@x-\pgf@x\edef\pgf@arrows@the@lineend{\the\pgf@x}%
730 \let\pgf@temp\pgf@arrows@convexhull%
731 \let\pgf@arrows@convexhull\pgfutil@empty%
732 \let\pgf@arrow@hull@point\pgf@arrow@hull@point@reverse%
733 \pgf@temp%
734 }
735 \def\pgf@arrow@hull@point@reverse#1#2{%
736 \pgf@x#1%
737 \pgfarrowshullpoint{-\pgf@x}{#2}%
738 }
739
740 \def\pgf@nousepath@here#1{\pgferror{The definition of an arrow may not use \string\pgfusepath}}
741
742 \def\pgfarrowssavethe#1{%
743 \expandafter\expandafter\expandafter\def%
744 \expandafter\expandafter\expandafter\pgf@arrows@saves%
745 \expandafter\expandafter\expandafter{\expandafter\pgf@arrows@saves\expandafter#1\the#1\relax}
746 }
747
748 \def\pgfarrowssave#1{%
749 \expandafter\expandafter\expandafter\def%
750 \expandafter\expandafter\expandafter\pgf@arrows@saves%
751 \expandafter\expandafter\expandafter{\expandafter\pgf@arrows@saves\expandafter\def\expandafter#1\expandafter{#1}}
752 }
753
754 \def\pgfarrowshullpoint#1#2{%
755 \pgf@x#1\relax%
756 \pgf@y#2\relax%
757 \edef\pgf@arrows@temp{\noexpand\pgf@arrows@convexhull\noexpand\pgf@arrow@hull@point{\the\pgf@x}{\the\pgf@y}}%
758 \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@arrows@convexhull\expandafter\expandafter\expandafter{\pgf@arrows@temp}%
759 }
760
761 \def\pgfarrowsupperhullpoint#1#2{%
762 \pgf@x#1\relax%
763 \pgf@y#2\relax%
764 \ifdim\pgf@y>0pt
765 \edef\pgf@arrows@temp{\noexpand\pgf@arrows@convexhull\noexpand\pgf@arrow@hull@point{\the\pgf@x}{\the\pgf@y}\ifpgfarrowharpoon\else\noexpand\pgf@arrow@hull@point{\the\pgf@x}{-\the\pgf@y}\fi}%
766 \else
767 \edef\pgf@arrows@temp{\noexpand\pgf@arrows@convexhull\noexpand\pgf@arrow@hull@point{\the\pgf@x}{\the\pgf@y}}%
768 \fi
769 \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\pgf@arrows@convexhull\expandafter\expandafter\expandafter{\pgf@arrows@temp}%
770 }
771
772 \def\pgfarrowssettipend#1{\pgf@x#1\edef\pgf@arrows@the@tipend{\the\pgf@x}}
773 \def\pgfarrowssetbackend#1{\pgf@x#1\edef\pgf@arrows@the@backend{\the\pgf@x}}
774 \def\pgfarrowssetlineend#1{\pgf@x#1\edef\pgf@arrows@the@lineend{\the\pgf@x}}
775 \def\pgfarrowssetvisualtipend#1{\pgf@x#1\edef\pgf@arrows@the@visualtipend{\the\pgf@x}}
776 \def\pgfarrowssetvisualbackend#1{\pgf@x#1\edef\pgf@arrows@the@visualbackend{\the\pgf@x}}
777
778
779 % Internal computation of the line end (shortening) for an arrow
780 %
781 % #1 = arrow tip list
782 %
783 % Description:
784 %
785 % \pgf@xa will contain the necessary path shortening for the given
786 % arrow tip list, \pgf@xb will contain the total length of the arrow
787 % tip list (sum of the differences between tip end and back end plus
788 % the seps).
789
790 \def\pgf@arrow@compute@shortening#1{%
791 \let\pgf@arrow@handle\pgf@arrow@compute@shortening@
792 \let\pgf@arrow@handle@dot\pgf@arrow@after@line@endtrue%
793 \pgf@arrow@after@line@endfalse%
794 \pgf@xa0pt%
795 \pgf@xb0pt%
796 #1%
797 }
798 \newif\ifpgf@arrow@after@line@end
799
800 \def\pgf@arrow@compute@shortening@#1#2{%
801 {\pgfarrows@getid{#1}{#2}\ifnum\pgf@arrow@flex@mode>0\relax\global\pgf@precise@shorteningtrue\fi\expandafter}\expandafter\pgf@x\the\pgfarrowsep%
802 \expandafter\expandafter\expandafter\pgf@arrow@cont@short\csname pgf@ar@ends@\pgf@arrow@id\endcsname%
803 }
804 \def\pgf@dot@text{.}
805
806 \def\pgf@arrow@cont@short#1#2#3{% tip end, back end, line end, sep
807 \advance\pgf@xb by#1%
808 \pgf@xc#2%
809 \advance\pgf@xb by-\pgf@xc%
810 \advance\pgf@xb by\pgf@x%
811 \ifpgf@arrow@after@line@end%
812 \advance\pgf@xa by#1%
813 \advance\pgf@xa by\pgf@x%
814 \pgf@xc#2%
815 \advance\pgf@xa by-\pgf@xc%
816 \else%
817 \pgf@xa#1%
818 \advance\pgf@xa by\pgf@x%
819 \pgf@xc#3%
820 \advance\pgf@xa by-\pgf@xc%
821 \fi%
822 }
823
824
825
826 \def\pgf@arrow@rigid@arrow#1#2{%
827 {%
828 \pgf@xb=#2%
829 \pgftransformxshift{-\pgf@xb}%
830 \let\pgf@arrow@handle\pgf@arrow@rigid
831 \let\pgf@arrow@handle@dot\relax%
832 #1%
833 }%
834 }
835
836
837 \def\pgf@arrow@rigid#1#2{%
838 % Prepare:
839 {%
840 \pgfarrows@getid{#1}{#2}%
841 % Do shift:
842 \expandafter\expandafter\expandafter\pgf@arrow@drawer@shift\csname pgf@ar@ends@\pgf@arrow@id\endcsname%
843 % Do slant:
844 \ifdim\pgfarrows@slant pt=0pt%
845 \else%
846 \pgftransformxslant{\pgfarrows@slant}%
847 \fi%
848 % do swap:
849 \ifpgfarrowswap%
850 \pgftransformyscale{-1}%
851 \fi%
852 {%
853 \csname pgf@ar@saves@\pgf@arrow@id\endcsname%
854 \pgf@arrows@rigid@hull%
855 }%
856 \expandafter}%
857 % Transform to next tip:
858 \expandafter\pgftransformxshift\expandafter{\the\pgf@xc}%
859 }
860
861
862
863
864 % Draw an arrow
865 %
866 % #1 = arrow tip list
867 % #2 = total length of the arrow (the value of \pgf@xb computed by
868 % \pgf@arrow@compute@shortening)
869 %
870 % Description:
871 %
872 % Draws an arrow tip list. The coordinate system must have been
873 % transformed so that the to-be-drawn arrow points right and should
874 % "end" at the origin.
875
876 \def\pgf@arrow@draw@arrow#1#2{%
877 {%
878 \pgf@xb=#2%
879 \pgftransformxshift{-\pgf@xb}%
880 \let\pgf@arrow@handle\pgf@arrow@drawer
881 \let\pgf@arrow@handle@dot\relax%
882 #1%
883 }%
884 }
885
886
887 \def\pgf@arrow@drawer#1#2{%
888 % Prepare:
889 {%
890 \pgfarrows@getid{#1}{#2}%
891 % Do shift:
892 \expandafter\expandafter\expandafter\pgf@arrow@drawer@shift\csname pgf@ar@ends@\pgf@arrow@id\endcsname%
893 % Do slant:
894 \ifdim\pgfarrows@slant pt=0pt%
895 \else%
896 \pgftransformxslant{\pgfarrows@slant}%
897 \fi%
898 % do swap:
899 \ifpgfarrowswap%
900 \pgftransformyscale{-1}%
901 \fi%
902 {%
903 \csname pgf@ar@saves@\pgf@arrow@id\endcsname%
904 \pgfscope%
905 \pgf@arrows@color@setup%
906 \pgflowlevelsynccm\csname pgf@ar@cache@\pgf@arrow@id\endcsname%
907 \endpgfscope%
908 \pgf@arrows@rigid@hull%
909 }%
910 \expandafter}%
911 % Transform to next tip:
912 \expandafter\pgftransformxshift\expandafter{\the\pgf@xc}%
913 }
914
915 \def\pgf@arrows@color@setup@restore@std@colors{%
916 % we want to allow 'arrows={fill=pgffillcolor}'. To this end, we have to ensure that \string\color@pgffillcolor is known.
917 % we can safely keep the macro in the current TeX group since it has global character anyway.
918 %
919 % Note that declaring \string\color@pgfstrokecolor as \global macro causes save stack issues and should be avoided.
920 \pgfutil@namelet{\string\color@pgfstrokecolor}{pgf@strokecolor@global}%
921 \pgfutil@namelet{\string\color@pgffillcolor}{pgf@fillcolor@global}%
922 %
923 }%
924
925 \def\pgf@arrows@color@setup{%
926 \ifx\pgf@arrows@stroke@color\pgfutil@empty\else\pgfsetstrokecolor{\pgf@arrows@stroke@color}\fi%
927 \ifx\pgf@arrows@fill@color\pgfutil@empty%
928 \ifx\pgf@strokecolor@global\pgf@fillcolor@global
929 \else
930 \pgf@arrows@color@setup@restore@std@colors
931 \pgfsetfillcolor{pgfstrokecolor}%
932 \fi%
933 \else%
934 \pgf@arrows@color@setup@restore@std@colors
935 \pgfsetfillcolor{\pgf@arrows@fill@color}%
936 \fi%
937 }
938
939 \def\pgf@arrow@drawer@shift#1#2#3{% tip end, back end, line end, sep
940 \pgf@xb#2\pgftransformxshift{-\pgf@xb}%
941 \pgf@xc#1%
942 \advance\pgf@xc by\pgfarrowsep%
943 \advance\pgf@xc by-\pgf@xb%
944 }
945
946 \def\pgf@arrows@rigid@hull{%
947 \ifpgf@relevantforpicturesize%
948 % Do bb update:
949 \expandafter\let\expandafter\pgf@temp\csname pgf@ar@hull@\pgf@arrow@id\endcsname%
950 \ifx\pgf@temp\pgfutil@empty\else%
951 \let\pgf@arrow@hull@point\pgf@arrow@hull@point@first%
952 \pgf@temp%
953 \pgf@arrow@update@bb%
954 \fi%
955 \fi
956 }
957
958
959 % Convex hull stuff:
960
961 \def\pgf@arrow@hull@point@first#1#2{%
962 % {\pgfsys@beginscope\pgfpathcircle{\pgfqpoint{#1}{#2}}{0.5pt}\pgfusepathqfill\pgfsys@endscope}%
963 \pgf@x#1\pgf@y#2%
964 \pgf@xa\pgf@pt@aa\pgf@x%
965 \advance\pgf@xa by\pgf@pt@ba\pgf@y%
966 \pgf@ya\pgf@pt@ab\pgf@x%
967 \advance\pgf@ya by\pgf@pt@bb\pgf@y%
968 \pgf@xb\pgf@xa\pgf@yb\pgf@ya%
969 \let\pgf@arrow@hull@point\pgf@arrow@hull@point@other%
970 }
971 \def\pgf@arrow@hull@point@other#1#2{%
972 % {\pgfsys@beginscope\pgfpathcircle{\pgfqpoint{#1}{#2}}{0.5pt}\pgfusepathqfill\pgfsys@endscope}%
973 \pgfutil@tempdima#1\pgfutil@tempdimb#2%
974 \pgf@x\pgf@pt@aa\pgfutil@tempdima%
975 \advance\pgf@x by\pgf@pt@ba\pgfutil@tempdimb%
976 \pgf@y\pgf@pt@ab\pgfutil@tempdima%
977 \advance\pgf@y by\pgf@pt@bb\pgfutil@tempdimb%
978 \ifdim\pgf@x<\pgf@xa\pgf@xa\pgf@x\else\ifdim\pgf@x>\pgf@xb\pgf@xb\pgf@x\fi\fi%
979 \ifdim\pgf@y<\pgf@ya\pgf@ya\pgf@y\else\ifdim\pgf@y>\pgf@yb\pgf@yb\pgf@y\fi\fi%
980 }
981
982 \def\pgf@arrow@update@bb{%
983 \advance\pgf@xa by\pgf@pt@x%
984 \advance\pgf@ya by\pgf@pt@y%
985 \advance\pgf@xb by\pgf@pt@x%
986 \advance\pgf@yb by\pgf@pt@y%
987 \ifdim\pgf@picmaxx=-16000pt\relax%
988 \global\pgf@picminx\pgf@xa%
989 \global\pgf@picmaxx\pgf@xb%
990 \global\pgf@picminy\pgf@ya%
991 \global\pgf@picmaxy\pgf@yb%
992 \else%
993 \ifdim\pgf@xa<\pgf@picminx\global\pgf@picminx\pgf@xa\fi%
994 \ifdim\pgf@ya<\pgf@picminy\global\pgf@picminy\pgf@ya\fi%
995 \ifdim\pgf@xb>\pgf@picmaxx\global\pgf@picmaxx\pgf@xb\fi%
996 \ifdim\pgf@yb>\pgf@picmaxy\global\pgf@picmaxy\pgf@yb\fi%
997 \fi%
998 }
999
1000
1001
1002 % Sets arrows
1003 %
1004 % #1 = An arrow specification of the form
1005 % <start spec>-<end spec>. This will call \pgfsetstartarrow{start
1006 % spec} and \pgfsetendarrow{end spec}.
1007 %
1008 % Alternatively, it may be of the form [options]. In this case,
1009 % the arrow options are set for the local scope and all arrows in
1010 % the current scope will have these options set.
1011 %
1012 % Example:
1013 %
1014 % \pgfsetarrows{-to}
1015
1016 \def\pgfsetarrows#1{\pgf@arrows#1\pgf@stop}
1017 \def\pgf@arrows{\pgfutil@ifnextchar[\pgf@arrows@test@opt\pgf@arrows@}%}
1018 \def\pgf@arrows@#1-#2\pgf@stop{%
1019 \pgfsetarrowsstart{#1}%
1020 \pgfsetarrowsend{#2}%
1021 }
1022 \def\pgf@arrows@test@opt[{%
1023 \pgfutil@ifnextchar-{\pgf@arrows@[}%} go back to normal reading for compat. reasons.
1024 \pgf@arrows@test@opt@%
1025 }
1026 \def\pgf@arrows@test@opt@#1]{%
1027 \pgfutil@ifnextchar\pgf@stop{%
1028 \let\pgf@arrows@options\pgf@arrows@options@scope%
1029 \pgfkeys{/pgf/arrow keys/.cd,#1}%
1030 \let\pgf@arrows@options@scope\pgf@arrows@options%
1031 % Ok, setup the options
1032 \pgfutil@gobble%
1033 }{%
1034 \pgf@arrows@[#1]% Oops: go back to normal mode
1035 }%
1036 }
1037
1038 \let\pgf@arrows@options@scope\pgfutil@empty
1039
1040
1041
1042
1043 %
1044 % Predefined arrows:
1045 %
1046
1047
1048 % A dot is used to indicate the end of the line:
1049
1050 \pgfdeclarearrow{
1051 name = .,
1052 drawing code =
1053 }
1054
1055
1056 % An underscore adds a space as in >_> or >_ >. However, it will be
1057 % faster to say ">[sep] >" or ">[sep=2pt] >".
1058
1059 \pgfdeclarearrow{
1060 name = _,
1061 defaults = {sep},
1062 drawing code =
1063 }
1064
1065
1066
1067 % Default shorthands:
1068
1069 \pgfdeclarearrow{ name = To, means = } % forward declaration
1070 \pgfdeclarearrow{ name = Bar, means = } % forward declaration
1071 \pgfkeys{
1072 <-> /.tip = {To},
1073 >-< /.tip = {>[reversed]},
1074 | /.tip = {Bar}
1075 }
1076
1077
1078
1079 % Compatibility with old arrow system:
1080
1081 \pgfkeys {}
1082
1083 \def\pgf@arrows@direct@def#1#2{\expandafter\pgf@arrows@direct@def@\expandafter{\csname pgf@ar@means@#2\endcsname}{#1}}
1084 \def\pgf@arrows@direct@def@#1#2{\expandafter\def\csname pgf@arrows@direct@name@#2\endcsname{\pgf@arrow@handle@shorthand@empty{#1}}}
1085 \pgf@arrows@direct@def{start@[}{]}
1086 \pgf@arrows@direct@def{start@]}{[}
1087 \pgf@arrows@direct@def{start@spaced [}{spaced ]}
1088 \pgf@arrows@direct@def{start@spaced ]}{spaced [}
1089 \pgf@arrows@direct@def{end@[}{[}
1090 \pgf@arrows@direct@def{end@]}{]}
1091 \pgf@arrows@direct@def{end@spaced [}{spaced [}
1092 \pgf@arrows@direct@def{end@spaced ]}{spaced ]}
1093
1094 \def\pgfsetarrowoptions#1#2{\expandafter\def\csname pgf@arrow@compat@opt@#1\endcsname{#2}}
1095 \def\pgfgetarrowoptions#1{\csname pgf@arrow@compat@opt@#1\endcsname}
1096 \def\pgfarrowsdeclare#1#2#3#4{%
1097 \pgfdeclarearrow{ name ={#1}-{#2}, setup code ={#3}, drawing code={#4}, parameters/.expand once={\csname pgf@arrow@compat@opt@#2\endcsname}}%
1098 \expandafter\def\csname pgf@arrow@compat@opt@#2\endcsname{0}}
1099 \def\pgfarrowsleftextend#1{\pgfmathsetlength\pgf@xa{#1}\pgfarrowssetbackend{\pgf@xa}}
1100 \def\pgfarrowsrightextend#1{\pgfmathsetlength\pgf@xb{#1}\pgfarrowssettipend{\pgf@xb}}
1101 \def\pgfarrowsdeclarealias#1#2#3#4{\pgfdeclarearrow{ name ={#1}-{#2}, means ={#4} } }
1102 \def\pgfarrowsdeclarereversed#1#2#3#4{\pgfdeclarearrow{ name ={#1}-{#2}, means={{#4}[reversed]}}}
1103 \def\pgfarrowsdeclarecombine{\pgfutil@ifnextchar*{\pgfarrowsdeclarecombine@star}{\pgf@@arrowsdeclarecombine}}
1104 \def\pgf@@arrowsdeclarecombine{\pgfutil@ifnextchar[{\pgf@arrowsdeclarecombine}{\pgf@arrowsdeclarecombine[0pt]}}
1105 \def\pgf@arrowsdeclarecombine[#1]#2#3#4#5#6#7{\def\pgf@@temp{#1}\ifx\pgf@@temp\pgf@linewidthtext\def\pgf@@temp{+0pt 1}\fi%
1106 \pgfdeclarearrow{name ={#2}-{#3}, means={#5[sep/.expand once=\pgf@@temp]#6}}}
1107 \def\pgf@linewidth@text{\pgflinewidth}
1108 \def\pgfarrowsdeclarecombine@star*{\pgfutil@ifnextchar[{\pgf@arrowsdeclarecombine@star}{\pgf@arrowsdeclarecombine@star[0pt]}}
1109 \def\pgf@arrowsdeclarecombine@star[#1]#2#3#4#5#6#7{\def\pgf@@temp{#1}\ifx\pgf@@temp\pgf@linewidthtext\def\pgf@@temp{+0pt 1}\fi%
1110 \pgfdeclarearrow{name ={#2}-{#3}, means={#5[sep/.expand once=\pgf@@temp].#6}}}
1111 \def\pgfarrowsdeclaredouble{\pgfutil@ifnextchar[{\pgf@arrowsdeclaredouble}{\pgf@arrowsdeclaredouble[0pt]}}
1112 \def\pgf@arrowsdeclaredouble[#1]#2#3#4#5{\pgfarrowsdeclarecombine[#1]{#2}{#3}{#4}{#5}{#4}{#5}}
1113 \def\pgfarrowsdeclaretriple{\pgfutil@ifnextchar[{\pgf@arrowsdeclaretriple}{\pgf@arrowsdeclaretriple[0pt]}}
1114 \def\pgf@arrowsdeclaretriple[#1]#2#3#4#5{ \pgfarrowsdeclarecombine[#1]{pgf@trip@#2}{pgf@trip@#3}{#4}{#5}{#4}{#5}%
1115 \pgfarrowsdeclarecombine[#1]{#2}{#3}{pgf@trip@#2}{pgf@trip@#3}{#4}{#5}}
1116 \def\pgf@linewidthtext{\pgflinewidth}
1117
1118 \pgfarrowsdeclare{stealth}{stealth}
1119 {
1120 \pgfutil@tempdima=0.28pt%
1121 \pgfutil@tempdimb=\pgflinewidth%
1122 \ifdim\pgfinnerlinewidth>0pt%
1123 \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
1124 \fi%
1125 \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
1126 \pgfarrowsleftextend{+-3\pgfutil@tempdima}
1127 \pgfarrowsrightextend{+5\pgfutil@tempdima}
1128 }
1129 {
1130 \pgfutil@tempdima=0.28pt%
1131 \pgfutil@tempdimb=\pgflinewidth%
1132 \ifdim\pgfinnerlinewidth>0pt%
1133 \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
1134 \fi%
1135 \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
1136 \pgfpathmoveto{\pgfqpoint{5\pgfutil@tempdima}{0pt}}
1137 \pgfpathlineto{\pgfqpoint{-3\pgfutil@tempdima}{4\pgfutil@tempdima}}
1138 \pgfpathlineto{\pgfpointorigin}
1139 \pgfpathlineto{\pgfqpoint{-3\pgfutil@tempdima}{-4\pgfutil@tempdima}}
1140 \pgfusepathqfill
1141 }
1142 \pgfarrowsdeclarereversed{stealth reversed}{stealth reversed}{stealth}{stealth}
1143 \pgfarrowsdeclare{to}{to}
1144 {
1145 \pgfutil@tempdima=-0.84pt%
1146 \advance\pgfutil@tempdima by-1.3\pgflinewidth%
1147 \pgfutil@tempdimb=0.21pt%
1148 \advance\pgfutil@tempdimb by.625\pgflinewidth%
1149 \pgfarrowsleftextend{+\pgfutil@tempdima}
1150 \pgfarrowsrightextend{+\pgfutil@tempdimb}
1151 }
1152 {
1153 \pgfutil@tempdima=0.28pt%
1154 \advance\pgfutil@tempdima by.3\pgflinewidth%
1155 \pgfsetlinewidth{0.8\pgflinewidth}
1156 \pgfsetdash{}{+0pt}
1157 \pgfsetroundcap
1158 \pgfsetroundjoin
1159 \pgfpathmoveto{\pgfqpoint{-3\pgfutil@tempdima}{4\pgfutil@tempdima}}
1160 \pgfpathcurveto
1161 {\pgfqpoint{-2.75\pgfutil@tempdima}{2.5\pgfutil@tempdima}}
1162 {\pgfqpoint{0pt}{0.25\pgfutil@tempdima}}
1163 {\pgfqpoint{0.75\pgfutil@tempdima}{0pt}}
1164 \pgfpathcurveto
1165 {\pgfqpoint{0pt}{-0.25\pgfutil@tempdima}}
1166 {\pgfqpoint{-2.75\pgfutil@tempdima}{-2.5\pgfutil@tempdima}}
1167 {\pgfqpoint{-3\pgfutil@tempdima}{-4\pgfutil@tempdima}}
1168 \pgfusepathqstroke
1169 }
1170 \pgfkeys{To /.tip = to}
1171 \pgfarrowsdeclare{to reversed}{to reversed}
1172 {
1173 \pgfutil@tempdima=-0.21pt%
1174 \advance\pgfutil@tempdima by-0.475\pgflinewidth%
1175 \pgfutil@tempdimb=0.98pt%
1176 \advance\pgfutil@tempdimb by1.45\pgflinewidth%
1177 \pgfarrowsleftextend{+\pgfutil@tempdima}
1178 \pgfarrowsrightextend{+\pgfutil@tempdimb}
1179 }
1180 {
1181 \pgfutil@tempdima=0.28pt%
1182 \advance\pgfutil@tempdima by.3\pgflinewidth%
1183 \pgfsetlinewidth{+0.8\pgflinewidth}
1184 \pgfsetdash{}{+0pt}
1185 \pgfsetroundcap
1186 \pgfsetroundjoin
1187 \pgfpathmoveto{\pgfqpoint{3.5\pgfutil@tempdima}{4\pgfutil@tempdima}}
1188 \pgfpathcurveto
1189 {\pgfqpoint{3.25\pgfutil@tempdima}{2.5\pgfutil@tempdima}}
1190 {\pgfqpoint{0.5\pgfutil@tempdima}{0.25\pgfutil@tempdima}}
1191 {\pgfqpoint{-0.25\pgfutil@tempdima}{0\pgfutil@tempdima}}
1192 \pgfpathcurveto
1193 {\pgfqpoint{0.5\pgfutil@tempdima}{-0.25\pgfutil@tempdima}}
1194 {\pgfqpoint{3.25\pgfutil@tempdima}{-2.5\pgfutil@tempdima}}
1195 {\pgfqpoint{3.5\pgfutil@tempdima}{-4\pgfutil@tempdima}}
1196 \pgfusepathqstroke
1197 }
1198 \pgfarrowsdeclare{latex}{latex}
1199 {
1200 \pgfutil@tempdima=0.28pt%
1201 \pgfutil@tempdimb=\pgflinewidth%
1202 \ifdim\pgfinnerlinewidth>0pt%
1203 \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
1204 \fi%
1205 \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
1206 \pgfarrowsleftextend{+-1\pgfutil@tempdima}
1207 \pgfarrowsrightextend{+9\pgfutil@tempdima}
1208 }
1209 {
1210 \pgfutil@tempdima=0.28pt%
1211 \pgfutil@tempdimb=\pgflinewidth%
1212 \ifdim\pgfinnerlinewidth>0pt%
1213 \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
1214 \fi%
1215 \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
1216 \pgfpathmoveto{\pgfqpoint{9\pgfutil@tempdima}{0pt}}
1217 \pgfpathcurveto
1218 {\pgfqpoint{6.3333\pgfutil@tempdima}{.5\pgfutil@tempdima}}
1219 {\pgfqpoint{2\pgfutil@tempdima}{2\pgfutil@tempdima}}
1220 {\pgfqpoint{-1\pgfutil@tempdima}{3.75\pgfutil@tempdima}}
1221 \pgfpathlineto{\pgfqpoint{-1\pgfutil@tempdima}{-3.75\pgfutil@tempdima}}
1222 \pgfpathcurveto
1223 {\pgfqpoint{2\pgfutil@tempdima}{-2\pgfutil@tempdima}}
1224 {\pgfqpoint{6.3333\pgfutil@tempdima}{-.5\pgfutil@tempdima}}
1225 {\pgfqpoint{9\pgfutil@tempdima}{0pt}}
1226 \pgfusepathqfill
1227 }
1228 \pgfarrowsdeclarereversed{latex reversed}{latex reversed}{latex}{latex}
1229 \pgfarrowsdeclare{@bar}{@bar}
1230 {
1231 \pgfarrowsleftextend{+-0.25\pgflinewidth}
1232 \pgfarrowsrightextend{+.75\pgflinewidth}
1233 }
1234 {
1235 \pgfutil@tempdima=2pt%
1236 \advance\pgfutil@tempdima by1.5\pgflinewidth%
1237 \pgfsetdash{}{+0pt}
1238 \pgfsetrectcap
1239 \pgfpathmoveto{\pgfqpoint{0.25\pgflinewidth}{-\pgfutil@tempdima}}
1240 \pgfpathlineto{\pgfqpoint{0.25\pgflinewidth}{\pgfutil@tempdima}}
1241 \pgfusepathqstroke
1242 }
1243 \pgfkeys{Bar /.tip = @bar}
1244 \pgfarrowsdeclare{space}{space}
1245 {
1246 \pgfutil@tempdima=0.88pt%
1247 \advance\pgfutil@tempdima by.3\pgflinewidth%
1248 \pgfarrowsleftextend{0pt}
1249 \pgfarrowsrightextend{\pgfutil@tempdima}
1250 }
1251 {}
1252
1253
1254
1255 \endinput