如何繪製代表無線鏈路連接的波形並設定盒子從一點到另一點的精確寬度

如何繪製代表無線鏈路連接的波形並設定盒子從一點到另一點的精確寬度

下圖表示兩台設備進行無線連線。

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\usetikzlibrary{shapes,arrows.meta,calc,fit,backgrounds,shapes.multipart,positioning}
\tikzset{box/.style={draw, rectangle, rounded corners, thick, node 
distance=7em, 
text width=6em, text centered, minimum height=3.5em}}
%\tikzset{line/.style={draw, thick, -{Latex[length=2mm,width=1mm]}}}
\tikzset{every node/.style={font=\footnotesize}}

\PreviewEnvironment{tikzpicture}
%=======================================
% Adjust the boarder of the flowchart
%=======================================
\setlength\PreviewBorder{4pt}%

\begin{document}
%************************************************************
%************************************************************
%  Define block styles
%************************************************************
%************************************************************
\tikzset{
block/.style={rectangle split, draw, rectangle split parts=2,text width=14em, text centered, rounded corners, minimum height=4em},
brwblock/.style={rectangle, draw, fill=brown!20, text width=13em, text centered, rounded corners, minimum height=3em, minimum width=30em}, 
whtblock/.style={rectangle, draw, fill=white!20, text width=14em, text centered, minimum height=4em},  
vertblock/.style={rectangle, draw, fill=cyan!20, text width=17em, text centered, minimum width=2em, minimum height=2em},   
line/.style={draw, {latex[length=5mm,width=5mm]}-{latex[length=5mm,width=5mm]}},
cloud/.style={draw, ellipse,fill=white!20, node distance=3cm,    minimum height=4em},  
% container/.style={draw, rectangle,dashed,inner sep=0.28cm, rounded corners,fill=yellow!20,minimum height=4cm}}
container1/.style={draw, rectangle,inner sep=0.4cm,fill=blue!8,minimum height=4cm,rounded corners},
container2/.style={draw, rectangle,inner sep=0.28cm,fill=green!10,minimum height=4em,rounded corners}}
%************************************************************
%************************************************************ 
\begin{tikzpicture}[node distance = 1.25cm, auto,every text node part/.style={align=center}]
%
%===============================================    
%  Reader
%===============================================  
  \node [whtblock,font=\fontsize{12}{0}\selectfont,fill=magenta!15] (LBT) {LBT \\[0.5em]Reader Anti-Collision Protocol};   
  \node [whtblock, below=of LBT, node distance=2.5cm,font=\fontsize{12}{0}\selectfont,fill=green!15] (FSA) {FSA \\[0.5em]Anti-Collision Protocol};
  \node [whtblock, below=of FSA, node distance=2.5cm,font=\fontsize{12}{0}\selectfont,fill=yellow!20] (PHY) {PHY Layer};
  \node [whtblock, below=of PHY, node distance=2.5cm,font=\fontsize{12}{0}\selectfont] (AT) {Active Transceiver};
%*****************
% TAG
%***************

  \node [whtblock, right=of AT, node distance=13cm,font=\fontsize{12}{0}\selectfont,shift={(2.8cm,0)}] (PTtag) {Passive Transceiver};
  \node [whtblock, above=of PTtag, node distance=13cm,font=\fontsize{12}{0}\selectfont,fill=yellow!20] (PHYtag) {PHY Layer};

  \node [whtblock, above=of PHYtag, node distance=13cm,font=\fontsize{12}{0}\selectfont,fill=green!15] (FSAtag) {FSA \\[0.5em]Anti-Collision Protocol};

  \node [vertblock, right=of PHYtag, node distance=13cm,font=\fontsize{12}{0}\selectfont,shift={(0cm,3.7cm)},fill=pink!30,rotate=-90] (EHtag) {Energy Harvester};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   CONTAINERS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{scope}[on background layer]
  \coordinate (aux1) at ([yshift=3mm]LBT.north);
  \node [container1,fit=(aux1) (FSA)(PHY)(AT)] (Reader) {};
  \node at (Reader.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] {\textbf{Reader}};
