使用路径图片属性从 UML-TikZ 包中扩展给定的形状

使用路径图片属性从 UML-TikZ 包中扩展给定的形状

我在第 20 行调用了样式定义。mystyle如您所见,我将\filldraw命令作为参数传递给样式定义mystyle。这样,我想实现在过渡线中间显示一个灰色圆圈。不幸的是,它不起作用。

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning, calc, shadings, shadows, shapes.arrows, arrows.meta, matrix, mindmap}
\usepackage{tikz-uml}
\begin{document}
\begin{tikzpicture}[
    mystyle/.style n args = {1}{
        color=black,
        rounded corners, 
        arrows={-Straight Barb[angle=60:9pt 3]},
        path picture={
            #1
        }
    }]
    \begin{umlstate}[name=Statemaschine]{Lightcontrol}
        \umlstateinitial[name=start, x=0,y=3]{start}
        \umlbasicstate [fill=red!20, width=5cm] {manual}
        \umlbasicstate [below left=4of manual,fill=red!20, width=5cm,] {waiting}
        \umlbasicstate [below right=4of manual,fill=red!20, width=5cm] {auto}
        \umlbasicstate [below=8of manual,fill=red!20, width=5cm] {time}
        \umltrans[mystyle={\filldraw [gray] (0,0) circle [radius=9pt]}]{waiting}{auto}
    \end{umlstate}
\end{tikzpicture}
\end{document}

答案1

insert path在两种状态之间使用。

b

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning, calc, shadings, shadows, shapes.arrows, arrows.meta, matrix, mindmap}

\usepackage{tikz-uml}

\begin{document}
    \begin{tikzpicture}[
        mystyle/.style  2 args = {%
            color=black,
            rounded corners, 
            arrows={-Straight Barb[angle=60:9pt 3]},
            insert path={node[circle, fill=gray!60,minimum size=12pt] at  ($(#1)!.5!(#2)$){}},
        }]
        \begin{umlstate}[name=Statemaschine]{Lightcontrol}
            \umlstateinitial[name=start, x=0,y=3]{start}
            \umlbasicstate [fill=red!20, width=5cm] {manual}
            \umlbasicstate [below left=4 of manual,fill=red!20, width=5cm,] {waiting}
            \umlbasicstate [below right=4 of manual,fill=red!20, width=5cm] {auto}
            \umlbasicstate [below=8 of manual,fill=red!20, width=5cm] {time}
            \umltrans[mystyle={waiting}{auto}]{waiting}{auto} % changed <<<<<<<<<<<<<<<<<<<
        \end{umlstate}
    \end{tikzpicture}

    \end{document}

相关内容