From 1183f8e866b15342db38d90474db426a5d2197e1 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 24 Feb 2014 23:00:15 +0000 Subject: pgf-umlsd (24feb14) git-svn-id: svn://tug.org/texlive/trunk@33045 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/pgf-umlsd/pgf-umlsd.sty | 90 ++++++++++++++++------ 1 file changed, 68 insertions(+), 22 deletions(-) (limited to 'Master/texmf-dist/tex') diff --git a/Master/texmf-dist/tex/latex/pgf-umlsd/pgf-umlsd.sty b/Master/texmf-dist/tex/latex/pgf-umlsd/pgf-umlsd.sty index 01c97ca83fb..99847db73b5 100644 --- a/Master/texmf-dist/tex/latex/pgf-umlsd/pgf-umlsd.sty +++ b/Master/texmf-dist/tex/latex/pgf-umlsd/pgf-umlsd.sty @@ -7,6 +7,15 @@ % Contributor: Nobel Huang , Southeast University, China % % History: +% v0.7 2012/03/05 +% - unify interface of call and callself +% - non-instantaneous message +% - bugfix: conflits with tikz library backgrounds +% v0.6 2011/07/27 +% - Fix Issue 6 reported by frankmorgner@gmail.com +% - diagram without a thread +% - allows empty diagram +% - New manual % v0.5 2009/09/30 Fix Issue 2 reported by vlado.handziski % - Nested callself is supported % - Rename sdloop and sdframe to sdblock @@ -27,9 +36,14 @@ % \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\ProvidesPackage{pgf-umlsd}[2009/09/30 v0.5 Some LaTeX macros for UML +\ProvidesPackage{pgf-umlsd}[2011/07/27 v0.6 Some LaTeX macros for UML Sequence Diagrams.] +\RequirePackage{tikz} +\usetikzlibrary{arrows,shadows} + +\RequirePackage{ifthen} + % Options % ? the instance name under line ? \newif\ifpgfumlsdunderline\pgfumlsdunderlinetrue @@ -43,11 +57,6 @@ Sequence Diagrams.] \DeclareOption{roundedcorners=false}{\pgfumlsdroundedcornersfalse} \ProcessOptions -% declare layers -\pgfdeclarelayer{background} -\pgfdeclarelayer{threadground} -\pgfsetlayers{background,threadground,main} - % new counters \newcounter{preinst} \newcounter{instnum} @@ -86,7 +95,7 @@ Sequence Diagrams.] % draw running (thick) line, should not call directly \newcommand*{\drawthread}[2]{ - \begin{pgfonlayer}{threadground} + \begin{pgfonlayer}{umlsd@threadlayer} \draw[threadstyle] (#1.west) -- (#1.east) -- (#2.east) -- (#2.west) -- cycle; \end{pgfonlayer} } @@ -96,6 +105,27 @@ Sequence Diagrams.] % \begin{call}[height]{caller}{function}{callee}{return} % \end{call} \newenvironment{call}[5][1]{ +\ifthenelse{\equal{#2}{#4}} +{ + \begin{callself}[#1]{#2}{#3}{#5} +} +{ + \begin{callanother}[#1]{#2}{#3}{#4}{#5} +} +} +{ +\ifthenelse{\equal{\f\thecallevel}{\t\thecallevel}} +{ + \end{callself} +} +{ + \end{callanother} +} +} + +% function call to another instance +% interal use only +\newenvironment*{callanother}[5][1]{ \stepcounter{seqlevel} \stepcounter{callevel} % push \path @@ -122,10 +152,11 @@ Sequence Diagrams.] } % a function do not need call others +% interal use only % Example: % \begin{callself}[height]{caller}{function}{return} % \end{callself} -\newenvironment{callself}[4][1]{ +\newenvironment*{callself}[4][1]{ \stepcounter{seqlevel} \stepcounter{callevel} % push \stepcounter{callselflevel} @@ -139,6 +170,7 @@ Sequence Diagrams.] -- (scb\thecallevel); \def\l\thecallevel{#1} \def\f\thecallevel{#2} + \def\t\thecallevel{#2} \def\returnvalue{#4} \tikzstyle{threadstyle}+=[instcolor#2] }{ @@ -155,13 +187,19 @@ Sequence Diagrams.] % message between threads % Example: -% \mess{sender}{message content}{receiver} -\newcommand{\mess}[3]{ +% \mess[delay]{sender}{message content}{receiver} +\newcommand{\mess}[4][0]{ \stepcounter{seqlevel} \path - (#1)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (messbeg) {} - (#3)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (messend) {}; - \draw[->,>=angle 60] (messbeg) -- (messend) node[midway, above] {#2}; + (#2)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (mess from) {}; + \addtocounter{seqlevel}{#1} + \path + (#4)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (mess to) {}; + \draw[->,>=angle 60] (mess from) -- (mess to) node[midway, above] + {#3}; + + \node (#3 from) at (mess from) {}; + \node (#3 to) at (mess to) {}; } \newenvironment{messcall}[4][1]{ @@ -192,11 +230,12 @@ Sequence Diagrams.] % manually. Possible parameters are: center, west, east \newcommand{\setthreadbias}[1]{\global\def\threadbias{#1}} -% In the situation of multi-threads, some events happen at the same -% time. Currently, we have to adjust the level(time) of events -% manually. This function makes the call earlier. +% This function makes the call earlier. \newcommand{\prelevel}{\addtocounter{seqlevel}{-1}} +% This function makes the call later. +\newcommand{\postlevel}{\addtocounter{seqlevel}{+1}} + % a block box with caption % \begin{sdblock}[caption background color]{caption}{comments} % \end{sdblock} @@ -215,9 +254,8 @@ Sequence Diagrams.] (current bounding box.west |- {blockbeg\theblocklevel}) + (-0.2,0) node (nw) {}; \path (boxeast |- blockend) node (se) {}; - \draw (nw) rectangle (se); - % title + % % title \node[blockstyle] (blocktitle) at (nw) {\blockname\theblocklevel}; \path (blocktitle.south east) + (0,0.2) node (set) {} (blocktitle.south east) + (-0.2,0) node (seb) {} @@ -227,11 +265,10 @@ Sequence Diagrams.] \node[blockstyle] (blocktitle) at (nw) {\blockname\theblocklevel}; \node[blockcommentstyle] (blockcomment) at (comm) {\blockcomm\theblocklevel}; + \coordinate (se) at (current bounding box.south east); \end{pgfinterruptboundingbox} - % add two points to keep the bounding box - \node[dot] (fnw) at (nw) {}; - \node[dot] (fse) at (se) {}; + \draw (se) rectangle (nw); \addtocounter{blocklevel}{-1} % pop \stepcounter{seqlevel} @@ -239,6 +276,11 @@ Sequence Diagrams.] % the environment of sequence diagram \newenvironment{sequencediagram}{ + % declare layers + \pgfdeclarelayer{umlsd@background} + \pgfdeclarelayer{umlsd@threadlayer} + \pgfsetlayers{umlsd@background,umlsd@threadlayer,main} + \begin{tikzpicture} \setlength{\unitlength}{1cm} \tikzstyle{sequence}=[coordinate] @@ -266,15 +308,19 @@ Sequence Diagrams.] \node[coordinate] (inst0) {}; } { - \begin{pgfonlayer}{background} + \begin{pgfonlayer}{umlsd@background} + \ifnum\c@instnum > 0 \foreach \t [evaluate=\t] in {1,...,\theinstnum}{ \draw[dotted] (inst\t) -- ++(0,-\theseqlevel*\unitfactor-2.2*\unitfactor); } + \fi + \ifnum\c@threadnum > 0 \foreach \t [evaluate=\t] in {1,...,\thethreadnum}{ \path (thread\t)+(0,-\theseqlevel*\unitfactor-0.1*\unitfactor) node (threadend) {}; \tikzstyle{threadstyle}+=[threadcolor\t] \drawthread{thread\t}{threadend} } + \fi \end{pgfonlayer} \end{tikzpicture}} -- cgit v1.2.3