PhoenixLecture  2.0.0
Set of tools to make lectures
ptimetable_tex.cpp File Reference
#include <iomanip>
#include "platexobj_create.h"
#include "ptimetable_invitation.h"
#include "ptimetable_tex.h"
+ Include dependency graph for ptimetable_tex.cpp:

Go to the source code of this file.

Functions

void ptimetable_addBlockInWeek (TexWeek &week, const PTimeTableBlock &block, const PString &invitationTimeTable)
 Add a block in week. More...
 
void ptimetable_blockToTex (PLatexObj &obj, const PTimeTableBlock &block)
 Convert a PTimeTableBlock into PLatexObj. More...
 
bool ptimetable_checkBlockExist (const PTimeTableBlock *&foundBlock, const std::map< PString, PTimeTableBlock > &mapBlock, const PString &timeText)
 Check if a block exists at a given time. More...
 
void ptimetable_compelteDayEmptyBlock (TexDay &day, const std::map< PString, PString > &mapHour)
 Complete day with empty blocks to make them coherent. More...
 
void ptimetable_completeEmptyBlock (TexTimetable &texTimetable)
 Complete day of timetable with empty blocks to make them coherent. More...
 
void ptimetable_createTabCell (PLatexObj &cell, const PString &text)
 Create a table cell. More...
 
void ptimetable_createTexTimeTable (TexTimetable &texTimetable, const PTimeTable &timetable)
 Create the TexTimetable. More...
 
PString ptimetable_dateToStr (const PLatexDate &date)
 Convert a date into a string which can be used in a std::map. More...
 
PString ptimetable_dateToText (const PLatexDate &date)
 Convert a date into a string. More...
 
void ptimetable_singleDay (TexDay &out, std::map< PString, PString > &mapHour, const TexDay &day)
 Create a single day with consistent mapHour. More...
 
bool ptimetable_tex (std::vector< PLatexObj > &vecContent, const PTimeTable &timetable, const PPath &outputDirectory, bool isSaveSpeaker)
 Convert a PTimeTable into PLatexObj. More...
 
void ptimetable_texChapter (std::vector< PLatexObj > &vecContent, const TexWeek &week, const TexTimetable &texTimetable)
 Convert a PTimeTable into PLatexObj. More...
 
void ptimetable_texLecture (std::vector< PLatexObj > &vecContent, const PTimeTableBlock &block, const TexTimetable &texTimetable)
 Save lectures in PLatexObj. More...
 
void ptimetable_texPart (std::vector< PLatexObj > &vecContent, const TexTimetable &texTimetable)
 Convert a PTimeTable into PLatexObj. More...
 
void ptimetable_texSection (std::vector< PLatexObj > &vecContent, const TexDay &day, const TexTimetable &texTimetable, const TexWeek &week)
 Convert a PTimeTable into PLatexObj. More...
 
PString ptimetable_timeToStr (const PLatexTime &texTime)
 Convert a PLatexTime into a string. More...
 
void ptimetable_toTex (PLatexObj &obj, const TexTimetable &texTimetable)
 Convert a TexTimetable into a PLatexObj. More...
 
void ptimetable_updateBlockTimeRow (PTimeTableBlock &block, const std::map< PString, PString > &mapHour)
 Update the time rows of the PTimeTableBlock. More...
 
void ptimetable_updateTimeRow (TexTimetable &texTimetable)
 Update the time rows of the PTimeTableBlock. More...
 
void ptimetable_updateWeekLaterTime (TexWeek &week, const PLatexTime &texTime)
 Update the later time of the week. More...
 

Function Documentation

◆ ptimetable_addBlockInWeek()

void ptimetable_addBlockInWeek ( TexWeek week,
const PTimeTableBlock block,
const PString invitationTimeTable 
)

Add a block in week.

Parameters
[out]week: TexWeek to be updated
block: PTimeTableBlock to be added into the week
invitationTimeTable: invitation of the full timetable

Update the later time of the week

Definition at line 63 of file ptimetable_tex.cpp.

63  {
64  PString blockDate(ptimetable_dateToStr(block.getDate()));
65  PString beginTime(ptimetable_timeToStr(block.getBeginTime()));
66  PString endTime(ptimetable_timeToStr(block.getEndTime()));
69 
70  std::map<PString, TexDay> & mapDay = week.mapDay;
71  std::map<PString, TexDay>::iterator it(mapDay.find(blockDate));
72  if(it != mapDay.end()){
73  it->second.mapBlock[beginTime] = block;
74  }else{
75  TexDay & day = mapDay[blockDate];
76  day.date = block.getDate();
77  day.invitation = invitationTimeTable + "_" + blockDate;
78  day.mapBlock[beginTime] = block;
79  }
80  week.mapHour[beginTime] = "";
81  week.mapHour[endTime] = "";
82 }
Extends the std::string.
Definition: PString.h:16
const PLatexDate & getDate() const
Gets the date of the PTimeTableBlock.
Definition: PTimeTable.cpp:586
const PLatexTime & getEndTime() const
Gets the endTime of the PTimeTableBlock.
Definition: PTimeTable.cpp:614
const PLatexTime & getBeginTime() const
Gets the beginTime of the PTimeTableBlock.
Definition: PTimeTable.cpp:600
PString ptimetable_dateToStr(const PLatexDate &date)
Convert a date into a string which can be used in a std::map.
PString ptimetable_timeToStr(const PLatexTime &texTime)
Convert a PLatexTime into a string.
void ptimetable_updateWeekLaterTime(TexWeek &week, const PLatexTime &texTime)
Update the later time of the week.
Day of the week.
Definition: TexTimetable.h:14
std::map< PString, PTimeTableBlock > mapBlock
Map of the block of a day (time format hour:minute)
Definition: TexTimetable.h:20
PString invitation
Invitation of the day.
Definition: TexTimetable.h:16
PLatexDate date
Date of the current day.
Definition: TexTimetable.h:18
std::map< PString, PString > mapHour
Map of the hours of the blocks in the week.
Definition: TexTimetable.h:30
std::map< PString, TexDay > mapDay
Map of hte day in the week (date format: year-month-day)
Definition: TexTimetable.h:32

