2

I'm creating a few flowcharts for my thesis but I'm having trouble getting them to look right.

My processes are based upon this one: Basic flow chart however I can't work out how to

  1. Insert a key
  2. Make my arrows 'tunnel'

By point two I mean like the arrow going from 'Program Interupt?' to 'Acquire data'

Here's my current TiKZ code:

\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
\begin{document}
\pagestyle{empty}
% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=blue!20,
text width=4.5em, text badly centered, node distance=2.5cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=yellow!20,
text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, very thick, color=black!50, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=2.5cm,
minimum height=2em]
\tikzstyle{data} = [trapezium, draw, fill=green!20,
text width=5em, text centered, node distance=2.5cm, minimum height=0.5em]
\tikzstyle{input} = [regular polygon,regular polygon sides=5, draw,       fill=cyan!20, text width=5em, text centered, node distance=2.5cm, minimum     height=0.25em]
    \begin{tikzpicture}[scale=2, node distance = 2cm, auto]
% Place nodes
\node [cloud] (start) {start};
\node [input, below of=start, node distance=2.5cm] (input) {Input     parameters};
\node [input, below of=input, node distance=4cm] (initiate) {Initiate};
\node [block, below of=initiate, node distance=3cm] (calc) {Calculate focal     laws};
\node [block, right of=calc, node distance=3cm] (acq) {Acquire data};
\node [data, below of=acq] (FMC) {FMC};
\node [data, below of=FMC] (process) {Process data};
\node [data, left of=process, node distance=3cm] (focal) {Focal laws};
\node [data, below of=process] (render) {Render image};
\node [decision, below of=render] (decide) {Interupt prgoramme?};
\node [cloud, below of=decide] (end) {end};
% Draw edges
\path [line] (start) -- (input);
\path [line] (input) -- (initiate);
\path [line] (initiate) -- (calc);
\path [line] (calc) -- (focal);
\path [line] (initiate) -| (acq);
\path [line] (acq) -- (FMC);
\path [line] (FMC) -- (process);
\path [line] (process) -- (render);
\path [line] (render) -- (decide);
\path [line] (focal) -- (process);
\path [line] (decide) -- node [, color=black] {yes}(end);
\path [line] (decide) -| node [, color=black] {no}(focal);
\end{tikzpicture}
\end{document}

The solution in this answer gives a similar look to what I'm after, but how do I convert it from co-ordinates (such as (0,2)) to my nodes?

  • 1
    for tunneling do you mean this? – Ignasi Mar 29 '16 at 16:47
  • By the way, \tikzstyle is deprecated. – cfr Mar 29 '16 at 21:04
  • Ignasi, that is very similar to what I'd like to do, thank you. Any idea on how to add the key? cfr, I'm not sure what you mean by \tikzstyle being deprecated. Could you please elaborate? – BenK-G Apr 1 '16 at 8:55
  • 1
    Well, it is deprecated syntax and should be avoided in new code. \tikzset{} is the replacement. – cfr Apr 1 '16 at 11:07
  • You can just substitute node names for the coordinates e.g. write (FMC) or whatever in place of (0,2), for example. – cfr Apr 1 '16 at 11:59
2

Here's an example of how to 'tunnel' the connections using Mark Wibrow's code with named nodes/coordinates rather than absolute locations. I've also updated the syntax and libraries.

\documentclass[tikz,multi,border=10pt]{standalone}
\usetikzlibrary{shapes.geometric,arrows.meta,positioning,calc,intersections}
\begin{document}
\tikzset{%
  decision/.style={diamond, draw, fill=blue!20, text width=4.5em, text badly centered, node distance=2.5cm, inner sep=0pt},
  block/.style={rectangle, draw, fill=yellow!20, text width=5em, text centered, rounded corners, minimum height=4em},
  line/.style={draw, very thick, color=black!50, -LaTeX},
  my cloud/.style={draw, ellipse,fill=red!20, node distance=2.5cm, minimum height=2em},
  data/.style={trapezium, draw, fill=green!20, text width=5em, text centered, node distance=2.5cm, minimum height=0.5em},
  input/.style={regular polygon,regular polygon sides=5, draw, fill=cyan!20, text width=5em, text centered, node distance=2.5cm, minimum height=0.25em},
  connect/.style args={(#1) to (#2) over (#3) to (#4) by #5}{% code from Mark Wibrow, ref: https://tex.stackexchange.com/a/111674/
    insert path={
      \pgfextra{
        \pgfinterruptpath
        \path [name path=a] (#1) -- (#2);
        \path [name path=b] (#3) -- (#4);
        \path [name intersections={of=a and b,by=inter}];
        \endpgfinterruptpath
      }
      let \p1=($(#1)-(inter)$), \n1={veclen(\x1,\y1)}, \n2={atan2(\y1,\x1)}, \n3={abs(#5)}, \n4={#5>0 ?180:-180}  in (#1) -- ($(#1)!\n1-\n3!(inter)$) arc (\n2:\n2+\n4:\n3) -- (#2)
    }
  },
}
\begin{tikzpicture}[scale=2, node distance = 2cm, auto]
  % Place nodes
  \node [my cloud] (start) {start};
  \node [input, below=25mm of start] (input) {Input parameters};
  \node [input, below=40mm of input] (initiate) {Initiate};
  \node [block, below=30mm of initiate] (calc) {Calculate focal laws};
  \node [block, right=30mm of calc] (acq) {Acquire data};
  \node [data, below=of acq] (FMC) {FMC};
  \node [data, below=of FMC] (process) {Process data};
  \node [data] (focal) at (calc |- process) {Focal laws};
  \node [data, below=of process] (render) {Render image};
  \node [decision, below=of render] (decide) {Interrupt programme?};
  \node [my cloud, below=of decide] (end) {end};
  % Draw edges
  \path [line] (start) -- (input);
  \path [line] (input) -- (initiate);
  \path [line] (initiate) -- (calc);
  \path [line] (calc) -- (focal);
  \path [line] (initiate) -| (acq);
  \path [line] (acq) -- (FMC);
  \path [line] (FMC) -- (process);
  \path [line] (process) -- (render);
  \path [line] (render) -- (decide);
  \path [line] (decide) -- node [color=black] {yes}(end);
  \path [line] (decide) -| node [color=black] {no}(focal);
  \coordinate (join) at ($(calc)!1/2!(acq)$);
  \path [line, connect=(focal) to (process) over (decide.west -| join) to (join) by -5pt];
  \path [line] (decide.west -| join) |- (acq.west);
\end{tikzpicture}
\end{document}

connect over by

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.