TikZ/CircuiTikZ 电源分配器符号

TikZ/CircuiTikZ 电源分配器符号

我想为 CircuiTikZ 绘制一个功率分配器符号,就像下面这样,但我真的不知道从哪里开始。也许这样的符号(即使输入/输出处没有“圆圈”)已经存在?

在此处输入图片描述

我的第一次尝试是

\newcommand{\Splitter}[1] 
{  % #1 = name
\begin{scope}[transform shape]
\draw[thick] (#1)node[](a){} +(-12pt,-12pt) rectangle +(12pt,12pt);
\draw[rotate=0] ([yshift=0pt]a) +(-25pt,0) -- +(-5pt,0);
\draw[rotate=0] ([yshift=0pt]a) +(-5pt,0) -- +(9pt,9pt);
\draw[rotate=0] ([yshift=0pt]a) +(-5pt,0) -- +(9pt,-9pt);
\draw[rotate=0] ([yshift=0pt]a) +(9pt,-9pt) -- +(25pt,-9pt);
\draw[rotate=0] ([yshift=0pt]a) +(9pt,+9pt) -- +(25pt,+9pt);
\end{scope}
}

问题是,将其包含在文档中,将我的分离器连接到输入/输出块是不可能的(或者非常困难)。

梅威瑟:

\documentclass{standalone}
\usepackage{circuitikz}
\newcommand{\Splitter}[1] 
{  % #1 = name
\begin{scope}[transform shape]
\draw[thick] (#1)node[](a){} +(-12pt,-12pt) rectangle +(12pt,12pt);
\draw[rotate=0] ([yshift=0pt]a) +(-25pt,0) -- +(-5pt,0);
\draw[rotate=0] ([yshift=0pt]a) +(-5pt,0) -- +(9pt,9pt);
\draw[rotate=0] ([yshift=0pt]a) +(-5pt,0) -- +(9pt,-9pt);
\draw[rotate=0] ([yshift=0pt]a) +(9pt,-9pt) -- +(25pt,-9pt);
\draw[rotate=0] ([yshift=0pt]a) +(9pt,+9pt) -- +(25pt,+9pt);
\end{scope}
}
\begin{document}  
\tikzset{ar/.style={-latex,shorten >=-1pt, shorten <=-1pt},
         block/.style = {draw, thick, rectangle, minimum height = 3em, minimum width = 3em}}
\begin{circuitikz}
%Input node
\node[block] at (-2,0) (in) {Input};

%Splitter
\path (0,0) to[sV,color=white,name=test]node[midway,above=-0.15cm]{Splitter}(0,1);
\Splitter{test}

%Input nodes
\node[block] at (+2,1) (out1) {Output 1};
\node[block] at (+2,-1) (out2) {Output 2};
\end{circuitikz}
\end{document}

在此处输入图片描述

感谢您的帮助!

答案1

替代 :-)

在此处输入图片描述

分离器被定义为节点。它的输出定义了两个新的锚点:out Aout B

\documentclass[border=1mm]{standalone}
\usepackage{siunitx}
\usepackage[siunitx]{circuitikz}
\usetikzlibrary{positioning,
                shapes
                }

\makeatletter
%%%% new anchors: "out A" and "out B"
\expandafter\def\csname pgf@anchor@rectangle@out A\endcsname{% output A: below .east
    \pgf@process{\southwest}%
    \pgf@ya=0.25\pgf@y%
    \pgf@process{\northeast}%
    \pgf@y=0.75\pgf@y%
    \advance\pgf@y by\pgf@ya    }% end of out A
\expandafter\def\csname pgf@anchor@rectangle@out B\endcsname{% output B: above .east
    \pgf@process{\southwest}%
    \pgf@ya=0.75\pgf@y%
    \pgf@process{\northeast}%
    \pgf@y=0.25\pgf@y%
    \advance\pgf@y by\pgf@ya    } % end of out B
\makeatother

\tikzset%
{
splitter/.style = {rectangle, draw, semithick, minimum height=10mm, minimum width=15mm,
                            append after command={\pgfextra{\let\LN\tikzlastnode
     \draw[thick] (\LN.west) -- ([xshift=-4mm] \LN.center)
                             -- ([xshift=-8mm] \LN.out A)
                             -- (\LN.out A)
  ([xshift=-4mm] \LN.center) -- ([xshift=-8mm] \LN.out B)
                             -- (\LN.out B);
    \node[left,font=\footnotesize] at (\LN.east) {#1};
                                                }}
                        },
         splitter/.default = {}
}
\begin{document}
\begin{circuitikz}
\node[splitter=\SI{-3}{\decibel},label=splitter] (s) {};
\draw[red]  ([xshift=-11mm] s.west) node[left] {P1} to[short,o-]  (s.west)
            (s.out A) to[short,-o] ++ (1,0) node[right] {P2}
            (s.out B) to[short,-o] ++ (1,0) node[right] {P3};
% showing used splitter anchors
\coordinate[pin={[gray]135:west}]   (c) at (s.west) {};
\coordinate[pin={[gray] 45:out A}]  (c) at (s.out A) {};
\coordinate[pin={[gray]-45:out B}]  (c) at (s.out B) {};
\end{circuitikz}
\end{document}

答案2

此解决方案将分割器置于原点,并将其他所有内容与其对齐。虽然#1最初用于定位分割器,但我用它来命名节点和作为 的一部分inout1以及out2坐标名称。(不能使用.:作为名称分隔符,因为它们是保留的。)

如果你打算经常使用它,你可以考虑创建一个形状。然后添加锚点并执行一些操作,例如node[splitter,anchor=in]将节点与其输入锚点对齐等。我有一些教程我的网站

\documentclass{standalone}
\usepackage{circuitikz}
\newcommand{\Splitter}[1] 
{  % #1 = name
\begin{scope}[transform shape]
\draw[thick] node[](#1){} +(-12pt,-12pt) rectangle +(12pt,12pt);
\draw[rotate=0] ([yshift=0pt]#1) +(-25pt,0) coordinate(#1-in) -- +(-5pt,0);
\draw[rotate=0] ([yshift=0pt]#1) +(-5pt,0) -- +(9pt,9pt) -- +(25pt,9pt) coordinate(#1-out1);
\draw[rotate=0] ([yshift=0pt]#1) +(-5pt,0) -- +(9pt,-9pt) -- +(25pt,-9pt) coordinate(#1-out2);
\end{scope}
}
\begin{document}  
\tikzset{ar/.style={-latex,shorten >=-1pt, shorten <=-1pt},
         block/.style = {draw, thick, rectangle, minimum height = 3em, minimum width = 3em}}
\begin{circuitikz}
\Splitter{test}
\draw
  (test-in) node[block,left] {Input}
  (test-out1) node[block,above right] {Output 1}
  (test-out2) node[block,below right] {Output 2};
\end{circuitikz}
\end{document}

演示

相关内容