References TexDay::date, PTimeTableBlock::getBeginTime(), PTimeTableBlock::getDate(), PTimeTableBlock::getEndTime(), TexDay::invitation, TexDay::mapBlock, TexWeek::mapDay, TexWeek::mapHour, ptimetable_dateToStr(), ptimetable_timeToStr(), and ptimetable_updateWeekLaterTime().

Referenced by ptimetable_createTexTimeTable().

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

◆ ptimetable_blockToTex()

void ptimetable_blockToTex ( PLatexObj obj,
const PTimeTableBlock block 
)

Convert a PTimeTableBlock into PLatexObj.

Parameters
[out]vecContent: vector of PLatexObj to be updated
block: PTimeTableBlock to be converted

Definition at line 220 of file ptimetable_tex.cpp.

220  {
221  if(block.getIsEmptyBlock()){
223  return;
224  }
226  obj.setRowSpan(block.getNbTimeRow());
227 
228  if(block.getStyle() != ""){
229  obj.setText(block.getStyle());
230  }
231  std::vector<PLatexObj> & vecContent = obj.getVecContent();
232  if(block.getVecSpeaker().size() != 0lu){
233  if(block.getInvitation() != ""){
234  vecContent.push_back(platexobj_createRendezVous(PPath(LATEX_INVITATION_OUTPUT_DIR "/" + block.getInvitation() + ".ics")));
235  vecContent.push_back(platexobj_createRef("sec_" + block.getInvitation(), block.getTitle()));
236  }
237  }else{
238  vecContent = block.getTitle().getVecContent();
239  }
240 }
#define LATEX_INVITATION_OUTPUT_DIR
Definition: PLatexObj_def.h:14
const std::vector< PLatexObj > & getVecContent() const
Gets the vecContent of the PLatexObj.
Definition: PLatexObj.cpp:410
void setRowSpan(long unsigned int rowSpan)
Sets the rowSpan of the PLatexObj.
Definition: PLatexObj.cpp:270
void setType(const PLatexType::PLatexType &type)
Sets the type of the PLatexObj.
Definition: PLatexObj.cpp:130
void setText(const PString &text)
Sets the text of the PLatexObj.
Definition: PLatexObj.cpp:137
Path of a directory or a file.
Definition: PPath.h:17
const PLatexObj & getTitle() const
Gets the title of the PTimeTableBlock.
Definition: PTimeTable.cpp:516
bool getIsEmptyBlock() const
Gets the isEmptyBlock of the PTimeTableBlock.
Definition: PTimeTable.cpp:698
size_t getNbTimeRow() const
Gets the nbTimeRow of the PTimeTableBlock.
Definition: PTimeTable.cpp:684
const PString & getStyle() const
Gets the style of the PTimeTableBlock.
Definition: PTimeTable.cpp:670
const PString & getInvitation() const
Gets the invitation of the PTimeTableBlock.
Definition: PTimeTable.cpp:558
const std::vector< PString > & getVecSpeaker() const
Gets the vecSpeaker of the PTimeTableBlock.
Definition: PTimeTable.cpp:544
@ TIMETABLE_EMPTYBLOCK
Definition: PLatexType.h:103
@ TIMETABLE_BLOCK
Definition: PLatexType.h:102
PLatexObj platexobj_createRef(const PString &label, const PString &text)
Create a reference (REF)
PLatexObj platexobj_createRendezVous(const PPath &fileNameIcs)
Create a RENDEZVOUS.

References PTimeTableBlock::getInvitation(), PTimeTableBlock::getIsEmptyBlock(), PTimeTableBlock::getNbTimeRow(), PTimeTableBlock::getStyle(), PTimeTableBlock::getTitle(), PLatexObj::getVecContent(), PTimeTableBlock::getVecSpeaker(), LATEX_INVITATION_OUTPUT_DIR, platexobj_createRef(), platexobj_createRendezVous(), PLatexObj::setRowSpan(), PLatexObj::setText(), PLatexObj::setType(), PLatexType::TIMETABLE_BLOCK, and PLatexType::TIMETABLE_EMPTYBLOCK.

Referenced by ptimetable_toTex().

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

◆ ptimetable_checkBlockExist()

bool ptimetable_checkBlockExist ( const PTimeTableBlock *&  foundBlock,
const std::map< PString, PTimeTableBlock > &  mapBlock,
const PString timeText 
)

Check if a block exists at a given time.

Parameters
[out]foundBlock: pointer to the found block, if there is one (NULL otherwise)
mapBlock: map of blocks to be checked
timeText: time to be searched
Returns
true if time does exist, false otherwise

Definition at line 123 of file ptimetable_tex.cpp.

123  {
124  std::map<PString, PTimeTableBlock>::const_iterator it(mapBlock.find(timeText));
125  if(it != mapBlock.end()){
126  foundBlock = &(it->second);
127  return true;
128  }else{
129  foundBlock = NULL;
130  return false;
131  }
132 }

Referenced by ptimetable_compelteDayEmptyBlock().

+ Here is the caller graph for this function:

◆ ptimetable_compelteDayEmptyBlock()

void ptimetable_compelteDayEmptyBlock ( TexDay day,
const std::map< PString, PString > &  mapHour 
)

Complete day with empty blocks to make them coherent.

Parameters
[out]day: TexDay to be completed
mapHour: map of hours in the week

Definition at line 138 of file ptimetable_tex.cpp.

138  {
139  std::map<PString, PTimeTableBlock> & mapBlock = day.mapBlock;
140  //Let's iterate over times of the week
141  std::map<PString, PString>::const_iterator itHour(mapHour.begin());
142  while(itHour != mapHour.end()){
143  PString currentTime(itHour->first);
144  //Let's check if we found a correspondingblock at this time
145  const PTimeTableBlock * foundBlock = NULL;
146  if(ptimetable_checkBlockExist(foundBlock, mapBlock, currentTime)){
147  //A block has been found, we can jump until its end
148  PString endTime(ptimetable_timeToStr(foundBlock->getEndTime()));
149  //Normally the endtime should exist in mapHour
150  itHour = mapHour.find(endTime);
151  }else{
152  //No block found, ew have to add an empty block
153  PTimeTableBlock emptyBlock;
154  emptyBlock.setIsEmptyBlock(true);
155  mapBlock[currentTime] = emptyBlock;
156  ++itHour;
157  }
158  }
159 }
Block of a Timetable.
Definition: PTimeTable.h:109
void setIsEmptyBlock(bool isEmptyBlock)
Sets the isEmptyBlock of the PTimeTableBlock.
Definition: PTimeTable.cpp:495
bool ptimetable_checkBlockExist(const PTimeTableBlock *&foundBlock, const std::map< PString, PTimeTableBlock > &mapBlock, const PString &timeText)
Check if a block exists at a given time.

References PTimeTableBlock::getEndTime(), TexDay::mapBlock, ptimetable_checkBlockExist(), ptimetable_timeToStr(), and PTimeTableBlock::setIsEmptyBlock().

Referenced by ptimetable_completeEmptyBlock().

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

◆ ptimetable_completeEmptyBlock()

void ptimetable_completeEmptyBlock ( TexTimetable texTimetable)

Complete day of timetable with empty blocks to make them coherent.

Parameters
[out]texTimetable: TexTimetable to be completed

Definition at line 164 of file ptimetable_tex.cpp.

164  {
165  //Let's iterate over weeks
166  std::vector<TexWeek> & vecWeek = texTimetable.vecWeek;
167  for(std::vector<TexWeek>::iterator itWeek(vecWeek.begin()); itWeek != vecWeek.end(); ++itWeek){
168  //Let's iterate over days
169  std::map<PString, TexDay> & mapDay = itWeek->mapDay;
170  std::map<PString, PString> & mapHour = itWeek->mapHour;
171  for(std::map<PString, TexDay>::iterator itDay(mapDay.begin()); itDay != mapDay.end(); ++itDay){
172  ptimetable_compelteDayEmptyBlock(itDay->second, mapHour);
173  }
174  }
175 }
void ptimetable_compelteDayEmptyBlock(TexDay &day, const std::map< PString, PString > &mapHour)
Complete day with empty blocks to make them coherent.
std::vector< TexWeek > vecWeek
Vector of week.
Definition: TexTimetable.h:42

References ptimetable_compelteDayEmptyBlock(), and TexTimetable::vecWeek.

Referenced by ptimetable_tex().

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

◆ ptimetable_createTabCell()

void ptimetable_createTabCell ( PLatexObj cell,
const PString text 
)

Create a table cell.

Parameters
[out]cell: cell of a table
text: text to write in the cell

Definition at line 246 of file ptimetable_tex.cpp.

246  {
248 
249  PLatexObj textObj;
250  textObj.setType(PLatexType::TEXT);
251  textObj.setText(text);
252  cell.getVecContent().push_back(textObj);
253 }
Describe a latex object.
Definition: PLatexObj.h:40

References PLatexObj::getVecContent(), PLatexObj::setText(), PLatexObj::setType(), PLatexType::TEXT, and PLatexType::TIMETABLE_BLOCK.

+ Here is the call graph for this function:

◆ ptimetable_createTexTimeTable()

void ptimetable_createTexTimeTable ( TexTimetable texTimetable,
const PTimeTable timetable 
)

Create the TexTimetable.

Parameters
[out]texTimetable: created TexTimetable
timetable: PTimeTable to be used to create the TexTimetable

Definition at line 88 of file ptimetable_tex.cpp.

88  {
89  const std::vector<PTimeTableBlock> & vecBlock = timetable.getVecBlock();
90  std::vector<TexWeek> & vecWeek = texTimetable.vecWeek;
91 
92  PString invitationTimeTable(timetable.getInvitation());
93  texTimetable.invitation = invitationTimeTable;
94  TexWeek emptyWeek;
95  emptyWeek.laterTime.setHour(0lu);
96  emptyWeek.laterTime.setMinute(0lu);
97  vecWeek.push_back(emptyWeek);
98  //TODO : here we need to deal with untitled weeks
99  //If no week has a title we have to dispatch days in month, or let say by 6-7 on a row to avoid too large generated web site
100  for(std::vector<PTimeTableBlock>::const_iterator it(vecBlock.begin()); it != vecBlock.end(); ++it){
101  if(it->getWeekTitle().getVecContent().size() != 0lu){
102  vecWeek.push_back(emptyWeek);
103  vecWeek.back().weekTitle = it->getWeekTitle();
104  vecWeek.back().invitation = it->getInvitation();
105  }
106  if(it->getTitle().getVecContent().size() != 0lu){
107  ptimetable_addBlockInWeek(vecWeek.back(), *it, invitationTimeTable);
108  }
109  }
110  //Create the map of speakers
111  const std::vector<PLatexSpeaker> & vecSpeaker = timetable.getVecSpeaker();
112  for(std::vector<PLatexSpeaker>::const_iterator it(vecSpeaker.begin()); it != vecSpeaker.end(); ++it){
113  texTimetable.mapSpeaker[it->getLabel()] = *it;
114  }
115 }
void setMinute(size_t minute)
Sets the minute of the PLatexTime.
Definition: PTimeTable.cpp:322
void setHour(size_t hour)
Sets the hour of the PLatexTime.
Definition: PTimeTable.cpp:315
const PString & getInvitation() const
Gets the invitation of the PTimeTable.
Definition: PTimeTable.cpp:859
const std::vector< PTimeTableBlock > & getVecBlock() const
Gets the vecBlock of the PTimeTable.
Definition: PTimeTable.cpp:929
const std::vector< PLatexSpeaker > & getVecSpeaker() const
Gets the vecSpeaker of the PTimeTable.
Definition: PTimeTable.cpp:943
void ptimetable_addBlockInWeek(TexWeek &week, const PTimeTableBlock &block, const PString &invitationTimeTable)
Add a block in week.
PString invitation
Invitation of the full event.
Definition: TexTimetable.h:40
std::map< PString, PLatexSpeaker > mapSpeaker
Map of Speaker.
Definition: TexTimetable.h:44
Week of the timetable.
Definition: TexTimetable.h:24
PLatexTime laterTime
Later time of all days.
Definition: TexTimetable.h:34

