[Tex/LaTex] TikZ arrow positioning

tikz-arrowstikz-pgf

With help of you I could get started with TikZ and create this image:

Original

Because I want to explain the double arrow part (HIS <-> Processing) better, I want to extend the "HIS" block and split this into two different blocks, surrounded with a dashed container "HIS":

Extended

As you can see the arrows overlap and I don't know the correct syntax to shift arrows, like what happened on the right side. This is what I'd like to accomplish:

enter image description here

Note the shift of the arrow coming out of processing, which is translated to the bottom. This shifting is also needed to have arrows between Reporting and Archive. The tex code (I use pdflatex) with the complete document surrounding the image is this:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,fit,calc}
\tikzstyle{box} = [draw, rectangle, rounded corners, thick, node distance=7em, text width=6em, text centered, minimum height=3.5em]
\tikzstyle{container} = [draw, rectangle, dashed, inner sep=2em]
\tikzstyle{line} = [draw, thick, -latex']

\begin{document}

\begin{tikzpicture}[auto]
    \node [box] (planning) {Planning};
    \node [box, below of=planning] (resources) {Resources};
    \node [box, below of=resources] (sensors) {Sensors};
    \node [box, below of=sensors] (processing) {Processing};

    \coordinate (middle) at ($(resources.west)!0.5!(sensors.west)$);
    \node [box, left of=middle, node distance=10em] (archive) {Archive};
    \node [box, left of=archive, node distance=10em] (reporting) {Reporting};

    \node[container, fit=(resources) (sensors)] (or) {};
    \node at (or.north west) [above right,node distance=0 and 0] {OR};

    \node[container, fit=(archive) (reporting)] (his) {};
    \node at (his.north west) [above right,node distance=0 and 0] {HIS};

    \path [line] (planning) -- (resources);
    \path [line] (resources) -- (sensors);
    \path [line] (sensors) -- (processing);

    \path [line] (archive) |- (planning);
    \path [line] (archive) |- (processing);
    \path [line] (processing) -| (reporting);

    \draw [line] (processing.east) -- ++(2,0) node(lowerright){} |- (planning.east);
    \draw [line] (lowerright |- or.east) -- (or.east -| resources.south east);
\end{tikzpicture}

\end{document}

I tried already (processing.south) -| (reporting) instead of (processing) -| (reporting), but this doesn't translate the arrow enough to have it fist a vertical part.

Any help is really appreciated, as I hope to understand TikZ better!

Best Answer

My solution leads to:

enter image description here

The code to realize it is:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows,calc,fit}
\tikzset{box/.style={draw, rectangle, rounded corners, thick, node distance=7em, text width=6em, text centered, minimum height=3.5em}}
\tikzset{container/.style={draw, rectangle, dashed, inner sep=2em}}
\tikzset{line/.style={draw, thick, -latex'}}

\begin{document}

\begin{tikzpicture}[auto]
    \node [box] (planning) {Planning};
    \node [box, below of=planning] (resources) {Resources};
    \node [box, below of=resources] (sensors) {Sensors};
    \node [box, below of=sensors] (processing) {Processing};

    \coordinate (middle) at ($(resources.west)!0.5!(sensors.west)$);
    \node [box, left of=middle, node distance=10em] (archive) {Archive};
    \node [box, left of=archive, node distance=10em] (reporting) {Reporting};

    \node[container, fit=(resources) (sensors)] (or) {};
    \node at (or.north west) [above right,node distance=0 and 0] {OR};

    \node[container, fit=(archive) (reporting)] (his) {};
    \node at (his.north west) [above right,node distance=0 and 0] {HIS};

    \path [line] (planning) -- (resources);
    \path [line] (resources) -- (sensors);
    \path [line] (sensors) -- (processing);

    \path [line] (archive) |- (planning);
    \path [line] (archive) |- (processing);
    \path [line] (processing)--($(processing.south)-(0,0.5)$) -| (reporting);

    \draw [line] ($(processing.south)-(0,0.5)$) -- ++(4,0) node(lowerright){} |- (planning.east);
    \draw [line] (lowerright |- or.east) -- (or.east -| resources.south east);

    \draw[line] (archive.170)--(reporting.10);
    \draw[line] (reporting.350)--(archive.190);
\end{tikzpicture}

\end{document}

Explanation

To shift down from the Reporting to Processing box I used this trick:

\path [line] (processing)--($(processing.south)-(0,0.5)$) -| (reporting);

to draw a line below the box using as reference its south anchor. Of course ($(processing.south)-(0,0.5)$) is the new reference also to connect the Planning box to the Processing one:

\draw [line] ($(processing.south)-(0,0.5)$) -- ++(4,0) node(lowerright){} |- (planning.east);

Notice that here I extended your ++(2,0) to cope with the fact that the new starting position is in the middle of the box.

Finally, to draw connection lines between Reporting and Archive box I used definitions that you can find in the TikZ documentation 48.2 Predefined Shapes (rectangle).