CmdReportDay: Made interval rendering configurable

This commit is contained in:
Paul Beckingham 2016-04-29 21:15:21 -04:00
parent 018179c5dd
commit 93e0acec21

View file

@ -36,9 +36,9 @@
#include <iostream> #include <iostream>
static void renderExclusionBlocks (Composite&, Composite&, const Datetime&, int, int, const std::vector <Range>&, Color&); static void renderExclusionBlocks (Composite&, Composite&, const Datetime&, int, int, const std::vector <Range>&, Color&);
static void renderInterval (Composite&, Composite&, const Datetime&, const Interval&, int, Palette&, std::map <std::string, Color>&);
static void renderSummary (const std::string&); static void renderSummary (const std::string&);
static void renderAxis (const Rules&, Palette&, const std::string&, int, int); static void renderAxis (const Rules&, Palette&, const std::string&, int, int);
static void renderInterval (const Rules&, Composite&, Composite&, const Datetime&, const Interval&, int, Palette&, std::map <std::string, Color>&);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdReportDay ( int CmdReportDay (
@ -102,7 +102,7 @@ int CmdReportDay (
renderExclusionBlocks (line1, line2, day, first_hour, last_hour, exclusions, colorExc); renderExclusionBlocks (line1, line2, day, first_hour, last_hour, exclusions, colorExc);
for (auto& track : tracked) for (auto& track : tracked)
renderInterval (line1, line2, day, track, first_hour, palette, tag_colors); renderInterval (rules, line1, line2, day, track, first_hour, palette, tag_colors);
std::cout << indent << line1.str () << '\n' std::cout << indent << line1.str () << '\n'
<< indent << line2.str () << '\n' << indent << line2.str () << '\n'
@ -169,6 +169,7 @@ static void renderExclusionBlocks (
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static void renderInterval ( static void renderInterval (
const Rules& rules,
Composite& line1, Composite& line1,
Composite& line2, Composite& line2,
const Datetime& day, const Datetime& day,
@ -177,6 +178,8 @@ static void renderInterval (
Palette& palette, Palette& palette,
std::map <std::string, Color>& tag_colors) std::map <std::string, Color>& tag_colors)
{ {
auto spacing = rules.getInteger ("report.day.spacing");
// Make sure the track only represents one day. // Make sure the track only represents one day.
Datetime eod {day}; Datetime eod {day};
eod++; eod++;
@ -184,20 +187,16 @@ static void renderInterval (
Interval clipped = clip (track, day_range); Interval clipped = clip (track, day_range);
// TODO track may have started days ago. // TODO track may have started days ago.
// std::cout << "# track " << track.dump () << "\n";
auto start_hour = clipped.range.start.hour (); auto start_hour = clipped.range.start.hour ();
auto start_min = clipped.range.start.minute (); auto start_min = clipped.range.start.minute ();
auto end_hour = clipped.range.end.hour (); auto end_hour = clipped.range.end.hour ();
auto end_min = clipped.range.end.minute (); auto end_min = clipped.range.end.minute ();
// std::cout << "# " << start_hour << "/" << start_min << " - " << end_hour << "/" << end_min << "\n";
auto start_block = quantizeTo15Minutes (start_min) / 15; auto start_block = quantizeTo15Minutes (start_min) / 15;
auto end_block = quantizeTo15Minutes (end_min == 0 ? 60 : end_min) / 15; auto end_block = quantizeTo15Minutes (end_min == 0 ? 60 : end_min) / 15;
// std::cout << "# blocks " << start_block << " - " << end_block << "\n";
int start_offset = (start_hour - first_hour) * 5 + start_block; int start_offset = (start_hour - first_hour) * (4 + spacing) + start_block;
int end_offset = (end_hour - 1 - first_hour) * 5 + end_block; int end_offset = (end_hour - 1 - first_hour) * (4 + spacing) + end_block;
// std::cout << "# offset " << start_offset << " - " << end_offset << "\n";
if (end_offset > start_offset) if (end_offset > start_offset)
{ {