Report layout cleanup

This commit is contained in:
Mark Watkins 2011-12-14 16:39:03 +10:00
parent 2184da591a
commit f186771c21
3 changed files with 44 additions and 88 deletions

View File

@ -1641,49 +1641,57 @@ short gGraph::marginRight() { return m_marginright; } //*m_graphview->printScale
short gGraph::marginTop() { return m_margintop; } //*m_graphview->printScaleY(); }
short gGraph::marginBottom() { return m_marginbottom; } //*m_graphview->printScaleY(); }
QPixmap gGraph::renderPixmap(int w, int h)
QPixmap gGraph::renderPixmap(int w, int h, float scale)
{
gGraphView *sg=mainwin->snapshotGraph();
if (!sg) return QPixmap();
//double scale=sg->printScaleY(); //sqrt(sg->printScaleX()*sg->printScaleX()+sg->printScaleY()*sg->printScaleY());
/*
QFont * _defaultfont=defaultfont;
QFont * _mediumfont=mediumfont;
QFont * _bigfont=bigfont;
QFont fa=*defaultfont;
QFont fb=*mediumfont;
QFont fc=*bigfont;
sg->setPrintScaleX(scale);
sg->setPrintScaleY(scale);
fa.setPointSize(fa.pointSize()*scale);
fb.setPointSize(fb.pointSize()*scale);
fc.setPointSize(fc.pointSize()*scale);
defaultfont=&fa;
mediumfont=&fb;
bigfont=&fc; */
bigfont=&fc;
sg->hideSplitter();
gGraphView *tgv=m_graphview;
m_graphview=sg;
//qint64 rmx=rmin_x,rMx=rmax_x;
//qint64 mx=min_x, Mx=max_x;
sg->setMinimumSize(w,h);
sg->setMaximumSize(w,h);
sg->setFixedSize(w,h);
float tmp=m_height;
m_height=PROFILE["GraphHeight"].toInt();//*sg->printScaleY();
m_height=h; //PROFILE["GraphHeight"].toInt();//*sg->printScaleY();
sg->trashGraphs();
sg->addGraph(this);
//sg->ResetBounds();
//sg->SetXBounds(mx,Mx);
//sg->updateScrollBar();
sg->updateScale();
//sg->updateScale();
sg->setScaleY(1.0);
//QImage image=sg->grabFrameBuffer();
//QPixmap pm=QPixmap::fromImage(image);
QPixmap pm=sg->renderPixmap(w,h,false);
sg->trashGraphs();
m_graphview=tgv;
m_height=tmp;
/*
defaultfont=_defaultfont;
mediumfont=_mediumfont;
bigfont=_bigfont; */
bigfont=_bigfont;
return pm;
}

View File

@ -277,7 +277,7 @@ public:
virtual ~gGraph();
void deselect();
void Trigger(int ms);
QPixmap renderPixmap(int width, int height);
QPixmap renderPixmap(int width, int height, float fontscale=1.0);
void setVisible(bool b) { m_visible=b; }
bool visible() { return m_visible; }
@ -422,6 +422,7 @@ public:
float findTop(gGraph * graph);
float scaleY() { return m_scaleY; }
void setScaleY(float sy) { m_scaleY=sy; }
void GetXBounds(qint64 & st,qint64 & et);
void ResetBounds(bool refresh=true); //short group=0);

View File

