%%%==============================================================================
%% Copyright 2022-23 by Alceu Frigeri
%%
%% This work may be distributed and/or modified under the conditions of
%%
%% * The [LaTeX Project Public License](http://www.latex-project.org/lppl.txt),
%%   version 1.3c (or later), and/or
%% * The [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.html),
%%   version 3 (or later)
%%
%% This work has the LPPL maintenance status *maintained*.
%%
%% The Current Maintainer of this work is Alceu Frigeri
%%
%% This is version 1.11 (2023/05/29)
%%
%% The list of files that compose this work can be found in the README.md file at
%% https://ctan.org/pkg/ufrgscca
%%
%%%==============================================================================
%% UFRGS stands for "Federal University of Rio Grande do Sul" in south Brazil
%% EE    stands for "Engineering School"
%% CCA   stands for "Control and Automation Engineering Course" (Portuguese acronym)
%%%==============================================================================
\NeedsTeXFormat{LaTeX2e}[2022/06/01]
\def\tc@tmp@packname{ufrgscca-curr-tab}
\def\tc@tmp@altpackname{ufrgsccacurrtab}
\def\tc@tmp@packdesc{UFRGS/CCA curricula tabular commands}
\def\tc@tmp@packdate{2023/05/29}
\def\tc@tmp@packversion{1.11beta}
\let\@exp\expandafter
\@exp\edef\csname\tc@tmp@altpackname version\endcsname{\tc@tmp@packversion}
\@exp\@exp\@exp\ProvidesPackage\@exp\@exp\@exp{\@exp\tc@tmp@packname\@exp}\@exp[\tc@tmp@packdate\space v\tc@tmp@packversion\space\tc@tmp@packdesc]

\RequirePackage{longtable}
\RequirePackage{ufrgscca-curr}

\NewDocumentCommand\TabClass{m}{%
 & #1 & \csname gr@class:#1.cred\endcsname & \csname gr@class:#1.typ\endcsname & \multicolumn{2}{J{11cm}}{\csname gr@class:#1.nam\endcsname}\\*%
    \edef\gr@disc{#1}%
		\ifcsdef{gr@class:#1.depA}{%
			& & & & %
   		& \def\gr@tab{\ }%
			\LstDep[\TabDepX]<A>{#1}\\*%
    }{}%
		\ifcsdef{gr@class:#1.depB}{%
			& & & & OU\\*%
			& & & & %
   		& \def\gr@tab{\ }%
			\LstDep[\TabDepX]<B>{#1}\\*%
		}{}%
		\ifcsdef{gr@class:#1.depC}{%
			& & & & OU\\*%
			& & & & %
   		& \def\gr@tab{\ }%
			\LstDep[\TabDepX]<C>{#1}\\*%
		}{}%
		\ifshowind{\ifcsundef{gr@class:#1.remark}%
		    {}{&       &       &  & \multicolumn{2}{l}{{\larger[2]{\color{red} \csname gr@class:#1.remark\endcsname}}}\\*}}{}%
\xdef\gr@topic{\csname gr@class:#1.topic\endcsname}%
&       &       &   & \multicolumn{2}{J{11cm}}{{\sc\color{\csname gr@topic:\gr@topic.color\endcsname} \csname gr@topic:\gr@topic.txt\endcsname}}\\*
&       &       &  & \multicolumn{2}{l}{{\smaller{\sc Súmula: }}}\\*%
&       &       &  & & {{\smaller\csname gr@class:#1.desc\endcsname}}\\ %
\ifcsundef{gr@class:#1.bibA}{}{&       &       &  & \multicolumn{2}{l}{{\smaller{\sc Bibliografia Básica Essencial: }}}\\* &       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.bibA\endcsname}\\*}%
\ifcsundef{gr@class:#1.bibB}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.bibB\endcsname}\\}%
\ifcsundef{gr@class:#1.bibC}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.bibC\endcsname}\\}%
\ifcsundef{gr@class:#1.bibD}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.bibD\endcsname}\\}%
\ifcsundef{gr@class:#1.bibE}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.bibE\endcsname}\\}%
\ifcsundef{gr@class:#1.bibF}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.bibF\endcsname}\\}%
\ifcsundef{gr@class:#1.bibG}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.bibG\endcsname}\\}%
\ifcsundef{gr@class:#1.bibH}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.bibH\endcsname}\\}%
\ifcsundef{gr@class:#1.bibI}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.bibI\endcsname}\\}%
\ifcsundef{gr@class:#1.bibJ}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.bibJ\endcsname}\\}%
\ifcsundef{gr@class:#1.basicA}{}{&       &       &  & \multicolumn{2}{l}{{\smaller{\sc Bibliografia Básica: }}}\\* &       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.basicA\endcsname}\\*}%
\ifcsundef{gr@class:#1.basicB}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.basicB\endcsname}\\}%
\ifcsundef{gr@class:#1.basicC}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.basicC\endcsname}\\}%
\ifcsundef{gr@class:#1.basicD}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.basicD\endcsname}\\}%
\ifcsundef{gr@class:#1.basicE}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.basicE\endcsname}\\}%
\ifcsundef{gr@class:#1.basicF}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.basicF\endcsname}\\}%
\ifcsundef{gr@class:#1.basicG}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.basicG\endcsname}\\}%
\ifcsundef{gr@class:#1.basicH}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.basicH\endcsname}\\}%
\ifcsundef{gr@class:#1.basicI}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.basicI\endcsname}\\}%
\ifcsundef{gr@class:#1.basicJ}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.basicJ\endcsname}\\}%
\ifcsundef{gr@class:#1.compA}{}{&       &       &  & \multicolumn{2}{l}{{\smaller{\sc Bibliografia Complementar: }}}\\* &       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.compA\endcsname}\\*}%
\ifcsundef{gr@class:#1.compB}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.compB\endcsname}\\}%
\ifcsundef{gr@class:#1.compC}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.compC\endcsname}\\}%
\ifcsundef{gr@class:#1.compD}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.compD\endcsname}\\}%
\ifcsundef{gr@class:#1.compE}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.compE\endcsname}\\}%
\ifcsundef{gr@class:#1.compF}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.compF\endcsname}\\}%
\ifcsundef{gr@class:#1.compG}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.compG\endcsname}\\}%
\ifcsundef{gr@class:#1.compH}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.compH\endcsname}\\}%
\ifcsundef{gr@class:#1.compI}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.compI\endcsname}\\}%
\ifcsundef{gr@class:#1.compJ}{}{&       &       &  & &{\smaller \textopenbullet\ \csname gr@class:#1.compJ\endcsname}\\}%
 \\[-1.5ex]%
}


%%%gr@class:\gr@disc.bib\Alph{gr@class:\gr@disc.bibcnt}

\NewDocumentCommand\TabDepX{m}{%
  {
    \ifshowind{\ifcsundef{gr@class:#1.remark}{}{\color{red}\bfseries}}{}
     \gr@tab\    #1 (\csname gr@class:#1.et\endcsname) %
	}
	\def\gr@tab{E}%
}

\NewDocumentCommand\TabDep{m}{%
    & & & & & #1 - \csname gr@class:#1.nam\endcsname\ (\csname gr@class:#1.et\endcsname)\\[-0.1ex]%
}

\NewDocumentCommand\TabEtp{D<>{ob}O{\notoc\section}m}{%
    #2{Etapa #3}%
    \begin{longtable}{l@{\,}l@{\ }c@{\ }c@{\ }J{5mm}@{}J{10.7cm}}%
        \LstClass[\TabClass]{#3}%
%        & \textbf{Total} & \textbf{\arabic{gr@cred#1}} & \textbf{#1}\\%
    \end{longtable}%
}

\NewDocumentCommand\@TabTopic{m}{%
 #1 & \csname gr@class:#1.cred\endcsname & \csname gr@class:#1.typ\endcsname & \csname gr@class:#1.nam\endcsname & (\csname gr@class:#1.et\endcsname)\\%
}

\NewDocumentCommand\TabTopic{O{ob}m}{%

\noindent\csname gr@topic:#2.txt\endcsname
\@ifundefined{gr@topic:#2}{\\\textbf{--No Classes Associated--}}{
    \begin{longtable}{l@{\,}l@{\ }c@{\ }J{11.2cm}@{\,}l}\smaller%
        \LstTopic[\@TabTopic]{#2}%
    \end{longtable}%
		}
}


\NewDocumentCommand\TabClassCompact{m}{%
 & #1 & \csname gr@class:#1.cred\endcsname & \csname gr@class:#1.typ\endcsname & \multicolumn{2}{J{11cm}}{\csname gr@class:#1.nam\endcsname}\\*%
    \edef\gr@disc{#1}%
		\ifcsdef{gr@class:#1.depA}{%
			\LstDep[\TabDep]<A>{#1}%
    }{}%
		\ifcsdef{gr@class:#1.depB}{%
			& & & & OU\\*%
			& & & & %
   		& \def\gr@tab{\ }%
			\LstDep[\TabDepX]<B>{#1}%
		}{}%
		\ifcsdef{gr@class:#1.depC}{%
			& & & & OU\\*%
			& & & & %
   		& \def\gr@tab{\ }%
			\LstDep[\TabDepX]<C>{#1}%
		}{}%
}

\NewDocumentCommand\TabEtpCompact{D<>{ob}O{}m}{%
    %#2{Etapa #3}%
    \begin{tabular}{l@{\,}l@{\ }c@{\ }c@{\ }J{4mm}@{}J{10cm}}%
    &{\larger\textbf{Etapa #3}}\\
        \LstClass[\TabClassCompact]{#3}%
%        & \textbf{Total} & \textbf{\arabic{gr@cred#1}} & \textbf{#1}\\%
    \end{tabular}%
}