%-----------------------------------------------------------
  \coordinate (aux2) at ([yshift=3mm]FSAtag.north);
  \node [container1,fit=(aux2) (PHYtag)(FSAtag)(PTtag)(EHtag)] (TAG) {};
  \node at (TAG.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] {\textbf{Tag}};
\end{scope}

 \node[brwblock,shift={(0,8.0cm)},minimum width=18cm,font=\fontsize{12}{0}\selectfont] at ($(Reader)!.5!(TAG)$) {\textbf{Scenario Setup}};

%************************************************************
%************************************************************
%  Draw edges
%************************************************************
%************************************************************
\draw [Latex-Latex,darkgray, thick] (LBT.south) -- (FSA.north);
\draw [Latex-Latex,darkgray, thick] (FSA.south) -- (PHY.north);
\draw [Latex-Latex,darkgray, thick] (PHY.south) -- (AT.north);
\draw [Latex-Latex,darkgray, thick] (FSAtag.south) -- (PHYtag.north);
\draw [Latex-Latex,darkgray, thick] (PTtag.north) -- (PHYtag.south);

\draw [-Latex,darkgray,very thick] ([yshift=6pt]AT.east) -- node [above,font=\fontsize{12}{0}\selectfont] {Power-Up \\[0.5em] Link} ([yshift=6pt]PTtag.west);
\draw [-Latex,darkgray,very thick] ([yshift=-6pt]PTtag.west) -- node [below,font=\fontsize{12}{0}\selectfont] {Backscattered \\[0.5em] Link} ([yshift=-6pt]AT.east);
\draw [Latex-,darkgray, thick] ([yshift= -10pt]PTtag.east) -- ([yshift=-94pt]EHtag.south);
\draw [-Latex,darkgray, thick] ([yshift= +10pt]PTtag.east) -- ([yshift=-74pt]EHtag.south);
\draw [Latex-,darkgray, thick] ([yshift= 0pt]PHYtag.east) -- ([yshift=-1pt]EHtag.south);
\draw [Latex-,darkgray, thick] ([yshift= 0pt]PHYtag.east) -- ([yshift=-1pt]EHtag.south);
\draw [Latex-,darkgray, thick] ([yshift= 0pt]FSAtag.east) -- ([yshift=82pt]EHtag.south);
\end{tikzpicture}
\end{document}

在此輸入影像描述

我想用代表波隨距離衰減的曲線來取代標籤「Power-Up Link」和「Backscattered Link」的水平箭頭,就像我手工繪製的那樣。上電鏈路中的波幅應大於反向散射鏈路中的波幅。我不知道如何製作這個,而且我還沒有找到任何類似的情節。

另外,我想問如何設定「場景設定」框蓋從Reader容器左側到Tag容器右側的精確寬度。我一直在測試minimum width=in的值\node[brwblock,shift={(0,8.0cm)},minimum width=18cm,font=\fontsize{12}{0}\selectfont] at ($(Reader)!.5!(TAG)$) {\textbf{Scenario Setup}};,但它不適合兩個容器的寬度。

能量收集器盒也有同樣的問題。我想將這個盒子從 FSA 的頂部擴展到被動收發器的底部,但使用text width=該樣式很難匹配這個長度vertblock

同樣,我已將yshiftEnergy Harvester 框和其餘框之間的箭頭線值調整為水平,但很難確定匹配的 yshift 是什麼以使水平箭頭從該框指向 FSA 和 PHY 層,和無源收發器盒。

我不知道這些問題是否可以在一個問題中得到回答,還是應該單獨提出。

答案1

您可以只使用expanding waves裝飾並將不需要的部分剪掉。

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\usetikzlibrary{shapes,arrows.meta,calc,fit,backgrounds,shapes.multipart,positioning,decorations.pathreplacing}
\tikzset{box/.style={draw, rectangle, rounded corners, thick, node 
distance=7em, 
text width=6em, text centered, minimum height=3.5em}}
%\tikzset{line/.style={draw, thick, -{Latex[length=2mm,width=1mm]}}}
\tikzset{every node/.style={font=\footnotesize}}

