From 48df9c2f46dd27f65cf0afad07fbb6b363bc2c27 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Fri, 29 Aug 2014 01:11:34 +1000 Subject: [PATCH] Stop print daily report screwing up selections --- sleepyhead/Graphs/gGraph.cpp | 2 +- sleepyhead/reports.cpp | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/sleepyhead/Graphs/gGraph.cpp b/sleepyhead/Graphs/gGraph.cpp index 00039d2b..92b111ba 100644 --- a/sleepyhead/Graphs/gGraph.cpp +++ b/sleepyhead/Graphs/gGraph.cpp @@ -320,7 +320,7 @@ void gGraph::paint(QPainter &painter, const QRegion ®ion) if (m_snapshot) { QLinearGradient linearGrad(QPointF(100, 100), QPointF(width / 2, 100)); - linearGrad.setColorAt(0, QColor(255, 150, 150,50)); + linearGrad.setColorAt(0, QColor(255, 150, 150,40)); linearGrad.setColorAt(1, QColor(255,255,255,20)); painter.fillRect(m_rect, QBrush(linearGrad)); diff --git a/sleepyhead/reports.cpp b/sleepyhead/reports.cpp index 756c9db0..71c3178d 100644 --- a/sleepyhead/reports.cpp +++ b/sleepyhead/reports.cpp @@ -407,10 +407,22 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date) QVector start, end; qint64 savest, saveet; + gGraph *g; + gv->GetXBounds(savest, saveet); + + for (int i=0;i < gv->size(); i++) { + g = (*gv)[i]; + + if (g->isEmpty() || !g->visible()) continue; + if (g->group() == 0) { + savest = g->min_x; + saveet = g->max_x; + break; + } + } qint64 st = savest, et = saveet; - gGraph *g; if (name == STR_TR_Daily) { if (!print_bookmarks) { @@ -429,21 +441,21 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date) et = day->last(MT_OXIMETER); } - if (g->name() == schema::channel[CPAP_FlowRate].code()) { - if (!((qAbs(savest - st) < 2000) && (qAbs(saveet - et) < 2000))) { + if (!g->isSnapshot() && (g->name() == schema::channel[CPAP_FlowRate].code())) { + if (!((qAbs(g->min_x - st) < 2000) && (qAbs(g->max_x - et) < 2000))) { start.push_back(st); end.push_back(et); graphs.push_back(g); labels.push_back(QObject::tr("Entire Day's Flow Waveform")); } - start.push_back(savest); - end.push_back(saveet); + start.push_back(g->min_x); + end.push_back(g->max_x); graphs.push_back(g); labels.push_back(QObject::tr("Current Selection")); } else { - start.push_back(savest); - end.push_back(saveet); + start.push_back(g->min_x); + end.push_back(g->max_x); graphs.push_back(g); labels.push_back(""); }