diff options
author | Norbert Preining <preining@logic.at> | 2021-04-05 22:35:56 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2021-04-05 22:35:56 +0000 |
commit | 88be3061db22405869f48992f1213b4ea7d3e613 (patch) | |
tree | 397f08a57073d04c891be956cb58109d3d9f1ed3 /Master/texmf-dist/tex/generic/circuitikz | |
parent | 18e239ac567c87e530280dfa6f07dfaf0e3d6a59 (diff) |
circuitikz (6apr21)
git-svn-id: svn://tug.org/texlive/trunk@58757 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/circuitikz')
4 files changed, 156 insertions, 32 deletions
diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcirc.defines.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcirc.defines.tex index b22da300eff..218f3777827 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcirc.defines.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcirc.defines.tex @@ -67,7 +67,9 @@ \newdimen \pgfstartlinewidth %%>>> -% arrow tips, ported over old arrows library (deprecated)%<<<1 +% arrow tips macros and utilities %<<<1 + +% the default arrow is latexslim, which has been ported over old arrows library (deprecated) % see https://tex.stackexchange.com/questions/234084/latex-arrow-tip-with-arrows-meta-library % this was the original definition of latex' tips, renamed to avoid clashes % @@ -99,6 +101,36 @@ } \pgfarrowsdeclarereversed{latexslim reversed}{latexslim reversed}{latexslim}{latexslim} + +% select the arrows using available defaults. +\def\pgfcirc@arrow@default{default} +% choose the arrows to use. Use #2 and #3 if the key is equal to "default" +% arguments: type, default start, default end +\def\pgfcirc@set@arrows#1#2#3{% + \pgfkeysifdefined{\circuitikzbasekey/#1 start arrow}% + {\edef\@@start{\ctikzvalof{#1 start arrow}}}% + {\edef\@@start{\pgfcirc@arrow@default}} + \pgfkeysifdefined{\circuitikzbasekey/#1 end arrow}% + {\edef\@@end{\ctikzvalof{#1 end arrow}}}% + {\edef\@@end{\pgfcirc@arrow@default}} + \ifx\@@start\pgfcirc@arrow@default + \pgfsetarrowsstart{#2}% + \else + \pgfsetarrowsstart{\@@start}% + \fi + \ifx\@@end\pgfcirc@arrow@default + \pgfsetarrowsend{#3}% + \else + \pgfsetarrowsend{\@@end}% + \fi +} + +\def\pgf@circ@declare@family@arrows#1{% + \ctikzset{#1 start arrow/.initial={default}} + \ctikzset{#1 end arrow/.initial={default}} + \tikzset{#1 start arrow/.style={\circuitikzbasekey/#1 start arrow={##1}}} + \tikzset{#1 end arrow/.style={\circuitikzbasekey/#1 end arrow={##1}}} +} %%>>> %% Macros to do things depending on the class%<<<1 diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcircbipoles.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcircbipoles.tex index 5a4d5b0d288..78dd1379fbe 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcircbipoles.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcircbipoles.tex @@ -13,6 +13,18 @@ %% Standard bipole shapes declarations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Generic macro and flags for bipoles %<<< +% Fixing tunable directions +\newif\ifpgf@circ@fixtunable@dir +\ctikzset{bipoles/fix tunable direction/.is if=pgf@circ@fixtunable@dir} +\ctikzset{bipoles/fix tunable direction=true} +% choosing several arrows +\pgf@circ@declare@family@arrows{tunable} +\pgf@circ@declare@family@arrows{wiper} +\pgf@circ@declare@family@arrows{switch} +%>>> + + %%%%%%%%%%%%%%%%%%%%%%%% % Resistive components: generics, resistors, wires %%%%%%%%%%%%%%%%%%%%%%%% @@ -104,6 +116,7 @@ \ctikzset{bipoles/multiwire/spacing/.initial=0.05} % crossing wires \ctikzset{bipoles/crossing/size/.initial=.2} + %%>>> %% Shapes for generic, resistives and wires components %<<< @@ -269,9 +282,14 @@ \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} \pgf@circ@draworfill \pgfscope - \pgfsetarrowsend{latexslim} - \pgfpathmoveto{\pgfpoint{.5\pgf@circ@res@left}{\pgf@circ@res@up}} - \pgfpathlineto{\pgfpoint{-.5\pgf@circ@res@left}{\pgf@circ@res@down}} + \pgfcirc@set@arrows{tunable}{}{latexslim} + \ifpgf@circ@fixtunable@dir + \pgfpathmoveto{\pgfpoint{.5\pgf@circ@res@left}{\pgf@circ@res@down}} + \pgfpathlineto{\pgfpoint{-.5\pgf@circ@res@left}{\pgf@circ@res@up}} + \else + \pgfpathmoveto{\pgfpoint{.5\pgf@circ@res@left}{\pgf@circ@res@up}} + \pgfpathlineto{\pgfpoint{-.5\pgf@circ@res@left}{\pgf@circ@res@down}} + \fi \pgfusepath{draw} \endpgfscope } @@ -493,7 +511,7 @@ \endpgfscope \pgfscope %\pgfsetlinewidth{\pgfstartlinewidth} - \pgfsetarrowsend{latexslim} + \pgfcirc@set@arrows{wiper}{}{latexslim} \pgfextractx{\pgf@circ@res@other}{\wiper} \pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{-\pgf@circ@res@down}} @@ -501,7 +519,7 @@ \endpgfscope } -%% Zig zag resistores +%% Zig-zag resistors \def\pgf@circ@zigzag#1{% \divide \pgf@circ@res@step by \numexpr4*\zigs\relax @@ -561,9 +579,14 @@ \pgf@circ@zigzag{.5} \pgfscope - \pgfsetarrowsend{latexslim} - \pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@other}{\pgf@circ@res@up}} - \pgfpathlineto{\pgfpoint{-.4\pgf@circ@res@other}{\pgf@circ@res@down}} + \pgfcirc@set@arrows{tunable}{}{latexslim} + \ifpgf@circ@fixtunable@dir + \pgfpathmoveto{\pgfpoint{-.4\pgf@circ@res@other}{\pgf@circ@res@down}} + \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@other}{\pgf@circ@res@up}} + \else + \pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@other}{\pgf@circ@res@up}} + \pgfpathlineto{\pgfpoint{-.4\pgf@circ@res@other}{\pgf@circ@res@down}} + \fi \pgfusepath{draw} \endpgfscope } @@ -594,7 +617,7 @@ \pgfscope %\pgfsetlinewidth{\pgfstartlinewidth} - \pgfsetarrowsend{latexslim} + \pgfcirc@set@arrows{wiper}{}{latexslim} \pgfextractx{\pgf@circ@res@other}{\wiper} \pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{-\pgf@circ@res@down}} @@ -857,9 +880,14 @@ \pgfusepath{draw} \pgfscope - \pgfsetarrowsend{latexslim} - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}} + \pgfcirc@set@arrows{tunable}{}{latexslim} + \ifpgf@circ@fixtunable@dir + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}} + \else + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}} + \fi \pgfusepath{draw} \endpgfscope @@ -967,6 +995,18 @@ \pgfkeys{/tikz/twolineschoke/.add code={}{\pgf@circuit@bipole@twolineschoketrue}} \ctikzset{twolineschoke/.add code={}{\pgf@circuit@bipole@twolineschoketrue}} % +% generic core anchor settings +\ctikzset{bipoles/inductors/core distance/.initial={2pt}} +\def\pgfcir@basic@core@anchors{% + \saveddimen{\coredistance}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{bipoles/inductors/core distance}}} + \anchor{core east}{% + \northeast\advance\pgf@y by\coredistance + } + \anchor{core west}{% + \northeast\advance\pgf@y by\coredistance\pgf@x=-\pgf@x + } +} +% \ctikzset{bipoles/americaninductor/height/.initial=.3} \ctikzset{bipoles/americaninductor/height 2/.initial=.1} \ctikzset{bipoles/americaninductor/width/.initial=.8} @@ -1013,7 +1053,8 @@ } } \anchor{midtap}{\midtap} -} + \pgfcir@basic@core@anchors + } {\ctikzvalof{bipoles/cuteinductor/lower coil height}} {cuteinductor} {\ctikzvalof{bipoles/cuteinductor/height}} @@ -1056,6 +1097,7 @@ } \anchor{midtap}{\midtap} \pgfcirc@border@extend@full{1}{2}{1.6}{2.6} + \pgfcir@basic@core@anchors } {\ctikzvalof{bipoles/cuteinductor/lower coil height}} {scuteinductor} @@ -1158,6 +1200,13 @@ } } \anchor{midtap}{\midtap} + \saveddimen{\coredistance}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{bipoles/inductors/core distance}}} + \anchor{core east}{% + \northeast\pgf@y=0.5\pgf@y\advance\pgf@y by\coredistance + } + \anchor{core west}{% + \northeast\pgf@y=0.5\pgf@y\advance\pgf@y by\coredistance\pgf@x=-\pgf@x + } } {\ctikzvalof{bipoles/vcuteinductor/lower coil height}} {vcuteinductor} @@ -1175,7 +1224,7 @@ {(\ctikzvalof{bipoles/vcuteinductor/width}*\scaledRlen+\pgfhorizontaltransformationadjustment\pgflinewidth+(\ctikzvalof{bipoles/vcuteinductor/coils}-1)*2*\pgf@circ@res@other)/\ctikzvalof{bipoles/vcuteinductor/coils}/2} \pgfscope - \pgfsetarrowsend{latexslim} + \pgfcirc@set@arrows{tunable}{}{latexslim} \pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@left}{\pgf@circ@res@down}} \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@right}{\pgf@circ@res@up}} \pgfusepath{draw} @@ -1206,6 +1255,7 @@ } } \anchor{midtap}{\midtap} + \pgfcir@basic@core@anchors } {\ctikzvalof{bipoles/americaninductor/height 2}} {americaninductor} @@ -1246,6 +1296,7 @@ } \anchor{midtap}{\midtap} \pgfcirc@border@extend@full{1}{2}{1.6}{2.6} + \pgfcir@basic@core@anchors } {\ctikzvalof{bipoles/americaninductor/height 2}} {samericaninductor} @@ -1289,6 +1340,13 @@ } } \anchor{midtap}{\midtap} + \saveddimen{\coredistance}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{bipoles/inductors/core distance}}} + \anchor{core east}{% + \northeast\pgf@y=0.5\pgf@y\advance\pgf@y by\coredistance + } + \anchor{core west}{% + \northeast\pgf@y=0.5\pgf@y\advance\pgf@y by\coredistance\pgf@x=-\pgf@x + } } {\ctikzvalof{bipoles/vamericaninductor/height 2}} {vamericaninductor} @@ -1313,7 +1371,7 @@ \pgfusepath{stroke} \pgfscope - \pgfsetarrowsend{latexslim} + \pgfcirc@set@arrows{tunable}{}{latexslim} \pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@left}{\pgf@circ@res@down}} \pgfpathlineto{\pgfpoint{-.4\pgf@circ@res@left}{\pgf@circ@res@up}} \pgfusepath{draw} @@ -1324,6 +1382,7 @@ \pgfcircdeclarebipolescaled{inductors} { \anchor{midtap}{\northeast\pgf@x=0pt\relax} + \pgfcir@basic@core@anchors } {\ctikzvalof{bipoles/fullgeneric/height}} {fullgeneric} @@ -1342,6 +1401,7 @@ \anchor{label}{\southwest\pgf@x=0.4\pgf@x\pgf@y=2\pgf@y}% \anchor{midtap}{\northeast\pgf@x=0pt\relax} \pgfcirc@border@extend@full{1}{2}{1}{2} + \pgfcir@basic@core@anchors } {\ctikzvalof{bipoles/fullgeneric/height}} {sfullgeneric} @@ -1364,6 +1424,13 @@ \pgfcircdeclarebipolescaled{inductors} { \anchor{midtap}{\northeast\pgf@x=0pt\relax} + \saveddimen{\coredistance}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{bipoles/inductors/core distance}}} + \anchor{core east}{% + \northeast\pgf@y=0.4\pgf@y\advance\pgf@y by \coredistance + } + \anchor{core west}{% + \northeast\pgf@y=0.4\pgf@y\advance\pgf@y by \coredistance\pgf@x=-\pgf@x + } } {\ctikzvalof{bipoles/tfullgeneric/height}} {tfullgeneric} @@ -1378,9 +1445,14 @@ \pgfusepath{draw,fill} \pgfscope - \pgfsetarrowsend{latexslim} - \pgfpathmoveto{\pgfpoint{.5\pgf@circ@res@left}{\pgf@circ@res@up}} - \pgfpathlineto{\pgfpoint{-.5\pgf@circ@res@left}{\pgf@circ@res@down}} + \pgfcirc@set@arrows{tunable}{}{latexslim} + \ifpgf@circ@fixtunable@dir + \pgfpathmoveto{\pgfpoint{.5\pgf@circ@res@left}{\pgf@circ@res@down}} + \pgfpathlineto{\pgfpoint{-.5\pgf@circ@res@left}{\pgf@circ@res@up}} + \else + \pgfpathmoveto{\pgfpoint{.5\pgf@circ@res@left}{\pgf@circ@res@up}} + \pgfpathlineto{\pgfpoint{-.5\pgf@circ@res@left}{\pgf@circ@res@down}} + \fi \pgfusepath{draw} \endpgfscope } @@ -3777,7 +3849,7 @@ \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} \pgfpathmoveto{\pgfpointpolar{90}{1.2\pgf@circ@res@right}} \pgfpatharc{90}{-20}{1.2\pgf@circ@res@right} - \pgfsetarrowsend{latexslim} + \pgfcirc@set@arrows{switch}{}{latexslim} \pgfsetbeveljoin \pgfusepath{draw} \endpgfscope @@ -3801,7 +3873,7 @@ \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} \pgfpathmoveto{\pgfpointpolar{-10}{1.2\pgf@circ@res@right}} \pgfpatharc{-10}{90}{1.2\pgf@circ@res@right} - \pgfsetarrowsend{latexslim} + \pgfcirc@set@arrows{switch}{}{latexslim} \pgfsetbeveljoin \pgfusepath{draw} \endpgfscope @@ -4059,7 +4131,7 @@ \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} % in node \pgfpathmoveto{\pgfpointpolar{70}{1.2\pgf@circ@res@right}} \pgfpatharc{70}{-10}{1.2\pgf@circ@res@right} - \pgfsetarrowsend{latexslim} + \pgfcirc@set@arrows{switch}{}{latexslim} \pgfusepath{draw} } @@ -4071,7 +4143,7 @@ \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} % in node \pgfpathmoveto{\pgfpointpolar{-10}{1.2\pgf@circ@res@right}} \pgfpatharc{-10}{60}{1.2\pgf@circ@res@right} - \pgfsetarrowsend{latexslim} + \pgfcirc@set@arrows{switch}{}{latexslim} \pgfusepath{draw} } @@ -4358,7 +4430,7 @@ \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} % in node \pgfpathmoveto{\pgfpointpolar{70}{1.5\pgf@circ@res@right}} \pgfpatharc{70}{-50}{1.5\pgf@circ@res@right} - \pgfsetarrowsend{latexslim} + \pgfcirc@set@arrows{switch}{}{latexslim} \pgfusepath{draw} } @@ -4367,10 +4439,9 @@ { \pgf@circ@setlinewidth{bipoles}{\pgflinewidth} \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} % in node - \pgfsetarrowsstart{latexslim} + \pgfcirc@set@arrows{switch}{latexslim}{latexslim} \pgfpathmoveto{\pgfpointpolar{-60}{1.5\pgf@circ@res@right}} \pgfpatharc{-60}{60}{1.5\pgf@circ@res@right} - \pgfsetarrowsend{latexslim} \pgfusepath{draw} } @@ -4381,7 +4452,7 @@ \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} % in node \pgfpathmoveto{\pgfpointpolar{-50}{1.5\pgf@circ@res@right}} \pgfpatharc{-50}{70}{1.5\pgf@circ@res@right} - \pgfsetarrowsend{latexslim} + \pgfcirc@set@arrows{switch}{}{latexslim} \pgfusepath{draw} } % %>>> diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcirclabel.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcirclabel.tex index 465f704ded7..8e2b4372c68 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcirclabel.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcirclabel.tex @@ -30,6 +30,11 @@ \ctikzset{bipole annotation style/.append style={#1}} }} +\ctikzset{label distance/.initial={0pt}} +\ctikzset{annotation distance/.initial={0pt}} +\tikzset{label distance/.code={\ctikzset{label distance={#1}}}} +\tikzset{annotation distance/.code={\ctikzset{annotation distance={#1}}}} + %% Options \ctikzset{label/.style = { l={#1} } } \ctikzset{l/.code = { @@ -182,13 +187,13 @@ % scale the distances in function of zoom, so that they are not % dependent on it but on font size. Thanks to @marmot % https://tex.stackexchange.com/a/476018/38080 - % the coeffcient is adjusted so that the distance is more or less + % the coefficient is adjusted so that the distance is more or less % the same for rotated labels and straight ones (although it will % depend on the font, so it's not exact). \pgfgettransformentries{\tmpa}{\tmpb}{\tmpc}{\tmpd}{\tmp}{\tmp}% \pgfmathsetmacro{\myscale}{sqrt(abs(\tmpa*\tmpd-\tmpb*\tmpc))}% abs should not be needed % \typeout{ROT\tmpa\space\tmpb\space\tmpc\space\tmpd\space\myscale} - \pgfmathsetlength\pgf@circ@res@temp{1.5*\pgf@circ@ls/\myscale} + \pgfmathsetlength\pgf@circ@res@temp{1.5*\pgf@circ@ls/\myscale+\ctikzvalof{#1 distance}/\myscale} \ifnum \ctikzvalof{bipole/#1/position}>0 %we need some more space for placement below, due to mid-anchor \else % we do not have <= in \ifnum... @@ -227,7 +232,7 @@ \pgfgettransformentries{\tmpa}{\tmpb}{\tmpc}{\tmpd}{\tmp}{\tmp}% \pgfmathsetmacro{\myscale}{sqrt(abs(\tmpa*\tmpd-\tmpb*\tmpc))}% abs should not be needed % \typeout{ROT\tmpa\space\tmpb\space\tmpc\space\tmpd\space\myscale} - \pgfmathsetlength\pgf@circ@res@temp{\pgf@circ@ls/\myscale} + \pgfmathsetlength\pgf@circ@res@temp{\pgf@circ@ls/\myscale+\ctikzvalof{#1 distance}/\myscale} \pgfmathadd{\pgf@circ@labanc}{90} \pgfmathround{\pgfmathresult} \def\pgf@circ@labanctext{\pgf@circ@labanc} diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex index 82b156c46d3..6acaa06aa99 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex @@ -730,13 +730,29 @@ \ifpgf@circ@rotaryarrow \pgfscope % arrow - \ifpgf@circ@rotaryarrow@ccw\pgfsetarrowsstart{latexslim}\fi + \pgfcirc@set@arrows{switch}{\ifpgf@circ@rotaryarrow@ccw latexslim\fi}{\ifpgf@circ@rotaryarrow@cw latexslim\fi} \pgf@circ@setlinewidth{bipoles}{\pgflinewidth} \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} % center of cin node \pgftransformrotate{\wiper} \pgfpathmoveto{\pgfpointpolar{50}{1.0\pgf@circ@res@right}} \pgfpatharc{50}{-50}{1.0\pgf@circ@res@right} - \ifpgf@circ@rotaryarrow@cw\pgfsetarrowsend{latexslim}\fi + \ifpgf@circ@rotaryarrow@ccw + \ifpgf@circ@rotaryarrow@cw + % both here, maintain values + \relax + \else + % only ccw: remove end arrow + \pgfsetarrowsend{} + \fi + \else + \ifpgf@circ@rotaryarrow@cw + % only cw: remove start arrow + \pgfsetarrowsstart{} + \else + % none: shouldn't happen + \relax + \fi + \fi \pgfusepath{draw} \endpgfscope \fi |