\PreviewEnvironment{tikzpicture}
%=======================================
% Adjust the boarder of the flowchart
%=======================================
\setlength\PreviewBorder{4pt}%

\begin{document}
%************************************************************
%************************************************************
%  Define block styles
%************************************************************
%************************************************************
\tikzset{
block/.style={rectangle split, draw, rectangle split parts=2,text width=14em, text centered, rounded corners, minimum height=4em},
brwblock/.style={rectangle, draw, fill=brown!20, text width=13em, text centered, rounded corners, minimum height=3em, minimum width=30em}, 
whtblock/.style={rectangle, draw, fill=white!20, text width=14em, text centered, minimum height=4em},  
vertblock/.style={rectangle, draw, fill=cyan!20, text width=17em, text centered, minimum width=2em, minimum height=2em},   
line/.style={draw, {latex[length=5mm,width=5mm]}-{latex[length=5mm,width=5mm]}},
cloud/.style={draw, ellipse,fill=white!20, node distance=3cm,    minimum height=4em},  
% container/.style={draw, rectangle,dashed,inner sep=0.28cm, rounded corners,fill=yellow!20,minimum height=4cm}}
container1/.style={draw, rectangle,inner sep=0.4cm,fill=blue!8,minimum height=4cm,rounded corners},
container2/.style={draw, rectangle,inner sep=0.28cm,fill=green!10,minimum height=4em,rounded corners}}
%************************************************************
%************************************************************ 
\begin{tikzpicture}[node distance = 1.25cm, auto,every text node part/.style={align=center}]
%
%===============================================    
%  Reader
%===============================================  
  \node [whtblock,font=\fontsize{12}{0}\selectfont,fill=magenta!15] (LBT) {LBT \\[0.5em]Reader Anti-Collision Protocol};   
  \node [whtblock, below=of LBT, node distance=2.5cm,font=\fontsize{12}{0}\selectfont,fill=green!15] (FSA) {FSA \\[0.5em]Anti-Collision Protocol};
  \node [whtblock, below=of FSA, node distance=2.5cm,font=\fontsize{12}{0}\selectfont,fill=yellow!20] (PHY) {PHY Layer};
  \node [whtblock, below=of PHY, node distance=2.5cm,font=\fontsize{12}{0}\selectfont] (AT) {Active Transceiver};
%*****************
% TAG
%***************

  \node [whtblock, right=of AT, node distance=13cm,font=\fontsize{12}{0}\selectfont,shift={(2.8cm,0)}] (PTtag) {Passive Transceiver};
  \node [whtblock, above=of PTtag, node distance=13cm,font=\fontsize{12}{0}\selectfont,fill=yellow!20] (PHYtag) {PHY Layer};

  \node [whtblock, above=of PHYtag, node distance=13cm,font=\fontsize{12}{0}\selectfont,fill=green!15] (FSAtag) {FSA \\[0.5em]Anti-Collision Protocol};

  \node [vertblock, right=of PHYtag, node distance=13cm,font=\fontsize{12}{0}\selectfont,shift={(0cm,3.7cm)},fill=pink!30,rotate=-90] (EHtag) {Energy Harvester};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   CONTAINERS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{scope}[on background layer]
  \coordinate (aux1) at ([yshift=3mm]LBT.north);
  \node [container1,fit=(aux1) (FSA)(PHY)(AT)] (Reader) {};
  \node at (Reader.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] {\textbf{Reader}};
%-----------------------------------------------------------
  \coordinate (aux2) at ([yshift=3mm]FSAtag.north);
  \node [container1,fit=(aux2) (PHYtag)(FSAtag)(PTtag)(EHtag)] (TAG) {};
  \node at (TAG.north) [fill=white,draw,font=\fontsize{12}{0}\selectfont] {\textbf{Tag}};
\end{scope}

 \node[brwblock,shift={(0,8.0cm)},minimum width=18cm,font=\fontsize{12}{0}\selectfont] at ($(Reader)!.5!(TAG)$) {\textbf{Scenario Setup}};

