[Tex/LaTex] Create custom node to draw this

nodestikz-pgf

I'm very very new to tikz, I've already done this:

enter image description here

With this code:

\documentclass{article}

\usepackage[spanish,es-noquoting]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{tikz}
\usetikzlibrary{shadows}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{positioning}
\usetikzlibrary{calc,intersections}

\begin{document}
\begin{tikzpicture}[terminal/.style={draw, drop shadow, fill=white, rectangle, inner sep=5pt, font=\bfseries, align=center}]
\tikzset{fallastyle/.style={text=red}}
\tikzset{pasastyle/.style={text=green}}
\def \radius {0.25\textwidth}
\def \margin {20} % margin in angles, depends on the radius

\path[name path=circulo] (0, 0) circle (\radius);

\node(escribir_prueba)[name path=path_escribir_prueba,terminal] at ({0+90}:\radius){(Re)Escribir\\ Prueba};
\node(correr_prueba)[name path=path_correr_prueba, terminal] at ({300+90}:\radius){Correr\\ Prueba};
\node(escribir_codigo)[name path=path_escribir_codigo, terminal] at ({240+90}:\radius){Escribir\\ Código};
\node(correr_todas_pruebas_1)[name path=path_correr_todas_pruebas_1, terminal] at ({180+90}:\radius){Correr todas\\ las pruebas};
\node(refactorizar)[name path=path_refactorizar, terminal] at ({120+90}:\radius){Refactorizar};
\node(correr_todas_pruebas_2)[name path=path_correr_todas_pruebas_2, terminal] at ({60+90}:\radius){Correr todas\\ las pruebas};


\node (start) [node distance=8mm and -1mm, above left=of escribir_prueba, circle, fill=black, minimum width=1pt]{};

% INTERSECCIONES
\path [name intersections={of=circulo and path_escribir_prueba,name=intESCRIBIRPRUEBA}];
\def \ESCRIBIRRIGHT {intESCRIBIRPRUEBA-1}
\def \ESCRIBIRLEFT {intESCRIBIRPRUEBA-2}

\path [name intersections={of=circulo and path_correr_prueba,name=intCORRERPRUEBA}];
\def \CORRERPRUEBAUP {intCORRERPRUEBA-1}
\def \CORRERPRUEBADOWN {intCORRERPRUEBA-2}

\path [name intersections={of=circulo and path_escribir_codigo,name=intESCRIBIRCODIGO}];
\def \ESCRIBIRCODIGOUP {intESCRIBIRCODIGO-1}
\def \ESCRIBIRCODIGODOWN {intESCRIBIRCODIGO-2}

\path [name intersections={of=circulo and path_correr_todas_pruebas_1,name=intCORRERTODASPRUEBASFIRST}];
\def \CORRERTODASPRUEBASFIRSTLEFT {intCORRERTODASPRUEBASFIRST-1}
\def \CORRERTODASPRUEBASFIRSTRIGHT {intCORRERTODASPRUEBASFIRST-2}

\path [name intersections={of=circulo and path_refactorizar,name=intREFACTORIZAR}];
\def \REFACTORIZARUP {intREFACTORIZAR-1}
\def \REFACTORIZARDOWN {intREFACTORIZAR-2}


\path [name intersections={of=circulo and path_correr_todas_pruebas_2,name=intCORRERTODASPRUEBASSECOND}];
\def \CORRERTODASPRUEBASSECONDUP {intCORRERTODASPRUEBASSECOND-1}
\def \CORRERTODASPRUEBASSECONDDOWN {intCORRERTODASPRUEBASSECOND-2}


\draw [->,bend left=15] (\ESCRIBIRRIGHT) to (\CORRERPRUEBAUP);
\draw [->,bend left=15] (node cs:name=correr_prueba, anchor=west) to  node [midway,left,pasastyle] { [pasa] } (node cs:name=escribir_prueba, anchor=south);
\draw [->,bend left=15] (\CORRERPRUEBADOWN) to node [midway,right,fallastyle] { [falla] } (\ESCRIBIRCODIGOUP);
\draw [->,bend left=15] (\ESCRIBIRCODIGODOWN) to (\CORRERTODASPRUEBASFIRSTRIGHT);
\draw [->,bend left=15] (node cs:name=correr_todas_pruebas_1, anchor=north) to  node [midway,left,fallastyle] { [falla] } (node cs:name=escribir_codigo, anchor=west);
\draw [->,bend left=15] (\CORRERTODASPRUEBASFIRSTLEFT) to node [midway,left,pasastyle] { [pasa] } (\REFACTORIZARDOWN);
\draw [->,bend left=15] (\REFACTORIZARUP) to (\CORRERTODASPRUEBASSECONDDOWN);
\draw [->,bend left=15] (node cs:name=correr_todas_pruebas_2, anchor=south) to  node [midway,right,fallastyle] { [falla] } (node cs:name=refactorizar, anchor=north);
\draw [->,bend left=15] (\CORRERTODASPRUEBASSECONDUP) to node [midway,left,pasastyle] { [pasa] }(\ESCRIBIRLEFT);


\draw [->,bend left=15] (node cs:name=start, anchor=east) to (node cs:name=escribir_prueba, anchor=north);
\end{tikzpicture}

I'm sure it's not the best way to do that, but as I said, I'm very new in tikz, and the concept seems clear: draw the nodes at 360/total_nodes degrees, find intersections between node and a circle, draw an arc between intersections.

So far so good. Now I want to do this, that is pretty much the same thing:
enter image description here

I would like to make the 3 bubbles (prueba-codigo-refactor) a node, so I can do the same thing I did before.

This code draws the 3 bubbles:

\begin{tikzpicture}
\node [draw, circle, fill=white, minimum width=5em]at (0, 0){Prueba};
\node [draw, circle, fill=white, minimum width=5em]at (1.2, -0.6){Código};
\node [draw, circle, fill=white, minimum width=5em]at (1.2, 0.6){Refactor};
\end{tikzpicture}

But I need the hole thing to behave as one node.
So the questions are:

  1. How can I do to make the 3 bubbles a node (and behave like a node) so I can do the same thing I did before?
  2. This is all I can think with one-day experience with tikz, you sure know better and may come up with a better solution, I want to hear it!

I want to learn tikz, so a "here, paste this code and works, bye bye" it's not the best answer for me. On the other side, "look at this link, bye bye" it's kind of hard to me to understand, a MME would be awesome (and the link).

Best Answer

Since the node shape is not special in the sense that custom paths are not required, you can place two more nodes whenever you place one somewhere. I've cooked up a style that works for this example but you can also make it more customized to accept positioning details, colors, styles etc.

Some care is needed to use it as it is because it will draw over the bubbles if you address directly the underlying bubble for the paths. There are some remedies but I'm not sure if you need them. Also append after command should be used inside a path but here we are just being adventurous.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{single bubble/.style={draw, circle, fill=white, minimum width=5em},
tribubble/.style={
        single bubble,
        append after command={
             \pgfextra{\let\mylastnode\tikzlastnode} 
             node [single bubble, above right = 1mm and 5mm of \mylastnode.center] {Código}
             node [single bubble, below right = 1mm and 5mm of \mylastnode.center] {Refactor}
        }
    }
}


\begin{document}

\begin{tikzpicture}
    \draw (0,0) circle (3cm);
    \node[tribubble] at (45:3cm){Prueba};
    \node[tribubble] at (-45:3cm){Prueba};
\end{tikzpicture}


\end{document}

enter image description here