References PTimeTable::getInvitation(), PTimeTable::getVecBlock(), PTimeTable::getVecSpeaker(), TexTimetable::invitation, TexWeek::laterTime, TexTimetable::mapSpeaker, ptimetable_addBlockInWeek(), PLatexTime::setHour(), PLatexTime::setMinute(), and TexTimetable::vecWeek.

Referenced by ptimetable_tex().

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

◆ ptimetable_dateToStr()

PString ptimetable_dateToStr ( const PLatexDate date)

Convert a date into a string which can be used in a std::map.

Parameters
date: PLatexDate to be converted in to a string
Returns
corresponding string (year-month-day)

Definition at line 17 of file ptimetable_tex.cpp.

17  {
18  std::stringstream dateStr;
19  dateStr << date.getYear() << "-" << std::setfill('0') << std::setw(2) << date.getMonth() << "-" << std::setfill('0') << std::setw(2) << date.getDay();
20  return dateStr.str();
21 }
size_t getMonth() const
Gets the month of the PLatexDate.
Definition: PTimeTable.cpp:245
size_t getYear() const
Gets the year of the PLatexDate.
Definition: PTimeTable.cpp:231
size_t getDay() const
Gets the day of the PLatexDate.
Definition: PTimeTable.cpp:259

References PLatexDate::getDay(), PLatexDate::getMonth(), and PLatexDate::getYear().

Referenced by ptimetable_addBlockInWeek(), and ptimetable_texSection().

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

◆ ptimetable_dateToText()

PString ptimetable_dateToText ( const PLatexDate date)

Convert a date into a string.

Parameters
date: PLatexDate to be converted in to a string
Returns
corresponding string (day-month-year)

Definition at line 27 of file ptimetable_tex.cpp.

27  {
28  std::stringstream dateStr;
29  dateStr << std::setfill('0') << std::setw(2) << date.getDay() << "/" << std::setfill('0') << std::setw(2) << date.getMonth() << "/" << date.getYear();
30  return dateStr.str();
31 }

References PLatexDate::getDay(), PLatexDate::getMonth(), and PLatexDate::getYear().

Referenced by ptimetable_texLecture(), and ptimetable_texSection().

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

◆ ptimetable_singleDay()

void ptimetable_singleDay ( TexDay out,
std::map< PString, PString > &  mapHour,
const TexDay day 
)

Create a single day with consistent mapHour.

Parameters
[out]out: output updated TexDay
[out]mapHour: output updated map of hours
day: TexDay to be updated

Definition at line 329 of file ptimetable_tex.cpp.

329  {
330  out.date = day.date;
331  out.invitation = day.invitation;
332  const std::map<PString, PTimeTableBlock> & mapBlock = day.mapBlock;
333  for(std::map<PString, PTimeTableBlock>::const_iterator it(mapBlock.begin()); it != mapBlock.end(); ++it){
334  if(it->second.getIsEmptyBlock()){continue;}
335  PString beginTime(ptimetable_timeToStr(it->second.getBeginTime()));
336  mapHour[beginTime] = "";
337  mapHour[ptimetable_timeToStr(it->second.getEndTime())] = "";
338  PTimeTableBlock block(it->second);
339  block.setNbTimeRow(1lu);
340  out.mapBlock[beginTime] = block;
341  }
342 
343 }

References TexDay::date, TexDay::invitation, TexDay::mapBlock, ptimetable_timeToStr(), and PTimeTableBlock::setNbTimeRow().

Referenced by ptimetable_texSection().

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

◆ ptimetable_tex()

bool ptimetable_tex ( std::vector< PLatexObj > &  vecContent,
const PTimeTable timetable,
const PPath outputDirectory,
bool  isSaveSpeaker 
)

Convert a PTimeTable into PLatexObj.

Parameters
[out]vecContent: vector of PLatexObj to be completed with PTimeTable
timetable: PTimeTable to be converted into PLatexObj
outputDirectory: output directory of merge block
isSaveSpeaker: true if the speakers have to saved in latex
Returns
true on success, false otherwise

Definition at line 478 of file ptimetable_tex.cpp.

478  {
479  //Let's convert the PTimeTable into a more precise representation
480  TexTimetable texTimetable;
481  std::cerr << "ptimetable_tex : call ptimetable_createTexTimeTable" << std::endl;
482  ptimetable_createTexTimeTable(texTimetable, timetable);
483  //Add empty block to make days coherent
484  std::cerr << "ptimetable_tex : call ptimetable_completeEmptyBlock" << std::endl;
485  ptimetable_completeEmptyBlock(texTimetable);
486  //Update the size of the blocks in the timetable
487  std::cerr << "ptimetable_tex : call ptimetable_updateTimeRow" << std::endl;
488  ptimetable_updateTimeRow(texTimetable);
489  //Let's put all block in the vecContent
490  std::cerr << "ptimetable_tex : call ptimetable_toTex" << std::endl;
491  PLatexObj timetableObj;
492  ptimetable_toTex(timetableObj, texTimetable);
493  vecContent.push_back(platexobj_createSection(PLatexType::PART, timetable.getName(), "sec_"+timetable.getInvitation()));
494  if(texTimetable.invitation != ""){
495  vecContent.push_back(platexobj_createRendezVous(PPath(LATEX_INVITATION_OUTPUT_DIR "/" + texTimetable.invitation + ".ics")));
496  }
497  vecContent.push_back(timetableObj);
498  ptimetable_texPart(vecContent, texTimetable);
499  if(isSaveSpeaker){
500  pspeaker_tex(vecContent, timetable);
501  }
502  return ptimetable_createInvitationMergBlock(outputDirectory, texTimetable);
503 // return ptimetable_createInvitation(outputDirectory, texTimetable);
504 }
const PLatexObj & getName() const
Gets the name of the PTimeTable.
Definition: PTimeTable.cpp:845
PLatexObj platexobj_createSection(PLatexType::PLatexType sectionType, const PLatexObj &complexTitle, const PString &label)
Create a part, chapter, section, subsection, subsubsection.
void pspeaker_tex(std::vector< PLatexObj > &vecContent, const std::vector< PLatexSpeaker > &vecSpeaker, const PString &sectionLabel)
Save all speakers of the given PTimeTable into a vector of PLatexObj.
bool ptimetable_createInvitationMergBlock(const PPath &outputDirectory, const TexTimetable &timetable)
Create invitations but merge blocks with the same invitation.
void ptimetable_texPart(std::vector< PLatexObj > &vecContent, const TexTimetable &texTimetable)
Convert a PTimeTable into PLatexObj.
void ptimetable_updateTimeRow(TexTimetable &texTimetable)
Update the time rows of the PTimeTableBlock.
void ptimetable_toTex(PLatexObj &obj, const TexTimetable &texTimetable)
Convert a TexTimetable into a PLatexObj.
void ptimetable_completeEmptyBlock(TexTimetable &texTimetable)
Complete day of timetable with empty blocks to make them coherent.
void ptimetable_createTexTimeTable(TexTimetable &texTimetable, const PTimeTable &timetable)
Create the TexTimetable.
Full latex timetable.
Definition: TexTimetable.h:38

References PTimeTable::getInvitation(), PTimeTable::getName(), TexTimetable::invitation, LATEX_INVITATION_OUTPUT_DIR, PLatexType::PART, platexobj_createRendezVous(), platexobj_createSection(), pspeaker_tex(), ptimetable_completeEmptyBlock(), ptimetable_createInvitationMergBlock(), ptimetable_createTexTimeTable(), ptimetable_texPart(), ptimetable_toTex(), and ptimetable_updateTimeRow().

Referenced by PConfigParser::parseTimeTable().

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

◆ ptimetable_texChapter()

void ptimetable_texChapter ( std::vector< PLatexObj > &  vecContent,
const TexWeek week,
const TexTimetable texTimetable 
)

Convert a PTimeTable into PLatexObj.

Parameters
[out]vecContent: vector of PLatexObj to be completed with PTimeTable
week: TexWeek to be converted into PLatexObj
texTimetable: full timetable TexTimetable

Definition at line 435 of file ptimetable_tex.cpp.

435  {
436  if(week.weekTitle.getVecContent().size() != 0lu){
438  vecContent.push_back(chapterTitle);
439  }
440  if(week.invitation != ""){
441  vecContent.push_back(platexobj_createRendezVous(PPath(LATEX_INVITATION_OUTPUT_DIR "/" + week.invitation + ".ics")));
442  }
443  if(week.weekTitle.getVecContent().size() != 0lu){
444  //Now we create a TexTimetable with the current week
445  TexTimetable weekTimetable;
446  weekTimetable.invitation = texTimetable.invitation;
447  weekTimetable.vecWeek.push_back(week);
448  PLatexObj timetableObj;
449  ptimetable_toTex(timetableObj, weekTimetable);
450  vecContent.push_back(timetableObj);
451  }
452  const std::map<PString, TexDay> & mapDay = week.mapDay;
453  for(std::map<PString, TexDay>::const_iterator itDay(mapDay.begin()); itDay != mapDay.end(); ++itDay){
454  ptimetable_texSection(vecContent, itDay->second, texTimetable, week);
455  }
456 }
void ptimetable_texSection(std::vector< PLatexObj > &vecContent, const TexDay &day, const TexTimetable &texTimetable, const TexWeek &week)
Convert a PTimeTable into PLatexObj.
PLatexObj weekTitle
Title of the week.
Definition: TexTimetable.h:26
PString invitation
Invitation of the week.
Definition: TexTimetable.h:28

References PLatexType::CHAPTER, PLatexObj::getVecContent(), TexWeek::invitation, TexTimetable::invitation, LATEX_INVITATION_OUTPUT_DIR, TexWeek::mapDay, platexobj_createRendezVous(), platexobj_createSection(), ptimetable_texSection(), ptimetable_toTex(), TexTimetable::vecWeek, and TexWeek::weekTitle.

Referenced by ptimetable_texPart().

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

◆ ptimetable_texLecture()

void ptimetable_texLecture ( std::vector< PLatexObj > &  vecContent,
const PTimeTableBlock block,
const TexTimetable texTimetable 
)

Save lectures in PLatexObj.

Parameters
[out]vecContent: vector of PLatexObj to be completed with TexTimetable
block: PTimeTableBlock to be converted into PLatexObj
texTimetable: full timetable TexTimetable

Definition at line 350 of file ptimetable_tex.cpp.

