summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/circuitikz/pgfcirccurrent.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-04-18 16:42:44 +0000
committerKarl Berry <karl@freefriends.org>2009-04-18 16:42:44 +0000
commit9fbcb733dd11b3c8375ec9997391296abbc6d79d (patch)
tree7c139328d5c1b332a5a5311bebd0bf665d18b11c /Master/texmf-dist/tex/latex/circuitikz/pgfcirccurrent.sty
parent6e3c22d01092e6a41b9147068d2719a44d5ac16f (diff)
new pgf package circuitikz (17apr09)
git-svn-id: svn://tug.org/texlive/trunk@12745 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/circuitikz/pgfcirccurrent.sty')
-rw-r--r--Master/texmf-dist/tex/latex/circuitikz/pgfcirccurrent.sty239
1 files changed, 239 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/circuitikz/pgfcirccurrent.sty b/Master/texmf-dist/tex/latex/circuitikz/pgfcirccurrent.sty
new file mode 100644
index 00000000000..c86d57635da
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/circuitikz/pgfcirccurrent.sty
@@ -0,0 +1,239 @@
+% Copyright 2007-2009 by Massimo Redaelli
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+%
+% See the file doc/LICENSE for more details.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Current handling
+
+%% Options
+
+
+\tikzset{i^>/.style = {
+ i = #1,
+ \circuitikzbasekey/bipole/current/direction = forward,
+ \circuitikzbasekey/bipole/current/x position = after,
+ \circuitikzbasekey/bipole/current/y position = above
+ }
+}
+
+\tikzset{i_>/.style = {
+ i = #1,
+ \circuitikzbasekey/bipole/current/direction = forward,
+ \circuitikzbasekey/bipole/current/x position = after,
+ \circuitikzbasekey/bipole/current/y position = below
+ }
+}
+
+\tikzset{i>^/.style = {
+ i = #1,
+ \circuitikzbasekey/bipole/current/direction = forward,
+ \circuitikzbasekey/bipole/current/x position = before,
+ \circuitikzbasekey/bipole/current/y position = above
+ }
+}
+
+\tikzset{i>_/.style = {
+ i = #1,
+ \circuitikzbasekey/bipole/current/direction = forward,
+ \circuitikzbasekey/bipole/current/x position = before,
+ \circuitikzbasekey/bipole/current/y position = below
+ }
+}
+
+\tikzset{i^</.style = {
+ i = #1,
+ \circuitikzbasekey/bipole/current/direction = backward,
+ \circuitikzbasekey/bipole/current/x position = after,
+ \circuitikzbasekey/bipole/current/y position = above
+ }
+}
+
+\tikzset{i_</.style = {
+ i = #1,
+ \circuitikzbasekey/bipole/current/direction = backward,
+ \circuitikzbasekey/bipole/current/x position = after,
+ \circuitikzbasekey/bipole/current/y position = below
+ }
+}
+
+\tikzset{i<^/.style = {
+ i = #1,
+ \circuitikzbasekey/bipole/current/direction = backward,
+ \circuitikzbasekey/bipole/current/x position = before,
+ \circuitikzbasekey/bipole/current/y position = above
+ }
+}
+
+\tikzset{i<_/.style = {
+ i = #1,
+ \circuitikzbasekey/bipole/current/direction = backward,
+ \circuitikzbasekey/bipole/current/x position = before,
+ \circuitikzbasekey/bipole/current/y position = below
+ }
+}
+
+\tikzset{i/.code = {
+% \ifpgf@circuit@bipole@iscurrent
+% \pgfkeys{\circuitikzbasekey/bipole/current/position=above}
+% \else
+% \pgfkeys{\circuitikzbasekey/bipole/current/position=below}
+% \fi
+ \pgfkeys{\circuitikzbasekey/bipole/current/direction = forward,
+ \circuitikzbasekey/bipole/current/x position = after,
+ \circuitikzbasekey/bipole/current/y position = above }
+ \pgfkeys{/tikz/circuitikz/bipole/current/label/name=#1}
+ \ctikzsetvalof{bipole/current/label/unit}{}
+ \ifpgf@circ@siunitx
+ \pgf@circ@handleSI{#1}
+ \ifpgf@circ@siunitx@res
+ \edef\pgf@temp{\pgf@circ@handleSI@val}
+ \pgfkeyslet{/tikz/circuitikz/bipole/current/label/name}{\pgf@temp}
+ \edef\pgf@temp{\pgf@circ@handleSI@unit}
+ \pgfkeyslet{/tikz/circuitikz/bipole/current/label/unit}{\pgf@temp}
+ \else
+ \fi
+ \else
+ \fi
+}
+}
+
+\tikzset{i</.style = { i = #1, \circuitikzbasekey/bipole/current/direction = backward } }
+\tikzset{i_/.style = { i = #1, \circuitikzbasekey/bipole/current/y position = below } }
+\tikzset{i>/.style = {i = #1, \circuitikzbasekey/bipole/current/direction = forward } }
+\tikzset{i^/.style = { i= #1, \circuitikzbasekey/bipole/current/y position = above } }
+
+
+\def\pgf@circ@drawnormalcurrent{
+ \ifpgf@circuit@bipole@current@before
+ \ifpgf@circuit@bipole@current@backward
+ { (\ctikzvalof{bipole/name}.left) --
+ node [currarrow, pos=\ctikzvalof{current/distance}, sloped, allow upside down] (Iarrow) {}
+ (\tikztostart)
+ }
+ \else
+ { (\tikztostart) --
+ node [currarrow, pos=\ctikzvalof{current/distance}, sloped, allow upside down] (Iarrow) {}
+ (\ctikzvalof{bipole/name}.left)
+ }
+ \fi
+ \else
+ \ifpgf@circuit@bipole@current@backward
+ { (\tikztotarget) --
+ node [currarrow, pos=\ctikzvalof{current/distance}, sloped, allow upside down] (Iarrow) {}
+ (\ctikzvalof{bipole/name}.right)
+ }
+ \else
+ { (\ctikzvalof{bipole/name}.right) --
+ node [currarrow, pos=\ctikzvalof{current/distance}, sloped, allow upside down] (Iarrow) {}
+ (\tikztotarget)
+ }
+ \fi
+ \fi
+}
+
+%% Output routine
+%% #1 - node name
+
+\def\pgf@circ@drawcurrent{
+ \pgfextra{
+ \edef\pgf@circ@ffffff{\pgf@circ@direction}
+ \def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@ffffff\pgf@nil}
+
+ \ifnum\pgfcircmathresult >4 \ifnum\pgfcircmathresult <86
+ \ifpgf@circuit@bipole@current@below
+ \def\pgf@circ@dir{north west} \else \def\pgf@circ@dir{south east}
+ \fi
+ \fi\fi
+ \ifnum\pgfcircmathresult >85 \ifnum\pgfcircmathresult <95
+ \ifpgf@circuit@bipole@current@below
+ \def\pgf@circ@dir{west} \else \def\pgf@circ@dir{east}
+ \fi
+ \fi\fi
+ \ifnum\pgfcircmathresult >94 \ifnum\pgfcircmathresult <176
+ \ifpgf@circuit@bipole@current@below
+ \def\pgf@circ@dir{south west}\else \def\pgf@circ@dir{north east}
+ \fi
+ \fi\fi
+ \ifnum\pgfcircmathresult >175 \ifnum\pgfcircmathresult <185
+ \ifpgf@circuit@bipole@current@below
+ \def\pgf@circ@dir{south}\else\def\pgf@circ@dir{north}
+ \fi
+ \fi\fi
+ \ifnum\pgfcircmathresult >184 \ifnum\pgfcircmathresult <256
+ \ifpgf@circuit@bipole@current@below
+ \def\pgf@circ@dir{south east}\else\def\pgf@circ@dir{north west}
+ \fi
+ \fi\fi
+ \ifnum\pgfcircmathresult >265 \ifnum\pgfcircmathresult <275
+ \ifpgf@circuit@bipole@current@below
+ \def\pgf@circ@dir{east}\else \def\pgf@circ@dir{west}
+ \fi
+ \fi\fi
+ \ifnum\pgfcircmathresult >284 \ifnum\pgfcircmathresult <356
+ \ifpgf@circuit@bipole@current@below
+ \def\pgf@circ@dir{north east}\else\def\pgf@circ@dir{south west}
+ \fi
+ \fi\fi
+ \ifnum\pgfcircmathresult <5
+ \ifpgf@circuit@bipole@current@below
+ \def\pgf@circ@dir{north}\else\def\pgf@circ@dir{south}
+ \fi
+ \fi
+ \ifnum\pgfcircmathresult >355
+ \ifpgf@circuit@bipole@current@below
+ \def\pgf@circ@dir{north}\else\def\pgf@circ@dir{south}
+ \fi
+ \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 % caso di corrente (centrata) su un corto
+ \ifpgf@circuit@bipole@current@backward
+ { (\tikztotarget) --
+ node [currarrow, pos=\ctikzvalof{current/distance}, sloped, allow upside down] (Iarrow) {}
+ (\tikztostart) }
+ \else
+ { (\tikztostart) --
+ node [currarrow, pos=\ctikzvalof{current/distance}, sloped, allow upside down] (Iarrow) {}
+ (\tikztotarget) }
+ \fi
+
+ \else % altri bipoli - e quindi tra nodo e target
+
+ \ifpgf@circuit@bipole@iscurrent
+ \ifpgf@circuit@europeancurrent
+ \pgf@circ@drawnormalcurrent
+ \else
+ \fi
+ \else
+ \pgf@circ@drawnormalcurrent
+ \fi
+ \fi
+
+ \ifpgf@circuit@bipole@iscurrent
+ node [anchor=\pgf@circ@dir] at (\ctikzvalof{bipole/name}.\pgf@circ@bipole@current@label@where)
+ { \pgf@circ@finallabel{current/} }
+ \else
+ (Iarrow.\pgf@circ@bipole@current@label@where) node [anchor=\pgf@circ@dir]
+ { \pgf@circ@finallabel{current/} }
+ \fi
+
+}
+
+\endinput
+
+
+