[pstricks] Drawing Feature Diagrams

Herbert Voss Herbert.Voss at fu-berlin.de
Fri May 1 22:16:00 CEST 2009


Paulo Matos schrieb:

> 'with ease' is obviously relative but if I have to typeset them,
> having to create an addon or a plugin to an existing package would
> take already time I don't have.
> 
> An example can be seen in:
> http://en.wikipedia.org/wiki/File:E-shopFM.jpg
> 
> Note that this diagram can in general be a graph. One of the
> difficulties or drawing such a beast is the arch between branches,
> which may exist not only between two branches (like in the picture in
> Bank Transfer <-> Credit card) but spanning several branches.

\documentclass[12pt,a4paper]{article}
\usepackage{pst-tree,pstricks-add}
\SpecialCoor
\newcommand{\Itemf}[2][]{\Tr[ref=b,#1]{%

\psframebox[linestyle=solid,fillcolor=cyan!50,fillstyle=solid]{\vphantom{gh}#2}}}
\renewcommand{\psedge}{\ncdiag[arm=0]}
\newcommand{\psedgeA}{\ncdiag[arm=0,arrowscale=2,arrows=-o,nodesepB=3pt]}
\newcommand{\psedgeB}{\ncdiag[arm=0,arrowscale=2,arrows=-*,nodesepB=3pt]}

\makeatletter
\def\Arc{\@ifnextchar*{\Arc at istar}{\Arc at i}}%
\def\Arc at i#1#2#3{%
\psarc[linecolor=black](#1){1cm}%
  {!\psGetNodeCenter{#1} \psGetNodeCenter{#2}
    #1.y #2.y sub abs #1.x #2.x sub abs atan 180 add 8 sub}%
  {!\psGetNodeCenter{#3}
    #1.y #3.y sub abs #1.x #3.x sub abs atan neg 360 add 8 add}}
\def\Arc at istar*#1#2#3{%
\pswedge*[linecolor=black](#1){1cm}%
  {!\psGetNodeCenter{#1} \psGetNodeCenter{#2}
    #1.y #2.y sub abs #1.x #2.x sub abs atan 180 add 8 sub}%
  {!\psGetNodeCenter{#3}
    #1.y #3.y sub abs #1.x #3.x sub abs atan neg 360 add 8 add}}
\makeatother
\begin{document}

\psset{angleA=-90,angleB=90,levelsep=72pt}

\pstree{\Itemf{E-Shop}}{%
    \Itemf[edge=\psedgeB]{Catalogue}%
    \pstree{\Itemf[edge=\psedgeB,name=payment]{Payment}}{
      \Itemf[name=bank]{Bank transfer}%
      \Itemf[name=credit]{Credit Card}%
    }%
    \pstree{\Itemf[edge=\psedgeB,name=security]{Security}}{
      \Itemf[name=high]{High}%
      \Itemf[name=standard]{Standard}%
    }%
    \Itemf[edge=\psedgeA]{Search}%
}
\Arc*{payment}{bank}{credit}\Arc{security}{high}{standard}

\end{document}


Herbert



More information about the PSTricks mailing list