Windows printing & GL context issues

This commit is contained in:
Mark Watkins 2011-12-09 00:47:10 +10:00
parent 07188c2cde
commit 0d1b153a45
3 changed files with 20 additions and 16 deletions

View File

@ -99,8 +99,12 @@ void GetTextExtent(QString text, int & width, int & height, QFont *font)
#endif
QFontMetrics fm(*font);
//QRect r=fm.tightBoundingRect(text);
width=fm.width(text); //fm.width(text);
width=fm.width(text);
#ifdef Q_WS_WIN32
height=fm.ascent();
#else
height=fm.xHeight()+2; //fm.ascent();
#endif
#ifdef ENABLE_THREADED_DRAWING
mut.unlock();
#endif

View File

@ -70,10 +70,11 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw)
GraphView=new gGraphView(ui->graphMainArea,shared);
GraphView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
snapGV=new gGraphView(ui->graphMainArea,shared);
snapGV=new gGraphView(ui->graphMainArea);
snapGV->setMinimumSize(172,172);
snapGV->hideSplitter();
snapGV->hide();
scrollbar=new MyScrollBar(ui->graphMainArea);
scrollbar->setOrientation(Qt::Vertical);
scrollbar->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Expanding);
@ -736,7 +737,9 @@ void Daily::Load(QDate date)
if (ahi+rei+fli>0) {
html+="</tr>\n"; //<tr><td colspan=4 align=center><i>"+tr("Event Breakdown")+"</i></td></tr>\n";
//G_AHI->setFixedSize(gwwidth,120);
QPixmap pixmap=snapGV->renderPixmap(172,172,false); //gwwidth,gwheight,false);
//mainwin->snapshotGraph()->setPrintScaleX(1);
//mainwin->snapshotGraph()->setPrintScaleY(1);
QPixmap pixmap=snapGV->renderPixmap(172,172);
QByteArray byteArray;
QBuffer buffer(&byteArray); // use buffer to store pixmap into byteArray
buffer.open(QIODevice::WriteOnly);

View File

@ -207,6 +207,11 @@ void MainWindow::Startup()
// profile is a global variable set in main after login
PROFILE.LoadMachineData();
SnapshotGraph=new gGraphView(this); //daily->graphView());
SnapshotGraph->setMaximumSize(1024,512);
SnapshotGraph->setMinimumSize(1024,512);
SnapshotGraph->hide();
daily=new Daily(ui->tabWidget,NULL,this);
ui->tabWidget->insertTab(1,daily,tr("Daily"));
@ -217,12 +222,6 @@ void MainWindow::Startup()
ui->tabWidget->insertTab(3,oximetry,tr("Oximetry"));
}
SnapshotGraph=new gGraphView(this,daily->graphView());
SnapshotGraph->setMaximumSize(1024,512);
SnapshotGraph->setMinimumSize(1024,512);
//ReportGraph->setMaximumSize(graph_print_width,graph_print_height);
//ReportGraph->setMinimumSize(graph_print_width,graph_print_height);
SnapshotGraph->hide();
if (daily) daily->ReloadGraphs();
if (overview) overview->ReloadGraphs();
@ -725,23 +724,21 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date)
if (pw>8000) {
div=4;
#ifdef Q_WS_WIN32
fontdiv=2;
fontdiv=2.3;
#else
fontdiv=2.3;
#endif
} else if (pw>2000) {
div=2;
fontdiv=1;
div=2.0;
fontdiv=2.0;
} else {
div=1;
#ifdef Q_WS_WIN32 // windows really doesn like the resulting font size
fontdiv=1;
#ifdef Q_WS_WIN32
fontdiv=1; // windows will crash if it's any smaller than this
#else
fontdiv=0.75;
#endif
}
//float div=highres ? 4.0 : 1.0;
float gw=pw/div;
float gh=ph/div;