Debian Codegraph @

texmf-dist/tex/latex/tikzquads/tikzquads.sty

raw
1 %%%==============================================================================
2 %% Copyright 2024-present by Alceu Frigeri
3 %%
4 %% This work may be distributed and/or modified under the conditions of
5 %%
6 %% * The [LaTeX Project Public License](http://www.latex-project.org/lppl.txt),
7 %% version 1.3c (or later), and/or
8 %% * The [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.html),
9 %% version 3 (or later)
10 %%
11 %% This work has the LPPL maintenance status *maintained*.
12 %%
13 %% The Current Maintainer of this work is Alceu Frigeri
14 %%
15 %% This is version {1.2a} {2025/11/10}
16 %%
17 %% The list of files that compose this work can be found in the README.md file at
18 %% https://ctan.org/pkg/tikzquads
19 %%
20 %%%==============================================================================
21 %% WARNING: These are personal packs/tests
22 %% They might and probably will change at will as needed
23 %%
24 %%%==============================================================================
25 \NeedsTeXFormat{LaTeX2e}[2022/06/01]
26
27
28 \ProvidesExplPackage
29 {tikzquads}
30 {2025/11/10}
31 {1.2a}
32 {CircuiTikZ Extension - Quadripoles and Dipoles}
33
34 \ExplSyntaxOn
35 %%%%%%%
36 %%%
37 %%% Just an attempt of having my packages info in a regular way
38 %%% \Pkginfograb_set:nn {<pkg-name>} { props} for each and all.
39 %%%
40 %%%%%%%
41 \RequirePackage{pkginfograb}
42 \pkginfograb_set:nn { tikzquads }
43 {
44 name = {tikzquads} ,
45 prefix = {tikzquads} ,
46 date = {2025/11/10},
47 version = {1.2a} ,
48 description = {CircuiTikZ~ Extension~- Quadripoles~ and~ Dipoles}
49 }
50 %%%%%%%
51 %%% End of cut-n-paste
52 %%%%%%%
53
54 \RequirePackage{pgfkeysearch}
55 \RequirePackage{tikzdotncross}
56
57 \keys_define:nn {tikzquads / quadconn }
58 {
59 left .usage:n = general ,
60 left .bool_set:N = \l__tikzquads_left_bool ,
61 left .value_forbidden:n = true ,
62
63 right .usage:n = general ,
64 right .bool_set_inverse:N = \l__tikzquads_left_bool ,
65 left .value_forbidden:n = true ,
66
67 up .usage:n = general ,
68 up .bool_set:N = \l__tikzquads_up_bool ,
69 up .value_forbidden:n = true ,
70
71 down .usage:n = general ,
72 down .bool_set_inverse:N = \l__tikzquads_up_bool ,
73 down .value_forbidden:n = true ,
74
75 dots .usage:n = general ,
76 dots .bool_set:N = \l__tikzquads_dots_bool ,
77 dots .value_forbidden:n = true ,
78
79 spacing .usage:n = general ,
80 spacing .tl_set:N = \l__tikzquads_spacing_tl ,
81 spacing .default:n = 0pt ,
82
83 swapped~ sides .usage:n = general ,
84 swapped~ sides .bool_set:N = \l__tikzquads_swap_bool ,
85 swapped~ sides .value_forbidden:n = true ,
86
87 default~ sides .usage:n = general ,
88 default~ sides .bool_set_inverse:N = \l__tikzquads_swap_bool ,
89 default~ sides .value_forbidden:n = true ,
90
91 defaults .usage:n = general ,
92 defaults .meta:n =
93 {
94 left , up , spacing , default~ sides ,
95 } ,
96 defaults .value_forbidden:n = true ,
97
98 }
99
100
101 \cs_new_protected:Npn \__tikzquads_down:nnnnnnn #1#2#3#4#5#6#7
102 {
103 }
104
105 \tl_new:N \l__tikzquads_tmpa_tl
106 \tl_new:N \l__tikzquads_tmpb_tl
107 \tl_new:N \l__tikzquads_base_spc_tl
108 \tl_new:N \l__tikzquads_coord_tl
109
110 \NewDocumentCommand{\QuadParConnect}{O{left,up}mm}
111 {
112 \keys_set:nn {tikzquads / quadconn}
113 {defaults,#1}
114 \SearchValueOf{QuadKeys}
115 {outer~ ext}{\l__tikzquads_base_spc_tl}
116
117 \bool_if:NTF \l__tikzquads_dots_bool
118 { \tl_set:Nn \l__tikzquads_coord_tl {\dotcoord} }
119 { \tl_set:Nn \l__tikzquads_coord_tl {\ncoord} }
120
121 \bool_if:NTF \l__tikzquads_swap_bool
122 {
123 \tl_set:Nn \l__tiqzquads_tmpa_tl {2}
124 \tl_set:Nn \l__tiqzquads_tmpb_tl {1}
125 }
126 {
127 \tl_set:Nn \l__tiqzquads_tmpa_tl {1}
128 \tl_set:Nn \l__tiqzquads_tmpb_tl {2}
129 }
130
131
132 \bool_if:NTF \l__tikzquads_left_bool
133 {
134 \bool_if:NTF \l__tikzquads_up_bool
135 {
136 \draw[name~ path=PathA]
137 (#2. \l__tiqzquads_tmpa_tl +) -- ++(-\l__tikzquads_base_spc_tl/2 - \l__tikzquads_spacing_tl/2,0) |- (#3. \l__tiqzquads_tmpa_tl +)
138 (#2. \l__tiqzquads_tmpa_tl -) ++(-\l__tikzquads_base_spc_tl - \l__tikzquads_spacing_tl,0) \l__tikzquads_coord_tl(c#2~ \l__tiqzquads_tmpa_tl -) |- (#3. \l__tiqzquads_tmpa_tl -);
139 \pathcross{c#2~ \l__tiqzquads_tmpa_tl -}{#2. \l__tiqzquads_tmpa_tl -}{PathA}[\l__tikzquads_base_spc_tl/4]
140 \draw (#2. \l__tiqzquads_tmpa_tl +) -- ++(-\l__tikzquads_base_spc_tl - \l__tikzquads_spacing_tl,0) \l__tikzquads_coord_tl(c#2~ \l__tiqzquads_tmpa_tl +);
141 }
142 {
143 \draw[name~ path=PathA]
144 (#3. \l__tiqzquads_tmpa_tl -) -- ++(-\l__tikzquads_base_spc_tl/2 - \l__tikzquads_spacing_tl/2,0) |- (#2. \l__tiqzquads_tmpa_tl -)
145 (#3. \l__tiqzquads_tmpa_tl +) ++(-\l__tikzquads_base_spc_tl - \l__tikzquads_spacing_tl,0) \l__tikzquads_coord_tl(c#3~ \l__tiqzquads_tmpa_tl +) |- (#2. \l__tiqzquads_tmpa_tl +);
146 \pathcross{c#3~ \l__tiqzquads_tmpa_tl +}{#3. \l__tiqzquads_tmpa_tl +}{PathA}[\l__tikzquads_base_spc_tl/4]
147 \draw (#3. \l__tiqzquads_tmpa_tl -) -- ++(-\l__tikzquads_base_spc_tl - \l__tikzquads_spacing_tl,0) \l__tikzquads_coord_tl(c#3~ \l__tiqzquads_tmpa_tl -);
148 }
149 }
150 {
151 \bool_if:NTF \l__tikzquads_up_bool
152 {
153 \draw[name~ path=PathA]
154 (#2. \l__tiqzquads_tmpb_tl +) -- ++(\l__tikzquads_base_spc_tl/2 + \l__tikzquads_spacing_tl/2,0) |- (#3. \l__tiqzquads_tmpb_tl +)
155 (#2. \l__tiqzquads_tmpb_tl -) ++(\l__tikzquads_base_spc_tl + \l__tikzquads_spacing_tl,0) \l__tikzquads_coord_tl(c#2~ \l__tiqzquads_tmpb_tl -) |- (#3. \l__tiqzquads_tmpb_tl -);
156 \pathcross*{c#2~ \l__tiqzquads_tmpb_tl -}{#2. \l__tiqzquads_tmpb_tl -}{PathA}[\l__tikzquads_base_spc_tl/4]
157 \draw (#2. \l__tiqzquads_tmpb_tl +) -- ++(\l__tikzquads_base_spc_tl + \l__tikzquads_spacing_tl,0) \l__tikzquads_coord_tl(c#2~ \l__tiqzquads_tmpb_tl +);
158 }
159 {
160 \draw[name~ path=PathA]
161 (#3. \l__tiqzquads_tmpb_tl -) -- ++(\l__tikzquads_base_spc_tl/2 + \l__tikzquads_spacing_tl/2,0) |- (#2. \l__tiqzquads_tmpb_tl -)
162 (#3. \l__tiqzquads_tmpb_tl +) ++(\l__tikzquads_base_spc_tl + \l__tikzquads_spacing_tl,0) \l__tikzquads_coord_tl(c#3~ \l__tiqzquads_tmpb_tl +) |- (#2. \l__tiqzquads_tmpb_tl +);
163 \pathcross*{c#3~ \l__tiqzquads_tmpb_tl +}{#3. \l__tiqzquads_tmpb_tl +}{PathA}[\l__tikzquads_base_spc_tl/4]
164 \draw (#3. \l__tiqzquads_tmpb_tl -) -- ++(\l__tikzquads_base_spc_tl + \l__tikzquads_spacing_tl,0) \l__tikzquads_coord_tl(c#3~ \l__tiqzquads_tmpb_tl -);
165 }
166 }
167
168 }
169
170 %
171 % ... it expects #1#2#3...
172 %
173 \prg_generate_conditional_variant:Nnn \pgfkeysearch_keysearch:nnN {v} {TF}
174 \cs_generate_variant:Nn \pgfkeysearch_keysearch:nnN {v}
175 \cs_new:Npn \SearchValueOf #1#2
176 { \pgfkeysearch_keysearch:vnN {tikzquads@@#1Path}{#2} }
177
178 \ExplSyntaxOff
179
180
181 \makeatletter
182
183 %%%
184 %%% This only makes sense 'for this package'
185 %%%
186 %%\NewDocumentCommand{\SearchValueOf}{mmm}{%
187 %% \pgfkeysearchvalueof{\csuse{tikzquads@@#1Path}}{#2}{#3}
188 %% }
189
190 %
191 %%%%%%%%%%%%%%%
192 %%%
193 %%% In case \SearchValueOf 'fails' one could use this (no expl3 code)
194 %%%
195 %%%%%%%%%%%%%%%
196 \newcommand{\tikzquads@@ValueOf}[2]
197 {\pgfkeysvalueof{\csuse{tikzquads@@#1Path}/#2}}
198
199 %\NewDocumentCommand{\tikzquads@@ValueOf}{mm}{\pgfkeysvalueof{\csuse{tikzquads@@#1Path}/#2}}
200
201 \newtoggle{tikzquads@@toggle@inverted}
202 \newtoggle{tikzquads@@toggle@generic}
203 \newtoggle{tikzquads@@toggle@alternate}
204 \newtoggle{tikzquads@@toggle@innermarks}
205 \newtoggle{tikzquads@@toggle@outermarks}
206 \newtoggle{tikzquads@@toggle@beziertip}
207 \newtoggle{tikzquads@@toggle@roundsources}
208 \newtoggle{tikzquads@@toggle@rawsources}
209 %
210
211 %
212 %%%%%%%%%%%%%%%
213 %%%
214 %%% general/base "Keys" Path
215 %%%
216 %%%%%%%%%%%%%%%
217 %
218 \def\tikzquads@@KeysPath{/tikz/tikzquads}
219 \pgfkeys{\tikzquads@@KeysPath/.is family}
220
221 \pgfkeys{\tikzquads@@KeysPath,
222 .search also={/tikz},
223 tip len/.initial=4pt,
224 tip type/.is choice,
225 tip type/bezier/.code={\toggletrue{tikzquads@@toggle@beziertip}},
226 tip type/triangle/.code={\togglefalse{tikzquads@@toggle@beziertip}},
227 source radius/.initial=0.3\pgf@circ@Rlen,%
228 @round sources/.code={\toggletrue{tikzquads@@toggle@roundsources}},
229 round sources/.style={@round sources},
230 @control sources/.code={\togglefalse{tikzquads@@toggle@roundsources}},
231 control sources/.style={@control sources},
232 thickness/.initial=2,
233 @generic/.code={\toggletrue{tikzquads@@toggle@generic}},
234 generic/.style={@generic},
235 european/.style={@generic},
236 @zigzag/.code={\togglefalse{tikzquads@@toggle@generic}},
237 zigzag/.style={@zigzag},
238 american/.style={@zigzag},
239 name/.initial={}, % this will be, if defined, the node name used in a to[] path
240 minussign len/.initial=1.0\pgf@circ@Rlen/14,%
241 plussign len/.initial=1.1\pgf@circ@Rlen/14,%
242 outer sep/.initial=1.5pt, %% Text separation
243 inner sep/.initial=1pt, %% Text separation
244 }
245
246
247 %%%%%%%%%%%%%%%
248 %%%
249 %%% "PGKeys" Path (for PseudoGraph)
250 %%%
251 %%%%%%%%%%%%%%%
252
253 \def\tikzquads@@PGKeysPath{\tikzquads@@KeysPath/PseudoGraph}
254 \pgfkeys{\tikzquads@@PGKeysPath/.is family}
255 \pgfkeys{/tikz/PGKeys/.style={\tikzquads@@PGKeysPath}}
256
257 \pgfkeys{\tikzquads@@PGKeysPath,
258 .search also={\tikzquads@@KeysPath,/tikz},
259 x axis/.initial={\footnotesize$V$},
260 y axis/.initial={\footnotesize$I$},
261 x val/.initial={\footnotesize$V_{th}$},
262 y val/.initial={\footnotesize$I_{N}$},
263 @PGPoints/.code={%
264 \tikzmath{%
265 %real \x , \y;
266 \y{Xaxispos}=\y{innerbottom};
267 \x{Yaxispos}=\x{innerleft};
268 %
269 \x{coordA}=\x{left};
270 \y{coordA}=\y{Ctop};
271 %
272 \x{coordB}=\x{Cright};
273 \y{coordB}=\y{bottom};
274 %
275 \y{TXaxiscoord}=\y{bottom};
276 \x{TYaxiscoord}=\x{left};
277 %
278 \x{TXvalcoord}=\x{Cright}-0;
279 \y{TXvalcoord}=\y{bottom};
280 %
281 \x{TYvalcoord}=\x{left};
282 \y{TYvalcoord}=\y{Ctop}-0;
283 }
284 \gdef\tikzquads@@PG@XaxisTanchor{top left}
285 \gdef\tikzquads@@PG@XvalTanchor{top right}
286 %
287 \gdef\tikzquads@@PG@YaxisTanchor{bottom right}
288 \gdef\tikzquads@@PG@YvalTanchor{top right}
289 },
290 first quadrant/.style={%
291 @PGPoints/.code={%
292 \tikzmath{%
293 %real \x , \y;
294 \y{Xaxispos}=\y{innerbottom};
295 \x{Yaxispos}=\x{innerleft};
296 %
297 \x{coordA}=\x{left};
298 \y{coordA}=\y{Ctop};
299 %
300 \x{coordB}=\x{Cright};
301 \y{coordB}=\y{bottom};
302 %
303 \y{TXaxiscoord}=\y{bottom};
304 \x{TYaxiscoord}=\x{left};
305 %
306 \x{TXvalcoord}=\x{Cright}-0;
307 \y{TXvalcoord}=\y{bottom};
308 %
309 \x{TYvalcoord}=\x{left};
310 \y{TYvalcoord}=\y{Ctop}-0;
311 }
312 \gdef\tikzquads@@PG@XaxisTanchor{top left}
313 \gdef\tikzquads@@PG@XvalTanchor{top right}
314 %
315 \gdef\tikzquads@@PG@YaxisTanchor{bottom right}
316 \gdef\tikzquads@@PG@YvalTanchor{top right}
317 },
318 },
319 second quadrant/.style={%
320 @PGPoints/.code={%
321 \tikzmath{%
322 %real \x , \y;
323 \y{Xaxispos}=\y{innerbottom};
324 \x{Yaxispos}=\x{innerright};
325 %
326 \x{coordA}=\x{right};
327 \y{coordA}=\y{Ctop};
328 %
329 \x{coordB}=\x{Cleft};
330 \y{coordB}=\y{bottom};
331 %
332 \y{TXaxiscoord}=\y{bottom};
333 \x{TYaxiscoord}=\x{Cright};
334 %
335 \x{TXvalcoord}=\x{Cleft}+2pt;
336 \y{TXvalcoord}=\y{bottom};
337 %
338 \x{TYvalcoord}=\x{right};
339 \y{TYvalcoord}=\y{Ctop}-2pt;
340 }
341 \gdef\tikzquads@@PG@XaxisTanchor{top left}
342 \gdef\tikzquads@@PG@XvalTanchor{top left}
343 %
344 \gdef\tikzquads@@PG@YaxisTanchor{bottom right}
345 \gdef\tikzquads@@PG@YvalTanchor{top left}
346 },
347 },
348 third quadrant/.style={%
349 @PGPoints/.code={%
350 \tikzmath{%
351 %real \x , \y;
352 \y{Xaxispos}=\y{innertop};
353 \x{Yaxispos}=\x{innerright};
354 %
355 \x{coordA}=\x{Cleft};
356 \y{coordA}=\y{top};
357 %
358 \x{coordB}=\x{right};
359 \y{coordB}=\y{Cbottom};
360 %
361 \y{TXaxiscoord}=\y{Ctop};
362 \x{TYaxiscoord}=\x{Cright};
363 %
364 \x{TXvalcoord}=\x{Cleft}+2pt;
365 \y{TXvalcoord}=\y{top};
366 %
367 \x{TYvalcoord}=\x{right};
368 \y{TYvalcoord}=\y{Cbottom}+2pt;
369 }
370 \gdef\tikzquads@@PG@XaxisTanchor{top left}
371 \gdef\tikzquads@@PG@XvalTanchor{bottom left}
372 %
373 \gdef\tikzquads@@PG@YaxisTanchor{bottom right}
374 \gdef\tikzquads@@PG@YvalTanchor{bottom left}
375 },
376 },
377 fourth quadrant/.style={%
378 @PGPoints/.code={%
379 \tikzmath{%
380 %real \x , \y;
381 \y{Xaxispos}=\y{innertop};
382 \x{Yaxispos}=\x{innerleft};
383 %
384 \x{coordA}=\x{left};
385 \y{coordA}=\y{Cbottom};
386 %
387 \x{coordB}=\x{Cright};
388 \y{coordB}=\y{top};
389 %
390 \y{TXaxiscoord}=\y{Ctop};
391 \x{TYaxiscoord}=\x{left};
392 %
393 \x{TXvalcoord}=\x{Cright}-2pt;
394 \y{TXvalcoord}=\y{top};
395 %
396 \x{TYvalcoord}=\x{left};
397 \y{TYvalcoord}=\y{Cbottom}+2pt;
398 }
399 \gdef\tikzquads@@PG@XaxisTanchor{top left}
400 \gdef\tikzquads@@PG@XvalTanchor{bottom right}
401 %
402 \gdef\tikzquads@@PG@YaxisTanchor{bottom right}
403 \gdef\tikzquads@@PG@YvalTanchor{bottom right}
404 },
405 },
406 half base height/.initial=0.5\pgf@circ@Rlen,%
407 base height/.code={%
408 \tikzmath{real \X;
409 \X{tmp} = 0.5*abs(#1);
410 }
411 \pgfkeysalso{\tikzquads@@QuadKeysPath/half base height=\X{tmp}}
412 },
413 half base width/.initial=0.5\pgf@circ@Rlen,%
414 base width/.code={%
415 \tikzmath{real \X;
416 \X{tmp} = 0.5*abs(#1);
417 }
418 \pgfkeysalso{\tikzquads@@QuadKeysPath/half base width=\X{tmp}}
419 },
420 }
421
422
423 %%%%%%%%%%%%%%%
424 %%%
425 %%% "QuadKeys" Path (Quadripoles)
426 %%%
427 %%%%%%%%%%%%%%%
428
429 \def\tikzquads@@QuadKeysPath{\tikzquads@@KeysPath/QuadKeys}
430 \pgfkeys{\tikzquads@@QuadKeysPath/.is family}
431 \pgfkeys{/tikz/QuadKeys/.style={\tikzquads@@QuadKeysPath}}
432
433 \newcommand{\tikzquads@@QuadGetAnchor}[2]
434 {\pgfkeys{\tikzquads@@QuadKeysPath,#1={#2}}}
435
436 %%%%%%%%%%%%%%%%%%%
437 %%%
438 %%% "R" Path (Rotation)
439 %%%
440 %%% re-mapping 'anchors names' in case of a 90 degree (clockwise) rotation
441 %%% assuming the element should always be 90 degree rotated.
442 %%%
443 %%%%%%%%%%%%%%%%%%%
444 \def\tikzquads@@RPath{\tikzquads@@QuadKeysPath/Anchor +90 Rotation}
445 \pgfkeys{\tikzquads@@RPath/.is family}
446 \pgfkeys{\tikzquads@@RPath,
447 south/.code={\csdef{#1}{west}},
448 south east/.code={\csdef{#1}{south west}},
449 east/.code={\csdef{#1}{south}},
450 north east/.code={\csdef{#1}{south east}},
451 north/.code={\csdef{#1}{east}},
452 north west/.code={\csdef{#1}{north east}},
453 west/.code={\csdef{#1}{north}},
454 south west/.code={\csdef{#1}{north west}},
455 }
456
457 \newcommand{\tikzquads@@RotateAnchor}[2]
458 {\pgfkeys{\tikzquads@@RPath,#1={#2}}}
459
460 %\NewDocumentCommand{\tikzquads@@RotateAnchor}{mm}
461 % {\pgfkeys{\tikzquads@@RPath,#1={#2}}}
462
463
464 %%%%%%%%%%%%%%%%%%%
465 %%%
466 %%% "AutoR" Path (Rotation)
467 %%%
468 %%% re-mapping 'anchors names' in case of a 90 degree (clockwise) rotation
469 %%% assuming the element should always be 90 degree rotated.
470 %%%
471 %%%%%%%%%%%%%%%%%%%
472 %%%%%%%%%%%%%%%%%%%%%%
473 %%%%%%
474 %%%%%% re-mapping 'anchors names' in case of an auto 90 degree (clockwise) rotation
475 %%%%%% assuming the rotation was conditional (and original anchors were thought in the original position.)
476 %%%%%%
477 %%%%%%%%%%%%%%%%%%%%%%
478 %%%\def\tikzquads@@AutoRPath{\tikzquads@@QuadKeysPath/Anchor Auto +90 Rotation}
479 %%%\pgfkeys{\tikzquads@@AutoRPath/.is family}
480 %%%\pgfkeys{\tikzquads@@AutoRPath,
481 %%% east/.code={\csdef{#1}{south}},
482 %%% west/.code={\csdef{#1}{north}},
483 %%% south west/.code={\csdef{#1}{south west}},
484 %%% south east/.code={\csdef{#1}{north east}},
485 %%% south/.code={\csdef{#1}{west}},
486 %%% north/.code={\csdef{#1}{east}},
487 %%% north east/.code={\csdef{#1}{north east}},
488 %%% north west/.code={\csdef{#1}{south west}},
489 %%%}
490 %%%\newcommand{\tikzquads@@AutoRotateAnchor}[2]{\pgfkeys{\tikzquads@@AutoRPath,#1={#2}}}
491
492
493 %%%%%%%%%%%%%%%%%%%
494 %%%
495 %%% re-mapping 'anchors names' in case of an 'auto' 90 degree (clockwise) rotation H Res -> V Res
496 %%% assuming the rotation was conditional (and original anchors were thought in the original position.)
497 %%%
498 %%%%%%%%%%%%%%%%%%%
499 \def\tikzquads@@AutoRPath{\tikzquads@@QuadKeysPath/Anchor Auto +90 Rotation}
500 \pgfkeys{\tikzquads@@AutoRPath/.is family}
501 \pgfkeys{\tikzquads@@AutoRPath,
502 east/.code={\csdef{#1}{east}},
503 west/.code={\csdef{#1}{west}},
504 south west/.code={\csdef{#1}{south east}},
505 south east/.code={\csdef{#1}{south west}},
506 south/.code={\csdef{#1}{south}},
507 north/.code={\csdef{#1}{north}},
508 north east/.code={\csdef{#1}{north west}},
509 north west/.code={\csdef{#1}{north east}},
510 }
511 \newcommand{\tikzquads@@AutoRotateAnchor}[2]
512 {\pgfkeys{\tikzquads@@AutoRPath,#1={#2}}}
513
514
515 %
516 %%%%%%%%%%%%%%%%%%%
517 %%%
518 %%% re-mapping 'anchors names' in case of an 'invert' key
519 %%%
520 %%%%%%%%%%%%%%%%%%%
521 \def\tikzquads@@TPath{\tikzquads@@QuadKeysPath/Translation}
522 \pgfkeys{\tikzquads@@TPath/.is family}
523 \pgfkeys{\tikzquads@@TPath,
524 setdefault/.style={#1/.code={\csdef{##1}{#1}}},
525 setdefault/.list={south west,south east,north west,north east,west,east,top left,top right,bottom left,bottom right,left,right},
526 set/.style 2 args={#1/.code={\csdef{##1}{#2}}},
527 .unknown/.code={\csdef{#1}{\pgfkeyscurrentname}},
528 }
529
530 %%%%%%%%%%%%%%%%%%%
531 %%%
532 %%% pgf hackery, well, extention: allowing composit names
533 %%%
534 %%%%%%%%%%%%%%%%%%%
535 \pgfkeys{/pgf/text/.cd,
536 top left/.style={/pgf/text/.cd,top,left},
537 top right/.style={/pgf/text/.cd,top,right},
538 bottom left/.style={/pgf/text/.cd,bottom,left},
539 bottom right/.style={/pgf/text/.cd,bottom,right},
540 }
541
542 %
543 %%%%%%%%%%%%%%%%%%%
544 %%%
545 %%% User Shapes as styles. Note that 'QuadKeys' assure that following keys are in the correct tree.
546 %%%
547 %%%%%%%%%%%%%%%%%%%
548
549 \tikzset{BB/.style={BB shape,QuadKeys,@BB fit set,half base width=\pgf@circ@Rlen}}
550 \tikzset{Black Box/.style={BB shape,QuadKeys,@BB fit set,half base width=\pgf@circ@Rlen}}
551 \tikzset{Norton/.style={NortonBB shape,QuadKeys,@BB fit set,round sources,half base width=\pgf@circ@Rlen}}
552 \tikzset{Thevenin/.style={TheveninBB shape,QuadKeys,@BB fit set,round sources,half base width=\pgf@circ@Rlen}}
553
554 \tikzset{Quad compact/.style={Quad shape,QuadKeys,half base width=\pgf@circ@Rlen}}
555 \tikzset{Quad/.style={Quad shape,QuadKeys}}
556 \tikzset{Quad Z/.style={Quad Z shape,QuadKeys}}
557 \tikzset{Quad Y/.style={Quad Y shape,QuadKeys}}
558 \tikzset{Quad G/.style={Quad G shape,QuadKeys}}
559 \tikzset{Quad H/.style={Quad H shape,QuadKeys}}
560
561 \tikzset{PG load line/.style={PG linear load line shape,PGKeys}}
562 \tikzset{PG linear load line/.style={PG linear load line shape,PGKeys}}
563
564 %%
565 %% These DO work, but be careful: the node gets a name only if <name> key is defined.
566 %%
567 %%%%%%%%%%%%%%%%%%%
568 %%%
569 %%% User shapes/keys which can be used in a to[]
570 %%% These DO work, but be careful: the node gets a name only if <name> key is defined.
571 %%%
572 %%%%%%%%%%%%%%%%%%%
573 \tikzset{ToQuad/.style={to path={node[Quad,outer x fit to={\tikztostart}{\tikztotarget}](\tikzquads@@ValueOf{Keys}{name}){}},QuadKeys}}
574 \tikzset{ToQuad Z/.style={to path={node[Quad Z,outer x fit to={\tikztostart}{\tikztotarget}](\tikzquads@@ValueOf{Keys}{name}){}},QuadKeys}}
575 \tikzset{ToQuad Y/.style={to path={node[Quad Y,outer x fit to={\tikztostart}{\tikztotarget}](\tikzquads@@ValueOf{Keys}{name}){}},QuadKeys}}
576 \tikzset{ToQuad G/.style={to path={node[Quad G,outer x fit to={\tikztostart}{\tikztotarget}](\tikzquads@@ValueOf{Keys}{name}){}},QuadKeys}}
577 \tikzset{ToQuad H/.style={to path={node[Quad H,outer x fit to={\tikztostart}{\tikztotarget}](\tikzquads@@ValueOf{Keys}{name}){}},QuadKeys}}
578 \tikzset{ToNorton/.style={to path={node[Norton,@BB fit set,y fit to={\tikztostart}{\tikztotarget}](\tikzquads@@ValueOf{Keys}{name}){}},QuadKeys}}
579 \tikzset{ToThevenin/.style={to path={node[Thevenin,@BB fit set,y fit to={\tikztostart}{\tikztotarget}](\tikzquads@@ValueOf{Keys}{name}){}},QuadKeys}}
580 \tikzset{ToBlack Box/.style={to path={node[Black Box,@BB fit set,y fit to={\tikztostart}{\tikztotarget}](\tikzquads@@ValueOf{Keys}{name}){}},QuadKeys}}
581
582 %%%%%%%%%%%%%%%%%%%
583 %%%
584 %%% Main keys definition
585 %%%
586 %%%%%%%%%%%%%%%%%%%
587 \pgfkeys{\tikzquads@@QuadKeysPath,
588 %.unknown/.code={\let\searchname=\pgfkeyscurrentname%
589 % \pgfkeysalso{/tikz/\searchname=#1}},
590 .search also={\tikzquads@@KeysPath,/tikz},
591 none/.initial={}, %% this is a 'hack' for Thevenin/Norton ('control variable')
592 half base width/.initial=2\pgf@circ@Rlen,%
593 base width/.code={%
594 \tikzmath{real \X;
595 \X{tmp} = 0.5*abs(#1);
596 }
597 \pgfkeysalso{\tikzquads@@QuadKeysPath/half base width=\X{tmp}}
598 },
599 height ext/.initial=4\pgf@circ@Rlen/14,%
600 height ext+/.style={height ext={4\pgf@circ@Rlen/14 + #1}},%
601 height/.initial=\pgf@circ@Rlen,%
602 half base height/.initial=10\pgf@circ@Rlen/14,%
603 base height/.code={%
604 \tikzmath{real \X;
605 \X{tmp} = 0.5*abs(#1);
606 }
607 \pgfkeysalso{\tikzquads@@QuadKeysPath/half base height=\X{tmp}}
608 },
609 inner ext/.initial=2\pgf@circ@Rlen/14,%
610 outer ext/.initial=5\pgf@circ@Rlen/14,
611 Y11/.initial=$Y_{11}$, Y12/.initial=$Y_{12}$, Y21/.initial=$Y_{21}$, Y22/.initial=$Y_{22}$,
612 Z11/.initial=$Z_{11}$, Z12/.initial=$Z_{12}$, Z21/.initial=$Z_{21}$, Z22/.initial=$Z_{22}$,
613 H11/.initial=$H_{11}$, H12/.initial=$H_{12}$, H21/.initial=$H_{21}$, H22/.initial=$H_{22}$,
614 G11/.initial=$G_{11}$, G12/.initial=$G_{12}$, G21/.initial=$G_{21}$, G22/.initial=$G_{22}$,
615 I1/.initial=$I_1$, I2/.initial=$I_2$, V1/.initial=$V_1$, V2/.initial=$V_2$,
616 In/.initial=$I_N$, Yn/.initial=$Y_N$, Vth/.initial=$V_{th}$, Zth/.initial=$Z_{th}$,
617 label top left/.initial={},
618 label top center/.initial={},
619 label top right/.initial={},
620 label inner top left/.initial={},
621 label inner top center/.initial={},
622 label inner top right/.initial={},
623 label bottom left/.initial={},
624 label bottom center/.initial={},
625 label bottom right/.initial={},
626 label inner bottom left/.initial={},
627 label inner bottom center/.initial={},
628 label inner bottom right/.initial={},
629 @inner marks/.code={\toggletrue{tikzquads@@toggle@innermarks}},
630 inner marks/.style={@inner marks},
631 @outer marks/.code={\toggletrue{tikzquads@@toggle@outermarks}},
632 outer marks/.style={@outer marks},
633 @raw sources/.code={\toggletrue{tikzquads@@toggle@rawsources}},
634 raw sources/.style={@raw sources},
635 @invert/.code={\toggletrue{tikzquads@@toggle@inverted}},
636 invert/.style={%
637 /tikz/xscale=-1,
638 @invert,
639 \tikzquads@@TPath,
640 % set={south west}{south east},
641 % set={south east}{south west},
642 % set={north west}{north east},
643 % set={north east}{north west},
644 % set={west}{east},
645 % set={east}{west},
646 set={bottom left}{bottom right},
647 set={bottom right}{bottom left},
648 set={top left}{top right},
649 set={top right}{top left},
650 set={left}{right},
651 set={right}{left},
652 \tikzquads@@QuadKeysPath,
653 },
654 compact/.style={half base width=\pgf@circ@Rlen},
655 @alternate/.code={\toggletrue{tikzquads@@toggle@alternate}},
656 alt/.style={@alternate},
657 opt/.style={@alternate},
658 inner x fit to/.style 2 args={inner x fit to*={#1}{#2}},
659 inner x fit to*/.code 2 args={%
660 \SearchValueOf{QuadKeys}{inner ext}{\@@innerext}
661 \tikzquads@@fitto{#1}{#2}{\@@innerext}{0}{\Xdiff}{\Xang}
662 \pgfkeysalso{/tikz/rotate=\Xang,\tikzquads@@QuadKeysPath/half base width=\Xdiff}
663 },
664 inner x fit to!/.code 2 args={%
665 \SearchValueOf{QuadKeys}{inner ext}{\@@innerext}
666 \tikzquads@@fitto{#1}{#2}{\@@innerext}{0}{\Xdiff}{\Xang}
667 \pgfkeysalso{\tikzquads@@QuadKeysPath/half base width=\Xdiff}
668 },
669 outer x fit to/.style 2 args={outer x fit to*={#1}{#2}},
670 outer x fit to*/.code 2 args={%
671 \SearchValueOf{QuadKeys}{outer ext}{\@@outerext}
672 \tikzquads@@fitto{#1}{#2}{-\@@outerext}{0}{\Xdiff}{\Xang}
673 \pgfkeysalso{/tikz/rotate=\Xang,\tikzquads@@QuadKeysPath/half base width=\Xdiff}
674 } ,
675 outer x fit to!/.code 2 args={%
676 \SearchValueOf{QuadKeys}{outer ext}{\@@outerext}
677 \tikzquads@@fitto{#1}{#2}{-\@@outerext}{0}{\Xdiff}{\Xang}
678 \pgfkeysalso{\tikzquads@@QuadKeysPath/half base width=\Xdiff}
679 } ,
680 y fit to/.style 2 args={y fit to!={#1}{#2}},
681 y fit to*/.code 2 args={%
682 \tikzquads@@fitto{#1}{#2}{0}{90}{\Ydiff}{\Yang}
683 \pgfkeysalso{/tikz/rotate=\Yang,\tikzquads@@QuadKeysPath/half base height=\Ydiff}
684 } ,
685 y fit to!/.code 2 args={%
686 \tikzquads@@fitto{#1}{#2}{0}{90}{\Ydiff}{\Yang}
687 \pgfkeysalso{\tikzquads@@QuadKeysPath/half base height=\Ydiff}
688 } ,
689 @BB fit set/.style={%
690 inner x fit to/.style 2 args={inner x fit to!={##1}{##2}},
691 outer x fit to/.style 2 args={outer x fit to!={##1}{##2}},
692 y fit to/.style 2 args={y fit to*={##1}{##2}},
693 }
694 }
695
696 \NewDocumentCommand{\tikzquads@@fitto}{mmmmmm}{
697 \tikzmath{coordinate \Ctmp; real \dx , \dy;% , \Rtmp ;
698 \Ctmp{from} = (#1);
699 \Ctmp{to} = (#2);
700 \dx{tmp} = (\Ctmpx{to} - \Ctmpx{from})/100;
701 \dy{tmp} = (\Ctmpy{to} - \Ctmpy{from})/100;
702 #5 = 50*sqrt((\dx{tmp})^2 + (\dy{tmp})^2) + #3;
703 #6 = atan2(\dy{tmp},\dx{tmp}) + #4;
704 }
705 }
706
707 \pgfkeys{\tikzquads@@QuadKeysPath,
708 setlabelscmd/.style={%
709 #1 N anchor/.style={},
710 #1 T anchor/.style={},
711 #1 label pos/.style 2 args={#1 N anchor/.style={\tikzquads@@TPath,##1=####1}, #1 T anchor/.style={\tikzquads@@TPath,##2=####1}, },
712 },
713 setlabelscmd/.list={Z11,Z12,Z21,Z22,Y11,Y12,Y21,Y22,G11,G12,G21,G22,H11,H12,H21,H22,In,Yn,Vth,Zth},
714 defaults/.style={
715 Z11 label pos={south west}{top left},
716 Z12 label pos={south east}{top left},
717 Z21 label pos={north west}{bottom right},
718 Z22 label pos={south east}{top right},
719 %
720 Y11 label pos={south east}{top left},
721 Y12 label pos={south east}{top left},
722 Y21 label pos={north west}{bottom right},
723 Y22 label pos={north west}{bottom right},
724 %
725 G11 label pos={south east}{top left},
726 G12 label pos={south east}{top left},
727 G21 label pos={north west}{bottom right},
728 G22 label pos={south east}{top right},
729 %
730 H11 label pos={south west}{top left},
731 H12 label pos={south east}{top left},
732 H21 label pos={north west}{bottom right},
733 H22 label pos={north west}{bottom right},
734 %
735 Yn label pos={south east}{top left},
736 In label pos={south east}{top left},
737 %
738 Zth label pos={south west}{top left},
739 Vth label pos={south east}{top left},
740 %
741 },
742 defaults,
743 }
744
745 %%%%%%%%%%%%%%%%%%%
746 %%%
747 %%% Coordinates for a Quadripole
748 %%%
749 %%%%%%%%%%%%%%%%%%%
750 %\newcommand{\tikzquads@@QuadPoints}{
751 \NewDocumentCommand{\tikzquads@@QuadPoints}{}{
752 \SearchValueOf{QuadKeys}{half base width}{\@@halfbasewidth}
753 \SearchValueOf{QuadKeys}{half base height}{\@@halfbaseheight}
754 \SearchValueOf{QuadKeys}{height ext}{\@@heightext}
755 \SearchValueOf{QuadKeys}{outer ext}{\@@outerext}
756 \SearchValueOf{QuadKeys}{inner ext}{\@@innerext}
757 \tikzmath{
758 real \x,\y;
759 \x{center}=0;
760 \y{center}=0;
761 \x{right}=0 + \@@halfbasewidth;
762 \y{top}=0 +( \@@halfbaseheight + \@@heightext);
763 %
764 \x{left}=0 - \@@halfbasewidth;
765 \y{bottom}=0 -( \@@halfbaseheight + \@@heightext);
766 %
767 \y{innerbottom}=0 - \@@halfbaseheight;
768 \y{innertop}=0 + \@@halfbaseheight;
769 %
770 \y{outerbottom}=\y{bottom} - 0.5*\@@outerext;
771 \y{outertop}=\y{top} + 0.5*\@@outerext;
772 %
773 \x{outerleft}=\x{left} - \@@outerext;
774 \x{innerleft}=\x{left} + \@@innerext;
775 %
776 \x{outerright}=\x{right} + \@@outerext;
777 \x{innerright}=\x{right} - \@@innerext;
778 %
779 \x{refC}=0 - 0.4*\@@halfbasewidth;
780 \x{refB}=(\x{innerleft}+\x{refC})/2; %center point for Res shape
781 \x{refA}=(2*\x{innerleft}+\x{refC})/3; %'center' point for Y.Res shape
782 %
783 \y{Tbottom}=\y{bottom} + 0.65ex;
784 %\y{Ttop}=-\y{Tbottom};
785 \x{Tinnerleft}=\x{innerleft} ;
786 \y{Tinnerbottom}=\y{innerbottom} + 0.95ex;
787 %\y{Tinnertop}=-\y{Tinnerbottom};
788 \x{Tinnerright}=\x{innerright};
789 \x{Tcenter}=0;
790 %
791 \y{Ttop}=\y{top} - 0.65ex;
792 \y{Tinnertop}=\y{innertop} - 0.95ex;
793 }
794 }
795
796
797
798
799 %%%%%%%%%%%%%%%%%%%
800 %%%
801 %%% if <key value>, #1, is zero, #2 is executed, otherwise #3.
802 %%%
803 %%%%%%%%%%%%%%%%%%%
804 %\newcommand{\tikzquads@@CondDraw}[3]{%
805 \NewDocumentCommand{\tikzquads@@CondDraw}{mmm}{%
806 \IfDecimal{\tikzquads@@ValueOf{QuadKeys}{#1}}{%
807 \ifnumequal{0+\tikzquads@@ValueOf{QuadKeys}{#1}}{0}{%
808 #2
809 }{%
810 #3
811 }
812 }{#3}
813 }
814
815 %%%%%%%%%%%%%%%%%%%
816 %%%
817 %%% if <key value>, #1, is zero, a in place line is drawn, otherwise shape #2 is draw.
818 %%%
819 %%%%%%%%%%%%%%%%%%%
820 %\newcommand{\tikzquads@@Zdraw}[5]{%
821 \NewDocumentCommand{\tikzquads@@Zdraw}{mmmmm}{%
822 \tikzquads@@CondDraw{#1}{%
823 \pgfnode{Shadow #2}{#3}{}{\tikz@fig@name-#1}{\pgfusepath{discard}}
824 \pgfpathmoveto{\pgfpointanchor{\tikz@fig@name-#1}{#4}}
825 \pgfpathlineto{\pgfpointanchor{\tikz@fig@name-#1}{#5}}
826 \pgfusepath{stroke}
827 }{%
828 \pgfnode{#2}{#3}{}{\tikz@fig@name-#1}{\pgfusepath{stroke}}
829 }
830 }
831
832
833
834 %%%%%%%%%%%%%%%%%%%
835 %%%
836 %%% Draws a Z side (impedance in series with a Voltage source
837 %%%
838 %%%%%%%%%%%%%%%%%%%
839
840 \newtoggle{tikzquads@@toggle@auxA}
841 \newtoggle{tikzquads@@toggle@auxB}
842 %
843 % #1->z11/z22 (res)
844 % #2->z12/z21 (vsource)
845 % #3 -> 'control source' I1/I2/V1/V2
846 % #4->"-" minus signal !!! for B side
847 %
848 %\newcommand{\tikzquads@@Zside}[4]{%
849 \NewDocumentCommand{\tikzquads@@Zside}{mmmm}{%
850 \togglefalse{tikzquads@@toggle@auxA}
851 \IfDecimal{\tikzquads@@ValueOf{QuadKeys}{#1}}{%
852 \ifnumequal{0+\tikzquads@@ValueOf{QuadKeys}{#1}}{0}{%
853 \toggletrue{tikzquads@@toggle@auxA}}
854 }{}{%
855 }
856 \togglefalse{tikzquads@@toggle@auxB}
857 \IfDecimal{\tikzquads@@ValueOf{QuadKeys}{#2}}{%
858 \ifnumequal{0+\tikzquads@@ValueOf{QuadKeys}{#2}}{0}{%
859 \toggletrue{tikzquads@@toggle@auxB}}
860 }{}{%
861 }
862 \ifboolexpr{togl{tikzquads@@toggle@alternate} and ( togl{tikzquads@@toggle@auxA} or togl{tikzquads@@toggle@auxB})}{%
863 \iftoggle{tikzquads@@toggle@auxA}{%
864 {%
865 \pgftransformshift{\pgfpoint{#4\x{refB}}{0}}
866 \tikzquads@@Zdraw{#2}{Vsource shape}{center}{north}{south}
867 }
868 {%
869 \pgfpathmoveto{\pgfpoint{#4\x{innerleft}}{\y{innertop}}}
870 \pgfpathlineto{\pgfpoint{#4\x{refB}}{\y{innertop}}}
871 \pgfpathlineto{\pgfpointanchor{\tikz@fig@name-#2}{north}}
872 \pgfpathmoveto{\pgfpointanchor{\tikz@fig@name-#2}{south}}
873 \pgfpathlineto{\pgfpoint{#4\x{refB}}{\y{innerbottom}}}
874 \pgfpathlineto{\pgfpoint{#4\x{innerleft}}{\y{innerbottom}}}
875 \pgfusepath{stroke}
876 }
877 }{%
878 {%
879 \pgftransformshift{\pgfpoint{#4\x{refB}}{0}}
880 % \pgftransformrotate{90} %%% was #490
881 % \tikzquads@@Zdraw{#1}{H Res shape}{center}{west}{east}
882 \tikzquads@@Zdraw{#1}{V Res shape}{center}{north}{south}
883 \pgfusepath{stroke}
884 }
885 {%
886 \pgfpathmoveto{\pgfpoint{#4\x{innerleft}}{\y{innertop}}}
887 \pgfpathlineto{\pgfpoint{#4\x{refB}}{\y{innertop}}}
888 % \pgfpathlineto{\pgfpointanchor{\tikz@fig@name-#1}{east}}
889 % \pgfpathmoveto{\pgfpointanchor{\tikz@fig@name-#1}{west}}
890 \pgfpathlineto{\pgfpointanchor{\tikz@fig@name-#1}{north}}
891 \pgfpathmoveto{\pgfpointanchor{\tikz@fig@name-#1}{south}}
892 \pgfpathlineto{\pgfpoint{#4\x{refB}}{\y{innerbottom}}}
893 \pgfpathlineto{\pgfpoint{#4\x{innerleft}}{\y{innerbottom}}}
894 \pgfusepath{stroke}
895 }
896 }
897 }{%
898 {%
899 \pgftransformshift{\pgfpoint{#4\x{refB}}{\y{innertop}}}
900 \tikzquads@@Zdraw{#1}{H Res shape}{center}{west}{east}
901 }
902 {%
903 \pgftransformshift{\pgfpoint{#4\x{refC}}{0}}
904 \tikzquads@@Zdraw{#2}{Vsource shape}{center}{north}{south}
905 }
906 {%
907 \pgfpathmoveto{\pgfpoint{#4\x{innerleft}}{\y{innertop}}}
908 \ifnumequal{#41}{-1}{%
909 \pgfpathlineto{\pgfpointanchor{\tikz@fig@name-#1}{east}}
910 \pgfpathmoveto{\pgfpointanchor{\tikz@fig@name-#1}{west}}
911 }{%
912 \pgfpathlineto{\pgfpointanchor{\tikz@fig@name-#1}{west}}
913 \pgfpathmoveto{\pgfpointanchor{\tikz@fig@name-#1}{east}}
914 }
915 \pgfpathlineto{\pgfpoint{#4\x{refC}}{\y{innertop}}}
916 \pgfpathlineto{\pgfpointanchor{\tikz@fig@name-#2}{north}}
917 \pgfpathmoveto{\pgfpointanchor{\tikz@fig@name-#2}{south}}
918 \pgfpathlineto{\pgfpoint{#4\x{refC}}{\y{innerbottom}}}
919 \pgfpathlineto{\pgfpoint{#4\x{innerleft}}{\y{innerbottom}}}
920 \pgfusepath{stroke}
921 }
922 }
923 %
924 \tikzquads@@QuadGetAnchor{#2 N anchor}{tikzquads@@NanchorB}
925 \tikzquads@@QuadGetAnchor{#1 T anchor}{tikzquads@@TanchorA}
926 \tikzquads@@QuadGetAnchor{#2 T anchor}{tikzquads@@TanchorB}
927 \ifboolexpr{togl{tikzquads@@toggle@alternate} and togl{tikzquads@@toggle@auxB}}{%
928 \tikzquads@@QuadGetAnchor{#1 N anchor}{tikzquads@@NanchorAx}
929 \tikzquads@@AutoRotateAnchor{\tikzquads@@NanchorAx}{tikzquads@@NanchorA}
930 }{%
931 \tikzquads@@QuadGetAnchor{#1 N anchor}{tikzquads@@NanchorA}
932 }
933 {%
934 \SearchValueOf{QuadKeys}{#1}{\@@valA}
935 \SearchValueOf{QuadKeys}{#2}{\@@valB}
936 \SearchValueOf{QuadKeys}{#3}{\@@valC}
937 \pgftransformresetnontranslations
938 \tikzquads@@CondDraw{#1}{}{\pgftext[\tikzquads@@TanchorA,at={\pgfpointanchor{\tikz@fig@name-#1}{\tikzquads@@NanchorA}}]{\@@valA}}
939 \ifboolexpr{togl{tikzquads@@toggle@rawsources}}{%
940 \tikzquads@@CondDraw{#2}{}{\pgftext[\tikzquads@@TanchorB,at={\pgfpointanchor{\tikz@fig@name-#2}{\tikzquads@@NanchorB}}]{\@@valB}}
941 }{%
942 \tikzquads@@CondDraw{#2}{}{\pgftext[\tikzquads@@TanchorB,at={\pgfpointanchor{\tikz@fig@name-#2}{\tikzquads@@NanchorB}}]{\@@valB\@@valC}}
943 }
944 }
945 }
946
947 %%%%%%%%%%%%%%%%%%%
948 %%%
949 %%% if <key value>, #1, is zero, nothing is drawn, otherwise shape #2 is draw.
950 %%%
951 %%%%%%%%%%%%%%%%%%%
952 %\newcommand{\tikzquads@@Ydraw}[3]{%
953 \NewDocumentCommand{\tikzquads@@Ydraw}{mmm}{%
954 \tikzquads@@CondDraw{#1}{%
955 \pgfnode{Shadow #2}{#3}{}{\tikz@fig@name-#1}{\pgfusepath{discard}}
956 }{%
957 \pgfnode{#2}{#3}{}{\tikz@fig@name-#1}{\pgfusepath{stroke}}
958 }
959 }
960
961 %%%%%%%%%%%%%%%%%%%
962 %%%
963 %%% Draws a Y side (impedance in paralel with a Currente source
964 %%%
965 %%%%%%%%%%%%%%%%%%%
966
967 % #1 Isource UP/DWN
968 % #2->y11/y22 (res)
969 % #3->y12/y21 (isource)
970 % #4 -> 'control source' I1/I2/V1/V2
971 % #5->"-" minus signal !!! for B side
972 %
973 %\newcommand{\tikzquads@@Yside}[5][IsourceDOWN shape]{%
974 \NewDocumentCommand{\tikzquads@@Yside}{O{IsourceDOWN shape}mmmm}{%
975 \togglefalse{tikzquads@@toggle@auxA}
976 \IfDecimal{\tikzquads@@ValueOf{QuadKeys}{#2}}{%
977 \ifnumequal{0+\tikzquads@@ValueOf{QuadKeys}{#2}}{0}{%
978 \toggletrue{tikzquads@@toggle@auxA}}
979 }{}{%
980 }
981 \togglefalse{tikzquads@@toggle@auxB}
982 \IfDecimal{\tikzquads@@ValueOf{QuadKeys}{#3}}{%
983 \ifnumequal{0+\tikzquads@@ValueOf{QuadKeys}{#3}}{0}{%
984 \toggletrue{tikzquads@@toggle@auxB}}
985 }{}{%
986 }
987 \ifboolexpr{togl{tikzquads@@toggle@alternate} and ( togl{tikzquads@@toggle@auxA} or togl{tikzquads@@toggle@auxB})}{%
988 \tikzmath{%
989 \x{20} = \x{refB};
990 \x{21} = \x{refB};
991 }
992 }{%
993 \tikzmath{%
994 \x{20} = \x{refA};
995 \x{21} = \x{refC};
996 }
997 }
998 %
999 {%
1000 \pgftransformshift{\pgfpoint{#5\x{20}}{0}}
1001 % \pgftransformrotate{90} %%% was {#590}
1002 % \tikzquads@@Ydraw{#2}{H Res shape}{center}
1003 \tikzquads@@Ydraw{#2}{V Res shape}{center}
1004 }
1005 \tikzquads@@CondDraw{#2}{}{
1006 \pgfpathmoveto{\pgfpoint{#5\x{innerleft}}{\y{innertop}}}
1007 \pgfpathlineto{\pgfpoint{#5\x{20}}{\y{innertop}}}
1008 % \pgfpathlineto{\pgfpointanchor{\tikz@fig@name-#2}{east}}
1009 % \pgfpathmoveto{\pgfpointanchor{\tikz@fig@name-#2}{west}}
1010 \pgfpathlineto{\pgfpointanchor{\tikz@fig@name-#2}{north}}
1011 \pgfpathmoveto{\pgfpointanchor{\tikz@fig@name-#2}{south}}
1012 \pgfpathlineto{\pgfpoint{#5\x{20}}{\y{innerbottom}}}
1013 \pgfpathlineto{\pgfpoint{#5\x{innerleft}}{\y{innerbottom}}}
1014 \pgfusepath{stroke}
1015 }
1016 %
1017 {%
1018 \pgftransformshift{\pgfpoint{#5\x{21}}{0}}
1019 \tikzquads@@Ydraw{#3}{#1}{center}
1020 }
1021 \tikzquads@@CondDraw{#3}{}{%
1022 \pgfpathmoveto{\pgfpoint{#5\x{innerleft}}{\y{innertop}}}
1023 \pgfpathlineto{\pgfpoint{#5\x{refA}}{\y{innertop}}}
1024 \pgfpathlineto{\pgfpoint{#5\x{21}}{\y{innertop}}}
1025 \pgfpathlineto{\pgfpointanchor{\tikz@fig@name-#3}{north}}
1026 \pgfpathmoveto{\pgfpointanchor{\tikz@fig@name-#3}{south}}
1027 \pgfpathlineto{\pgfpoint{#5\x{21}}{\y{innerbottom}}}
1028 \pgfpathlineto{\pgfpoint{#5\x{innerleft}}{\y{innerbottom}}}
1029 \pgfusepath{stroke}
1030 }
1031 %\tikzquads@@QuadGetAnchor{#2 N anchor}{tikzquads@@NanchorAx}
1032 \tikzquads@@QuadGetAnchor{#2 N anchor}{tikzquads@@NanchorA}
1033 \tikzquads@@QuadGetAnchor{#3 N anchor}{tikzquads@@NanchorB}
1034 \tikzquads@@QuadGetAnchor{#2 T anchor}{tikzquads@@TanchorA}
1035 \tikzquads@@QuadGetAnchor{#3 T anchor}{tikzquads@@TanchorB}
1036 %\tikzquads@@RotateAnchor{\tikzquads@@NanchorAx}{tikzquads@@NanchorA}
1037 {%
1038 \SearchValueOf{QuadKeys}{#2}{\@@valA}
1039 \SearchValueOf{QuadKeys}{#3}{\@@valB}
1040 \SearchValueOf{QuadKeys}{#4}{\@@valC}
1041 \pgftransformresetnontranslations
1042 \tikzquads@@CondDraw{#2}{}{\pgftext[\tikzquads@@TanchorA,at={\pgfpointanchor{\tikz@fig@name-#2}{\tikzquads@@NanchorA}}]{\@@valA}}
1043 \ifboolexpr{togl{tikzquads@@toggle@rawsources}}{%
1044 \tikzquads@@CondDraw{#3}{}{\pgftext[\tikzquads@@TanchorB,at={\pgfpointanchor{\tikz@fig@name-#3}{\tikzquads@@NanchorB}}]{\@@valB}}
1045 }{%
1046 \tikzquads@@CondDraw{#3}{}{\pgftext[\tikzquads@@TanchorB,at={\pgfpointanchor{\tikz@fig@name-#3}{\tikzquads@@NanchorB}}]{\@@valB\@@valC}}
1047 }
1048 }
1049 }
1050
1051
1052 %%%%%%%%%%%%%%%%%%%
1053 %%%
1054 %%% Coordinates for a Horizontal Resistor
1055 %%%
1056 %%%%%%%%%%%%%%%%%%%
1057 %\newcommand{\tikzquads@@HResPoints}{%
1058 \NewDocumentCommand{\tikzquads@@HResPoints}{}{%
1059 \SearchValueOf{QuadKeys}{outer sep}{\@@outersep}
1060 \pgfkeyget{\circuitikzbasekey/bipoles/resistor}{width}{\@@width}
1061 \pgfkeyget{\circuitikzbasekey/bipoles/resistor}{height}{\@@height}
1062 \tikzmath{%
1063 real \x,\y;
1064 \x{center}=0;
1065 \y{center}=0;
1066 %
1067 \x{left}=-\@@width\pgf@circ@Rlen/2;
1068 \x{right}=\@@width\pgf@circ@Rlen/2;
1069 %
1070 \y{top}=+\@@height\pgf@circ@Rlen/2;
1071 \y{bottom}=-\@@height\pgf@circ@Rlen/2;
1072 %
1073 \x{step}=\@@width\pgf@circ@Rlen/12;
1074 \y{step}=\@@height\pgf@circ@Rlen/2;
1075 %
1076 \x{Tcenter}=0;
1077 \y{Tcenter}=0;
1078 %
1079 \y{Ttop}=+\@@height\pgf@circ@Rlen/2 +\@@outersep;
1080 \y{Tbottom}=-\y{Ttop};
1081 %
1082 \x{Tright}=+\@@width\pgf@circ@Rlen/2 +\@@outersep;
1083 \x{Tleft}=-\x{Tright};
1084 %
1085 \y{Ctop}=\y{Ttop};
1086 \y{Cbottom}=\y{Tbottom};
1087 %
1088 \x{Cleft}=\x{left};
1089 \x{Cright}=\x{right};
1090 }
1091 }
1092
1093
1094 %%%%%%%%%%%%%%%%%%%
1095 %%%
1096 %%% Coordinates for a Vertical Resistor
1097 %%%
1098 %%%%%%%%%%%%%%%%%%%
1099 %\newcommand{\tikzquads@@VResPoints}{
1100 \NewDocumentCommand{\tikzquads@@VResPoints}{}{
1101 \SearchValueOf{QuadKeys}{outer sep}{\@@outersep}
1102 \pgfkeyget{\circuitikzbasekey/bipoles/resistor}{width}{\@@width}
1103 \pgfkeyget{\circuitikzbasekey/bipoles/resistor}{height}{\@@height}
1104 \tikzmath{%
1105 real \x,\y;
1106 \x{center}=0;
1107 \y{center}=0;
1108 %
1109 \y{bottom}=-\@@width\pgf@circ@Rlen/2;
1110 \y{top}=\@@width\pgf@circ@Rlen/2;
1111 %
1112 \x{right}=+\@@height\pgf@circ@Rlen/2;
1113 \x{left}=-\@@height\pgf@circ@Rlen/2;
1114 %
1115 \x{step}=\@@width\pgf@circ@Rlen/12;
1116 \y{step}=\@@height\pgf@circ@Rlen/2;
1117 %
1118 \x{Tcenter}=0;
1119 \y{Tcenter}=0;
1120 %
1121 \y{Ttop}=+\@@width\pgf@circ@Rlen/2 +\@@outersep;
1122 \y{Tbottom}=-\y{Ttop};
1123 %
1124 \x{Tright}=+\@@height\pgf@circ@Rlen/2 +\@@outersep;
1125 \x{Tleft}=-\x{Tright};
1126 %
1127 \y{Ctop}=\y{top};
1128 \y{Cbottom}=\y{bottom};
1129 %
1130 \x{Cleft}=\x{Tleft};
1131 \x{Cright}=\x{Tright};
1132 }
1133 }
1134
1135
1136
1137 %%%%%%%%%%%%%%%%%%%
1138 %%%
1139 %%% Base Anchors for a Resistor like shape
1140 %%%
1141 %%%%%%%%%%%%%%%%%%%
1142 %\newcommand{\tikzquads@@ResBaseAnchors}[1]{%
1143 \NewDocumentCommand{\tikzquads@@ResBaseAnchors}{m}{%
1144 \anchor{center}{\centerpoint}
1145 \savedanchor\centerpoint{%
1146 #1
1147 \pgfpoint{\x{center}}{\y{center}}
1148 }
1149 \anchor{text}{%
1150 #1
1151 \pgfpoint{\x{Tcenter}}{\y{Ttop}}
1152 }
1153 \anchor{west}{\west}
1154 \savedanchor{\west}{%
1155 #1
1156 \pgfpoint{\x{Cleft}}{\y{center}}
1157 }
1158 \anchor{east}{\east}
1159 \savedanchor{\east}{%
1160 #1
1161 \pgfpoint{\x{Cright}}{\y{center}}
1162 }
1163 \anchor{north}{\north}
1164 \savedanchor{\north}{%
1165 #1
1166 \pgfpoint{\x{center}}{\y{Ctop}}
1167 }
1168 \anchor{south}{\south}
1169 \savedanchor{\south}{%
1170 #1
1171 \pgfpoint{\x{center}}{\y{Cbottom}}
1172 }
1173 \anchor{north west}{\northwest}%
1174 \savedanchor{\northwest}{%
1175 #1
1176 \pgfpoint{\x{Tleft}}{\y{Ttop}}
1177 }
1178 \anchor{north east}{\northeast}%
1179 \savedanchor{\northeast}{%
1180 #1
1181 \pgfpoint{\x{Tright}}{\y{Ttop}}
1182 }
1183 \anchor{south west}{\southwest}%
1184 \savedanchor{\southwest}{%
1185 #1
1186 \pgfpoint{\x{Tleft}}{\y{Tbottom}}
1187 }
1188 \anchor{south east}{\southeast}%
1189 \savedanchor{\southeast}{%
1190 #1
1191 \pgfpoint{\x{Tright}}{\y{Tbottom}}
1192 }
1193 }
1194
1195 %\newcommand{\tikzquads@@DrawRes}[1]{%
1196 %}
1197
1198 %%%%%%%%%%%%%%%%%%%
1199 %%%
1200 %%% Resistor shape. either zig-zag or generic/european
1201 %%%
1202 %%%%%%%%%%%%%%%%%%%
1203 \pgfdeclareshape{H Res shape}{%
1204 \tikzquads@@ResBaseAnchors{\tikzquads@@HResPoints}
1205 \behindbackgroundpath{%
1206 \tikzquads@@HResPoints
1207 \pgfsetxvec{\pgfpoint{\x{step}}{0}}
1208 \pgfsetyvec{\pgfpoint{0}{\y{step}}}
1209 \begin{pgfscope}
1210 \SearchValueOf{QuadKeys}{thickness}{\@@tmpthickness}
1211 \pgfsetlinewidth{\@@tmpthickness\pgflinewidth}
1212 \pgfsetbeveljoin
1213 \iftoggle{tikzquads@@toggle@generic}{%
1214 \pgfpathmoveto{\pgfpointxy{-6}{-1}}
1215 \pgfpathlineto{\pgfpointxy{-6}{1}}
1216 \pgfpathlineto{\pgfpointxy{6}{1}}
1217 \pgfpathlineto{\pgfpointxy{6}{-1}}
1218 \pgfpathlineto{\pgfpointxy{-6}{-1}}
1219 }{%
1220 \pgfpathmoveto{\pgfpointxy{-6}{0}}
1221 \pgfpathlineto{\pgfpointxy{-5}{1}}
1222 \pgfpathlineto{\pgfpointxy{-3}{-1}}
1223 \pgfpathlineto{\pgfpointxy{-1}{1}}
1224 \pgfpathlineto{\pgfpointxy{1}{-1}}
1225 \pgfpathlineto{\pgfpointxy{3}{1}}
1226 \pgfpathlineto{\pgfpointxy{5}{-1}}
1227 \pgfpathlineto{\pgfpointxy{6}{0}}
1228 }
1229 \pgfusepath{stroke}
1230 \end{pgfscope}
1231 }
1232 \backgroundpath{}
1233 }
1234
1235
1236 %%%%%%%%%%%%%%%%%%%
1237 %%%
1238 %%% Shadow H Res shape => do nothing but defines anchors
1239 %%%
1240 %%%%%%%%%%%%%%%%%%%
1241 \pgfdeclareshape{Shadow H Res shape}{%
1242 \inheritsavedanchors[from=H Res shape]
1243 \foreach \anchor in {north,north west,north east,center,west,east,
1244 ,south,south west,south east,text}{%
1245 \inheritanchor[from=H Res shape]{\anchor}}
1246 \backgroundpath{}
1247 }
1248
1249
1250 %%%%%%%%%%%%%%%%%%%
1251 %%%
1252 %%% Resistor shape. either zig-zag or generic/european
1253 %%%
1254 %%%%%%%%%%%%%%%%%%%
1255 \pgfdeclareshape{V Res shape}{%
1256 \tikzquads@@ResBaseAnchors{\tikzquads@@VResPoints}
1257 \behindbackgroundpath{%
1258 \tikzquads@@HResPoints
1259 \pgfsetxvec{\pgfpoint{\x{step}}{0}}
1260 \pgfsetyvec{\pgfpoint{0}{\y{step}}}
1261 \begin{pgfscope}
1262 \SearchValueOf{QuadKeys}{thickness}{\@@tmpthickness}
1263 \pgfsetlinewidth{\@@tmpthickness\pgflinewidth}
1264 \pgfsetbeveljoin
1265 \pgftransformrotate{90}
1266 \iftoggle{tikzquads@@toggle@generic}{
1267 \pgfpathmoveto{\pgfpointxy{-6}{-1}}
1268 \pgfpathlineto{\pgfpointxy{-6}{1}}
1269 \pgfpathlineto{\pgfpointxy{6}{1}}
1270 \pgfpathlineto{\pgfpointxy{6}{-1}}
1271 \pgfpathlineto{\pgfpointxy{-6}{-1}}
1272 }{%
1273 \pgfpathmoveto{\pgfpointxy{-6}{0}}
1274 \pgfpathlineto{\pgfpointxy{-5}{1}}
1275 \pgfpathlineto{\pgfpointxy{-3}{-1}}
1276 \pgfpathlineto{\pgfpointxy{-1}{1}}
1277 \pgfpathlineto{\pgfpointxy{1}{-1}}
1278 \pgfpathlineto{\pgfpointxy{3}{1}}
1279 \pgfpathlineto{\pgfpointxy{5}{-1}}
1280 \pgfpathlineto{\pgfpointxy{6}{0}}
1281 }
1282 \pgfusepath{stroke}
1283 \end{pgfscope}
1284 }
1285 \backgroundpath{}
1286 }
1287
1288
1289 %%%%%%%%%%%%%%%%%%%
1290 %%%
1291 %%% Shadow V Res shape => do nothing but defines anchors
1292 %%%
1293 %%%%%%%%%%%%%%%%%%%
1294 \pgfdeclareshape{Shadow V Res shape}{%
1295 \inheritsavedanchors[from=V Res shape]
1296 \foreach \anchor in {north,north west,north east,center,west,east,
1297 ,south,south west,south east,text}{%
1298 \inheritanchor[from=V Res shape]{\anchor}}
1299 \backgroundpath{}
1300 }
1301
1302
1303
1304 %%%%%%%%%%%%%%%%%%%
1305 %%%
1306 %%% a simple arrow tip, can be a simple triangle or a bezier based one.
1307 %%% back of the tip at the 'starting point'
1308 %%%
1309 %%%%%%%%%%%%%%%%%%%
1310 %\newcommand{\tikzquads@@arrowtipat}[3]{%
1311 \NewDocumentCommand{\tikzquads@@arrowtipat}{mmm}{%
1312 {
1313 \pgftransformshift{\pgfpoint{#2}{#3}}
1314 \pgftransformscale{\tikzquads@@ValueOf{Keys}{tip len}}
1315 \pgftransformrotate{#1}
1316 \iftoggle{tikzquads@@toggle@beziertip}{%
1317 %% bezier version
1318 \pgfsetroundcap\pgfsetbeveljoin
1319 \pgfpathmoveto{\pgfpoint{1}{0}}
1320 \pgfpathcurveto{\pgfpoint{0.3}{0.125}}{\pgfpoint{0.3}{0.125}}{\pgfpoint{0}{0.4}}
1321 \pgfpathcurveto{\pgfpoint{0.15}{0}}{\pgfpoint{0.15}{0}}{\pgfpoint{0}{-0.4}}
1322 \pgfpathcurveto{\pgfpoint{0.3}{-0.125}}{\pgfpoint{0.3}{-0.125}}{\pgfpoint{1}{0}}
1323 }{ %% simple triangle version
1324 \pgfsetroundcap
1325 \pgfpathmoveto{\pgfpoint{1}{0}}
1326 \pgfpathlineto{\pgfpoint{0}{0.45}}
1327 \pgfpathlineto{\pgfpoint{0}{-0.45}}
1328 \pgfpathlineto{\pgfpoint{1}{0}}
1329 }
1330 }
1331 }
1332
1333 %%%%%%%%%%%%%%%%%%%
1334 %%%
1335 %%% a simple, centered at point of reference, 'plus' sign... it could be a \pgftext... but, that way it is more controlable.
1336 %%%
1337 %%%%%%%%%%%%%%%%%%%
1338 %\newcommand{\tikzquads@@plussignat}[3][\tikzquads@@ValueOf{Keys}{plussign len}]{%
1339 \NewDocumentCommand{\tikzquads@@plussignat}{O{\tikzquads@@ValueOf{Keys}{plussign len}}mm}{%
1340 {%
1341 \pgftransformshift{\pgfpoint{#2}{#3}}
1342 \pgftransformscale{#1}
1343 \pgfpathmoveto{\pgfpoint{-1}{0}}
1344 \pgfpathlineto{\pgfpoint{1}{0}}
1345 \pgfpathmoveto{\pgfpoint{0}{-1}}
1346 \pgfpathlineto{\pgfpoint{0}{1}}
1347 }
1348 }
1349
1350 %%%%%%%%%%%%%%%%%%%
1351 %%%
1352 %%% a simple, centered at point of reference, 'minus' sign... it could be a \pgftext... but, that way it is more controlable.
1353 %%%
1354 %%%%%%%%%%%%%%%%%%%
1355 %\newcommand{\tikzquads@@minussignat}[3][\tikzquads@@ValueOf{Keys}{minussign len}]{%
1356 \NewDocumentCommand{\tikzquads@@minussignat}{O{\tikzquads@@ValueOf{Keys}{minussign len}}mm}{%
1357 {%
1358 \pgftransformshift{\pgfpoint{#2}{#3}}
1359 \pgftransformscale{#1}
1360 \pgfpathmoveto{\pgfpoint{-1}{0}}
1361 \pgfpathlineto{\pgfpoint{1}{0}}
1362 }
1363 }
1364
1365
1366 %%%%%%%%%%%%%%%%%%%
1367 %%%
1368 %%% Coordinates for a (base) Source
1369 %%%
1370 %%%%%%%%%%%%%%%%%%%
1371 %\newcommand{\tikzquads@@SourcePoints}{%
1372 \NewDocumentCommand{\tikzquads@@SourcePoints}{}{%
1373 \SearchValueOf{QuadKeys}{source radius}{\@@sourceradius}
1374 \SearchValueOf{QuadKeys}{outer sep}{\@@outersep}
1375 \tikzmath{%
1376 real \x,\y;
1377 \x{center}=0;
1378 \y{center}=0;
1379 \x{left}=-\@@sourceradius;
1380 \x{right}=\@@sourceradius;
1381 \y{top}=\@@sourceradius;
1382 \y{bottom}=-\@@sourceradius;
1383 %
1384 \x{Tcenter}=0;
1385 \y{Tcenter}=0;
1386 \y{Tmiddletop}=+cos(45)*(\@@sourceradius+\@@outersep);
1387 \y{Tmiddlebottom}=-\y{Tmiddletop};
1388 %
1389 \x{Tmiddleright}=+cos(45)*(\@@sourceradius+\@@outersep);
1390 \x{Tmiddleleft}=-\x{Tmiddleright};
1391 }
1392 }
1393
1394
1395
1396 %%%%%%%%%%%%%%%%%%%
1397 %%%
1398 %%% Base Anchors for a Source like shape
1399 %%%
1400 %%%%%%%%%%%%%%%%%%%
1401 %\newcommand{\tikzquads@@SourceBaseAnchors}[1]{%
1402 \NewDocumentCommand{\tikzquads@@SourceBaseAnchors}{m}{%
1403 \savedanchor\centerpoint{%
1404 \pgfpoint{0}{0}
1405 }
1406 \anchor{center}{\centerpoint}
1407 \anchor{text}{\text}%
1408 \savedanchor{\text}{%
1409 #1
1410 \pgfpoint{\x{Tmiddleright}}{\y{Tmiddletop}}
1411 }
1412 \anchor{west}{\west}%
1413 \savedanchor{\west}{%
1414 #1
1415 \pgfpoint{\x{left}}{\y{center}}
1416 }
1417 \anchor{east}{\east}%
1418 \savedanchor{\east}{%
1419 #1
1420 \pgfpoint{\x{right}}{\y{center}}
1421 }
1422 \anchor{north}{\north}%
1423 \savedanchor{\north}{%
1424 #1
1425 \pgfpoint{\x{center}}{\y{top}}
1426 }
1427 \anchor{south}{\south}%
1428 \savedanchor{\south}{%
1429 #1
1430 \pgfpoint{\x{center}}{\y{bottom}}
1431 }
1432 \anchor{north west}{\northwest}%
1433 \savedanchor{\northwest}{%
1434 #1
1435 \pgfpoint{\x{Tmiddleleft}}{\y{Tmiddletop}}
1436 }
1437 \anchor{north east}{\northeast}%
1438 \savedanchor{\northeast}{%
1439 #1
1440 \pgfpoint{\x{Tmiddleright}}{\y{Tmiddletop}}
1441 }
1442 \anchor{south west}{\southwest}%
1443 \savedanchor{\southwest}{%
1444 #1
1445 \pgfpoint{\x{Tmiddleleft}}{\y{Tmiddlebottom}}
1446 }
1447 \anchor{south east}{\southeast}%
1448 \savedanchor{\southeast}{%
1449 #1
1450 \pgfpoint{\x{Tmiddleright}}{\y{Tmiddlebottom}}
1451 }
1452 }
1453
1454 %%%%%%%%%%%%%%%%%%%
1455 %%%
1456 %%% Base shape for a source like shape
1457 %%%
1458 %%%%%%%%%%%%%%%%%%%
1459 \pgfdeclareshape{Base source shape}{%
1460 \tikzquads@@SourceBaseAnchors{\tikzquads@@SourcePoints}
1461 \backgroundpath{}
1462 }
1463
1464
1465 %%%%%%%%%%%%%%%%%%%
1466 %%%
1467 %%% Voltage source shape. either round or diamond
1468 %%%
1469 %%%%%%%%%%%%%%%%%%%
1470 \pgfdeclareshape{Vsource shape}{%
1471 \inheritsavedanchors[from=Base source shape]
1472 \foreach \anchor in {north,north west,north east,center,west,east,
1473 ,south,south west,south east,text}{%
1474 \inheritanchor[from=Base source shape]{\anchor}}
1475 \backgroundpath{
1476 \SearchValueOf{QuadKeys}{thickness}{\@@tmpthickness}
1477 \SearchValueOf{QuadKeys}{source radius}{\@@sourceradius}
1478 \SearchValueOf{QuadKeys}{minussign len}{\@@minussignlen}
1479 \SearchValueOf{QuadKeys}{plussign len}{\@@plussignlen}
1480 \pgfsetroundcap
1481 \begin{pgfscope}
1482 \tikzquads@@SourcePoints
1483 \pgfsetbeveljoin
1484 \pgfsetlinewidth{\@@tmpthickness\pgflinewidth}
1485 \iftoggle{tikzquads@@toggle@roundsources}{%
1486 \pgfpathcircle{\pgfpoint{0}{0}}{\@@sourceradius}
1487 }{%
1488 \pgfpathmoveto{\pgfpoint{\x{center}}{\y{top}}}
1489 \pgfpathlineto{\pgfpoint{\x{right}}{\y{center}}}
1490 \pgfpathlineto{\pgfpoint{\x{center}}{\y{bottom}}}
1491 \pgfpathlineto{\pgfpoint{\x{left}}{\y{center}}}
1492 \pgfpathlineto{\pgfpoint{\x{center}}{\y{top}}}
1493 }
1494 \pgfusepath{stroke}
1495 \end{pgfscope}
1496 \tikzquads@@minussignat[\@@minussignlen]{0}{-0.4*\@@sourceradius}
1497 \tikzquads@@plussignat[\@@plussignlen]{0}{0.4*\@@sourceradius}
1498 \pgfusepath{stroke}
1499 }
1500 }
1501
1502
1503 %%%%%%%%%%%%%%%%%%%
1504 %%%
1505 %%% Shadow Vsource shape => do nothing but defines anchors
1506 %%%
1507 %%%%%%%%%%%%%%%%%%%
1508 \pgfdeclareshape{Shadow Vsource shape}{%
1509 \inheritsavedanchors[from=Base source shape]
1510 \foreach \anchor in {north,north west,north east,center,west,east,
1511 ,south,south west,south east,text}{%
1512 \inheritanchor[from=Base source shape]{\anchor}}
1513 \backgroundpath{}
1514 }
1515
1516
1517 %%%%%%%%%%%%%%%%%%%
1518 %%%
1519 %%% currente source shape, arrow pointing down. either round or diamond
1520 %%%
1521 %%%%%%%%%%%%%%%%%%%
1522 \pgfdeclareshape{IsourceDOWN shape}{%
1523 \inheritsavedanchors[from=Base source shape]
1524 \foreach \anchor in {north,north west,north east,center,west,east,
1525 ,south,south west,south east,text}{%
1526 \inheritanchor[from=Base source shape]{\anchor}}
1527 \backgroundpath{
1528 \SearchValueOf{QuadKeys}{thickness}{\@@tmpthickness}
1529 \SearchValueOf{QuadKeys}{source radius}{\@@sourceradius}
1530 \SearchValueOf{QuadKeys}{tip len}{\@@tiplen}
1531 \begin{pgfscope}
1532 \tikzquads@@SourcePoints
1533 \pgfsetlinewidth{\@@tmpthickness\pgflinewidth}
1534 \pgfsetroundcap
1535 \iftoggle{tikzquads@@toggle@roundsources}{%
1536 \pgfpathcircle{\pgfpoint{0}{0}}{\@@sourceradius}
1537 }{%
1538 \pgfpathmoveto{\pgfpoint{\x{center}}{\y{top}}}
1539 \pgfpathlineto{\pgfpoint{\x{right}}{\y{center}}}
1540 \pgfpathlineto{\pgfpoint{\x{center}}{\y{bottom}}}
1541 \pgfpathlineto{\pgfpoint{\x{left}}{\y{center}}}
1542 \pgfpathlineto{\pgfpoint{\x{center}}{\y{top}}}
1543 }
1544 \pgfpathmoveto{\pgfpoint{0}{0.7*\@@sourceradius}}
1545 \pgfpathlineto{\pgfpoint{0}{-0.7*\@@sourceradius}}
1546 %
1547 \pgfusepath{stroke}
1548 \tikzquads@@arrowtipat{-90}{0}{-0.7*\@@sourceradius+\@@tiplen}
1549 \pgfusepath{stroke,fill}
1550 \end{pgfscope}
1551 }}
1552
1553 %%%%%%%%%%%%%%%%%%%
1554 %%%
1555 %%% Shadow IsourceDOWN shape => do nothing but defines anchors
1556 %%%
1557 %%%%%%%%%%%%%%%%%%%
1558 \pgfdeclareshape{Shadow IsourceDOWN shape}{%
1559 \inheritsavedanchors[from=Base source shape]
1560 \foreach \anchor in {north,north west,north east,center,west,east,
1561 ,south,south west,south east,text}{%
1562 \inheritanchor[from=Base source shape]{\anchor}}
1563 \backgroundpath{}
1564 }
1565
1566
1567 %%%%%%%%%%%%%%%%%%%
1568 %%%
1569 %%% currente source shape, arrow pointing up. either round or diamond
1570 %%%
1571 %%%%%%%%%%%%%%%%%%%
1572 \pgfdeclareshape{IsourceUP shape}{%
1573 \inheritsavedanchors[from=Base source shape]
1574 \foreach \anchor in {north,north west,north east,center,west,east,
1575 ,south,south west,south east,text}{%
1576 \inheritanchor[from=Base source shape]{\anchor}}
1577 \backgroundpath{%
1578 \SearchValueOf{QuadKeys}{thickness}{\@@tmpthickness}
1579 \SearchValueOf{QuadKeys}{source radius}{\@@sourceradius}
1580 \SearchValueOf{QuadKeys}{tip len}{\@@tiplen}
1581 \begin{pgfscope}
1582 \tikzquads@@SourcePoints
1583 \pgfsetlinewidth{\@@tmpthickness\pgflinewidth}
1584 \pgfsetroundcap
1585 \iftoggle{tikzquads@@toggle@roundsources}{%
1586 \pgfpathcircle{\pgfpoint{0}{0}}{\@@sourceradius}
1587 }{%
1588 \pgfpathmoveto{\pgfpoint{\x{center}}{\y{top}}}
1589 \pgfpathlineto{\pgfpoint{\x{right}}{\y{center}}}
1590 \pgfpathlineto{\pgfpoint{\x{center}}{\y{bottom}}}
1591 \pgfpathlineto{\pgfpoint{\x{left}}{\y{center}}}
1592 \pgfpathlineto{\pgfpoint{\x{center}}{\y{top}}}
1593 }
1594 \pgfpathmoveto{\pgfpoint{0}{0.7*\@@sourceradius}}
1595 \pgfpathlineto{\pgfpoint{0}{-0.7*\@@sourceradius}}
1596 %
1597 \pgfusepath{stroke}
1598 \tikzquads@@arrowtipat{90}{0}{0.7*\@@sourceradius-\@@tiplen}
1599 \pgfusepath{stroke,fill}
1600 \end{pgfscope}
1601 }
1602 }
1603
1604 %%%%%%%%%%%%%%%%%%%
1605 %%%
1606 %%% Shadow IsourceUP shape => do nothing but defines anchors
1607 %%%
1608 %%%%%%%%%%%%%%%%%%%
1609 \pgfdeclareshape{Shadow IsourceUP shape}{%
1610 \inheritsavedanchors[from=Base source shape]
1611 \foreach \anchor in {north,north west,north east,center,west,east,
1612 ,south,south west,south east,text}{%
1613 \inheritanchor[from=Base source shape]{\anchor}}
1614 \backgroundpath{}
1615 }
1616
1617
1618 %%%%%%%%%%%%%%%%%%%
1619 %%%
1620 %%% Base Anchors for a Quadripole like shape
1621 %%% (note that the second side anchors are missing,
1622 %%% since this will also be used as a base for the black box)
1623 %%%
1624 %%%%%%%%%%%%%%%%%%%
1625 %\newcommand{\tikzquads@@QuadBaseAnchors}[1]{%
1626 \NewDocumentCommand{\tikzquads@@QuadBaseAnchors}{m}{%
1627 \savedanchor\centerpoint{%
1628 \pgfpoint{0}{0}
1629 }
1630 \anchor{center}{\centerpoint}
1631 \anchor{text}{\text}%
1632 \savedanchor{\text}{%
1633 #1
1634 \pgfpoint{\x{Tinnerleft}}{\y{Tbottom}}
1635 }
1636 \anchor{bottom left}{\bottomleft}
1637 \savedanchor{\bottomleft}{%
1638 #1
1639 \pgfpoint{\x{Tinnerleft}}{\y{Tbottom}}
1640 }
1641 \anchor{bottom center}{\bottomcenter}
1642 \savedanchor{\bottomcenter}{%
1643 #1
1644 \pgfpoint{0}{\y{Tbottom}}
1645 }
1646 \anchor{bottom right}{\bottomright}
1647 \savedanchor{\bottomright}{%
1648 #1
1649 \pgfpoint{\x{Tinnerright}}{\y{Tbottom}}
1650 }
1651 \anchor{inner bottom left}{\innerbottomleft}
1652 \savedanchor{\innerbottomleft}{%
1653 #1
1654 \pgfpoint{\x{Tinnerleft}}{\y{Tinnerbottom}}
1655 }
1656 \anchor{inner bottom center}{\innerbottomcenter}%
1657 \savedanchor{\innerbottomcenter}{%
1658 #1
1659 \pgfpoint{0}{\y{Tinnerbottom}}
1660 }
1661 \anchor{inner bottom right}{\innerbottomright}%
1662 \savedanchor{\innerbottomright}{%
1663 #1
1664 \pgfpoint{\x{Tinnerright}}{\y{Tinnerbottom}}
1665 }
1666 \anchor{top left}{\topleft}%
1667 \savedanchor{\topleft}{%
1668 #1
1669 \pgfpoint{\x{Tinnerleft}}{-\y{Tbottom}}
1670 }
1671 \anchor{top center}{\topcenter}%
1672 \savedanchor{\topcenter}{%
1673 #1
1674 \pgfpoint{0}{-\y{Tbottom}}
1675 }
1676 \anchor{top right}{\topright}%
1677 \savedanchor{\topright}{%
1678 #1
1679 \pgfpoint{\x{Tinnerright}}{-\y{Tbottom}}
1680 }
1681 \anchor{inner top left}{\innertopleft}%
1682 \savedanchor{\innertopleft}{%
1683 #1
1684 \pgfpoint{\x{Tinnerleft}}{-\y{Tinnerbottom}}
1685 }
1686 \anchor{inner top center}{\innertopcenter}%
1687 \savedanchor{\innertopcenter}{%
1688 #1
1689 \pgfpoint{0}{-\y{Tinnerbottom}}
1690 }
1691 \anchor{inner top right}{\innertopright}%
1692 \savedanchor{\innertopright}{%
1693 #1
1694 \pgfpoint{\x{Tinnerright}}{-\y{Tinnerbottom}}
1695 }
1696 \anchor{west}{\west}%
1697 \savedanchor{\west}{%
1698 #1
1699 \pgfpoint{\x{outerleft}}{\y{center}}
1700 }
1701 \anchor{east}{\east}%
1702 \savedanchor{\east}{%
1703 #1
1704 \pgfpoint{\x{outerright}}{\y{center}}
1705 }
1706 \anchor{north}{\north}%
1707 \savedanchor{\north}{%
1708 #1
1709 \pgfpoint{\x{center}}{\y{outertop}}
1710 }
1711 \anchor{north west}{\northwest}%
1712 \savedanchor{\northwest}{%
1713 #1
1714 \pgfpoint{\x{outerleft}}{\y{outertop}}
1715 }
1716 \anchor{north east}{\northeast}%
1717 \savedanchor{\northeast}{%
1718 #1
1719 \pgfpoint{\x{outerright}}{\y{outertop}}
1720 }
1721 \anchor{south}{\south}%
1722 \savedanchor{\south}{%
1723 #1
1724 \pgfpoint{\x{center}}{\y{outerbottom}}
1725 }
1726 \anchor{south west}{\southwest}%
1727 \savedanchor{\southwest}{%
1728 #1
1729 \pgfpoint{\x{outerleft}}{\y{outerbottom}}
1730 }
1731 \anchor{south east}{\southeast}%
1732 \savedanchor{\southeast}{%
1733 #1
1734 \pgfpoint{\x{outerright}}{\y{outerbottom}}
1735 }
1736 \anchor{1+}{\NodeA}
1737 \savedanchor{\NodeA}{%
1738 #1
1739 \pgfpoint{\x{outerleft}}{\y{innertop}}
1740 }
1741 \anchor{1-}{\NodeB}
1742 \savedanchor{\NodeB}{%
1743 #1
1744 \pgfpoint{\x{outerleft}}{\y{innerbottom}}
1745 }
1746 \anchor{inner 1+}{\NodeAi}
1747 \savedanchor{\NodeAi}{%
1748 #1
1749 \pgfpoint{\x{innerleft}}{\y{innertop}}
1750 }
1751 \anchor{inner 1-}{\NodeBi}
1752 \savedanchor{\NodeBi}{%
1753 #1
1754 \pgfpoint{\x{innerleft}}{\y{innerbottom}}
1755 }
1756 }
1757
1758
1759 %%%%%%%%%%%%%%%%%%%
1760 %%%
1761 %%% the Quadripole Base shape itself. Just a box with the external currents and voltages marked.
1762 %%%
1763 %%%%%%%%%%%%%%%%%%%
1764 \pgfdeclareshape{Quad shape}{%
1765 %
1766 \tikzquads@@QuadBaseAnchors{\tikzquads@@QuadPoints}
1767 %
1768 \anchor{2+}{\NodeC}
1769 \savedanchor{\NodeC}{%
1770 \tikzquads@@QuadPoints
1771 \pgfpoint{\x{outerright}}{\y{innertop}}
1772 }
1773 \anchor{2-}{\NodeD}
1774 \savedanchor{\NodeD}{%
1775 \tikzquads@@QuadPoints
1776 \pgfpoint{\x{outerright}}{\y{innerbottom}}
1777 }
1778 \anchor{inner 2+}{\NodeCi}
1779 \savedanchor{\NodeCi}{%
1780 \tikzquads@@QuadPoints
1781 \pgfpoint{\x{innerright}}{\y{innertop}}
1782 }
1783 \anchor{inner 2-}{\NodeDi}
1784 \savedanchor{\NodeDi}{%
1785 \tikzquads@@QuadPoints
1786 \pgfpoint{\x{innerright}}{\y{innerbottom}}
1787 }
1788 %
1789 \behindbackgroundpath{% this is new
1790 \tikzquads@@QuadPoints
1791 \SearchValueOf{QuadKeys}{outer ext}{\@@outerext}
1792 \SearchValueOf{QuadKeys}{minussign len}{\@@minussignlen}
1793 \SearchValueOf{QuadKeys}{plussign len}{\@@plussignlen}
1794 %
1795 \pgfpathmoveto{\pgfpoint{\x{left}}{\y{bottom}}}
1796 \pgfpathlineto{\pgfpoint{\x{left}}{\y{top}}}
1797 \pgfpathlineto{\pgfpoint{\x{right}}{\y{top}}}
1798 \pgfpathlineto{\pgfpoint{\x{right}}{\y{bottom}}}
1799 \pgfpathlineto{\pgfpoint{\x{left}}{\y{bottom}}}
1800 \pgfpathmoveto{\pgfpoint{\x{outerleft}}{\y{innerbottom}}}
1801 \pgfpathlineto{\pgfpoint{\x{innerleft}}{\y{innerbottom}}}
1802 \pgfpathmoveto{\pgfpoint{-\x{outerleft}}{\y{innerbottom}}}
1803 \pgfpathlineto{\pgfpoint{-\x{innerleft}}{\y{innerbottom}}}
1804 \pgfpathmoveto{\pgfpoint{\x{outerleft}}{\y{innertop}}}
1805 \pgfpathlineto{\pgfpoint{\x{innerleft}}{\y{innertop}}}
1806 \pgfpathmoveto{\pgfpoint{-\x{outerleft}}{\y{innertop}}}
1807 \pgfpathlineto{\pgfpoint{-\x{innerleft}}{\y{innertop}}}
1808 \tikzquads@@plussignat[\@@plussignlen/2]{\x{outerleft}+\@@outerext/2}{\y{innertop}-\@@outerext/2}
1809 \tikzquads@@minussignat[\@@minussignlen/2]{\x{outerleft}+\@@outerext/2}{\y{innerbottom}+\@@outerext/2}
1810 \tikzquads@@plussignat[\@@plussignlen/2]{-\x{outerleft}-\@@outerext/2}{\y{innertop}-\@@outerext/2}
1811 \tikzquads@@minussignat[\@@minussignlen/2]{-\x{outerleft}-\@@outerext/2}{\y{innerbottom}+\@@outerext/2}
1812 \pgfusepath{draw}
1813 \tikzquads@@arrowtipat{0}{\x{outerleft}+\@@outerext/2}{\y{innertop}}
1814 \tikzquads@@arrowtipat{180}{-\x{outerleft}-\@@outerext/2}{\y{innertop}}
1815 \pgfusepath{draw,fill}
1816 %
1817 \iftoggle{tikzquads@@toggle@innermarks}{%
1818 {%
1819 \pgftransformshift{\pgfpoint{-\x{innerleft}}{\y{innertop}}}
1820 \pgfnode{circ}{center}{}{}{}
1821 }
1822 {%
1823 \pgftransformshift{\pgfpoint{\x{innerleft}}{\y{innertop}}}
1824 \pgfnode{circ}{center}{}{}{}
1825 }
1826 {%
1827 \pgftransformshift{\pgfpoint{\x{innerleft}}{\y{innerbottom}}}
1828 \pgfnode{circ}{center}{}{}{}
1829 }
1830 {%
1831 \pgftransformshift{\pgfpoint{-\x{innerleft}}{\y{innerbottom}}}
1832 \pgfnode{circ}{center}{}{}{}
1833 }
1834 }{}
1835 %
1836 \iftoggle{tikzquads@@toggle@outermarks}{
1837 {%
1838 \pgftransformshift{\pgfpoint{-\x{outerleft}}{\y{innertop}}}
1839 \pgfnode{circ}{center}{}{}{}
1840 }
1841 {%
1842 \pgftransformshift{\pgfpoint{\x{outerleft}}{\y{innertop}}}
1843 \pgfnode{circ}{center}{}{}{}
1844 }
1845 {%
1846 \pgftransformshift{\pgfpoint{\x{outerleft}}{\y{innerbottom}}}
1847 \pgfnode{circ}{center}{}{}{}
1848 }
1849 {%
1850 \pgftransformshift{\pgfpoint{-\x{outerleft}}{\y{innerbottom}}}
1851 \pgfnode{circ}{center}{}{}{}
1852 }
1853 }{}
1854 %
1855 {%
1856 \pgfsetdash{{0.8pt}{1pt}{0.2pt}{1pt}}{0pt}
1857 \pgfsetlinewidth{0.5\pgflinewidth}
1858 \pgfpathmoveto{\pgfpoint{-\x{refA}}{\y{innerbottom}}}
1859 \pgfpathlineto{\pgfpoint{\x{refA}}{\y{innerbottom}}}
1860 \pgfusepath{draw}
1861 }
1862 \SearchValueOf{QuadKeys}{I1}{\@@IA}
1863 \SearchValueOf{QuadKeys}{I2}{\@@IB}
1864 \SearchValueOf{QuadKeys}{V1}{\@@VA}
1865 \SearchValueOf{QuadKeys}{V2}{\@@VB}
1866 %
1867 \iftoggle{tikzquads@@toggle@inverted}{%
1868 \pgftransformresetnontranslations
1869 \pgftext[bottom,right,at={\pgfpoint{\x{left}-0.4ex}{\y{innertop}+0.8ex}}]{\@@IB}
1870 \pgftext[bottom,left,at={\pgfpoint{\x{right}+0.4ex}{\y{innertop}+0.8ex}}]{\@@IA}
1871 \pgftext[left,x=\x{right}+0.4ex]{\@@VA}
1872 \pgftext[right,x=\x{left}-0.4ex]{\@@VB}
1873 }{%
1874 %\pgftransformresetnontranslations %might be added, changes nothing if nothing scaled/rotated.
1875 \pgftext[bottom,left,at={\pgfpoint{\x{right}+0.4ex}{\y{innertop}+0.8ex}}]{\@@IB}
1876 \pgftext[bottom,right,at={\pgfpoint{\x{left}-0.4ex}{\y{innertop}+0.8ex}}]{\@@IA}
1877 \pgftext[right,x=\x{left}-0.4ex]{\@@VA}
1878 \pgftext[left,x=\x{right}+0.4ex]{\@@VB}
1879 }
1880 \SearchValueOf{QuadKeys}{label top left}{\@@Ltl}
1881 \SearchValueOf{QuadKeys}{label top center}{\@@Ltc}
1882 \SearchValueOf{QuadKeys}{label top right}{\@@Ltr}
1883 \SearchValueOf{QuadKeys}{label inner top left}{\@@Litl}
1884 \SearchValueOf{QuadKeys}{label inner top center}{\@@Litc}
1885 \SearchValueOf{QuadKeys}{label inner top right}{\@@Litr}
1886 %
1887 \SearchValueOf{QuadKeys}{label bottom left}{\@@Lbl}
1888 \SearchValueOf{QuadKeys}{label bottom center}{\@@Lbc}
1889 \SearchValueOf{QuadKeys}{label bottom right}{\@@Lbr}
1890 \SearchValueOf{QuadKeys}{label inner bottom left}{\@@Libl}
1891 \SearchValueOf{QuadKeys}{label inner bottom center}{\@@Libc}
1892 \SearchValueOf{QuadKeys}{label inner bottom right}{\@@Libr}
1893 {%
1894 \iftoggle{tikzquads@@toggle@inverted}{ \pgftransformresetnontranslations }{}
1895 \pgftext[top,left,at={\pgfpoint{\x{Tinnerleft}}{\y{Ttop}}}]{\@@Ltl}
1896 \pgftext[top,center,at={\pgfpoint{\x{Tcenter}}{\y{Ttop}}}]{\@@Ltc}
1897 \pgftext[top,right,at={\pgfpoint{\x{Tinnerright}}{\y{Ttop}}}]{\@@Ltr}
1898 %
1899 \pgftext[top,left,at={\pgfpoint{\x{Tinnerleft}}{\y{Tinnertop}}}]{\@@Litl}
1900 \pgftext[top,center,at={\pgfpoint{\x{Tcenter}}{\y{Tinnertop}}}]{\@@Litc}
1901 \pgftext[top,right,at={\pgfpoint{\x{Tinnerright}}{\y{Tinnertop}}}]{\@@Litr}
1902 %
1903 \pgftext[bottom,left,at={\pgfpoint{\x{Tinnerleft}}{\y{Tbottom}}}]{\@@Lbl}
1904 \pgftext[bottom,center,at={\pgfpoint{\x{Tcenter}}{\y{Tbottom}}}]{\@@Lbc}
1905 \pgftext[bottom,right,at={\pgfpoint{\x{Tinnerright}}{\y{Tbottom}}}]{\@@Lbr}
1906 %
1907 \pgftext[bottom,left,at={\pgfpoint{\x{Tinnerleft}}{\y{Tinnerbottom}}}]{\@@Libl}
1908 \pgftext[bottom,center,at={\pgfpoint{\x{Tcenter}}{\y{Tinnerbottom}}}]{\@@Libc}
1909 \pgftext[bottom,right,at={\pgfpoint{\x{Tinnerright}}{\y{Tinnerbottom}}}]{\@@Libr}
1910 %
1911 }
1912 }
1913 \backgroundpath{ \iftoggle{tikzquads@@toggle@inverted}{\pgftransformresetnontranslations}{} }
1914 }
1915
1916
1917
1918 %%%%%%%%%%%%%%%%%%%
1919 %%%
1920 %%% the Z Quadripole shape itself.
1921 %%%
1922 %%%%%%%%%%%%%%%%%%%
1923 \pgfdeclareshape{Quad Z shape}{%
1924 \inheritsavedanchors[from=Quad shape]
1925 \foreach \anchor in {north,center,west,east,south,north west,north east,south west, south east,
1926 text,bottom left,bottom right,bottom center, inner bottom left, inner bottom right, inner bottom center,
1927 top left,top right,top center, inner top left, inner top right, inner top center,
1928 1+,2+,1-,2-, inner 1+, inner 2+, inner 1-, inner 2-}{%
1929 \inheritanchor[from=Quad shape]{\anchor}}
1930 \inheritbehindbackgroundpath[from=Quad shape]
1931 \backgroundpath{%
1932 \tikzquads@@QuadPoints
1933 \tikzquads@@Zside{Z11}{Z12}{I2}{}
1934 \tikzquads@@Zside{Z22}{Z21}{I1}{-}
1935 \iftoggle{tikzquads@@toggle@inverted}{\pgftransformresetnontranslations}{}
1936 }
1937 }
1938
1939
1940
1941 %%%%%%%%%%%%%%%%%%%
1942 %%%
1943 %%% the Y Quadripole shape itself.
1944 %%%
1945 %%%%%%%%%%%%%%%%%%%
1946 \pgfdeclareshape{Quad Y shape}{%
1947 \inheritsavedanchors[from=Quad shape]
1948 \foreach \anchor in {north,center,west,east,south,north west,north east,south west, south east,
1949 text,bottom left,bottom right,bottom center, inner bottom left, inner bottom right, inner bottom center,
1950 top left,top right,top center, inner top left, inner top right, inner top center,
1951 1+,2+,1-,2-, inner 1+, inner 2+, inner 1-, inner 2-}{%
1952 \inheritanchor[from=Quad shape]{\anchor}}
1953 \inheritbehindbackgroundpath[from=Quad shape]
1954 \backgroundpath{%
1955 \tikzquads@@QuadPoints
1956 \tikzquads@@Yside{Y11}{Y12}{V2}{}
1957 \tikzquads@@Yside{Y22}{Y21}{V1}{-}
1958 \iftoggle{tikzquads@@toggle@inverted}{\pgftransformresetnontranslations}{}
1959 }
1960 }
1961
1962
1963 %%%%%%%%%%%%%%%%%%%
1964 %%%
1965 %%% the H Quadripole shape itself.
1966 %%%
1967 %%%%%%%%%%%%%%%%%%%
1968 \pgfdeclareshape{Quad H shape}{%
1969 \inheritsavedanchors[from=Quad shape]
1970 \foreach \anchor in {north,center,west,east,south,north west,north east,south west, south east,
1971 text,bottom left,bottom right,bottom center, inner bottom left, inner bottom right, inner bottom center,
1972 top left,top right,top center, inner top left, inner top right, inner top center,
1973 1+,2+,1-,2-, inner 1+, inner 2+, inner 1-, inner 2-}{%
1974 \inheritanchor[from=Quad shape]{\anchor}}
1975 \inheritbehindbackgroundpath[from=Quad shape]
1976 \backgroundpath{%
1977 \tikzquads@@QuadPoints
1978 \tikzquads@@Zside{H11}{H12}{V2}{}
1979 \tikzquads@@Yside{H22}{H21}{I1}{-}
1980 \iftoggle{tikzquads@@toggle@inverted}{\pgftransformresetnontranslations}{}
1981 }
1982 }
1983
1984 %%%%%%%%%%%%%%%%%%%
1985 %%%
1986 %%% the G Quadripole shape itself.
1987 %%%
1988 %%%%%%%%%%%%%%%%%%%
1989 \pgfdeclareshape{Quad G shape}{%
1990 \inheritsavedanchors[from=Quad shape]
1991 \foreach \anchor in {north,center,west,east,south,north west,north east,south west, south east,
1992 text,bottom left,bottom right,bottom center, inner bottom left, inner bottom right, inner bottom center,
1993 top left,top right,top center, inner top left, inner top right, inner top center,
1994 1+,2+,1-,2-, inner 1+, inner 2+, inner 1-, inner 2-}{%
1995 \inheritanchor[from=Quad shape]{\anchor}}
1996 \inheritbehindbackgroundpath[from=Quad shape]
1997 \backgroundpath{%
1998 \tikzquads@@QuadPoints
1999 \tikzquads@@Yside{G11}{G12}{I2}{}
2000 \tikzquads@@Zside{G22}{G21}{V1}{-}
2001 \iftoggle{tikzquads@@toggle@inverted}{\pgftransformresetnontranslations}{}
2002 }
2003 }
2004
2005
2006 %%%%%%%%%%%%%%%%%%%
2007 %%%
2008 %%% the BB (Black Box) is just a 'single sided' Quad
2009 %%%
2010 %%%%%%%%%%%%%%%%%%%
2011 %%%%%%%%%%%%%%%%%%%
2012 %%%
2013 %%% Coordinates for a Black Box
2014 %%%
2015 %%%%%%%%%%%%%%%%%%%
2016 %\newcommand{\tikzquads@@BBPoints}{%
2017 \NewDocumentCommand{\tikzquads@@BBPoints}{}{%
2018 \SearchValueOf{QuadKeys}{outer ext}{\@@outerext}
2019 \SearchValueOf{QuadKeys}{inner ext}{\@@innerext}
2020 \SearchValueOf{QuadKeys}{half base height}{\@@halfbaseheight}
2021 \SearchValueOf{QuadKeys}{half base width}{\@@halfbasewidth}
2022 \SearchValueOf{QuadKeys}{height ext}{\@@heightext}
2023 \tikzmath{%
2024 real \x,\y;
2025 \x{center}=0;
2026 \y{center}=0;
2027 \x{right}=0 + \@@halfbasewidth;
2028 \y{top}=0 +( \@@halfbaseheight + \@@heightext);
2029 %
2030 \x{left}=0 - \@@halfbasewidth;
2031 \y{bottom}=0 -( \@@halfbaseheight + \@@heightext);
2032 %
2033 \y{innerbottom}=0 - \@@halfbaseheight;
2034 \y{innertop}=0 + \@@halfbaseheight;
2035 %
2036 \y{outerbottom}=\y{bottom} - 0.5*\@@outerext;
2037 \y{outertop}=\y{top} + 0.5*\@@outerext;
2038 %
2039 \x{outerleft}=\x{left} - \@@outerext;
2040 \x{innerleft}=\x{left} + \@@innerext;
2041 %
2042 \x{outerright}=\x{right} + \@@outerext;
2043 \x{innerright}=\x{right} - \@@innerext;
2044 %
2045 \x{refC}=0 + 0.3*\@@halfbasewidth;
2046 \x{refB}=(\x{innerleft}+\x{refC})/2; %center point for Res shape
2047 \x{refA}=(2*\x{innerleft}+\x{refC})/3; %'center' point for Y.Res shape
2048 %
2049 \y{Tbottom}=\y{bottom} + 0.65ex;
2050 \x{Tinnerleft}=\x{innerleft} ;
2051 \y{Tinnerbottom}=\y{innerbottom} + 0.95ex;
2052 \x{Tinnerright}=\x{innerright};
2053 \x{Tcenter}=0;
2054 %
2055 \y{Ttop}=\y{top} - 0.65ex;
2056 \y{Tinnertop}=\y{innertop} - 0.95ex;
2057 }
2058 }
2059
2060
2061 %%%%%%%%%%%%%%%%%%%
2062 %%%
2063 %%% the base shape for a one port 'black box'. Just the box plus the external current/voltage marked
2064 %%%
2065 %%%%%%%%%%%%%%%%%%%
2066 \pgfdeclareshape{BB shape}{%
2067 \tikzquads@@QuadBaseAnchors{\tikzquads@@BBPoints}
2068 \behindbackgroundpath{%
2069 \tikzquads@@BBPoints
2070 \SearchValueOf{QuadKeys}{outer ext}{\@@outerext}
2071 \SearchValueOf{QuadKeys}{plussign len}{\@@plussignlen}
2072 \SearchValueOf{QuadKeys}{minussign len}{\@@minussignlen}
2073 \pgfpathmoveto{\pgfpoint{\x{left}}{\y{bottom}}}
2074 \pgfpathlineto{\pgfpoint{\x{left}}{\y{top}}}
2075 \pgfpathlineto{\pgfpoint{\x{right}}{\y{top}}}
2076 \pgfpathlineto{\pgfpoint{\x{right}}{\y{bottom}}}
2077 \pgfpathlineto{\pgfpoint{\x{left}}{\y{bottom}}}
2078 \pgfpathmoveto{\pgfpoint{\x{outerleft}}{\y{innerbottom}}}
2079 \pgfpathlineto{\pgfpoint{\x{innerleft}}{\y{innerbottom}}}
2080 \pgfpathmoveto{\pgfpoint{\x{outerleft}}{\y{innertop}}}
2081 \pgfpathlineto{\pgfpoint{\x{innerleft}}{\y{innertop}}}
2082 \tikzquads@@plussignat[\@@plussignlen/2]{\x{outerleft}+\@@outerext/2}{\y{innertop}-\@@outerext/2}
2083 \tikzquads@@minussignat[\@@minussignlen/2]{\x{outerleft}+\@@outerext/2}{\y{innerbottom}+\@@outerext/2}
2084 \pgfusepath{draw}
2085 \tikzquads@@arrowtipat{180}{\x{outerleft}+\@@outerext/2}{\y{innertop}}
2086 \pgfusepath{draw,fill}
2087 %
2088 \iftoggle{tikzquads@@toggle@innermarks}{
2089 {%
2090 \pgftransformshift{\pgfpoint{\x{innerleft}}{\y{innertop}}}
2091 \pgfnode{circ}{center}{}{}{}
2092 }
2093 {%
2094 \pgftransformshift{\pgfpoint{\x{innerleft}}{\y{innerbottom}}}
2095 \pgfnode{circ}{center}{}{}{}
2096 }
2097 }{}
2098 %
2099 \iftoggle{tikzquads@@toggle@outermarks}{
2100 {%
2101 \pgftransformshift{\pgfpoint{\x{outerleft}}{\y{innertop}}}
2102 \pgfnode{circ}{center}{}{}{}
2103 }
2104 {%
2105 \pgftransformshift{\pgfpoint{\x{outerleft}}{\y{innerbottom}}}
2106 \pgfnode{circ}{center}{}{}{}
2107 }
2108 }{}
2109 %
2110 \SearchValueOf{QuadKeys}{I1}{\@@IA}
2111 \SearchValueOf{QuadKeys}{V1}{\@@VA}
2112 %
2113 \iftoggle{tikzquads@@toggle@inverted}{
2114 \pgftransformresetnontranslations
2115 \pgftext[bottom,left,at={\pgfpoint{\x{right}+0.4ex}{\y{innertop}+0.8ex}}]{\@@IA}
2116 \pgftext[left,x=\x{right}+0.4ex]{\@@VA}
2117 }{%
2118 \pgftext[bottom,right,at={\pgfpoint{\x{left}-0.4ex}{\y{innertop}+0.8ex}}]{\@@IA}
2119 \pgftext[right,x=\x{left}-0.4ex]{\@@VA}
2120 }
2121 \SearchValueOf{QuadKeys}{label top left}{\@@Ltl}
2122 \SearchValueOf{QuadKeys}{label top center}{\@@Ltc}
2123 \SearchValueOf{QuadKeys}{label top right}{\@@Ltr}
2124 \SearchValueOf{QuadKeys}{label inner top left}{\@@Litl}
2125 \SearchValueOf{QuadKeys}{label inner top center}{\@@Litc}
2126 \SearchValueOf{QuadKeys}{label inner top right}{\@@Litr}
2127 %
2128 \SearchValueOf{QuadKeys}{label bottom left}{\@@Lbl}
2129 \SearchValueOf{QuadKeys}{label bottom center}{\@@Lbc}
2130 \SearchValueOf{QuadKeys}{label bottom right}{\@@Lbr}
2131 \SearchValueOf{QuadKeys}{label inner bottom left}{\@@Libl}
2132 \SearchValueOf{QuadKeys}{label inner bottom center}{\@@Libc}
2133 \SearchValueOf{QuadKeys}{label inner bottom right}{\@@Libr}
2134 {%
2135 \iftoggle{tikzquads@@toggle@inverted}{ \pgftransformresetnontranslations }{}
2136 \pgftext[top,left,at={\pgfpoint{\x{Tinnerleft}}{\y{Ttop}}}]{\@@Ltl}
2137 \pgftext[top,center,at={\pgfpoint{\x{Tcenter}}{\y{Ttop}}}]{\@@Ltc}
2138 \pgftext[top,right,at={\pgfpoint{\x{Tinnerright}}{\y{Ttop}}}]{\@@Ltr}
2139 %
2140 \pgftext[top,left,at={\pgfpoint{\x{Tinnerleft}}{\y{Tinnertop}}}]{\@@Litl}
2141 \pgftext[top,center,at={\pgfpoint{\x{Tcenter}}{\y{Tinnertop}}}]{\@@Litc}
2142 \pgftext[top,right,at={\pgfpoint{\x{Tinnerright}}{\y{Tinnertop}}}]{\@@Litr}
2143 %
2144 \pgftext[bottom,left,at={\pgfpoint{\x{Tinnerleft}}{\y{Tbottom}}}]{\@@Lbl}
2145 \pgftext[bottom,center,at={\pgfpoint{\x{Tcenter}}{\y{Tbottom}}}]{\@@Lbc}
2146 \pgftext[bottom,right,at={\pgfpoint{\x{Tinnerright}}{\y{Tbottom}}}]{\@@Lbr}
2147 %
2148 \pgftext[bottom,left,at={\pgfpoint{\x{Tinnerleft}}{\y{Tinnerbottom}}}]{\@@Libl}
2149 \pgftext[bottom,center,at={\pgfpoint{\x{Tcenter}}{\y{Tinnerbottom}}}]{\@@Libc}
2150 \pgftext[bottom,right,at={\pgfpoint{\x{Tinnerright}}{\y{Tinnerbottom}}}]{\@@Libr}
2151 %
2152 }
2153 \pgfusepath{draw}
2154 }
2155 \backgroundpath{}
2156 }
2157
2158
2159 %%%%%%%%%%%%%%%%%%%
2160 %%%
2161 %%% A 'Thevenin' circuit inside a black box.
2162 %%%
2163 %%%%%%%%%%%%%%%%%%%
2164 \pgfdeclareshape{TheveninBB shape}{%
2165 \inheritsavedanchors[from=BB shape]
2166 \foreach \anchor in {north,center,west,east,south,north west,north east,south west, south east,
2167 text,bottom left,bottom right,bottom center, inner bottom left, inner bottom right, inner bottom center,
2168 top left,top right,top center, inner top left, inner top right, inner top center,
2169 1+,1-, inner 1+, inner 1-}{%
2170 \inheritanchor[from=BB shape]{\anchor}}
2171 \inheritbehindbackgroundpath[from=BB shape]
2172 \backgroundpath{%
2173 \tikzquads@@BBPoints
2174 \tikzquads@@Zside{Zth}{Vth}{none}{}
2175 \iftoggle{tikzquads@@toggle@inverted}{\pgftransformresetnontranslations}{}
2176 }
2177 }
2178
2179
2180 %%%%%%%%%%%%%%%%%%%
2181 %%%
2182 %%% A 'Norton' circuit inside a black box.
2183 %%%
2184 %%%%%%%%%%%%%%%%%%%
2185 \pgfdeclareshape{NortonBB shape}{%
2186 \inheritsavedanchors[from=BB shape]
2187 \foreach \anchor in {north,center,west,east,south,north west,north east,south west, south east,
2188 text,bottom left,bottom right,bottom center, inner bottom left, inner bottom right, inner bottom center,
2189 top left,top right,top center, inner top left, inner top right, inner top center,
2190 1+,1-, inner 1+, inner 1-}{%
2191 \inheritanchor[from=BB shape]{\anchor}}
2192 \inheritbehindbackgroundpath[from=BB shape]
2193 \backgroundpath{%
2194 \tikzquads@@BBPoints
2195 \tikzquads@@Yside[IsourceUP shape]{Yn}{In}{none}{}
2196 \iftoggle{tikzquads@@toggle@inverted}{\pgftransformresetnontranslations}{}
2197 }
2198 }
2199
2200
2201
2202
2203 %%%%%%%%%%%%%%%%%%%
2204 %%%
2205 %%% A Pseudo-Graph is just that, a crude representantion of a graph, out-of-scale.
2206 %%%
2207 %%%%%%%%%%%%%%%%%%%
2208 %%%%%%%%%%%%%%%%%%%
2209 %%%
2210 %%% Coordinates for a Pseudo-Graph shape
2211 %%%
2212 %%%%%%%%%%%%%%%%%%%
2213 %\newcommand{\tikzquads@@PGPoints}{%
2214 \NewDocumentCommand{\tikzquads@@PGPoints}{}{%
2215 \SearchValueOf{PGKeys}{outer sep}{\@@outersep}
2216 \SearchValueOf{PGKeys}{half base width}{\@@halfbasewidth}
2217 \SearchValueOf{PGKeys}{half base height}{\@@halfbaseheight}
2218 \tikzmath{%
2219 real \x,\y;
2220 \x{center}=0;
2221 \y{center}=0;
2222 \x{right}=\@@halfbasewidth + \@@outersep;
2223 \x{left}= 0-\x{right};
2224 \y{top}=+( \@@halfbaseheight + \@@outersep);
2225 \y{bottom}=0-\y{top};
2226 %
2227 \x{axisright}=\@@halfbasewidth;
2228 \x{axisleft}=0-\x{right};
2229 \y{axistop}=+\@@halfbaseheight;
2230 \y{axisbottom}=0-\y{top};
2231 %
2232 \y{Cbottom}=0.6*\y{axisbottom};
2233 \y{Ctop}=0-\y{Cbottom};
2234 %
2235 \x{Cleft}=0.6*\x{axisleft};
2236 \x{Cright}=-\x{Cleft};
2237 %
2238 \y{innerbottom}=0.8*\y{axisbottom};
2239 \y{innertop}=0-\y{innerbottom};
2240 %
2241 \x{innerleft}=0.8*\x{axisleft};
2242 \x{innerright}=-\x{innerleft};
2243 %
2244 }
2245 }
2246
2247
2248 %%%%%%%%%%%%%%%%%%%
2249 %%%
2250 %%% Base Anchors for a PseudoGraph like shape
2251 %%%
2252 %%%%%%%%%%%%%%%%%%%
2253 %\newcommand{\tikzquads@@PGBaseAnchors}[1]{%
2254 \NewDocumentCommand{\tikzquads@@PGBaseAnchors}{m}{%
2255 \savedanchor\centerpoint{
2256 \pgfpoint{0}{0}
2257 }
2258 \anchor{center}{\centerpoint}
2259 \anchor{text}{\text}%
2260 \savedanchor{\text}{%
2261 #1
2262 \pgfpoint{\x{center}}{\y{center}}
2263 }
2264 \anchor{west}{\west}%
2265 \savedanchor{\west}{%
2266 #1
2267 \pgfpoint{\x{left}}{\y{center}}
2268 }
2269 \anchor{east}{\east}%
2270 \savedanchor{\east}{%
2271 #1
2272 \pgfpoint{\x{right}}{\y{center}}
2273 }
2274 \anchor{north}{\north}%
2275 \savedanchor{\north}{%
2276 #1
2277 \pgfpoint{\x{center}}{\y{top}}
2278 }
2279 \anchor{south}{\south}%
2280 \savedanchor{\south}{%
2281 #1
2282 \pgfpoint{\x{center}}{\y{bottom}}
2283 }
2284 \anchor{north west}{\northwest}%
2285 \savedanchor{\northwest}{%
2286 #1
2287 \pgfpoint{\x{left}}{\y{top}}
2288 }
2289 \anchor{north east}{\northeast}%
2290 \savedanchor{\northeast}{%
2291 #1
2292 \pgfpoint{\x{right}}{\y{top}}
2293 }
2294 \anchor{south west}{\southwest}%
2295 \savedanchor{\southwest}{%
2296 #1
2297 \pgfpoint{\x{left}}{\y{bottom}}
2298 }
2299 \anchor{south east}{\southeast}%
2300 \savedanchor{\southeast}{%
2301 #1
2302 \pgfpoint{\x{right}}{\y{bottom}}
2303 }
2304 }
2305
2306 %%%%%%%%%%%%%%%%%%%
2307 %%%
2308 %%% Base shape for a source like shape
2309 %%%
2310 %%%%%%%%%%%%%%%%%%%
2311 \pgfdeclareshape{Base PG shape}{%
2312 \tikzquads@@PGBaseAnchors{\tikzquads@@PGPoints}
2313 \backgroundpath{%
2314 }
2315 }
2316
2317
2318 %%%%%%%%%%%%%%%%%%%
2319 %%%
2320 %%% currente source shape, arrow pointing up. either round or diamond
2321 %%%
2322 %%%%%%%%%%%%%%%%%%%
2323 \newdimen\tikzquads@@pgflinewidth
2324 \pgfdeclareshape{PG linear load line shape}{%
2325 \inheritsavedanchors[from=Base PG shape]
2326 \foreach \anchor in {north,north west,north east,center,west,east,
2327 ,south,south west,south east,text}{%
2328 \inheritanchor[from=Base PG shape]{\anchor}}
2329 \backgroundpath{%
2330 \begin{pgfscope}
2331 \tikzquads@@PGPoints
2332 \tikzquads@@pgflinewidth=\pgflinewidth
2333 \SearchValueOf{QuadKeys}{thickness}{\@@tmpthickness}
2334 \pgfsetlinewidth{\@@tmpthickness\pgflinewidth}
2335 \pgfsetroundcap
2336 \pgfkeys{\tikzquads@@PGKeysPath/@PGPoints}
2337 \pgfpathmoveto{\pgfpoint{\x{axisleft}}{\y{Xaxispos}}}
2338 \pgfpathlineto{\pgfpoint{\x{axisright}}{\y{Xaxispos}}}
2339 %
2340 \pgfpathmoveto{\pgfpoint{\x{Yaxispos}}{\y{axisbottom}}}
2341 \pgfpathlineto{\pgfpoint{\x{Yaxispos}}{\y{axistop}}}
2342 \pgfusepath{stroke}
2343 \tikzquads@@arrowtipat{0}{\x{axisright}}{\y{Xaxispos}}
2344 \tikzquads@@arrowtipat{90}{\x{Yaxispos}}{\y{axistop}}
2345 \pgfusepath{stroke,fill}
2346 \pgfsetlinewidth{\tikzquads@@pgflinewidth}
2347 \pgfpathmoveto{\pgfpoint{\x{coordA}}{\y{coordA}}}
2348 \pgfpathlineto{\pgfpoint{\x{coordB}}{\y{coordB}}}
2349 \pgfusepath{stroke}
2350 \SearchValueOf{PGKeys}{x axis}{\@@Xaxis}
2351 \SearchValueOf{PGKeys}{x val}{\@@Xval}
2352 \SearchValueOf{PGKeys}{y axis}{\@@Yaxis}
2353 \SearchValueOf{PGKeys}{y val}{\@@Yval}
2354 \pgftext[\tikzquads@@PG@XaxisTanchor,at=\pgfpoint{\x{axisright}}{\y{TXaxiscoord}}]{\@@Xaxis}
2355 \pgftext[\tikzquads@@PG@XvalTanchor,at=\pgfpoint{\x{TXvalcoord}}{\y{TXvalcoord}}]{\@@Xval}
2356 \pgftext[\tikzquads@@PG@YaxisTanchor,at=\pgfpoint{\x{TYaxiscoord}}{\y{axistop}}]{\@@Yaxis}
2357 \pgftext[\tikzquads@@PG@YvalTanchor,at=\pgfpoint{\x{TYvalcoord}}{\y{TYvalcoord}}]{\@@Yval}
2358 \end{pgfscope}
2359 }
2360 }
2361