[Tex/LaTex] Progressive tikz picture in beamer

beameroverlaystikz-qtree

I have the following slide in my beamer presentation :

\documentclass[11pt]{beamer}
\usepackage{ulem}
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\usetikzlibrary{positioning}
\usepackage{philex}

\begin{document}

\begin{frame}{Contraintes sur le mouvement}

\lb{}{La fille que j'aidais aime ce que tu détestes.}
\begin{center}
\begin{tikzpicture}[scale=.6]
\tikzset{every tree node/.style={align=center,anchor=north}}% to allow linebreaks

\Tree 
[.TP
[.DP 
    [.DP \edge[roof]; {La fille} ]
    [.CP 
        [.C que ]
        [.TP 
            [.\node(tempsAidais)[draw] {T};  ]
            [.\node(aidais){VP};  \edge[roof]; {j'aidais\\\Huge\color{blue}?} ] ] ] ]
[.T$'$  
[.\node(tempsAime)[draw] {T};  ]
[.VP 
[.DP \edge[roof]; {\sout{La fille...}} ] 
[.V$'$ 
%[.V \fbox{aime} ]
[.V \node(aime){aime\\\Huge\color{blue}?}; ]
[.CP 
        [.C ce que ]
        [.TP 
            [.\node(tempsDétestes)[draw] {T};  ]
            [.\node(détestes){VP};  \edge[roof]; {tu détestes\\\Huge\color{blue}?} ] ] ] ] ] ] ] ]

\node (aidais2) [below=.7cm of aidais] {};
\node (détestes2) [below=.7cm of détestes] {};

\draw[-latex] (aidais2.south) to[out=270,in=225,looseness=2] (tempsAidais.265);
\draw[-latex] (aime.south) to[out=270,in=270,looseness=2] (tempsAime.280);
\draw[-latex] (détestes2.south) to[out=270,in=260,looseness=2] (tempsDétestes.south);



\end{tikzpicture}
\end{center}
\end{frame}

\end{document}

I would like to present it first without the interrogation dots, the squares around the Ts, and arrows. Then add the interrogation dots. Then the squares around the Ts. And finally add the arrows.

I could do 4 dirrefent frames, but in that case the counter of my numbered example would be incremented.

So is there a way to progressively draw a tikz picture on a single frame?

Best Answer

A combination of \only and \uncover could be used. The reason for using \uncover for the arrows is that with \only the arrows are not considered at all for the first three slides, causing a change in the bounding box, making the tree jump around a bit (replace \uncover with \only to see what I mean).

\documentclass[11pt]{beamer}
\usepackage{ulem}
\usepackage{tikz-qtree}
\usepackage{tikz-qtree-compat}
\usetikzlibrary{positioning}
\usepackage{philex}

\begin{document}

\begin{frame}{Contraintes sur le mouvement}

\lb{}{La fille que j'aidais aime ce que tu détestes.}
\begin{center}
\begin{tikzpicture}[scale=.6]
\tikzset{every tree node/.style={align=center,anchor=north}}% to allow linebreaks

\Tree 
[.TP
[.DP 
    [.DP \edge[roof]; {La fille} ]
    [.CP 
        [.C que ]
        [.TP 
            [.\node(tempsAidais) {T};  ]
            [.\node(aidais){VP};  \edge[roof]; {j'aidais\only<2->{\\\Huge\color{blue}?}} ] ] ] ]
[.T$'$  
[.\node(tempsAime) {T};  ]
[.VP 
[.DP \edge[roof]; {\sout{La fille...}} ] 
[.V$'$ 
%[.V \fbox{aime} ]
[.V \node(aime){aime\only<2->{\\\Huge\color{blue}?}}; ]
[.CP 
        [.C ce que ]
        [.TP 
            [.\node(tempsDétestes) {T};  ]
            [.\node(détestes){VP};  \edge[roof]; {tu détestes\only<2->{\\\Huge\color{blue}?}} ] ] ] ] ] ] ] ]

\only<3->{%
\foreach \n in {tempsAidais,tempsAime,tempsDétestes}
  \draw (\n.south east) rectangle (\n.north west);
}

\uncover<4>{\node (aidais2) [below=.7cm of aidais] {};
\node (détestes2) [below=.7cm of détestes] {};

\draw[-latex] (aidais2.south) to[out=270,in=225,looseness=2] (tempsAidais.265);
\draw[-latex] (aime.south) to[out=270,in=270,looseness=2] (tempsAime.280);
\draw[-latex] (détestes2.south) to[out=270,in=260,looseness=2] (tempsDétestes.south);
}


\end{tikzpicture}
\end{center}
\end{frame}

\end{document}

enter image description here