%************************************************************
%************************************************************
%  Draw edges
%************************************************************
%************************************************************
\draw [Latex-Latex,darkgray, thick] (LBT.south) -- (FSA.north);
\draw [Latex-Latex,darkgray, thick] (FSA.south) -- (PHY.north);
\draw [Latex-Latex,darkgray, thick] (PHY.south) -- (AT.north);
\draw [Latex-Latex,darkgray, thick] (FSAtag.south) -- (PHYtag.north);
\draw [Latex-Latex,darkgray, thick] (PTtag.north) -- (PHYtag.south);

\draw [-Latex,darkgray,very thick] ([yshift=6pt]AT.east) -- node [above,font=\fontsize{12}{0}\selectfont] {Power-Up \\[0.5em] Link} ([yshift=6pt]PTtag.west);
\draw [-Latex,darkgray,very thick] ([yshift=-6pt]PTtag.west) -- node [below,font=\fontsize{12}{0}\selectfont] {Backscattered \\[0.5em] Link} ([yshift=-6pt]AT.east);
\draw [Latex-,darkgray, thick] ([yshift= -10pt]PTtag.east) -- ([yshift=-94pt]EHtag.south);
\draw [-Latex,darkgray, thick] ([yshift= +10pt]PTtag.east) -- ([yshift=-74pt]EHtag.south);
\draw [Latex-,darkgray, thick] ([yshift= 0pt]PHYtag.east) -- ([yshift=-1pt]EHtag.south);
\draw [Latex-,darkgray, thick] ([yshift= 0pt]PHYtag.east) -- ([yshift=-1pt]EHtag.south);
\draw [Latex-,darkgray, thick] ([yshift= 0pt]FSAtag.east) -- ([yshift=82pt]EHtag.south);
\begin{scope}
\clip ([yshift=24pt]AT.east) --([yshift=12pt]PTtag.west) --([yshift=0pt]AT.east);
\draw[red,thick,decorate,decoration={expanding waves,angle=20}] 
([yshift=12pt]AT.center) --([yshift=6pt]PTtag.west);
\end{scope}
\begin{scope}
\clip ([yshift=-12pt]PTtag.west) --([yshift=-8pt]AT.east)
-- ([yshift=-4pt]PTtag.west);
\draw[red,thick,decorate,decoration={expanding waves,angle=20}] 
([yshift=-8pt]PTtag.center) --([yshift=-8pt]AT.east);
\end{scope}
\end{tikzpicture}
\end{document}

在此輸入影像描述

如果我將上部剪輯範圍替換為

\begin{scope}
\clip[postaction=draw] ([yshift=24pt]AT.east) --([yshift=14pt]PTtag.west)--([yshift=10pt]PTtag.west) --([yshift=0pt]AT.east);
\draw[red,thick,decorate,decoration={expanding waves,angle=20}] 
([yshift=12pt]AT.center) --([yshift=6pt]PTtag.west);
\end{scope}

我明白了

在此輸入影像描述

所以波在它到達的地方(即右邊的盒子)更寬。解釋您的評論的第二種方法是使傳入的上波在其到達點處變寬,然後使下波在其離開點處變寬。這可以透過例如

\begin{scope}
\clip ([yshift=24pt]AT.east) --([yshift=15pt]PTtag.west)--([yshift=9pt]PTtag.west) --([yshift=0pt]AT.east);
\draw[red,thick,decorate,decoration={expanding waves,angle=20}] 
([yshift=12pt]AT.center) --([yshift=6pt]PTtag.center);
\end{scope}
\begin{scope}
\clip ([yshift=-12pt]PTtag.west) --([yshift=-9pt]AT.east) --([yshift=-7pt]AT.east)
-- ([yshift=-4pt]PTtag.west);
\draw[red,thick,decorate,decoration={expanding waves,angle=20}] 
([yshift=-8pt]PTtag.center) --([yshift=-8pt]AT.east);
\end{scope}

在此輸入影像描述

相關內容