From: <ai...@us...> - 2009-03-17 21:26:09
|
Revision: 9749 http://plplot.svn.sourceforge.net/plplot/?rev=9749&view=rev Author: airwin Date: 2009-03-17 21:25:30 +0000 (Tue, 17 Mar 2009) Log Message: ----------- AWI for Alban Rochel. Alban got access to a Mandriva virtual machine which appeared to give results equivalent to AWI's Debian Lenny screenshots for the previous commit. The present commit is his adjustments to make the Mandriva results look good (and hopefully AWI's as well). - Adjust glyph size to larger values. - Qt gave bounding boxes a bit too large for the text, mainly on the Y axis, and the text is not exactly centered vertically. Alban adjusted the bounding box empirically to get better results. This should reduce the offset issues. - The -geometry parameter is taken into account for the epsqt and qtwidget devices. (AWI's comments. The changes improve a lot of things, but they make svgqt (created with qt-4.5.0 and viewed with reliable versions of konqueror and firefox) much worse. Also, this commit fixed an issue with the epsqt background, but the bounding box is quite bad now [almost two times too large] for that case. So I will play with these adjustments some more, but for now it is good to get Alban's current best shot at an adjustment committed to give us a benchmark for further effort.) Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-16 17:15:49 UTC (rev 9748) +++ trunk/drivers/qt.cpp 2009-03-17 21:25:30 UTC (rev 9749) @@ -258,11 +258,11 @@ switch(fontFamily) { - case 1: f.setFamily("Times"); break; - case 2: f.setFamily("Courier"); break; - case 3: f.setFamily("Helvetica"); break; - case 4: f.setFamily("Helvetica"); break; - case 0: default: f.setFamily("Helvetica"); break; + case 1: f.setFamily("Times"); f.setStyleHint(QFont::Times); break; + case 2: f.setFamily("Courier"); f.setStyleHint(QFont::Courier); break; + case 3: f.setFamily("Helvetica"); f.setStyleHint(QFont::SansSerif); break; + case 4: f.setFamily("Helvetica"); f.setStyleHint(QFont::SansSerif); break; + case 0: default: f.setFamily("Helvetica"); f.setStyleHint(QFont::SansSerif); break; } if(fontStyle) f.setItalic(true); if(fontWeight) f.setWeight(QFont::Bold); @@ -284,6 +284,8 @@ tempPainter.drawText(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text, &bounding); // For svg debug +// std::cout << bounding.left()+bounding.right() << std::endl; +bounding.adjust(-0.5, bounding.height(), -0.5, -bounding.height()/5.); // Empiric adjustment of the true bounding box // tempPainter.drawLine(bounding.left(), bounding.bottom(), bounding.right(), bounding.bottom()); // tempPainter.drawLine(bounding.left(), bounding.top(), bounding.right(), bounding.top()); // tempPainter.drawLine(bounding.left(), bounding.bottom(), bounding.left(), bounding.top()); @@ -314,7 +316,7 @@ yOffset=0.; xOffset=0.; - currentFontSize=chrht*72./25.4*1.5; + currentFontSize=chrht*72./25.4*1.6; currentFontScale=1.; underlined=false; overlined=false; @@ -1025,16 +1027,24 @@ #endif #if defined (PLD_epsqt) || defined(PLD_pdfqt) -QtEPSDevice::QtEPSDevice() +QtEPSDevice::QtEPSDevice(int i_iWidth, int i_iHeight) { setPageSize(QPrinter::A4); setResolution(DPI); setColorMode(QPrinter::Color); setOrientation(QPrinter::Landscape); setPrintProgram(QString("lpr")); - - m_dWidth=pageRect().width(); - m_dHeight=pageRect().height(); + + if(i_iWidth<=0 || i_iHeight<=0) + { + m_dWidth=pageRect().width(); + m_dHeight=pageRect().height(); + } + else + { + m_dWidth=i_iWidth; + m_dHeight=i_iHeight; + } m_painterP=NULL; // fontScalingFactor=1.; @@ -1124,12 +1134,16 @@ // QPrinter devices won't create if there is no QApplication declared... initQtApp(false); - pls->dev=new QtEPSDevice; if (pls->xlength <= 0 || pls->ylength <= 0) { + pls->dev=new QtEPSDevice; pls->xlength = ((QtEPSDevice*)(pls->dev))->m_dWidth; pls->ylength = ((QtEPSDevice*)(pls->dev))->m_dHeight; } + else + { + pls->dev=new QtEPSDevice(pls->xlength, pls->ylength); + } if (pls->xlength > pls->ylength) ((QtEPSDevice*)(pls->dev))->downscale = (PLFLT)pls->xlength/(PLFLT)(PIXELS_X-1); @@ -1197,12 +1211,11 @@ m_painterP=new QPainter; m_dAspectRatio=(double)i_iWidth/(double)i_iHeight; - cursorParameters.isTracking=false; m_pixPixmap=NULL; m_iOldSize=0; - resize(i_iWidth, i_iHeight); +// resize(i_iWidth, i_iHeight); pic=new QPicture; m_painterP->begin(pic); @@ -1413,7 +1426,7 @@ { double w=(double)width(); double h=(double)height(); - + if(w/h>m_dAspectRatio) //Too wide, h is the limitating factor { io_dYFact=h/m_dHeight; @@ -1440,10 +1453,10 @@ void QtPLTabWidget::newTab() { - QtPLWidget * plotWidget=new QtPLWidget; + QtPLWidget * plotWidget=new QtPLWidget(m_iWidth, m_iHeight); plotWidget->downscale=downscale; - plotWidget->m_dWidth=m_dWidth; - plotWidget->m_dHeight=m_dHeight; +// plotWidget->m_dWidth=m_dWidth; +// plotWidget->m_dHeight=m_dHeight; addTab(plotWidget, QString("page %1").arg(count()+1)); currentWidget=plotWidget; widgets.push_back(plotWidget); @@ -1473,12 +1486,25 @@ PLINT w, h; initQtApp(true); QMainWindow * mw=new QMainWindow; - QtPLTabWidget* tabWidget=new QtPLTabWidget; + QtPLTabWidget* tabWidget;//=new QtPLTabWidget; - plsc->dev = (void*)tabWidget; - plsc->xlength = tabWidget->m_dWidth; - plsc->ylength = tabWidget->m_dHeight; +// plsc->dev = (void*)tabWidget; +// plsc->xlength = tabWidget->m_dWidth; +// plsc->ylength = tabWidget->m_dHeight; + if (pls->xlength <= 0 || pls->ylength <= 0) + { + tabWidget=new QtPLTabWidget; + pls->dev=(void*) tabWidget; + pls->xlength = tabWidget->m_iWidth; + pls->ylength = tabWidget->m_iHeight; + } + else + { + tabWidget=new QtPLTabWidget(pls->xlength, pls->ylength); + pls->dev=(void*) tabWidget; + } + if (plsc->xlength > plsc->ylength) tabWidget->downscale = (PLFLT)plsc->xlength/(PLFLT)(PIXELS_X-1); else Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-16 17:15:49 UTC (rev 9748) +++ trunk/drivers/qt.h 2009-03-17 21:25:30 UTC (rev 9749) @@ -47,7 +47,7 @@ #include "plplotP.h" #include "drivers.h" -#define DPI 72 +#define DPI 120 //72 #define QT_DEFAULT_X 842 #define QT_DEFAULT_Y 598 @@ -136,8 +136,8 @@ class QtSVGDevice: public QtPLDriver, public QSvgGenerator { public: - QtSVGDevice(int i_iWidth=QT_DEFAULT_X, - int i_iHeight=QT_DEFAULT_Y); + QtSVGDevice(int i_iWidth=-1, + int i_iHeight=-1); virtual ~QtSVGDevice(); @@ -154,7 +154,8 @@ class QtEPSDevice: public QtPLDriver, public QPrinter { public: - QtEPSDevice(); + QtEPSDevice(int i_iWidth=QT_DEFAULT_X, + int i_iHeight=QT_DEFAULT_Y); virtual ~QtEPSDevice(); @@ -246,8 +247,11 @@ class QtPLTabWidget: public QTabWidget, public QtPLDriver { public: - QtPLTabWidget() + QtPLTabWidget(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y) { + + m_iWidth=i_iWidth; + m_iHeight=i_iHeight; currentWidget=NULL; } @@ -312,11 +316,15 @@ QtPLWidget* currentWidget; + int m_iWidth, m_iHeight; + protected: void newTab(); QList<QtPLWidget*> widgets; double resolution; + + }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |