PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
main.cpp File Reference
#include <fstream>
#include <iostream>
#include "PPath.h"
#include "OptionParser.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

OptionParser createOptionParser ()
 Create the OptionParser of this program. More...
 
int main (int argc, char **argv)
 
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. More...
 
void saveBeamerBackground (std::ofstream &fs, const PPath &filePng, long unsigned int slideNumber, bool want169)
 Save the beamer background. More...
 
void saveBeamerHeaderTex (std::ofstream &fs, bool want169)
 Make the beamer tex header. More...
 
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. More...
 
void saveBeamerSlideNumber (std::ofstream &fs, long unsigned int slideNumber, const PString &numberColor, const PString &footPage, const PString &footPageColor)
 Save the beamer slide number. More...
 
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. More...
 
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. More...
 

Function Documentation

◆ createOptionParser()

OptionParser createOptionParser ( )

Create the OptionParser of this program.

Returns
OptionParser of this program

Definition at line 17 of file main.cpp.

17  {
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");
21 
22  parser.addOption("input", "i", OptionType::FILENAME, true, "list of input files");
23 
24  PString defaultOutput("output.tex");
25  parser.addOption("output", "o", defaultOutput, "name of the output tex file");
26 
27  parser.addOption("169", "169", OptionType::NONE, false, "make 16:9 presentation");
28 
29  PString defaultColor("gray");
30  parser.addOption("numbercolor", "n", defaultColor, "color of the slides' number (black, white, blue, green, red, yellow, gray(by default))");
31 
32  PString defaultTextFootpage("black");
33  parser.addOption("footpage", "f", defaultTextFootpage, "text to be written on the foot page");
34 
35  PString defaultFootpageColor("white");
36  parser.addOption("footpagecolor", "g", defaultFootpageColor, "color of the foot page (black, white, blue, green, red, yellow, white(by default))");
37 
38  return parser;
39 }
Parse the options passed to a program.
Definition: OptionParser.h:15
Extends the std::string.
Definition: PString.h:16

References OptionParser::addOption(), OptionType::FILENAME, OptionType::NONE, OptionParser::setExampleLongOption(), and OptionParser::setExampleShortOption().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 228 of file main.cpp.

228  {
229  OptionParser parser = createOptionParser();
230  parser.parseArgument(argc, argv);
231 
232  const OptionMode & defaultMode = parser.getDefaultMode();
233  std::vector<PPath> listInputFile;
234  defaultMode.getValue(listInputFile, "input");
235 
236  PString outputFile("output.tex");
237  defaultMode.getValue(outputFile, "output");
238 
239  PString numberColor("gray");
240  defaultMode.getValue(numberColor, "numbercolor");
241 
242  PString footPage("");
243  defaultMode.getValue(footPage, "footpage");
244 
245  PString footPageColor("white");
246  defaultMode.getValue(footPageColor, "footpagecolor");
247 
248  bool is169 = defaultMode.isOptionExist("169");
249  makeTexSlides(outputFile, listInputFile, is169, numberColor, footPage, footPageColor);
250  return 0;
251 }
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.
Definition: main.cpp:193
OptionParser createOptionParser()
Create the OptionParser of this program.
Definition: main.cpp:17
Describe a mode in the program arguments.
Definition: OptionMode.h:13
bool isOptionExist(const PString &optionName) const
Say if the given option has been passed to the program.
Definition: OptionMode.cpp:210
bool getValue(T &value, const PString &optionName) const
Get the value of the option.
void parseArgument(int argc, char **argv)
Parse the arguments passed to the program.
const OptionMode & getDefaultMode() const
Get default mode.

References createOptionParser(), OptionParser::getDefaultMode(), OptionMode::getValue(), OptionMode::isOptionExist(), makeTexSlides(), and OptionParser::parseArgument().

+ Here is the call graph for this function:

◆ makeTexSlides()

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.

Parameters
outputFileName: output file name
listInputFile: list of the png slides input
want169: to have a 16:9 aspect ratio
numberColor: color of the slide number (black, white, red, blue, green, yellow, gray(by default))
footPage: string to be written in the footpage of the slides
footPageColor: color of the foot page

Definition at line 193 of file main.cpp.

195 {
196  if(outputFileName == "" || listInputFile.size() == 0lu){return;}
197 
198  std::ofstream fs;
199  fs.open(outputFileName.c_str());
200  if(!fs.is_open()){
201  std::cerr << "makeTexSlides : can't open file '" << outputFileName << "'" << std::endl;
202  return;
203  }
204  saveBeamerHeaderTex(fs, want169);
205 
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());
211 
212  if(previousFile.size() < 6lu || currentFileName.size() < 6lu){
213  ++i;
214  }else{
215  if(previousFile.substr(0, previousFile.size() - 6lu) != currentFileName.substr(0, currentFileName.size() - 6lu)){
216  ++i;
217  }
218  }
219  previousFile = currentFileName;
220  saveBeamerSlide(fs, *it, i, want169, numberColor, footPage, footPageColor);
221  }
222 
223  fs << "\\end{document}" << std::endl;
224 
225  fs.close();
226 }
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.
Definition: main.cpp:168
void saveBeamerHeaderTex(std::ofstream &fs, bool want169)
Make the beamer tex header.
Definition: main.cpp:45
Path of a directory or a file.
Definition: PPath.h:17

References saveBeamerHeaderTex(), and saveBeamerSlide().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveBeamerBackground()

void saveBeamerBackground ( std::ofstream &  fs,
const PPath filePng,
long unsigned int  slideNumber,
bool  want169 
)

Save the beamer background.

Parameters
[out]fs: file to be written
filePng: name of the png file to be used as background
slideNumber: slide number
want169: to have a 16:9 aspect ratio

Definition at line 84 of file main.cpp.

84  {
85  if(want169){
86  fs << "\\pgfdeclareimage[height=90mm, interpolate=true]{slide"<<slideNumber<<"}{"<<filePng<<"}" << std::endl;
87  }else{
88  fs << "\\pgfdeclareimage[height=96mm,width=128mm]{slide"<<slideNumber<<"}{"<<filePng<<"}" << std::endl;
89  }
90  fs << "\\setbeamertemplate{background}{\\pgfuseimage{slide"<<slideNumber<<"}}" << std::endl;
91 }

Referenced by saveBeamerSlidePng(), and saveBeamerSlideTex().

+ Here is the caller graph for this function:

◆ saveBeamerHeaderTex()

void saveBeamerHeaderTex ( std::ofstream &  fs,
bool  want169 
)

Make the beamer tex header.

Parameters
[out]fs: file to be completed
want169: to have a 16:9 aspect ratio

Definition at line 45 of file main.cpp.

45  {
46  if(want169){
47  fs << "\\documentclass[hyperref={ bookmarks=false, pdftoolbar=false, pdfmenubar=false, pdftitle={Titre}, pdfauthor={Pierre Aubert}}, french, 9pt, aspectratio=169]{beamer}" << std::endl;
48  }else{
49  fs << "\\documentclass[hyperref={ bookmarks=false, pdftoolbar=false, pdfmenubar=false, pdftitle={Titre}, pdfauthor={Pierre Aubert}}, french, 9pt]{beamer}" << std::endl;
50  }
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;
55 
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;
61 
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;
65 
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;
76 }

Referenced by makeTexSlides().

+ Here is the caller graph for this function:

◆ saveBeamerSlide()

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.

Parameters
[out]fs: file to be completed
filePng: file png to be in the slide
slideNumber: slide number
want169: to have a 16:9 aspect ratio
numberColor: color of the slide number (black, white, red, blue, green, yellow, gray(by default))
footPage: string to be written in the footpage of the slides
footPageColor: color of the foot page

Definition at line 168 of file main.cpp.

170 {
171  //Check if the extention is not png
172  // If the extention is tex I need to put the content into a slide
173  // I need also to add the theme and the page number
174 
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);
180  }else{
181  std::cerr << "saveBeamerSlide : unknown extention '"<<fileExtention<<"' of file '"<<filePng<<"'" << std::endl;
182  }
183 }
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.
Definition: main.cpp:150
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.
Definition: main.cpp:124
PString getExtension() const
Get file extension.
Definition: PPath.cpp:252

References PPath::getExtension(), saveBeamerSlidePng(), and saveBeamerSlideTex().

Referenced by makeTexSlides().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveBeamerSlideNumber()

void saveBeamerSlideNumber ( std::ofstream &  fs,
long unsigned int  slideNumber,
const PString numberColor,
const PString footPage,
const PString footPageColor 
)

Save the beamer slide number.

Parameters
[out]fs: file to be written
slideNumber: slide number
numberColor: color of the slide number (black, white, red, blue, green, yellow, gray(by default))
footPage: string to be written in the footpage of the slides
footPageColor: color of the foot page

Definition at line 100 of file main.cpp.

102 {
103  if(slideNumber != 0lu){
104  if(footPage != ""){
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;
108  }
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;
112  }
113 }

Referenced by saveBeamerSlidePng(), and saveBeamerSlideTex().

+ Here is the caller graph for this function:

◆ saveBeamerSlidePng()

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.

Parameters
[out]fs: file to be completed
filePng: file png to be in the slide
slideNumber: slide number
want169: to have a 16:9 aspect ratio
numberColor: color of the slide number (black, white, red, blue, green, yellow, gray(by default))
footPage: string to be written in the footpage of the slides
footPageColor: color of the foot page

Definition at line 150 of file main.cpp.

152 {
153  saveBeamerBackground(fs, filePng, slideNumber, want169);
154  fs << "\\frame{"<<std::endl;
155  saveBeamerSlideNumber(fs, slideNumber, numberColor, footPage, footPageColor);
156  fs << "}" << std::endl << std::endl;
157 }
void saveBeamerSlideNumber(std::ofstream &fs, long unsigned int slideNumber, const PString &numberColor, const PString &footPage, const PString &footPageColor)
Save the beamer slide number.
Definition: main.cpp:100
void saveBeamerBackground(std::ofstream &fs, const PPath &filePng, long unsigned int slideNumber, bool want169)
Save the beamer background.
Definition: main.cpp:84

References saveBeamerBackground(), and saveBeamerSlideNumber().

Referenced by saveBeamerSlide().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveBeamerSlideTex()

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.

Parameters
[out]fs: file to be written
fileTex: name of the tex file to be red
slideNumber: slide number
want169: to have a 16:9 aspect ratio
numberColor: color of the slide number (black, white, red, blue, green, yellow, gray(by default))
footPage: string to be written in the footpage of the slides
footPageColor: color of the foot page

Definition at line 124 of file main.cpp.

126 {
127  PPath backGroundFile(CMAKE_INSTALL_PREFIX "/share/BeamerCreator/theme2.png");
128  if(slideNumber == 0){
129  backGroundFile = PPath(CMAKE_INSTALL_PREFIX "/share/BeamerCreator/firstTheme.png");
130  }
131  saveBeamerBackground(fs, backGroundFile, slideNumber, want169);
132 
133  fs << "\\frame{"<<std::endl;
134  fs << fileTex.loadFileContent() << std::endl;
135  saveBeamerSlideNumber(fs, slideNumber, numberColor, footPage, footPageColor);
136  fs << "}" << std::endl << std::endl;
137 }
PString loadFileContent() const
Get the file content in a PString.
Definition: PPath.cpp:382

References PPath::loadFileContent(), saveBeamerBackground(), and saveBeamerSlideNumber().

Referenced by saveBeamerSlide().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: