% 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. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Quadripoles \long\def\pgfcircdeclarequadpole#1#2#3{ \pgfdeclareshape{#1} { \anchor{center}{ \northwest \pgf@x=0pt } \savedanchor\northwest{% \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/quadpoles/#1/height}\pgf@circ@Rlen \pgf@y=.5\pgf@y \pgf@x=.5\pgf@circ@Rlen \pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/quadpoles/#1/width}\pgf@x } \anchor{A2}{ \northwest \pgf@y=-\pgf@y } \anchor{B1}{ \northwest \pgf@x=-\pgf@x } \anchor{A1}{ \northwest } \anchor{B2}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y } \anchor{north}{ \northwest \pgf@x=0pt } \anchor{south}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } \anchor{west}{ \northwest \pgf@y=0pt } \anchor{east}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } \anchor{south west}{ \northwest \pgf@y=-\pgf@y } \anchor{north east}{ \northwest \pgf@x=-\pgf@x } \anchor{north west}{ \northwest } \anchor{south east}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y } \anchor{base}{ \northwest \pgf@x=0pt } #3 \backgroundpath{ \pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}} \northwest \pgf@circ@res@up = \pgf@y \pgf@circ@res@down = -\pgf@y \pgf@circ@res@right = -\pgf@x \pgf@circ@res@left = \pgf@x #2 } } } \def\pgf@circ@drawtransformerbasicanchor{ \pgfkeysvalueof{/tikz/circuitikz/quadpoles/trans/height} \anchor{AA2}{ \northwest \pgf@x=\pgfkeysvalueof{/tikz/circuitikz/quadpoles/transformer/width1}\pgf@x \pgf@x=.7\pgf@x \pgf@y=-\pgf@y \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/quadpoles/transformer/height1}\pgf@y } \anchor{BB1}{ \northwest \pgf@x=-\pgf@x \pgf@x=\pgfkeysvalueof{/tikz/circuitikz/quadpoles/transformer/width1}\pgf@x \pgf@x=.7\pgf@x \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/quadpoles/transformer/height1}\pgf@y } \anchor{AA1}{ \northwest \pgf@x=\pgfkeysvalueof{/tikz/circuitikz/quadpoles/transformer/width1}\pgf@x \pgf@x=.7\pgf@x \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/quadpoles/transformer/height1}\pgf@y } \anchor{BB2}{ \northwest \pgf@x=-\pgf@x \pgf@x=\pgfkeysvalueof{/tikz/circuitikz/quadpoles/transformer/width1}\pgf@x \pgf@x=.7\pgf@x \pgf@y=-\pgf@y \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/quadpoles/transformer/height1}\pgf@y } } \def\pgf@circ@drawtransformerbasicbody{ \def\stretto{.4} \pgfscope \pgfslopedattimetrue \pgfallowupsidedownattimetrue \pgftransformlineattime{.5}{% \pgfpoint% {\stretto\pgf@circ@res@left}% {\pgf@circ@res@up}% }{% \pgfpoint {\stretto\pgf@circ@res@left}% {\pgf@circ@res@down}% } \edef\pgf@circ@temp{\ctikzvalof{inductor}}% \def\pgf@temp{european}% \ifx\pgf@temp\pgf@circ@temp% \pgfnode{fullgenericshape}{center}{}{pgf@inductor1}{\pgfusepath{stroke}} \else% \def\pgf@temp{cute} \ifx\pgf@temp\pgf@circ@temp% \pgfnode{cuteinductorshape}{center}{}{pgf@inductor1}{\pgfusepath{stroke}} \else% \pgfnode{americaninductorshape}{center}{}{pgf@inductor1}{\pgfusepath{stroke}} \fi% \fi% \endpgfscope \pgfscope \pgfslopedattimetrue \pgfallowupsidedownattimetrue \pgftransformlineattime{.5}{% \pgfpoint% {\stretto\pgf@circ@res@right}% {\pgf@circ@res@down}% }{% \pgfpoint {\stretto\pgf@circ@res@right}% {\pgf@circ@res@up}% } \edef\pgf@circ@temp{\ctikzvalof{inductor}}% \def\pgf@temp{european}% \ifx\pgf@temp\pgf@circ@temp% \pgfnode{fullgenericshape}{center}{}{pgf@inductor2}{\pgfusepath{stroke}} \else% \def\pgf@temp{cute} \ifx\pgf@temp\pgf@circ@temp% \pgfnode{cuteinductorshape}{center}{}{pgf@inductor2}{\pgfusepath{stroke}} \else% \pgfnode{americaninductorshape}{center}{}{pgf@inductor2}{\pgfusepath{stroke}} \fi% \fi% \endpgfscope \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint{\stretto\pgf@circ@res@left}{\pgf@circ@res@up}} \pgfpathlineto{\pgfpointanchor{pgf@inductor1}{b}} \pgfpathmoveto{\pgfpointanchor{pgf@inductor1}{a}} \pgfpathlineto{\pgfpoint{\stretto\pgf@circ@res@left}{\pgf@circ@res@down}} \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}} \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint{\stretto\pgf@circ@res@right}{\pgf@circ@res@up}} \pgfpathlineto{\pgfpointanchor{pgf@inductor2}{a}} \pgfpathmoveto{\pgfpointanchor{pgf@inductor2}{b}} \pgfpathlineto{\pgfpoint{\stretto\pgf@circ@res@right}{\pgf@circ@res@down}} \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}} \pgfusepath{draw} } % contrib Kristofer M. Monisit \pgfdeclareshape{fd op amp} { \anchor{center}{\pgfpointorigin} \savedanchor\northwest{% \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/height}\pgf@circ@Rlen \pgf@y=.5\pgf@y \pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/width}\pgf@circ@Rlen \pgf@x=.5\pgf@x } \anchor{south}{ \northwest \pgf@y=-\pgf@y } \anchor{north}{ \northwest } \savedanchor\left{% \pgf@y=0pt } \savedanchor\inOne{% \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/height}\pgf@circ@Rlen \pgf@y=.5\pgf@y \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@y \pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/width}\pgf@circ@Rlen \pgf@x=.5\pgf@x } \anchor{-}{ \inOne } \anchor{+}{ \inOne \pgf@y=-\pgf@y } \savedanchor\up{% \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/height}\pgf@circ@Rlen \pgf@y=.5\pgf@y \pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/width}\pgf@circ@Rlen \pgf@x=.5\pgf@x \pgf@circ@res@up = \pgf@y \pgf@circ@res@right = -\pgf@x \pgf@circ@res@left = \pgf@x \pgfpointlineattime{ \pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/up pos}}{ \pgfpoint{ \pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left} {\pgf@circ@res@up}} {\pgfpoint{.7\pgf@circ@res@right}{0pt}} } \anchor{up}{ \up } \anchor{down}{ \up \pgf@y=-\pgf@y } \anchor{out +}{ \northwest \pgf@y=.5\pgf@y \pgf@x=-.7\pgf@x } \anchor{out -}{ \northwest \pgf@y=-.5\pgf@y \pgf@x=-.7\pgf@x } \anchor{west}{ \left } \anchor{east}{ \left \pgf@x=-\pgf@x } \backgroundpath{ \pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}} \northwest \pgf@circ@res@up = \pgf@y \pgf@circ@res@down = -\pgf@y \pgf@circ@res@right = -\pgf@x \pgf@circ@res@left = \pgf@x % Negative input terminal \pgfpathmoveto{\pgfpoint {\pgf@circ@res@left} {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left} {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@up}} \pgftext[left, at=\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@up}]{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/font} $-$} % Positive input terminal \pgfpathmoveto{\pgfpoint {\pgf@circ@res@left} {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@down}} \pgfpathlineto{\pgfpoint {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left} {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@down}} \pgftext[left, at=\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@down}]{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/font} $+$} % Negative output terminal \pgfpathmoveto{\pgfpoint {0.7\pgf@circ@res@right} {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@down}} \pgfpathlineto{\pgfpoint {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}} {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@down}} \pgftext[left, at=\pgfpoint{0.3\pgf@circ@res@left}{.3\pgf@circ@res@down}]{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/font} $-$} % Positive output terminal \pgfpathmoveto{\pgfpoint {0.7\pgf@circ@res@right} {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}} {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@up}} \pgftext[left, at=\pgfpoint{0.3\pgf@circ@res@left}{.3\pgf@circ@res@up}]{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/font} $+$} \pgfsetrectcap % Draw them all! \pgfusepath{draw} % Triangle \pgfscope \pgfsetlinewidth{2\pgflinewidth} \pgftransformxshift{.7\pgf@circ@res@left} \pgf@circ@res@step=\pgf@circ@res@right \advance\pgf@circ@res@step by -\pgf@circ@res@left \pgf@circ@res@step=.7\pgf@circ@res@step \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}} \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}} \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{0pt}} \pgfpathclose \pgfusepath{draw} \endpgfscope } } \pgfcircdeclarequadpole{transformer}{ \pgf@circ@drawtransformerbasicbody }{\pgf@circ@drawtransformerbasicanchor} \pgfcircdeclarequadpole{transformer core}{ \pgf@circ@drawtransformerbasicbody \pgfmoveto{\pgfpoint% {\ctikzvalof{quadpoles/transformer core/core width}\pgf@circ@res@right}% {\ctikzvalof{quadpoles/transformer core/core height}\pgf@circ@res@down}% } \pgflineto{ \pgfpoint {\ctikzvalof{quadpoles/transformer core/core width}\pgf@circ@res@right}% {\ctikzvalof{quadpoles/transformer core/core height}\pgf@circ@res@up}% } \pgfmoveto{\pgfpoint% {\ctikzvalof{quadpoles/transformer core/core width}\pgf@circ@res@left}% {\ctikzvalof{quadpoles/transformer core/core height}\pgf@circ@res@down}% } \pgflineto{ \pgfpoint {\ctikzvalof{quadpoles/transformer core/core width}\pgf@circ@res@left}% {\ctikzvalof{quadpoles/transformer core/core height}\pgf@circ@res@up}% } \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgflinewidth} \pgfusepath{draw} }{\pgf@circ@drawtransformerbasicanchor} \pgfcircdeclarequadpole{gyrator}{ \def\stretto{.4} \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint{\stretto\pgf@circ@res@left}{\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint{\stretto\pgf@circ@res@left}{\pgf@circ@res@down}} \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}} \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint{\stretto\pgf@circ@res@right}{\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint{\stretto\pgf@circ@res@right}{\pgf@circ@res@down}} \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}} \pgfusepath{draw} \pgfsetlinewidth{2\pgflinewidth} \pgfpathmoveto{\pgfpoint{\stretto\pgf@circ@res@left}{.7*\stretto\pgf@circ@res@down}} \pgfpatharc{90}{270}{.7*\stretto\pgf@circ@res@down} \pgfpathmoveto{\pgfpoint{\stretto\pgf@circ@res@right}{.7*\stretto\pgf@circ@res@up}} \pgfpatharc{-90}{90}{.7*\stretto\pgf@circ@res@down} \pgfusepath{draw} }{} %% four-port % defines a general outer box for four-ports % TikZ usage: % \draw (0,0) node[coupler](coup){\SI{-3}{dB}} % (coup.port1) to[short,-o] ++(-1,0) % \long\def\pgfcircdeclarefourport#1#2{ \pgfdeclareshape{#1}{ \anchor{center}{ \northwest \pgf@x=0pt \pgf@y=0pt } \savedanchor\northwest{% \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/quadpoles/#1/height}\pgf@circ@Rlen \pgf@y=.5\pgf@y \pgf@x=.5\pgf@circ@Rlen \pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/quadpoles/#1/width}\pgf@x } \anchor{north}{ \northwest \pgf@x=0pt } \anchor{south}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } \anchor{west}{ \northwest \pgf@y=0pt } \anchor{east}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } \anchor{south west}{ \northwest \pgf@y=-\pgf@y } \anchor{north east}{ \northwest \pgf@x=-\pgf@x } \anchor{north west}{ \northwest } \anchor{south east}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y } \anchor{port1}{ \northwest \pgf@y=-0.5\pgf@y } \anchor{port2}{ \northwest \pgf@x=-\pgf@x \pgf@y=-0.5\pgf@y } \anchor{port3}{ \northwest \pgf@x=-\pgf@x \pgf@y=0.5\pgf@y } \anchor{port4}{ \northwest \pgf@y=0.5\pgf@y } \anchor{1}{ \northwest \pgf@y=-0.5\pgf@y } \anchor{2}{ \northwest \pgf@x=-\pgf@x \pgf@y=-0.5\pgf@y } \anchor{3}{ \northwest \pgf@x=-\pgf@x \pgf@y=0.5\pgf@y } \anchor{4}{ \northwest \pgf@y=0.5\pgf@y } \anchor{text}{ \northwest \advance \pgf@y by 0.5\ht\pgfnodeparttextbox \pgf@x=-.5\wd\pgfnodeparttextbox } \backgroundpath{ \pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}} \northwest \pgf@circ@res@up = \pgf@y \pgf@circ@res@down = -\pgf@y \pgf@circ@res@right = -\pgf@x \pgf@circ@res@left = \pgf@x \pgfstartlinewidth=\pgflinewidth % draw outer box \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth} \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}} \pgfusepath{draw} % draw inner stuff #2 % draw inner text \pgftext[center,x=-0.15\pgf@circ@res@step,y=0]{\ctikzvalof{bipoles/twoport/text}} } } } % four-port \pgfcircdeclarefourport{fourport}{} % straight coupler \pgfcircdeclarefourport{coupler}{ \pgfsetlinewidth{\pgfstartlinewidth} \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0.5\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0.5\pgf@circ@res@up}} \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0.5\pgf@circ@res@down}} \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0.5\pgf@circ@res@down}} \pgfusepath{draw} \pgfpathmoveto{\pgfpoint{0.7\pgf@circ@res@left}{0.4\pgf@circ@res@down}} \pgfpathlineto{\pgfpoint{0.7\pgf@circ@res@right}{0.4\pgf@circ@res@up}} \pgfsetarrows{latex-latex} \pgfusepath{draw} \pgfpathmoveto{\pgfpoint{0.7\pgf@circ@res@left}{0.4\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint{0.7\pgf@circ@res@right}{0.4\pgf@circ@res@down}} \pgfsetarrows{latex-latex} \pgfusepath{draw} } % "bended" coupler \pgfcircdeclarefourport{coupler2}{ \pgfsetlinewidth{\pgfstartlinewidth} \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0.5\pgf@circ@res@up}} \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0.5\pgf@circ@res@up}} \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0.5\pgf@circ@res@down}} \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0.5\pgf@circ@res@down}} \pgfusepath{draw} \pgfpathmoveto{\pgfpoint{0.1\pgf@circ@res@left}{0pt}} \pgfpatharc{0}{90} {0.4\pgf@circ@res@up} \pgfsetarrowsend{latex} \pgfusepath{draw} \pgfpathmoveto{\pgfpoint{0.1\pgf@circ@res@left}{0pt}} \pgfpatharc{0}{-90} {0.4\pgf@circ@res@up} \pgfsetarrowsend{latex} \pgfusepath{draw} \pgfpathmoveto{\pgfpoint{0.1\pgf@circ@res@right}{0pt}} \pgfpatharc{180}{90} {0.4\pgf@circ@res@up} \pgfsetarrowsend{latex} \pgfusepath{draw} \pgfpathmoveto{\pgfpoint{0.1\pgf@circ@res@right}{0pt}} \pgfpatharc{-180}{-90} {0.4\pgf@circ@res@up} \pgfsetarrowsend{latex} \pgfusepath{draw} }