You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.9 KiB

7 years ago
  1. % ROUNDDIAG STYLE
  2. % for LaTeX version 2e
  3. % by -- 2008 Martin Hutle <martin.hutle@epfl.ch>
  4. %
  5. % This style file is free software; you can redistribute it and/or
  6. % modify it under the terms of the GNU Lesser General Public
  7. % License as published by the Free Software Foundation; either
  8. % version 2 of the License, or (at your option) any later version.
  9. %
  10. % This style file is distributed in the hope that it will be useful,
  11. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. % Lesser General Public License for more details.
  14. %
  15. % You should have received a copy of the GNU Lesser General Public
  16. % License along with this style file; if not, write to the
  17. % Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18. % Boston, MA 02111-1307, USA.
  19. %
  20. \NeedsTeXFormat{LaTeX2e}
  21. \ProvidesPackage{rounddiag}
  22. \typeout{Document Style `rounddiag' - provides simple round diagrams}
  23. %
  24. \RequirePackage{ifthen}
  25. \RequirePackage{calc}
  26. \RequirePackage{tikz}
  27. \def\rdstretch{3}
  28. \tikzstyle{msg}=[->,thick,>=latex]
  29. \tikzstyle{rndline}=[dotted]
  30. \tikzstyle{procline}=[dotted]
  31. \newenvironment{rounddiag}[2]{
  32. \begin{center}
  33. \begin{tikzpicture}
  34. \foreach \i in {1,...,#1}
  35. \draw[procline] (0,#1-\i) node[xshift=-1em]{$p_{\i}$} -- (#2*\rdstretch+1,#1-\i);
  36. \foreach \i in {0,...,#2}
  37. \draw[rndline] (\i*\rdstretch+0.5,0) -- (\i*\rdstretch+0.5,#1-1);
  38. \newcommand{\rdat}[2]{
  39. (##2*\rdstretch+0.5,#1-##1)
  40. }%
  41. \newcommand{\round}[2]{%
  42. \def\rdround{##1}
  43. \ifthenelse{\equal{##2}{}}{}{
  44. \node[yshift=-1em] at ({##1*\rdstretch+0.5-{0.5*\rdstretch}},0) {##2};
  45. }
  46. }%
  47. \newcommand{\rdmessage}[3]{\draw[msg]
  48. (\rdround*\rdstretch-\rdstretch+0.5,#1-##1) -- node[yshift=1.2ex]{##3}
  49. (\rdround*\rdstretch+0.5,#1-##2);}%
  50. \newcommand{\rdalltoall}{%
  51. \foreach \i in {1,...,#1}
  52. \foreach \j in {1,...,#1}
  53. { \rdmessage{\i}{\j}{}}}%
  54. }{%
  55. \end{tikzpicture}
  56. \end{center}
  57. }