summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/circuitikz/tex/pgfcircvoltage.tex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-07-07 03:01:19 +0000
committerNorbert Preining <norbert@preining.info>2020-07-07 03:01:19 +0000
commitef87f13c4503a2aa4a9098cbf33e0bfcad19008e (patch)
tree3ffb99adbe8054f2bd6d04f982ea2a8e07a6bb62 /graphics/pgf/contrib/circuitikz/tex/pgfcircvoltage.tex
parent2caa59ac79d64858cdff8486b3fecc9859111e38 (diff)
CTAN sync 202007070301
Diffstat (limited to 'graphics/pgf/contrib/circuitikz/tex/pgfcircvoltage.tex')
-rw-r--r--graphics/pgf/contrib/circuitikz/tex/pgfcircvoltage.tex216
1 files changed, 138 insertions, 78 deletions
diff --git a/graphics/pgf/contrib/circuitikz/tex/pgfcircvoltage.tex b/graphics/pgf/contrib/circuitikz/tex/pgfcircvoltage.tex
index 00fa692b0f..032a66f29c 100644
--- a/graphics/pgf/contrib/circuitikz/tex/pgfcircvoltage.tex
+++ b/graphics/pgf/contrib/circuitikz/tex/pgfcircvoltage.tex
@@ -58,6 +58,7 @@
% Default position varies whether the component is a voltage source
% or not
\ctikzset{v/.code = {
+ \pgfcirc@has@vtrue
\ifpgf@circuit@bipole@isvoltage
\pgfkeys{\circuitikzbasekey/bipole/voltage/position=above,
\circuitikzbasekey/bipole/voltage/direction=forward}
@@ -174,6 +175,10 @@
\def\pgf@circ@bipole@voltage@label@anchor{center}
\fi
\fi
+ \ifpgf@circuit@bipole@voltage@raised
+ \def\pgf@circ@bipole@voltage@label@anchor{center}
+ \pgfmathsetlength{\absvshift}{\absvshift+height{"Q"}} % with the current font.
+ \fi
}
% %\pgf@circ@Rlen/\ctikzvalof{current arrow scale} is equal to the length of the currarrow
%absolute move, minimum space is length of arrowhead
@@ -193,28 +198,33 @@
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)
+ coordinate (\pgfcirc@a@prefix-Vto) at ($(pgfcirc@Vto1) ! \absvshift!90 : (pgfcirc@Vfrom1)$)
+ coordinate (\pgfcirc@a@prefix-Vfrom) at ($(pgfcirc@Vfrom1) ! \absvshift!-90 : (pgfcirc@Vto1)$)
+ coordinate (\pgfcirc@a@prefix-Vlab) at ($(\pgfcirc@a@prefix-Vto)!0.5!(\pgfcirc@a@prefix-Vfrom) $)
+ coordinate (pgfcirc@Vdir) at (\pgfcirc@a@prefix-Vto)
\else
- coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!90 : (anchorendnode)$)
- coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom@flat) ! \absvshift!-90 : (anchorstartnode)$)
+ coordinate (\pgfcirc@a@prefix-Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!90 : (anchorendnode)$)
+ coordinate (\pgfcirc@a@prefix-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)
+ coordinate (\pgfcirc@a@prefix-Vcont1) at ($(pgfcirc@Vcont1t) ! -\absvshift!90 : (pgfcirc@Vcont2t)$)
+ coordinate (\pgfcirc@a@prefix-Vcont2) at ($(pgfcirc@Vcont2t) ! -\absvshift!-90 : (pgfcirc@Vcont1t)$)
+ coordinate (\pgfcirc@a@prefix-Vlab) at ($(\pgfcirc@a@prefix-Vcont2)!0.5!(\pgfcirc@a@prefix-Vcont1)$)
+ coordinate (pgfcirc@Vdir) at (\pgfcirc@a@prefix-Vcont2)
\fi
- \else % we are here in case of american here
+ \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@a@prefix-Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!90 : (anchorendnode)$)
+ coordinate (\pgfcirc@a@prefix-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)$)
+ coordinate (\pgfcirc@a@prefix-Vlab) at ($(pgfcirc@bottom) ! \absvshift!-90 : (pgfcirc@Vdir0)$)
+ coordinate (pgfcirc@Vdir) at ($(pgfcirc@mid)+(\pgfcirc@a@prefix-Vlab)-(pgfcirc@Vfrom@flat)$)
+ \ifpgf@circuit@bipole@voltage@raised
+ % move the from and to up to the level of Vlab
+ coordinate (\pgfcirc@a@prefix-Vto) at ($(\pgfcirc@a@prefix-Vlab)+(pgfcirc@Vto@flat)-(pgfcirc@mid)$)
+ coordinate (\pgfcirc@a@prefix-Vfrom) at ($(\pgfcirc@a@prefix-Vlab)+(pgfcirc@Vfrom@flat)-(pgfcirc@mid)$)
+ \fi
\fi
\else
\ifpgf@circuit@europeanvoltage
@@ -224,102 +234,113 @@
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) $)
+ coordinate (\pgfcirc@a@prefix-Vto) at ($(pgfcirc@Vto1) ! \absvshift!-90 : (pgfcirc@Vfrom1)$)
+ coordinate (\pgfcirc@a@prefix-Vfrom) at ($(pgfcirc@Vfrom1) ! \absvshift!90 : (pgfcirc@Vto1)$)
+ coordinate (\pgfcirc@a@prefix-Vlab) at ($(\pgfcirc@a@prefix-Vto)!0.5!(\pgfcirc@a@prefix-Vfrom) $)
% direction line to shift the label later
- coordinate (pgfcirc@Vdir) at (pgfcirc@Vto)
+ coordinate (pgfcirc@Vdir) at (\pgfcirc@a@prefix-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)$)
+ coordinate (\pgfcirc@a@prefix-Vto) at ($(pgfcirc@Vto@flat) ! -\absvshift!90 : (anchorendnode)$)
+ coordinate (\pgfcirc@a@prefix-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)$)
+ coordinate (\pgfcirc@a@prefix-Vcont1) at ($(pgfcirc@Vcont1t) ! \absvshift!90 : (pgfcirc@Vcont2t)$)
+ coordinate (\pgfcirc@a@prefix-Vcont2) at ($(pgfcirc@Vcont2t) ! \absvshift!-90 : (pgfcirc@Vcont1t)$)
+ coordinate (\pgfcirc@a@prefix-Vlab) at ($(\pgfcirc@a@prefix-Vcont2)!0.5!(\pgfcirc@a@prefix-Vcont1)$)
% direction line to shift the label later
- coordinate (pgfcirc@Vdir) at (pgfcirc@Vcont2)
+ coordinate (pgfcirc@Vdir) at (\pgfcirc@a@prefix-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@a@prefix-Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!-90 : (anchorendnode)$)
+ coordinate (\pgfcirc@a@prefix-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)$)
+ coordinate (\pgfcirc@a@prefix-Vlab) at ($(pgfcirc@top) ! \absvshift!90 : (pgfcirc@Vdir0)$)
+ coordinate (pgfcirc@Vdir) at ($(pgfcirc@mid)+(\pgfcirc@a@prefix-Vlab)-(pgfcirc@Vfrom@flat)$)
+ \ifpgf@circuit@bipole@voltage@raised
+ % move the from and to up to the level of Vlab
+ coordinate (\pgfcirc@a@prefix-Vto) at ($(\pgfcirc@a@prefix-Vlab)+(pgfcirc@Vto@flat)-(pgfcirc@mid)$)
+ coordinate (\pgfcirc@a@prefix-Vfrom) at ($(\pgfcirc@a@prefix-Vlab)+(pgfcirc@Vfrom@flat)-(pgfcirc@mid)$)
+ \fi
\fi
\fi
\ifx\@@kind\@@open
- coordinate (pgfcirc@Vto) at (pgfcirc@Vto@flat)
- coordinate (pgfcirc@Vfrom) at (pgfcirc@Vfrom@flat)
+ coordinate (\pgfcirc@a@prefix-Vto) at (pgfcirc@Vto@flat)
+ coordinate (\pgfcirc@a@prefix-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 [ocirc, fill=green] at (\pgfcirc@a@prefix-Vto) {}
+ node [ocirc, fill=yellow] at (\pgfcirc@a@prefix-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) {}
+ node [osquarepole, fill=red] at (\pgfcirc@a@prefix-Vcont1) {}
+ node [osquarepole, fill=blue] at (\pgfcirc@a@prefix-Vcont2) {}
\fi
\fi
\fi
+ %
+ % Now we draw the voltage things (only if not empty --- in which case we have been
+ % called just to set the anchors)
+ %
+ \pgf@circ@ifkeyempty{bipole/voltage/label/name}\else
\ifpgf@circuit@europeanvoltage
\ifpgf@circuit@bipole@voltage@straight
\ifpgf@circuit@bipole@voltage@backward
- (pgfcirc@Vto) --(pgfcirc@Vfrom) node[currarrow, sloped, allow upside down, pos=1,anchor=tip] {}
+ (\pgfcirc@a@prefix-Vto) --(\pgfcirc@a@prefix-Vfrom) node[currarrow, sloped, allow upside down, pos=1,anchor=tip] {}
\else
- (pgfcirc@Vfrom) --(pgfcirc@Vto) node[currarrow, sloped, allow upside down, pos=1,anchor=tip] {}
+ (\pgfcirc@a@prefix-Vfrom) --(\pgfcirc@a@prefix-Vto) node[currarrow, sloped, allow upside down, pos=1,anchor=tip] {}
\fi
\else
\ifpgf@circuit@bipole@voltage@backward
- (pgfcirc@Vto) .. controls (pgfcirc@Vcont2) and (pgfcirc@Vcont1) ..
+ (\pgfcirc@a@prefix-Vto) .. controls (\pgfcirc@a@prefix-Vcont2) and (\pgfcirc@a@prefix-Vcont1) ..
node[currarrow, sloped, allow upside down, pos=1, anchor=tip] {}
- (pgfcirc@Vfrom)
+ (\pgfcirc@a@prefix-Vfrom)
\else
- (pgfcirc@Vfrom) .. controls (pgfcirc@Vcont1) and (pgfcirc@Vcont2) ..
+ (\pgfcirc@a@prefix-Vfrom) .. controls (\pgfcirc@a@prefix-Vcont1) and (\pgfcirc@a@prefix-Vcont2) ..
node[currarrow, sloped, allow upside down, pos=1, anchor=tip] {}
- (pgfcirc@Vto)
+ (\pgfcirc@a@prefix-Vto)
\fi
\fi
\else % american
\ifpgf@circuit@bipole@voltage@backward
\ifpgf@circ@oldvoltagedirection
- (pgfcirc@Vfrom) node[inner sep=0, node font=\pgf@circ@avfont,
+ (\pgfcirc@a@prefix-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,
+ (\pgfcirc@a@prefix-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,
+ (\pgfcirc@a@prefix-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,
+ (\pgfcirc@a@prefix-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,
+ (\pgfcirc@a@prefix-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,
+ (\pgfcirc@a@prefix-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,
+ (\pgfcirc@a@prefix-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,
+ (\pgfcirc@a@prefix-Vto) node[inner sep=0, node font=\pgf@circ@avfont,
anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avminus}
\fi
\fi
\fi
+ \fi % Closing the ...ifempty
}
%% Output routine for voltage sources
@@ -351,21 +372,22 @@
\ifpgf@circuit@bipole@voltage@below
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) $)
+ coordinate (\pgfcirc@a@prefix-Vfrom) at ($ (pgfcirc@Vfrom0) ! \addvshift! -90: (pgfcirc@Vto0) $)
+ coordinate (\pgfcirc@a@prefix-Vto) at ($ (pgfcirc@Vto0) ! \addvshift! 90: (pgfcirc@Vfrom0) $)
\else
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) $)
+ coordinate (\pgfcirc@a@prefix-Vfrom) at ($ (pgfcirc@Vfrom0) ! \addvshift! 90: (pgfcirc@Vto0) $)
+ coordinate (\pgfcirc@a@prefix-Vto) at ($ (pgfcirc@Vto0) ! \addvshift! -90: (pgfcirc@Vfrom0) $)
\fi
- coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vto)!0.5!(pgfcirc@Vfrom) $)
- coordinate (pgfcirc@Vdir) at (pgfcirc@Vto)
+ coordinate (\pgfcirc@a@prefix-Vlab) at ($(\pgfcirc@a@prefix-Vto)!0.5!(\pgfcirc@a@prefix-Vfrom) $)
+ coordinate (pgfcirc@Vdir) at (\pgfcirc@a@prefix-Vto)
+ \pgf@circ@ifkeyempty{bipole/voltage/label/name}\else
\ifpgf@circuit@europeanvoltage
\ifpgf@circuit@bipole@voltage@backward
- (pgfcirc@Vto) -- node[currarrow, sloped, allow upside down, pos=1, anchor=tip] {} (pgfcirc@Vfrom)
+ (\pgfcirc@a@prefix-Vto) -- node[currarrow, sloped, allow upside down, pos=1, anchor=tip] {} (\pgfcirc@a@prefix-Vfrom)
\else
- (pgfcirc@Vfrom) -- node[currarrow, sloped, allow upside down, pos=1, anchor=tip] {} (pgfcirc@Vto)
+ (\pgfcirc@a@prefix-Vfrom) -- node[currarrow, sloped, allow upside down, pos=1, anchor=tip] {} (\pgfcirc@a@prefix-Vto)
\fi
\else% american voltage
\ifpgf@circuit@bipole@voltageoutsideofsymbol
@@ -373,23 +395,24 @@
\ifpgf@circ@fixbatteries
\ifpgf@circuit@bipole@voltage@backward
- (pgfcirc@Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus}
- (pgfcirc@Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus}
+ (\pgfcirc@a@prefix-Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus}
+ (\pgfcirc@a@prefix-Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus}
\else
- (pgfcirc@Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus}
- (pgfcirc@Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus}
+ (\pgfcirc@a@prefix-Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus}
+ (\pgfcirc@a@prefix-Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus}
\fi
\else
\ifpgf@circuit@bipole@voltage@backward
- (pgfcirc@Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus}
- (pgfcirc@Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus}
+ (\pgfcirc@a@prefix-Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus}
+ (\pgfcirc@a@prefix-Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus}
\else
- (pgfcirc@Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus}
- (pgfcirc@Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus}
+ (\pgfcirc@a@prefix-Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus}
+ (\pgfcirc@a@prefix-Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus}
\fi
\fi
\fi
\fi
+ \fi % closes ...ifempty
}
%% Output routine
@@ -397,8 +420,21 @@
%%
%% locally used dimensions
\newdimen{\pgfcirc@labelshift}
+\newif\ifpgfcirc@v@curved % helper if --- true only if voltages are curved
\def\pgf@circ@drawvoltage{% node name
- \pgfextra{ %WARNING: indentation is probably wrong
+ \pgfextra{%
+ % set the helper if...curved
+ \ifpgf@circuit@europeanvoltage
+ \ifpgf@circuit@bipole@voltage@straight
+ \pgfcirc@v@curvedfalse
+ \else
+ \pgfcirc@v@curvedtrue
+ \fi
+ \else
+ \pgfcirc@v@curvedfalse
+ \fi
+ % \typeout{V routine called with prefix: \pgfcirc@a@prefix}
+ % Label anchors WARNING: indentation is probably wrong
\edef\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@direction\pgf@nil}
\ifnum\pgfcircmathresult >4 \ifnum\pgfcircmathresult <86
\ifpgf@circuit@bipole@voltage@below
@@ -457,13 +493,15 @@
\fi
\fi\fi
+ % export anchor position (if not needed, is always the same macro)
+ \expandafter\xdef\csname pgfcirc@\pgfcirc@a@prefix-Vlab-anchor\endcsname{\pgf@circ@bipole@voltage@label@anchor}
% 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
@@ -507,7 +545,12 @@
% 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}}%
+ \ifpgf@circuit@bipole@voltage@raised
+ % do not apply the shift if we are using raised american style
+ \edef\labeldist{1.4}% default value
+ \else
+ \edef\labeldist{\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/voltage/american label distance}}%
+ \fi
% \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
@@ -534,6 +577,9 @@
\ifpgf@circuit@bipole@isvoltage
\pgf@circ@drawvoltagegenerator
+ % add fake cont1 and cont2 anchors for export
+ coordinate (\pgfcirc@a@prefix-Vcont1) at ($(\pgfcirc@a@prefix-Vfrom) !0.5! (\pgfcirc@a@prefix-Vto)$)
+ coordinate (\pgfcirc@a@prefix-Vcont2) at ($(\pgfcirc@a@prefix-Vfrom) !0.5! (\pgfcirc@a@prefix-Vto)$)
\else
\pgf@circ@drawvoltagegeneric
\fi
@@ -544,26 +590,40 @@
% \pgf@circ@debugvtrue}
% move a bit if requested
- coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vlab) ! \pgfcirc@labelshift ! \pgf@circ@bipole@voltage@label@where :(pgfcirc@Vdir)$)
+ coordinate (\pgfcirc@a@prefix-Vlab) at ($(\pgfcirc@a@prefix-Vlab) ! \pgfcirc@labelshift ! \pgf@circ@bipole@voltage@label@where :(pgfcirc@Vdir)$)
% check for the case of american AND open
\ifpgf@circuit@europeanvoltage
\else
\ifx\@@kind\@@open
% override pgfcirc@Vlab
- coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vfrom@flat)!0.5!(pgfcirc@Vto@flat)$)\fi
+ coordinate (\pgfcirc@a@prefix-Vlab) at ($(pgfcirc@Vfrom@flat)!0.5!(pgfcirc@Vto@flat)$)\fi
\fi
\ifpgf@circ@debugv
- node [odiamondpole, color=blue] at (pgfcirc@Vlab) {}
+ node [odiamondpole, color=blue] at (\pgfcirc@a@prefix-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}}
+ % put the node only if it's not empty
+ \pgf@circ@ifkeyempty{bipole/voltage/label/name}\else
+ node [anchor=\pgf@circ@bipole@voltage@label@anchor, inner sep=2pt,
+ \circuitikzbasekey/bipole voltage style](\ctikzvalof{bipole/name}voltage)
+ at (\pgfcirc@a@prefix-Vlab) {\pgf@circ@finallabels{voltage/label}}
+ \fi
+
+ \ifpgfcirc@v@curved\else
+ % fake Vcont1 and Vcont2 for when they are exported --- in the middle of Vto and Vfrom
+ coordinate (\pgfcirc@a@prefix-Vcont1) at ($(\pgfcirc@a@prefix-Vfrom) !0.5! (\pgfcirc@a@prefix-Vto)$)
+ coordinate (\pgfcirc@a@prefix-Vcont2) at ($(\pgfcirc@a@prefix-Vfrom) !0.5! (\pgfcirc@a@prefix-Vto)$)
+ \fi
+ % revert from and to (and c1 - c2) if needed (simpler than rework the positioning above...)
+ \ifpgf@circuit@bipole@voltage@backward
+ \pgfcirc@swap@coordinates{\pgfcirc@a@prefix-Vfrom}{\pgfcirc@a@prefix-Vto}
+ \pgfcirc@swap@coordinates{\pgfcirc@a@prefix-Vcont1}{\pgfcirc@a@prefix-Vcont2}
+ \fi
}%end drawvoltages
\endinput