From 46664e932a29dc32f69fac4c6773c5c3da0ece8e Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 21 Jun 2020 20:42:13 +0000 Subject: circuitikz (21jun20) git-svn-id: svn://tug.org/texlive/trunk@55620 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/generic/circuitikz/pgfcirc.defines.tex | 152 +++++--- .../tex/generic/circuitikz/pgfcircbipoles.tex | 152 +++++++- .../tex/generic/circuitikz/pgfcircmultipoles.tex | 121 ++++-- .../tex/generic/circuitikz/pgfcircpath.tex | 86 ++++- .../tex/generic/circuitikz/pgfcircshapes.tex | 4 +- .../tex/generic/circuitikz/pgfcirctripoles.tex | 242 +++++++++--- .../tex/generic/circuitikz/pgfcircutils.tex | 25 +- .../tex/generic/circuitikz/pgfcircvoltage.tex | 404 +++++++++++---------- 8 files changed, 820 insertions(+), 366 deletions(-) (limited to 'Master/texmf-dist/tex/generic/circuitikz') diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcirc.defines.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcirc.defines.tex index a9499dd06aa..af70e82d753 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcirc.defines.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcirc.defines.tex @@ -438,7 +438,7 @@ \ctikzset{bipoles/loudspeaker/depth/.initial=.3} \ctikzset{bipoles/loudspeaker/width/.initial=.8} \ctikzset{bipoles/mic/height/.initial=1.2} -\ctikzset{bipoles/mic/depth/.initial=.0} +\ctikzset{bipoles/mic/depth/.initial=.1} \ctikzset{bipoles/mic/width/.initial=.8} % Zig Zag resistors @@ -722,10 +722,8 @@ \ctikzset{bipoles/open/width/.initial=.3} %necessary for curly voltages \ctikzset{bipoles/open/voltage/straight label distance/.initial=0} \ctikzset{bipoles/open/voltage/distance from node/.initial=.2} -\ctikzset{bipoles/short/height/.initial=0} %dummy height for voltage positioning -\ctikzset{bipoles/short/width/.initial=0} %dummy width for voltage positioning -%\ctikzset{bipoles/short/voltage/straight label distance/.initial=.2} -%\ctikzset{bipoles/short/voltage/distance from node/.initial=.5} +\ctikzset{bipoles/short/height/.initial=.1} %dummy height for voltage positioning +\ctikzset{bipoles/short/width/.initial=.1} %dummy width for voltage positioning % multiwire \ctikzset{bipoles/multiwire/height/.initial=0.4} \ctikzset{bipoles/multiwire/width/.initial=0.2} @@ -739,20 +737,20 @@ \ctikzset{bipoles/voltmeter/width/.initial=.60} \ctikzset{bipoles/smeter/height/.initial=.60} \ctikzset{bipoles/smeter/width/.initial=.60} -\ctikzset{bipoles/smeter/voltage/additional label shift/.initial=1} +\ctikzset{bipoles/smeter/voltage/additional shift/.initial=1} \ctikzset{bipoles/qmeter/depth/.initial=.40} \ctikzset{bipoles/qmeter/height/.initial=.80} \ctikzset{bipoles/qmeter/width/.initial=.60} % this must be specified for each one -\ctikzset{bipoles/qvprobe/voltage/additional label shift/.initial=.5} -\ctikzset{bipoles/qiprobe/voltage/additional label shift/.initial=.5} -\ctikzset{bipoles/qpprobe/voltage/additional label shift/.initial=.5} +\ctikzset{bipoles/qvprobe/voltage/additional shift/.initial=.5} +\ctikzset{bipoles/qiprobe/voltage/additional shift/.initial=.5} +\ctikzset{bipoles/qpprobe/voltage/additional shift/.initial=.5} \ctikzset{bipoles/iloop/width/.initial=.40} \ctikzset{bipoles/iloop/height/.initial=.60} \ctikzset{bipoles/oscope/height/.initial=.60} \ctikzset{bipoles/oscope/width/.initial=.60} -\ctikzset{bipoles/oscope/voltage/additional label shift/.initial=1} +\ctikzset{bipoles/oscope/voltage/additional shift/.initial=1} % option to not rotate the new (Romano's) instruments @@ -1207,6 +1205,7 @@ %% transistors stop here %% Logic ports +%% beware that the third option is in IEEE ports in pgfcircmultipoles.tex \newif\ifpgf@circuit@europeanlogicport \ctikzset{logic ports/.is choice} @@ -1219,6 +1218,9 @@ \tikzset{nand port/.style={shape=european nand port}}% \tikzset{nor port/.style={shape=european nor port}}% \tikzset{xnor port/.style={shape=european xnor port}}% + % there is no Schmitt ports in european style (yet) + \tikzset{schmitt port/.style={shape=schmitt}}% + \tikzset{invschmitt port/.style={shape=invschmitt}}% }} \ctikzset{logic ports/american/.code= {\pgf@circuit@europeanlogicportfalse \tikzset{and port/.style={shape=american and port}}% @@ -1229,6 +1231,8 @@ \tikzset{nand port/.style={shape=american nand port}}% \tikzset{nor port/.style={shape=american nor port}}% \tikzset{xnor port/.style={shape=american xnor port}}% + \tikzset{schmitt port/.style={shape=schmitt}}% + \tikzset{invschmitt port/.style={shape=invschmitt}}% }} \ctikzset{logic ports origin/.is choice} @@ -1272,12 +1276,26 @@ \ctikzset{american or shape/roundy/.code={\pgfcirc@roundy@or@shapestrue}} \ctikzset{american or shape/pointy/.code={\pgfcirc@roundy@or@shapesfalse}} -\newif\ifpgfcirc@draw@leads\pgfcirc@draw@leadstrue +\newif\ifpgfcirc@draw@input@leads\pgfcirc@draw@input@leadstrue \ctikzset{logic ports draw input leads/.is choice} -\ctikzset{logic ports draw input leads/true/.code={\pgfcirc@draw@leadstrue}} -\ctikzset{logic ports draw input leads/false/.code={\pgfcirc@draw@leadsfalse}} -\tikzset{input leads/.code={\pgfcirc@draw@leadstrue}} -\tikzset{no input leads/.code={\pgfcirc@draw@leadsfalse}} +\ctikzset{logic ports draw input leads/true/.code={\pgfcirc@draw@input@leadstrue}} +\ctikzset{logic ports draw input leads/false/.code={\pgfcirc@draw@input@leadsfalse}} +\tikzset{input leads/.code={\pgfcirc@draw@input@leadstrue}} +\tikzset{no input leads/.code={\pgfcirc@draw@input@leadsfalse}} + +\newif\ifpgfcirc@draw@output@leads\pgfcirc@draw@output@leadstrue +\ctikzset{logic ports draw output leads/.is choice} +\ctikzset{logic ports draw output leads/true/.code={\pgfcirc@draw@output@leadstrue}} +\ctikzset{logic ports draw output leads/false/.code={\pgfcirc@draw@output@leadsfalse}} +\tikzset{output leads/.code={\pgfcirc@draw@output@leadstrue}} +\tikzset{no output leads/.code={\pgfcirc@draw@output@leadsfalse}} + +\ctikzset{logic ports draw leads/.is choice} +\ctikzset{logic ports draw leads/true/.code={\pgfcirc@draw@output@leadstrue\pgfcirc@draw@input@leadstrue}} +\ctikzset{logic ports draw leads/false/.code={\pgfcirc@draw@output@leadsfalse\pgfcirc@draw@input@leadsfalse}} +\tikzset{all leads/.code={\pgfcirc@draw@output@leadstrue\pgfcirc@draw@input@leadstrue}} +\tikzset{no leads/.code={\pgfcirc@draw@output@leadsfalse\pgfcirc@draw@input@leadsfalse}} + \ctikzset{tripoles/american and port/width/.initial=1.1} \ctikzset{tripoles/american and port/height/.initial=.8} @@ -1869,7 +1887,7 @@ \ctikzset{voltage/american/.code = {\pgf@circuit@europeanvoltagefalse\pgf@circuit@bipole@voltage@straightfalse}} \ctikzset{voltage/european/.code = {\pgf@circuit@europeanvoltagetrue\pgf@circuit@bipole@voltage@straightfalse}} \ctikzset{voltage/straight/.code = {\pgf@circuit@europeanvoltagetrue\pgf@circuit@bipole@voltage@straighttrue}} -\ctikzset{voltage/curved/.code = {\pgf@circuit@europeanvoltagetrue\pgf@circuit@bipole@voltage@straighttrue}} +\ctikzset{voltage/curved/.code = {\pgf@circuit@europeanvoltagetrue\pgf@circuit@bipole@voltage@straightfalse}} \ctikzset{current/.is choice} \ctikzset{current/american/.code = \pgf@circuit@europeancurrentfalse} @@ -1880,61 +1898,100 @@ \ctikzset{straight/true/.code = {\pgf@circuit@bipole@voltage@straighttrue}} \ctikzset{straight/false/.code = {\pgf@circuit@bipole@voltage@straightfalse}} \ctikzset{bipole/straight/.is if=pgf@circuit@bipole@voltage@straight} -% never used, removed (RG 2020-05-17) -% \ctikzset{straightvoltage value/.initial=true} -% \ctikzset{straightvoltage/.style = {/tikz/circuitikz/straight=true}} - % % voltage is used also to set parameters, apart for the /.is choice % above. I hope it is ok --- would be a mess otherwise % - -\ctikzset{voltage/distance from node/.initial=.5} %\pgf@circ@Rlen units -\ctikzset{voltage/distance from line/.initial=.08} % pos, tra 0 e 1 -\ctikzset{voltage/bump a/.initial=1.2} -\ctikzset{voltage/bump b/.initial=1.5} \ctikzset{voltage/shift/.initial=0.0} % shift form the cable of voltage symbols \ctikzset{voltage shift/.style={voltage/shift=#1}} \tikzset{voltage shift/.style={\circuitikzbasekey/voltage/shift=#1}} -\ctikzset{voltage/european label distance/.initial=1.4} -\ctikzset{voltage/american label distance/.initial=1.1} + % shaping the +/- sign, see pgfcircvoltage.tex \ctikzset{voltage/american font/.initial={}} \ctikzset{voltage/american plus/.initial={$+$}} \ctikzset{voltage/american minus/.initial={$-$}} - +% here we start the voltage adjustments for special components. +% default values: +% +% this is the distance of the "point" marking the voltage along the line +% 0.0 is on the external nodes of the to path +% 1.0 is cramped on the object +% this can be overriden component by component +\ctikzset{voltage/distance from node/.initial=.5}% pos, 0->1 +% +% this is the distance from the line (perpendicular to) where the voltage is drawn. +% It is global, and not adjustable by component (use the "label distance" or locally +% if you need it) +\ctikzset{voltage/distance from line/.initial=.08}% in \pgf@circ@scaled@Rlen units +% +% bend paramenters for european arc. You can override them component-based +\ctikzset{voltage/bump b/.initial=1.5} +% +% generator voltages symbols or arrows (always straight) are put along the +% 60 ... 120 angles of the symbol (don't ask why). The distance here is on the +% center..angle line. It's called bump a because I don't know... +% +\ctikzset{voltage/bump a/.initial=1.2} +% +% these are the label distances FROM the drawings. +% You can override them component by component. +\ctikzset{voltage/european label distance/.initial=1.4} +\ctikzset{voltage/straight label distance/.initial=1.4} +\ctikzset{voltage/american label distance/.initial=1.4} +% +% the KIND is the node name without SHAPE +% See the definition above for meaning +% if bipoles/KIND/voltage/straight label distance is not defined, it uses the height +% if bipoles/KIND/voltage/additional shift is not defined, it is 0 (extra distance) +% % special cases for voltage positions -\ctikzset{bipoles/generic/voltage/distance from node/.initial=.4} +\ctikzset{bipoles/generic/voltage/distance from node/.initial=0.4} \ctikzset{bipoles/generic/voltage/bump b/.initial=2} -\ctikzset{bipoles/generic/voltage/european label distance/.initial=1.8} -%\ctikzset{bipoles/thermocouple/voltage/distance from node/.initial=.3} -\ctikzset{bipoles/thermocouple/voltage/bump b/.initial=2.2} -\ctikzset{bipoles/thermocouple/voltage/european label distance/.initial=1.5} +% \ctikzset{bipoles/ageneric/voltage/distance from node/.initial=.4} \ctikzset{bipoles/ageneric/voltage/bump b/.initial=2} -\ctikzset{bipoles/ageneric/voltage/european label distance/.initial=1.8} +% \ctikzset{bipoles/fullgeneric/voltage/distance from node/.initial=.4} \ctikzset{bipoles/fullgeneric/voltage/bump b/.initial=2} -\ctikzset{bipoles/fullgeneric/voltage/european label distance/.initial=1.8} +% \ctikzset{bipoles/memristor/voltage/distance from node/.initial=.4} \ctikzset{bipoles/memristor/voltage/bump b/.initial=2} -\ctikzset{bipoles/memristor/voltage/european label distance/.initial=1.8} -%\ctikzset{bipoles/tline/voltage/distance from node/.initial=.2} +% \ctikzset{bipoles/tline/voltage/bump b/.initial=2.4} -\ctikzset{bipoles/tline/voltage/european label distance/.initial=2.1} -%\ctikzset{bipoles/varistor/voltage/distance from node/.initial=.2} +% \ctikzset{bipoles/varistor/voltage/bump b/.initial=2.4} -\ctikzset{bipoles/varistor/voltage/european label distance/.initial=2} -%\ctikzset{bipoles/photoresistor/voltage/distance from node/.initial=.2} -\ctikzset{bipoles/photoresistor/voltage/bump b/.initial=2} -\ctikzset{bipoles/photoresistor/voltage/european label distance/.initial=1.8} -%\ctikzset{bipoles/thermistor/voltage/distance from node/.initial=.2} +\ctikzset{bipoles/varistor/voltage/american label distance/.initial=1.8} +% +\ctikzset{bipoles/photoresistor/voltage/bump b/.initial=1.6} +% \ctikzset{bipoles/thermistor/voltage/bump b/.initial=2.4} -\ctikzset{bipoles/thermistor/voltage/european label distance/.initial=2} -%\ctikzset{bipoles/thermistorntc/voltage/distance from node/.initial=.2} +\ctikzset{bipoles/thermistor/voltage/european label distance/.initial=0.8} \ctikzset{bipoles/thermistorntc/voltage/bump b/.initial=1.6} -%\ctikzset{bipoles/thermistorptc/voltage/distance from node/.initial=.2} +\ctikzset{bipoles/thermistorntc/voltage/european label distance/.initial=0.8} \ctikzset{bipoles/thermistorptc/voltage/bump b/.initial=1.6} +\ctikzset{bipoles/thermistorptc/voltage/european label distance/.initial=0.8} +% +\ctikzset{bipoles/ccapacitor/voltage/bump b/.initial=2.2} +% +\ctikzset{bipoles/emptyzzdiode/voltage/bump b/.initial=2.5} +\ctikzset{bipoles/emptyzzdiode/voltage/european label distance/.initial=1.0} +\ctikzset{bipoles/fullzzdiode/voltage/bump b/.initial=2.5} +\ctikzset{bipoles/fullzzdiode/voltage/european label distance/.initial=1.0} +\ctikzset{bipoles/emptythyristor/voltage/bump b/.initial=2.0} +\ctikzset{bipoles/emptythyristor/voltage/european label distance/.initial=1.2} +\ctikzset{bipoles/fullthyristor/voltage/bump b/.initial=2.0} +\ctikzset{bipoles/fullthyristor/voltage/european label distance/.initial=1.2} +\ctikzset{bipoles/emptytriac/voltage/bump b/.initial=1.8} +\ctikzset{bipoles/emptytriac/voltage/european label distance/.initial=0.8} +\ctikzset{bipoles/fulltriac/voltage/bump b/.initial=1.8} +\ctikzset{bipoles/fulltriac/voltage/european label distance/.initial=0.8} +% +\ctikzset{bipoles/short/voltage/american label distance/.initial=2.8} +\ctikzset{bipoles/open/voltage/distance from node/.initial=0.3} +% +\ctikzset{bipoles/battery/voltage/bump a/.initial=1.4} +\ctikzset{bipoles/vsourceAM/voltage/american label distance/.initial=1.2} +\ctikzset{bipoles/cvsourceAM/voltage/american label distance/.initial=1.2} % % american open voltage adjusting % @@ -1942,7 +1999,6 @@ \ctikzset{american open voltage/.is choice} \ctikzset{american open voltage/center/.code={\pgf@adjust@open@voltagetrue}} \ctikzset{american open voltage/legacy/.code={\pgf@adjust@open@voltagefalse}} - % % currents % diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcircbipoles.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcircbipoles.tex index 1e9ada97753..36ddd5d0790 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcircbipoles.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcircbipoles.tex @@ -170,16 +170,16 @@ \anchorborder{% \ifpgf@circuit@bipole@inverted \pgf@circ@res@left=-\pgf@x - \pgf@circ@res@right=-\pgf@y + \pgf@circ@res@up=-\pgf@y \else \pgf@circ@res@left=\pgf@x - \pgf@circ@res@right=\pgf@y + \pgf@circ@res@up=\pgf@y \fi - \ifdim\pgf@circ@res@right>0cm - \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@right}}{\northeastborder} + \ifdim\pgf@circ@res@up>0cm + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\northeastborder} \else \southwestborder - \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@right}}{\pgfpoint{-\pgf@x}{-\pgf@y}} + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{-\pgf@x}{-\pgf@y}} \fi } @@ -218,12 +218,34 @@ %%% NOTICE that the short is really NOT drawn; we trust the fact that its %%% natural length is zero. \pgfcircdeclarebipole -{} +{% fix the anchor border to add a bit of space for voltage and labels + % it uses the dummy width and height + \anchorborder{% + \ifpgf@circuit@bipole@inverted + \pgf@circ@res@left=-\pgf@x + \pgf@circ@res@up=-\pgf@y + \else + \pgf@circ@res@left=\pgf@x + \pgf@circ@res@up=\pgf@y + \fi + \ifdim\pgf@circ@res@up>0cm + \pgf@x=\ctikzvalof{bipoles/short/width}\pgf@circ@Rlen + \pgf@y=\ctikzvalof{bipoles/short/height}\pgf@circ@Rlen + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} + {\pgfpoint{\pgf@x}{\pgf@y}} + \else + \pgf@x=-\ctikzvalof{bipoles/short/width}\pgf@circ@Rlen + \pgf@y=-\ctikzvalof{bipoles/short/height}\pgf@circ@Rlen + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} + {\pgfpoint{-\pgf@x}{-\pgf@y}} + \fi + } +} {0} {short} {0} {0} -{ } +{} %% Open circuit \pgfcircdeclarebipole @@ -232,7 +254,7 @@ {open} {\ctikzvalof{bipoles/open/height}} {\ctikzvalof{bipoles/open/width}} -{ } +{} % multiwire(s) \pgfcircdeclarebipole @@ -2414,7 +2436,24 @@ %% Black alternative zigzag Zener diode \pgfcircdeclarebipolescaled{diodes} -{} +{% fix the anchor border + \anchorborder{% + \ifpgf@circuit@bipole@inverted + \pgf@circ@res@left=-\pgf@x + \pgf@circ@res@up=-\pgf@y + \else + \pgf@circ@res@left=\pgf@x + \pgf@circ@res@up=\pgf@y + \fi + \ifdim\pgf@circ@res@up>0cm + \northeastborder + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@x}{1.3\pgf@y}} + \else + \southwestborder + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{-\pgf@x}{-1.3\pgf@y}} + \fi + } +} {\ctikzvalof{bipoles/diode/height}} {fullzzdiode} {\ctikzvalof{bipoles/diode/height}} @@ -2540,7 +2579,24 @@ } %% Black light emitting diode \pgfcircdeclarebipolescaled{diodes} -{} +{% fix the anchor border + \anchorborder{% + \ifpgf@circuit@bipole@inverted + \pgf@circ@res@left=-\pgf@x + \pgf@circ@res@up=-\pgf@y + \else + \pgf@circ@res@left=\pgf@x + \pgf@circ@res@up=\pgf@y + \fi + \ifdim\pgf@circ@res@up>0cm + \northeastborder + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@x}{1.8\pgf@y}} + \else + \southwestborder + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{-\pgf@x}{-\pgf@y}} + \fi + } +} {\ctikzvalof{bipoles/diode/height}} {fulllediode} {\ctikzvalof{bipoles/diode/height}} @@ -2565,7 +2621,24 @@ %% Black photodiode \pgfcircdeclarebipolescaled{diodes} -{} +{% fix the anchor border + \anchorborder{% + \ifpgf@circuit@bipole@inverted + \pgf@circ@res@left=-\pgf@x + \pgf@circ@res@up=-\pgf@y + \else + \pgf@circ@res@left=\pgf@x + \pgf@circ@res@up=\pgf@y + \fi + \ifdim\pgf@circ@res@up>0cm + \northeastborder + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@x}{1.8\pgf@y}} + \else + \southwestborder + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{-\pgf@x}{-\pgf@y}} + \fi + } +} {\ctikzvalof{bipoles/diode/height}} {fullpdiode} {\ctikzvalof{bipoles/diode/height}} @@ -2671,7 +2744,24 @@ %% Empty alternative zigzag Zener diode \pgfcircdeclarebipolescaled{diodes} -{} +{% fix the anchor border + \anchorborder{% + \ifpgf@circuit@bipole@inverted + \pgf@circ@res@left=-\pgf@x + \pgf@circ@res@up=-\pgf@y + \else + \pgf@circ@res@left=\pgf@x + \pgf@circ@res@up=\pgf@y + \fi + \ifdim\pgf@circ@res@up>0cm + \northeastborder + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@x}{1.3\pgf@y}} + \else + \southwestborder + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{-\pgf@x}{-1.3\pgf@y}} + \fi + } +} {\ctikzvalof{bipoles/diode/height}} {emptyzzdiode} {\ctikzvalof{bipoles/diode/height}} @@ -2735,7 +2825,24 @@ %% Empty light emitting diode \pgfcircdeclarebipolescaled{diodes} -{} +{% fix the anchor border + \anchorborder{% + \ifpgf@circuit@bipole@inverted + \pgf@circ@res@left=-\pgf@x + \pgf@circ@res@up=-\pgf@y + \else + \pgf@circ@res@left=\pgf@x + \pgf@circ@res@up=\pgf@y + \fi + \ifdim\pgf@circ@res@up>0cm + \northeastborder + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@x}{1.8\pgf@y}} + \else + \southwestborder + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{-\pgf@x}{-\pgf@y}} + \fi + } +} {\ctikzvalof{bipoles/diode/height}} {emptylediode} {\ctikzvalof{bipoles/diode/height}} @@ -2755,7 +2862,24 @@ %% Empty photodiode \pgfcircdeclarebipolescaled{diodes} -{} +{% fix the anchor border + \anchorborder{% + \ifpgf@circuit@bipole@inverted + \pgf@circ@res@left=-\pgf@x + \pgf@circ@res@up=-\pgf@y + \else + \pgf@circ@res@left=\pgf@x + \pgf@circ@res@up=\pgf@y + \fi + \ifdim\pgf@circ@res@up>0cm + \northeastborder + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@x}{1.8\pgf@y}} + \else + \southwestborder + \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{-\pgf@x}{-\pgf@y}} + \fi + } +} {\ctikzvalof{bipoles/diode/height}} {emptypdiode} {\ctikzvalof{bipoles/diode/height}} diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex index a023e058d39..ed5399d441d 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex @@ -1229,6 +1229,11 @@ % draw "inverting" circles on outputs, they must be last % \pgfscope + \ifpgf@circuit@ieeelogicport + \def\@@notcirc{notcirc} + \else + \def\@@notcirc{ocirc} + \fi \pgfsetlinewidth{\ctikzvalof{multipoles/external pins thickness}\pgflinewidth} \pgf@circ@count@a=\numpins\relax \divide\pgf@circ@count@a by 2 \pgf@circ@count@b=\pgf@circ@count@a @@ -1239,14 +1244,14 @@ \edef\@@tmp{\ctikzvalof{multipoles/flipflop/n\the\pgf@circ@count@c}} \ifnum\@@tmp>0\pgfscope \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfnode{ocirc}{east}{}{\thisshape-N\the\pgf@circ@count@c}{\pgfusepath{stroke}} + \pgfnode{\@@notcirc}{east}{}{\thisshape-N\the\pgf@circ@count@c}{\pgfusepath{stroke}} \endpgfscope\fi % right side pins \pgf@circ@count@c=\numexpr2*\pgf@circ@count@b-\pgf@circ@count@a+1\relax \edef\@@tmp{\ctikzvalof{multipoles/flipflop/n\the\pgf@circ@count@c}} \ifnum\@@tmp>0\pgfscope \pgftransformshift{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfnode{ocirc}{west}{}{\thisshape-N\the\pgf@circ@count@c}{\pgfusepath{stroke}} + \pgfnode{\@@notcirc}{west}{}{\thisshape-N\the\pgf@circ@count@c}{\pgfusepath{stroke}} \endpgfscope\fi \advance\pgf@circ@count@a by -1\relax% \repeatpgfmathloop @@ -1254,13 +1259,13 @@ \edef\@@tmp{\ctikzvalof{multipoles/flipflop/nu}} \ifnum\@@tmp>0\pgfscope \pgftransformshift{\pgfpoint{0pt}{\pgf@circ@res@up}} - \pgfnode{ocirc}{south}{}{\thisshape-Nu}{\pgfusepath{stroke}} + \pgfnode{\@@notcirc}{south}{}{\thisshape-Nu}{\pgfusepath{stroke}} \endpgfscope\fi % down side \edef\@@tmp{\ctikzvalof{multipoles/flipflop/nd}} \ifnum\@@tmp>0\pgfscope \pgftransformshift{\pgfpoint{0pt}{\pgf@circ@res@down}} - \pgfnode{ocirc}{north}{}{\thisshape-Nd}{\pgfusepath{stroke}} + \pgfnode{\@@notcirc}{north}{}{\thisshape-Nd}{\pgfusepath{stroke}} \endpgfscope\fi \endpgfscope }% @@ -1431,7 +1436,7 @@ \pgf@circ@draworfill \endpgfscope % now we have to draw the pins, if needed - \ifdim\extshift>0pt\ifpgfcirc@draw@leads\pgfscope % let's avoid too much indent + \ifdim\extshift>0pt\ifpgfcirc@draw@input@leads\pgfscope % let's avoid too much indent % Ok, we have to draw the leads (a.k.a. pins) \pgfsetlinewidth{\ctikzvalof{multipoles/external pins thickness}\pgflinewidth} % We mimic the anchors here --- probably there is a better way @@ -1814,7 +1819,11 @@ % % integrate with the other logic ports % -\ctikzset{logic ports/ieee/.code= {\pgf@circuit@europeanlogicportfalse +% +\newif\ifpgf@circuit@ieeelogicport\pgf@circuit@ieeelogicportfalse +\ctikzset{logic ports/ieee/.code= {% + \pgf@circuit@ieeelogicporttrue + \pgf@circuit@europeanlogicportfalse \tikzset{and port/.style={shape=ieeestd and port}}% \tikzset{or port/.style={shape=ieeestd or port}}% \tikzset{xor port/.style={shape=ieeestd xor port}}% @@ -1824,8 +1833,11 @@ \tikzset{nor port/.style={shape=ieeestd nor port}}% \tikzset{xnor port/.style={shape=ieeestd xnor port}}% \tikzset{schmitt port/.style={shape=ieeestd schmitt port}}% - \tikzset{inv schmitt port/.style={shape=ieeestd schmitt port}}% + \tikzset{invschmitt port/.style={shape=ieeestd invschmitt port}}% }} +% add code to be compatible with the other ports +\ctikzset{logic ports/european/.add code={\pgf@circuit@ieeelogicportfalse}} +\ctikzset{logic ports/american/.add code={\pgf@circuit@ieeelogicportfalse}} \tikzset{ieee ports/.style = {\circuitikzbasekey/logic ports = ieee}} % % the base angle for the or port. See the drawings. This will not change with height @@ -2244,9 +2256,11 @@ \pgfextractx{\pgf@circ@res@other}{\bodyright} %body border, without "not" ball \advance\pgf@circ@res@other by \pinlen\relax \ifdim \pgf@circ@res@other > \pgf@circ@res@right - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} - \pgfusepath{draw} + \ifpgfcirc@draw@output@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} + \pgfusepath{draw} + \fi \fi \ifnum #3=1\relax\pgfscope \pgftransformshift{\pgfpoint{\pgf@circ@res@right}{0pt}} @@ -2270,7 +2284,7 @@ \pgfmathsetlength{\pgf@circ@res@temp}{\pgf@circ@res@up+0.5*\pind} \pgfextractx{\pgf@circ@res@left}{\bodyleft} \pgfextracty{\pgf@circ@res@down}{\bodyleft} - \ifpgfcirc@draw@leads + \ifpgfcirc@draw@input@leads %input leads --- all the same for AND ports \loop\ifnum\pgf@circ@count@a>0 \advance\pgf@circ@res@temp by -\pind @@ -2318,7 +2332,7 @@ % Find the pins on the rack; they are 1... \pgf@circ@count@b=\numexpr (\inputs - \inners)/2\relax % =K; numexpr rounds up! \pgf@circ@count@c=\numexpr \inputs - \pgf@circ@count@b +1 \relax % =inputs - K +1 - \ifpgfcirc@draw@leads + \ifpgfcirc@draw@input@leads %input leads --- for or ports \loop\ifnum\pgf@circ@count@a>0 \pgfextractx{\pgf@circ@res@right}{\topleft} @@ -2490,10 +2504,7 @@ \anchor{body right}{\bodyright\pgf@y=0pt} \anchor{right}{\bottomright\pgf@y=0pt} \anchor{body left}{\bodyleft\pgf@y=0pt}% central edge of the body - \anchor{left}{% central edge of the component - \pgf@circ@ieeestd@xorbar% save \xorbar in temp - \bodyleft\pgf@y=0pt\advance\pgf@x by -\pgf@circ@res@temp - } + \anchor{left}{\bodyleft\pgf@y=0pt} \anchor{up}{% \bodyleft \pgf@y=+0.5\pgf@y\pgf@x=0pt @@ -2502,7 +2513,57 @@ \bodyleft \pgf@y=-0.5\pgf@y\pgf@x=0pt } - + % this is for when it's used as a bipole + % we use the enclosing rectangle (see below) + \anchorborder{% + %% This (commented out) is the correct border anchor. But if we use the correct + %% border anchor there is no horizontal space for the label ;-) because + %% the triangle is too steep. So we will use a simple square border + %% + %% find the border anchor of a triangle (like a not port or an + %% amplifier) --- + %% + %% -----^ up + %% I --- | + %% I -|-- + %%left I | --- right + %% ----I-----|-------I----- + %% + %% + %\pgf@xa=\pgf@x + %% it's simmetrical w/ vertical side, use only positive y + %\pgfmathsetmacro{\@@switchy}{ifthenelse(\pgf@y>0,1,-1)} + %\pgfmathsetlength{\pgf@ya}{abs(\pgf@y)} + %\pgfextracty{\pgf@circ@res@up}{\bodyleft} + %\pgfextractx{\pgf@circ@res@left}{\bodyleft} + %\pgfextractx{\pgf@circ@res@right}{\bodyright} + %% limit angle for the left (vertical) side + %\pgfmathsetmacro{\@@phimax}{atan2(\pgf@circ@res@up,\pgf@circ@res@left)} + %\pgfmathsetmacro{\@@phi}{atan2(\pgf@ya,\pgf@xa)} + %\pgfmathsetmacro{\@@leftside}{ifthenelse(\@@phi>\@@phimax,1,0)} + %% find the border + %\ifnum\@@leftside>0 + % % vertical side + % \pgfpointborderrectangle{\pgfpoint{\pgf@xa}{\pgf@ya}} + % {\pgfpoint{-\pgf@circ@res@left}{\pgf@circ@res@up}} + %\else + % % triangle upper line + % \pgfpointintersectionoflines + % {\pgfpointorigin}{\pgfqpoint{\pgf@xa}{\pgf@ya}} + % {\pgfqpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfqpoint{\pgf@circ@res@right}{0pt}} + %\fi + %% readjust y sign + %\pgf@y=\@@switchy\pgf@y + % + % this is the square border to position the path label with a bit of horizontal space + % + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgfextracty{\pgf@circ@res@up}{\bodyleft} + \pgfextractx{\pgf@circ@res@left}{\bodyleft} + \pgfpointborderrectangle{\pgfpoint{\pgf@xa}{\pgf@ya}} + {\pgfpoint{-\pgf@circ@res@left}{\pgf@circ@res@up}} + } % geographical anchors \anchor{nw}{\northwest} \anchor{ne}{\northeast} @@ -2533,9 +2594,11 @@ \pgfextractx{\pgf@circ@res@other}{\bodyright} %body border, without "not" ball \advance\pgf@circ@res@other by \pinlen\relax \ifdim \pgf@circ@res@other > \pgf@circ@res@right - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} - \pgfusepath{draw} + \ifpgfcirc@draw@output@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} + \pgfusepath{draw} + \fi \fi \ifnum #2=1\relax\pgfscope \pgftransformshift{\pgfpoint{\pgf@circ@res@right}{0pt}} @@ -2556,9 +2619,11 @@ \pgfextracty{\pgf@circ@res@up}{\bodyleft} \pgfextractx{\pgf@circ@res@right}{\bodyright} % \draw input pin - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pinlen}{0pt}} - \pgfusepath{draw} + \ifpgfcirc@draw@input@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pinlen}{0pt}} + \pgfusepath{draw} + \fi \pgfscope \pgf@circ@setlinewidth{tripoles}{\pgflinewidth} \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} @@ -2569,14 +2634,16 @@ \endpgfscope } -\pgfcircdeclareieeebufferportpair{schmitt}{inv schmitt}{% +\pgfcircdeclareieeebufferportpair{schmitt}{invschmitt}{% \pgfextractx{\pgf@circ@res@left}{\bodyleft} \pgfextracty{\pgf@circ@res@up}{\bodyleft} \pgfextractx{\pgf@circ@res@right}{\bodyright} % \draw input pin - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pinlen}{0pt}} - \pgfusepath{draw} + \ifpgfcirc@draw@input@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pinlen}{0pt}} + \pgfusepath{draw} + \fi \pgfscope \pgf@circ@setlinewidth{tripoles}{\pgflinewidth} \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcircpath.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcircpath.tex index 6f5c89c9a4e..e6ba47b7ab7 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcircpath.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcircpath.tex @@ -69,21 +69,57 @@ } } - %% Generic bipole path -%% I am not user what the second argument is needed for \def\pgf@circ@bipole@path#1#2{ - + % Create a bipole path from the shapes defined with \pgfcircdeclarebipole + % or \pgfcircdeclarebipolescaled; the node shapes are named with a "shape" + % appended to the main (path-style) name + % #1 path-style node name + % #2 the argument passed from the to-path structure; don't touch + % + % Example: + % \def\pgf@circ@capacitor@path#1{\pgf@circ@bipole@path{capacitor}{#1}} + % + \pgf@circ@bipole@path@base{shape}{}{#1}{#2} +} +% +% this is used for components that are mainly node-style but have a path-style form +% +\def\pgfcirc@node@to@path#1#2#3{% + % add a path-style component based on a node-style one without mangling the name + % of the shape. + % #1: node-type shape name (existing) + % #2: path-type name (to be created) + % #3: additional options to add to the path style + % + \expandafter\def\csname pgf@circ@#1@path\endcsname##1{\pgf@circ@bipole@path@base{}{##1}{#1}{}}% + \compattikzset{#2/.style = {\circuitikzbasekey, + /tikz/to path=\csname pgf@circ@#1@path\endcsname{##1}, + #3}}% + \ctikzset{bipoles/#1/height/.initial=1}% +} +%% +%% ultra-generic bipole path +%% I am not sure what the last argument is needed for, but don't touch it or everything explodes +%% +\def\pgf@circ@bipole@path@base#1#2#3#4{% + % + % Create a path-style component based on a node-style shape + % #1: postfix to be added to the name path to obtain the main shape name + % #2: text to be passed as text to the node + % #3: name of the bipole component + % #4: this will be filled by the argument of the to-path + % \pgfextra{ \set@explicit@center@anchor{\tikztostart} \set@explicit@center@anchor{\tikztotarget} \pgfsyssoftpath@getcurrentpath{\myp@th}%% save current path to extend after calculation of correct start/end coordinates - \ctikzset{bipole/kind = #1} + \ctikzset{bipole/kind = #3} \edef\pgf@temp{\ctikzvalof{bipole/name}} \def\pgf@circ@temp{} \ifx\pgf@temp\pgf@circ@temp % if it has not a name \pgfmathrandominteger{\pgf@circ@rand}{1000}{9999} - \ctikzset{bipole/name = #1\pgf@circ@rand} % create it (re-usage should not create problem, but...) + \ctikzset{bipole/name = #3\pgf@circ@rand} % create it (re-usage should not create problem, but...) \fi } @@ -98,16 +134,16 @@ % \typeout{DIRECTION:\pgf@circ@direction} \pgfsyssoftpath@setcurrentpath{\myp@th} } - \pgfextra{\def\pgf@temp{open}\def\pgf@circ@temp{#1}} + \pgfextra{\def\pgf@temp{open}\def\pgf@circ@temp{#3}} \ifx\pgf@temp\pgf@circ@temp % if it is an open \else --($(\ctikzvalof{bipole/name}start) ! .5\pgflinewidth ! (\ctikzvalof{bipole/name}end)$) %ugly workaround to get correct linejoins(node breaks path?) \fi ($(\tikztostart) ! .5 ! (\tikztotarget)$)%%positio of middle node - node[#1shape, rotate=\pgf@circ@direction, yscale=\ctikzvalof{mirror value}, xscale=\ctikzvalof{invert value}] - (\ctikzvalof{bipole/name}) {} + node[#3#1, rotate=\pgf@circ@direction, yscale=\ctikzvalof{mirror value}, xscale=\ctikzvalof{invert value}] + (\ctikzvalof{bipole/name}) {#2} \ifpgf@circuit@bipole@inverted - \ifcsname pgf@anchor@#1shape@pathstart\endcsname%if special path-anchors are defined, use them! + \ifcsname pgf@anchor@#3#1@pathstart\endcsname%if special path-anchors are defined, use them! coordinate (anchorstartnode) at (\ctikzvalof{bipole/name}.pathend) coordinate (anchorendnode) at (\ctikzvalof{bipole/name}.pathstart) \else @@ -115,7 +151,7 @@ coordinate (anchorendnode) at (\ctikzvalof{bipole/name}.left) \fi \else - \ifcsname pgf@anchor@#1shape@pathstart\endcsname%if special path-anchors are defined, use them! + \ifcsname pgf@anchor@#3#1@pathstart\endcsname%if special path-anchors are defined, use them! coordinate (anchorstartnode) at (\ctikzvalof{bipole/name}.pathstart) coordinate (anchorendnode) at (\ctikzvalof{bipole/name}.pathend) \else @@ -123,7 +159,7 @@ coordinate (anchorendnode) at (\ctikzvalof{bipole/name}.right) \fi \fi - \pgfextra{\def\pgf@temp{open}\def\pgf@circ@temp{#1}} + \pgfextra{\def\pgf@temp{open}\def\pgf@circ@temp{#3}} \ifx\pgf@temp\pgf@circ@temp % if it is an open \else (\ctikzvalof{bipole/name}start.center) -- (anchorstartnode) @@ -136,7 +172,7 @@ \pgf@circ@ifkeyempty{bipole/voltage/label/name}\else\pgf@circ@drawvoltage\fi \pgf@circ@ifkeyempty{bipole/current/label/name}\else\pgf@circ@drawcurrent\fi \pgf@circ@ifkeyempty{bipole/flow/label/name}\else\pgf@circ@drawflow\fi - \pgfextra{\def\pgf@temp{open}\def\pgf@circ@temp{#1}} + \pgfextra{\def\pgf@temp{open}\def\pgf@circ@temp{#3}} \ifx\pgf@temp\pgf@circ@temp % if it is an open (\ctikzvalof{bipole/name}end)%Move to end of path \else @@ -378,7 +414,9 @@ %% Styles \def\comnpatname{\ifpgf@circuit@compat *\else\fi} -\def\compattikzset#1{\tikzset{\comnpatname#1}} +\def\compattikzset#1{% + % \typeout{BIPOLEDEF:\space \detokenize{#1}}% + \tikzset{\comnpatname#1}} %\def\ctikzsetbipole#1#2{% % \tikzset{#1/.style= {to path=#2, \circuitikzbasekey, l=##1}}% @@ -672,9 +710,9 @@ \compattikzset{dcisource/.style = {\circuitikzbasekey, /tikz/to path=\pgf@circ@dcisource@path, \circuitikzbasekey/bipole/is current=true, l=#1}} \compattikzset{ioosource/.style = {\circuitikzbasekey, \circuitikzbasekey/bipole/is current=true,/tikz/to path=\pgf@circ@oosource@path, i=#1}} -\compattikzset{voosource/.style = {\circuitikzbasekey, \circuitikzbasekey/bipole/is voltage=true,/tikz/to path=\pgf@circ@oosource@path, v=#1}} -\compattikzset{oosourcetrans/.style = {\circuitikzbasekey, \circuitikzbasekey/bipole/is voltage=true,/tikz/to path=\pgf@circ@oosourcetrans@path, v=#1}} -\compattikzset{ooosource/.style = {\circuitikzbasekey, \circuitikzbasekey/bipole/is voltage=true,/tikz/to path=\pgf@circ@ooosource@path, v=#1}} +\compattikzset{voosource/.style = {\circuitikzbasekey, \circuitikzbasekey/bipole/is voltage=true, \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true, /tikz/to path=\pgf@circ@oosource@path, v=#1}} +\compattikzset{oosourcetrans/.style = {\circuitikzbasekey, \circuitikzbasekey/bipole/is voltage=true,\circuitikzbasekey/bipole/is voltageoutsideofsymbol=true, /tikz/to path=\pgf@circ@oosourcetrans@path, v=#1}} +\compattikzset{ooosource/.style = {\circuitikzbasekey, \circuitikzbasekey/bipole/is voltage=true,\circuitikzbasekey/bipole/is voltageoutsideofsymbol=true, /tikz/to path=\pgf@circ@ooosource@path, v=#1}} \compattikzset{vsource/.style = {\comnpatname voltage source = #1}} \compattikzset{isource/.style = {\comnpatname current source = #1}} @@ -913,3 +951,19 @@ \pgf@circ@definetranspath{nigbt} \pgf@circ@definetranspath{Lpigbt} \pgf@circ@definetranspath{Lnigbt} +% +% Path-style logical ports +% +% create path-style element for one input --- one output logical ports +% +\def\pgfcirc@port@node@to@path#1#2{% + % + % add a logic port path style component --- we need to suppress leads + % and use the correct center + % + \pgfcirc@node@to@path{#1}{#2}{/tikz/no leads, \circuitikzbasekey/logic ports origin=center}% +} +\pgfcirc@port@node@to@path{not port}{inline not} +\pgfcirc@port@node@to@path{buffer port}{inline buffer} +\pgfcirc@port@node@to@path{schmitt port}{inline schmitt} +\pgfcirc@port@node@to@path{invschmitt port}{inline invschmitt} diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcircshapes.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcircshapes.tex index 823ff5b6328..966128140ef 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcircshapes.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcircshapes.tex @@ -283,7 +283,7 @@ \pgfextracty{\pgf@circ@res@up}{\northwest} \pgfpointborderrectangle {\pgfqpoint{\pgf@xa}{\pgf@ya}} - {\pgfqpoint{\pgf@circ@res@up}{\pgfqpoint{\pgf@circ@res@up}}} + {\pgfqpoint{\pgf@circ@res@up}{\pgf@circ@res@up}} } \behindforegroundpath{ \pgfscope @@ -326,7 +326,7 @@ \pgfextracty{\pgf@circ@res@up}{\northwest} \pgfpointborderrectangle {\pgfqpoint{\pgf@xa}{\pgf@ya}} - {\pgfqpoint{\pgf@circ@res@up}{\pgfqpoint{\pgf@circ@res@up}}} + {\pgfqpoint{\pgf@circ@res@up}{\pgf@circ@res@up}} } \behindforegroundpath{ \pgfscope diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcirctripoles.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcirctripoles.tex index 739373f2eb5..9b1fd385c31 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcirctripoles.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcirctripoles.tex @@ -449,7 +449,7 @@ \pgfextracty{\pgf@circ@res@temp}{\step}% \pgf@circ@res@step = \dimexpr 2\pgf@circ@res@temp -2\pgf@circ@res@up\relax \pgf@circ@res@count = \inputs\relax - \ifpgfcirc@draw@leads + \ifpgfcirc@draw@input@leads %input leads \loop\ifnum\pgf@circ@res@count>0 \advance\pgf@circ@res@temp by -\pgf@circ@res@step @@ -461,11 +461,11 @@ \repeat \fi % output lead - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} - \pgfpathlineto{\pgfpoint - {\ctikzvalof{tripoles/american and port/port width}\pgf@circ@res@right} - {0pt}} - \pgfusepath{draw} + \ifpgfcirc@draw@output@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} + \pgfpathlineto{\pgfpoint{\ctikzvalof{tripoles/american and port/port width}\pgf@circ@res@right} {0pt}} + \pgfusepath{draw} + \fi \pgf@circ@setlinewidth{tripoles}{\pgflinewidth} @@ -482,7 +482,7 @@ \pgfextracty{\pgf@circ@res@temp}{\step}% \pgf@circ@res@step = \dimexpr 2\pgf@circ@res@temp -2\pgf@circ@res@up\relax \pgf@circ@res@count = \inputs\relax - \ifpgfcirc@draw@leads + \ifpgfcirc@draw@input@leads %input leads \loop\ifnum\pgf@circ@res@count>0 \advance\pgf@circ@res@temp by -\pgf@circ@res@step @@ -494,11 +494,12 @@ \repeat \fi - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} - \pgfpathlineto{\pgfpoint - {\ctikzvalof{tripoles/american nand port/port width}\pgf@circ@res@right} {0pt}} - - \pgfusepath{draw} + \ifpgfcirc@draw@output@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} + \pgfpathlineto{\pgfpoint + {\ctikzvalof{tripoles/american nand port/port width}\pgf@circ@res@right} {0pt}} + \pgfusepath{draw} + \fi \pgf@circ@setlinewidth{tripoles}{\pgflinewidth} \pgf@circ@res@step = \ctikzvalof{tripoles/american nand port/circle width}\pgf@circ@res@right \pgf@circ@res@other = \ctikzvalof{tripoles/american nand port/port width}\pgf@circ@res@right @@ -528,7 +529,7 @@ \pgfextracty{\pgf@circ@res@temp}{\step}% \pgf@circ@res@step = \dimexpr 2\pgf@circ@res@temp -2\pgf@circ@res@up\relax \pgf@circ@res@count = \inputs\relax - \ifpgfcirc@draw@leads + \ifpgfcirc@draw@input@leads %input leads \loop\ifnum\pgf@circ@res@count>0 \advance\pgf@circ@res@temp by -\pgf@circ@res@step @@ -541,10 +542,11 @@ \fi \pgf@circ@res@other=\ctikzvalof{tripoles/american nor port/port width}\pgf@circ@res@right - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} - - \pgfusepath{draw} + \ifpgfcirc@draw@output@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} + \pgfusepath{draw} + \fi \pgf@circ@setlinewidth{tripoles}{\pgflinewidth} @@ -589,7 +591,7 @@ \pgfextracty{\pgf@circ@res@temp}{\step}% \pgf@circ@res@step = \dimexpr 2\pgf@circ@res@temp -2\pgf@circ@res@up\relax \pgf@circ@res@count = \inputs\relax - \ifpgfcirc@draw@leads + \ifpgfcirc@draw@input@leads %input leads \loop\ifnum\pgf@circ@res@count>0 \advance\pgf@circ@res@temp by -\pgf@circ@res@step @@ -602,10 +604,11 @@ \fi \pgf@circ@res@other=\ctikzvalof{tripoles/american or port/port width}\pgf@circ@res@right - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} - - \pgfusepath{draw} + \ifpgfcirc@draw@output@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} + \pgfusepath{draw} + \fi \pgf@circ@setlinewidth{tripoles}{\pgflinewidth} @@ -646,7 +649,7 @@ \pgfextracty{\pgf@circ@res@temp}{\step}% \pgf@circ@res@step = \dimexpr 2\pgf@circ@res@temp -2\pgf@circ@res@up\relax \pgf@circ@res@count = \inputs\relax - \ifpgfcirc@draw@leads + \ifpgfcirc@draw@input@leads %input leads \loop\ifnum\pgf@circ@res@count>0 \advance\pgf@circ@res@temp by -\pgf@circ@res@step @@ -660,10 +663,11 @@ \fi \pgf@circ@res@other=\ctikzvalof{tripoles/american xor port/port width}\pgf@circ@res@right - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} - - \pgfusepath{draw} + \ifpgfcirc@draw@output@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} + \pgfusepath{draw} + \fi \pgf@circ@setlinewidth{tripoles}{\pgflinewidth} @@ -710,7 +714,7 @@ \pgfextracty{\pgf@circ@res@temp}{\step}% \pgf@circ@res@step = \dimexpr 2\pgf@circ@res@temp -2\pgf@circ@res@up\relax \pgf@circ@res@count = \inputs\relax - \ifpgfcirc@draw@leads + \ifpgfcirc@draw@input@leads %input leads \loop\ifnum\pgf@circ@res@count>0 \advance\pgf@circ@res@temp by -\pgf@circ@res@step @@ -724,10 +728,11 @@ \fi \pgf@circ@res@other=\ctikzvalof{tripoles/american xnor port/port width}\pgf@circ@res@right - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} - - \pgfusepath{draw} + \ifpgfcirc@draw@output@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} + \pgfusepath{draw} + \fi \pgf@circ@setlinewidth{tripoles}{\pgflinewidth} @@ -788,8 +793,14 @@ \northwest \pgf@y=0pt } + \anchor{left}{ + \northwest + \pgf@x=0.7\pgf@x + \pgf@y=0pt + } \anchor{bin}{ \northwest + \pgf@x=0.7\pgf@x \pgf@y=0pt } \anchor{bin 1}{ @@ -802,6 +813,11 @@ \pgf@y=0pt \pgf@x=-\pgf@x } + \anchor{right}{ + \northwest + \pgf@y=0pt + \pgf@x=-0.7\pgf@x + } \anchor{bout}{ \northwest \pgf@y=0pt @@ -844,6 +860,19 @@ \pgf@x=-\pgf@x \pgf@y=-\pgf@y } + \anchorborder{% this is used when the node is used as a path element + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgfextracty{\pgf@circ@res@up}{\northwest} + \pgfextractx{\pgf@circ@res@left}{\northwest} + \pgfpointborderrectangle{\pgfpoint{\pgf@xa}{\pgf@ya}} + {\pgfpoint{-\pgf@circ@res@left}{\pgf@circ@res@up}} + } + \anchor{text}{% + % centered and a bit to the left (it's a triangle)! + \pgf@x=\dimexpr -.6\wd\pgfnodeparttextbox\relax + \pgf@y=\dimexpr.5\dp\pgfnodeparttextbox-.5\ht\pgfnodeparttextbox\relax + } \backgroundpath{ \pgfsetcolor{\ctikzvalof{color}} @@ -874,14 +903,16 @@ \pgf@circ@draworfill \endpgfscope - \ifpgfcirc@draw@leads + \ifpgfcirc@draw@input@leads %input leads \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@left}{0pt}} \fi - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} - \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{0pt}} + \ifpgfcirc@draw@output@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} + \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{0pt}} + \fi \pgfusepath{draw} } @@ -906,8 +937,14 @@ \northwest \pgf@y=0pt } + \anchor{left}{ + \northwest + \pgf@x=0.7\pgf@x + \pgf@y=0pt + } \anchor{bin}{ \northwest + \pgf@x=0.7\pgf@x \pgf@y=0pt } \anchor{bin 1}{ @@ -920,6 +957,11 @@ \pgf@y=0pt \pgf@x=-\pgf@x } + \anchor{right}{ + \northwest + \pgf@y=0pt + \pgf@x=-0.7\pgf@x + } \anchor{bout}{ \northwest \pgf@y=0pt @@ -962,6 +1004,19 @@ \pgf@x=-\pgf@x \pgf@y=-\pgf@y } + \anchorborder{% this is used when the node is used as a path element + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgfextracty{\pgf@circ@res@up}{\northwest} + \pgfextractx{\pgf@circ@res@left}{\northwest} + \pgfpointborderrectangle{\pgfpoint{\pgf@xa}{\pgf@ya}} + {\pgfpoint{-\pgf@circ@res@left}{\pgf@circ@res@up}} + } + \anchor{text}{% + % centered and a bit to the left (it's a triangle)! + \pgf@x=\dimexpr -.6\wd\pgfnodeparttextbox\relax + \pgf@y=\dimexpr.5\dp\pgfnodeparttextbox-.5\ht\pgfnodeparttextbox\relax + } \backgroundpath{ \pgfsetcolor{\ctikzvalof{color}} @@ -985,14 +1040,16 @@ \pgf@circ@draworfill \endpgfscope - \ifpgfcirc@draw@leads + \ifpgfcirc@draw@input@leads %input leads \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@left}{0pt}} \fi - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} - \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{0pt}} + \ifpgfcirc@draw@output@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} + \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{0pt}} + \fi \pgfusepath{draw} } @@ -1016,6 +1073,11 @@ \northwest \pgf@y=0pt } + \anchor{left}{ + \northwest + \pgf@y=0pt + \pgf@x=0.7\pgf@x + } \anchor{bin}{ \northwest \pgf@y=0pt @@ -1031,6 +1093,11 @@ \pgf@y=0pt \pgf@x=-\pgf@x } + \anchor{right}{ + \northwest + \pgf@y=0pt + \pgf@x=-0.7\pgf@x + } \anchor{bout}{ \northwest \pgf@y=0pt @@ -1073,6 +1140,19 @@ \pgf@x=-\pgf@x \pgf@y=-\pgf@y } + \anchorborder{% this is used when the node is used as a path element + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgfextracty{\pgf@circ@res@up}{\northwest} + \pgfextractx{\pgf@circ@res@left}{\northwest} + \pgfpointborderrectangle{\pgfpoint{\pgf@xa}{\pgf@ya}} + {\pgfpoint{-\pgf@circ@res@left}{\pgf@circ@res@up}} + } + \anchor{text}{% + % centered and a bit to the left (it's a triangle)! + \pgf@x=\dimexpr -.6\wd\pgfnodeparttextbox\relax + \pgf@y=\dimexpr.5\dp\pgfnodeparttextbox-.5\ht\pgfnodeparttextbox\relax + } \backgroundpath{ \pgfsetcolor{\ctikzvalof{color}} @@ -1103,14 +1183,16 @@ \pgf@circ@draworfill \endpgfscope - \ifpgfcirc@draw@leads + \ifpgfcirc@draw@input@leads %input leads \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@left}{0pt}} \fi - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} - \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{0pt}} + \ifpgfcirc@draw@output@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} + \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{0pt}} + \fi \pgfusepath{draw} %draw inner shape @@ -1147,6 +1229,11 @@ \northwest \pgf@y=0pt } + \anchor{left}{ + \northwest + \pgf@y=0pt + \pgf@x=0.7\pgf@x + } \anchor{bin}{ \northwest \pgf@y=0pt @@ -1162,6 +1249,11 @@ \pgf@y=0pt \pgf@x=-\pgf@x } + \anchor{right}{ + \northwest + \pgf@y=0pt + \pgf@x=-.7\pgf@x + } \anchor{bout}{ \northwest \pgf@y=0pt @@ -1204,6 +1296,19 @@ \pgf@x=-\pgf@x \pgf@y=-\pgf@y } + \anchorborder{% this is used when the node is used as a path element + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgfextracty{\pgf@circ@res@up}{\northwest} + \pgfextractx{\pgf@circ@res@left}{\northwest} + \pgfpointborderrectangle{\pgfpoint{\pgf@xa}{\pgf@ya}} + {\pgfpoint{-\pgf@circ@res@left}{\pgf@circ@res@up}} + } + \anchor{text}{% + % centered and a bit to the left (it's a triangle)! + \pgf@x=\dimexpr -.6\wd\pgfnodeparttextbox\relax + \pgf@y=\dimexpr.5\dp\pgfnodeparttextbox-.5\ht\pgfnodeparttextbox\relax + } \backgroundpath{ \pgfsetcolor{\ctikzvalof{color}} @@ -1228,14 +1333,16 @@ \pgf@circ@draworfill \endpgfscope - \ifpgfcirc@draw@leads + \ifpgfcirc@draw@input@leads %input leads \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@left}{0pt}} \fi - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} - \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right-\pgf@circ@res@other}{0pt}} + \ifpgfcirc@draw@output@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} + \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right-\pgf@circ@res@other}{0pt}} + \fi \pgfusepath{draw} %draw inner shape @@ -1282,15 +1389,21 @@ \savedmacro{\ctikzclass}{\edef\ctikzclass{logic ports}} \saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} \saveddimen{\boutshift}{% - \ifpgf@circ@european@port@circle - \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} - \edef\pgf@temp{ocirc} - \edef\pgf@circ@temp{\ctikzvalof{tripoles/european not shape}} - \ifx\pgf@temp\pgf@circ@temp % it's ocirc - \pgfmathsetlength{\pgf@x}{2*\ctikzvalof{nodes width}*\pgf@circ@Rlen} - \else % it's ieee not circ - \pgf@circ@notradius % defined together with ieeestd ports - \pgf@x=2\pgf@circ@res@temp + \edef\pgf@temp{not} + \edef\pgf@circ@temp{#4} + \ifx\pgf@temp\pgf@circ@temp % is a not + \ifpgf@circ@european@port@circle + \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} + \edef\pgf@temp{ocirc} + \edef\pgf@circ@temp{\ctikzvalof{tripoles/european not shape}} + \ifx\pgf@temp\pgf@circ@temp % it's ocirc + \pgfmathsetlength{\pgf@x}{2*\ctikzvalof{nodes width}*\pgf@circ@Rlen} + \else % it's ieee not circ + \pgf@circ@notradius % defined together with ieeestd ports + \pgf@x=2\pgf@circ@res@temp + \fi + \else + \pgf@x=0pt \fi \else \pgf@x=0pt @@ -1355,7 +1468,7 @@ \anchor{bout}{\right\advance\pgf@x by \boutshift\pgf@y=0pt} \anchor{left}{\left}% edges of component minus leads - \anchor{right}{\right} + \anchor{right}{\right\advance\pgf@x by \boutshift\pgf@y=0pt} \anchor{north east}{\northeast}% see \Compass macro \anchor{south west}{\southwest} @@ -1374,6 +1487,14 @@ \anchor{east}{\pgfextractx{\pgf@circ@res@right}{\northeast}% \pgfpoint{\pgf@circ@res@right}{0cm}} + \anchorborder{% this is used when the node is used as a path element + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgfextracty{\pgf@circ@res@up}{\northeast} + \pgfextractx{\pgf@circ@res@right}{\northeast} + \pgfpointborderrectangle{\pgfpoint{\pgf@xa}{\pgf@ya}} + {\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}} + } \backgroundpath{ \pgfsetcolor{\ctikzvalof{color}} \pgfstartlinewidth=\pgflinewidth @@ -1384,7 +1505,7 @@ {\pgfpoint{\ctikzvalof{tripoles/european #1 port/reserved}\pgf@circ@res@right}{\pgf@circ@res@down}} \pgf@circ@draworfill \endpgfscope - \ifpgfcirc@draw@leads + \ifpgfcirc@draw@input@leads %input leads \ifnum#3=1\relax \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}% @@ -1402,13 +1523,14 @@ \advance\pgf@circ@res@count by -1 \repeat \fi + \pgfusepath{draw} \fi % - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} - \pgfpathlineto{% - \pgfpoint{\ctikzvalof{tripoles/european #1 port/reserved}\pgf@circ@res@right}{0pt}} - % - \pgfusepath{draw} + \ifpgfcirc@draw@output@leads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} + \pgfpathlineto{ \pgfpoint{\ctikzvalof{tripoles/european #1 port/reserved}\pgf@circ@res@right}{0pt}} + \pgfusepath{draw} + \fi % \edef\pgf@temp{not} \edef\pgf@circ@temp{#4} diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcircutils.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcircutils.tex index 2860ef9a32d..58420725ad9 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcircutils.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcircutils.tex @@ -71,13 +71,22 @@ %% this code has been contributed by Schrödinger's cat %% https://tex.stackexchange.com/a/529159/38080 %% -\tikzset{use fpu reciprocal/.code={% -\def\pgfmathreciprocal@##1{% - \begingroup - \pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}% - \pgfmathparse{1/##1}% - \pgfmath@smuggleone\pgfmathresult - \endgroup -}}}% +%% Use the official key to use the fpu if installed, see +%% https://github.com/pgf-tikz/pgf/issues/861 +%% +%% Thanks to "muzimuzhi Z" https://tex.stackexchange.com/a/547085/38080 +%% +\pgfkeysifdefined{/pgf/fpu/install only/.@cmd}{% + \pgfqkeys{/pgf}{use fpu reciprocal/.code={\pgfkeys{/pgf/fpu/install only={reciprocal}}}}% + }{% + \pgfqkeys{/pgf}{use fpu reciprocal/.code={% + \def\pgfmathreciprocal@##1{% + \begingroup + \pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}% + \pgfmathparse{1/##1}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + }}}% +} \endinput diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcircvoltage.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcircvoltage.tex index 4ba528296d1..00fa692b0f6 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcircvoltage.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcircvoltage.tex @@ -123,62 +123,23 @@ } %% Output routine for generic bipoles +% put this to true to see the voltage label coordinate anchors +\newif\ifpgf@circ@debugv\pgf@circ@debugvfalse \def\pgf@circ@drawvoltagegeneric{ \pgfextra{ - % \typeout{NAME:\ctikzvalof{bipole/name}} - \edef\pgf@temp{/tikz/circuitikz/bipoles/\ctikzvalof{bipole/kind}/voltage/straight label distance} - \pgfkeysifdefined{\pgf@temp} - { - \edef\partheight{\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/voltage/straight label distance}} - \edef\tmpdistfromline{(\partheight\pgf@circ@scaled@Rlen)} - } - { - \pgfkeysifdefined{/tikz/circuitikz/bipoles/voltage/straight label distance} - { - \edef\partheight{\ctikzvalof{bipoles/voltage/straight label distance}} - \edef\tmpdistfromline{(\partheight\pgf@circ@scaled@Rlen)} - } - {%calculate default value from part height - \edef\pgf@temp{/tikz/circuitikz/bipoles/\ctikzvalof{bipole/kind}/height} - \pgfkeysifdefined{\pgf@temp} - { - \edef\partheight{0.5*\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/height}} - \edef\tmpdistfromline{(\partheight\pgf@circ@scaled@Rlen+0.2\pgf@circ@scaled@Rlen)} - } - { - \edef\tmpdistfromline{(.5\pgf@circ@scaled@Rlen)} %fallback to fixed value - } - } - } % \typeout{KIND:\ctikzvalof{bipole/kind}\space RLEN:\the\pgf@circ@Rlen\space SCALED:\the\pgf@circ@scaled@Rlen} \ifnum \ctikzvalof{mirror value}=-1 - \ifpgf@circuit@bipole@inverted - \ifpgf@circuit@bipole@voltage@straight - \def\distfromline{\tmpdistfromline} - \else + \ifpgf@circuit@bipole@inverted \def\distfromline{\ctikzvalof{voltage/distance from line}\pgf@circ@scaled@Rlen} - \fi - \else - \ifpgf@circuit@bipole@voltage@straight - \def\distfromline{-\tmpdistfromline} \else \def\distfromline{-\ctikzvalof{voltage/distance from line}\pgf@circ@scaled@Rlen} \fi - \fi \else \ifpgf@circuit@bipole@inverted - \ifpgf@circuit@bipole@voltage@straight - \def\distfromline{-\tmpdistfromline} - \else \def\distfromline{-\ctikzvalof{voltage/distance from line}\pgf@circ@scaled@Rlen} - \fi - \else - \ifpgf@circuit@bipole@voltage@straight - \def\distfromline{\tmpdistfromline} \else \def\distfromline{\ctikzvalof{voltage/distance from line}\pgf@circ@scaled@Rlen} - \fi \fi \fi \ifpgf@circuit@bipole@voltage@below @@ -196,71 +157,121 @@ { \edef\bumpb{\ctikzvalof{voltage/bump b}} } \edef\shiftv{\ctikzvalof{voltage/shift}} % additional per-bipole voltage shift (internal) - \edef\pgf@temp{/tikz/circuitikz/bipoles/\ctikzvalof{bipole/kind}/voltage/additional label shift} + \edef\pgf@temp{/tikz/circuitikz/bipoles/\ctikzvalof{bipole/kind}/voltage/additional shift} \pgfkeysifdefined{\pgf@temp} { - \edef\addvshift{\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/voltage/additional label shift}} + \edef\addvshift{\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/voltage/additional shift}} } { \edef\addvshift{0} } \newdimen{\absvshift} \pgfmathsetlength{\absvshift}{(1+\shiftv+\addvshift)*(\distfromline)} - % put this to true to see the voltage label coordinate anchors - \newif\ifpgf@circ@debugv\pgf@circ@debugvfalse + % reset anchor if american and open + \ifpgf@circuit@europeanvoltage + \else + \ifx\@@kind\@@open + \def\pgf@circ@bipole@voltage@label@anchor{center} + \fi + \fi } % %\pgf@circ@Rlen/\ctikzvalof{current arrow scale} is equal to the length of the currarrow - coordinate (pgfcirc@midtmp) at ($(\tikztostart) ! \pgf@circ@Rlen/\ctikzvalof{current arrow scale} ! (anchorstartnode)$) %absolute move, minimum space is length of arrowhead + %absolute move, minimum space is length of arrowhead + coordinate (pgfcirc@midtmp) at ($(\tikztostart) ! \pgf@circ@Rlen/\ctikzvalof{current arrow scale} ! (anchorstartnode)$) coordinate (pgfcirc@midtmp) at ($(pgfcirc@midtmp) ! \distancefromnode ! (anchorstartnode)$) coordinate (pgfcirc@Vfrom@flat) at (pgfcirc@midtmp) - coordinate (pgfcirc@Vfrom) at ($(pgfcirc@midtmp) ! -\distfromline ! \pgf@circ@voltage@angle:(anchorstartnode)$) - - coordinate (pgfcirc@midtmp) at ($(\tikztotarget) ! \pgf@circ@Rlen/\ctikzvalof{current arrow scale} ! (anchorendnode)$)%absolute move, minimum space is length of arrowhead + %absolute move, minimum space is length of arrowhead + coordinate (pgfcirc@midtmp) at ($(\tikztotarget) ! \pgf@circ@Rlen/\ctikzvalof{current arrow scale} ! (anchorendnode)$) coordinate (pgfcirc@midtmp) at ($(pgfcirc@midtmp) ! \distancefromnode ! (anchorendnode)$) coordinate (pgfcirc@Vto@flat) at (pgfcirc@midtmp) - coordinate (pgfcirc@Vto) at ($(pgfcirc@midtmp) ! \distfromline ! \pgf@circ@voltage@angle : (anchorendnode)$) + coordinate (pgfcirc@mid) at ($(pgfcirc@Vfrom@flat)!0.5!(pgfcirc@Vto@flat)$) \ifpgf@circuit@bipole@voltage@below - \ifpgf@circ@debugv - node [ocirc, fill=red] at (anchorstartnode) {} - node [ocirc, fill=blue] at (anchorendnode) {} - node [ocirc, fill=green] at (pgfcirc@Vto) {} - node [ocirc, fill=yellow] at (pgfcirc@Vfrom) {} - node [odiamondpole, fill=green!50!black] at (pgfcirc@Vto@flat) {} - node [odiamondpole, fill=orange] at (pgfcirc@Vfrom@flat) {} - \fi - coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!90 : (anchorendnode)$) - coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom@flat) ! \absvshift!-90 : (anchorstartnode)$) - coordinate (pgfcirc@Vcont1t) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.-110)$) - coordinate (pgfcirc@Vcont2t) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.-70)$) - coordinate (pgfcirc@Vcont1) at ($(pgfcirc@Vcont1t) ! -\absvshift!90 : (pgfcirc@Vcont2t)$) - coordinate (pgfcirc@Vcont2) at ($(pgfcirc@Vcont2t) ! -\absvshift!-90 : (pgfcirc@Vcont1t)$) - \ifpgf@circ@debugv - node [odiamondpole, fill=green] at (pgfcirc@Vto) {} - node [odiamondpole, fill=yellow] at (pgfcirc@Vfrom) {} - node [osquarepole, fill=red] at (pgfcirc@Vcont1) {} - node [osquarepole, fill=blue] at (pgfcirc@Vcont2) {} + % see comments for the "above" part (similar) + \ifpgf@circuit@europeanvoltage + \ifpgf@circuit@bipole@voltage@straight + coordinate (pgfcirc@bottom) at (\ctikzvalof{bipole/name}.-90) + coordinate (pgfcirc@Vto1) at ($(pgfcirc@mid)+(pgfcirc@bottom)-(pgfcirc@Vfrom@flat)$) + coordinate (pgfcirc@Vfrom1) at ($(pgfcirc@mid)+(pgfcirc@bottom)-(pgfcirc@Vto@flat)$) + coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto1) ! \absvshift!90 : (pgfcirc@Vfrom1)$) + coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom1) ! \absvshift!-90 : (pgfcirc@Vto1)$) + coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vto)!0.5!(pgfcirc@Vfrom) $) + coordinate (pgfcirc@Vdir) at (pgfcirc@Vto) + \else + coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!90 : (anchorendnode)$) + coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom@flat) ! \absvshift!-90 : (anchorstartnode)$) + coordinate (pgfcirc@Vcont1t) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.-110)$) + coordinate (pgfcirc@Vcont2t) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.-70)$) + coordinate (pgfcirc@Vcont1) at ($(pgfcirc@Vcont1t) ! -\absvshift!90 : (pgfcirc@Vcont2t)$) + coordinate (pgfcirc@Vcont2) at ($(pgfcirc@Vcont2t) ! -\absvshift!-90 : (pgfcirc@Vcont1t)$) + coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vcont2)!0.5!(pgfcirc@Vcont1)$) + coordinate (pgfcirc@Vdir) at (pgfcirc@Vcont2) + \fi + \else % we are here in case of american here + % we are in case of american here + coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!90 : (anchorendnode)$) + coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom@flat) ! \absvshift!-90 : (anchorstartnode)$) + coordinate (pgfcirc@bottom) at (\ctikzvalof{bipole/name}.-90) + coordinate (pgfcirc@Vdir0) at ($(pgfcirc@mid)+(pgfcirc@bottom)-(pgfcirc@Vfrom@flat)$) + coordinate (pgfcirc@Vlab) at ($(pgfcirc@bottom) ! \absvshift!-90 : (pgfcirc@Vdir0)$) + coordinate (pgfcirc@Vdir) at ($(pgfcirc@mid)+(pgfcirc@Vlab)-(pgfcirc@Vfrom@flat)$) \fi \else - \ifpgf@circ@debugv - node [ocirc, fill=red] at (anchorstartnode) {} - node [ocirc, fill=blue] at (anchorendnode) {} - node [ocirc, fill=green] at (pgfcirc@Vto) {} - node [ocirc, fill=yellow] at (pgfcirc@Vfrom) {} - node [odiamondpole, fill=green] at (pgfcirc@Vto@flat) {} - node [odiamondpole, fill=yellow] at (pgfcirc@Vfrom@flat) {} + \ifpgf@circuit@europeanvoltage + \ifpgf@circuit@bipole@voltage@straight + coordinate (pgfcirc@top) at (\ctikzvalof{bipole/name}.90) + % move parallel to the component line at pgfcirc@top distance + coordinate (pgfcirc@Vto1) at ($(pgfcirc@mid)+(pgfcirc@top)-(pgfcirc@Vfrom@flat)$) + coordinate (pgfcirc@Vfrom1) at ($(pgfcirc@mid)+(pgfcirc@top)-(pgfcirc@Vto@flat)$) + % add the extra distance + coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto1) ! \absvshift!-90 : (pgfcirc@Vfrom1)$) + coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom1) ! \absvshift!90 : (pgfcirc@Vto1)$) + coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vto)!0.5!(pgfcirc@Vfrom) $) + % direction line to shift the label later + coordinate (pgfcirc@Vdir) at (pgfcirc@Vto) + \else + % european voltages here + coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto@flat) ! -\absvshift!90 : (anchorendnode)$) + coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom@flat) ! -\absvshift!-90 : (anchorstartnode)$) + % identify the two control points for the "arc" of the voltage + coordinate (pgfcirc@Vcont1t) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.110)$) + coordinate (pgfcirc@Vcont2t) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.70)$) + % and shift them a bit + coordinate (pgfcirc@Vcont1) at ($(pgfcirc@Vcont1t) ! \absvshift!90 : (pgfcirc@Vcont2t)$) + coordinate (pgfcirc@Vcont2) at ($(pgfcirc@Vcont2t) ! \absvshift!-90 : (pgfcirc@Vcont1t)$) + coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vcont2)!0.5!(pgfcirc@Vcont1)$) + % direction line to shift the label later + coordinate (pgfcirc@Vdir) at (pgfcirc@Vcont2) + \fi + \else + % we are in case of american here + coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!-90 : (anchorendnode)$) + coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom@flat) ! \absvshift!90 : (anchorstartnode)$) + coordinate (pgfcirc@top) at (\ctikzvalof{bipole/name}.90) + % move parallel to the component line + coordinate (pgfcirc@Vdir0) at ($(pgfcirc@mid)+(pgfcirc@top)-(pgfcirc@Vfrom@flat)$) + % and add the extra distance + coordinate (pgfcirc@Vlab) at ($(pgfcirc@top) ! \absvshift!90 : (pgfcirc@Vdir0)$) + coordinate (pgfcirc@Vdir) at ($(pgfcirc@mid)+(pgfcirc@Vlab)-(pgfcirc@Vfrom@flat)$) \fi - coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto@flat) ! -\absvshift!90 : (anchorendnode)$) - coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom@flat) ! -\absvshift!-90 : (anchorstartnode)$) - coordinate (pgfcirc@Vcont1t) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.110)$) - coordinate (pgfcirc@Vcont2t) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.70)$) - coordinate (pgfcirc@Vcont1) at ($(pgfcirc@Vcont1t) ! \absvshift!90 : (pgfcirc@Vcont2t)$) - coordinate (pgfcirc@Vcont2) at ($(pgfcirc@Vcont2t) ! \absvshift!-90 : (pgfcirc@Vcont1t)$) - \ifpgf@circ@debugv - node [odiamondpole, fill=green] at (pgfcirc@Vto) {} - node [odiamondpole, fill=yellow] at (pgfcirc@Vfrom) {} - node [osquarepole, fill=red] at (pgfcirc@Vcont1) {} - node [osquarepole, fill=blue] at (pgfcirc@Vcont2) {} + \fi + \ifx\@@kind\@@open + coordinate (pgfcirc@Vto) at (pgfcirc@Vto@flat) + coordinate (pgfcirc@Vfrom) at (pgfcirc@Vfrom@flat) + \fi + \ifpgf@circ@debugv + node [ocirc, fill=red] at (anchorstartnode) {} + node [ocirc, fill=blue] at (anchorendnode) {} + node [ocirc, fill=green] at (pgfcirc@Vto) {} + node [ocirc, fill=yellow] at (pgfcirc@Vfrom) {} + node [odiamondpole, fill=green!50!black] at (pgfcirc@Vto@flat) {} + node [odiamondpole, fill=orange] at (pgfcirc@Vfrom@flat) {} + \ifpgf@circuit@europeanvoltage + \ifpgf@circuit@bipole@voltage@straight + \else + node [osquarepole, fill=red] at (pgfcirc@Vcont1) {} + node [osquarepole, fill=blue] at (pgfcirc@Vcont2) {} + \fi \fi \fi @@ -283,57 +294,29 @@ \fi \fi \else % american - \ifx\@@kind\@@open % open circuit; put + and - directly on it - \ifpgf@circuit@bipole@voltage@backward - \ifpgf@circ@oldvoltagedirection - (pgfcirc@Vfrom@flat) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=center]{\pgf@circ@avplus} - (pgfcirc@Vto@flat) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=center]{\pgf@circ@avminus} - \else - (pgfcirc@Vfrom@flat) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=center]{\pgf@circ@avminus} - (pgfcirc@Vto@flat) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=center]{\pgf@circ@avplus} - \fi - \else - \ifpgf@circ@oldvoltagedirection - (pgfcirc@Vfrom@flat) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=center]{\pgf@circ@avminus} - (pgfcirc@Vto@flat) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=center]{\pgf@circ@avplus} - \else - (pgfcirc@Vfrom@flat) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=center]{\pgf@circ@avplus} - (pgfcirc@Vto@flat) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=center]{\pgf@circ@avminus} - \fi + \ifpgf@circuit@bipole@voltage@backward + \ifpgf@circ@oldvoltagedirection + (pgfcirc@Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, + anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avplus} + (pgfcirc@Vto) node[inner sep=0, node font=\pgf@circ@avfont, + anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avminus} + \else + (pgfcirc@Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, + anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avminus} + (pgfcirc@Vto) node[inner sep=0, node font=\pgf@circ@avfont, + anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avplus} \fi - \else % not open circuit - \ifpgf@circuit@bipole@voltage@backward - \ifpgf@circ@oldvoltagedirection - (pgfcirc@Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avplus} - (pgfcirc@Vto) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avminus} - \else - (pgfcirc@Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avminus} - (pgfcirc@Vto) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avplus} - \fi - \else - \ifpgf@circ@oldvoltagedirection - (pgfcirc@Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avminus} - (pgfcirc@Vto) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avplus} - \else - (pgfcirc@Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avplus} - (pgfcirc@Vto) node[inner sep=0, node font=\pgf@circ@avfont, - anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avminus} - \fi + \else + \ifpgf@circ@oldvoltagedirection + (pgfcirc@Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, + anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avminus} + (pgfcirc@Vto) node[inner sep=0, node font=\pgf@circ@avfont, + anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avplus} + \else + (pgfcirc@Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, + anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avplus} + (pgfcirc@Vto) node[inner sep=0, node font=\pgf@circ@avfont, + anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avminus} \fi \fi \fi @@ -345,19 +328,39 @@ % it's not perfect, but I can't find the way to do it correctly... \pgfextra{ \edef\shiftv{\ctikzvalof{voltage/shift}} - \edef\bumpa{\ctikzvalof{voltage/bump a}} + % distance along the 60-120 axis + \edef\pgf@temp{/tikz/circuitikz/bipoles/\ctikzvalof{bipole/kind}/voltage/bump a} + \pgfkeysifdefined{\pgf@temp} + { + \edef\bumpa{\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/voltage/bump a}} + } + { + \edef\bumpa{\ctikzvalof{voltage/bump a}} + } + % additional per-bipole voltage shift (internal) + \edef\pgf@temp{/tikz/circuitikz/bipoles/\ctikzvalof{bipole/kind}/voltage/additional shift} + \pgfkeysifdefined{\pgf@temp} + { + \edef\addvshift{\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/voltage/additional shift}} + } + { + \edef\addvshift{0} + } \pgfmathsetmacro{\bumpaplus}{\bumpa + 0.5*\shiftv} % coefficient added "by feel". Sorry. } \ifpgf@circuit@bipole@voltage@below - coordinate (pgfcirc@Vfrom) at ($(\ctikzvalof{bipole/name}.center) ! \bumpaplus ! (\ctikzvalof{bipole/name}.-120)$) - coordinate (pgfcirc@Vto) at ($(\ctikzvalof{bipole/name}.center) ! \bumpaplus ! (\ctikzvalof{bipole/name}.-60)$) + coordinate (pgfcirc@Vfrom0) at ($(\ctikzvalof{bipole/name}.center) ! \bumpaplus ! (\ctikzvalof{bipole/name}.-120)$) + coordinate (pgfcirc@Vto0) at ($(\ctikzvalof{bipole/name}.center) ! \bumpaplus ! (\ctikzvalof{bipole/name}.-60)$) + coordinate (pgfcirc@Vfrom) at ($ (pgfcirc@Vfrom0) ! \addvshift! -90: (pgfcirc@Vto0) $) + coordinate (pgfcirc@Vto) at ($ (pgfcirc@Vto0) ! \addvshift! 90: (pgfcirc@Vfrom0) $) \else - coordinate (pgfcirc@Vfrom) at ($ (\ctikzvalof{bipole/name}.center) ! \bumpaplus ! (\ctikzvalof{bipole/name}.120)$) - coordinate (pgfcirc@Vto) at ($ (\ctikzvalof{bipole/name}.center) ! \bumpaplus ! (\ctikzvalof{bipole/name}.60)$) + coordinate (pgfcirc@Vfrom0) at ($ (\ctikzvalof{bipole/name}.center) ! \bumpaplus ! (\ctikzvalof{bipole/name}.120)$) + coordinate (pgfcirc@Vto0) at ($ (\ctikzvalof{bipole/name}.center) ! \bumpaplus ! (\ctikzvalof{bipole/name}.60)$) + coordinate (pgfcirc@Vfrom) at ($ (pgfcirc@Vfrom0) ! \addvshift! 90: (pgfcirc@Vto0) $) + coordinate (pgfcirc@Vto) at ($ (pgfcirc@Vto0) ! \addvshift! -90: (pgfcirc@Vfrom0) $) \fi - % fix the (unused in this case) Vcont1/2 coords for label placement along the line - coordinate (pgfcirc@Vcont1) at (pgfcirc@Vto) - coordinate (pgfcirc@Vcont2) at (pgfcirc@Vfrom) + coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vto)!0.5!(pgfcirc@Vfrom) $) + coordinate (pgfcirc@Vdir) at (pgfcirc@Vto) \ifpgf@circuit@europeanvoltage \ifpgf@circuit@bipole@voltage@backward (pgfcirc@Vto) -- node[currarrow, sloped, allow upside down, pos=1, anchor=tip] {} (pgfcirc@Vfrom) @@ -392,6 +395,8 @@ %% Output routine %% this is the entry point %% +%% locally used dimensions +\newdimen{\pgfcirc@labelshift} \def\pgf@circ@drawvoltage{% node name \pgfextra{ %WARNING: indentation is probably wrong \edef\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@direction\pgf@nil} @@ -454,11 +459,11 @@ % this must be set *before* changing for mirroring and inverting; in that case % the xscale/yscale parameters take it into account - \ifpgf@circuit@bipole@voltage@below - \def\pgf@circ@bipole@voltage@label@where{-90} - \else - \def\pgf@circ@bipole@voltage@label@where{90} - \fi + \ifpgf@circuit@bipole@voltage@below + \def\pgf@circ@bipole@voltage@label@where{-90} + \else + \def\pgf@circ@bipole@voltage@label@where{90} + \fi % magic to counteract the scale and yscale effects (there should be a better way...) \ifnum \ctikzvalof{mirror value}=-1 @@ -480,20 +485,46 @@ % take into account scaling \setscaledRlenforclass - \edef\pgf@temp{/tikz/circuitikz/bipoles/\ctikzvalof{bipole/kind}/voltage/european label distance} - \pgfkeysifdefined{\pgf@temp} - { \edef\eudist{\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/voltage/european label distance}} } - { \edef\eudist{\ctikzvalof{voltage/european label distance}} } + \ifpgf@circuit@europeanvoltage + \ifpgf@circuit@bipole@voltage@straight + % check for straight + \edef\pgf@temp{/tikz/circuitikz/bipoles/\ctikzvalof{bipole/kind}/voltage/straight label distance} + \pgfkeysifdefined{\pgf@temp}{% + \edef\labeldist{\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/voltage/straight label distance}}% + % \typeout{ST:ADJUSTED\space for\space \ctikzvalof{bipole/kind} \space at \space \stdist} + }{\edef\labeldist{\ctikzvalof{voltage/straight label distance}}} + \ifpgf@circ@debugv\edef\whichtypeshift{STR}\fi + \else + % check for european + \edef\pgf@temp{/tikz/circuitikz/bipoles/\ctikzvalof{bipole/kind}/voltage/european label distance} + \pgfkeysifdefined{\pgf@temp}{% + \edef\labeldist{\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/voltage/european label distance}}% + % \typeout{EU:ADJUSTED\space for\space \ctikzvalof{bipole/kind} \space at \space \eudist} + }{ \edef\labeldist{\ctikzvalof{voltage/european label distance}}} + \ifpgf@circ@debugv\edef\whichtypeshift{EUR}\fi + \fi + \else + % check for american + \edef\pgf@temp{/tikz/circuitikz/bipoles/\ctikzvalof{bipole/kind}/voltage/american label distance} + \pgfkeysifdefined{\pgf@temp}{% + \edef\labeldist{\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/voltage/american label distance}}% + % \typeout{AL:ADJUSTED\space for\space \ctikzvalof{bipole/kind} \space at \space \aldist} + }{\edef\labeldist{\ctikzvalof{voltage/american label distance}}} + \ifpgf@circ@debugv\edef\whichtypeshift{AME}\fi + \fi % find the height of the bipole or use a default value \edef\pgf@temp{/tikz/circuitikz/bipoles/\ctikzvalof{bipole/kind}/height} \pgfkeysifdefined{\pgf@temp} {\pgfmathsetmacro{\partheightf}{0.5*\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/height}} \edef\partheight{\partheightf\pgf@circ@scaled@Rlen}} {\edef\partheight{(.5\pgf@circ@scaled@Rlen)}} %fallback to fixed value - \newdimen{\alshift} - % this is more or less the same of the legacy code; we shift the american label a bit - % outside the (+) -- (-) line - \pgfmathsetlength{\alshift}{(\ctikzvalof{voltage/american label distance}-0.6)*\partheight} + + \ifpgf@circuit@bipole@isvoltage + \pgfmathsetlength{\pgfcirc@labelshift}{(\labeldist-1.2)*\partheight} + \else + \pgfmathsetlength{\pgfcirc@labelshift}{(\labeldist-1.4)*\partheight} + \fi + % the value for the european was by default 1.4 \pgfsetcornersarced{\pgfpointorigin}% do not use rounded corners! % set the macro for detecting open \edef\@@kind{\ctikzvalof{bipole/kind}}\edef\@@open{open} @@ -506,42 +537,33 @@ \else \pgf@circ@drawvoltagegeneric \fi + % % debugging + % \pgfextra{% + % \typeout{LABEL\space KIND:\@@kind\space EU:\the\pgfcirc@eushift\space AL:\the\pgfcirc@alshift\space + % DIRECTION:\pgf@circ@bipole@voltage@label@where} + % \pgf@circ@debugvtrue} - % \pgfextra{\typeout{LABEL\space KIND:\@@kind\space OPEN:\@@open}} + % move a bit if requested + coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vlab) ! \pgfcirc@labelshift ! \pgf@circ@bipole@voltage@label@where :(pgfcirc@Vdir)$) - \ifpgf@circuit@bipole@voltage@straight - coordinate (Vlab) at ($(pgfcirc@Vto)!0.5!(pgfcirc@Vfrom) $) - node [anchor=\pgf@circ@bipole@voltage@label@anchor, inner sep=2pt, - \circuitikzbasekey/bipole voltage style](\ctikzvalof{bipole/name}voltage) - at (Vlab) {\pgf@circ@finallabels{voltage/label}} + % check for the case of american AND open + \ifpgf@circuit@europeanvoltage \else - \ifpgf@circuit@europeanvoltage - coordinate (Vlab) at ($(pgfcirc@Vcont1)!0.5!(pgfcirc@Vcont2)$) - \else - coordinate (Vlab) at ($(pgfcirc@Vfrom)!0.5!(pgfcirc@Vto)$) - \ifpgf@circuit@bipole@isvoltage\else - % add a bit of space for american labels above their symbols in the normal case. You can avoid that - % with voltage/american label distance=0.5 (it's measured from the center of the component, in heights) - coordinate (Vlab) at ($(Vlab) ! \alshift ! \pgf@circ@bipole@voltage@label@where :(pgfcirc@Vto)$) - \fi - \fi + \ifx\@@kind\@@open + % override pgfcirc@Vlab + coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vfrom@flat)!0.5!(pgfcirc@Vto@flat)$)\fi + \fi - \ifpgf@circuit@europeanvoltage - node [anchor=\pgf@circ@bipole@voltage@label@anchor, inner sep=2pt, - \circuitikzbasekey/bipole voltage style](\ctikzvalof{bipole/name}voltage) - at (Vlab) {\pgf@circ@finallabels{voltage/label}} - \else % american voltages - \ifx\@@kind\@@open - coordinate (Vlab) at ($(pgfcirc@Vfrom@flat)!0.5!(pgfcirc@Vto@flat)$) - node [anchor=center, inner sep=2pt, - \circuitikzbasekey/bipole voltage style](\ctikzvalof{bipole/name}voltage) - at (Vlab) {\pgf@circ@finallabels{voltage/label}} - \else - node [anchor=\pgf@circ@bipole@voltage@label@anchor, inner sep=2pt, - \circuitikzbasekey/bipole voltage style](\ctikzvalof{bipole/name}voltage) - at (Vlab) {\pgf@circ@finallabels{voltage/label}} - \fi - \fi + \ifpgf@circ@debugv + node [odiamondpole, color=blue] at (pgfcirc@Vlab) {} + node [odiamondpole, color=red] at (pgfcirc@Vdir) {} + node [overlay, red, font=\tiny, anchor=south east, align=right] at(pgfcirc@Vdir) + {\whichtypeshift:\the\pgfcirc@labelshift\\ DIR:\pgf@circ@bipole@voltage@label@where} \fi + + node [anchor=\pgf@circ@bipole@voltage@label@anchor, inner sep=2pt, + \circuitikzbasekey/bipole voltage style](\ctikzvalof{bipole/name}voltage) + at (pgfcirc@Vlab) {\pgf@circ@finallabels{voltage/label}} + }%end drawvoltages \endinput -- cgit v1.2.3