6

I have a problem drawing first a vertical line (the red line in the attached example) from a node and then at some point horizontal to another point:

enter image description here

My code looks like this:

    \documentclass{standalone}
    \usepackage{tikz}
    \usetikzlibrary{calc,
                    arrows,
                    matrix,
                    chains,
                    arrows.meta,positioning,
                    decorations.pathreplacing,
                    decorations.markings,
                    intersections,
                    positioning,
                    fit}

    \tikzstyle{vecArrow} = [thick, decoration={markings,mark=at position
       1 with {\arrow[semithick]{open triangle 60}}},
       double distance=1.4pt, shorten >= 5.5pt,
       preaction = {decorate},
       postaction = {draw,line width=1.4pt, white,shorten >= 4.5pt}]
    \tikzstyle{innerWhite} = [semithick, white,line width=1.4pt, shorten >= 4.5pt]

    \tikzset{
        *|/.style={
            to path={
                (perpendicular cs: horizontal line through={(\tikztostart)},
                                     vertical line through={(\tikztotarget)})
                -- (\tikztotarget) \tikztonodes
            }
        }
    }

    %% \usepackage{showframe}
    \usepackage{amsmath}
    \usepackage[linesnumbered,ruled]{algorithm2e}

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \newcommand{\mygrid}{\tikz{\draw[step=2.5mm] (0,0)  grid (2.0,1);}}

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \begin{document}

    \begin{tikzpicture}[
      decoration={
        markings,
        mark=at position 0.5 with {\draw (3pt,2pt) -- (-3pt,-2pt);}
        }]

    \node[draw,rectangle,minimum height=7mm] (opm3) at (0.0,0.0)              {$Op_{-3}$};
    \node[draw,rectangle,minimum height=7mm] (opm2)       [right=2pt of opm3] {$Op_{-2}$};
    \node[draw,rectangle,minimum height=7mm] (opm1)       [right=2pt of opm2] {$Op_{-1}$};
    \node[draw,rectangle,minimum height=7mm] (opfirst)    [right=2pt of opm1] {$Op_{0}$};
    \node[draw,rectangle,minimum height=7mm] (oplast)     [right=of opfirst]  {$Op_{l-1}$};
    \node at ($(opfirst)!.5!(oplast)$) {\ldots};

    \node[draw,
    rectangle,
    minimum height=7mm,
    minimum width=65mm] (multiplexer) at (2.7,-2.0)        {Multiplexer};

    \draw[postaction={decorate}] (opm3.south)    -- (opm3.south|-multiplexer.north);
    \draw[postaction={decorate}] (opm2.south)    -- (opm2.south|-multiplexer.north);
    \draw[postaction={decorate}] (opm1.south)    -- (opm1.south|-multiplexer.north);
    \draw[postaction={decorate}] (opfirst.south) -- (opfirst.south|-multiplexer.north);
    \draw[postaction={decorate}] (oplast.south)   -- (oplast.south|-multiplexer.north);

    \node[draw,rectangle,minimum height=7mm] (zaehler1)    [right=10mm of multiplexer] {$Z\ddot{a}hler_1$};

    \draw[postaction={decorate}] (zaehler1.west) -- (zaehler1.west-|multiplexer.east);


    \node[draw,rectangle,minimum height=7mm, minimum width=20mm] (swar)        [below=10mm of multiplexer] {OP};
    \node [left=2pt of swar] {SWAR};

    \node[draw,rectangle,dotted,minimum height=7mm] (versatz)     [right=-0.5pt of swar] {Versatz};
    \node[draw,rectangle,minimum height=7mm,dotted] (zaehler2)    [right=10mm of versatz] {$Z\ddot{a}hler_2$};

    \node[draw,rectangle,minimum height=7mm, minimum width=20mm] (swar)        [below=10mm of multiplexer] {};

    \draw[dotted] (zaehler2.west) -- (zaehler2.west-|versatz.east);
    \draw[postaction={decorate}] (swar.north) -- (swar.north|-multiplexer.south);

    \node at (2.0,-7.0) {Steuertabelle};
    \node at (6.5,-5.0) {Steuersignale};

    \node[rectangle, draw, inner sep=0, shift={(5.0,-6.0)}] (stol) {\mygrid};
    \node[rectangle, draw, inner sep=0, shift={(8.0,-6.0)}] (stor) {\mygrid};
    \node at ($(stol)!.5!(stor)$) {\ldots};

    \node[rectangle, draw, inner sep=0, shift={(5.0,-8.0)}] (stul) {\mygrid};
    \node[rectangle, draw, inner sep=0, shift={(8.0,-8.0)}] (stur) {\mygrid};
    \node at ($(stul)!.5!(stur)$) {\ldots};

    \node at ($(stol)!.5!(stul)$) {\vdots};
    \node at ($(stor)!.5!(stur)$) {\vdots};

    \draw[thick,black] (4.0,-6.0) node (op) {} -- (6.0,-6.0) -- (6.0,-5.75) -- (4.0,-5.75) --(4.0,-6.0);
    \draw[thick,black] (7.0,-6.0) -- (9,-6.0) -- (9.0,-5.75) -- (7.0,-5.75) --(7.0,-6.0);

    \draw[thick,red,-{Latex[width=1mm]}] (swar.south) -- (4.0,-5.9);

    \end{tikzpicture}
