3

In the following diagram, some distances are set manually testing different values, but they do not have exact dimensions.

\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},  
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=18.75cm,font=\fontsize{12}{0}\selectfont] at ($(Reader.west)!.5!(TAG.east)$) {\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 thin, opacity=0] ([yshift=11pt]AT.east) -- node [above,font=\fontsize{12}{0}\selectfont,yshift=10pt, black,opacity=1] {Power-Up \\[0.3em] Link} ([yshift=11pt]PTtag.west);
\draw [-Latex,darkgray,very thin, opacity=0] ([yshift=-11pt]PTtag.west) -- node [below,font=\fontsize{12}{0}\selectfont,yshift=-5pt,black,opacity=1] {Backscattered \\[0.4em] Link} ([yshift=-11pt]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=22pt]AT.east) --([yshift=18pt]PTtag.west)--([yshift=5pt]PTtag.west) --([yshift=0pt]AT.east);
    \draw[red,thick] foreach \X in {1,...,15} {([yshift=11pt,xshift=-0.5mm]AT.east) ellipse(\X*3.65mm and {(3.65+\X)*1mm})};
\end{scope}

\begin{scope}
\clip ([yshift=-18pt]PTtag.west) --([yshift=-15pt]AT.east) --([yshift=-7pt]AT.east)-- ([yshift=-4pt]PTtag.west);
\draw[red,thick] foreach \X in {1,...,15} {([yshift=-11pt,xshift=-0.25mm]PTtag.west) ellipse(\X*3.25mm and {(3.25+\X)*1mm})};
\end{scope}

\end{tikzpicture}
\end{document}

enter image description here

Specifically, the rectangle "Scenario Setup" does not match the exact width of the Reader and Tag container boxes. I have been testing values of minimum width= until one that visually matches but it not exact. A similar problem has the vertical box "Energy Harvester", which I have been testing different vertical widths to match the distance between the top of the "FSA" box to the bottom of the "Passive Transceiver" box, but it is not exact.

I have done other manual settings like the arrow lines that go from/to the vertical box "Energy Harvester" to the other three horizontal boxes, FSA, PHY and Passive Transceiver. In those lines, the start and end positions have been y-shifted to look horizontal lines, but they are not perfectly horizontals.

I would like to ask how to set exact dimensions of Scenario Setup and Energy Harvester boxes, and how to set the shifted lines to be horizontals.

Regards

3

You can use fit nodes with inner sep=0pt and text node placed with label=center:... to create nodes like "scenario" and "energy harvester".

And arrows can be adjusted using perpendicular coordinates -| and |- as end points.

Side comment: font options could be included in .style definitions to save some typing. And also node distance could be included in positioning options.

\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},  
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};

  \node [vertblock, fit=(FSAtag.north) (PTtag.south), inner ysep=0pt, right=5mm of PHYtag, label={[font=\fontsize{12}{0}\selectfont, rotate=90]center:Energy Hasvester}, fill=pink!30] (EHtag) {};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   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=18.75cm,font=\fontsize{12}{0}\selectfont] at ($(Reader.west)!.5!(TAG.east)$) {\textbf{Scenario Setup}};

 \node[brwblock, fit=(Reader.west) (TAG.east), inner sep=0pt, above right= 1cm and 0pt of Reader.north west, 
 label={[font=\fontsize{12}{0}\selectfont]center:\textbf{Scenario Setup}}
 ] (scenario) {};

%************************************************************
%************************************************************
%  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 thin, opacity=0] ([yshift=11pt]AT.east) -- node [above,font=\fontsize{12}{0}\selectfont,yshift=10pt, black,opacity=1] {Power-Up \\[0.3em] Link} ([yshift=11pt]PTtag.west);
\draw [-Latex,darkgray,very thin, opacity=0] ([yshift=-11pt]PTtag.west) -- node [below,font=\fontsize{12}{0}\selectfont,yshift=-5pt,black,opacity=1] {Backscattered \\[0.4em] Link} ([yshift=-11pt]AT.east);

\draw [Latex-,darkgray, thick] ([yshift=-10pt]PTtag.east) coordinate(aux) -- (aux-|EHtag.west);
\draw [-Latex,darkgray, thick] ([yshift=10pt]PTtag.east) coordinate(aux) -- (aux-|EHtag.west);
%\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] (PHYtag) -- (PHYtag-|EHtag.west);
%\draw [Latex-,darkgray, thick] ([yshift= 0pt]PHYtag.east) -- ([yshift=-1pt]EHtag.south);
\draw [Latex-,darkgray, thick] (FSAtag) -- (FSAtag-|EHtag.west);
%\draw [Latex-,darkgray, thick] ([yshift= 0pt]FSAtag.east) -- ([yshift=82pt]EHtag.south);

\begin{scope}
    \clip ([yshift=22pt]AT.east) --([yshift=18pt]PTtag.west)--([yshift=5pt]PTtag.west) --([yshift=0pt]AT.east);
    \draw[red,thick] foreach \X in {1,...,15} {([yshift=11pt,xshift=-0.5mm]AT.east) ellipse(\X*3.65mm and {(3.65+\X)*1mm})};
\end{scope}

\begin{scope}
\clip ([yshift=-18pt]PTtag.west) --([yshift=-15pt]AT.east) --([yshift=-7pt]AT.east)-- ([yshift=-4pt]PTtag.west);
\draw[red,thick] foreach \X in {1,...,15} {([yshift=-11pt,xshift=-0.25mm]PTtag.west) ellipse(\X*3.25mm and {(3.25+\X)*1mm})};
\end{scope}

\end{tikzpicture}
\end{document}

enter image description here

2
  • Thank you very much. May ask you about the position commands above right= 1cm and 0pt of Reader.north west used in the Scenario Setup box. I do not understand its use. Thank you. – user1993416 Mar 11 '19 at 12:24
  • @user1993416 Please, read section 17.5.3 Advanced Placement Options in pgfmanual. positioning library is explained there. – Ignasi Mar 11 '19 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.