I've found a Q/A about how to create group nodes to blocks. It works, but exact opposite way as I needed. It defines internals and then draws blocks around them.
I need to define block with internals, LaTeX pseudocode:
\begin{tikzpicture}
\myblock(main){Main block name}{
\mynode(anode)[params]
\mynode(bnode)[params,right=of anode]
\myblock(subblock){Subblock name}[below=of anode]{
\mynode(subnodea)[p...]
\mynode(subnodeb)[p...]
}
}
\myblock(sideblock){Aux block}[right=of main]{
... mynodes ...
}
\end{tikzpicture}
Is there a way, how to define myblock as "complex node" - position is as one node and it moves all its internal nodes.
I've figured out part of the solution (didn't put commands into \def yet):
\begin{tikzpicture}[
element/.style={draw=black, fill=white},
group/.style={draw=black, rounded corners, fill=white}
]
\node(main_a)[element]{MAIN A};
\node(group_a)[group, below=of main_a]{
\begin{tikzpicture}
\node(b)[element]{bb};
\node(c)[element, left=of b]{ccc - left};
\end{tikzpicture}
};
\node(group_a_aux_r)[element,right=of group_a]{Aux Group Right};
\node(group_a_aux_l)[element,left=of group_a]{Aux Group Left};
\node(group_a_aux_b)[element,below=of group_a]{Aux Group Bottom};
\draw[->,red] (main_a) -- (group_a);
\draw[->,red] (group_a) -- (group_a_aux_r);
\draw[->,red] (group_a) -- (group_a_aux_l);
\draw[->,red] (group_a) -- (group_a_aux_b);
\node(group_b)[group, right=of group_a_aux_r]{
\begin{tikzpicture}
\node(d)[element]{dddd};
\node(e)[element, left=of d]{eeee - left};
\end{tikzpicture}
};
%code below fails - second image!!
\node(aux_b)[element,right=of b,draw=blue]{Aux B};
\node(aux_c)[element,left=of c,draw=blue]{Aux C};
\draw[->,blue] (b) -- (aux_b);
\draw[->,blue] (c) -- (aux_c);
\draw[->,green] (c) -- (d);
\end{tikzpicture}
Here is what I get without inner references:
It works: lays out children, puts it into node and lays it out as node. However, It passes properties of group_a to its children, which is unwanted behaviour!
Here is what I get when inner references are added:

This is completely broken.


pic. – Feb 08 '15 at 11:52pic? What is that? – kravemir Feb 08 '15 at 12:16picinpgfmanual. – Feb 08 '15 at 12:25pics: http://tex.stackexchange.com/a/187977/1952, http://tex.stackexchange.com/a/151772/1952, http://tex.stackexchange.com/a/182700/1952 – Ignasi Feb 09 '15 at 08:07