
%%%%%%%%%%%%%%% Détails d'une compétence

% Usage : \frameCompetence{abbr_comp}{type_comp}{lettre_comp}  % {compteur_comp}
\newcommand\frameCompetence[3]{

\xdef\CNOM{#1} % Abbr de la compétence : CCA/CyberA
\xdef\CTYPE{#2} % Type : C pour commun, S pour spécifique
\xdef\CLETTRE{#3} % Letter

%\def\CNOM{CyberA} 
%\def\CTYPE{S}
%\def\CLETTRE{A}


  \begin{frame}[plain]{}
    \subsection{\CNOM : \csname compname\CNOM\endcsname}
    \begin{tikzpicture}[overlay, remember picture]
			\coordinate(topleftcorner) at ($ (current page.north west) + (10mm,-12mm) $);
			\coordinate(bottomleftcorner) at ($ (current page.south west) + (10mm,10mm) $);
			\coordinate(bottomrightcorner) at ($ (current page.south east) + (-10mm,10mm) $);
		
      \coordinate(lastpoint) at ($ (current page.north west) + (10mm,-12mm) $);
			\coordinate(toprightcorner) at ($ (current page.north east) + (-12mm,-12mm) $);


      \coordinate(refpoint) at ($ (lastpoint)+(0mm,0mm) $);
      \coordinate (bottompoint) at ($ (lastpoint)+(0,-20mm) $);
      \coordinate (subrefpoint) at ($ (refpoint)+(90mm,0mm) $); % Segmentation
      \begin{pgfonlayer}{main}
        % \draw ($ (current page.north west) + (10mm,-10mm) $) rectangle ($ (current page.south east) + (-10mm,10mm) $);
        % \draw[thick](lastpoint)--++(-1cm,0);
        \node[outer sep=0,inner sep=0mm,% les composantes essentielles
        minimum height=20mm,%
        text width=190mm,%130
        align=left,%
        text=comp\CTYPE\CLETTRE p,fill=comp\CTYPE\CLETTRE!70!white%
        ] (rightrightbox) at (lastpoint-|subrefpoint) [anchor=north west] {%
						\ifcsdef{componame\CNOM A}{ % Si au moins une compo essentielle
						\begin{list}{$\bullet$}{\topsep=0pt \partopsep=0pt \parsep=0pt \itemsep=0pt \leftmargin=1em \itemindent=0em}%
							%% boucle sur les composantes essentielles
							%\item test \compoloop
							\foreach \YY in \compoloop {%
								\ifcsdef{componame\CNOM\YY}{
									\item \textcolor{comp\CTYPE\CLETTRE p}{en \csname componame\CNOM\YY\endcsname}
								}{\linebreak}%
							}
						\end{list}%
					}{}
        };
				
				% Titre de la compétence
        \coordinate(bottompoint) at ($ (rightrightbox.south west)+(-5mm,0) $);
        \coordinate(toppoint) at ($ (refpoint) $);
        \node[outer sep=0,inner sep=0mm,%
        text width=63mm,%
        fit=(bottompoint)(toppoint),
        align=center,%
        fill=comp\CTYPE\CLETTRE,text=comp\CTYPE\CLETTRE p%
        ] (leftbox) {%
          \Large\bfseries Compétence \CNOM\\[3mm]
					\begin{hyphenrules}{nohyphenation}\csname compname\CNOM\endcsname\end{hyphenrules}%
        };
      \end{pgfonlayer}
			
			% Le fond coloré général de la compétence
      \begin{pgfonlayer}{background}
        \coordinate(toppoint) at ($ (lastpoint)+(30mm,2mm) $);
        \coordinate(bottompoint) at ($ (rightrightbox.south east)+(2mm,-2mm) $);
        \coordinate(bottomwpoint) at ($ (leftbox.south east)+(2mm,-2mm) $);
        \node[outer sep=0,inner sep=0mm,
        fit=(leftbox)(rightrightbox)(toppoint)(bottompoint)(bottomwpoint), % (rightbox)
        fill=comp\CTYPE\CLETTRE,
        blur shadow={shadow blur steps=5}
        ] (bodybox) {};
        \coordinate (tmpa) at ($ (lastpoint)+(80mm,0) $);
        \coordinate (tmpb) at (tmpa|-bodybox.south);
        \fill[fill=comp\CTYPE\CLETTRE!50!white] ($ (leftbox.north east)+(2mm,0mm) $) rectangle ($ (bodybox.south west-|rightrightbox.south west)+(-2mm,2mm) $);
        \coordinate(toppoint) at ($ (lastpoint)+(25mm,2mm) $);
      \end{pgfonlayer}
			
			%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			% La définition
			%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

      \coordinate(lastpoint) at ($ (lastpoint|-bodybox.south) + (0,-4mm) $);
      \coordinate (subrefpoint) at ($ (refpoint)+(45mm,0mm) $);
      \begin{pgfonlayer}{main}
        % \draw[thick](lastpoint)--++(-1cm,0);
        \node[outer sep=0,inner sep=0mm,%
        minimum height=20mm,%
        text width=225mm-(\value{cptressource}*5mm),%
        align=left,%
        text=black,fill=comp\CTYPE\CLETTRE!10!white%
        ] (rightbox) at (lastpoint-|subrefpoint) [anchor=north west] {%
          \textcolor{black}{\csname compdef\CNOM\endcsname}%
        };
        \coordinate(bottompoint) at ($ (rightbox.south west)+(-10mm,0) $);
        \coordinate(toppoint) at ($ (lastpoint)+(32mm,0mm) $);
        \node[outer sep=0,inner sep=0mm,%
        % text width=45mm,%
        % fit=(bottompoint)(toppoint),
        align=right,%
        % fill=comp\CTYPE\CLETTRE,text=comp\CTYPE\CLETTRE p%
        ] at ($ (rightbox.west)+(-10mm,0) $) [anchor=east] (leftbox) {%
          \large\bfseries Définition%
        };
      \end{pgfonlayer}
			
			\begin{pgfonlayer}{background} % La barre verticale de la définition
        \coordinate(toppoint) at ($ (rightbox.north west)+(-2mm,2mm) $);
        \coordinate(bottompoint) at ($ (rightbox.south east)+(2mm,-2mm) $);
        \node[outer sep=0,inner sep=0mm,
        fit=(toppoint)(bottompoint),
        fill=comp\CTYPE\CLETTRE!10!white,
        blur shadow={shadow blur steps=5}
        ] (bodybox) {};
        \coordinate (tmpa) at ($ (lastpoint)+(80mm,0) $);
        \coordinate (tmpb) at (tmpa|-bodybox.south);
        \fill[fill=comp\CTYPE\CLETTRE] ($ (rightbox.north west)+(-6mm,0mm) $) rectangle ($ (rightbox.south west)+(-5mm,0) $);
      \end{pgfonlayer}
			
        %\coordinate (domaines) at ($ (toprightcorner|-lastpoint) $);
        %\coordinate (domtxtA) at ($ (domaines)+(0mm,-2mm) $);

			%%% Fin de la définition
			
			%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			% Les situations professionnelles
			%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			
      \coordinate(lastpoint) at ($ (lastpoint|-rightbox.south) + (0,-6mm) $);
      \coordinate (subrefpoint) at ($ (refpoint)+(45mm,0mm) $);
      \begin{pgfonlayer}{main}
        % \draw[thick](lastpoint)--++(-1cm,0);
        \node[outer sep=0,inner sep=0mm,%
        minimum height=15mm,%
        text width=225mm-(\value{cptressource}*5mm),%
        align=left,%
        text=black,fill=comp\CTYPE\CLETTRE!20!white%
        ] (rightbox) at (lastpoint-|subrefpoint) [anchor=north west] {%
          \ifcsdef{situproname\CNOM A}{ % S'il y a au moins une situation pro
						\begin{list}{\checkmark}{\topsep=0pt \partopsep=0pt \parsep=0pt \itemsep=0pt \leftmargin=2em \itemindent=0em}%
							\foreach \YY in \situloop {%
								\ifcsdef{situproname\CNOM\YY}{\item %
									\textcolor{black}{\csname situproname\CNOM\YY\endcsname}}{}%
								}
						\end{list}%
						}{}
        };
        \coordinate(bottompoint) at ($ (rightbox.south west)+(-10mm,0) $);
        \coordinate(toppoint) at ($ (lastpoint)+(32mm,0mm) $);
        \node[outer sep=0,inner sep=0mm,%
        % text width=45mm,%
        % fit=(bottompoint)(toppoint),
        align=right,%
        % fill=comp\CTYPE\CLETTRE,text=comp\CTYPE\CLETTRE p%
        ] at ($ (rightbox.west)+(-10mm,0) $) [anchor=east] (leftbox) {%
          \large\bfseries Situations\\\large\bfseries professionnelles%
        };
      \end{pgfonlayer}
			
			
      %\ifcsdef{domaineA}{
        %\coordinate (domaines) at ($ (lastpoint|-lastpoint)+(-400mm,0)+(0,2mm) $);
        %\node[inner sep=0,outer sep=0,anchor=north west,text width=\value{cptressource}*5mm,align=center] (domtxt) at (domaines) {\textbf{Domaines de ressources}};
        %\node[inner sep=0,outer sep=0,fit=(domaines)] (domcont) {};
        %\foreach \DOM [count=\COU] in \cptressourceloop {%
          %\coordinate (domanchor\DOM) at ($ (domtxt.south-|domaines)+(-5mm,-1mm)+5*(\COU mm,0) $);
          %\node[inner sep=0,outer sep=0,rotate=90,anchor=north east] at (domanchor\DOM) (domtest\DOM) {\csname domaine\DOM\endcsname};
          %\node[inner sep=0,outer sep=0,fit=(domcont)(domtest\DOM)] (domcont) {};
        %}
        %\node[inner sep=0,outer sep=0,anchor=west] (domtxt) at (domaines) {\textbf{Domaines de ressources}};
        %\coordinate (domaines) at ($ (toprightcorner|-lastpoint)+\value{cptressource}*(-5mm,0mm)+(0,2mm) $); 
        %\node[inner sep=0,outer sep=0,anchor=north west,text width=\value{cptressource}*5mm,align=center] (domtxt) at (domaines) {\textbf{Domaines de ressources}};
        %\foreach \DOM [count=\COU] in \cptressourceloop {%
          %\coordinate (domanchor\DOM) at ($ (domcont.south-|domaines)+(-5mm,-1mm)+5*(\COU mm,0) $);
          %\node[inner sep=0,outer sep=0,rotate=90,anchor=north west] (domtxt\DOM) at (domanchor\DOM) {\csname domaine\DOM\endcsname};
        %}
      %}{
        \coordinate (domaines) at ($ (toprightcorner|-lastpoint) $);
        \coordinate (domtxtA) at ($ (domaines)+(0mm,-2mm) $);
      %}

			\begin{pgfonlayer}{background} % La barre verticale des situations pro
        \coordinate(toppoint) at ($ (rightbox.north west)+(-2mm,2mm) $);
        \coordinate(bottompoint) at ($ (rightbox.south east)+(2mm,-2mm) $);
        \node[outer sep=0,inner sep=0mm,
        fit=(toppoint)(bottompoint),
        fill=comp\CTYPE\CLETTRE!20!white,
        blur shadow={shadow blur steps=5}
        ] (bodybox) {};
        \coordinate (tmpa) at ($ (lastpoint)+(80mm,0) $);
        \coordinate (tmpb) at (tmpa|-bodybox.south);
        \fill[fill=comp\CTYPE\CLETTRE] ($ (rightbox.north west)+(-6mm,0mm) $) rectangle ($ (rightbox.south west)+(-5mm,0) $);
      \end{pgfonlayer}
			
        \coordinate (domaines) at ($ (toprightcorner|-lastpoint) $);
        \coordinate (domtxtA) at ($ (domaines)+(0mm,-2mm) $);
      %}
			%%% Fin des situations pro
			
			%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			%%% Sous-titres niveaux / apprentissages critiques
			%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			\coordinate(lastpoint) at ($ (lastpoint|-rightbox.south) + (0,-4mm) $);
			\coordinate (subrefpoint) at ($ (refpoint)+(45mm,45mm) $);
      \begin{pgfonlayer}{main}
        % \draw[thick](lastpoint)--++(-1cm,0);
        \node[outer sep=0,inner sep=0mm,%
        minimum height=8mm,%
        text width=225mm-(\value{cptressource}*5mm),%
        align=center,%
        text=black,
        ] (rightbox) at (lastpoint-|subrefpoint) [anchor=north west] {\large\bfseries Apprentissages critiques};
        \coordinate(bottompoint) at ($ (rightbox.south west)+(-10mm,0) $);
        \coordinate(toppoint) at ($ (lastpoint)+(32mm,0mm) $);
        \node[outer sep=0,inner sep=0mm,%
        %text width=45mm,%
        % fit=(bottompoint)(toppoint),
        align=center,%
        % fill=comp\CTYPE\CLETTRE,text=comp\CTYPE\CLETTRE p%
        ] at ($ (rightbox.west)+(-15mm,0) $) [anchor=east] (leftbox) {%
				\large\bfseries Niveaux de \\ \large\bfseries développement%
        };
      \end{pgfonlayer}
			
			\coordinate (lastpoint) at ($ (lastpoint|-rightbox.south) + (0,-4mm) $);
			\coordinate (subrefpoint) at ($ (refpoint)+(45mm,0mm) $);
      \coordinate (domaines) at ($ (toprightcorner|-lastpoint) $);
      \coordinate (domtxtA) at ($ (domaines)+(0mm,5mm) $);

      %}
			%%% Fin des sous-titres
			
			% title box => replacement des coordonnées
      \node[inner sep=2mm,outer sep=0,fit=(bodybox)(domtxtA.west)] (titlebox) {};
      \coordinate(lastpoint) at (lastpoint|-titlebox.south);
      \coordinate(highright) at ($ (rightbox.west|-lastpoint)+(-10mm,0) $);
      \coordinate(highleft) at (highright-|lastpoint);
      \coordinate(highmid) at ($ .5*(highright)+.5*(highleft) $);
									
						
			%% Les niveaux
      \foreach \NIV in \nivloop {%
        \ifcsdef{niveauname\CNOM\NIV}{ % Si le niveau existe
          % \pause
          \begin{pgfonlayer}{main} % Liste des apprentissages critiques
            % \draw[thick](lastpoint)--++(-1cm,0);
            \node[outer sep=0,inner sep=0mm,%
            minimum height=20mm,%
            text width=225mm-(\value{cptressource}*5mm),%
            align=left,%
            text=black,fill=white%
            ] (rightbox) at (lastpoint-|subrefpoint) [anchor=north west] {%
              \large % Taille police
              \ifcsdef{apprdesc\CNOM\NIV A}{ % Si un apprentissage critique est décrit
                \begin{list}{$\bullet$}{\topsep=0pt \partopsep=0pt \parsep=0pt \itemsep=0pt \leftmargin=1em \itemindent=0em}%
                  \foreach \YY in \apploop {%
                    \ifcsdef{apprdesc\CNOM\NIV\YY}{\item %
                      \tikz[remember picture,overlay]{\coordinate(list\YY) at (0,0);%
                      }%
                      \textcolor{black}{\csname apprdesc\CNOM\NIV\YY\endcsname}}{}%
                  }
                \end{list}%
              }{}%
            };
            %\ifcsdef{domaineA}{
              %\foreach \YY in \apploop {%
                %\ifcsdef{comp\XX niv\NIV app\YY}{
                  %\foreach \DOM in \cptressourceloop {%
                    %\ifcsdef{comp\XX niv\NIV app\YY dom\DOM}{%
                      %\fill[fill=comp\CTYPE\CLETTRE] ($ (list\YY-|domtxt\DOM.north west)+(.5mm,0mm) $) rectangle ++(3mm,3mm);
                    %}{
                      %\fill[fill=black!20!white] ($ (list\YY-|domtxt\DOM.north west)+(.5mm,0mm) $) rectangle ++(3mm,3mm);
                    %}
                  %}
                %}
              %}
            %}{}
            \coordinate(lowright) at ($ (highright)+(0,-25mm) $);
            \coordinate(lowmid) at ($ (highmid)+(0,-25mm) $);
            \node[inner sep=0,outer sep=0,text width=33mm,anchor=north,align=center] (testarrow) at ($ (highmid)+(-200mm,-2mm) $) {
              \textbf{\csname niveauname\CNOM\NIV\endcsname}\\
              \begin{hyphenrules}{nohyphenation}\csname niveaudesc\CNOM\NIV\endcsname\end{hyphenrules}
            };
            \node[inner sep=0,outer sep=0,fit=(rightbox)(lowright)(testarrow)] (thearrow) {};
            \coordinate(lowright) at (highright|-thearrow.south);
            \coordinate(lowleft) at (lowright-|lastpoint);
            \coordinate(lowmid) at ($ .5*(lowright)+.5*(lowleft)+(0,-5mm) $);
            \node[inner sep=0,outer sep=0,text width=33mm,anchor=north,%
            align=flush center,%
            text=comp\CTYPE\CLETTRE p!\csname niveauink\NIV\endcsname!black] (arrow) at ($ (highmid)+(0mm,-2mm) $) {
              \textbf{\csname niveauname\CNOM\NIV\endcsname}\\
              \csname niveaudesc\CNOM\NIV\endcsname
            };
          \end{pgfonlayer}
          \begin{pgfonlayer}{background} % Flèche
            \draw[%
            thick,%
            fill=comp\CTYPE\CLETTRE!\csname niveaufill\NIV\endcsname!white,
            draw=comp\CTYPE\CLETTRE!\csname niveaupath\NIV\endcsname!white,
            blur shadow={shadow blur steps=5}
            ](highright)--(highmid)--(highleft)--(lowleft)--(lowmid)--(lowright)--cycle;
          \end{pgfonlayer}

					% Décalage des positions
          \draw[thick,draw=comp\CTYPE\CLETTRE] ($ (highright)+(10mm,0) $)--(highright-|toprightcorner);
          \coordinate (lastpoint) at ($ (lastpoint|-lowleft)+(0,-2mm) $);
          \coordinate (highmid) at ($ (lowmid)+(0,-2mm) $);
          \coordinate (highleft) at ($ (lowleft)+(0,-2mm) $);
          \coordinate (highright) at ($ (lowright)+(0,-2mm) $);
        %}
				}{} % fin existante niveau
      } % fin boucle niveau
			
			
		% Le numero de pages
		\node[inner sep=0,outer sep=0,text width=33mm,anchor=north,align=center] (testarrow) at ($ (bottomrightcorner)+(0mm,0mm) $) {
\insertframenumber{}~/~\inserttotalframenumber{}
};
		
    \end{tikzpicture}
  \end{frame}
}