| 1 |
% Copyright 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{pgfcorepathusage.code.tex} |
| 11 |
|
| 12 |
|
| 13 |
% Stroke/fill/clip/etc. the current path. Depending on the options, |
| 14 |
% the current path will be stroked/filled/clipped/etc. If no options |
| 15 |
% are given, the path is stroked. If multiple options are given, all |
| 16 |
% of them are performed (in a sensible order). |
| 17 |
% |
| 18 |
% #1 = action(s) to be applied to the current path. Valid actions are: |
| 19 |
% stroke - strokes the path. |
| 20 |
% draw - strokes the path and adds arrow tips. |
| 21 |
% tips - adds arrow tips. |
| 22 |
% fill - fills the path. |
| 23 |
% clip - clip the path. |
| 24 |
% discard - Discards the path. Same effect as having an empty |
| 25 |
% options list. |
| 26 |
% |
| 27 |
% Example: |
| 28 |
% |
| 29 |
% % Draws an edge. |
| 30 |
% \pgfpathmoveto{\pgfxy(0,0)} |
| 31 |
% \pgfpathlineto{\pgfxy(0,1)} |
| 32 |
% \pgfpathlineto{\pgfxy(1,0)} |
| 33 |
% \pgfusepath{stroke} |
| 34 |
|
| 35 |
\pgfkeys{ |
| 36 |
/pgf/stroke/.code=\let\pgf@up@stroke\pgf@up@stroke@text\pgf@up@path@neededtrue, |
| 37 |
/pgf/draw/.code=\let\pgf@up@stroke\pgf@up@stroke@text\pgf@up@path@neededtrue, |
| 38 |
/pgf/fill/.code=\let\pgf@up@fill\pgf@up@fill@text\pgf@up@path@neededtrue, |
| 39 |
/pgf/clip/.code=\let\pgf@up@clip\pgf@up@clip@text\pgf@up@path@neededtrue, |
| 40 |
/pgf/discard/.code=, |
| 41 |
/pgf/use as bounding box/.code=\let\pgf@up@bb\pgf@do@up@bb, |
| 42 |
/pgf/arrow keys/flex/.code=\pgferror{You need to say \string\usetikzlibrary{bending} for flexing and bending arrows}, |
| 43 |
/pgf/arrow keys/flex'/.code=\pgferror{You need to say \string\usetikzlibrary{bending} for flexing and bending arrows}, |
| 44 |
/pgf/arrow keys/bend/.code=\pgferror{You need to say \string\usetikzlibrary{bending} for flexing and bending arrows}, |
| 45 |
/pgf/arrow keys/quick/.code=\pgfarrowsaddtooptions{\let\pgf@arrow@flex@mode\pgf@arrow@mode@is@quick}, |
| 46 |
} |
| 47 |
|
| 48 |
\pgfkeys{ |
| 49 |
/pgf/.cd, |
| 50 |
tips/.is choice, |
| 51 |
tips/.default=true, |
| 52 |
tips/proper/.code=\let\pgf@tips@mode\pgf@tips@mode@onproper, |
| 53 |
tips/on proper draw/.code=\let\pgf@tips@mode\pgf@tips@mode@onproperdraw, |
| 54 |
tips/true/.code=\let\pgf@tips@mode\pgf@tips@mode@true, |
| 55 |
tips/on draw/.code=\let\pgf@tips@mode\pgf@tips@mode@ondraw, |
| 56 |
tips/never/.code=\let\pgf@tips@mode\pgf@tips@mode@false, |
| 57 |
tips/false/.code=\let\pgf@tips@mode\pgf@tips@mode@false, |
| 58 |
} |
| 59 |
\def\pgf@tips@mode@onproper{4} |
| 60 |
\def\pgf@tips@mode@onproperdraw{3} |
| 61 |
\def\pgf@tips@mode@true{2} |
| 62 |
\def\pgf@tips@mode@ondraw{1} |
| 63 |
\def\pgf@tips@mode@false{0} |
| 64 |
\let\pgf@tips@mode\pgf@tips@mode@ondraw |
| 65 |
|
| 66 |
|
| 67 |
% The following can only be set to "true" using the options in the |
| 68 |
% module "bending" |
| 69 |
\newif\ifpgf@precise@shortening |
| 70 |
\def\pgf@arrow@mode@is@quick{0} |
| 71 |
\let\pgf@arrow@flex@mode\pgf@arrow@mode@is@quick |
| 72 |
|
| 73 |
\newif\ifpgf@up@path@needed |
| 74 |
\newif\ifpgf@up@draw@arrows |
| 75 |
\def\pgf@up@stroke@text{stroke} |
| 76 |
\def\pgf@up@fill@text{fill} |
| 77 |
\def\pgf@up@clip@text{clip} |
| 78 |
\def\pgf@do@up@bb{\pgf@relevantforpicturesizefalse} |
| 79 |
|
| 80 |
\def\pgfusepath#1{% |
| 81 |
\pgf@up@path@neededfalse% |
| 82 |
\pgf@up@draw@arrowsfalse% |
| 83 |
\let\pgf@up@stroke\pgfutil@empty% |
| 84 |
\let\pgf@up@fill\pgfutil@empty% |
| 85 |
\let\pgf@up@clip\pgfutil@empty% |
| 86 |
\let\pgf@up@bb\pgfutil@empty% |
| 87 |
\pgfset{#1}% |
| 88 |
\expandafter\def\expandafter\pgf@up@action\expandafter{\csname pgfsys@\pgf@up@fill\pgf@up@stroke\endcsname}% |
| 89 |
\ifnum\pgf@tips@mode=2\relax% |
| 90 |
\pgf@up@path@neededtrue% |
| 91 |
\fi% |
| 92 |
\ifnum\pgf@tips@mode=4\relax% |
| 93 |
\pgf@up@path@neededtrue% |
| 94 |
\fi% |
| 95 |
\ifpgf@up@path@needed% |
| 96 |
\else% |
| 97 |
\pgfsyssoftpath@setcurrentpath\pgfutil@empty% |
| 98 |
\fi% |
| 99 |
\ifx\pgf@up@stroke\pgfutil@empty% |
| 100 |
\ifx\pgf@up@fill\pgfutil@empty% |
| 101 |
\let\pgf@up@action=\pgfutil@empty% |
| 102 |
\ifx\pgf@up@clip\pgfutil@empty% |
| 103 |
\else% |
| 104 |
% only clipping |
| 105 |
\let\pgf@up@action=\pgfsys@discardpath% |
| 106 |
\fi% |
| 107 |
\fi% |
| 108 |
\fi% |
| 109 |
\pgfsyssoftpath@getcurrentpath\pgf@last@processed@path |
| 110 |
\pgfprocessround{\pgf@last@processed@path}{\pgf@last@processed@path}% change the path |
| 111 |
\pgfsyssoftpath@setcurrentpath\pgf@last@processed@path% |
| 112 |
% |
| 113 |
% Check whether the path is stroked. If so, add half the line width |
| 114 |
% to the bounding box. |
| 115 |
% |
| 116 |
\ifpgf@relevantforpicturesize% |
| 117 |
\ifx\pgf@up@stroke\pgfutil@empty% |
| 118 |
\else% |
| 119 |
\ifdim\pgf@picmaxx=-16000pt\relax% |
| 120 |
\else% |
| 121 |
\pgf@x=\pgf@pathminx\advance\pgf@x by-.5\pgflinewidth% |
| 122 |
\ifdim\pgf@x<\pgf@picminx\global\pgf@picminx\pgf@x\fi% |
| 123 |
\pgf@y=\pgf@pathminy\advance\pgf@y by-.5\pgflinewidth% |
| 124 |
\ifdim\pgf@y<\pgf@picminy\global\pgf@picminy\pgf@y\fi% |
| 125 |
\pgf@x=\pgf@pathmaxx\advance\pgf@x by.5\pgflinewidth% |
| 126 |
\ifdim\pgf@x>\pgf@picmaxx\global\pgf@picmaxx\pgf@x\fi% |
| 127 |
\pgf@y=\pgf@pathmaxy\advance\pgf@y by.5\pgflinewidth% |
| 128 |
\ifdim\pgf@y>\pgf@picmaxy\global\pgf@picmaxy\pgf@y\fi% |
| 129 |
\fi% |
| 130 |
\fi% |
| 131 |
\fi% |
| 132 |
% |
| 133 |
\ifx\pgf@up@clip\pgfutil@empty% |
| 134 |
\ifx\pgf@up@stroke\pgfutil@empty% |
| 135 |
\ifx\pgf@up@action\pgfutil@empty% |
| 136 |
\ifnum\pgf@tips@mode=2\relax% |
| 137 |
\pgf@up@draw@arrows@only% |
| 138 |
\fi% |
| 139 |
\ifnum\pgf@tips@mode=4\relax% |
| 140 |
\pgf@up@draw@arrows@only% |
| 141 |
\fi% |
| 142 |
\else% |
| 143 |
\pgfsyssoftpath@invokecurrentpath% |
| 144 |
\pgf@up@action% |
| 145 |
\fi% |
| 146 |
\else% |
| 147 |
\pgfgetpath\pgf@arrowpath% |
| 148 |
\pgf@path@setup@tempswa% |
| 149 |
\pgfprocesscheckclosed{\pgf@arrowpath}{\pgfutil@tempswafalse}% |
| 150 |
\pgf@path@check@proper% |
| 151 |
\ifpgfutil@tempswa% |
| 152 |
\pgf@check@for@arrow@and@animation% |
| 153 |
\pgf@prepare@end@of@path% |
| 154 |
\begingroup% |
| 155 |
\pgf@prepare@start@of@path% |
| 156 |
\fi% |
| 157 |
\pgfsyssoftpath@invokecurrentpath% |
| 158 |
\pgf@up@action% |
| 159 |
\ifdim\pgfinnerlinewidth>0pt\relax% |
| 160 |
\pgf@stroke@inner@line% |
| 161 |
\fi% |
| 162 |
\ifpgfutil@tempswa% |
| 163 |
\pgf@add@arrow@at@start% |
| 164 |
\endgroup% |
| 165 |
\pgf@add@arrow@at@end% |
| 166 |
\fi% |
| 167 |
\fi% |
| 168 |
\else% |
| 169 |
\pgfsyssoftpath@invokecurrentpath% |
| 170 |
\pgfsys@clipnext% |
| 171 |
\pgf@up@action% |
| 172 |
\pgf@relevantforpicturesizefalse% |
| 173 |
\fi% |
| 174 |
\pgf@up@bb% |
| 175 |
\pgfsyssoftpath@setcurrentpath\pgfutil@empty% |
| 176 |
\pgf@resetpathsizes% |
| 177 |
\ignorespaces% |
| 178 |
} |
| 179 |
\def\pgf@path@setup@tempswa{% |
| 180 |
\ifnum\pgf@tips@mode>0\relax |
| 181 |
\pgfutil@tempswatrue% |
| 182 |
\else |
| 183 |
\pgfutil@tempswafalse% |
| 184 |
\fi% |
| 185 |
} |
| 186 |
\def\pgf@up@draw@arrows@only{% |
| 187 |
\pgfgetpath\pgf@arrowpath% |
| 188 |
\pgfutil@tempswatrue% |
| 189 |
\pgfprocesscheckclosed{\pgf@arrowpath}{\pgfutil@tempswafalse}% |
| 190 |
\pgf@path@check@proper% |
| 191 |
\ifpgfutil@tempswa% |
| 192 |
\pgf@check@for@arrow@and@animation% |
| 193 |
\pgf@prepare@end@of@path% |
| 194 |
\begingroup% |
| 195 |
\pgf@prepare@start@of@path% |
| 196 |
\pgf@add@arrow@at@start% |
| 197 |
\endgroup% |
| 198 |
\pgf@add@arrow@at@end% |
| 199 |
\fi% |
| 200 |
} |
| 201 |
|
| 202 |
\def\pgf@check@for@arrow@and@animation{\pgfsys@if@fresh@currentid{\pgf@check@for@arrow@and@animation@}{}}% |
| 203 |
\def\pgf@check@for@arrow@and@animation@{% |
| 204 |
\expandafter\ifx\csname pgfsysanim@path@is@animated@\pgf@sys@id@current@id @\pgfsys@current@type\endcsname\pgfutil@empty% |
| 205 |
% Ok, an animation is here! |
| 206 |
\ifx\pgf@end@tip@sequence\pgfutil@empty% |
| 207 |
\ifx\pgf@start@tip@sequence\pgfutil@empty% |
| 208 |
\else% |
| 209 |
\pgf@check@for@arrow@and@animation@error% |
| 210 |
\fi% |
| 211 |
\else% |
| 212 |
\pgf@check@for@arrow@and@animation@error% |
| 213 |
\fi% |
| 214 |
\fi% |
| 215 |
} |
| 216 |
\def\pgf@check@for@arrow@and@animation@error{\pgferror{Animated path may not have normal arrow tips. Use a base path with arrow tips}} |
| 217 |
|
| 218 |
\def\pgf@path@check@proper{% |
| 219 |
\ifpgfutil@tempswa% |
| 220 |
\ifnum\pgf@tips@mode>2\relax% |
| 221 |
\pgf@path@check@proper@% |
| 222 |
\fi% |
| 223 |
\fi% |
| 224 |
} |
| 225 |
|
| 226 |
\def\pgf@path@check@proper@{% |
| 227 |
{% |
| 228 |
\pgf@x0pt\pgf@y\pgf@x% |
| 229 |
\pgfutil@tempswatrue% |
| 230 |
\let\pgfsyssoftpath@movetotoken\pgf@path@proper@init% |
| 231 |
\let\pgfsyssoftpath@linetotoken\pgf@path@proper@test%% |
| 232 |
\let\pgfsyssoftpath@curvetosupportatoken\pgf@path@proper@test% |
| 233 |
\let\pgfsyssoftpath@curvetosupportbtoken=\pgf@path@proper@test% |
| 234 |
\let\pgfsyssoftpath@curvetotoken\pgf@path@proper@test% |
| 235 |
\let\pgfsyssoftpath@rectcornertoken\pgf@path@proper@test% |
| 236 |
\let\pgfsyssoftpath@rectsizetoken\pgf@path@proper@zero@test% |
| 237 |
\let\pgfsyssoftpath@closepathtoken\pgf@path@proper@test% |
| 238 |
% Execute the path: |
| 239 |
\pgf@arrowpath% |
| 240 |
\expandafter |
| 241 |
}% |
| 242 |
\ifpgfutil@tempswa\pgfutil@tempswafalse\else\pgfutil@tempswatrue\fi% |
| 243 |
} |
| 244 |
|
| 245 |
\def\pgf@path@proper@init#1#2{\pgfutil@tempswatrue\pgf@x#1\pgf@y#2}% |
| 246 |
\def\pgf@path@proper@test#1#2{% |
| 247 |
\ifdim\pgf@x=#1\relax\else\pgfutil@tempswafalse\fi% |
| 248 |
\ifdim\pgf@y=#2\relax\else\pgfutil@tempswafalse\fi} |
| 249 |
\def\pgf@path@proper@zero@test#1#2{% |
| 250 |
\ifdim\pgf@x=0pt\relax\else\pgfutil@tempswafalse\fi% |
| 251 |
\ifdim\pgf@y=0pt\relax\else\pgfutil@tempswafalse\fi} |
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
\def\pgf@stroke@inner@line{% |
| 257 |
\let\pgf@temp@save=\pgf@strokecolor@global |
| 258 |
\pgfsys@beginscope% |
| 259 |
{% |
| 260 |
\pgfsys@setlinewidth{\pgfinnerlinewidth}% |
| 261 |
\pgfsetstrokecolor{\pgfinnerstrokecolor}% |
| 262 |
\pgfsyssoftpath@invokecurrentpath% |
| 263 |
\pgfsys@stroke% |
| 264 |
}% |
| 265 |
\pgfsys@endscope% |
| 266 |
\global\let\pgf@strokecolor@global=\pgf@temp@save |
| 267 |
} |
| 268 |
|
| 269 |
\let\pgf@prepare@start@of@path\relax% |
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
% Shorten start/end of paths by a certain amount. |
| 275 |
% |
| 276 |
% #1 = amount by which paths should be shortened. |
| 277 |
% |
| 278 |
% Example: |
| 279 |
% |
| 280 |
% \pgfpathmoveto{\pgfpointorigin} |
| 281 |
% \pgfpathlineto{\pgfpoint{10pt}{0pt} |
| 282 |
% |
| 283 |
% % The following has the same effect: |
| 284 |
% \pgfsetshortenstart{1pt} |
| 285 |
% \pgfpathmoveto{\pgfpointorigin} |
| 286 |
% \pgfpathlineto{\pgfpoint{11pt}{0pt} |
| 287 |
|
| 288 |
\def\pgfsetshortenstart#1{\pgfmathsetlength\pgf@shorten@start@additional{#1}} |
| 289 |
\def\pgfsetshortenend#1{\pgfmathsetlength\pgf@shorten@end@additional{#1}} |
| 290 |
|
| 291 |
\newdimen\pgf@shorten@end@additional |
| 292 |
\newdimen\pgf@shorten@start@additional |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
% |
| 297 |
% |
| 298 |
% Handling the end of a path |
| 299 |
% |
| 300 |
% |
| 301 |
% The "handling" consists of first testing whether we need to do |
| 302 |
% anything at all, namely because either an arrow tip should be drawn |
| 303 |
% at the end or because the path should be shortened at the end. If |
| 304 |
% so, we shorten the path if needed and, later on, add the arrow tip. |
| 305 |
% |
| 306 |
|
| 307 |
\newif\ifpgf@worry |
| 308 |
|
| 309 |
|
| 310 |
% Prepare the end of the path: Test whether anything must be done |
| 311 |
% (step 0) and, if so, split the path (step 1), extract the interesting points from |
| 312 |
% the path (step 2), prepare further computations (step 3), shorten |
| 313 |
% the path (step 4) if necessary, and add the arrow tip (step 4 in |
| 314 |
% macro \pgf@add@arrow@at@end, which is called later). |
| 315 |
|
| 316 |
\def\pgf@prepare@end@of@path{% |
| 317 |
\let\pgfprocessresultpathsuffix\relax% flag that nothing has happened... |
| 318 |
\let\pgfprocessresultsubpathsuffix\relax% |
| 319 |
\pgfsyssoftpath@getcurrentpath\pgf@arrowpath% |
| 320 |
% |
| 321 |
% Step 0 start: |
| 322 |
% |
| 323 |
% Do we need to worry about the end? |
| 324 |
% |
| 325 |
\ifx\pgf@arrowpath\pgfutil@empty\else% |
| 326 |
\pgf@worryfalse% |
| 327 |
\ifx\pgf@end@tip@sequence\pgfutil@empty% |
| 328 |
\else% |
| 329 |
\pgf@worrytrue% Yes, worry if we have to draw an arrow |
| 330 |
\fi% |
| 331 |
\pgf@precise@shorteningfalse% |
| 332 |
\pgf@arrow@compute@shortening\pgf@end@tip@sequence% |
| 333 |
\advance\pgf@xa by\pgf@shorten@end@additional% |
| 334 |
\advance\pgf@xb by\pgf@shorten@end@additional% |
| 335 |
\ifdim\pgf@xa=0pt\relax\else\pgf@worrytrue\fi% Also, worry if shortening is requested |
| 336 |
\edef\pgf@path@shortening@distance{\the\pgf@xa}% |
| 337 |
\edef\pgf@arrow@tip@total@length{\the\pgf@xb}% |
| 338 |
% |
| 339 |
% Step 0 done. |
| 340 |
% |
| 341 |
\ifpgf@worry% |
| 342 |
% Ok, need to "worry" about the end, either because we need to |
| 343 |
% shorten it or to draw an arrow head. |
| 344 |
% |
| 345 |
% Step 1: Split |
| 346 |
% |
| 347 |
\pgfprocesssplitpath{\pgf@arrowpath}% |
| 348 |
\pgfprocesssplitsubpath{\pgfprocessresultpathsuffix}% |
| 349 |
% |
| 350 |
% Step 2: extract |
| 351 |
% |
| 352 |
\expandafter\pgf@parse@end\pgfprocessresultsubpathsuffix\pgf@stop\pgf@stop\pgf@stop% |
| 353 |
% |
| 354 |
% Step 3: prep |
| 355 |
% |
| 356 |
\pgf@prep@end% |
| 357 |
% |
| 358 |
% Step 4: shorten |
| 359 |
% |
| 360 |
\ifdim\pgf@path@shortening@distance=0pt\else\pgf@do@shorten@end\fi% |
| 361 |
\expandafter\expandafter\expandafter\def% |
| 362 |
\expandafter\expandafter\expandafter\pgf@arrowpath% |
| 363 |
\expandafter\expandafter\expandafter{\expandafter\pgfprocessresultpathprefix\pgfprocessresultpathsuffix}% |
| 364 |
\pgfsyssoftpath@setcurrentpath\pgf@arrowpath% |
| 365 |
\fi% |
| 366 |
\fi% |
| 367 |
} |
| 368 |
|
| 369 |
\def\pgf@parse@end#1#2#3#4#5#6{% |
| 370 |
\ifx#4\pgf@stop% Only a moveto! -> do nothing! |
| 371 |
\def\pgfpointlastonpath{\pgfqpoint{#2}{#3}}% |
| 372 |
\let\pgf@next\relax% |
| 373 |
\let\pgf@do@shorten@end\relax% |
| 374 |
\let\pgf@do@draw@end\pgf@do@draw@straightend% |
| 375 |
\let\pgf@prep@end\pgf@prep@movetoend% |
| 376 |
\else\ifx#4\pgfsyssoftpath@curvetosupportatoken% A curve -> this will get complicated... |
| 377 |
\def\pgfsubpathfourthlasttoken{#1}% |
| 378 |
\def\pgfpointfourthlastonpath{\pgfqpoint{#2}{#3}}% |
| 379 |
\def\pgfpointthirdlastonpath{\pgfqpoint{#5}{#6}}% |
| 380 |
\ifpgf@precise@shortening% |
| 381 |
\let\pgf@do@shorten@end\pgf@do@shorten@curvedend% |
| 382 |
\let\pgf@do@draw@end\pgf@do@draw@curvedend% |
| 383 |
\let\pgf@prep@end\pgf@prep@curveend% |
| 384 |
\else% |
| 385 |
\def\pgfsubpathstart{\noexpand#1{#2}{#3}\noexpand#4{#5}{#6}}% |
| 386 |
\let\pgf@do@shorten@end\pgf@do@shorten@straightend% |
| 387 |
\let\pgf@do@draw@end\pgf@do@draw@straightend% |
| 388 |
\let\pgf@prep@end\pgf@prep@straightend% |
| 389 |
\fi% |
| 390 |
\let\pgf@next\pgf@parse@end@curve@cont% |
| 391 |
\else% A straight line -> great! |
| 392 |
\def\pgfsubpathstart{\noexpand#1{#2}{#3}\noexpand#4}% |
| 393 |
\def\pgfpointsecondlastonpath{\pgfqpoint{#2}{#3}}% |
| 394 |
\def\pgfpointlastonpath{\pgfqpoint{#5}{#6}}% |
| 395 |
\let\pgfpointfourthlastonpath\relax% |
| 396 |
\let\pgfpointthirdlastonpath\relax% |
| 397 |
\let\pgf@next\pgf@parse@end@gobble@three% |
| 398 |
\let\pgf@do@shorten@end\pgf@do@shorten@straightend% |
| 399 |
\let\pgf@do@draw@end\pgf@do@draw@straightend% |
| 400 |
\let\pgf@prep@end\pgf@prep@straightend% |
| 401 |
\fi\fi% |
| 402 |
\pgf@next% Needed for reading rest of path... |
| 403 |
} |
| 404 |
|
| 405 |
\def\pgf@parse@end@gobble@three#1#2#3{}% |
| 406 |
\def\pgf@parse@end@curve@cont#1#2#3#4#5#6#7#8#9{% |
| 407 |
\def\pgfpointsecondlastonpath{\pgfqpoint{#2}{#3}}% |
| 408 |
\def\pgfpointlastonpath{\pgfqpoint{#5}{#6}}% |
| 409 |
\ifpgf@precise@shortening% |
| 410 |
\else% |
| 411 |
\expandafter\def\expandafter\pgfsubpathstart\expandafter{\pgfsubpathstart\noexpand#1{#2}{#3}\noexpand#4}% |
| 412 |
\fi% |
| 413 |
} |
| 414 |
|
| 415 |
% |
| 416 |
% Preps |
| 417 |
% |
| 418 |
\def\pgf@prep@movetoend{% |
| 419 |
\pgf@process{\pgfpointlastonpath}% |
| 420 |
\pgf@xb\pgf@x |
| 421 |
\pgf@yb\pgf@y |
| 422 |
\pgf@xc\pgf@x |
| 423 |
\pgf@yc\pgf@y |
| 424 |
} |
| 425 |
\def\pgf@prep@straightend{% |
| 426 |
\let\pgf@ref\pgfpointsecondlastonpath |
| 427 |
\ifx\pgfpointlastonpath\pgfpointsecondlastonpath% degenerate! |
| 428 |
\ifx\pgfpointthirdlastonpath\relax% cannot help it: really a zero-length path |
| 429 |
\else% |
| 430 |
\ifx\pgfpointlastonpath\pgfpointthirdlastonpath% double degenerate! |
| 431 |
\let\pgf@ref\pgfpointfourthlastonpath% Use third point for reference. |
| 432 |
\else |
| 433 |
\let\pgf@ref\pgfpointthirdlastonpath% Use third point for reference. |
| 434 |
\fi% |
| 435 |
\fi% |
| 436 |
\fi% |
| 437 |
\pgfpointlineatdistance{\pgf@path@shortening@distance}{\pgfpointlastonpath}{\pgf@ref}% |
| 438 |
\pgf@xa\pgf@x% |
| 439 |
\pgf@ya\pgf@y% |
| 440 |
} |
| 441 |
|
| 442 |
|
| 443 |
% |
| 444 |
% Line shortening for straight lines: |
| 445 |
% |
| 446 |
\def\pgf@do@shorten@straightend{% |
| 447 |
\edef\pgfprocessresultsubpathsuffix{\pgfsubpathstart{\the\pgf@xa}{\the\pgf@ya}}% |
| 448 |
\expandafter\expandafter\expandafter\def% |
| 449 |
\expandafter\expandafter\expandafter\pgfprocessresultpathsuffix% |
| 450 |
\expandafter\expandafter\expandafter{\expandafter\pgfprocessresultsubpathprefix\pgfprocessresultsubpathsuffix}% |
| 451 |
} |
| 452 |
|
| 453 |
|
| 454 |
% |
| 455 |
% Draw an end arrow by calling an appropriate subfunction, if necessary |
| 456 |
% |
| 457 |
|
| 458 |
\def\pgf@add@arrow@at@end{% |
| 459 |
\ifx\pgf@arrowpath\pgfutil@empty\else% |
| 460 |
\ifx\pgf@end@tip@sequence\pgfutil@empty\else% |
| 461 |
\pgf@do@draw@end% |
| 462 |
\fi% |
| 463 |
\fi% |
| 464 |
} |
| 465 |
|
| 466 |
% |
| 467 |
% Draw an end arrow at the end of a straight line |
| 468 |
% |
| 469 |
\def\pgf@do@draw@straightend{% |
| 470 |
{% |
| 471 |
\pgftransformreset% |
| 472 |
\pgftransformarrow{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{\pgf@xb}{\pgf@yb}}% |
| 473 |
\pgf@arrow@draw@arrow\pgf@end@tip@sequence\pgf@arrow@tip@total@length% |
| 474 |
}% |
| 475 |
} |
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
% |
| 482 |
% |
| 483 |
% Handling the start of a path |
| 484 |
% |
| 485 |
% |
| 486 |
% The "handling" is similar to the case for the start of the path. We |
| 487 |
% may be able to skip the splitting if that was done already for the |
| 488 |
% end. Otherwise, things are basically the same. |
| 489 |
% |
| 490 |
|
| 491 |
% Prepare the start of the path: Test whether anything must be done |
| 492 |
% (step 0) and, if so, split the path (step 1) if necessary, extract |
| 493 |
% the interesting points from the path (step 2), prepare computations |
| 494 |
% (step 3) needed for both shortening and tip adding, shorten the path |
| 495 |
% (step 4), and add the arrow tip (step 5 in macro |
| 496 |
% \pgf@add@arrow@at@start, which is called later). |
| 497 |
|
| 498 |
\def\pgf@prepare@start@of@path{% |
| 499 |
% |
| 500 |
% Step 0 start: |
| 501 |
% |
| 502 |
% Do we need to worry about the start? |
| 503 |
% |
| 504 |
\ifx\pgf@arrowpath\pgfutil@empty\else% |
| 505 |
\pgf@worryfalse% |
| 506 |
\ifx\pgf@start@tip@sequence\pgfutil@empty\else\pgf@worrytrue\fi% Yes, worry if we have to draw an arrow |
| 507 |
\pgf@precise@shorteningfalse% |
| 508 |
\pgf@arrow@compute@shortening\pgf@start@tip@sequence% |
| 509 |
\advance\pgf@xa by\pgf@shorten@start@additional% |
| 510 |
\advance\pgf@xb by\pgf@shorten@start@additional% |
| 511 |
\ifdim\pgf@xa=0pt\relax\else\pgf@worrytrue\fi% Also, worry if shortening is requested |
| 512 |
\edef\pgf@path@shortening@distance{\the\pgf@xa}% |
| 513 |
\edef\pgf@arrow@tip@total@length{\the\pgf@xb}% |
| 514 |
% |
| 515 |
% Step 0 done. |
| 516 |
% |
| 517 |
\ifpgf@worry% |
| 518 |
% Ok, need to "worry" about the start, either because we need to |
| 519 |
% shorten it or to draw an arrow head. |
| 520 |
% |
| 521 |
% Step 1: Split |
| 522 |
% |
| 523 |
\ifx\pgfprocessresultpathsuffix\relax% |
| 524 |
% Ok, still need to compute the split: |
| 525 |
\pgfprocesssplitpath{\pgf@arrowpath}% |
| 526 |
\fi% |
| 527 |
% |
| 528 |
% Step 2: extract |
| 529 |
% |
| 530 |
\expandafter\pgf@parse@start\pgfprocessresultpathsuffix\pgf@stop\pgf@stop\pgf@stop% |
| 531 |
% |
| 532 |
% Step 3: prep |
| 533 |
% |
| 534 |
\pgf@prep@start% |
| 535 |
% |
| 536 |
% Step 4: shorten |
| 537 |
% |
| 538 |
\ifdim\pgf@path@shortening@distance=0pt\else\pgf@do@shorten@start\fi% |
| 539 |
\expandafter\expandafter\expandafter\def% |
| 540 |
\expandafter\expandafter\expandafter\pgf@arrowpath% |
| 541 |
\expandafter\expandafter\expandafter{\expandafter\pgfprocessresultpathprefix\pgfprocessresultpathsuffix}% |
| 542 |
\pgfsyssoftpath@setcurrentpath\pgf@arrowpath% |
| 543 |
\fi% |
| 544 |
\fi% |
| 545 |
} |
| 546 |
|
| 547 |
\def\pgf@parse@start#1#2#3#4#5#6{% |
| 548 |
\def\pgfpointfirstonpath{\pgfqpoint{#2}{#3}}% |
| 549 |
\def\pgfpointsecondonpath{\pgfqpoint{#5}{#6}}% |
| 550 |
\let\pgfpointthirdonpath\relax% |
| 551 |
\let\pgfpointfourthonpath\relax% |
| 552 |
\def\pgfsubpathfirsttoken{\noexpand#1}% |
| 553 |
\def\pgfsubpathsecondtoken{\noexpand#4}% |
| 554 |
\ifx#4\pgf@stop% Only a moveto! -> do nothing! |
| 555 |
\let\pgf@next\relax% |
| 556 |
\let\pgf@do@shorten@start\relax% |
| 557 |
\let\pgf@prep@start\pgf@prep@movetostart% |
| 558 |
\let\pgf@do@draw@start\pgf@do@draw@straightstart% |
| 559 |
\else\ifx#4\pgfsyssoftpath@curvetosupportatoken% A curve -> this will get complicated... |
| 560 |
\ifpgf@precise@shortening% |
| 561 |
\let\pgf@next\pgf@parse@start@curve@cont% |
| 562 |
\let\pgf@do@shorten@start\pgf@do@shorten@curvedstart% |
| 563 |
\let\pgf@do@draw@start\pgf@do@draw@curvedstart% |
| 564 |
\let\pgf@prep@start\pgf@prep@curvedstart% |
| 565 |
\else% can treat the end like a straight line... |
| 566 |
\let\pgf@next\pgf@parse@start@curve@cont@straight% |
| 567 |
\let\pgf@do@shorten@start\pgf@do@shorten@straightstart% |
| 568 |
\let\pgf@do@draw@start\pgf@do@draw@straightstart% |
| 569 |
\let\pgf@prep@start\pgf@prep@straightstart% |
| 570 |
\fi% |
| 571 |
\else% A straight line -> great! |
| 572 |
\let\pgf@next\pgf@parse@start@till@stop% |
| 573 |
\let\pgf@do@shorten@start\pgf@do@shorten@straightstart% |
| 574 |
\let\pgf@do@draw@start\pgf@do@draw@straightstart% |
| 575 |
\let\pgf@prep@start\pgf@prep@straightstart% |
| 576 |
\fi\fi% |
| 577 |
\pgf@next% Needed for reading rest of path... |
| 578 |
} |
| 579 |
|
| 580 |
\def\pgf@parse@start@till@stop#1\pgf@stop\pgf@stop\pgf@stop{\def\pgfsubpathend{#1}}% |
| 581 |
|
| 582 |
\def\pgf@parse@start@curve@cont#1#2#3#4#5#6#7\pgf@stop\pgf@stop\pgf@stop{% |
| 583 |
\def\pgfpointthirdonpath{\pgfqpoint{#2}{#3}}% |
| 584 |
\def\pgfpointfourthonpath{\pgfqpoint{#5}{#6}}% |
| 585 |
\def\pgfsubpathend{#7}% |
| 586 |
} |
| 587 |
|
| 588 |
\def\pgf@parse@start@curve@cont@straight#1#2#3#4#5#6#7\pgf@stop\pgf@stop\pgf@stop{% |
| 589 |
\def\pgfpointthirdonpath{\pgfqpoint{#2}{#3}}% |
| 590 |
\def\pgfpointfourthonpath{\pgfqpoint{#5}{#6}}% |
| 591 |
\def\pgfsubpathend{#1{#2}{#3}#4{#5}{#6}#7}% |
| 592 |
} |
| 593 |
|
| 594 |
% |
| 595 |
% Preps |
| 596 |
% |
| 597 |
\def\pgf@prep@movetostart{% |
| 598 |
\pgf@process{\pgfpointfirstonpath}% |
| 599 |
\pgf@xb\pgf@x |
| 600 |
\pgf@yb\pgf@y |
| 601 |
\pgf@xc\pgf@x |
| 602 |
\pgf@yc\pgf@y |
| 603 |
} |
| 604 |
\def\pgf@prep@straightstart{% |
| 605 |
\let\pgf@ref\pgfpointsecondonpath |
| 606 |
\ifx\pgfpointfirstonpath\pgfpointsecondonpath% degenerate! |
| 607 |
\ifx\pgfpointthirdonpath\relax% cannot help it: really a zero-length path |
| 608 |
\else% |
| 609 |
\ifx\pgfpointfirstonpath\pgfpointthirdonpath% double degenerate! |
| 610 |
\let\pgf@ref\pgfpointfourthonpath% Use third point for reference. |
| 611 |
\else |
| 612 |
\let\pgf@ref\pgfpointthirdonpath% Use third point for reference. |
| 613 |
\fi% |
| 614 |
\fi% |
| 615 |
\fi% |
| 616 |
\pgfpointlineatdistance{\pgf@path@shortening@distance}{\pgfpointfirstonpath}{\pgf@ref}% |
| 617 |
\pgf@xa\pgf@x% |
| 618 |
\pgf@ya\pgf@y% |
| 619 |
} |
| 620 |
|
| 621 |
% |
| 622 |
% Line shortening for straight lines: |
| 623 |
% |
| 624 |
\def\pgf@do@shorten@straightstart{% |
| 625 |
\edef\pgfprocessresultpathsuffix{\pgfsubpathfirsttoken{\the\pgf@xa}{\the\pgf@ya}\pgfsubpathsecondtoken{\the\pgf@xc}{\the\pgf@yc}}% |
| 626 |
\expandafter\expandafter\expandafter\def% |
| 627 |
\expandafter\expandafter\expandafter\pgfprocessresultpathsuffix% |
| 628 |
\expandafter\expandafter\expandafter{\expandafter\pgfprocessresultpathsuffix\pgfsubpathend}% |
| 629 |
} |
| 630 |
|
| 631 |
|
| 632 |
% |
| 633 |
% Draw a start arrow by calling an appropriate subfunction, if necessary |
| 634 |
% |
| 635 |
|
| 636 |
\def\pgf@add@arrow@at@start{% |
| 637 |
\ifx\pgf@arrowpath\pgfutil@empty\else% |
| 638 |
\ifx\pgf@start@tip@sequence\pgfutil@empty\else% |
| 639 |
\pgf@do@draw@start% |
| 640 |
\fi% |
| 641 |
\fi% |
| 642 |
} |
| 643 |
|
| 644 |
% |
| 645 |
% Draw an start arrow at the start of a straight line |
| 646 |
% |
| 647 |
\def\pgf@do@draw@straightstart{% |
| 648 |
{% |
| 649 |
\pgftransformreset% |
| 650 |
\pgftransformarrow{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{\pgf@xb}{\pgf@yb}}% |
| 651 |
\pgf@arrow@draw@arrow\pgf@start@tip@sequence\pgf@arrow@tip@total@length% |
| 652 |
}% |
| 653 |
} |
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
\let\pgf@shorten@end=\pgfutil@empty |
| 658 |
\let\pgf@shorten@start=\pgfutil@empty |
| 659 |
|
| 660 |
|
| 661 |
\endinput% |