summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/circuitikz/tex/pgfcirccurrent.tex
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib/circuitikz/tex/pgfcirccurrent.tex')
-rw-r--r--graphics/pgf/contrib/circuitikz/tex/pgfcirccurrent.tex49
1 files changed, 32 insertions, 17 deletions
diff --git a/graphics/pgf/contrib/circuitikz/tex/pgfcirccurrent.tex b/graphics/pgf/contrib/circuitikz/tex/pgfcirccurrent.tex
index b8cf055590..a6b0d039b7 100644
--- a/graphics/pgf/contrib/circuitikz/tex/pgfcirccurrent.tex
+++ b/graphics/pgf/contrib/circuitikz/tex/pgfcirccurrent.tex
@@ -88,6 +88,7 @@
}
\ctikzset{i/.code = {
+ \pgfcirc@has@itrue
\pgfkeys{\circuitikzbasekey/bipole/current/direction = forward,
\circuitikzbasekey/bipole/current/x position = after,
\circuitikzbasekey/bipole/current/y position = above }
@@ -131,8 +132,8 @@
%% Output routine
\def\pgf@circ@drawcurrent{
\pgfextra{
- \edef\pgf@circ@ffffff{\pgf@circ@direction}
- \def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@ffffff\pgf@nil}
+ \edef\pgf@circ@rounded@dir{\pgf@circ@direction}
+ \def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@rounded@dir\pgf@nil}
\ifnum\pgfcircmathresult >4 \ifnum\pgfcircmathresult <86
\ifpgf@circuit@bipole@current@below
@@ -178,36 +179,50 @@
\ifpgf@circuit@bipole@current@below
\def\pgf@circ@dir{north}\else\def\pgf@circ@dir{south}
\fi
- \fi
+ \fi
+ % export anchor position (if not needed, is always the same macro)
+ \expandafter\xdef\csname pgfcirc@\pgfcirc@a@prefix-Ilab-anchor\endcsname{\pgf@circ@dir}
- \ifpgf@circuit@bipole@current@below
- \def\pgf@circ@bipole@current@label@where{-90}
- \else
- \def\pgf@circ@bipole@current@label@where{+90}
- \fi
+ \ifpgf@circuit@bipole@current@below
+ \def\pgf@circ@bipole@current@label@where{-90}
+ \else
+ \def\pgf@circ@bipole@current@label@where{+90}
+ \fi
}
+ %
\pgfextra{\def\pgf@temp{short}\edef\pgf@circ@temp{\ctikzvalof{bipole/kind}}}
\ifx\pgf@circ@temp\pgf@temp%draw current at a short at middle of the line
- (\tikztostart)--(\tikztotarget)
+ coordinate (\pgfcirc@a@prefix-Ifrom) at (\tikztostart)
+ coordinate (\pgfcirc@a@prefix-Ito) at (\tikztotarget)
\else% normal bipole or source
\ifpgf@circuit@bipole@current@before
- (\tikztostart)--(anchorstartnode)
+ coordinate (\pgfcirc@a@prefix-Ifrom) at (\tikztostart)
+ coordinate (\pgfcirc@a@prefix-Ito) at (anchorstartnode)
\else
- (anchorendnode)--(\tikztotarget)
+ coordinate (\pgfcirc@a@prefix-Ifrom) at (anchorendnode)
+ coordinate (\pgfcirc@a@prefix-Ito) at (\tikztotarget)
\fi
\fi
\ifpgf@circuit@bipole@current@backward
\pgfextra{
- \pgfmathsubtract{\pgf@circ@ffffff}{180}
- \edef\pgf@circ@ffffff{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil}
+ \pgfmathsubtract{\pgf@circ@rounded@dir}{180}
+ \edef\pgf@circ@rounded@dir{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil}
}
\fi
- coordinate[currarrow,pos=\ctikzvalof{current/distance},rotate=\pgf@circ@ffffff,
- anchor=center](Iarrow)
- (Iarrow.\pgf@circ@bipole@current@label@where)
+ coordinate (\pgfcirc@a@prefix-Ipos) at ($(\pgfcirc@a@prefix-Ifrom)! \ctikzvalof{current/distance} !(\pgfcirc@a@prefix-Ito)$)
+ % if the current label is not empty (in which case we have already all the anchors)
+ \pgf@circ@ifkeyempty{bipole/current/label/name}\else
+ % put the arrow node
+ node[currarrow, rotate=\pgf@circ@rounded@dir, anchor=center](Iarrow) at (\pgfcirc@a@prefix-Ipos) {}
+ % put the label
node[anchor=\pgf@circ@dir, \circuitikzbasekey/bipole current style]
- (\ctikzvalof{bipole/name}current){\pgf@circ@finallabels{current/label}}
+ (\ctikzvalof{bipole/name}current)
+ at (Iarrow.\pgf@circ@bipole@current@label@where){\pgf@circ@finallabels{current/label}}
+ \fi % end ifempty
+ \ifpgf@circuit@bipole@current@backward
+ \pgfcirc@swap@coordinates{\pgfcirc@a@prefix-Ifrom}{\pgfcirc@a@prefix-Ito}
+ \fi
}
\endinput