@ -209,8 +209,8 @@ void MainWindow::Startup()
PROFILE.LoadMachineData();
SnapshotGraph=new gGraphView(this); //daily->graphView());
SnapshotGraph->setMaximumSize(1024,512);
SnapshotGraph->setMinimumSize(1024,512);
//SnapshotGraph->setMaximumSize(1024,512);
//SnapshotGraph->setMinimumSize(1024,512);
SnapshotGraph->hide();
daily=new Daily(ui->tabWidget,NULL,this);
@ -869,50 +869,24 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
float lki=cpap->count(CPAP_LeakFlag)/cpap->hours();
float exp=cpap->count(CPAP_ExP)/cpap->hours();
int piesize=1.5*72.0*vscale;
float fscale=font_scale;
if (!highres)
fscale=1;
QString stats;
painter.setFont(*mediumfont);
stats="AHI\t"+QString::number(ahi,'f',2)+"\n";
QRectF bounds=painter.boundingRect(QRectF(0,0,res.width(),0),stats,QTextOption(Qt::AlignRight));
painter.drawText(bounds,stats,QTextOption(Qt::AlignRight));
//if (bounds.height()>maxy) maxy=bounds.height();
getDaily()->eventBreakdownPie()->showTitle(false);
int piesize=1.5*72.0*vscale;
mainwin->snapshotGraph()->setMinimumSize(piesize,piesize);
mainwin->snapshotGraph()->setMaximumSize(piesize,piesize);
QFont * _defaultfont=defaultfont;
QFont * _mediumfont=mediumfont;
QFont * _bigfont=bigfont;
QFont fa=*defaultfont;
QFont fb=*mediumfont;
QFont fc=*bigfont;
if (!no_scaling ) {
// fa.setPointSizeF((fa.pointSizeF()/graph_xscale)*2);
// fb.setPointSizeF((fb.pointSizeF()/graph_xscale)*2);
// fc.setPointSizeF((fc.pointSizeF()/graph_xscale)*2);
qDebug() << QApplication::desktop()->physicalDpiX();
fa.setPointSizeF(fa.pointSizeF()*font_scale);
fb.setPointSizeF(fb.pointSizeF()*font_scale);
fc.setPointSizeF(fc.pointSizeF()*font_scale);
}
defaultfont=&fa;
mediumfont=&fb;
bigfont=&fc;
QPixmap ebp=getDaily()->eventBreakdownPie()->renderPixmap(piesize,piesize);
defaultfont=_defaultfont;
mediumfont=_mediumfont;
bigfont=_bigfont;
getDaily()->eventBreakdownPie()->setMargins(0,0,0,0);
QPixmap ebp=getDaily()->eventBreakdownPie()->renderPixmap(piesize,piesize,fscale);
painter.drawPixmap(res.width()-piesize,bounds.height(),piesize,piesize,ebp);
getDaily()->eventBreakdownPie()->showTitle(true);
cpapinfo+="\n\n";
painter.setFont(*defaultfont);
@ -967,9 +941,6 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
}
top+=maxy;
mainwin->snapshotGraph()->setMinimumSize(gw,gh);
mainwin->snapshotGraph()->setMaximumSize(gw,gh);
bool first=true;
QStringList labels;
QVector<gGraph *> graphs;
@ -1062,49 +1033,25 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
PROFILE["UseAntiAliasing"]=force_antialiasing;
int tmb=g->m_marginbottom;
g->m_marginbottom=0;
float fscale=font_scale*graph_xscale;
if (!no_scaling ) {
SnapshotGraph->setPrintScaleX(fscale);
SnapshotGraph->setPrintScaleY(fscale);
}
QFont * _defaultfont=defaultfont;
QFont * _mediumfont=mediumfont;
QFont * _bigfont=bigfont;
QFont fa=*defaultfont;
QFont fb=*mediumfont;
QFont fc=*bigfont;
if (!no_scaling ) {
fa.setPointSizeF(fa.pointSizeF()*fscale);
fb.setPointSizeF(fb.pointSizeF()*fscale);
fc.setPointSizeF(fc.pointSizeF()*fscale);
}
defaultfont=&fa;
mediumfont=&fb;
bigfont=&fc;
float fscale=1;
if (!no_scaling) fscale=font_scale*graph_xscale;
//g->showTitle(false);
QPixmap pm=g->renderPixmap(gw,gh);
QPixmap pm=g->renderPixmap(gw,gh,fscale);
//g->showTitle(true);
defaultfont=_defaultfont;
mediumfont=_mediumfont;
bigfont=_bigfont;
g->m_marginbottom=tmb;
PROFILE["UseAntiAliasing"]=aa_setting;
QPixmap pm2;
if (!no_scaling) {
QPixmap pm2=pm.scaledToWidth(printer_width);
painter.drawPixmap(0,top,pm2.width(),pm2.height(),pm2);
top+=pm2.height();
pm2=pm.scaledToWidth(printer_width);
} else {
painter.drawPixmap(0,top,pm.width(),pm.height(),pm);
top+=gh;
pm2=pm;
}
painter.drawPixmap(0,top,pm2.width(),pm2.height(),pm2);
top+=pm2.height();
gcnt++;
if (qprogress) {
qprogress->setValue(i);