I'm creating a command for automatic generation of resources and deadlocks through TikZ. I have the following code that works correctly:
\usetikzlibrary{shapes,positioning,fit}
\begin{tikzpicture}
\tikzset{
proc/.style={draw,circle},
res/.style={rectangle,draw,minimum height=2.5em, minimum width=2.5em},
resi/.style={circle, inner sep=0.1em,circle,draw,node distance=0.5em},
}
\newcommand{\drawressingle}[2]{%
\node (#1l) {#2};
\node [resi,below=0.15em of #1l] (#1i1) {};
}
\newcommand{\drawres}[4]{%
\ifx&\tikzstyle{placeres}=[];%
\else\tikzstyle{placeres}=[#4];\fi%
\node [placeres] (#1l) {#2};
\node [resi,below=0.15em of #1l] (#1i1) {};
\foreach \i in {2,...,#3}{
\pgfmathtruncatemacro{\h}{\i-1}
\node [resi,below=of #1i\h] (#1i\i) {};
}
}
\drawressingle{r1}{R1}{}
\drawres{r2}{R2}{2}{left=of r1l}
\drawres{r3}{R3}{5}{right=of r1l}
\end{tikzpicture}
What I want to do is create a new node that is basically a rectangle around all of the nodes called e.g. r1i1, r1i2, .... What I will need is something that can generate the following if the first param is r1 and the third param is 3:
\node[fit=(r1i1)(r1i2)(r1i3)] {};
I can't think of a way to loop over and generate the above.