mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-06 03:00:43 +00:00
Fix font scaling issue
This commit is contained in:
parent
6e07522dbe
commit
42fcd0a389
@ -953,6 +953,7 @@ gGraph::gGraph(gGraphView *graphview,QString title,QString units, int height,sho
|
||||
f_miny=f_maxy=0;
|
||||
m_enforceMinY=m_enforceMaxY=false;
|
||||
rec_miny=rec_maxy=0;
|
||||
m_showTitle=true;
|
||||
}
|
||||
gGraph::~gGraph()
|
||||
{
|
||||
@ -996,6 +997,12 @@ bool gGraph::isEmpty()
|
||||
}
|
||||
return empty;
|
||||
}
|
||||
|
||||
void gGraph::showTitle(bool b)
|
||||
{
|
||||
m_showTitle=b;
|
||||
}
|
||||
|
||||
float gGraph::printScaleX() { return m_graphview->printScaleX(); }
|
||||
float gGraph::printScaleY() { return m_graphview->printScaleY(); }
|
||||
|
||||
@ -1017,43 +1024,6 @@ void gGraph::setDay(Day * day)
|
||||
ResetBounds();
|
||||
}
|
||||
|
||||
/*void gGraph::invalidate()
|
||||
{ // this may not be necessary, as scrollbar & resize issues a full redraw..
|
||||
|
||||
//m_lastbounds.setWidth(m_graphview->width());
|
||||
m_lastbounds.setY(m_graphview->findTop(this));
|
||||
m_lastbounds.setX(gGraphView::titleWidth);
|
||||
m_lastbounds.setHeight(m_height * m_graphview->scaleY());
|
||||
m_lastbounds.setWidth(m_graphview->width()-gGraphView::titleWidth);
|
||||
int i=0;
|
||||
//m_lastbounds.setHeight(0);
|
||||
}
|
||||
|
||||
void gGraph::repaint()
|
||||
{
|
||||
if (m_lastbounds.height()>0) {
|
||||
//glScissor(0,m_lastbounds.y(),m_lastbounds.width(),m_lastbounds.height());
|
||||
// m_graphview->swapBuffers(); // how fast is this??
|
||||
//glEnable(GL_SCISSOR_BOX);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glColor4f(1,1,1,1.0); // Gradient End
|
||||
glVertex2i(0,m_lastbounds.y());
|
||||
glVertex2i(gGraphView::titleWidth,m_lastbounds.y());
|
||||
glVertex2i(gGraphView::titleWidth,m_lastbounds.y()+height());
|
||||
glVertex2i(0,m_lastbounds.y()+height());
|
||||
glEnd();
|
||||
|
||||
paint(m_lastbounds.x(),m_lastbounds.y(),m_lastbounds.width(),m_lastbounds.height());
|
||||
m_graphview->swapBuffers();
|
||||
//glDisable(GL_SCISSOR_BOX);
|
||||
} else {
|
||||
qDebug() << "Wanted to redraw graph" << m_title << "but previous bounds were invalid.. Issuing a slower full redraw instead. Todo: Find out why.";
|
||||
m_graphview->updateGL();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void gGraph::qglColor(QColor col)
|
||||
{
|
||||
m_graphview->qglColor(col);
|
||||
@ -1087,11 +1057,13 @@ void gGraph::paint(int originX, int originY, int width, int height)
|
||||
|
||||
//glColor4f(0,0,0,1);
|
||||
left=marginLeft(),right=marginRight(),top=marginTop(),bottom=marginBottom();
|
||||
int x,y;
|
||||
GetTextExtent(title(),x,y,mediumfont);
|
||||
int title_x=(float(y)*2);
|
||||
renderText(title(),marginLeft()+title_x,originY+height/2,90,Qt::black,mediumfont);
|
||||
left+=title_x;
|
||||
int x=0,y=0;
|
||||
if (m_showTitle) {
|
||||
GetTextExtent(title(),x,y,mediumfont);
|
||||
int title_x=(float(y)*2);
|
||||
renderText(title(),marginLeft()+title_x,originY+height/2,90,Qt::black,mediumfont);
|
||||
left+=title_x;
|
||||
} else left=0;
|
||||
|
||||
//#define DEBUG_LAYOUT
|
||||
#ifdef DEBUG_LAYOUT
|
||||
@ -1113,6 +1085,7 @@ void gGraph::paint(int originX, int originY, int width, int height)
|
||||
|
||||
for (int i=0;i<m_layers.size();i++) {
|
||||
Layer *ll=m_layers[i];
|
||||
if (!ll->visible()) continue;
|
||||
tmp=ll->Height()*m_graphview->printScaleY();
|
||||
if (ll->position()==LayerTop) top+=tmp;
|
||||
if (ll->position()==LayerBottom) bottom+=tmp;
|
||||
@ -1120,6 +1093,7 @@ void gGraph::paint(int originX, int originY, int width, int height)
|
||||
|
||||
for (int i=0;i<m_layers.size();i++) {
|
||||
Layer *ll=m_layers[i];
|
||||
if (!ll->visible()) continue;
|
||||
tmp=ll->Width()*m_graphview->printScaleX();
|
||||
if (ll->position()==LayerLeft) {
|
||||
ll->paint(*this,originX+left,originY+top,tmp,height-top-bottom);
|
||||
@ -1140,6 +1114,7 @@ void gGraph::paint(int originX, int originY, int width, int height)
|
||||
bottom=marginBottom(); top=marginTop();
|
||||
for (int i=0;i<m_layers.size();i++) {
|
||||
Layer *ll=m_layers[i];
|
||||
if (!ll->visible()) continue;
|
||||
tmp=ll->Height()*m_graphview->printScaleY();
|
||||
if (ll->position()==LayerTop) {
|
||||
ll->paint(*this,originX+left,originY+top,width-left-right,tmp);
|
||||
@ -1153,6 +1128,7 @@ void gGraph::paint(int originX, int originY, int width, int height)
|
||||
|
||||
for (int i=0;i<m_layers.size();i++) {
|
||||
Layer *ll=m_layers[i];
|
||||
if (!ll->visible()) continue;
|
||||
if (ll->position()==LayerCenter) {
|
||||
ll->paint(*this,originX+left,originY+top,width-left-right,height-top-bottom);
|
||||
}
|
||||
|
@ -291,6 +291,8 @@ public:
|
||||
int maxHeight() { return m_max_height; }
|
||||
void setMaxHeight(int height) { m_max_height=height; }
|
||||
|
||||
void showTitle(bool b);
|
||||
|
||||
float printScaleX();
|
||||
float printScaleY();
|
||||
bool isEmpty();
|
||||
@ -399,6 +401,7 @@ protected:
|
||||
Day * m_day;
|
||||
GLBuffer * m_quad;
|
||||
bool m_enforceMinY,m_enforceMaxY;
|
||||
bool m_showTitle;
|
||||
signals:
|
||||
|
||||
protected slots:
|
||||
|
@ -494,11 +494,10 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
|
||||
int x,y;
|
||||
|
||||
for (int j=0;j<m_codes.size();j++) {
|
||||
//if (totalcounts[j]==0) continue;
|
||||
if (!m_goodcodes[j]) continue;
|
||||
ChannelID code=m_codes[j];
|
||||
a=schema::channel[code].label();
|
||||
a+=" ";
|
||||
a="";
|
||||
a+=schema::channel[code].label()+" ";
|
||||
switch(m_type[j]) {
|
||||
case ST_WAVG: a+="Avg"; break;
|
||||
case ST_AVG: a+="Avg"; break;
|
||||
@ -531,9 +530,10 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
|
||||
}
|
||||
a+="="+val;
|
||||
GetTextExtent(a,x,y);
|
||||
px-=20+x;
|
||||
w.renderText(a,px+20,py+1);
|
||||
quads->add(px+5,py-7,px+18,py-7,px+18,py+1,px+5,py+1,m_colors[j]);
|
||||
float wt=20*w.printScaleX();
|
||||
px-=wt+x;
|
||||
w.renderText(a,px+wt,py+1);
|
||||
quads->add(px+wt-y/4-y,py-y,px+wt-y/4,py-y,px+wt-y/4,py+1,px+wt-y/4-y,py+1,m_colors[j]);
|
||||
//lines->add(px,py,px+20,py,m_colors[j]);
|
||||
//lines->add(px,py+1,px+20,py+1,m_colors[j]);
|
||||
}
|
||||
|
2
daily.h
2
daily.h
@ -49,7 +49,7 @@ public:
|
||||
void UnitsChanged();
|
||||
Session * GetJournalSession(QDate date);
|
||||
QString GetDetailsText();
|
||||
|
||||
gGraph * eventBreakdownPie() { return GAHI; }
|
||||
private slots:
|
||||
|
||||
void on_calendar_currentPageChanged(int year, int month);
|
||||
|
110
mainwindow.cpp
110
mainwindow.cpp
@ -711,12 +711,12 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
bool highres;
|
||||
bool aa_setting=PROFILE.ExistsAndTrue("UseAntiAliasing");
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
/*#ifdef Q_WS_MAC
|
||||
PROFILE["HighResPrinting"]=true; // forced on
|
||||
bool force_antialiasing=true;
|
||||
#else
|
||||
#else */
|
||||
bool force_antialiasing=PROFILE.ExistsAndTrue("UseAntiAliasing");
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
if (PROFILE.ExistsAndTrue("HighResPrinting")) {
|
||||
printer=new QPrinter(QPrinter::HighResolution);
|
||||
@ -754,7 +754,7 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
|
||||
QSizeF pres=printer->paperSize(QPrinter::Point);
|
||||
QSizeF pxres=printer->paperSize(QPrinter::DevicePixel);
|
||||
//float hscale=pxres.width()/pres.width();
|
||||
float hscale=pxres.width()/pres.width();
|
||||
float vscale=pxres.height()/pres.height();
|
||||
|
||||
QFontMetrics fm(*bigfont);
|
||||
@ -765,6 +765,8 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
//QRect screen=QApplication::desktop()->screenGeometry();
|
||||
QRect res=printer->pageRect();
|
||||
|
||||
qDebug() << "X" << printer->logicalDpiX() << printer->physicalDpiX();
|
||||
qDebug() << "Y" << printer->logicalDpiY() << printer->physicalDpiY();
|
||||
qDebug() << "Printer Resolution is" << res.width() << "x" << res.height();
|
||||
|
||||
qDebug() << "res:" << printer->resolution() << "dpi" << float(res.width()) / float(res.height());
|
||||
@ -788,9 +790,6 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
//float scalex=1.0/graph_xscale;
|
||||
float gh=full_graph_height*graph_xscale;
|
||||
|
||||
mainwin->snapshotGraph()->setMinimumSize(gw,gh);
|
||||
mainwin->snapshotGraph()->setMaximumSize(gw,gh);
|
||||
|
||||
QString title=name+" Report";
|
||||
painter.setFont(*bigfont);
|
||||
int top=0;
|
||||
@ -798,6 +797,7 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
painter.drawText(bounds,title,QTextOption(Qt::AlignHCenter | Qt::AlignTop));
|
||||
top+=bounds.height();
|
||||
painter.setFont(*defaultfont);
|
||||
float font_scale=float(printer->physicalDpiX())/float(QApplication::desktop()->physicalDpiX());
|
||||
|
||||
int maxy=0;
|
||||
if (!PROFILE["FirstName"].toString().isEmpty()) {
|
||||
@ -853,26 +853,70 @@ 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();
|
||||
|
||||
QString stats;
|
||||
stats="AHI\t"+QString::number(ahi,'f',2)+"\n";
|
||||
stats+="AI \t"+QString::number(oai,'f',2)+"\n";
|
||||
stats+="HI \t"+QString::number(hi,'f',2)+"\n";
|
||||
stats+="CAI\t"+QString::number(cai,'f',2)+"\n";
|
||||
if (cpap->machine->GetClass()=="PRS1") {
|
||||
stats+="REI\t"+QString::number(rei,'f',2)+"\n";
|
||||
stats+="VSI\t"+QString::number(vsi,'f',2)+"\n";
|
||||
stats+="FLI\t"+QString::number(fli,'f',2)+"\n";
|
||||
stats+="PB/CSR\t"+QString::number(csr,'f',2)+"%\n";
|
||||
} else if (cpap->machine->GetClass()=="ResMed") {
|
||||
stats+="UAI\t"+QString::number(uai,'f',2)+"\n";
|
||||
} else if (cpap->machine->GetClass()=="Intellipap") {
|
||||
stats+="NRI\t"+QString::number(nri,'f',2)+"\n";
|
||||
stats+="LKI\t"+QString::number(lki,'f',2)+"\n";
|
||||
stats+="EPI\t"+QString::number(exp,'f',2)+"\n";
|
||||
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);
|
||||
}
|
||||
QRectF bounds=painter.boundingRect(QRectF(0,top,res.width(),0),stats,QTextOption(Qt::AlignRight));
|
||||
|
||||
defaultfont=&fa;
|
||||
mediumfont=&fb;
|
||||
bigfont=&fc;
|
||||
|
||||
QPixmap ebp=getDaily()->eventBreakdownPie()->renderPixmap(piesize,piesize);
|
||||
|
||||
defaultfont=_defaultfont;
|
||||
mediumfont=_mediumfont;
|
||||
bigfont=_bigfont;
|
||||
|
||||
painter.drawPixmap(res.width()-piesize,top,piesize,piesize,ebp);
|
||||
getDaily()->eventBreakdownPie()->showTitle(true);
|
||||
|
||||
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();
|
||||
//if (bounds.height()>maxy) maxy=bounds.height();
|
||||
|
||||
painter.setFont(*defaultfont);
|
||||
|
||||
stats="AI="+QString::number(oai,'f',2)+" ";
|
||||
stats+="HI="+QString::number(hi,'f',2)+" ";
|
||||
stats+="CAI="+QString::number(cai,'f',2)+" ";
|
||||
if (cpap->machine->GetClass()=="PRS1") {
|
||||
stats+="REI="+QString::number(rei,'f',2)+" ";
|
||||
stats+="VSI="+QString::number(vsi,'f',2)+" ";
|
||||
stats+="FLI="+QString::number(fli,'f',2)+" ";
|
||||
stats+="PB/CSR="+QString::number(csr,'f',2)+"%";
|
||||
} else if (cpap->machine->GetClass()=="ResMed") {
|
||||
stats+="UAI="+QString::number(uai,'f',2)+" ";
|
||||
} else if (cpap->machine->GetClass()=="Intellipap") {
|
||||
stats+="NRI="+QString::number(nri,'f',2)+" ";
|
||||
stats+="LKI="+QString::number(lki,'f',2)+" ";
|
||||
stats+="EPI="+QString::number(exp,'f',2)+" ";
|
||||
}
|
||||
bounds=painter.boundingRect(QRectF(0,top+maxy,res.width(),0),stats,QTextOption(Qt::AlignLeft));
|
||||
painter.drawText(bounds,stats,QTextOption(Qt::AlignLeft));
|
||||
if (top+maxy+bounds.height()>maxy) maxy=top+maxy+bounds.height();
|
||||
}
|
||||
QRectF bounds=painter.boundingRect(QRectF((res.width()/2)-(res.width()/6),top,res.width()/2,0),cpapinfo,QTextOption(Qt::AlignLeft));
|
||||
painter.drawText(bounds,cpapinfo,QTextOption(Qt::AlignLeft));
|
||||
@ -894,6 +938,9 @@ 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;
|
||||
@ -981,10 +1028,11 @@ 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(1.5);
|
||||
SnapshotGraph->setPrintScaleY(1.5);
|
||||
SnapshotGraph->setPrintScaleX(fscale);
|
||||
SnapshotGraph->setPrintScaleY(fscale);
|
||||
}
|
||||
QFont * _defaultfont=defaultfont;
|
||||
QFont * _mediumfont=mediumfont;
|
||||
@ -995,16 +1043,18 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
|
||||
QFont fc=*bigfont;
|
||||
|
||||
if (!no_scaling ) {
|
||||
fa.setPointSizeF(fa.pointSizeF()*2);
|
||||
fb.setPointSizeF(fb.pointSizeF()*2);
|
||||
fc.setPointSizeF(fc.pointSizeF()*2);
|
||||
fa.setPointSizeF(fa.pointSizeF()*fscale);
|
||||
fb.setPointSizeF(fb.pointSizeF()*fscale);
|
||||
fc.setPointSizeF(fc.pointSizeF()*fscale);
|
||||
}
|
||||
|
||||
defaultfont=&fa;
|
||||
mediumfont=&fb;
|
||||
bigfont=&fc;
|
||||
|
||||
//g->showTitle(false);
|
||||
QPixmap pm=g->renderPixmap(gw,gh);
|
||||
//g->showTitle(true);
|
||||
|
||||
defaultfont=_defaultfont;
|
||||
mediumfont=_mediumfont;
|
||||
|
@ -195,13 +195,13 @@ PreferencesDialog::PreferencesDialog(QWidget *parent,Profile * _profile) :
|
||||
ui->skipEmptyDays->setChecked(general["SkipEmptyDays"].value().toBool());
|
||||
ui->enableMultithreading->setChecked(general["EnableMultithreading"].value().toBool());
|
||||
ui->cacheSessionData->setChecked(general["MemoryHog"].value().toBool());
|
||||
#ifdef Q_WS_MAC
|
||||
general["HighResPrinting"].setValue(true);
|
||||
ui->highResolutionPrinting->setChecked(true);
|
||||
ui->highResolutionPrinting->setEnabled(false);
|
||||
#else
|
||||
//#ifdef Q_WS_MAC
|
||||
// general["HighResPrinting"].setValue(true);
|
||||
// ui->highResolutionPrinting->setChecked(true);
|
||||
// ui->highResolutionPrinting->setEnabled(false);
|
||||
//#else
|
||||
ui->highResolutionPrinting->setChecked(general["HighResPrinting"].value().toBool());
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
ui->graphHeight->setValue(general["GraphHeight"].value().toInt());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user