![带有 circuitikz 的磁控管符号](https://linux22.com/image/338328/%E5%B8%A6%E6%9C%89%20circuitikz%20%E7%9A%84%E7%A3%81%E6%8E%A7%E7%AE%A1%E7%AC%A6%E5%8F%B7.png)
答案1
这里是,如果可以的话,我将把它包含在下一个 circuitikz 版本中:
\documentclass{standalone}
\usepackage{circuitikz}
\makeatletter
\ctikzset{/tikz/circuitikz/tripoles/magnetron/width/.initial=1}
\pgfdeclareshape{magnetron}
{
\savedanchor\northwest{
\pgf@y= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/magnetron/width}\pgf@y
\pgf@y=.5\pgf@y
\pgf@x= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
\pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/magnetron/width}\pgf@x
\pgf@x=.5\pgf@x
}
\anchor{center}{
\pgfpointorigin
}
\anchor{anode}{
\northwest
\pgf@circ@res@step= \pgf@y
\pgfpointorigin
\pgfpathmoveto{ \pgfpointpolar{-90}{\pgf@circ@res@step}}
}
\anchor{cathode1}{
\northwest
\pgf@circ@res@step= \pgf@y
\pgfpointorigin
\pgfpathmoveto{ \pgfpointpolar{105}{\pgf@circ@res@step}}
}
\anchor{cathode2}{
\northwest
\pgf@circ@res@step= \pgf@y
\pgfpointorigin
\pgfpathmoveto{ \pgfpointpolar{75}{\pgf@circ@res@step}}
}
\anchor{text}{
\pgfpointorigin
\advance \pgf@x by -.5\wd\pgfnodeparttextbox
\advance \pgf@y by -.5\ht\pgfnodeparttextbox
}
\anchor{left}{%
\northwest
\pgf@y=0pt
}
\anchor{right}{%
\northwest
\pgf@y=0pt
\pgf@x=-\pgf@x
}
\anchor{top}{
\northwest
\pgf@x=0pt
}
\anchor{pathstart}{
\northwest
\pgf@x=0pt
}
\anchor{pathend}{
\northwest
\pgf@x=0pt
\pgf@y=-\pgf@y
}
\anchor{bottom}{
\northwest
\pgf@x=0pt
\pgf@y=-\pgf@y
}
\anchor{center}{
\pgf@y=0pt
\pgf@x=0pt
}
\anchor{east}{
\northwest
\pgf@y=0pt
\pgf@x=-\pgf@x
}
\anchor{west}{
\northwest
\pgf@y=0pt
}
\anchor{south}{
\northwest
\pgf@x=0pt
\pgf@y=-\pgf@y
}
\anchor{north}{
\northwest
\pgf@x=0pt
}
\backgroundpath{
\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
\pgf@circ@res@step=\ctikzvalof{tripoles/magnetron/width}\pgf@circ@Rlen
\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
\pgfmathsetlength{\pgf@circ@res@other}{sin(15)*\pgf@circ@res@up}
\pgfscope
\pgfstartlinewidth=\pgflinewidth
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
%create outer circle
\pgfpathcircle{\pgfpoint{0}{0}} {\pgf@circ@res@right}
\pgfsetfillcolor{white}
\pgfusepath{draw}
%create chambers
\foreach \angle in {45,135,225,315}{
\pgfpathmoveto{ \pgfpointpolar{\angle}{0.4\pgf@circ@res@right}}
\pgfpathlineto{ \pgfpointpolar{\angle}{\pgf@circ@res@right}}
}
\pgfsetroundcap
\pgfusepath{draw}
\pgfscope
%draw connection from outside
%anode
\pgfsetlinewidth{\pgfstartlinewidth}
\pgfpathmoveto{\pgfpoint{0\pgf@circ@res@left}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{0\pgf@circ@res@right}{.15\pgf@circ@res@down}}
%cathodes
\pgfpathmoveto{\pgfpointpolar{105}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{-\pgf@circ@res@other}{.5\pgf@circ@res@up}}
\pgfpathmoveto{\pgfpointpolar{75}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{.5\pgf@circ@res@up}}
\pgfsetbuttcap
\pgfusepath{draw}
\endpgfscope
%create cathode
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{.5\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{0}{.15\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{-\pgf@circ@res@other}{.5\pgf@circ@res@up}}
\pgfusepath{draw}
%create anode
\pgfpathmoveto{\pgfpoint{0.3\pgf@circ@res@left}{.15\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{0.3\pgf@circ@res@right}{.15\pgf@circ@res@down}}
\pgfsetbuttcap
\pgfusepath{draw}
\endpgfscope
}
}
\makeatother
\begin{document}
\begin{circuitikz}
\draw (0,0) to[L]++(0,-2);
\draw (2,-1) node[magnetron,scale=1](magn){};
\draw (magn.anode) --++(0,-1)node[rground]{};
\draw (magn.cathode1)--++(0,1)node[above]{$1$};
\draw (magn.cathode2)--++(0,1)node[above]{$2$};
\draw[->](magn.east) --++(1,0)node[right]{$RF_{out}$};
\end{circuitikz}
\end{document}
此致,
斯蒂芬
答案2
我修改了 Stefan 代码,认为它更好:
\documentclass{standalone}
\usepackage{circuitikz}
\usepackage[english]{babel}
\makeatletter
\ctikzset{/tikz/circuitikz/tripoles/magnetron/width/.initial=1}
\pgfdeclareshape{magnetron}
{
\savedanchor\northwest{
\pgf@y= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/magnetron/width}\pgf@y
\pgf@y=.5\pgf@y
\pgf@x= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
\pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/magnetron/width}\pgf@x
\pgf@x=.5\pgf@x
}
\anchor{center}{
\pgfpointorigin
}
\anchor{anode}{
\northwest
\pgf@circ@res@step= \pgf@y
\pgfpointorigin
\pgfpathmoveto{ \pgfpointpolar{-90}{\pgf@circ@res@step}}
}
\anchor{cathode1}{
\northwest
\pgf@circ@res@step= \pgf@y
\pgfpointorigin
\pgfpathmoveto{ \pgfpointpolar{105}{\pgf@circ@res@step}}
}
\anchor{cathode2}{
\northwest
\pgf@circ@res@step= \pgf@y
\pgfpointorigin
\pgfpathmoveto{ \pgfpointpolar{75}{\pgf@circ@res@step}}
}
\anchor{text}{
\pgfpointorigin
\advance \pgf@x by -.5\wd\pgfnodeparttextbox
\advance \pgf@y by -.5\ht\pgfnodeparttextbox
}
\anchor{left}{%
\northwest
\pgf@y=0pt
}
\anchor{right}{%
\northwest
\pgf@y=0pt
\pgf@x=-\pgf@x
}
\anchor{top}{
\northwest
\pgf@x=0pt
}
\anchor{pathstart}{
\northwest
\pgf@x=0pt
}
\anchor{pathend}{
\northwest
\pgf@x=0pt
\pgf@y=-\pgf@y
}
\anchor{bottom}{
\northwest
\pgf@x=0pt
\pgf@y=-\pgf@y
}
\anchor{center}{
\pgf@y=0pt
\pgf@x=0pt
}
\anchor{east}{
\northwest
\pgf@y=0pt
\pgf@x=-\pgf@x
}
\anchor{west}{
\northwest
\pgf@y=0pt
}
\anchor{south}{
\northwest
\pgf@x=0pt
\pgf@y=-\pgf@y
}
\anchor{north}{
\northwest
\pgf@x=0pt
}
\backgroundpath{
\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
\pgf@circ@res@step=\ctikzvalof{tripoles/magnetron/width}\pgf@circ@Rlen
\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
\pgfmathsetlength{\pgf@circ@res@other}{sin(15)*\pgf@circ@res@up}
\pgfscope
\pgfstartlinewidth=\pgflinewidth
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
%create outer circle
\pgfpathcircle{\pgfpoint{0}{0}} {\pgf@circ@res@right}
\pgfsetfillcolor{white}
\pgfusepath{draw}
%create chambers
\foreach \angle in {45,135,225,315}{
\pgfpathmoveto{ \pgfpointpolar{\angle}{0.6\pgf@circ@res@right}}
\pgfpathlineto{ \pgfpointpolar{\angle}{\pgf@circ@res@right}}
}
\pgfsetroundcap
\pgfusepath{draw}
\pgfscope
%draw connection from outside
%anode
\pgfsetlinewidth{\pgfstartlinewidth}
\pgfpathmoveto{\pgfpoint{0\pgf@circ@res@left}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{0\pgf@circ@res@right}{.5\pgf@circ@res@down}}
%cathodes
\pgfpathmoveto{\pgfpointpolar{105}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{-\pgf@circ@res@other}{.5\pgf@circ@res@up}}
\pgfpathmoveto{\pgfpointpolar{75}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{.5\pgf@circ@res@up}}
\pgfsetbuttcap
\pgfusepath{draw}
\endpgfscope
%create cathode
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{.5\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{0}{.15\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{-\pgf@circ@res@other}{.5\pgf@circ@res@up}}
\pgfusepath{draw}
%create anode
\pgfpathmoveto{\pgfpoint{0.3\pgf@circ@res@left}{.5\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{0.3\pgf@circ@res@right}{.5\pgf@circ@res@down}}
\pgfsetbuttcap
\pgfusepath{draw}
\endpgfscope
}
}
\makeatother
\begin{document}
\begin{circuitikz}
\draw (0,0) to[L]++(0,-2);
\draw (2,-1) node[magnetron,scale=1](magn){};
\draw (magn.anode) --++(0,-1)node[rground]{};
\draw (magn.cathode1)--++(0,1)node[above]{$1$};
\draw (magn.cathode2)--++(0,1)node[above]{$2$};
\draw[->](magn.east) --++(1,0)node[right]{$RF_{out}$};
\end{circuitikz}
\end{document}