350  {
351  if(block.getVecSpeaker().size() == 0lu){return;}
352  vecContent.push_back(platexobj_createSection(PLatexType::SUBSECTION, block.getTitle(), "sec_"+block.getInvitation()));
353  if(block.getInvitation() != ""){
354  vecContent.push_back(platexobj_createRendezVous(PPath(LATEX_INVITATION_OUTPUT_DIR "/" + block.getInvitation() + ".ics")));
355  }
356  vecContent.push_back(platexobj_createTextBf("Date", ""));
357  vecContent.push_back(platexobj_createText(" : "+ptimetable_dateToText(block.getDate()), ""));
358  vecContent.push_back(platexobj_createNewLine());
359  vecContent.push_back(platexobj_createTextBf("Location", ""));
360  vecContent.push_back(platexobj_createText(" : ", ""));
361  vecContent.push_back(block.getLocation());
362  vecContent.push_back(platexobj_createNewLine());
363  vecContent.push_back(platexobj_createTextBf("Start at", ""));
364  vecContent.push_back(platexobj_createText(" : "+ptimetable_timeToStr(block.getBeginTime()), ""));
365  vecContent.push_back(platexobj_createNewLine());
366  vecContent.push_back(platexobj_createTextBf("Stop at", ""));
367  vecContent.push_back(platexobj_createText(" : "+ptimetable_timeToStr(block.getEndTime()), ""));
368 
369 
370  vecContent.push_back(platexobj_createSection(PLatexType::SUBSUBSECTIONSTAR, platexobj_createText("Speakers",""), ""));
371  PLatexObj listSpeaker(platexobj_createItemize());
372  const std::vector<PString> & vecSpeaker = block.getVecSpeaker();
373  const std::map<PString, PLatexSpeaker> & mapSpeaker = texTimetable.mapSpeaker;
374  for(std::vector<PString>::const_iterator itSpeaker(vecSpeaker.begin()); itSpeaker != vecSpeaker.end(); ++itSpeaker){
375  std::map<PString, PLatexSpeaker>::const_iterator it(mapSpeaker.find(*itSpeaker));
376  if(it != mapSpeaker.end()){
377  const PLatexSpeaker & speaker = it->second;
378  listSpeaker.getVecContent().push_back(platexobj_createItem(platexobj_createRef("speaker_"+*itSpeaker, speaker.getName())));
379  }else{
380  std::cerr << "ptimetable_texLecture : speaker '"<<(*itSpeaker)<<"' not found in map of speakers" << std::endl;
381  }
382  }
383  vecContent.push_back(listSpeaker);
384  if(block.getDescription().getVecContent().size() != 0lu){
385  vecContent.push_back(platexobj_createSection(PLatexType::SUBSUBSECTIONSTAR, platexobj_createText("Description",""), ""));
386  vecContent.push_back(platexobj_createParagraph(block.getDescription(), ""));
387  }
388 }
Describe a speaker in a timetable.
Definition: PTimeTable.h:15
const PLatexObj & getName() const
Gets the name of the PLatexSpeaker.
Definition: PTimeTable.cpp:83
const PLatexObj & getDescription() const
Gets the description of the PTimeTableBlock.
Definition: PTimeTable.cpp:572
const PLatexObj & getLocation() const
Gets the location of the PTimeTableBlock.
Definition: PTimeTable.cpp:656
@ SUBSUBSECTIONSTAR
Definition: PLatexType.h:61
PLatexObj platexobj_createNewLine()
Create a new line.
PLatexObj platexobj_createText(const PString &text, const PString &label)
Create a TEXT.
PLatexObj platexobj_createItem(const PLatexObj &obj)
Create an ITEM.
PLatexObj platexobj_createParagraph(const PString &text, const PString &label)
Create a PARAGRAPH.
PLatexObj platexobj_createItemize()
Create an ITEMIZE.
PLatexObj platexobj_createTextBf(const PString &text, const PString &label)
Create a TEXT.
PString ptimetable_dateToText(const PLatexDate &date)
Convert a date into a string.

References PTimeTableBlock::getBeginTime(), PTimeTableBlock::getDate(), PTimeTableBlock::getDescription(), PTimeTableBlock::getEndTime(), PTimeTableBlock::getInvitation(), PTimeTableBlock::getLocation(), PLatexSpeaker::getName(), PTimeTableBlock::getTitle(), PLatexObj::getVecContent(), PTimeTableBlock::getVecSpeaker(), LATEX_INVITATION_OUTPUT_DIR, TexTimetable::mapSpeaker, platexobj_createItem(), platexobj_createItemize(), platexobj_createNewLine(), platexobj_createParagraph(), platexobj_createRef(), platexobj_createRendezVous(), platexobj_createSection(), platexobj_createText(), platexobj_createTextBf(), ptimetable_dateToText(), ptimetable_timeToStr(), PLatexType::SUBSECTION, and PLatexType::SUBSUBSECTIONSTAR.

Referenced by ptimetable_texSection().

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

◆ ptimetable_texPart()

void ptimetable_texPart ( std::vector< PLatexObj > &  vecContent,
const TexTimetable texTimetable 
)

Convert a PTimeTable into PLatexObj.

Parameters
[out]vecContent: vector of PLatexObj to be completed with PTimeTable
texTimetable: TexTimetable to be converted into PLatexObj

Definition at line 463 of file ptimetable_tex.cpp.

463  {
464  const std::vector<TexWeek> & vecWeek = texTimetable.vecWeek;
465  for(std::vector<TexWeek>::const_iterator itWeek(vecWeek.begin()); itWeek != vecWeek.end(); ++itWeek){
466  if(itWeek->mapDay.size() == 0lu){continue;}
467  ptimetable_texChapter(vecContent, *itWeek, texTimetable);
468  }
469 }
void ptimetable_texChapter(std::vector< PLatexObj > &vecContent, const TexWeek &week, const TexTimetable &texTimetable)
Convert a PTimeTable into PLatexObj.

References ptimetable_texChapter(), and TexTimetable::vecWeek.

Referenced by ptimetable_tex().

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

◆ ptimetable_texSection()

void ptimetable_texSection ( std::vector< PLatexObj > &  vecContent,
const TexDay day,
const TexTimetable texTimetable,
const TexWeek week 
)

Convert a PTimeTable into PLatexObj.

Parameters
[out]vecContent: vector of PLatexObj to be completed with PTimeTable
day: TexDay to be converted into PLatexObj
texTimetable: full timetable TexTimetable
week: current week of the day

Definition at line 396 of file ptimetable_tex.cpp.

398 {
400  vecContent.push_back(sectionTitle);
401  if(day.invitation != ""){
402  vecContent.push_back(platexobj_createRendezVous(PPath(LATEX_INVITATION_OUTPUT_DIR "/" + day.invitation + ".ics")));
403  }
404 
405  TexWeek weekTimeTable;
406  weekTimeTable.invitation = week.invitation;
407  weekTimeTable.weekTitle = week.weekTitle;
408 
409  TexDay outDay;
410  ptimetable_singleDay(outDay, weekTimeTable.mapHour, day);
411  weekTimeTable.mapDay[ptimetable_dateToStr(outDay.date)] = outDay;
412 
413  //Now we create a TexTimetable with the current day
414  TexTimetable dayTimetable;
415  dayTimetable.invitation = texTimetable.invitation;
416  dayTimetable.vecWeek.push_back(weekTimeTable);
417 
418  PLatexObj timetableObj;
419  ptimetable_toTex(timetableObj, dayTimetable);
420  vecContent.push_back(timetableObj);
421 
422  const std::map<PString, PTimeTableBlock> & mapBlock = day.mapBlock;
423  for(std::map<PString, PTimeTableBlock>::const_iterator it(mapBlock.begin()); it != mapBlock.end(); ++it){
424  if(it->second.getIsEmptyBlock()){continue;}
425  ptimetable_texLecture(vecContent, it->second, texTimetable);
426  }
427 }
void ptimetable_texLecture(std::vector< PLatexObj > &vecContent, const PTimeTableBlock &block, const TexTimetable &texTimetable)
Save lectures in PLatexObj.
void ptimetable_singleDay(TexDay &out, std::map< PString, PString > &mapHour, const TexDay &day)
Create a single day with consistent mapHour.

