# Redefine options in TikZ-UML sequence diagrams

I have several TikZ-UML sequence diagrams and mostly I always set the options dt=5 and padding=3 for all umlcall. Is it possible to set these two variables for these values as default?

\documentclass{report}
\usepackage{tikz}
\usepackage{tikz-uml}
\begin{document}

\begin{tikzpicture}
\begin{umlseqdiag}
\umlbasicobject{B}
\umlbasicobject[x=6]{C}

\end{umlcall}

\end{umlcall}

\end{umlcall}

\end{umlseqdiag}
\end{tikzpicture}

\end{document}


The umlcall environment does

\pgfkeys{/tikzuml/call/.cd,%
dt/.initial={tikzumlEmpty},%
[...]


so there's no way to pass different initial values except correcting the environment's definition. Here's a way with xpatch.

\documentclass{report}
\usepackage{tikz}
\usepackage{tikz-uml}

\usepackage{xpatch}
\xpatchcmd{\umlcall}
{dt/.initial={tikzumlEmpty}}
{dt/.initial=5}
{}{}
\xpatchcmd{\umlcall}
{}{}

\begin{document}

\begin{tikzpicture}
\begin{umlseqdiag}
\umlbasicobject{B}
\umlbasicobject[x=6]{C}

\end{umlcall}

\end{umlcall}

\end{umlcall}

\end{umlseqdiag}
\end{tikzpicture}

\begin{tikzpicture}
\begin{umlseqdiag}
\umlbasicobject{B}
\umlbasicobject[x=6]{C}

\begin{umlcall}[op=msg1, return={r0, r1}, dt=4]{C}{B}
\end{umlcall}

\begin{umlcall}[op=callback, return={ok}]{B}{C}
\end{umlcall}

\begin{umlcall}[op=msg2, return=r2]{C}{B}
\end{umlcall}

\end{umlseqdiag}
\end{tikzpicture}

\end{document}


I typeset the original call and the new one where the values are not specified in order to see they're identical.

• Is \ddt a non-existent command to cause an error on purpose when xpatch fails? (I couldn't find a specific definition on the documentation.) Why is not used when patching dt? – user3371321 Apr 1 '14 at 13:28
• @user3371321 Yes, I use it to get warned if the patch fails, it's supposed to be undefined. Usually I remove it after testing, but this time I forgot doing it. – egreg Apr 1 '14 at 13:31

Here, I created a new environment, Umlcall which has your desired defaults. I changed up your MWE parameters a bit to show that one can override the defaults, and that the method works without any optional argument, as well. The defaults are defined in the macro \umldefaults.

\documentclass{report}
\usepackage{tikz}
\usepackage{tikz-uml}
\newenvironment{Umlcall}[3][]{\expandafter\umlcall\expandafter[\umldefaults #1]{#2}{#3}}%
{\endumlcall}
\begin{document}

\begin{tikzpicture}
\begin{umlseqdiag}
\umlbasicobject{B}
\umlbasicobject[x=6]{C}

\end{Umlcall}

\begin{Umlcall}[op=callback, return={ok}]{B}{C}
\end{Umlcall}

\begin{Umlcall}[op=msg2, return=r2]{C}{B}
\end{Umlcall}

\begin{Umlcall}{C}{B}
\end{Umlcall}

\end{umlseqdiag}
\end{tikzpicture}

\end{document}


You're right. tikz-uml offers a way to define global default value thanks to the command \tikzumlset but I only activated it for drawing purpose, namely draw, fill and text options of each available UML element. I added the possibility to define global default value for quite every option of every element. This will be available soon in the new release of tikz-uml.