Debian Codegraph @

texmf-dist/tex/generic/tikz-ext/tikzlibraryext.paths.ortho.code.tex

raw
1 % Copyright 2022 by Qrrbrbirlbel
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 Free Documentation License.
7 %
8
9 \unless\ifcsname tikzextset\endcsname
10 \input tikzext-util.tex
11 \fi
12
13 %% For the operators r-lr, r-rl, r-ud and r-du we need to check after TikZ found r
14 \let\tikzextorig@tikz@rect\tikz@rect
15 \def\tikz@rect{\pgfutil@ifnextchar e\tikzextorig@tikz@rect\tikzext@tikz@r}
16 \def\tikzext@tikz@r -{%
17 \pgfutil@ifnextchar l\tikzext@ortho@lr{%
18 \pgfutil@ifnextchar r\tikzext@ortho@rl{%
19 \pgfutil@ifnextchar u\tikzext@ortho@ud{%
20 \pgfutil@ifnextchar d\tikzext@ortho@du\tikz@expand
21 }%
22 }%
23 }%
24 }
25 %% For the operator |-| we need to check after TikZ found |-
26 \let\tikzextorig@tikz@vh@lineto@next\tikz@vh@lineto@next
27 \def\tikz@vh@lineto@next{%
28 \pgfutil@ifnextchar|{\expandafter\tikzext@ortho@vhv\pgfutil@gobble}%
29 {\pgfutil@ifnextchar\tikz@activebar{\expandafter\tikzext@ortho@vhv\pgfutil@gobble}%
30 {\tikzextorig@tikz@vh@lineto@next}}}
31 %% For the operator -|- we need to check after TikZ found -|
32 \let\tikzextorig@tikz@hv@lineto\tikz@hv@lineto
33 \def\tikz@hv@lineto{%
34 \pgfutil@ifnextchar-{\expandafter\tikzext@ortho@hvh\pgfutil@gobble}%
35 {\tikzextorig@tikz@hv@lineto}}
36
37 %% |-|[<opts>] and -|-[<opts>] are allowed
38 \def\tikzext@ortho@vhv{\pgfutil@ifnextchar[{\tikzext@ortho@opts\tikzext@ortho@vhv@next}{\tikzext@ortho@opts\tikzext@ortho@vhv@next[]}}
39 \def\tikzext@ortho@hvh{\pgfutil@ifnextchar[{\tikzext@ortho@opts\tikzext@ortho@hvh@next}{\tikzext@ortho@opts\tikzext@ortho@hvh@next[]}}
40
41 %% r-rl[<opts>], r-lr[<opts>], etc.
42 \def\tikzext@ortho@rl rl{\pgfutil@ifnextchar[{\tikzext@ortho@opts\tikzext@ortho@rl@next}{\tikzext@ortho@opts\tikzext@ortho@rl@next[]}}
43 \def\tikzext@ortho@lr lr{\pgfutil@ifnextchar[{\tikzext@ortho@opts\tikzext@ortho@lr@next}{\tikzext@ortho@opts\tikzext@ortho@lr@next[]}}
44 \def\tikzext@ortho@du du{\pgfutil@ifnextchar[{\tikzext@ortho@opts\tikzext@ortho@du@next}{\tikzext@ortho@opts\tikzext@ortho@du@next[]}}
45 \def\tikzext@ortho@ud ud{\pgfutil@ifnextchar[{\tikzext@ortho@opts\tikzext@ortho@ud@next}{\tikzext@ortho@opts\tikzext@ortho@ud@next[]}}
46
47 %% TikZ interjects are done, the rest is independent:
48 \newif\iftikzext@ortho@fromcenter
49 \newif\iftikzext@ortho@preflush
50 \tikzext@ortho@preflushtrue
51
52 %%% HVVH/UDLR
53 \tikzextset{%
54 ortho/.code=\pgfqkeys{/tikz/ext/ortho}{#1},
55 hvvh/.code=\pgfqkeys{/tikz/ext/ortho}{#1},%
56 udlr/.code=\pgfqkeys{/tikz/ext/ortho}{#1},%
57 ortho/.search also=/tikz,
58 ortho/middle 0 to 1/.style={/tikz/ext/ortho/spacing=0},%
59 ortho/from center/.is if=tikzext@ortho@fromcenter,%
60 ortho/spacing/.code=% spacing = 0 or 1 means that the middle part are the pos-itions 0 to 1,
61 % the first part is -1 to 0, the last part is to 2
62 \pgfmathint{#1}\let\tikzext@ortho@timing@parts\pgfmathresult% in case they are calculations to be done
63 \ifnum\tikzext@ortho@timing@parts<2
64 \def\tikzext@ortho@timing@parts{1}%
65 \def\tikzext@ortho@timing@first{0}%
66 \def\tikzext@ortho@timing@last{1}%
67 \def\tikzext@ortho@timing@subtr{0}%
68 \def\tikzext@ortho@timing@factor{1}%
69 \else % in all other cases n > 1 the kinks are at pos = 1/n and (n - 1)/n
70 \pgfmathreciprocal{\tikzext@ortho@timing@parts}%
71 \let\tikzext@ortho@timing@first\pgfmathresult
72 \pgfmathsetmacro\tikzext@ortho@timing@last{1-\pgfmathresult}%
73 \pgfmathreciprocal{\tikzext@ortho@timing@parts-2}%
74 \let\tikzext@ortho@timing@subtr\pgfmathresult
75 \pgfmathsetmacro\tikzext@ortho@timing@factor{1+2*\pgfmathresult}%
76 \fi,%
77 ortho/hvh ratio/.code=%
78 \pgfkeyssetvalue{/tikz/ext/ortho/hvh distance}{}%
79 \pgfkeyssetvalue{/tikz/ext/ortho/hvh ratio}{#1},
80 ortho/vhv ratio/.code=%
81 \pgfkeyssetvalue{/tikz/ext/ortho/vhv distance}{}%
82 \pgfkeyssetvalue{/tikz/ext/ortho/vhv ratio}{#1},
83 ortho/hvh distance/.code=%
84 \pgfkeyssetvalue{/tikz/ext/ortho/hvh distance}{#1}%
85 \pgfkeyssetvalue{/tikz/ext/ortho/hvh ratio}{},
86 ortho/vhv distance/.code=%
87 \pgfkeyssetvalue{/tikz/ext/ortho/vhv distance}{#1}%
88 \pgfkeyssetvalue{/tikz/ext/ortho/vhv ratio}{},
89 ortho/hvvh distance/.style={
90 /tikz/ext/ortho/hvh distance={#1},
91 /tikz/ext/ortho/vhv distance={#1}},
92 ortho/hvvh ratio/.style={
93 /tikz/ext/ortho/hvh ratio={#1},
94 /tikz/ext/ortho/vhv ratio={#1}},
95 ortho/ratio/.style={% there's no udlr ratio so we make ratio an alias to hvvh ratio
96 /tikz/ext/ortho/hvh ratio={#1},
97 /tikz/ext/ortho/vhv ratio={#1}},
98 % with it's always a distance (or a unit in the xy cs)
99 ortho/ud distance/.initial=+.5cm,
100 ortho/du distance/.initial=+.5cm,
101 ortho/lr distance/.initial=+.5cm,
102 ortho/rl distance/.initial=+.5cm,
103 ortho/udlr distance/.style={
104 /tikz/ext/ortho/ud distance={#1},
105 /tikz/ext/ortho/du distance={#1},
106 /tikz/ext/ortho/lr distance={#1},
107 /tikz/ext/ortho/rl distance={#1}},
108 ortho/distance/.style={
109 /tikz/ext/ortho/hvh distance={#1},
110 /tikz/ext/ortho/vhv distance={#1},
111 /tikz/ext/ortho/ud distance={#1},
112 /tikz/ext/ortho/du distance={#1},
113 /tikz/ext/ortho/lr distance={#1},
114 /tikz/ext/ortho/rl distance={#1}},
115 ortho/ratio=.5,% default value
116 ortho/spacing=4,% default value
117 }%
118
119 %% collect options and nodes, coordinates and pics onpath
120 \let\tikzext@ortho@options\pgfutil@empty
121 \def\tikzext@ortho@opts#1[#2]{\def\tikzext@ortho@options{#2}#1}
122 \def\tikzext@ortho@hvh@next{%
123 \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikzext@ortho@hvh@next}
124 {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikzext@ortho@hvh@next}%
125 {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikzext@ortho@hvh@next}{\tikz@scan@one@point\tikzext@ortho@hvh@do}}}}%
126 \def\tikzext@ortho@vhv@next{%
127 \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikzext@ortho@vhv@next}
128 {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikzext@ortho@vhv@next}%
129 {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikzext@ortho@vhv@next}{\tikz@scan@one@point\tikzext@ortho@vhv@do}}}}%
130 \def\tikzext@ortho@ud@next{%
131 \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikzext@ortho@ud@next}
132 {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikzext@ortho@ud@next}
133 {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikzext@ortho@ud@next}{\tikz@scan@one@point\tikzext@ortho@ud@do}}}}%
134 \def\tikzext@ortho@du@next{%
135 \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikzext@ortho@du@next}
136 {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikzext@ortho@du@next}
137 {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikzext@ortho@du@next}{\tikz@scan@one@point\tikzext@ortho@du@do}}}}%
138 \def\tikzext@ortho@lr@next{%
139 \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikzext@ortho@lr@next}
140 {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikzext@ortho@lr@next}
141 {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikzext@ortho@lr@next}{\tikz@scan@one@point\tikzext@ortho@lr@do}}}}%
142 \def\tikzext@ortho@rl@next{%
143 \pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikzext@ortho@rl@next}
144 {\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikzext@ortho@rl@next}
145 {\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikzext@ortho@rl@next}{\tikz@scan@one@point\tikzext@ortho@rl@do}}}}%
146
147 \def\tikzext@ortho@do#1#2#3#4{%
148 % #1 = first kink
149 % #2 = second kink
150 % #3 = end
151 % #4 = tikz@shapeborder@name
152 \pgfpathlineto{#1}%
153 \pgfpathlineto{#2}%
154 \pgfpathlineto{#3}%
155 \def\tikzext@ortho@timer@kinkA{#1}%
156 \def\tikzext@ortho@timer@kinkB{#2}%
157 \def\tikz@timer@end{#3}%
158 \let\tikz@timer\tikzext@ortho@timer
159 \def\tikzext@temp{#4}%
160 \ifx\tikzext@temp\pgfutil@empty
161 \let\tikz@moveto@waiting\relax
162 \else
163 \let\tikz@moveto@waiting\tikzext@temp
164 \fi
165 \tikz@scan@next@command}%
166
167 \def\tikzext@ortho@timer{%
168 \pgfutil@tempdima=\tikz@time pt
169 \ifdim\pgfutil@tempdima<\tikzext@ortho@timer@first pt % first quarter
170 \ifnum\tikzext@ortho@timer@parts=1
171 \advance\pgfutil@tempdima1pt
172 \else
173 \pgfutil@tempdima\tikzext@ortho@timer@parts\pgfutil@tempdima
174 \fi
175 \pgftransformlineattime{\pgf@sys@tonumber\pgfutil@tempdima}{\tikz@timer@start}{\tikzext@ortho@timer@kinkA}%
176 \else
177 \ifdim\pgfutil@tempdima>\tikzext@ortho@timer@last pt %last quarter
178 \ifnum\tikzext@ortho@timer@parts=1
179 \advance\pgfutil@tempdima-1pt%
180 \else
181 \pgfutil@tempdima\tikzext@ortho@timer@parts\pgfutil@tempdima
182 \fi
183 \advance\pgfutil@tempdima-\tikzext@ortho@timer@parts pt
184 \advance\pgfutil@tempdima1pt
185 \pgftransformlineattime{\pgf@sys@tonumber\pgfutil@tempdima}{\tikzext@ortho@timer@kinkB}{\tikz@timer@end}%
186 \else % middle bit
187 \pgfutil@tempdima=\tikzext@ortho@timer@factor\pgfutil@tempdima
188 \advance\pgfutil@tempdima-\tikzext@ortho@timer@subtr pt
189 \pgftransformlineattime{\pgf@sys@tonumber\pgfutil@tempdima}{\tikzext@ortho@timer@kinkA}{\tikzext@ortho@timer@kinkB}%
190 \fi
191 \fi
192 }
193
194 \def\tikzext@ortho@savetimer{%
195 \def\noexpand\tikzext@ortho@timer@parts{\tikzext@ortho@timing@parts}%
196 \def\noexpand\tikzext@ortho@timer@first{\tikzext@ortho@timing@first}%
197 \def\noexpand\tikzext@ortho@timer@last{\tikzext@ortho@timing@last}%
198 \def\noexpand\tikzext@ortho@timer@subtr{\tikzext@ortho@timing@subtr}%
199 \def\noexpand\tikzext@ortho@timer@factor{\tikzext@ortho@timing@factor}%
200 }
201 %% -|- operator
202 \def\tikzext@ortho@hvh@do#1{%
203 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
204 \pgf@xb=\tikz@lastx
205 \pgf@xc=\tikz@lastx
206 \pgf@yc=\tikz@lasty
207 \tikz@make@last@position{#1}%
208 \tikz@flush@moveto@toward{\pgfqpoint{\tikz@lastx}{\pgf@yc}}\pgf@xc\pgf@yc
209 \begingroup
210 \def\tikzext@temp{\pgfqkeys{/tikz/ext/ortho}}%
211 \expandafter\tikzext@temp\expandafter{\tikzext@ortho@options}%
212 \edef\tikzext@ortho@ratio{\pgfkeysvalueof{/tikz/ext/ortho/hvh ratio}}%
213 \ifx\tikzext@ortho@ratio\pgfutil@empty
214 \pgfmathparse{\pgfkeysvalueof{/tikz/ext/ortho/hvh distance}}%
215 \ifpgfmathunitsdeclared
216 \pgfutil@tempdima=\pgfmathresult pt
217 \else
218 \pgf@process{\pgfqpointxy{\pgfmathresult}{0}}%
219 \ifdim\pgf@x<0pt
220 \pgf@x=-\pgf@x
221 \fi
222 \ifdim\pgfmathresult pt<0pt
223 \pgf@x=-\pgf@x
224 \fi
225 \pgfutil@tempdima=\pgf@x
226 \fi
227 \else
228 \pgfmathsetmacro\tikzext@ortho@ratio{\tikzext@ortho@ratio}%
229 \fi
230 \iftikz@shapeborder
231 \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\pgfqpoint{\pgf@xb}{\tikz@lasty}}}%
232 \iftikzext@ortho@fromcenter
233 \pgf@xc\pgf@xb
234 \fi
235 \ifx\tikzext@ortho@ratio\pgfutil@empty
236 \ifdim\pgfutil@tempdima<0pt\relax
237 \iftikzext@ortho@fromcenter
238 \pgf@xc\tikz@lastx
239 \else
240 \pgf@xc\pgf@x
241 \fi
242 \fi
243 \ifdim\pgf@xb>\tikz@lastx
244 \pgfutil@tempdima-\pgfutil@tempdima
245 \fi
246 \else
247 \iftikzext@ortho@fromcenter
248 \pgfutil@tempdima\tikz@lastx
249 \else
250 \pgfutil@tempdima\pgf@x
251 \fi
252 \advance\pgfutil@tempdima-\pgf@xc
253 \pgfutil@tempdima\tikzext@ortho@ratio\pgfutil@tempdima
254 \fi
255 \advance\pgf@xc\pgfutil@tempdima
256 \edef\pgf@tempa{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
257 \edef\pgf@tempb{\noexpand\pgfqpoint{\the\pgf@xc}{\the\tikz@lasty}}%
258 \edef\pgf@temp{\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
259 \else
260 \let\tikz@shapeborder@name\pgfutil@empty
261 \iftikzext@ortho@fromcenter
262 \pgf@xc\pgf@xb
263 \fi
264 \ifx\tikzext@ortho@ratio\pgfutil@empty
265 \ifdim\pgfutil@tempdima<0pt\relax
266 \pgf@xc\tikz@lastx
267 \fi
268 \ifdim\pgf@xb>\tikz@lastx
269 \pgfutil@tempdima-\pgfutil@tempdima
270 \fi
271 \else
272 \pgfutil@tempdima\tikz@lastx
273 \advance\pgfutil@tempdima-\pgf@xc
274 \pgfutil@tempdima\tikzext@ortho@ratio\pgfutil@tempdima
275 \fi
276 \advance\pgf@xc\pgfutil@tempdima
277 \edef\pgf@tempa{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
278 \edef\pgf@tempb{\noexpand\pgfqpoint{\the\pgf@xc}{\the\tikz@lasty}}%
279 \edef\pgf@temp{\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
280 \fi%
281 \edef\tikzext@temp{%
282 \endgroup
283 \tikzext@ortho@savetimer
284 \noexpand\tikzext@ortho@do
285 {\expandafter\noexpand\pgf@tempa}%
286 {\expandafter\noexpand\pgf@tempb}%
287 {\expandafter\noexpand\pgf@temp}%
288 {\tikz@shapeborder@name}}%
289 \tikzext@temp
290 }%
291
292 %% |-| operator
293 \def\tikzext@ortho@vhv@do#1{%
294 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
295 \pgf@xc=\tikz@lastx
296 \pgf@yb=\tikz@lasty
297 \pgf@yc=\tikz@lasty
298 \tikz@make@last@position{#1}%
299 \tikz@flush@moveto@toward{\pgfqpoint{\pgf@xc}{\tikz@lasty}}\pgf@xc\pgf@yc
300 \begingroup
301 \def\tikzext@temp{\pgfqkeys{/tikz/ext/ortho}}%
302 \expandafter\tikzext@temp\expandafter{\tikzext@ortho@options}%
303 \edef\tikzext@ortho@ratio{\pgfkeysvalueof{/tikz/ext/ortho/vhv ratio}}%
304 \ifx\tikzext@ortho@ratio\pgfutil@empty
305 \pgfmathparse{\pgfkeysvalueof{/tikz/ext/ortho/vhv distance}}%
306 \ifpgfmathunitsdeclared
307 \pgfutil@tempdima=\pgfmathresult pt
308 \else
309 \typeout{\pgfmathresult\space before}%
310 \pgf@process{\pgfqpointxy{0}{\pgfmathresult}}%
311 \ifdim\pgf@y<0pt
312 \pgf@y=-\pgf@y
313 \fi
314 \ifdim\pgfmathresult pt<0pt
315 \pgf@y=-\pgf@y
316 \fi
317 \typeout{\pgfmathresult\space after, \the\pgf@y}%
318 \pgfutil@tempdima=\pgf@y
319 \fi
320 \else
321 \pgfmathsetmacro\tikzext@ortho@ratio{\tikzext@ortho@ratio}%
322 \fi
323 \iftikz@shapeborder
324 \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\pgfqpoint{\tikz@lastx}{\pgf@yb}}}%
325 \iftikzext@ortho@fromcenter
326 \pgf@yc\pgf@yb
327 \fi
328 \ifx\tikzext@ortho@ratio\pgfutil@empty
329 \ifdim\pgfutil@tempdima<0pt\relax
330 \iftikzext@ortho@fromcenter
331 \pgf@yc\tikz@lasty
332 \else
333 \pgf@yc\pgf@y
334 \fi
335 \fi
336 \ifdim\pgf@yb>\tikz@lasty
337 \pgfutil@tempdima-\pgfutil@tempdima
338 \fi
339 \else
340 \iftikzext@ortho@fromcenter
341 \pgfutil@tempdima\tikz@lasty
342 \else
343 \pgfutil@tempdima\pgf@y
344 \fi
345 \advance\pgfutil@tempdima-\pgf@yc
346 \pgfutil@tempdima\tikzext@ortho@ratio\pgfutil@tempdima
347 \fi
348 \advance\pgf@yc\pgfutil@tempdima
349 \edef\pgf@tempa{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
350 \edef\pgf@tempb{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\pgf@yc}}%
351 \edef\pgf@temp{\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
352 \else
353 \let\tikz@shapeborder@name\pgfutil@empty
354 \iftikzext@ortho@fromcenter
355 \pgf@yc\pgf@yb
356 \fi
357 \ifx\tikzext@ortho@ratio\pgfutil@empty
358 \ifdim\pgfutil@tempdima<0pt\relax
359 \pgf@yc\tikz@lasty
360 \fi
361 \ifdim\pgf@yb>\tikz@lasty
362 \pgfutil@tempdima-\pgfutil@tempdima
363 \fi
364 \else
365 \pgfutil@tempdima\tikz@lasty
366 \advance\pgfutil@tempdima-\pgf@yc
367 \pgfutil@tempdima\tikzext@ortho@ratio\pgfutil@tempdima
368 \fi
369 \advance\pgf@yc\pgfutil@tempdima
370 \edef\pgf@tempa{\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
371 \edef\pgf@tempb{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\pgf@yc}}%
372 \edef\pgf@temp{\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
373 \fi%
374 \edef\tikzext@temp{%
375 \endgroup
376 \tikzext@ortho@savetimer
377 \noexpand\tikzext@ortho@do
378 {\expandafter\noexpand\pgf@tempa}%
379 {\expandafter\noexpand\pgf@tempb}%
380 {\expandafter\noexpand\pgf@temp}%
381 {\tikz@shapeborder@name}}%
382 \tikzext@temp
383 }
384
385 %% r-ud operator
386 \def\tikzext@ortho@ud@do#1{\tikzext@ortho@uddu@do{#1}{}{ud}{<}}
387
388 %% r-du operator
389 \def\tikzext@ortho@du@do#1{\tikzext@ortho@uddu@do{#1}{-}{du}{>}}
390
391 %% r-lr operator
392 \def\tikzext@ortho@lr@do#1{\tikzext@ortho@lrrl@do{#1}{-}{lr}{>}}
393
394 %% r-rl operator
395 \def\tikzext@ortho@rl@do#1{\tikzext@ortho@lrrl@do{#1}{}{rl}{<}}
396
397 % ud/du
398 \def\tikzext@ortho@uddu@do#1#2#3#4{%
399 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
400 \pgf@xc\tikz@lastx
401 \pgf@yb\tikz@lasty
402 \advance\tikz@lasty#21pt%
403 \let\pgf@temp\tikz@moveto@waiting
404 \tikz@flush@moveto@toward{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}\pgf@xc\pgf@yc
405 \tikz@make@last@position{#1}%
406 \begingroup
407 \def\tikzext@temp{\pgfqkeys{/tikz/ext/ortho}}%
408 \expandafter\tikzext@temp\expandafter{\tikzext@ortho@options}%
409 \pgfmathparse{\pgfkeysvalueof{/tikz/ext/ortho/#3 distance}}%
410 \ifpgfmathunitsdeclared
411 \pgfutil@tempdima=\pgfmathresult pt
412 \else
413 \pgf@process{\pgfqpointxy{0}{\pgfmathresult}}%
414 \pgfutil@tempdima=\pgf@y
415 \ifdim\pgfutil@tempdima<0pt
416 \pgfutil@tempdima=-\pgfutil@tempdima
417 \fi
418 \fi
419 \iftikz@shapeborder
420 \advance\pgf@y#21pt%
421 \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\pgfqpoint{\pgf@x}{\pgf@y}}}%
422 \iftikzext@ortho@fromcenter
423 \pgf@yc\pgf@yb
424 \else\ifx\pgf@temp\relax
425 \pgf@yc\pgf@yb
426 \fi
427 \fi
428 \ifdim\pgf@yc#4\pgf@y
429 \iftikzext@ortho@fromcenter
430 \pgf@yc=\tikz@lasty
431 \else
432 \pgf@yc=\pgf@y
433 \fi
434 \fi
435 \advance\pgf@yc#2\pgfutil@tempdima
436 \edef\pgf@temp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
437 \else
438 \let\tikz@shapeborder@name\pgfutil@empty
439 \ifx\pgf@temp\relax\else
440 \iftikzext@ortho@fromcenter\else
441 \pgf@yb\pgf@yc
442 \fi
443 \fi
444 \ifdim\pgf@yb#4\tikz@lasty\pgf@yb\tikz@lasty\fi
445 \advance\pgf@yb#2\pgfutil@tempdima
446 \pgf@yc\pgf@yb
447 \edef\pgf@temp{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
448 \fi
449 \edef\tikzext@temp{%
450 \endgroup
451 \tikzext@ortho@savetimer
452 \noexpand\tikzext@ortho@do
453 {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
454 {\noexpand\pgfqpoint{\the\tikz@lastx}{\the\pgf@yc}}%
455 {\expandafter\noexpand\pgf@temp}%
456 {\tikz@shapeborder@name}}%
457 \tikzext@temp
458 }
459
460 %% lr/rl
461 \def\tikzext@ortho@lrrl@do#1#2#3#4{%
462 \edef\tikz@timer@start{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
463 \pgf@xb\tikz@lastx
464 \pgf@yc\tikz@lasty
465 \advance\tikz@lastx#21pt%
466 \let\pgf@temp\tikz@moveto@waiting
467 \tikz@flush@moveto@toward{\pgfqpoint{\tikz@lastx}{\tikz@lasty}}\pgf@xc\pgf@yc
468 \tikz@make@last@position{#1}%
469 \begingroup
470 \def\tikzext@temp{\pgfqkeys{/tikz/ext/ortho}}%
471 \expandafter\tikzext@temp\expandafter{\tikzext@ortho@options}%
472 \pgfmathparse{\pgfkeysvalueof{/tikz/ext/ortho/#3 distance}}%
473 \ifpgfmathunitsdeclared
474 \pgfutil@tempdima=\pgfmathresult pt
475 \else
476 \pgf@process{\pgfqpointxy{\pgfmathresult}{0}}%
477 \pgfutil@tempdima=\pgf@x
478 \ifdim\pgfutil@tempdima<0pt
479 \pgfutil@tempdima=-\pgfutil@tempdima
480 \fi
481 \fi
482 \iftikz@shapeborder
483 \advance\pgf@x#21pt%
484 \pgf@process{\pgfpointshapeborder{\tikz@shapeborder@name}{\pgfqpoint{\pgf@x}{\pgf@y}}}%
485 \iftikzext@ortho@fromcenter
486 \pgf@xc\pgf@xb
487 \else\ifx\pgf@temp\relax
488 \pgf@xc\pgf@xb
489 \fi
490 \fi
491 \ifdim\pgf@xc#4\pgf@x
492 \iftikzext@ortho@fromcenter
493 \pgf@xc=\tikz@lastx
494 \else
495 \pgf@xc=\pgf@x
496 \fi
497 \fi
498 \advance\pgf@xc#2\pgfutil@tempdima
499 \edef\pgf@temp{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
500 \else
501 \let\tikz@shapeborder@name\pgfutil@empty
502 \ifx\pgf@temp\relax\else
503 \iftikzext@ortho@fromcenter\else
504 \pgf@xb\pgf@xc
505 \fi
506 \fi
507 \ifdim\pgf@xb#4\tikz@lastx\pgf@xb\tikz@lastx\fi
508 \advance\pgf@xb#2\pgfutil@tempdima
509 \pgf@xc\pgf@xb
510 \edef\pgf@temp{\noexpand\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
511 \fi
512 \edef\tikzext@temp{%
513 \endgroup
514 \tikzext@ortho@savetimer
515 \noexpand\tikzext@ortho@do
516 {\noexpand\pgfqpoint{\the\pgf@xc}{\the\pgf@yc}}%
517 {\noexpand\pgfqpoint{\the\pgf@xc}{\the\tikz@lasty}}%
518 {\expandafter\noexpand\pgf@temp}%
519 {\tikz@shapeborder@name}}%
520 \tikzext@temp
521 }
522
523 %% a few nice to haves, use with to or edge operator
524 \tikzextset{
525 node as new start/.is if=tikzext@ortho@preflush,
526 node as new start,
527 ortho/install shortcuts/.style={
528 *|/.style={/tikz/ext/only vertical second={##1}}, *|/.default=,
529 |*/.style={/tikz/ext/only vertical first={##1}}, |*/.default=,
530 *-/.style={/tikz/ext/only horizontal second={##1}}, *-/.default=,
531 -*/.style={/tikz/ext/only horizontal first={##1}}, -*/.default=,
532 |-/.style={/tikz/to path={|-(\tikztotarget)\tikztonodes}},
533 -|/.style={/tikz/to path={-|(\tikztotarget)\tikztonodes}},
534 -|-/.style={/tikz/ext/horizontal vertical horizontal={##1}}, -|-/.default=,
535 |-|/.style={/tikz/ext/vertical horizontal vertical={##1}}, |-|/.default=,
536 r-du/.style={/tikz/ext/down horizontal up={##1}}, r-du/.default=,
537 r-ud/.style={/tikz/ext/up horizontal down={##1}}, r-ud/.default=,
538 r-rl/.style={/tikz/ext/right vertical left={##1}}, r-rl/.default=,
539 r-lr/.style={/tikz/ext/left vertical right={##1}}, r-lr/.default=%
540 },
541 horizontal vertical/.style={/tikz/to path={-|(\tikztotarget)\tikztonodes}},
542 vertical horizontal/.style={/tikz/to path={|-(\tikztotarget)\tikztonodes}},
543 horizontal vertical horizontal/.default=,
544 horizontal vertical horizontal/.style={/tikz/to path={-|-[{#1}](\tikztotarget)\tikztonodes}},
545 vertical horizontal vertical/.default=,
546 vertical horizontal vertical/.style={/tikz/to path={|-|[{#1}](\tikztotarget)\tikztonodes}},
547 right vertical left/.default=,
548 right vertical left/.style={/tikz/to path={r-rl[{#1}](\tikztotarget)\tikztonodes]}},
549 left vertical right/.default=,
550 left vertical right/.style={/tikz/to path={r-lr[{#1}](\tikztotarget)\tikztonodes]}},
551 up horizontal down/.default=,
552 up horizontal down/.style={/tikz/to path={r-ud[{#1}](\tikztotarget)\tikztonodes]}},
553 down horizontal up/.default=,
554 down horizontal up/.style={/tikz/to path={r-du[{#1}](\tikztotarget)\tikztonodes]}},
555 only vertical second/.style={/tikz/to path={
556 \pgfextra
557 \let\tikzext@ortho@anchor\pgfutil@empty
558 \let\tikzext@origtotarget\pgfutil@empty
559 \tikz@scan@one@point\pgfutil@firstofone(\tikztostart)\relax
560 \iftikz@shapeborder
561 \tikz@scan@one@point\pgfutil@firstofone(\tikztotarget)\relax
562 \ifdim\pgf@y>\tikz@lasty\relax
563 \edef\tikztostart{\tikztostart.north}%
564 \iftikz@shapeborder\def\tikzext@ortho@anchor{.south}\fi
565 \else
566 \edef\tikztostart{\tikztostart.south}%
567 \iftikz@shapeborder\def\tikzext@ortho@anchor{.north}\fi
568 \fi
569 \fi
570 \def\tikz@tempa{#1}%
571 \ifx\tikz@tempa\pgfutil@empty\else
572 \let\tikzext@origtotarget\tikztotarget
573 \edef\tikztotarget{[xshift={#1}]\tikztotarget\tikzext@ortho@anchor}%
574 \fi
575 \endpgfextra
576 \pgfkeys@expanded{%
577 (perpendicular cs: horizontal line through={(\tikztostart)},
578 vertical line through={(\tikztotarget)}) -- (\tikztotarget)}\tikztonodes
579 \pgfextra
580 \ifx\tikzext@origtotarget\pgfutil@empty\else
581 \iftikzext@ortho@preflush(\tikzext@origtotarget)\fi\fi\endpgfextra}},
582 only vertical second/.default=,
583 only horizontal second/.style={/tikz/to path={
584 \pgfextra
585 \let\tikzext@ortho@anchor\pgfutil@empty
586 \let\tikzext@origtotarget\pgfutil@empty
587 \tikz@scan@one@point\pgfutil@firstofone(\tikztostart)\relax
588 \iftikz@shapeborder
589 \tikz@scan@one@point\pgfutil@firstofone(\tikztotarget)\relax
590 \ifdim\pgf@x>\tikz@lastx\relax
591 \edef\tikztostart{\tikztostart.east}%
592 \iftikz@shapeborder\def\tikzext@ortho@anchor{.west}\fi
593 \else
594 \edef\tikztostart{\tikztostart.west}%
595 \iftikz@shapeborder\def\tikzext@ortho@anchor{.east}\fi
596 \fi
597 \fi
598 \def\tikz@tempa{#1}%
599 \ifx\tikz@tempa\pgfutil@empty\else
600 \let\tikzext@origtotarget\tikztotarget
601 \edef\tikztotarget{[yshift={#1}]\tikztotarget\tikzext@ortho@anchor}%
602 \fi
603 \endpgfextra
604 \pgfkeys@expanded{%
605 (perpendicular cs: vertical line through={(\tikztostart)},
606 horizontal line through={(\tikztotarget)}) -- (\tikztotarget)}\tikztonodes
607 \pgfextra
608 \ifx\tikzext@origtotarget\pgfutil@empty\else
609 \iftikzext@ortho@preflush(\tikzext@origtotarget)\fi\fi\endpgfextra}},
610 only horizontal second/.default=,
611 only vertical first/.style={/tikz/to path={
612 \pgfextra
613 \let\tikzext@ortho@anchor\pgfutil@empty
614 \let\tikzext@origtotarget\pgfutil@empty
615 \tikz@scan@one@point\pgfutil@firstofone(\tikztotarget)\relax
616 \pgf@ya=\pgf@y
617 \iftikz@shapeborder
618 \let\tikzext@origtotarget\tikztotarget
619 \tikz@scan@one@point\pgfutil@firstofone(\tikztostart)\relax
620 \ifdim\pgf@ya>\tikz@lasty\relax
621 \edef\tikztotarget{\tikztotarget.south}%
622 \iftikz@shapeborder\def\tikzext@ortho@anchor{.north}\fi
623 \else
624 \edef\tikztotarget{\tikztotarget.north}%
625 \iftikz@shapeborder\def\tikzext@ortho@anchor{.south}\fi
626 \fi
627 \fi
628 \def\tikz@tempa{#1}%
629 \ifx\tikz@tempa\pgfutil@empty\else
630 \edef\tikztostart{[xshift={#1}]\tikztostart\tikzext@ortho@anchor}%
631 \fi
632 \endpgfextra
633 \expandafter(\tikztostart)
634 -- (perpendicular cs: vertical line through/.expanded={(\tikztostart)},
635 horizontal line through={(\tikztotarget)})
636 \tikztonodes
637 \pgfextra
638 \ifx\tikzext@origtotarget\pgfutil@empty\else
639 \iftikzext@ortho@preflush(\tikzext@origtotarget)\fi\fi\endpgfextra}},
640 only vertical first/.default=,
641 only horizontal first/.style={/tikz/to path={
642 \pgfextra
643 \let\tikzext@ortho@anchor\pgfutil@empty
644 \let\tikzext@origtotarget\pgfutil@empty
645 \tikz@scan@one@point\pgfutil@firstofone(\tikztotarget)\relax
646 \pgf@xa=\pgf@x
647 \iftikz@shapeborder
648 \let\tikzext@origtotarget\tikztotarget
649 \tikz@scan@one@point\pgfutil@firstofone(\tikztostart)\relax
650 \ifdim\pgf@xa>\tikz@lastx\relax
651 \edef\tikztotarget{\tikztotarget.west}%
652 \iftikz@shapeborder\def\tikzext@ortho@anchor{.east}\fi
653 \else
654 \edef\tikztotarget{\tikztotarget.east}%
655 \iftikz@shapeborder\def\tikzext@ortho@anchor{.west}\fi
656 \fi
657 \fi
658 \def\tikz@tempa{#1}%
659 \ifx\tikz@tempa\pgfutil@empty\else
660 \edef\tikztostart{[yshift={#1}]\tikztostart\tikzext@ortho@anchor}%
661 \fi
662 \endpgfextra
663 \expandafter(\tikztostart)
664 -- (perpendicular cs: horizontal line through/.expanded={(\tikztostart)},
665 vertical line through={(\tikztotarget)})
666 \tikztonodes \pgfextra
667 \ifx\tikzext@origtotarget\pgfutil@empty\else
668 \iftikzext@ortho@preflush(\tikzext@origtotarget)\fi\fi\endpgfextra}},
669 only horizontal first/.default=,
670 only vertical first to center/.style={/tikz/to path={
671 \pgfextra
672 \let\tikzext@origtotarget\tikztotarget
673 \endpgfextra
674 (\tikztostart) -- (perpendicular cs: vertical line through={(\tikztostart)},
675 horizontal line through={(\tikztotarget)})
676 \tikztonodes \ifx\tikzext@origtotarget\pgfutil@empty\else\iftikzext@ortho@preflush(\tikzext@origtotarget)\fi\fi}},
677 only horizontal first to center/.style={/tikz/to path={
678 \pgfextra
679 \let\tikzext@origtotarget\tikztotarget
680 \endpgfextra
681 (\tikztostart) -- (perpendicular cs: horizontal line through={(\tikztostart)},
682 vertical line through={(\tikztotarget)})
683 \tikztonodes \ifx\tikzext@origtotarget\pgfutil@empty\else\iftikzext@ortho@preflush(\tikzext@origtotarget)\fi\fi}}%
684 }
685
686 %%% Compatibility
687 \tikzextset{
688 /tikz-ext/compat/add library={paths.ortho}{pre 0.6},
689 compat/paths.ortho/warn/.append code={%
690 \pgfutil@for\tikzext@temp:=ortho/ratio,ortho/distance,ortho/from center,ortho/spacing,ortho/middle 0 to 1,%
691 ortho/ud distance,ortho/du distance,ortho/lr distance,ortho/rl distance,ortho/udlr distance,%
692 horizontal vertical,vertical horizontal,horizontal vertical horizontal,%
693 vertical horizontal vertical,up horizontal down,down horizontal up,%
694 left vertical right,right vertical left,only vertical second,%
695 only horizontal second,only vertical first,only horizontal first,%
696 ortho/install shortcuts\do{%
697 \pgfkeys@expanded{\noexpand\tikzextutil@compatwarning@key
698 {paths.ortho}{pre 0.6}{/tikz/\tikzext@temp}{/tikz/ext/\tikzext@temp}%
699 }%
700 }%
701 },
702 compat/paths.ortho/pre 0.6/.append code={%
703 \pgfutil@for\tikzext@temp:=ortho/ratio,ortho/distance,ortho/from center,ortho/spacing,ortho/middle 0 to 1,%
704 ortho/ud distance,ortho/du distance,ortho/lr distance,ortho/rl distance,ortho/udlr distance,%
705 horizontal vertical,vertical horizontal,horizontal vertical horizontal,%
706 vertical horizontal vertical,up horizontal down,down horizontal up,%
707 left vertical right,right vertical left,only vertical second,%
708 only horizontal second,only vertical first,only horizontal first,%
709 ortho/install shortcuts\do{%
710 \pgfkeysedef{/tikz/\tikzext@temp}{%
711 \noexpand\pgfkeysvalueof{/tikz/ext/\tikzext@temp/.@cmd}##1\noexpand\pgfeov
712 }%
713 }%
714 },
715 compat/paths.ortho/\pgfkeysvalueof{/tikz/ext/compat/paths.ortho}%
716 }
717 \endinput