References TexDay::date, TexDay::invitation, TexWeek::invitation, TexTimetable::invitation, LATEX_INVITATION_OUTPUT_DIR, TexDay::mapBlock, TexWeek::mapDay, TexWeek::mapHour, platexobj_createRendezVous(), platexobj_createSection(), platexobj_createText(), ptimetable_dateToStr(), ptimetable_dateToText(), ptimetable_singleDay(), ptimetable_texLecture(), ptimetable_toTex(), PLatexType::SECTION, TexTimetable::vecWeek, and TexWeek::weekTitle.

Referenced by ptimetable_texChapter().

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

◆ ptimetable_timeToStr()

PString ptimetable_timeToStr ( const PLatexTime texTime)

Convert a PLatexTime into a string.

Parameters
texTime: PLatexTime to be converted in to a string
Returns
corresponding string (hour:minute)

Definition at line 37 of file ptimetable_tex.cpp.

37  {
38  std::stringstream timeStr;
39  timeStr << std::setfill('0') << std::setw(2) << texTime.getHour() << ":" << std::setfill('0') << std::setw(2) << texTime.getMinute();
40  return timeStr.str();
41 }
size_t getMinute() const
Gets the minute of the PLatexTime.
Definition: PTimeTable.cpp:343
size_t getHour() const
Gets the hour of the PLatexTime.
Definition: PTimeTable.cpp:329

References PLatexTime::getHour(), and PLatexTime::getMinute().

Referenced by ptimetable_addBlockInWeek(), ptimetable_compelteDayEmptyBlock(), ptimetable_singleDay(), ptimetable_texLecture(), and ptimetable_updateBlockTimeRow().

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

◆ ptimetable_toTex()

void ptimetable_toTex ( PLatexObj obj,
const TexTimetable texTimetable 
)

Convert a TexTimetable into a PLatexObj.

Parameters
[out]obj: PLatexObj from TexTimetable
texTimetable: TexTimetable

Definition at line 259 of file ptimetable_tex.cpp.

259  {
260  //std::vector<PString> vecDay{"Monday", "Tuesday", "Wednesday", "Thrusday", "Friday", "Saturday", "Sunday"};
262  obj.setLabelName(texTimetable.invitation);
263  const std::vector<TexWeek> & vecWeek = texTimetable.vecWeek;
264  for(std::vector<TexWeek>::const_iterator itWeek(vecWeek.begin()); itWeek != vecWeek.end(); ++itWeek){
265  if(itWeek->mapDay.size() == 0lu){continue;}
266  PLatexObj weekObj;
268  if(itWeek->invitation != ""){
269  weekObj.getComplexTitle().push_back(platexobj_createRendezVous(PPath(LATEX_INVITATION_OUTPUT_DIR "/" + itWeek->invitation + ".ics")));
270  weekObj.getComplexTitle().push_back(platexobj_createRef("sec_"+itWeek->invitation, itWeek->weekTitle));
271  weekObj.setLabelName(itWeek->invitation);
272  }
273 
274  const std::map<PString, PString> & mapHour = itWeek->mapHour;
275  const std::map<PString, TexDay> & mapDay = itWeek->mapDay;
276  //Header of the week (days)
278  weekRowHeader.getVecContent().push_back(platexobj_createTimetableBlock("timetableDayStyle", platexobj_createText("Period/Day")));
279 
280  for(std::map<PString, TexDay>::const_iterator itDay(mapDay.begin()); itDay != mapDay.end(); ++itDay){
281  const PLatexDate & date = itDay->second.date;
282  std::stringstream dateStr;
283  dateStr << std::setfill('0') << std::setw(2) << date.getDay() << "/" << std::setfill('0') << std::setw(2) << date.getMonth() << "/" << date.getYear();
284 
285  PLatexObj contentBlock(platexobj_createNone());
286  if(itDay->second.invitation != ""){
287  contentBlock.getVecContent().push_back(platexobj_createRendezVous(PPath(LATEX_INVITATION_OUTPUT_DIR "/" + itDay->second.invitation + ".ics")));
288  contentBlock.getVecContent().push_back(platexobj_createRef("sec_" + itDay->second.invitation, dateStr.str()));
289  }
290 
291  PLatexObj refTimetableBlock(platexobj_createTimetableBlock("timetableDayStyle", contentBlock));
292  weekRowHeader.getVecContent().push_back(refTimetableBlock);
293  }
294  weekObj.getVecContent().push_back(weekRowHeader);
295 
296  //Timetable with hours
297  for(std::map<PString, PString>::const_iterator itHour(mapHour.begin()); itHour != mapHour.end(); ++itHour){
298  PLatexObj timeRowObj;
300 
301  PLatexObj textTime;
302  textTime.setText(itHour->first);
304  timeRowObj.getVecContent().push_back(textTime);
305 
306  size_t i(0lu);
307  for(std::map<PString, TexDay>::const_iterator itDay(mapDay.begin()); itDay != mapDay.end(); ++itDay){
308  //For each day we have to find which block starts at the given hour time
309  const std::map<PString, PTimeTableBlock> & mapBlock = itDay->second.mapBlock;
310  std::map<PString, PTimeTableBlock>::const_iterator itBlock(mapBlock.find(itHour->first));
311  if(itBlock != mapBlock.end()){ //We found a corresponding block
312  PLatexObj blockObj;
313  ptimetable_blockToTex(blockObj, itBlock->second);
314  timeRowObj.getVecContent().push_back(blockObj);
315  }
316  ++i;
317  }
318  weekObj.getVecContent().push_back(timeRowObj);
319  }
320  obj.getVecContent().push_back(weekObj);
321  }
322 }
Describes a date.
Definition: PTimeTable.h:58
void setLabelName(const PString &labelName)
Sets the labelName of the PLatexObj.
Definition: PLatexObj.cpp:158
const std::vector< PLatexObj > & getComplexTitle() const
Gets the complexTitle of the PLatexObj.
Definition: PLatexObj.cpp:396
@ TIMETABLE_TIME
Definition: PLatexType.h:104
@ TIMETABLE_WEEK
Definition: PLatexType.h:99
@ TIMETABLE_TIMEROW
Definition: PLatexType.h:100
PLatexObj platexobj_createTimetableBlock(const PString &blockStyle)
Create a TIMETABLE_BLOCK.
PLatexObj platexobj_createNone()
Create a NONE PLatexObj.
PLatexObj platexobj_createTimetableTimeRow()
Create an TIMETABLE_TIMEROW.
void ptimetable_blockToTex(PLatexObj &obj, const PTimeTableBlock &block)
Convert a PTimeTableBlock into PLatexObj.

