Search code examples
latexdiagramtikz

TikZ code for bandwidth segmentation: display problem


I would like to illustrate graphically a bandwidth segmentizer. To do so, I would like to represent the following diagram in TikZ diagram to realise in Tikz

So far, I have the following LaTeX code

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usepackage{amsmath, amssymb, mathtools}
\usepackage{physics}



\newcounter{cnt}\setcounter{cnt}{0}
\begin{document}
    \tikzset{str_to_vec/.style = {rectangle, draw, minimum width=3cm, text centered}}
    \tikzset{modulus2/.style = {rectangle, draw, text centered}}
    \tikzset{thresh/.style = {rectangle, draw, text centered}}
    \tikzset{dottedline/.style = {ultra thick, loosely dotted,shorten >=1mm, shorten <=1mm}}
    \begin{tikzpicture}[>=latex]
        \node[rectangle, draw] (RX) at (0, 0) {Rx};
        \node[
            rectangle,
            draw,
            minimum height=3cm,
            text width=1.8cm,
            text centered
            ]
        (PFB_CHANNELIZER) at ($(RX) + (3, 0)$)
        {PFB\\ Channelizer};

        \draw[->]
        (RX)
        --
        (
        $(PFB_CHANNELIZER.north west)
        !0.5!
        (PFB_CHANNELIZER.south west)$
        );

        \foreach \i in {0.15, 0.35}
        {
            \draw[->]
            (
            $(PFB_CHANNELIZER.north east)
            !\i!
            (PFB_CHANNELIZER.south east)$
            )
            coordinate (PFB_\thecnt)
            to
            ++(1.5, 0)
            coordinate (STR_TO_VEC_\thecnt)
            node[str_to_vec, anchor=west] {stream to vector};

            \draw[->]
            (STR_TO_VEC_\thecnt.east)
            to
            ++(5, 0)
            coordinate (MODULUS2_\thecnt)
            node[modulus2, anchor=west] {$\norm{\cdot}^2$};

            \draw[->]
            (MODULUS2_\thecnt.east)
            to
            ++(5, 0)
            coordinate (THRESHOLD_\thecnt)
            node[thresh, anchor=west] {threshold};
            \stepcounter{cnt}
        }

        \draw[->]
        (
        $(PFB_CHANNELIZER.north east)
        !0.85!
        (PFB_CHANNELIZER.south east)$
        )
        coordinate (PFB_3)
        to
        ++(1.5, 0)
        coordinate (STR_TO_VEC_3)
        node[str_to_vec, anchor=west] {stream to vector};

        \draw[->]
        (STR_TO_VEC_3.east)
        to
        ++(5, 0)
        coordinate (MODULUS2_3)
        node[modulus2, anchor=west] {$\norm{\cdot}^2$};

        \draw[->]
        (MODULUS2_3.east)
        to
        ++(5, 0)
        coordinate (THRESHOLD_3)
        node[thresh, anchor=west] {threshold};

        \draw[dottedline]
        (STR_TO_VEC_1.south)
        --
        (STR_TO_VEC_3.north);

        \draw[dottedline]
        (MODULUS2_1.south)
        --
        (MODULUS2_3.north);
    \end{tikzpicture}
\end{document}

which produces a strange output result of TikZ code (probably because of the anchor=west) options, and I do not know how to do without these. Can someone help me out ? Thank you and have a nice day, Alex


Solution

  • The problem is that you are drawing your arrows from the previous arrow and not from the previous node. If you add a name to your nodes instead (foo in the example below), the new arrow won't be drawn over the old node:

    \documentclass{standalone}
    \usepackage{tikz}
    \usetikzlibrary{positioning,calc}
    \usepackage{amsmath, amssymb, mathtools}
    \usepackage{physics}
    
    
    
    \newcounter{cnt}\setcounter{cnt}{0}
    \begin{document}
        \tikzset{str_to_vec/.style = {rectangle, draw, minimum width=3cm, text centered}}
        \tikzset{modulus2/.style = {rectangle, draw, text centered}}
        \tikzset{thresh/.style = {rectangle, draw, text centered}}
        \tikzset{dottedline/.style = {ultra thick, loosely dotted,shorten >=1mm, shorten <=1mm}}
        \begin{tikzpicture}[>=latex]
    
            \draw[->]
            (0,0)
            to
            ++(5, 0)
            coordinate (MODULUS2_3)
            node[modulus2, anchor=west] (foo) {$\norm{\cdot}^2$};
    
            \draw[->]
            (foo)
            to
            ++(5, 0)
            coordinate (THRESHOLD_3)
            node[thresh, anchor=west] {threshold};
    
    
        \end{tikzpicture}
    \end{document}
    

    enter image description here