我有这段文本片段......
\documentclass{article}
\usepackage{pgf-umlsd}
\usepackage[a1paper,portrait]{geometry}
\usepackage{float}
\begin{document}
\section{Use Case 1: Imbalance Settlement and Resistors}
\begin{figure}[H]
\centering
\begin{sequencediagram}
\tikzstyle{inststyle}+=[bottom color=white, top color=white]
\newthread{ecp}{:ECP}{}
\newinst[1]{eap}{:EAP}{}
\newinst[1]{stream}{:STREAM}{}
%\newinst[1]{db}{:DATABASE}{}
\newinst[1]{spf}{:SPF}{}
\tikzstyle{inststyle}+=[bottom color=white, top color=white]
\newinst[1]{rtu}{:RTU}{}
\newthread{operator}{:OPERATOR}{}
\begin{sdblock}{loop}{[for each PTU]}
\begin{sdblock}{loop}{[continuous]}
\begin{call}{ecp}{getSPF}{stream}{SPF}
\begin{call}{stream}{getSPF}{spf}{SPF}
\end{call}
\postlevel
\end{call}
\prelevel \prelevel
setthreadbias{east}
\begin{call}{operator}{getSPF}{stream}{SPF}
\postlevel
\end{call}
\end{sdblock}
\end{sdblock}
\end{sequencediagram}
\end{figure}
\end{document}
问题:如何将 sdblock(或者另一个方块)放置在红色方块的位置?
答案1
pgf-umlsd
创建根据级别命名的各种节点。您可以使用这些节点以及一些手动调整来制作这样的框。例如,如果您添加,\usetikzlibrary{fit}
您可以使用
\node [fit=(cf1)(rt1),draw,red,very thick,inner ysep=2mm,yshift=1.5mm] {};
或者没有任何库:
\draw [red, very thick] ([shift={(10pt,11pt)}]cf1.north west) rectangle ([shift={(-10pt,-2pt)}]rt1.south east);
在 之前添加其中任一项\end{sequencediagram}
。
对于两个不同事物之间的 ,你会得到称为、和的call
节点,其中是一个整数。对于回到同一事物的 ,你会得到称为、和的节点。cfN
ctN
rfN
rtN
N
call
scN
scbN
sceN
sctN
\documentclass[border=5mm]{standalone}
\usepackage{pgf-umlsd}
\usetikzlibrary{fit}
\begin{document}
\begin{sequencediagram}
\tikzstyle{inststyle}+=[bottom color=white, top color=white]
\newthread{ecp}{:ECP}{}
\newinst[1]{eap}{:EAP}{}
\newinst[1]{stream}{:STREAM}{}
%\newinst[1]{db}{:DATABASE}{}
\newinst[1]{spf}{:SPF}{}
\tikzstyle{inststyle}+=[bottom color=white, top color=white]
\newinst[1]{rtu}{:RTU}{}
\newthread{operator}{:OPERATOR}{}
\begin{sdblock}{loop}{[for each PTU]}
\begin{sdblock}{loop}{[continuous]}
\begin{call}{ecp}{getSPF}{stream}{SPF}
\begin{call}{stream}{getSPF}{spf}{SPF}
\end{call}
\postlevel
\end{call}
\prelevel \prelevel
setthreadbias{east}
\begin{call}{operator}{getSPF}{stream}{SPF}
\postlevel
\end{call}
\end{sdblock}
\end{sdblock}
\node [fit=(cf1)(rt1),draw,red,very thick,inner ysep=2mm,yshift=1.5mm] {};
%\draw [red, very thick] ([shift={(10pt,11pt)}]cf1.north west) rectangle ([shift={(-10pt,-2pt)}]rt1.south east);
\end{sequencediagram}
\end{document}