12#include "OptionParser.h"
18 OptionParser parser(
true, __PROGRAM_VERSION__);
19 parser.setExampleLongOption(
"phoenix_beamercreator --input=fileInput.png --output=output.tex");
20 parser.setExampleShortOption(
"phoenix_beamercreator -i fileInput1.png fileInput2.png fileInput3.png fileInput4.png -o output.tex");
22 parser.addOption(
"input",
"i", OptionType::FILENAME,
true,
"list of input files");
24 PString defaultOutput(
"output.tex");
25 parser.addOption(
"output",
"o", defaultOutput,
"name of the output tex file");
27 parser.addOption(
"169",
"169", OptionType::NONE,
false,
"make 16:9 presentation");
29 PString defaultColor(
"gray");
30 parser.addOption(
"numbercolor",
"n", defaultColor,
"color of the slides' number (black, white, blue, green, red, yellow, gray(by default))");
32 PString defaultTextFootpage(
"black");
33 parser.addOption(
"footpage",
"f", defaultTextFootpage,
"text to be written on the foot page");
35 PString defaultFootpageColor(
"white");
36 parser.addOption(
"footpagecolor",
"g", defaultFootpageColor,
"color of the foot page (black, white, blue, green, red, yellow, white(by default))");
47 fs <<
"\\documentclass[hyperref={ bookmarks=false, pdftoolbar=false, pdfmenubar=false, pdftitle={Titre}, pdfauthor={Pierre Aubert}}, french, 9pt, aspectratio=169]{beamer}" << std::endl;
49 fs <<
"\\documentclass[hyperref={ bookmarks=false, pdftoolbar=false, pdfmenubar=false, pdftitle={Titre}, pdfauthor={Pierre Aubert}}, french, 9pt]{beamer}" << std::endl;
51 fs <<
"\\setbeamertemplate{footline}{}" << std::endl;
52 fs <<
"\\setbeamertemplate{headline}{}" << std::endl;
53 fs <<
"%To have textblock" << std::endl;
54 fs <<
"\\usepackage[absolute,overlay]{textpos}" << std::endl;
56 fs <<
"\\usepackage{calc}\n\n\n\\usepackage{amssymb}\n\\usepackage{color}\n\\usepackage{amsfonts}\n\\usepackage{bbm}\n\\pagestyle{empty}\n\n\n";
57 fs <<
"\\usepackage{amsmath}\n\\usepackage{esint}\n\n";
58 fs <<
"\\usepackage{multirow}" << std::endl;
59 fs <<
"\\beamertemplatenavigationsymbolsempty" << std::endl;
60 fs <<
"\\beamertemplatetransparentcovered" << std::endl;
62 fs <<
"% marges qui pourissent l'existence pour les alignements" << std::endl;
63 fs <<
"\\setbeamersize{text margin left=0.0cm}" << std::endl;
64 fs <<
"\\setbeamersize{text margin right=0.0cm}" << std::endl;
66 fs <<
"\\newcommand{\\R}{\\mathbb{R}}" << std::endl;
67 fs <<
"\\newcommand{\\N}{\\mathbb{N}}" << std::endl;
68 fs <<
"\\newcommand{\\Z}{\\mathbb{Z}}" << std::endl;
69 fs <<
"\\newcommand{\\C}{\\mathbb{C}}" << std::endl;
70 fs <<
"\\newcommand{\\Q}{\\mathbb{Q}}" << std::endl;
71 fs <<
"\\newcommand{\\M}{\\mathbb{M}}" << std::endl;
72 fs <<
"\\newcommand{\\normal}{\\mathcal{N}}" << std::endl;
73 fs <<
"\\newcommand{\\uniform}{\\mathcal{U}}" << std::endl;
74 fs <<
"\\newcommand{\\A}{\\mathcal{A}}" << std::endl;
75 fs <<
"\\renewcommand{\\b}[1]{\\textbf{#1}}" << std::endl;
84void saveBeamerBackground(std::ofstream & fs,
const PPath & filePng,
long unsigned int slideNumber,
bool want169){
86 fs <<
"\\pgfdeclareimage[height=90mm, interpolate=true]{slide"<<slideNumber<<
"}{"<<filePng<<
"}" << std::endl;
88 fs <<
"\\pgfdeclareimage[height=96mm,width=128mm]{slide"<<slideNumber<<
"}{"<<filePng<<
"}" << std::endl;
90 fs <<
"\\setbeamertemplate{background}{\\pgfuseimage{slide"<<slideNumber<<
"}}" << std::endl;
101 const PString & footPage,
const PString & footPageColor)
103 if(slideNumber != 0lu){
105 fs <<
"\t\\begin{textblock*}{0.9\\textwidth}(0.01\\textwidth,0.97\\textheight)" << std::endl;
106 fs <<
"\t\t\\large{\\color{"<<footPageColor<<
"} " << footPage <<
"}" << std::endl;
107 fs <<
"\t\\end{textblock*}" << std::endl;
109 fs <<
"\t\\begin{textblock*}{0.1\\textwidth}(0.960\\textwidth,0.98\\textheight)" << std::endl;
110 fs <<
"\t\t\\textbf{\\Large{\\color{"<<numberColor<<
"} " << (slideNumber + 1lu) <<
"}}" << std::endl;
111 fs <<
"\t\\end{textblock*}" << std::endl;
124void saveBeamerSlideTex(std::ofstream & fs,
const PPath & fileTex,
long unsigned int slideNumber,
bool want169,
const PString & numberColor,
125 const PString & footPage,
const PString & footPageColor)
127 PPath backGroundFile(CMAKE_INSTALL_PREFIX
"/share/BeamerCreator/theme2.png");
128 if(slideNumber == 0){
129 backGroundFile = PPath(CMAKE_INSTALL_PREFIX
"/share/BeamerCreator/firstTheme.png");
133 fs <<
"\\frame{"<<std::endl;
134 fs << fileTex.loadFileContent() << std::endl;
136 fs <<
"}" << std::endl << std::endl;
150void saveBeamerSlidePng(std::ofstream & fs,
const PPath & filePng,
long unsigned int slideNumber,
bool want169,
const PString & numberColor,
151 const PString & footPage,
const PString & footPageColor)
154 fs <<
"\\frame{"<<std::endl;
156 fs <<
"}" << std::endl << std::endl;
168void saveBeamerSlide(std::ofstream & fs,
const PPath & filePng,
long unsigned int slideNumber,
bool want169,
const PString & numberColor,
169 const PString & footPage,
const PString & footPageColor)
175 PPath fileExtention(filePng.getExtension());
176 if(fileExtention ==
"png"){
177 saveBeamerSlidePng(fs, filePng, slideNumber, want169, numberColor, footPage, footPageColor);
178 }
else if(fileExtention ==
"tex"){
179 saveBeamerSlideTex(fs, filePng, slideNumber, want169, numberColor, footPage, footPageColor);
181 std::cerr <<
"saveBeamerSlide : unknown extention '"<<fileExtention<<
"' of file '"<<filePng<<
"'" << std::endl;
193void makeTexSlides(
const PPath & outputFileName,
const std::vector<PPath> & listInputFile,
bool want169,
const PString & numberColor,
194 const PString & footPage,
const PString & footPageColor)
196 if(outputFileName ==
"" || listInputFile.size() == 0lu){
return;}
199 fs.open(outputFileName.c_str());
201 std::cerr <<
"makeTexSlides : can't open file '" << outputFileName <<
"'" << std::endl;
206 fs <<
"\\begin{document}" << std::endl;
207 PString previousFile(
"");
208 long unsigned int i(-1lu);
209 for(std::vector<PPath>::const_iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
210 PPath currentFileName(it->getFileName());
212 if(previousFile.size() < 6lu || currentFileName.size() < 6lu){
215 if(previousFile.substr(0, previousFile.size() - 6lu) != currentFileName.substr(0, currentFileName.size() - 6lu)){
219 previousFile = currentFileName;
220 saveBeamerSlide(fs, *it, i, want169, numberColor, footPage, footPageColor);
223 fs <<
"\\end{document}" << std::endl;
228int main(
int argc,
char** argv){
230 parser.parseArgument(argc, argv);
232 const OptionMode & defaultMode = parser.getDefaultMode();
233 std::vector<PPath> listInputFile;
234 defaultMode.getValue(listInputFile,
"input");
236 PString outputFile(
"output.tex");
237 defaultMode.getValue(outputFile,
"output");
239 PString numberColor(
"gray");
240 defaultMode.getValue(numberColor,
"numbercolor");
242 PString footPage(
"");
243 defaultMode.getValue(footPage,
"footpage");
245 PString footPageColor(
"white");
246 defaultMode.getValue(footPageColor,
"footpagecolor");
248 bool is169 = defaultMode.isOptionExist(
"169");
249 makeTexSlides(outputFile, listInputFile, is169, numberColor, footPage, footPageColor);
void saveBeamerSlideNumber(std::ofstream &fs, long unsigned int slideNumber, const PString &numberColor, const PString &footPage, const PString &footPageColor)
Save the beamer slide number.
void saveBeamerSlidePng(std::ofstream &fs, const PPath &filePng, long unsigned int slideNumber, bool want169, const PString &numberColor, const PString &footPage, const PString &footPageColor)
Make the beamer tex slide.
int main(int argc, char **argv)
void saveBeamerSlide(std::ofstream &fs, const PPath &filePng, long unsigned int slideNumber, bool want169, const PString &numberColor, const PString &footPage, const PString &footPageColor)
Make the beamer tex slide.
void saveBeamerBackground(std::ofstream &fs, const PPath &filePng, long unsigned int slideNumber, bool want169)
Save the beamer background.
void saveBeamerSlideTex(std::ofstream &fs, const PPath &fileTex, long unsigned int slideNumber, bool want169, const PString &numberColor, const PString &footPage, const PString &footPageColor)
Save the beamer slide with a tex file.
void saveBeamerHeaderTex(std::ofstream &fs, bool want169)
Make the beamer tex header.
void makeTexSlides(const PPath &outputFileName, const std::vector< PPath > &listInputFile, bool want169, const PString &numberColor, const PString &footPage, const PString &footPageColor)
Make the tex slides.
OptionParser createOptionParser()
Create the OptionParser of this program.