相对于节点移动绘制命令

相对于节点移动绘制命令

我正在尝试使用 TikZ 中的节点制作框图。我需要画一个扬声器来表示信号是音频信号。

这是 tikzpicture 的代码:

\tikzstyle{block} = [draw, minimum width=1.2cm, minimum height=0.8cm, align=center]
\begin{tikzpicture}[every node/.style={scale=0.5}]

\node[block, text width=1.4cm](am_demod) at (0, 0){Envelope detector};

% Rama tono
\node[block, above right=0.4cm and 0.5cm of am_demod](lpf_tono) {$LPF$};
\node[block, text width=1.4cm, right=0.4cm of lpf_tono](cf_tono) {Corrector de fase};

% Rama FM (ref)
\node[block, right=0.5cm of am_demod](bpf_fm) {$BPF$};
\node[block, right=0.4cm of bpf_fm](lim) {Limitador};
\node[block, right=0.4cm of lim](bpf_fm2) {$BPF$};
\node[block, right=0.4cm of bpf_fm2](dt) {$\frac{d}{dt}$};
\node[block, text width=1.4cm, right=0.4cm of dt](env) {Envelope detector};
\node[block, text width=1.4cm, right=0.4cm of env](cf_ref) {Corrector de fase};

% Rama morse
\node[block, below right=0.8cm and 0.5cm of am_demod](bpf_morse) {$BPF$};
\node[draw,circle, minimum size=0.6cm, right=0.7cm of bpf_morse](mul) {};
\node[block, right=0.7cm of mul](lpf_morse) {$LPF$};
\node[below=0.4cm of mul, align=center](cos) {$2 \cdot cos(2\pi f_{morse}t)$};

\draw[scale=0.25, shift=($(mul.north) + (0mm, 0.8mm)$)] (11mm,2mm) -- +(0mm,-4mm)
    (13mm,4mm) -- +(0mm,-8mm)
    (15mm,6mm) -- +(0mm,-12mm)
    (0mm,0mm) -- +(0mm,-3mm) -- +(4mm,-3mm) -- +(9mm,-7mm) -- +(9mm,7mm) -- +(4mm,3mm) -- +(0mm,3mm) -- +(0mm,0mm);

\end{tikzpicture}

我正在使用以下 tikz 库:

\usetikzlibrary{math, calc, arrows, angles, quotes, patterns, positioning}

我的问题是,当我尝试通过 node.north 坐标加上偏移量来移动绘图时,我不知道在最后一个绘图命令中使用正确的语法。

提前致谢

答案1

无法随意移动某些路径。但是,您可以在移动时考虑此节点的坐标。例如,如果节点位于右侧(0,0),则可以移动绘制扬声器的路径,例如\draw[scale=0.25, xshift=-40mm] ...

您的图像可以以更一致、更简洁的方式绘制。通过使用chain库,MWE 可以:

\documentclass[margin=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{chains,
                positioning}

\begin{document}

    \begin{tikzpicture}[
    node distance = 4mm and 5mm,
      start chain = going right,
every node/.style = {scale=0.5}, 
     block/.style = {draw, minimum width=13mm, minimum height=11mm, 
                     align=center},
         C/.style = {circle, draw, minimum size =9mm}
                     ]
    \begin{scope}[nodes={block, on chain}]
\node[anchor=west] (am_demod)   {Envelope\\ detector}; % <---
\node (bpf_fm2)                 {$BPF$};
\node (lim)                     {Limitador};
\node (bpf_fm)                  {$BPF$};
\node (dt)                      {$\frac{d}{dt}$};
\node (env)                     {Envelope\\ detector};
\node (cf_ref)                  {Corrector\\ de fase};
    \end{scope}
% Rama tono
\node[block, above=of bpf_fm2]  (lpf_tono) {$LPF$};
\node[block, above=of lim]      (cf_tono)   {Corrector\\  de fase};
% Rama morse
\node[block, below=of bpf_fm2]  (bpf_morse) {$BPF$};
\node[C, below=of lim]  (mul)   {};
\node[block, below=of bpf_fm] (lpf_morse) {$LPF$};
\node[below=of mul]     (cos)   {$2 {\cdot} cos(2\pi f_{\mathrm{morse}}t)$};

\draw[scale=0.25, xshift=-40mm] % <---
    (11mm,2mm) -- +(0mm,-4mm)
    (13mm,4mm) -- +(0mm,-8mm)
    (15mm,6mm) -- +(0mm,-12mm)
    (0mm,0mm)  -- +(0mm,-3mm) -- +(4mm,-3mm) -- +(9mm,-7mm) 
               -- +(9mm, 7mm) -- +(4mm, 3mm) -- +(0mm,3mm) 
               -- +(0mm,0mm);
\end{tikzpicture}

\end{document}

在我看来,你的块方案并不完整。缺少连接块的箭头。这是如何实现的以及它们是否有标签尚不清楚。我只能建议使用quotes箭头标签库。

在此处输入图片描述

编辑:您可以将扬声器绘制为pic图像并将其定位为节点主分支的输入。

join还让我们预测,节点的主分支由没有标签的箭头连接。然后,考虑宏(在 中定义chains)绘制的箭头并用于扬声器的MWE\pic是:

\documentclass[margin=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                chains,
                positioning}

\begin{document}

    \begin{tikzpicture}[
    node distance = 4mm and 5mm,
      start chain = A going right,
every node/.style = {scale=0.5},
       arr/.style = {draw=gray, semithick, -{Straight Barb[scale=0.8]}},
     block/.style = {draw, minimum width=13mm, minimum height=11mm,
                     align=center},
         C/.style = {circle, draw, minimum size=9mm},
pics/speaker/.style = {code={%
  \draw (0,0) coordinate[right=0.45] (-LS)
        -- +(0,-0.15)   -- +(0.2,-0.15) -- +(0.45,-0.35)
        -- +(0.45,0.35) -- +(0.2, 0.15) -- +(0,0.15)
        -- cycle
    (0.6,0.1) to[bend left] +(0,-0.2)
    (0.7,0.2) to[bend left] +(0,-0.4)
    (0.8,0.3) to[bend left] +(0,-0.6);
    }}
                       ]
% loudspeaker
\pic (in) {speaker};
%%%% positioning of blocks      
    \begin{scope}[nodes={block, on chain, join=by arr}]
\node[right=2mm of in-LS]  {Envelope\\ detector};  % A-1
\node   {$BPF$};                            % A-2
\node   {Limitador};
\node   {$BPF$};
\node   {$\frac{d}{dt}$};
\node   {Envelope\\ detector};
\node   {Corrector\\ de fase};              % A-7
    \end{scope}
% Rama tono
\node[block, above=of A-2]  (A-2a)  {$LPF$};
\node[block, above=of A-3]  (A-3a)  {Corrector\\ de fase};
% Rama morse
\node[block, below=of A-2]  (A-2b) {$BPF$};
\node[C,     at={(A-3 |- A-2b)}]    (A-3b)  {};
\node[block, below=of A-4]  (A-4b)  {$LPF$};
\node[below=of A-3b]        (cos)   {$2\cdot\cos(2\pi f_{\mathrm{morse}}t)$};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容