References PLatexObj::getComplexTitle(), PLatexDate::getDay(), PLatexDate::getMonth(), PLatexObj::getVecContent(), PLatexDate::getYear(), TexTimetable::invitation, LATEX_INVITATION_OUTPUT_DIR, platexobj_createNone(), platexobj_createRef(), platexobj_createRendezVous(), platexobj_createText(), platexobj_createTimetableBlock(), platexobj_createTimetableTimeRow(), ptimetable_blockToTex(), PLatexObj::setLabelName(), PLatexObj::setText(), PLatexObj::setType(), PLatexType::TIMETABLE, PLatexType::TIMETABLE_TIME, PLatexType::TIMETABLE_TIMEROW, PLatexType::TIMETABLE_WEEK, and TexTimetable::vecWeek.

Referenced by ptimetable_tex(), ptimetable_texChapter(), and ptimetable_texSection().

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

◆ ptimetable_updateBlockTimeRow()

void ptimetable_updateBlockTimeRow ( PTimeTableBlock block,
const std::map< PString, PString > &  mapHour 
)

Update the time rows of the PTimeTableBlock.

Parameters
[out]block: PTimeTableBlock to be updated
mapHour: map of all the begining hours in the week

Definition at line 181 of file ptimetable_tex.cpp.

181  {
182  PString beginTime(ptimetable_timeToStr(block.getBeginTime()));
183  PString endTime(ptimetable_timeToStr(block.getEndTime()));
184 
185  std::map<PString, PString>::const_iterator itBeginTime = mapHour.find(beginTime);
186  std::map<PString, PString>::const_iterator itEndTime = mapHour.find(endTime);
187  if(itBeginTime != mapHour.end() && itEndTime != mapHour.end()){
188  size_t nbHourBlock(0lu);
189  for(std::map<PString, PString>::const_iterator it(itBeginTime); it != itEndTime && it != mapHour.end(); ++it){
190  ++nbHourBlock;
191  }
192  block.setNbTimeRow(nbHourBlock);
193  }
194 }
void setNbTimeRow(size_t nbTimeRow)
Sets the nbTimeRow of the PTimeTableBlock.
Definition: PTimeTable.cpp:488

References PTimeTableBlock::getBeginTime(), PTimeTableBlock::getEndTime(), ptimetable_timeToStr(), and PTimeTableBlock::setNbTimeRow().

Referenced by ptimetable_updateTimeRow().

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

◆ ptimetable_updateTimeRow()

void ptimetable_updateTimeRow ( TexTimetable texTimetable)

Update the time rows of the PTimeTableBlock.

Parameters
[out]texTimetable: TexTimetable to be updated

Definition at line 199 of file ptimetable_tex.cpp.

199  {
200  //Let's iterate over weeks
201  std::vector<TexWeek> & vecWeek = texTimetable.vecWeek;
202  for(std::vector<TexWeek>::iterator itWeek(vecWeek.begin()); itWeek != vecWeek.end(); ++itWeek){
203  //Let's iterate over days
204  std::map<PString, TexDay> & mapDay = itWeek->mapDay;
205  std::map<PString, PString> & mapHour = itWeek->mapHour;
206  for(std::map<PString, TexDay>::iterator itDay(mapDay.begin()); itDay != mapDay.end(); ++itDay){
207  //Let's iterate over blocks
208  std::map<PString, PTimeTableBlock> & mapBlock = itDay->second.mapBlock;
209  for(std::map<PString, PTimeTableBlock>::iterator itBlock(mapBlock.begin()); itBlock != mapBlock.end(); ++itBlock){
210  ptimetable_updateBlockTimeRow(itBlock->second, mapHour);
211  }
212  }
213  }
214 }
void ptimetable_updateBlockTimeRow(PTimeTableBlock &block, const std::map< PString, PString > &mapHour)
Update the time rows of the PTimeTableBlock.

References ptimetable_updateBlockTimeRow(), and TexTimetable::vecWeek.

Referenced by ptimetable_tex().

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

◆ ptimetable_updateWeekLaterTime()

void ptimetable_updateWeekLaterTime ( TexWeek week,
const PLatexTime texTime 
)

Update the later time of the week.

Parameters
[out]week: TexWeek to be udpated
texTime: PLatexTime

Definition at line 47 of file ptimetable_tex.cpp.

47  {
48  PLatexTime & laterTime = week.laterTime;
49  if(laterTime.getHour() < texTime.getHour()){
50  laterTime = texTime;
51  }else if(laterTime.getHour() == texTime.getHour()){
52  if(laterTime.getMinute() < texTime.getMinute()){
53  laterTime = texTime;
54  }
55  }
56 }
Describes a date.
Definition: PTimeTable.h:86

References PLatexTime::getHour(), PLatexTime::getMinute(), and TexWeek::laterTime.

Referenced by ptimetable_addBlockInWeek().

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