\end{document}

Any idea is appreciated.

Thanks Marcel

3 Answers3

5

for fun and exercise (since your problem have been solved by Bobyandbob comment) ...

in mwe below i remove from yours all unnecessary anchor extension, define few new styles which make code much shorter, all elements are positioned relative to each other. btw, it is sufficient to load each tikz library ones :-)

maybe you will find the proposed solution useful:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
                calc, 
                decorations.markings,
                positioning,
                }

    \begin{document}

    \begin{tikzpicture}[
 node distance = 8mm and 10mm,
    box/.style = {draw, minimum height=7mm, outer sep=0mm},
   ebox/.style = {% emphesize box
                  draw, thick, inner sep=0mm,
                  minimum height=2.5mm, minimum width=20mm},
      DL/.style = {% Decorated Line
                  decoration={markings,
                              mark=at position 0.5 with
                              {\draw (3pt,2pt) -- (-3pt,-2pt);}},
                  postaction={decorate}},
 mygrid/.style = {inner sep=0mm,
                  minimum height=10mm, minimum width=20mm,
                  node contents={},
                  path picture={%
                  \draw[step=2.5mm]  (path picture bounding box.south west)  grid + (2,1);
                                }
                  },
shrtdot/.style = {thick, dotted, shorten > =2.2mm, shorten <=2.2mm}
                        ]

\node[box] (opm3)                           {$Op_{-3}$};
\node[box] (opm2)       [right=2pt of opm3] {$Op_{-2}$};
\node[box] (opm1)       [right=2pt of opm2] {$Op_{-1}$};
\node[box] (opfirst)    [right=2pt of opm1] {$Op_{0}$};
\node[box] (oplast)     [right=of opfirst]  {$Op_{l-1}$};
\draw[shrtdot] (opfirst) -- (oplast);

\node[box, minimum width=65mm] (multiplexer) at (2.7,-2.0)  {Multiplexer};

\draw[DL] (opm3) -- (opm3 |- multiplexer.north);
\draw[DL] (opm2) -- (opm2 |- multiplexer.north);
\draw[DL] (opm1) -- (opm1 |- multiplexer.north);
\draw[DL] (opfirst) -- (opfirst |- multiplexer.north);
\draw[DL] (oplast)  -- (oplast  |- multiplexer.north);

\node[box,right=of multiplexer] (zaehler1) {$Z\ddot{a}hler_1$};
\draw[DL] (zaehler1) -- (multiplexer);

\node[box, minimum width=20mm,
      below=of multiplexer] (swar)  {OP};
\node [left=2pt of swar]            {SWAR};

\node[box,dotted,
      right=0mm of swar] (versatz)      {Versatz};
\node[box,dotted,
      right=of versatz] (zaehler2)  {$Z\ddot{a}hler_2$};

\draw[shrtdot]  (zaehler2) -- (versatz);
\draw[DL]       (multiplexer) -- (swar);

\node (stol) [mygrid, below right=of swar];
\node (stor) [mygrid, right=of stol];
\draw[shrtdot]   (stol) -- (stor);
\node [above=1mm of $(stol.north)!0.5!(stor.north)$] (6.5,-5.0) {Steuersignale};

\node (stul) [mygrid, below=of stol];
\node (stur) [mygrid, below=of stor];
\draw[shrtdot]   (stul) -- (stur);
\node [left=of $(stol)!0.5!(stul)$] {Steuertabelle};

\draw[shrtdot]   (stol) -- (stul);
\draw[shrtdot]   (stor) -- (stur);

\node (a) [ebox,above] at (stol.center) {};
\node     [ebox,above] at (stor.center) {};

\draw[thick,red,-Latex] (swar) |- (a);
    \end{tikzpicture}
\end{document}

enter image description here

Zarko
  • 296,517
2

The proposed solution of bobbyandbob (see comments) works like a charm:

\draw[thick,red,-{Latex[width=1mm]}] (swar.south) |- (4.0,-5.9);
Damien Dtx
  • 706
  • 4
  • 11
1

A solution that gives more manual control uses the \coordinate command. The location of the "elbow" is at coordinates (2.7,-5.9). So the code

\coordinate(elbow) at (2.7,-5.9);
\draw[thick,red,-{Latex[width=1mm]}] (swar.south) -- (elbow) -- (4.0,-5.9);

will produce the output:

enter image description here

Changing the coordinates of the elbow

\coordinate(elbow) at (2.0,-5.9);
\draw[thick,red,-{Latex[width=1mm]}] (swar.south) -- (elbow) -- (4.0,-5.9);

produces more of a bend:

enter image description here

Sandy G
  • 42,558