From: <ai...@us...> - 2009-03-09 18:05:24
|
Revision: 9686 http://plplot.svn.sourceforge.net/plplot/?rev=9686&view=rev Author: airwin Date: 2009-03-09 18:05:18 +0000 (Mon, 09 Mar 2009) Log Message: ----------- AWI for Alban Rochel. Implement familying for all qt file-based devices (i.e., everything other than qtwidget). Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-09 17:55:22 UTC (rev 9685) +++ trunk/drivers/qt.cpp 2009-03-09 18:05:18 UTC (rev 9686) @@ -62,53 +62,81 @@ #endif ; +/*--------------------------------------------------------------------- + qt_family_check () + + support function to help supress more than one page if family file + output not specified by the user (e.g., with the -fam command-line option). + Adapted directly from svg.c + ---------------------------------------------------------------------*/ +static int already_warned = 0; +static int qt_family_check(PLStream *pls) +{ + if (pls->family || pls->page == 1) + { + return 0; + } + else + { + if(! already_warned) + { + already_warned = 1; + plwarn("All pages after the first skipped because family file output not specified.\n"); + } + return 1; + } +} + // Declaration of the driver-specific interface functions #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) void plD_init_rasterqt(PLStream *); +void plD_eop_rasterqt(PLStream *); #endif #if defined (PLD_bmpqt) void plD_dispatch_init_bmpqt(PLDispatchTable *pdt); -void plD_eop_bmpqt(PLStream *); +void plD_bop_bmpqt(PLStream *); #endif #if defined (PLD_jpgqt) void plD_dispatch_init_jpgqt(PLDispatchTable *pdt); -void plD_eop_jpgqt(PLStream *); +void plD_bop_jpgqt(PLStream *); #endif #if defined (PLD_pngqt) void plD_dispatch_init_pngqt(PLDispatchTable *pdt); -void plD_eop_pngqt(PLStream *); +void plD_bop_pngqt(PLStream *); #endif #if defined (PLD_ppmqt) void plD_dispatch_init_ppmqt(PLDispatchTable *pdt); -void plD_eop_ppmqt(PLStream *); +void plD_bop_ppmqt(PLStream *); #endif #if defined (PLD_tiffqt) void plD_dispatch_init_tiffqt(PLDispatchTable *pdt); -void plD_eop_tiffqt(PLStream *); +void plD_bop_tiffqt(PLStream *); #endif #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 void plD_dispatch_init_svgqt(PLDispatchTable *pdt); void plD_init_svgqt(PLStream *); +void plD_bop_svgqt(PLStream *); void plD_eop_svgqt(PLStream *); #endif #if defined(PLD_epsqt) || defined(PLD_pdfqt) void plD_init_epspdfqt(PLStream *); -void plD_eop_epspdfqt_helper(PLStream *, int ifeps); +void plD_bop_epspdfqt_helper(PLStream *, int ifeps); +void plD_eop_epspdfqt(PLStream *); #endif #if defined(PLD_epsqt) void plD_dispatch_init_epsqt(PLDispatchTable *pdt); -void plD_eop_epsqt(PLStream *); +void plD_bop_epsqt(PLStream *); #endif #if defined(PLD_pdfqt) void plD_dispatch_init_pdfqt(PLDispatchTable *pdt); -void plD_eop_pdfqt(PLStream *); +void plD_bop_pdfqt(PLStream *); #endif #if defined(PLD_qtwidget) @@ -214,10 +242,6 @@ m_painterP->setPen(p); } -void QtPLDriver::savePlot(char* fileName) -{ -} - //////////// Buffered driver /////////////////////// QtPLBufferedDriver::QtPLBufferedDriver(PLINT i_iWidth, PLINT i_iHeight): @@ -343,10 +367,6 @@ m_listBuffer.append(el); } -void QtPLBufferedDriver::savePlot(char* fileName) -{ -} - // Draw the content of the buffer void QtPLBufferedDriver::doPlot(QPainter* i_painterP, double x_fact, double y_fact, double x_offset, double y_offset) { @@ -457,15 +477,19 @@ void plD_line_qt(PLStream * pls, short x1a, short y1a, short x2a, short y2a) { QtPLDriver * widget=NULL; + // We have to dynamic_cast to make sure the good virtual functions are called #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); + if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); + if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_epsqt) || defined(PLD_pdfqt) if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); + if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_qtwidget) if(widget==NULL) widget=dynamic_cast<QtPLTabWidget*>((QWidget *) pls->dev); @@ -479,14 +503,18 @@ void plD_polyline_qt(PLStream *pls, short *xa, short *ya, PLINT npts) { QtPLDriver * widget=NULL; + #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); + if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); + if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_epsqt) || defined(PLD_pdfqt) if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); + if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_qtwidget) if(widget==NULL) widget=dynamic_cast<QtPLTabWidget*>((QWidget *) pls->dev); @@ -502,14 +530,18 @@ short *xa, *ya; PLINT i, j; QtPLDriver * widget=NULL; + #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); + if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); + if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_epsqt) || defined(PLD_pdfqt) if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); + if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_qtwidget) if(widget==NULL) widget=dynamic_cast<QtPLTabWidget*>((QWidget *) pls->dev); @@ -550,12 +582,15 @@ QtPLDriver * widget=NULL; #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); + if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); + if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_epsqt) || defined(PLD_pdfqt) if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); + if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_qtwidget) if(widget==NULL) widget=dynamic_cast<QtPLTabWidget*>((QWidget *) pls->dev); @@ -597,29 +632,22 @@ m_painterP->setRenderHint(QPainter::Antialiasing, true); // Let's fill the background m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); - // For page numbering - pageCounter=0; } -// Used to append _page# when multiple pages -QString QtRasterDevice::getFileName(char* fileName) +void QtRasterDevice::definePlotName(const char* fileName, const char* format) { - QString fn(fileName); - - if(pageCounter==0) return fn; - - int pos=fn.lastIndexOf("."); - if(pos<0) pos=fn.length(); - QString res=fn.insert(pos, QString("_page%1").arg(pageCounter+1)); - return res; + // Avoid buffer overflows + strncpy(this->format, format, 4); + this->format[4]='\0'; + + this->fileName=QString(fileName); } -void QtRasterDevice::savePlot(char* fileName, const char* format) +void QtRasterDevice::savePlot() { m_painterP->end(); - save(getFileName(fileName), format, 85); + save(fileName, format, 85); - ++pageCounter; m_painterP->begin(this); m_painterP->setRenderHint(QPainter::Antialiasing, true); QBrush b=m_painterP->brush(); @@ -639,6 +667,7 @@ pls->dev_flush=1; pls->dev_clear=1; pls->termin=0; + pls->page = 0; // Initialised with the default (A4) size pls->dev=new QtRasterDevice; @@ -659,9 +688,18 @@ plP_setpxl(DPI/25.4/((QtRasterDevice*)(pls->dev))->downscale, DPI/25.4/((QtRasterDevice*)(pls->dev))->downscale); + /* Initialize family file info */ + plFamInit(pls); + plOpenFile(pls); } +void plD_eop_rasterqt(PLStream *pls) +{ + if(qt_family_check(pls)) {return;} + ((QtRasterDevice *)pls->dev)->savePlot(); +} + #endif #if defined(PLD_bmpqt) @@ -676,16 +714,22 @@ pdt->pl_init = (plD_init_fp) plD_init_rasterqt; pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; - pdt->pl_eop = (plD_eop_fp) plD_eop_bmpqt; - pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_rasterqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_bmpqt; pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; pdt->pl_state = (plD_state_fp) plD_state_qt; pdt->pl_esc = (plD_esc_fp) plD_esc_qt; } -void plD_eop_bmpqt(PLStream *pls) +void plD_bop_bmpqt(PLStream *pls) { - ((QtRasterDevice *)pls->dev)->savePlot(pls->FileName, "BMP"); + /* Plot familying stuff. Not really understood, just copying gd.c */ + plGetFam(pls); + + pls->famadv = 1; + pls->page++; + if(qt_family_check(pls)) {return;} + ((QtRasterDevice *)pls->dev)->definePlotName(pls->FileName, "BMP"); } #endif @@ -701,16 +745,22 @@ pdt->pl_init = (plD_init_fp) plD_init_rasterqt; pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; - pdt->pl_eop = (plD_eop_fp) plD_eop_jpgqt; - pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_rasterqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_jpgqt; pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; pdt->pl_state = (plD_state_fp) plD_state_qt; pdt->pl_esc = (plD_esc_fp) plD_esc_qt; } -void plD_eop_jpgqt(PLStream *pls) +void plD_bop_jpgqt(PLStream *pls) { - ((QtRasterDevice *)pls->dev)->savePlot(pls->FileName, "JPG"); + /* Plot familying stuff. Not really understood, just copying gd.c */ + plGetFam(pls); + + pls->famadv = 1; + pls->page++; + if(qt_family_check(pls)) {return;} + ((QtRasterDevice *)pls->dev)->definePlotName(pls->FileName, "JPG"); } #endif @@ -726,16 +776,22 @@ pdt->pl_init = (plD_init_fp) plD_init_rasterqt; pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; - pdt->pl_eop = (plD_eop_fp) plD_eop_pngqt; - pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_rasterqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_pngqt; pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; pdt->pl_state = (plD_state_fp) plD_state_qt; pdt->pl_esc = (plD_esc_fp) plD_esc_qt; } -void plD_eop_pngqt(PLStream *pls) +void plD_bop_pngqt(PLStream *pls) { - ((QtRasterDevice *)pls->dev)->savePlot(pls->FileName, "PNG"); + /* Plot familying stuff. Not really understood, just copying gd.c */ + plGetFam(pls); + + pls->famadv = 1; + pls->page++; + if(qt_family_check(pls)) {return;} + ((QtRasterDevice *)pls->dev)->definePlotName(pls->FileName, "PNG"); } #endif @@ -751,16 +807,22 @@ pdt->pl_init = (plD_init_fp) plD_init_rasterqt; pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; - pdt->pl_eop = (plD_eop_fp) plD_eop_ppmqt; - pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_rasterqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_ppmqt; pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; pdt->pl_state = (plD_state_fp) plD_state_qt; pdt->pl_esc = (plD_esc_fp) plD_esc_qt; } -void plD_eop_ppmqt(PLStream *pls) +void plD_bop_ppmqt(PLStream *pls) { - ((QtRasterDevice *)pls->dev)->savePlot(pls->FileName, "PPM"); + /* Plot familying stuff. Not really understood, just copying gd.c */ + plGetFam(pls); + + pls->famadv = 1; + pls->page++; + if(qt_family_check(pls)) {return;} + ((QtRasterDevice *)pls->dev)->definePlotName(pls->FileName, "PPM"); } #endif @@ -776,52 +838,48 @@ pdt->pl_init = (plD_init_fp) plD_init_rasterqt; pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; - pdt->pl_eop = (plD_eop_fp) plD_eop_tiffqt; - pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_rasterqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_tiffqt; pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; pdt->pl_state = (plD_state_fp) plD_state_qt; pdt->pl_esc = (plD_esc_fp) plD_esc_qt; } -void plD_eop_tiffqt(PLStream *pls) +void plD_bop_tiffqt(PLStream *pls) { - ((QtRasterDevice *)pls->dev)->savePlot(pls->FileName, "TIFF"); + /* Plot familying stuff. Not really understood, just copying gd.c */ + plGetFam(pls); + + pls->famadv = 1; + pls->page++; + if(qt_family_check(pls)) {return;} + ((QtRasterDevice *)pls->dev)->definePlotName(pls->FileName, "TIFF"); } #endif #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 QtSVGDevice::QtSVGDevice(int i_iWidth, int i_iHeight): - QtPLBufferedDriver(i_iWidth, i_iHeight) + QtPLDriver(i_iWidth, i_iHeight) { setSize(QSize(m_dWidth, m_dHeight)); - pageCounter=0; } QtSVGDevice::~QtSVGDevice() { - clearBuffer(); } -QString QtSVGDevice::getFileName(char* fileName) +void QtSVGDevice::definePlotName(const char* fileName) { - QString fn(fileName); - - if(pageCounter==0) return fn; - - int pos=fn.lastIndexOf("."); - if(pos<0) pos=fn.length(); - QString res=fn.insert(pos, QString("_page%1").arg(pageCounter+1)); - return res; + setFileName(QString(fileName)); + setResolution(72); + + m_painterP=new QPainter(this); + m_painterP->fillRect(0, 0, m_dWidth, m_dHeight, QBrush(Qt::black)); } -void QtSVGDevice::savePlot(char* fileName) +void QtSVGDevice::savePlot() { - setFileName(getFileName(fileName)); - setResolution(72); - - m_painterP=new QPainter(this); - doPlot(); m_painterP->end(); } @@ -837,7 +895,7 @@ pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; pdt->pl_eop = (plD_eop_fp) plD_eop_svgqt; - pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_bop = (plD_bop_fp) plD_bop_svgqt; pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; pdt->pl_state = (plD_state_fp) plD_state_qt; pdt->pl_esc = (plD_esc_fp) plD_esc_qt; @@ -854,6 +912,7 @@ pls->dev_flush=1; pls->dev_clear=1; pls->termin=0; + pls->page = 0; pls->dev=new QtSVGDevice; @@ -871,27 +930,38 @@ plP_setphy((PLINT) 0, (PLINT) (pls->xlength / ((QtSVGDevice*)(pls->dev))->downscale), (PLINT) 0, (PLINT) (pls->ylength / ((QtSVGDevice*)(pls->dev))->downscale)); plP_setpxl(DPI/25.4/((QtSVGDevice*)(pls->dev))->downscale, DPI/25.4/((QtSVGDevice*)(pls->dev))->downscale); - + + /* Initialize family file info */ + plFamInit(pls); + plOpenFile(pls); } +void plD_bop_svgqt(PLStream *pls) +{ + /* Plot familying stuff. Not really understood, just copying gd.c */ + plGetFam(pls); + + pls->famadv = 1; + pls->page++; + if(qt_family_check(pls)) {return;} + ((QtSVGDevice *)pls->dev)->definePlotName(pls->FileName); +} + void plD_eop_svgqt(PLStream *pls) { double downscale; - int pageCounter; QSize s; - ((QtSVGDevice *)pls->dev)->savePlot(pls->FileName); + ((QtSVGDevice *)pls->dev)->savePlot(); // Once saved, we have to create a new device with the same properties // to be able to plot another page. downscale=((QtSVGDevice *)pls->dev)->downscale; - pageCounter=((QtSVGDevice *)pls->dev)->pageCounter; s=((QtSVGDevice *)pls->dev)->size(); delete ((QtSVGDevice *)pls->dev); pls->dev=new QtSVGDevice(s.width(), s.height()); ((QtSVGDevice *)pls->dev)->downscale=downscale; - ((QtSVGDevice *)pls->dev)->pageCounter=pageCounter+1; } #endif @@ -899,7 +969,6 @@ #if defined (PLD_epsqt) || defined(PLD_pdfqt) QtEPSDevice::QtEPSDevice() { - pageCounter=0; setPageSize(QPrinter::A4); setResolution(DPI); setColorMode(QPrinter::Color); @@ -911,24 +980,11 @@ QtEPSDevice::~QtEPSDevice() { - clearBuffer(); } -QString QtEPSDevice::getFileName(char* fileName) +void QtEPSDevice::definePlotName(const char* fileName, int ifeps) { - QString fn(fileName); - - if(pageCounter==0) return fn; - - int pos=fn.lastIndexOf("."); - if(pos<0) pos=fn.length(); - QString res=fn.insert(pos, QString("_page%1").arg(pageCounter+1)); - return res; -} - -void QtEPSDevice::savePlot(char* fileName, int ifeps) -{ - setOutputFileName(getFileName(fileName)); + setOutputFileName(QString(fileName)); if(ifeps) { setOutputFormat(QPrinter::PostScriptFormat); @@ -939,7 +995,11 @@ } m_painterP=new QPainter(this); - doPlot(); + m_painterP->fillRect(0, 0, m_dWidth, m_dHeight, QBrush(Qt::black)); +} + +void QtEPSDevice::savePlot() +{ m_painterP->end(); } @@ -955,8 +1015,8 @@ pdt->pl_init = (plD_init_fp) plD_init_epspdfqt; pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; - pdt->pl_eop = (plD_eop_fp) plD_eop_epsqt; - pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_epspdfqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_epsqt; pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; pdt->pl_state = (plD_state_fp) plD_state_qt; pdt->pl_esc = (plD_esc_fp) plD_esc_qt; @@ -975,8 +1035,8 @@ pdt->pl_init = (plD_init_fp) plD_init_epspdfqt; pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; - pdt->pl_eop = (plD_eop_fp) plD_eop_pdfqt; - pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_epspdfqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_pdfqt; pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; pdt->pl_state = (plD_state_fp) plD_state_qt; pdt->pl_esc = (plD_esc_fp) plD_esc_qt; @@ -994,6 +1054,7 @@ pls->dev_flush=1; pls->dev_clear=1; pls->termin=0; + pls->page = 0; int argc=0; char argv[]={'\0'}; @@ -1017,42 +1078,54 @@ plP_setpxl(DPI/25.4/((QtEPSDevice*)(pls->dev))->downscale, DPI/25.4/((QtEPSDevice*)(pls->dev))->downscale); + /* Initialize family file info */ + plFamInit(pls); + plOpenFile(pls); } -void plD_eop_epspdfqt_helper(PLStream *pls, int ifeps) +void plD_bop_epspdfqt_helper(PLStream *pls, int ifeps) { + /* Plot familying stuff. Not really understood, just copying gd.c */ + plGetFam(pls); + + pls->famadv = 1; + pls->page++; + if(qt_family_check(pls)) {return;} + ((QtEPSDevice *)pls->dev)->definePlotName(pls->FileName, ifeps); +} + +void plD_eop_epspdfqt(PLStream *pls) +{ double downscale; - int pageCounter; - + int argc=0; char argv[]={'\0'}; - ((QtEPSDevice *)pls->dev)->savePlot(pls->FileName, ifeps); + ((QtEPSDevice *)pls->dev)->savePlot(); // Once saved, we have to create a new device with the same properties // to be able to plot another page. downscale=((QtEPSDevice *)pls->dev)->downscale; - pageCounter=((QtEPSDevice *)pls->dev)->pageCounter; + delete ((QtEPSDevice *)pls->dev); QApplication * app=new QApplication(argc, (char**)&argv); pls->dev=new QtEPSDevice; ((QtEPSDevice *)pls->dev)->downscale=downscale; - ((QtEPSDevice *)pls->dev)->pageCounter=pageCounter+1; delete app; } #if defined(PLD_epsqt) -void plD_eop_epsqt(PLStream *pls) +void plD_bop_epsqt(PLStream *pls) { - plD_eop_epspdfqt_helper(pls, 1); + plD_bop_epspdfqt_helper(pls, 1); } #endif #if defined(PLD_pdfqt) -void plD_eop_pdfqt(PLStream *pls) +void plD_bop_pdfqt(PLStream *pls) { - plD_eop_epspdfqt_helper(pls, 0); + plD_bop_epspdfqt_helper(pls, 0); } #endif @@ -1166,6 +1239,7 @@ painter->fillRect(0, 0, width(), height(), QBrush(Qt::white)); painter->fillRect(0, 0, width(), height(), QBrush(Qt::gray, Qt::Dense4Pattern)); painter->fillRect((int)x_offset, (int)y_offset, (int)floor(x_fact*m_dWidth+0.5), (int)floor(y_fact*m_dHeight+0.5), QBrush(Qt::black)); + painter->setRenderHint(QPainter::Antialiasing, true); doPlot(painter, x_fact, y_fact, x_offset, y_offset); painter->end(); m_bAwaitingRedraw=false; Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-09 17:55:22 UTC (rev 9685) +++ trunk/drivers/qt.h 2009-03-09 18:05:18 UTC (rev 9686) @@ -122,8 +122,6 @@ // Set pen to draw solid strokes (called after drawing dashed strokes) virtual void setSolid(); - virtual void savePlot(char* fileName); - // Conversion factor from internal plplot coordinates to device coordinates double downscale; double m_dWidth, m_dHeight; @@ -132,9 +130,7 @@ QPainter* m_painterP; }; -// This device is used in two situations: -// - if the device can only start plotting when given a destination file (SVG, EPS, PDF), then we have to accumulate the plot commands before printing them when eop() is called -// - If the device may have to redraw (Widget), then the accumulated commands are re-issued, possibly corrected to fit a new device size +// This driver is used if the device may have to redraw (Widget), then the accumulated commands are re-issued, possibly corrected to fit a new device size class QtPLBufferedDriver: public QtPLDriver { public: @@ -157,8 +153,6 @@ virtual void setSolid(); - virtual void savePlot(char* fileName); - // Actually plots on the device, using the p QPainter. // if p is null, then the defaut QPainter m_painterP is used. // x_fact, y_fact, x_offset and y_offset allow to center the plot @@ -191,14 +185,13 @@ virtual ~QtRasterDevice(){} - // Saves the plot to the fileName file, possibly appending - // _page# to the file name if not the 1st page - void savePlot(char* fileName, const char* format); + void definePlotName(const char* fileName, const char* format); + void savePlot(); + protected: - // Generates the actual file name, depending on fileName and pageCounter - QString getFileName(char* fileName); - int pageCounter; + char format[5]; + QString fileName; }; #endif @@ -206,7 +199,7 @@ #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 #include <QSvgGenerator> // Driver painting on an SVG device -class QtSVGDevice: public QtPLBufferedDriver, public QSvgGenerator +class QtSVGDevice: public QtPLDriver, public QSvgGenerator { public: QtSVGDevice(int i_iWidth=QT_DEFAULT_X, @@ -214,29 +207,27 @@ virtual ~QtSVGDevice(); - void savePlot(char* fileName); - - int pageCounter; // public because read and written by plD_eop + void definePlotName(const char* fileName); + + void savePlot(); protected: - QString getFileName(char* fileName); }; #endif #if defined (PLD_epsqt) || defined (PLD_pdfqt) // Driver painting on an EPS or PDF device, uses QPrinter // A (possibly dummy) QApplication must be declared before use -class QtEPSDevice: public QtPLBufferedDriver, public QPrinter +class QtEPSDevice: public QtPLDriver, public QPrinter { public: QtEPSDevice(); virtual ~QtEPSDevice(); - - QString getFileName(char* fileName); - - void savePlot(char* fileName, int ifeps); + + void definePlotName(const char* fileName, int ifeps); + + void savePlot(); - int pageCounter;// public because read and written by plD_eop protected: }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-10 23:52:30
|
Revision: 9708 http://plplot.svn.sourceforge.net/plplot/?rev=9708&view=rev Author: airwin Date: 2009-03-10 23:52:24 +0000 (Tue, 10 Mar 2009) Log Message: ----------- Make driver information consistently terminate with line feed. Modified Paths: -------------- trunk/drivers/aqt.c trunk/drivers/cgm.c trunk/drivers/gcw.c trunk/drivers/gd.c trunk/drivers/impress.c trunk/drivers/ljii.c trunk/drivers/ljiip.c trunk/drivers/mem.c trunk/drivers/ntk.c trunk/drivers/null.c trunk/drivers/pbm.c trunk/drivers/pdf.c trunk/drivers/plmeta.c trunk/drivers/ps.c trunk/drivers/pstex.c trunk/drivers/psttf.cc trunk/drivers/svg.c trunk/drivers/tek.c trunk/drivers/tkwin.c trunk/drivers/xfig.c trunk/drivers/xwinttf.c Modified: trunk/drivers/aqt.c =================================================================== --- trunk/drivers/aqt.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/aqt.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -51,7 +51,7 @@ static NSAutoreleasePool *arpool; /* Objective-C autorelease pool */ static id adapter; /* Adapter object */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_aqt = "aqt:AquaTerm (Mac OS X):1:aqt:50:aqt"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_aqt = "aqt:AquaTerm (Mac OS X):1:aqt:50:aqt\n"; static int currentPlot = 0; static int maxWindows = 30; Modified: trunk/drivers/cgm.c =================================================================== --- trunk/drivers/cgm.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/cgm.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -81,7 +81,7 @@ #include <cd.h> /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_cgm = "cgm:CGM file:0:cgm:44:cgm"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_cgm = "cgm:CGM file:0:cgm:44:cgm\n"; /* Prototypes for functions in this file. */ Modified: trunk/drivers/gcw.c =================================================================== --- trunk/drivers/gcw.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/gcw.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -87,7 +87,7 @@ /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_gcw = "gcw:Gnome Canvas Widget:1:gcw:10:gcw"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_gcw = "gcw:Gnome Canvas Widget:1:gcw:10:gcw\n"; /* Global driver options */ Modified: trunk/drivers/gd.c =================================================================== --- trunk/drivers/gd.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/gd.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -140,7 +140,7 @@ "jpeg:JPEG file:0:gd:40:jpeg\n" #endif #if defined(PLD_gif) - "gif:GIF file:0:gd:47:gif" + "gif:GIF file:0:gd:47:gif\n" #endif ; Modified: trunk/drivers/impress.c =================================================================== --- trunk/drivers/impress.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/impress.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -10,7 +10,7 @@ #include "drivers.h" /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_impress = "imp:Impress File:0:impress:37:imp"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_impress = "imp:Impress File:0:impress:37:imp\n"; /* Function prototypes */ Modified: trunk/drivers/ljii.c =================================================================== --- trunk/drivers/ljii.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/ljii.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -23,7 +23,7 @@ /* Device info */ PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_ljii = - "ljii:LaserJet II Bitmap File (150 dpi):0:ljii:33:ljii"; + "ljii:LaserJet II Bitmap File (150 dpi):0:ljii:33:ljii\n"; /* Function prototypes */ Modified: trunk/drivers/ljiip.c =================================================================== --- trunk/drivers/ljiip.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/ljiip.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -28,7 +28,7 @@ /* Device info */ PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_ljiip = - "ljiip:LaserJet IIp/deskjet compressed graphics:0:ljiip:32:ljiip"; + "ljiip:LaserJet IIp/deskjet compressed graphics:0:ljiip:32:ljiip\n"; /* Function prototypes */ Modified: trunk/drivers/mem.c =================================================================== --- trunk/drivers/mem.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/mem.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -21,7 +21,7 @@ #include "drivers.h" /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_mem = "mem:User-supplied memory device:-1:mem:46:mem"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_mem = "mem:User-supplied memory device:-1:mem:46:mem\n"; void plD_dispatch_init_mem ( PLDispatchTable *pdt ); Modified: trunk/drivers/ntk.c =================================================================== --- trunk/drivers/ntk.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/ntk.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -34,7 +34,7 @@ #include <tk.h> /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_ntk = "ntk:New tk driver:1:ntk:43:ntk"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_ntk = "ntk:New tk driver:1:ntk:43:ntk\n"; void plD_dispatch_init_ntk ( PLDispatchTable *pdt ); Modified: trunk/drivers/null.c =================================================================== --- trunk/drivers/null.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/null.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -10,7 +10,7 @@ #include "drivers.h" /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_null = "null:Null device:-1:null:42:null"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_null = "null:Null device:-1:null:42:null\n"; void plD_dispatch_init_null ( PLDispatchTable *pdt ); Modified: trunk/drivers/pbm.c =================================================================== --- trunk/drivers/pbm.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/pbm.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -14,7 +14,7 @@ #include "drivers.h" /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_pbm = "pbm:PDB (PPM) Driver:0:pbm:38:pbm"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_pbm = "pbm:PDB (PPM) Driver:0:pbm:38:pbm\n"; void plD_dispatch_init_pbm ( PLDispatchTable *pdt ); Modified: trunk/drivers/pdf.c =================================================================== --- trunk/drivers/pdf.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/pdf.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -88,7 +88,7 @@ } pdfdev; /* local variables */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_pdf = "pdf:Portable Document Format PDF:1:pdf:58:pdf"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_pdf = "pdf:Portable Document Format PDF:1:pdf:58:pdf\n"; static jmp_buf env; /*********************************************************************** Modified: trunk/drivers/plmeta.c =================================================================== --- trunk/drivers/plmeta.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/plmeta.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -37,7 +37,7 @@ #include <string.h> /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_plmeta = "plmeta:PLplot Native Meta-File:0:plmeta:26:plm"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_plmeta = "plmeta:PLplot Native Meta-File:0:plmeta:26:plm\n"; void plD_dispatch_init_plm ( PLDispatchTable *pdt ); Modified: trunk/drivers/ps.c =================================================================== --- trunk/drivers/ps.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/ps.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -51,7 +51,7 @@ PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_ps = "ps:PostScript File (monochrome):0:ps:29:psm\n" - "psc:PostScript File (color):0:ps:30:psc"; + "psc:PostScript File (color):0:ps:30:psc\n"; /* Prototypes for functions in this file. */ Modified: trunk/drivers/pstex.c =================================================================== --- trunk/drivers/pstex.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/pstex.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -13,7 +13,7 @@ /* Device info */ PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_pstex = - "pstex:Combined Postscript/LaTeX files:0:pstex:41:pstex"; + "pstex:Combined Postscript/LaTeX files:0:pstex:41:pstex\n"; /*--------------------------------------------------------------------------*\ * plD_init_pstex() Modified: trunk/drivers/psttf.cc =================================================================== --- trunk/drivers/psttf.cc 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/psttf.cc 2009-03-10 23:52:24 UTC (rev 9708) @@ -58,7 +58,7 @@ PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_psttf = "psttf:PostScript File (monochrome):0:psttf:55:psttfm\n" - "psttfc:PostScript File (color):0:psttf:56:psttfc"; + "psttfc:PostScript File (color):0:psttf:56:psttfc\n"; /* Prototypes for functions in this file. */ Modified: trunk/drivers/svg.c =================================================================== --- trunk/drivers/svg.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/svg.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -54,7 +54,7 @@ /* local variables */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_svg = "svg:Scalable Vector Graphics (SVG 1.1):1:svg:57:svg"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_svg = "svg:Scalable Vector Graphics (SVG 1.1):1:svg:57:svg\n"; static int already_warned = 0; Modified: trunk/drivers/tek.c =================================================================== --- trunk/drivers/tek.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/tek.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -49,7 +49,7 @@ "vlt:VLT vt100/tek emulator:1:tek:23:vlt\n" #endif #if defined(PLD_xterm) - "xterm:Xterm Window:1:tek:18:xterm" + "xterm:Xterm Window:1:tek:18:xterm\n" #endif ; Modified: trunk/drivers/tkwin.c =================================================================== --- trunk/drivers/tkwin.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/tkwin.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -80,7 +80,7 @@ #endif /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_tkwin = "tkwin:New tk driver:1:tkwin:45:tkwin"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_tkwin = "tkwin:New tk driver:1:tkwin:45:tkwin\n"; void * ckcalloc(size_t nmemb, size_t size); Modified: trunk/drivers/xfig.c =================================================================== --- trunk/drivers/xfig.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/xfig.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -10,7 +10,7 @@ #include "drivers.h" /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_xfig = "xfig:Fig file:0:xfig:31:xfig"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_xfig = "xfig:Fig file:0:xfig:31:xfig\n"; typedef struct { PLINT xold, yold; Modified: trunk/drivers/xwinttf.c =================================================================== --- trunk/drivers/xwinttf.c 2009-03-10 22:41:34 UTC (rev 9707) +++ trunk/drivers/xwinttf.c 2009-03-10 23:52:24 UTC (rev 9708) @@ -57,7 +57,7 @@ /* local variables */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_xwinttf = "xwinttf:TrueType X Windows Driver:1:xwinttf:59:xwinttf"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_xwinttf = "xwinttf:TrueType X Windows Driver:1:xwinttf:59:xwinttf\n"; static int currentPage = -1; static int XScreen; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-11 00:01:16
|
Revision: 9709 http://plplot.svn.sourceforge.net/plplot/?rev=9709&view=rev Author: airwin Date: 2009-03-11 00:01:06 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Make driver information consistently terminate with line feed. Modified Paths: -------------- trunk/drivers/gnome.c trunk/drivers/linuxvga.c trunk/drivers/tk.c trunk/drivers/wingcc.c trunk/drivers/xwin.c Modified: trunk/drivers/gnome.c =================================================================== --- trunk/drivers/gnome.c 2009-03-10 23:52:24 UTC (rev 9708) +++ trunk/drivers/gnome.c 2009-03-11 00:01:06 UTC (rev 9709) @@ -39,7 +39,7 @@ #include <unistd.h> /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_gnome = "gnome:Gnome Canvas:1:gnome:6:gnome"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_gnome = "gnome:Gnome Canvas:1:gnome:6:gnome\n"; /*#undef DEBUG*/ #define DEBUG Modified: trunk/drivers/linuxvga.c =================================================================== --- trunk/drivers/linuxvga.c 2009-03-10 23:52:24 UTC (rev 9708) +++ trunk/drivers/linuxvga.c 2009-03-11 00:01:06 UTC (rev 9709) @@ -18,7 +18,7 @@ #include <vga.h> /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_linuxvga = "linuxvga:Linux VGA driver:0:linuxvga:8:vga"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_linuxvga = "linuxvga:Linux VGA driver:0:linuxvga:8:vga\n"; /* Function prototypes */ Modified: trunk/drivers/tk.c =================================================================== --- trunk/drivers/tk.c 2009-03-10 23:52:24 UTC (rev 9708) +++ trunk/drivers/tk.c 2009-03-11 00:01:06 UTC (rev 9709) @@ -63,7 +63,7 @@ #endif /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_tk = "tk:Tcl/TK Window:1:tk:7:tk"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_tk = "tk:Tcl/TK Window:1:tk:7:tk\n"; /* Number of instructions to skip between updates */ Modified: trunk/drivers/wingcc.c =================================================================== --- trunk/drivers/wingcc.c 2009-03-10 23:52:24 UTC (rev 9708) +++ trunk/drivers/wingcc.c 2009-03-11 00:01:06 UTC (rev 9709) @@ -62,7 +62,7 @@ /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_wingcc = "wingcc:Win32 (GCC):1:wingcc:9:wingcc"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_wingcc = "wingcc:Win32 (GCC):1:wingcc:9:wingcc\n"; /* Struct to hold device-specific info. */ Modified: trunk/drivers/xwin.c =================================================================== --- trunk/drivers/xwin.c 2009-03-10 23:52:24 UTC (rev 9708) +++ trunk/drivers/xwin.c 2009-03-11 00:01:06 UTC (rev 9709) @@ -45,7 +45,7 @@ #endif /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_xwin = "xwin:X-Window (Xlib):1:xwin:5:xw"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_xwin = "xwin:X-Window (Xlib):1:xwin:5:xw\n"; static int synchronize = 0; /* change to 1 for X synchronized operation */ /* Use "-drvopt sync" cmd line option to set. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-11 02:42:55
|
Revision: 9711 http://plplot.svn.sourceforge.net/plplot/?rev=9711&view=rev Author: airwin Date: 2009-03-11 02:42:36 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Make driver information consistently terminate with line feed. Modified Paths: -------------- trunk/drivers/dg300.c trunk/drivers/hpgl.c Modified: trunk/drivers/dg300.c =================================================================== --- trunk/drivers/dg300.c 2009-03-11 02:40:07 UTC (rev 9710) +++ trunk/drivers/dg300.c 2009-03-11 02:42:36 UTC (rev 9711) @@ -10,7 +10,7 @@ #include "drivers.h" /* Device info */ -PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_dg300 = "dg300:DG300 Terminal:0:dg300:25:dg300"; +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_dg300 = "dg300:DG300 Terminal:0:dg300:25:dg300\n"; void plD_dispatch_init_dg ( PLDispatchTable *pdt ); Modified: trunk/drivers/hpgl.c =================================================================== --- trunk/drivers/hpgl.c 2009-03-11 02:40:07 UTC (rev 9710) +++ trunk/drivers/hpgl.c 2009-03-11 02:42:36 UTC (rev 9711) @@ -45,7 +45,7 @@ "hp7580:HP 7580 Plotter File (Large Plotter):0:hpgl:35:hp7580\n" #endif #if defined(PLD_lj_hpgl) - "lj_hpgl:HP Laserjet III, HPGL emulation mode:0:hpgl:36:lj_hpgl" + "lj_hpgl:HP Laserjet III, HPGL emulation mode:0:hpgl:36:lj_hpgl\n" #endif ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sm...@us...> - 2009-03-11 14:34:09
|
Revision: 9715 http://plplot.svn.sourceforge.net/plplot/?rev=9715&view=rev Author: smekal Date: 2009-03-11 14:33:48 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Applied a patch by Vadim Zeitlin where all inclusions of wx/wx.h are moved to top before any other header inclusions. Otherwise winsock.h may be included before wxWidgets has the chance to include winsock2.h (if compiled with IPv6 support) which leads to compiler errors (on Win32). Modified Paths: -------------- trunk/drivers/wxwidgets.cpp trunk/drivers/wxwidgets_agg.cpp trunk/drivers/wxwidgets_app.cpp trunk/drivers/wxwidgets_dc.cpp trunk/drivers/wxwidgets_gc.cpp Modified: trunk/drivers/wxwidgets.cpp =================================================================== --- trunk/drivers/wxwidgets.cpp 2009-03-11 05:28:45 UTC (rev 9714) +++ trunk/drivers/wxwidgets.cpp 2009-03-11 14:33:48 UTC (rev 9715) @@ -25,6 +25,11 @@ * - NA */ +/* wxwidgets headers */ +#include <wx/wx.h> +#include <wx/wfstream.h> +#include <wx/except.h> + #include "plDevs.h" /* plplot headers */ @@ -34,11 +39,6 @@ /* C/C++ headers */ #include <cstdio> -/* wxwidgets headers */ -#include <wx/wx.h> -#include <wx/wfstream.h> -#include <wx/except.h> - #include "wxwidgets.h" #ifdef __WXMAC__ Modified: trunk/drivers/wxwidgets_agg.cpp =================================================================== --- trunk/drivers/wxwidgets_agg.cpp 2009-03-11 05:28:45 UTC (rev 9714) +++ trunk/drivers/wxwidgets_agg.cpp 2009-03-11 14:33:48 UTC (rev 9715) @@ -24,15 +24,15 @@ * is commented out, since there are problems with the affine transformation */ +/* wxwidgets headers */ +#include <wx/wx.h> +#include <wx/strconv.h> + #include "plDevs.h" /* plplot headers */ #include "plplotP.h" #include "plfci-truetype.h" - -/* wxwidgets headers */ -#include <wx/wx.h> -#include <wx/strconv.h> /* std and driver headers */ #include "wxwidgets.h" Modified: trunk/drivers/wxwidgets_app.cpp =================================================================== --- trunk/drivers/wxwidgets_app.cpp 2009-03-11 05:28:45 UTC (rev 9714) +++ trunk/drivers/wxwidgets_app.cpp 2009-03-11 14:33:48 UTC (rev 9715) @@ -23,6 +23,8 @@ * - Add dialog to get width and height from user for plot size to save. */ +/* wxwidgets headers */ +#include "wx/wx.h" #include "plDevs.h" @@ -33,9 +35,6 @@ #include "drivers.h" #include "plevent.h" -/* wxwidgets headers */ -#include "wx/wx.h" - /* std and driver headers */ #include "wxwidgets.h" Modified: trunk/drivers/wxwidgets_dc.cpp =================================================================== --- trunk/drivers/wxwidgets_dc.cpp 2009-03-11 05:28:45 UTC (rev 9714) +++ trunk/drivers/wxwidgets_dc.cpp 2009-03-11 14:33:48 UTC (rev 9715) @@ -26,14 +26,14 @@ * - implement AddToClipRegion for text correctly */ +/* wxwidgets headers */ +#include <wx/wx.h> + #include "plDevs.h" /* plplot headers */ #include "plplotP.h" -/* wxwidgets headers */ -#include <wx/wx.h> - /* std and driver headers */ #include <cmath> #include "wxwidgets.h" Modified: trunk/drivers/wxwidgets_gc.cpp =================================================================== --- trunk/drivers/wxwidgets_gc.cpp 2009-03-11 05:28:45 UTC (rev 9714) +++ trunk/drivers/wxwidgets_gc.cpp 2009-03-11 14:33:48 UTC (rev 9715) @@ -25,14 +25,14 @@ * - implement AddToClipRegion for text correctly */ +/* wxwidgets headers */ +#include <wx/wx.h> + #include "plDevs.h" /* plplot headers */ #include "plplotP.h" -/* wxwidgets headers */ -#include <wx/wx.h> - /* std and driver headers */ #include "wxwidgets.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sm...@us...> - 2009-03-11 15:30:08
|
Revision: 9718 http://plplot.svn.sourceforge.net/plplot/?rev=9718&view=rev Author: smekal Date: 2009-03-11 15:29:54 +0000 (Wed, 11 Mar 2009) Log Message: ----------- To get rid of Visual C++ warnings, unreferenced variables were removed, explicit type casts added and Debug2 (two arguments) and Debug3 (3 arguments) macros were added. Modified Paths: -------------- trunk/drivers/wingcc.c trunk/drivers/xfig.c Modified: trunk/drivers/wingcc.c =================================================================== --- trunk/drivers/wingcc.c 2009-03-11 14:39:48 UTC (rev 9717) +++ trunk/drivers/wingcc.c 2009-03-11 15:29:54 UTC (rev 9718) @@ -161,6 +161,8 @@ #if defined(_MSC_VER) #define Debug(a) do {if (pls->debug){fprintf(stderr,(a));}}while(0) + #define Debug2(a,b) do {if (pls->debug){fprintf(stderr,(a),(b));}}while(0) + #define Debug3(a,b,c) do {if (pls->debug){fprintf(stderr,(a),(b),(c));}}while(0) #elif defined(__BORLANDC__) #define Debug if (pls->debug) printf #else @@ -623,10 +625,10 @@ dev->scale=(PLFLT)PIXELS_Y/dev->height; } - Debug("Scale = %f (FLT)\n",dev->scale); + Debug2("Scale = %f (FLT)\n",dev->scale); plP_setpxl(dev->scale*pls->xdpi/25.4,dev->scale*pls->ydpi/25.4); - plP_setphy(0, dev->scale*dev->width, 0, dev->scale*dev->height); + plP_setphy(0, (PLINT)(dev->scale*dev->width), 0, (PLINT)(dev->scale*dev->height)); #ifdef HAVE_FREETYPE if (pls->dev_text) @@ -650,10 +652,10 @@ POINT points[2]; - points[0].x=x1a/dev->scale; - points[1].x=x2a/dev->scale; - points[0].y=dev->height - (y1a/dev->scale); - points[1].y=dev->height - (y2a/dev->scale); + points[0].x=(LONG)(x1a/dev->scale); + points[1].x=(LONG)(x2a/dev->scale); + points[0].y=(LONG)(dev->height - (y1a/dev->scale)); + points[1].y=(LONG)(dev->height - (y2a/dev->scale)); dev->oldobject = SelectObject (dev->hdc, dev->pen); @@ -687,8 +689,8 @@ { for (i = 0; i < npts; i++) { - points[i].x = (unsigned long) xa[i]/dev->scale; - points[i].y = (unsigned long) dev->height - (ya[i]/dev->scale); + points[i].x = (LONG)(xa[i]/dev->scale); + points[i].y = (LONG)(dev->height - (ya[i]/dev->scale)); } dev->oldobject = SelectObject (dev->hdc, dev->pen); Polyline(dev->hdc,points,npts); @@ -726,8 +728,8 @@ for (i = 0; i < pls->dev_npts; i++) { - points[i].x = pls->dev_x[i]/dev->scale; - points[i].y = dev->height -(pls->dev_y[i]/dev->scale); + points[i].x = (PLINT)(pls->dev_x[i]/dev->scale); + points[i].y = (PLINT)(dev->height -(pls->dev_y[i]/dev->scale)); } dev->fillbrush = CreateSolidBrush(dev->colour); @@ -999,7 +1001,7 @@ { memcpy(&dev->oldrect,&dev->rect,sizeof(RECT)); GetClientRect(dev->hwnd,&dev->rect); - Debug("[%d %d]",dev->rect.right,dev->rect.bottom); + Debug3("[%d %d]",dev->rect.right,dev->rect.bottom); if ((dev->rect.right>0)&&(dev->rect.bottom>0)) /* Check to make sure it isn't just minimised (i.e. zero size) */ { @@ -1322,8 +1324,7 @@ pls->xdpi=GetDeviceCaps(dev->hdc,HORZRES)/GetDeviceCaps(dev->hdc,HORZSIZE)*25.4; pls->ydpi=GetDeviceCaps(dev->hdc,VERTRES)/GetDeviceCaps(dev->hdc,VERTSIZE)*25.4; plP_setpxl(dev->scale*pls->xdpi/25.4,dev->scale*pls->ydpi/25.4); - plP_setphy(0, dev->scale*dev->width, 0, dev->scale*dev->height); - + plP_setphy(0, (PLINT)(dev->scale*dev->width), 0, (PLINT)(dev->scale*dev->height)); } /*--------------------------------------------------------------------------*\ @@ -1342,8 +1343,6 @@ #endif PRINTDLG Printer; DOCINFO docinfo; - char *PrinterName; - BOOL ret; /* * Reset the docinfo structure to 0 and set it's fields up Modified: trunk/drivers/xfig.c =================================================================== --- trunk/drivers/xfig.c 2009-03-11 14:39:48 UTC (rev 9717) +++ trunk/drivers/xfig.c 2009-03-11 15:29:54 UTC (rev 9718) @@ -141,7 +141,7 @@ pls->color = 1; /* Is a color device */ plP_setpxl(dev->xscale_dev, dev->xscale_dev); /* dpmm -- dots per mm */ - plP_setphy(0, FIGX * dev->xscale_dev, 0, FIGY * dev->yscale_dev); /* physical dimension in mm */ + plP_setphy(0, (PLINT)(FIGX * dev->xscale_dev), 0, (PLINT)(FIGY * dev->yscale_dev)); /* physical dimension in mm */ /* Write out header */ @@ -541,8 +541,8 @@ ref = DPI/72. * ft_ht / 2.; /* rotate point in xfig is lower left corner, compensate */ - args->y = dev->offset + dev->ymax * (int)dev->xscale_dev - (args->y - ref*cos(alpha)); - args->x = args->x + ref*sin(alpha); + args->y = (PLINT)(dev->offset + dev->ymax * (int)dev->xscale_dev - (args->y - ref*cos(alpha))); + args->x = (PLINT)(args->x + ref*sin(alpha)); /* * font family, serie and shape. Currently not supported by plplot This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-11 17:20:00
|
Revision: 9721 http://plplot.svn.sourceforge.net/plplot/?rev=9721&view=rev Author: airwin Date: 2009-03-11 17:19:13 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Rename get-drv-info.c to test-drv-info.c. Implement a test_dyndrivers target that is only created if not cross building. Restore some file dependencies. Greatly simplify cross-build logic. Modified Paths: -------------- trunk/drivers/CMakeLists.txt Added Paths: ----------- trunk/drivers/test-drv-info.c Removed Paths: ------------- trunk/drivers/get-drv-info.c Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-03-11 17:16:40 UTC (rev 9720) +++ trunk/drivers/CMakeLists.txt 2009-03-11 17:19:13 UTC (rev 9721) @@ -41,43 +41,40 @@ ${CMAKE_BINARY_DIR}/include ) - option(TEST_DYNDRIVERS "Test dynamic drivers" OFF) - if(TEST_DYNDRIVERS) + option(TEST_DYNDRIVERS "Test dynamic drivers" ON) + if(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test_dyndrivers_dir) + set_source_files_properties( - get-drv-info.c + test-drv-info.c PROPERTIES COMPILE_FLAGS "-I${LTDL_INCLUDE_DIR} -DUSINGDLL" ) - if(NOT CMAKE_CROSSCOMPILING) - add_executable(get-drv-info get-drv-info.c) - target_link_libraries(get-drv-info - plplot${LIB_TAG} - ${LTDL_LIBRARIES} - ) - set(get-drv-info_RPATH - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/lib/csa - ${CMAKE_BINARY_DIR}/lib/nn - ${CMAKE_BINARY_DIR}/lib/qsastime - ${libplplot${LIB_TAG}_RPATH} - ) - - set_target_properties( - get-drv-info - PROPERTIES - INSTALL_RPATH "${get-drv-info_RPATH}" - BUILD_WITH_INSTALL_RPATH ON - ) - else(NOT CMAKE_CROSSCOMPILING) - set(IMPORT_EXECUTABLES ${CMAKE_NATIVE_BINARY_DIR}/drivers/ImportExecutables.cmake) - include(${IMPORT_EXECUTABLES}) - endif(NOT CMAKE_CROSSCOMPILING) + add_executable(test-drv-info test-drv-info.c) + target_link_libraries(test-drv-info + plplot${LIB_TAG} + ${LTDL_LIBRARIES} + ) + set(test-drv-info_RPATH + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR}/src + ${CMAKE_BINARY_DIR}/lib/csa + ${CMAKE_BINARY_DIR}/lib/nn + ${CMAKE_BINARY_DIR}/lib/qsastime + ${libplplot${LIB_TAG}_RPATH} + ) + + set_target_properties( + test-drv-info + PROPERTIES + INSTALL_RPATH "${test-drv-info_RPATH}" + BUILD_WITH_INSTALL_RPATH ON + ) + get_target_property(test-drv-info_LOCATION test-drv-info LOCATION) + set(test_dyndrivers_FDEPENDS) + set(test_dyndrivers_TDEPENDS test-drv-info) - if(NOT CMAKE_CROSSCOMPILING) - export(TARGETS get-drv-info FILE ${CMAKE_CURRENT_BINARY_DIR}/ImportExecutables.cmake ) - endif(NOT CMAKE_CROSSCOMPILING) - endif(TEST_DYNDRIVERS) + endif(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) foreach(SOURCE_ROOT_NAME ${DRIVERS_LIST}) #message("${SOURCE_ROOT_NAME}_SOURCE = ${${SOURCE_ROOT_NAME}_SOURCE}") @@ -166,28 +163,29 @@ SUFFIX ${DYNAMIC_SUFFIX} ) endif(USE_RPATH) - if(TEST_DYNDRIVERS) + if(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) get_target_property( ${SOURCE_ROOT_NAME}_LOCATION ${SOURCE_ROOT_NAME} LOCATION ) add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_ROOT_NAME}.rc - COMMAND get-drv-info + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_dyndrivers_dir/${SOURCE_ROOT_NAME}.rc + COMMAND test-drv-info ${SOURCE_ROOT_NAME} - > ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_ROOT_NAME}.rc + > ${CMAKE_CURRENT_BINARY_DIR}/test_dyndrivers_dir/${SOURCE_ROOT_NAME}.rc + COMMAND ${CMAKE_COMMAND} -E compare_files + ${CMAKE_CURRENT_BINARY_DIR}/test_dyndrivers_dir/${SOURCE_ROOT_NAME}.rc + ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_ROOT_NAME}.rc DEPENDS ${${SOURCE_ROOT_NAME}_LOCATION} + ${test-drv-info_LOCATION} ) - add_custom_target( - ${SOURCE_ROOT_NAME}_CHECK ALL - DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_ROOT_NAME}.rc + list(APPEND test_dyndrivers_FDEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/test_dyndrivers_dir/${SOURCE_ROOT_NAME}.rc ) - # Workaround CMake 2-level make recursion issue for parallel builds. - add_dependencies(${SOURCE_ROOT_NAME}_CHECK ${SOURCE_ROOT_NAME}) - endif(TEST_DYNDRIVERS) + list(APPEND test_dyndrivers_TDEPENDS ${SOURCE_ROOT_NAME}) + endif(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) install(TARGETS ${SOURCE_ROOT_NAME} DESTINATION ${DRV_DIR}) install( @@ -195,5 +193,11 @@ DESTINATION ${DRV_DIR} ) endforeach(SOURCE_ROOT_NAME ${DRIVERS_LIST}) + if(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) + add_custom_target(test_dyndrivers + DEPENDS ${test_dyndrivers_FDEPENDS} + ) + add_dependencies(test_dyndrivers ${test_dyndrivers_TDEPENDS}) + endif(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) endif(ENABLE_DYNDRIVERS) Deleted: trunk/drivers/get-drv-info.c =================================================================== --- trunk/drivers/get-drv-info.c 2009-03-11 17:16:40 UTC (rev 9720) +++ trunk/drivers/get-drv-info.c 2009-03-11 17:19:13 UTC (rev 9721) @@ -1,80 +0,0 @@ -/* Get device info from PLplot driver module - * - * Copyright (C) 2003 Rafael Laboissiere - * Copyright (C) 2004 Joao Cardoso - * - * This file is part of PLplot. - * - * PLplot is free software; you can redistribute it and/or modify it under - * the terms of the GNU Library General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * PLplot is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library - * General Public License for more details. - - * You should have received a copy of the GNU Library General Public License - * along with the GNU C Library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02110-1301, USA. - */ - -#include "plplotP.h" -#ifndef LTDL_WIN32 - #include <ltdl.h> -#else - #include "ltdl_win32.h" -#endif -#include <stdio.h> -#include <signal.h> -#include <stdlib.h> - -#define SYM_LEN 300 -#define DRVSPEC_LEN 400 - -/* SEGV signal handler */ -RETSIGTYPE -catch_segv (int sig) -{ - fprintf (stderr, "libltdl error: %s\n", lt_dlerror ()); - exit (1); -} - -int -main (int argc, char* argv[]) -{ - lt_dlhandle dlhand; - char sym[SYM_LEN]; - char* drvnam = argv[1]; - char drvspec[ DRVSPEC_LEN ]; - char** info; - - /* Establish a handler for SIGSEGV signals. */ - signal (SIGSEGV, catch_segv); - - lt_dlinit (); -#ifdef LTDL_WIN32 - snprintf( drvspec, DRVSPEC_LEN, "%s", drvnam ); -#else - snprintf( drvspec, DRVSPEC_LEN, "%s/%s", plGetDrvDir (), drvnam ); -#endif /* LTDL_WIN32 */ - dlhand = lt_dlopenext (drvspec); - if (dlhand == NULL) { - fprintf (stderr, "Could not open driver module %s\n" - "libltdl error: %s\n", drvspec, lt_dlerror ()); - return 1; - } - snprintf (sym, SYM_LEN, "plD_DEVICE_INFO_%s", drvnam); - info = (char **) lt_dlsym (dlhand, sym); - if (info != NULL) { - printf ("%s", *info); - return 0; - } - else { - fprintf (stderr, "Could not read symbol %s in driver module %s\n" - "libltdl error: %s\n", sym, drvspec, lt_dlerror ()); - return 1; - } -} Copied: trunk/drivers/test-drv-info.c (from rev 9717, trunk/drivers/get-drv-info.c) =================================================================== --- trunk/drivers/test-drv-info.c (rev 0) +++ trunk/drivers/test-drv-info.c 2009-03-11 17:19:13 UTC (rev 9721) @@ -0,0 +1,80 @@ +/* Get device info from PLplot driver module + * + * Copyright (C) 2003 Rafael Laboissiere + * Copyright (C) 2004 Joao Cardoso + * + * This file is part of PLplot. + * + * PLplot is free software; you can redistribute it and/or modify it under + * the terms of the GNU Library General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * PLplot is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library + * General Public License for more details. + + * You should have received a copy of the GNU Library General Public License + * along with the GNU C Library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02110-1301, USA. + */ + +#include "plplotP.h" +#ifndef LTDL_WIN32 + #include <ltdl.h> +#else + #include "ltdl_win32.h" +#endif +#include <stdio.h> +#include <signal.h> +#include <stdlib.h> + +#define SYM_LEN 300 +#define DRVSPEC_LEN 400 + +/* SEGV signal handler */ +RETSIGTYPE +catch_segv (int sig) +{ + fprintf (stderr, "libltdl error: %s\n", lt_dlerror ()); + exit (1); +} + +int +main (int argc, char* argv[]) +{ + lt_dlhandle dlhand; + char sym[SYM_LEN]; + char* drvnam = argv[1]; + char drvspec[ DRVSPEC_LEN ]; + char** info; + + /* Establish a handler for SIGSEGV signals. */ + signal (SIGSEGV, catch_segv); + + lt_dlinit (); +#ifdef LTDL_WIN32 + snprintf( drvspec, DRVSPEC_LEN, "%s", drvnam ); +#else + snprintf( drvspec, DRVSPEC_LEN, "%s/%s", plGetDrvDir (), drvnam ); +#endif /* LTDL_WIN32 */ + dlhand = lt_dlopenext (drvspec); + if (dlhand == NULL) { + fprintf (stderr, "Could not open driver module %s\n" + "libltdl error: %s\n", drvspec, lt_dlerror ()); + return 1; + } + snprintf (sym, SYM_LEN, "plD_DEVICE_INFO_%s", drvnam); + info = (char **) lt_dlsym (dlhand, sym); + if (info != NULL) { + printf ("%s", *info); + return 0; + } + else { + fprintf (stderr, "Could not read symbol %s in driver module %s\n" + "libltdl error: %s\n", sym, drvspec, lt_dlerror ()); + return 1; + } +} Property changes on: trunk/drivers/test-drv-info.c ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-11 17:59:12
|
Revision: 9724 http://plplot.svn.sourceforge.net/plplot/?rev=9724&view=rev Author: airwin Date: 2009-03-11 17:59:00 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Initial commit of template files for all tk-related devices. These were generated directly by the test-drv-info command that was run by the test_dyndrivers target. Added Paths: ----------- trunk/drivers/ntk.rc.in trunk/drivers/tk.rc.in trunk/drivers/tkwin.rc.in Added: trunk/drivers/ntk.rc.in =================================================================== --- trunk/drivers/ntk.rc.in (rev 0) +++ trunk/drivers/ntk.rc.in 2009-03-11 17:59:00 UTC (rev 9724) @@ -0,0 +1 @@ +ntk:New tk driver:1:ntk:43:ntk Property changes on: trunk/drivers/ntk.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/tk.rc.in =================================================================== --- trunk/drivers/tk.rc.in (rev 0) +++ trunk/drivers/tk.rc.in 2009-03-11 17:59:00 UTC (rev 9724) @@ -0,0 +1 @@ +tk:Tcl/TK Window:1:tk:7:tk Property changes on: trunk/drivers/tk.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/tkwin.rc.in =================================================================== --- trunk/drivers/tkwin.rc.in (rev 0) +++ trunk/drivers/tkwin.rc.in 2009-03-11 17:59:00 UTC (rev 9724) @@ -0,0 +1 @@ +tkwin:New tk driver:1:tkwin:45:tkwin Property changes on: trunk/drivers/tkwin.rc.in ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-11 23:04:20
|
Revision: 9726 http://plplot.svn.sourceforge.net/plplot/?rev=9726&view=rev Author: airwin Date: 2009-03-11 23:04:09 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Add alpha channel opacity support to the qt device driver. Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-11 18:22:33 UTC (rev 9725) +++ trunk/drivers/qt.cpp 2009-03-11 23:04:09 UTC (rev 9726) @@ -6,6 +6,7 @@ Imperial College, London Copyright (C) 2009 Imperial College, London + Copyright (C) 2009 Alan W. Irwin This is free software; you can redistribute it and/or modify it under the terms of the GNU General Lesser Public License as published @@ -202,14 +203,14 @@ delete[] polygon; } -void QtPLDriver::setColor(int r, int g, int b) +void QtPLDriver::setColor(int r, int g, int b, int a) { QPen p=m_painterP->pen(); - p.setColor(QColor(r, g, b)); + p.setColor(QColor(r, g, b, a)); m_painterP->setPen(p); QBrush B=m_painterP->brush(); - B.setColor(QColor(r, g, b)); + B.setColor(QColor(r, g, b, a)); m_painterP->setBrush(B); } @@ -530,13 +531,14 @@ m_listBuffer.append(el); } -void QtPLBufferedDriver::setColor(int r, int g, int b) +void QtPLBufferedDriver::setColor(int r, int g, int b, int a) { BufferElement el; el.Element=SET_COLOUR; el.Data.ColourStruct.R=r; el.Data.ColourStruct.G=g; el.Data.ColourStruct.B=b; + el.Data.ColourStruct.A=a; m_listBuffer.append(el); } @@ -633,9 +635,9 @@ break; case SET_COLOUR: - p.setColor(QColor(i->Data.ColourStruct.R, i->Data.ColourStruct.G, i->Data.ColourStruct.B)); + p.setColor(QColor(i->Data.ColourStruct.R, i->Data.ColourStruct.G, i->Data.ColourStruct.B, i->Data.ColourStruct.A)); i_painterP->setPen(p); - b.setColor(QColor(i->Data.ColourStruct.R, i->Data.ColourStruct.G, i->Data.ColourStruct.B)); + b.setColor(QColor(i->Data.ColourStruct.R, i->Data.ColourStruct.G, i->Data.ColourStruct.B, i->Data.ColourStruct.A)); i_painterP->setBrush(b); break; @@ -700,7 +702,7 @@ #endif if(widget==NULL) return; - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b); + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, (int)(255.*pls->curcolor.a)); widget->drawLine(x1a, y1a, x2a, y2a); } @@ -725,7 +727,7 @@ #endif if(widget==NULL) return; - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b); + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, (int)(255.*pls->curcolor.a)); widget->drawPolyline(xa, ya, npts); } @@ -756,7 +758,7 @@ { case PLESC_DASH: widget->setDashed(pls->nms, pls->mark, pls->space); - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b); + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, (int)(255.*pls->curcolor.a)); widget->drawPolyline(pls->dev_x, pls->dev_y, pls->dev_npts); widget->setSolid(); break; @@ -770,7 +772,7 @@ xa[i] = pls->dev_x[i]; ya[i] = pls->dev_y[i]; } - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b); + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, (int)(255.*pls->curcolor.a)); widget->drawPolygon(xa, ya, pls->dev_npts); delete[] xa; @@ -813,11 +815,11 @@ break; case PLSTATE_COLOR0: - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b); + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, (int)(255.*pls->curcolor.a)); break; case PLSTATE_COLOR1: - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b); + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, (int)(255.*pls->curcolor.a)); break; Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-11 18:22:33 UTC (rev 9725) +++ trunk/drivers/qt.h 2009-03-11 23:04:09 UTC (rev 9726) @@ -6,6 +6,7 @@ Imperial College, London Copyright (C) 2009 Imperial College, London + Copyright (C) 2009 Alan W. Irwin This is free software; you can redistribute it and/or modify it under the terms of the GNU General Lesser Public License as published @@ -89,7 +90,7 @@ struct ColourStruct_ { - PLINT R, G, B; + PLINT R, G, B, A; } ColourStruct; PLINT intParam; @@ -113,7 +114,7 @@ virtual void drawPolygon(short * x, short * y, PLINT npts); - virtual void setColor(int r, int g, int b); + virtual void setColor(int r, int g, int b, int a); virtual void setWidth(PLINT w); @@ -145,7 +146,7 @@ virtual void drawPolygon(short * x, short * y, PLINT npts); - virtual void setColor(int r, int g, int b); + virtual void setColor(int r, int g, int b, int a); virtual void setWidth(PLINT r); @@ -332,10 +333,10 @@ currentWidget->drawPolygon(x, y, npts); } - virtual void setColor(int r, int g, int b) + virtual void setColor(int r, int g, int b, int a) { if(currentWidget==NULL) newTab(); - currentWidget->setColor(r, g, b); + currentWidget->setColor(r, g, b, a); } virtual void setWidth(PLINT w) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sm...@us...> - 2009-03-12 08:19:40
|
Revision: 9728 http://plplot.svn.sourceforge.net/plplot/?rev=9728&view=rev Author: smekal Date: 2009-03-12 08:19:17 +0000 (Thu, 12 Mar 2009) Log Message: ----------- To get rid of Visual C++ warnings explicit type casts were added. Modified Paths: -------------- trunk/drivers/cgm.c trunk/drivers/ps.c trunk/drivers/svg.c Modified: trunk/drivers/cgm.c =================================================================== --- trunk/drivers/cgm.c 2009-03-12 08:18:31 UTC (rev 9727) +++ trunk/drivers/cgm.c 2009-03-12 08:19:17 UTC (rev 9728) @@ -185,7 +185,6 @@ plD_init_cgm_Dev(PLStream *pls) { cgm_Dev *dev; - int i; /* Allocate and initialize device-specific data */ @@ -208,8 +207,6 @@ dev->fill_colour=dev->colour; /* initially set fill and line colour the same */ dev->last_fill_colour=-1; /* set to -1 = unallocated */ dev->last_line_colour=-1; /* set to -1 = unallocated */ - - } /*----------------------------------------------------------------------*\ Modified: trunk/drivers/ps.c =================================================================== --- trunk/drivers/ps.c 2009-03-12 08:18:31 UTC (rev 9727) +++ trunk/drivers/ps.c 2009-03-12 08:19:17 UTC (rev 9728) @@ -735,7 +735,7 @@ #define PROC_STR_STRING_LENGTH 1000 unsigned char *strp, str[PROC_STR_STRING_LENGTH], *cur_strp, cur_str[PROC_STR_STRING_LENGTH]; - float font_factor = 1.4; + float font_factor = 1.4f; PLINT clxmin, clxmax, clymin, clymax; /* Clip limits */ PLINT clipx[4],clipy[4]; /* Current clip limits */ @@ -852,8 +852,8 @@ /* Determine the adjustment for page orientation */ theta -= 90.*pls->diorot; - args->y += offset*cos(theta*PI/180.); - args->x -= offset*sin(theta*PI/180.); + args->y += (PLINT)(offset*cos(theta*PI/180.)); + args->x -= (PLINT)(offset*sin(theta*PI/180.)); /* ps driver is rotated by default */ plRotPhy(ORIENTATION, dev->xmin, dev->ymin, dev->xmax, dev->ymax, @@ -1019,10 +1019,10 @@ l1 *= 0.6; l2 *= 0.6; - dev->llx = MIN(dev->llx, args->x + (MIN(l1*cs,l2*cs)-1.5) * font_factor * ft_ht * ENLARGE ); - dev->lly = MIN(dev->lly, args->y + (MIN(l1*sn,l2*sn)-1.5) * font_factor * ft_ht * ENLARGE ); - dev->urx = MAX(dev->urx, args->x + (MAX(l1*cs,l2*cs)+1.5) * font_factor * ft_ht * ENLARGE ); - dev->ury = MAX(dev->ury, args->y + (MAX(l1*sn,l2*sn)+1.5) * font_factor * ft_ht * ENLARGE ); + dev->llx = (int)(MIN(dev->llx, args->x + (MIN(l1*cs,l2*cs)-1.5) * font_factor * ft_ht * ENLARGE)); + dev->lly = (int)(MIN(dev->lly, args->y + (MIN(l1*sn,l2*sn)-1.5) * font_factor * ft_ht * ENLARGE)); + dev->urx = (int)(MAX(dev->urx, args->x + (MAX(l1*cs,l2*cs)+1.5) * font_factor * ft_ht * ENLARGE)); + dev->ury = (int)(MAX(dev->ury, args->y + (MAX(l1*sn,l2*sn)+1.5) * font_factor * ft_ht * ENLARGE)); } } Modified: trunk/drivers/svg.c =================================================================== --- trunk/drivers/svg.c 2009-03-12 08:18:31 UTC (rev 9727) +++ trunk/drivers/svg.c 2009-03-12 08:19:17 UTC (rev 9728) @@ -962,7 +962,7 @@ short desired_offset(short level, double ftHt) { if(level != 0){ - return -level * ftHt * pow(0.6, abs(level)); + return (short)(-level * ftHt * pow(0.6, abs(level))); } else{ return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-12 15:32:22
|
Revision: 9729 http://plplot.svn.sourceforge.net/plplot/?rev=9729&view=rev Author: airwin Date: 2009-03-12 15:31:50 +0000 (Thu, 12 Mar 2009) Log Message: ----------- AWI for Alban Rochel. Major update/reorganization. Changes: - Qt-based font support - alpha blending - fixed memory leaks, at least every one I could identify. Among the leaks and problems identified by valgrind, some are related to Qt, but they appear even on minimal Qt examples (a simple empty QApplication). - hopefully fixed all crashed and segfaults - fixed non-filled areas problems on example 30 - Large clean-up of the driver architecture. Working on the fonts, I've found Qt classes allowing me to simplify *much* the interactive driver. The QtPLBufferedDriver class is not used any more. - the output size parameter is taken into account (I had forgotten this one in the previous releases, letting everything to the default A4 size), except for EPS/PDF: Qt 4.2 and 4.3 require a standard paper size. I've left it to A4. Bugs: - I've had lots of issues with the SVG driver to have correct text placement. I've decided to give up for the moment, unless I've missed something I believe I've found a bug in Qt. I've made a quick and dirty fix which still leaves imperfect text offsets. I'll investigate a little, and do a bug report to Qt if it is indeed a Qt bug. [AWI comment: our experience is this symptom is often a result of text placement bugs in Linux SVG viewers. For example, anything related to GNOME (eog) or ImageMagick uses the librsvg2 library which has a bug with regard to SVG text placement. For reliable text-placement results use konqueror to view *.svg files. When I do that for example 2, I find the numbers displaced to the right a small amount, but that may be due to Alban's "quick and dirty" fix to match bugs in the SVG viewer he used.] - No symbols on the x01 plots for the raster, EPS/PDF and interactive drivers. No idea why, I remember seeing them at some point (!), but for the moment (until the next release), let's forget them... - The number of displayed symbols in example 23 is much smaller than with other devices. I don't know much of font handling and unicode, so I don't know if it is a Qt limitation or if I can do something about it (which I suppose). Again, I'll deal with that in a future release. - [AWI] Characters too small by roughly a factor of two. Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-12 08:19:17 UTC (rev 9728) +++ trunk/drivers/qt.cpp 2009-03-12 15:31:50 UTC (rev 9729) @@ -6,7 +6,6 @@ Imperial College, London Copyright (C) 2009 Imperial College, London - Copyright (C) 2009 Alan W. Irwin This is free software; you can redistribute it and/or modify it under the terms of the GNU General Lesser Public License as published @@ -32,6 +31,12 @@ #include "qt.h" +// global variables initialised in init(), used in tidy() +// QApplication* app=NULL; +int argc; // argc and argv have to exist when tidy() is used, thus they are made global +char ** argv; +int appCounter=0; // to be rigorous, all uses should be placed between mutexes + // Drivers declaration PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_qt = #if defined(PLD_bmpqt) @@ -63,6 +68,35 @@ #endif ; +void initQtApp() +{ + ++appCounter; + if(qApp==NULL && appCounter==1) + { + argc=1; + argv=new char*[2]; + argv[0]=new char[10]; + argv[1]=new char[1]; + snprintf(argv[0], 10, "qt_driver"); + argv[1][0]='\0'; + /*app=*/new QApplication(argc, argv); + } +} + +void closeQtApp() +{ + --appCounter; + if(qApp!=NULL && appCounter==0) + { + delete qApp; +// qApp=NULL; + delete[] argv[0]; + delete[] argv[1]; + delete[] argv; + argv=NULL; + } +} + /*--------------------------------------------------------------------- qt_family_check () @@ -152,7 +186,7 @@ void plD_line_qt(PLStream *, short, short, short, short); void plD_polyline_qt(PLStream *, short*, short*, PLINT); void plD_bop_qt(PLStream *){} -void plD_tidy_qt(PLStream *){} +void plD_tidy_qt(PLStream *); void plD_state_qt(PLStream *, PLINT); void plD_esc_qt(PLStream *, PLINT, void*); @@ -163,6 +197,8 @@ m_dWidth=i_iWidth; m_dHeight=i_iHeight; downscale=1.; + svgBugFactor=1.; +// fontScalingFactor=1.; } QtPLDriver::~QtPLDriver() @@ -203,481 +239,238 @@ delete[] polygon; } -void QtPLDriver::setColor(int r, int g, int b, int a) -{ - QPen p=m_painterP->pen(); - p.setColor(QColor(r, g, b, a)); - m_painterP->setPen(p); - - QBrush B=m_painterP->brush(); - B.setColor(QColor(r, g, b, a)); - m_painterP->setBrush(B); -} +// QRect getNewRect(const QRect& input, double yOffset, double fontSize) +// { +// return QRect(input.right(), -yOffset*fontSize, 2, 2); +// } -void QtPLDriver::setWidth(PLINT w) +QFont QtPLDriver::getFont(PLUNICODE unicode) { - QPen p=m_painterP->pen(); - p.setWidth(w); - m_painterP->setPen(p); -} + // Get new font parameters + unsigned char fontFamily, fontStyle, fontWeight; -void QtPLDriver::setDashed(PLINT nms, PLINT* mark, PLINT* space) -{ - // 72 dpi - // => 72/25400 = 0.00283 dot for 1 micron - QVector<qreal> vect; - for(int i=0; i<nms; ++i) + plP_fci2hex(unicode, &fontFamily, PL_FCI_FAMILY); + plP_fci2hex(unicode, &fontStyle, PL_FCI_STYLE); + plP_fci2hex(unicode, &fontWeight, PL_FCI_WEIGHT); + + QFont f; + f.setPointSizeF(currentFontSize*currentFontScale<4 ? 4 : currentFontSize*currentFontScale); + + switch(fontFamily) { - vect << (PLFLT)mark[i]*0.00283; - vect << (PLFLT)space[i]*0.00283; + case 1: f.setFamily("serif"); break; + case 2: f.setFamily("monospace"); break; + case 3: f.setFamily("script"); break; + case 4: f.setFamily("symbol"); break; + case 0: default: f.setFamily("sans-serif"); break; } - QPen p=m_painterP->pen(); - p.setDashPattern(vect); - m_painterP->setPen(p); + if(fontStyle) f.setItalic(true); + if(fontWeight) f.setWeight(QFont::Bold); + else f.setWeight(QFont::Normal); + + f.setUnderline(underlined); + f.setOverline(overlined); + + return f; } -void QtPLDriver::setSolid() +void QtPLDriver::drawTextInPicture(QPainter* p, const QString& text) { - QPen p=m_painterP->pen(); - p.setStyle(Qt::SolidLine); - m_painterP->setPen(p); -} + QPicture tempPic; + QPainter tempPainter(&tempPic); + tempPainter.setFont(p->font()); + QRectF rect(0., 0., 1., 1.); + QRectF bounding; + tempPainter.drawText(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text, &bounding); -#if 0 -/*--------------------------------------------------------------------- - Font style and weight lookup tables - ---------------------------------------------------------------------*/ -/*$$ These are lookup tables what the actual wxWidgets codes are needed - to set the font -const wxFontFamily fontFamilyLookup[5] = { - wxFONTFAMILY_SWISS, // sans-serif - wxFONTFAMILY_ROMAN, // serif - wxFONTFAMILY_TELETYPE, // monospace - wxFONTFAMILY_SCRIPT, // script - wxFONTFAMILY_ROMAN // symbol -}; +// For svg debug +// 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()); +// tempPainter.drawLine(bounding.right(), bounding.bottom(), bounding.right(), bounding.top()); +// tempPainter.drawLine(0., bounding.bottom()+5., 0., bounding.top()-5.); + tempPainter.end(); -const int fontStyleLookup[3] = { - wxFONTFLAG_DEFAULT, // upright - wxFONTFLAG_ITALIC, // italic - wxFONTFLAG_SLANT // oblique -}; - -const int fontWeightLookup[2] = { - wxFONTFLAG_DEFAULT, // medium - wxFONTFLAG_BOLD // bold -}; -*/ - -void ProcessString( PLStream* pls, EscText* args ) -{ - /* Check that we got unicode, warning message and return if not */ - if( args->unicode_array_len == 0 ) { - printf( "Non unicode string passed to a cairo driver, ignoring\n" ); - return; - } + p->drawPicture(xOffset+bounding.width()/2., -yOffset, tempPic); - /* Check that unicode string isn't longer then the max we allow */ - if( args->unicode_array_len >= 500 ) { - printf( "Sorry, the QT drivers only handles strings of length < %d\n", 500 ); - return; - } - - /* Calculate the font size (in pixels) */ - /*$$ this is driver specific - we need the actual pixels if raster device - otherwise correct scaled size (determined more or less empirically - fontSize = pls->chrht * VIRTUAL_PIXELS_PER_MM/scaley * 1.3; */ - - /* calculate rotation of text */ - plRotationShear( args->xform, &rotation, &shear, &stride); - rotation -= pls->diorot * M_PI / 2.0; - cos_rot = cos( rotation ); - sin_rot = sin( rotation ); - /* Set font color */ - //$$ don't know if needed - - /* First just determine text width and height, by processing the whole code - without do the actual drawing */ - posX = args->x; - posY = args->y; - PSDrawText( args->unicode_array, args->unicode_array_len, false ); - - /* now process the text again, this time draw it */ - posX = (PLINT) (args->x-(args->just*textWidth)*scalex*cos_rot-(0.5*textHeight)*scalex*sin_rot); - posY = (PLINT) (args->y-(args->just*textWidth)*scaley*sin_rot+(0.5*textHeight)*scaley*cos_rot); - PSDrawText( args->unicode_array, args->unicode_array_len, true ); + xOffset+=bounding.width()/svgBugFactor; } -void PSDrawText( PLUNICODE* ucs4, int ucs4Len, bool drawText ) +QPicture QtPLDriver::getTextPicture(PLUNICODE* text, int len, int chrht) { - int i = 0; - - char utf8_string[max_string_length]; - char utf8[5]; - memset( utf8_string, '\0', max_string_length ); - - /* Get PLplot escape character */ - char plplotEsc; - plgesc( &plplotEsc ); - - /* Get the curent font */ - fontScale = 1.0; - yOffset = 0.0; - PLUNICODE fci; - plgfci( &fci ); - PSSetFont( fci ); - textWidth=0; - textHeight=0; - - while( i < ucs4Len ) { - if( ucs4[i] < PL_FCI_MARK ) { /* not a font change */ - if( ucs4[i] != (PLUNICODE)plplotEsc ) { /* a character to display */ - ucs4_to_utf8( ucs4[i], utf8 ); - strncat( utf8_string, utf8, max_string_length ); - i++; - continue; - } - i++; - if( ucs4[i] == (PLUNICODE)plplotEsc ) { /* a escape character to display */ - ucs4_to_utf8( ucs4[i], utf8 ); - strncat( utf8_string, utf8, max_string_length ); - i++; - continue; - } else { - if( ucs4[i] == (PLUNICODE)'u' ) { /* Superscript */ - // draw string so far - PSDrawTextToDC( utf8_string, drawText ); - - // change font scale - if( yOffset<0.0 ) - fontScale *= 1.25; /* Subscript scaling parameter */ - else - fontScale *= 0.8; /* Subscript scaling parameter */ - PSSetFont( fci ); - - yOffset += scaley * fontSize * fontScale / 2.; - } - if( ucs4[i] == (PLUNICODE)'d' ) { /* Subscript */ - // draw string so far - PSDrawTextToDC( utf8_string, drawText ); - - // change font scale - double old_fontScale=fontScale; - if( yOffset>0.0 ) - fontScale *= 1.25; /* Subscript scaling parameter */ - else - fontScale *= 0.8; /* Subscript scaling parameter */ - PSSetFont( fci ); - - yOffset -= scaley * fontSize * old_fontScale / 2.; - } - if( ucs4[i] == (PLUNICODE)'-' ) { /* underline */ - // draw string so far - PSDrawTextToDC( utf8_string, drawText ); - - underlined = !underlined; - PSSetFont( fci ); - } - if( ucs4[i] == (PLUNICODE)'+' ) { /* overline */ - /* not implemented yet */ - } - i++; - } - } else { /* a font change */ - // draw string so far - PSDrawTextToDC( utf8_string, drawText ); - - // get new font - fci = ucs4[i]; - PSSetFont( fci ); - i++; - } - } - - PSDrawTextToDC( utf8_string, drawText ); -} - -void PSSetFont( PLUNICODE fci ) -{ - unsigned char fontFamily, fontStyle, fontWeight; - - plP_fci2hex( fci, &fontFamily, PL_FCI_FAMILY ); - plP_fci2hex( fci, &fontStyle, PL_FCI_STYLE ); - plP_fci2hex( fci, &fontWeight, PL_FCI_WEIGHT ); - - /*$$ In the next part I delete the old font, get a new font depending - on fontFamily, fontStyle, fontWeight, set underlined option - and set the font */ + char plplotEsc; + plgesc( &plplotEsc ); + PLUNICODE fci; + plgfci( &fci ); + + double old_fontScale; - /*if( m_font ) - delete m_font; - - m_font=wxFont::New((int) (fontSize*fontScale<4 ? 4 : fontSize*fontScale), - fontFamilyLookup[fontFamily], - fontStyleLookup[fontStyle] & fontWeightLookup[fontWeight] ); - m_font->SetUnderlined( underlined ); - m_dc->SetFont( *m_font );*/ -} + QPicture res; + QPainter p(&res); + + QString currentString; -void PSDrawTextToDC( char* utf8_string, bool drawText ) -{ - /*$$ width, height; d, l are not used here - wxCoord w, h, d, l; */ + yOffset=0.; + xOffset=0.; - /*$$ convert utf8 to current Encoding and get text extent - wxString str(wxConvUTF8.cMB2WC(utf8_string), *wxConvCurrent); - m_dc->GetTextExtent( str, &w, &h, &d, &l ); */ - - /*$$ do the actual drawing (second time) - if( drawText ) - m_dc->DrawRotatedText( str, (wxCoord) ((posX-yOffset*sin_rot)/scalex), - (wxCoord) (height-(posY+yOffset*cos_rot)/scaley), - rotation*180.0/M_PI ); */ - - /*$$ calculate the new position where the next text will be written, - and determine textWidth and textHeight - posX += (PLINT) (w*scalex*cos_rot); - posY += (PLINT) (w*scalex*sin_rot); - textWidth += w; - textHeight = (wxCoord) (textHeight>(h+yOffset/scaley) ? textHeight : (h+yOffset/scaley)); */ - - /* clear string as we don't need it anymore */ - memset( utf8_string, '\0', max_string_length ); -} -#endif + currentFontSize=chrht*p.device()->logicalDpiY()/25.4*fontScalingFactor; + currentFontScale=1.; + underlined=false; + overlined=false; + + p.setFont(getFont(fci)); + + int i=0; + while(i < len) + { + if(text[i]<PL_FCI_MARK) // Not a font change + { + if(text[i]!=(PLUNICODE)plplotEsc) + { + currentString.append(QString((QChar*)&(text[i]), 1)); + ++i; + continue; + } + ++i; // Now analyse the escaped character + switch(text[i]) + { + case 'd': + drawTextInPicture(&p, currentString); + + currentString.clear(); + old_fontScale=currentFontScale; + if( yOffset>0.0 ) + currentFontScale *= 1.25; /* Subscript scaling parameter */ + else + currentFontScale *= 0.8; /* Subscript scaling parameter */ -//////////// Buffered driver /////////////////////// + yOffset -= currentFontSize * old_fontScale / 2.; + + p.setFont(getFont(fci)); + break; + case 'u': + drawTextInPicture(&p, currentString); + + currentString.clear(); + if( yOffset<0.0 ) + currentFontScale *= 1.25; /* Subscript scaling parameter */ + else + currentFontScale *= 0.8; /* Subscript scaling parameter */ -QtPLBufferedDriver::QtPLBufferedDriver(PLINT i_iWidth, PLINT i_iHeight): - QtPLDriver(i_iWidth, i_iHeight) -{} + yOffset += currentFontSize * currentFontScale / 2.; + p.setFont(getFont(fci)); + break; + case '-': + drawTextInPicture(&p, currentString); + + currentString.clear(); + underlined=!underlined; + p.setFont(getFont(fci)); + break; + case '+': + drawTextInPicture(&p, currentString); -QtPLBufferedDriver::~QtPLBufferedDriver() -{ - clearBuffer(); -} - -void QtPLBufferedDriver::clearBuffer() -{ - for(QLinkedList<BufferElement>::iterator i=m_listBuffer.begin(); i!=m_listBuffer.end(); ++i) - - { - switch(i->Element) + currentString.clear(); + overlined=!overlined; + p.setFont(getFont(fci)); + break; + case '#': + currentString.append(QString((QChar*)&(text[i]), 1)); + break; + default : + std::cout << "unknown escape char " << ((QChar)text[i]).toLatin1() << std::endl; + break; + } + } + else // Font change { - case POLYLINE: - case POLYGON: - delete[] i->Data.PolylineStruct.x; - delete[] i->Data.PolylineStruct.y; - break; - - case SET_DASHED: - delete[] i->Data.PolylineStruct.x; - break; - - default: - break; + drawTextInPicture(&p, currentString); + + currentString.clear(); + fci=text[i]; + p.setFont(getFont(fci)); } + ++i; } - - m_listBuffer.clear(); + drawTextInPicture(&p, currentString); + + p.end(); + return res; } -void QtPLBufferedDriver::drawLine(short x1, short y1, short x2, short y2) +void QtPLDriver::drawText(PLStream* pls, EscText* txt) { - BufferElement el; - el.Element=LINE; - el.Data.LineStruct.x1=(PLFLT)x1*downscale; - el.Data.LineStruct.y1=m_dHeight-(PLFLT)(y1*downscale); - el.Data.LineStruct.x2=(PLFLT)x2*downscale; - el.Data.LineStruct.y2=m_dHeight-(PLFLT)(y2*downscale); - - m_listBuffer.append(el); -} - -void QtPLBufferedDriver::drawPolyline(short * x, short * y, PLINT npts) -{ - BufferElement el; - el.Element=POLYLINE; - el.Data.PolylineStruct.npts=(PLINT)npts; - el.Data.PolylineStruct.x=new PLFLT[npts]; - el.Data.PolylineStruct.y=new PLFLT[npts]; - for(int i=0; i<npts; ++i) - { - el.Data.PolylineStruct.x[i]=(PLFLT)(x[i])*downscale; - el.Data.PolylineStruct.y[i]=m_dHeight-(PLFLT)((y[i])*downscale); + /* Check that we got unicode, warning message and return if not */ + if( txt->unicode_array_len == 0 ) { + printf( "Non unicode string passed to a Qt driver, ignoring\n" ); + return; } - - m_listBuffer.append(el); -} - -void QtPLBufferedDriver::drawPolygon(short * x, short * y, PLINT npts) -{ - BufferElement el; - el.Element=POLYGON; - el.Data.PolylineStruct.npts=(PLINT)npts; - el.Data.PolylineStruct.x=new PLFLT[npts]; - el.Data.PolylineStruct.y=new PLFLT[npts]; - for(int i=0; i<npts; ++i) - { - el.Data.PolylineStruct.x[i]=(PLFLT)(x[i])*downscale; - el.Data.PolylineStruct.y[i]=m_dHeight-(PLFLT)((y[i])*downscale); + + /* Check that unicode string isn't longer then the max we allow */ + if( txt->unicode_array_len >= 500 ) { + printf( "Sorry, the Qt drivers only handle strings of length < %d\n", 500 ); + return; } - if(el.Data.PolylineStruct.x[0]==el.Data.PolylineStruct.x[npts-1] && el.Data.PolylineStruct.y[0]==el.Data.PolylineStruct.y[npts-1]) - { - --el.Data.PolylineStruct.npts; - } - - m_listBuffer.append(el); -} -void QtPLBufferedDriver::setColor(int r, int g, int b, int a) -{ - BufferElement el; - el.Element=SET_COLOUR; - el.Data.ColourStruct.R=r; - el.Data.ColourStruct.G=g; - el.Data.ColourStruct.B=b; - el.Data.ColourStruct.A=a; - - m_listBuffer.append(el); -} + PLFLT rotation, shear, stride; + plRotationShear( txt->xform, &rotation, &shear, &stride); + + double picDpi; + QPicture picText=getTextPicture(txt->unicode_array, txt->unicode_array_len, pls->chrht); + picDpi=picText.logicalDpiY(); -void QtPLBufferedDriver::setWidth(PLINT w) -{ - BufferElement el; - el.Element=SET_WIDTH; - el.Data.intParam=w; - m_listBuffer.append(el); + rotation -= pls->diorot * M_PI / 2.0; + m_painterP->translate(txt->x*downscale, m_dHeight-txt->y*downscale); + QMatrix rotShearMatrix(cos(rotation)*stride, -sin(rotation)*stride, cos(rotation)*sin(shear)+sin(rotation)*cos(shear), -sin(rotation)*sin(shear)+cos(rotation)*cos(shear), 0., 0.); + + m_painterP->setWorldMatrix(rotShearMatrix, true); + m_painterP->translate(-txt->just*xOffset*m_painterP->device()->logicalDpiY()/picDpi, 0.); + m_painterP->drawPicture(0., 0., picText); + + m_painterP->setWorldMatrix(QMatrix()); + } -void QtPLBufferedDriver::setDashed(PLINT nms, PLINT* mark, PLINT* space) +void QtPLDriver::setColor(int r, int g, int b, double alpha) { - BufferElement el; - el.Element=SET_DASHED; - el.Data.PolylineStruct.npts=2*nms; - el.Data.PolylineStruct.x=new PLFLT[2*nms]; - for(int i=0; i<nms; i++) - { - el.Data.PolylineStruct.x[2*i]=(PLFLT)mark[i]*0.00283; - el.Data.PolylineStruct.x[2*i+1]=(PLFLT)space[i]*0.00283; - } - - m_listBuffer.append(el); + QPen p=m_painterP->pen(); + p.setColor(QColor(r, g, b, alpha*255)); + m_painterP->setPen(p); + + QBrush B=m_painterP->brush(); + B.setColor(QColor(r, g, b, alpha*255)); + B.setStyle(Qt::SolidPattern); + m_painterP->setBrush(B); } -void QtPLBufferedDriver::setSolid() +void QtPLDriver::setWidth(PLINT w) { - BufferElement el; - el.Element=SET_SOLID; - m_listBuffer.append(el); + QPen p=m_painterP->pen(); + p.setWidth(w); + m_painterP->setPen(p); } -// Draw the content of the buffer -void QtPLBufferedDriver::doPlot(QPainter* i_painterP, double x_fact, double y_fact, double x_offset, double y_offset) +void QtPLDriver::setDashed(PLINT nms, PLINT* mark, PLINT* space) { - QLineF line; - QPointF * polyline; - PLINT npts; QVector<qreal> vect; - - if(i_painterP==NULL) i_painterP=m_painterP; - - QPen p=i_painterP->pen(); - QBrush b=i_painterP->brush(); - b.setStyle(Qt::SolidPattern); - i_painterP->setBrush(b); - - i_painterP->fillRect(x_offset, y_offset, m_dWidth*x_fact, m_dHeight*y_fact, QBrush(Qt::black)); - - if(m_listBuffer.empty()) + for(int i=0; i<nms; ++i) { - return; + vect << (PLFLT)mark[i]*m_painterP->device()->logicalDpiX()/25400.; + vect << (PLFLT)space[i]*m_painterP->device()->logicalDpiX()/25400.; } - for(QLinkedList<BufferElement>::const_iterator i=m_listBuffer.begin(); i!=m_listBuffer.end(); ++i) - { - switch(i->Element) - { - case LINE: - line=QLineF(i->Data.LineStruct.x1*x_fact+x_offset, i->Data.LineStruct.y1*y_fact+y_offset, i->Data.LineStruct.x2*x_fact+x_offset, i->Data.LineStruct.y2*y_fact+y_offset); - i_painterP->drawLine(line); - break; - - case POLYLINE: - npts=i->Data.PolylineStruct.npts; - polyline=new QPointF[npts]; - for(int j=0; j<npts; ++j) - { - polyline[j].setX(i->Data.PolylineStruct.x[j]*x_fact+x_offset); - polyline[j].setY(i->Data.PolylineStruct.y[j]*y_fact+y_offset); - } - i_painterP->drawPolyline(polyline, npts); - delete[] polyline; - break; - - case POLYGON: - npts=i->Data.PolylineStruct.npts; - polyline=new QPointF[npts]; - for(int j=0; j<npts; ++j) - { - polyline[j].setX(i->Data.PolylineStruct.x[j]*x_fact+x_offset); - polyline[j].setY(i->Data.PolylineStruct.y[j]*y_fact+y_offset); - } - i_painterP->drawPolygon(polyline, npts); - - delete[] polyline; - break; - - case SET_WIDTH: - - p.setWidthF(i->Data.intParam); - i_painterP->setPen(p); - break; - - case SET_COLOUR: - p.setColor(QColor(i->Data.ColourStruct.R, i->Data.ColourStruct.G, i->Data.ColourStruct.B, i->Data.ColourStruct.A)); - i_painterP->setPen(p); - b.setColor(QColor(i->Data.ColourStruct.R, i->Data.ColourStruct.G, i->Data.ColourStruct.B, i->Data.ColourStruct.A)); - i_painterP->setBrush(b); - break; - - case SET_DASHED: - vect.clear(); - for(int j=0; j<i->Data.PolylineStruct.npts; j++) - { - if(i->Data.PolylineStruct.x[j]>=1.) //TODO remove that when bug #228554 of Qt is solved on Windows... - vect << i->Data.PolylineStruct.x[j]; - else - vect <<1.; - } - p.setDashPattern(vect); - i_painterP->setPen(p); - break; - - case SET_SOLID: - p.setStyle(Qt::SolidLine); - i_painterP->setPen(p); - break; - - case SET_SMOOTH: - i_painterP->setRenderHint(QPainter::Antialiasing, i->Data.intParam); - break; - - default: - break; - } - } + QPen p=m_painterP->pen(); + p.setDashPattern(vect); + m_painterP->setPen(p); } -void QtPLBufferedDriver::getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset) +void QtPLDriver::setSolid() { - io_dXFact=1.; - io_dYFact=1.; - io_dXOffset=0.; - io_dYOffset=0.; + QPen p=m_painterP->pen(); + p.setStyle(Qt::SolidLine); + m_painterP->setPen(p); } - // Generic driver interface void plD_line_qt(PLStream * pls, short x1a, short y1a, short x2a, short y2a) @@ -702,7 +495,7 @@ #endif if(widget==NULL) return; - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, (int)(255.*pls->curcolor.a)); + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); widget->drawLine(x1a, y1a, x2a, y2a); } @@ -727,7 +520,7 @@ #endif if(widget==NULL) return; - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, (int)(255.*pls->curcolor.a)); + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); widget->drawPolyline(xa, ya, npts); } @@ -758,7 +551,7 @@ { case PLESC_DASH: widget->setDashed(pls->nms, pls->mark, pls->space); - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, (int)(255.*pls->curcolor.a)); + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); widget->drawPolyline(pls->dev_x, pls->dev_y, pls->dev_npts); widget->setSolid(); break; @@ -772,7 +565,7 @@ xa[i] = pls->dev_x[i]; ya[i] = pls->dev_y[i]; } - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, (int)(255.*pls->curcolor.a)); + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); widget->drawPolygon(xa, ya, pls->dev_npts); delete[] xa; @@ -782,6 +575,8 @@ case PLESC_HAS_TEXT: /*$$ call the generic ProcessString function ProcessString( pls, (EscText *)ptr ); */ + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); + widget->drawText(pls, (EscText *)ptr); break; default: break; @@ -815,11 +610,11 @@ break; case PLSTATE_COLOR0: - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, (int)(255.*pls->curcolor.a)); + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); break; case PLSTATE_COLOR1: - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, (int)(255.*pls->curcolor.a)); + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); break; @@ -827,6 +622,28 @@ } } +void plD_tidy_qt(PLStream * pls) +{ + QtPLDriver * widget=NULL; + #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) + if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_svgqt) && QT_VERSION >= 0x040300 + if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_epsqt) || defined(PLD_pdfqt) + if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); +#endif + + if(widget!=NULL) + { + delete widget; + pls->dev=NULL; + } + + closeQtApp(); +} + ////////////////// Raster driver-specific definitions: class and interface functions ///////// #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) @@ -841,10 +658,22 @@ b.setStyle(Qt::SolidPattern); m_painterP->setBrush(b); m_painterP->setRenderHint(QPainter::Antialiasing, true); + int res=DPI/25.4*1000.; + setDotsPerMeterX(res); + setDotsPerMeterY(res); + // Let's fill the background m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); + + svgBugFactor=1.; + fontScalingFactor=1.; } +QtRasterDevice::~QtRasterDevice() +{ + if(m_painterP!=NULL) delete m_painterP; +} + void QtRasterDevice::definePlotName(const char* fileName, const char* format) { // Avoid buffer overflows @@ -879,25 +708,29 @@ pls->dev_clear=1; pls->termin=0; pls->page = 0; - + pls->dev_text = 1; // want to draw text + pls->dev_unicode = 1; // want unicode + + initQtApp(); /*$$ these variables must be 1 so that we can process - unicode text on our own - pls->dev_text = 1; // want to draw text - pls->dev_unicode = 1; // want unicode */ + unicode text on our own */ + /*$$ if you want to use the hershey font only for the symbols set this to 1 pls->dev_hrshsym = 1; */ - - // Initialised with the default (A4) size - pls->dev=new QtRasterDevice; // Shamelessly copied on the Cairo stuff :) if (pls->xlength <= 0 || pls->ylength <= 0) { + pls->dev=new QtRasterDevice; pls->xlength = ((QtRasterDevice*)(pls->dev))->m_dWidth; pls->ylength = ((QtRasterDevice*)(pls->dev))->m_dHeight; } + else + { + pls->dev=new QtRasterDevice(pls->xlength, pls->ylength); + } if (pls->xlength > pls->ylength) ((QtRasterDevice*)(pls->dev))->downscale = (PLFLT)pls->xlength/(PLFLT)(PIXELS_X-1); @@ -1083,16 +916,20 @@ QtPLDriver(i_iWidth, i_iHeight) { setSize(QSize(m_dWidth, m_dHeight)); + m_painterP=NULL; + svgBugFactor=1.37; + fontScalingFactor=1.; } QtSVGDevice::~QtSVGDevice() { + if(m_painterP!=NULL) delete m_painterP; } void QtSVGDevice::definePlotName(const char* fileName) { setFileName(QString(fileName)); - setResolution(72); + setResolution(DPI); m_painterP=new QPainter(this); m_painterP->fillRect(0, 0, m_dWidth, m_dHeight, QBrush(Qt::black)); @@ -1133,14 +970,21 @@ pls->dev_clear=1; pls->termin=0; pls->page = 0; + pls->dev_text = 1; // want to draw text + pls->dev_unicode = 1; // want unicode - pls->dev=new QtSVGDevice; + initQtApp(); if (pls->xlength <= 0 || pls->ylength <= 0) { + pls->dev=new QtSVGDevice; pls->xlength = ((QtSVGDevice*)(pls->dev))->m_dWidth; pls->ylength = ((QtSVGDevice*)(pls->dev))->m_dHeight; } + else + { + pls->dev=new QtSVGDevice(pls->xlength, pls->ylength); + } if (pls->xlength > pls->ylength) ((QtSVGDevice*)(pls->dev))->downscale = (PLFLT)pls->xlength/(PLFLT)(PIXELS_X-1); @@ -1193,13 +1037,18 @@ setResolution(DPI); setColorMode(QPrinter::Color); setOrientation(QPrinter::Landscape); + setPrintProgram(QString("lpr")); m_dWidth=pageRect().width(); m_dHeight=pageRect().height(); + m_painterP=NULL; + svgBugFactor=1.; + fontScalingFactor=1.; } QtEPSDevice::~QtEPSDevice() { + if(m_painterP!=NULL) delete m_painterP; } void QtEPSDevice::definePlotName(const char* fileName, int ifeps) @@ -1275,14 +1124,13 @@ pls->dev_clear=1; pls->termin=0; pls->page = 0; + pls->dev_text = 1; // want to draw text + pls->dev_unicode = 1; // want unicode - int argc=0; - char argv[]={'\0'}; // QPrinter devices won't create if there is no QApplication declared... - QApplication * app=new QApplication(argc, (char**)&argv); - pls->dev=new QtEPSDevice; - delete app; + initQtApp(); + pls->dev=new QtEPSDevice; if (pls->xlength <= 0 || pls->ylength <= 0) { pls->xlength = ((QtEPSDevice*)(pls->dev))->m_dWidth; @@ -1321,18 +1169,16 @@ int argc=0; char argv[]={'\0'}; - + if(qt_family_check(pls)) {return;} ((QtEPSDevice *)pls->dev)->savePlot(); // Once saved, we have to create a new device with the same properties // to be able to plot another page. downscale=((QtEPSDevice *)pls->dev)->downscale; - delete ((QtEPSDevice *)pls->dev); - - QApplication * app=new QApplication(argc, (char**)&argv); + //QApplication * app=new QApplication(argc, (char**)&argv); pls->dev=new QtEPSDevice; ((QtEPSDevice *)pls->dev)->downscale=downscale; - delete app; + //delete app; } #if defined(PLD_epsqt) @@ -1352,7 +1198,7 @@ #if defined (PLD_qtwidget) QtPLWidget::QtPLWidget(int i_iWidth, int i_iHeight, QWidget* parent): - QWidget(parent), QtPLBufferedDriver(i_iWidth, i_iHeight) + QWidget(parent), QtPLDriver(i_iWidth, i_iHeight) { m_painterP=new QPainter; @@ -1363,77 +1209,81 @@ m_iOldSize=0; resize(i_iWidth, i_iHeight); - + + pic=new QPicture; + m_painterP->begin(pic); + + svgBugFactor=1.; + fontScalingFactor=0.6; + } QtPLWidget::~QtPLWidget() { - clearBuffer(); +// clearBuffer(); if(m_pixPixmap!=NULL) delete m_pixPixmap; + if(m_painterP!=NULL) delete m_painterP; + if(pic!=NULL) delete pic; } -void QtPLWidget::setSmooth(bool b) -{ - BufferElement el; - el.Element=SET_SMOOTH; - el.Data.intParam=b; - m_listBuffer.append(el); -} - void QtPLWidget::clearWidget() { - clearBuffer(); +// clearBuffer(); + m_painterP->end(); + delete pic; + pic=new QPicture; + m_painterP->begin(pic); m_bAwaitingRedraw=true; update(); } -void QtPLWidget::captureMousePlotCoords(double * xi, double* yi, double * xf, double * yf) -{ - setMouseTracking(true); - cursorParameters.isTracking=true; - cursorParameters.cursor_start_x= - cursorParameters.cursor_start_y= - cursorParameters.cursor_end_x= - cursorParameters.cursor_end_y=-1.; - cursorParameters.step=1; - do - { - QCoreApplication::processEvents(QEventLoop::AllEvents, 10); - - } while(cursorParameters.isTracking); - - PLFLT a,b; - PLINT c; - plcalc_world(cursorParameters.cursor_start_x, 1.-cursorParameters.cursor_start_y, &a, &b, &c); - *xi=a; - *yi=b; - plcalc_world(cursorParameters.cursor_end_x, 1.-cursorParameters.cursor_end_y, &a, &b, &c); - *xf=a; - *yf=b; - -} +// void QtPLWidget::captureMousePlotCoords(double * xi, double* yi, double * xf, double * yf) +// { +// setMouseTracking(true); +// cursorParameters.isTracking=true; +// cursorParameters.cursor_start_x= +// cursorParameters.cursor_start_y= +// cursorParameters.cursor_end_x= +// cursorParameters.cursor_end_y=-1.; +// cursorParameters.step=1; +// do +// { +// QCoreApplication::processEvents(QEventLoop::AllEvents, 10); +// +// } while(cursorParameters.isTracking); +// +// PLFLT a,b; +// PLINT c; +// plcalc_world(cursorParameters.cursor_start_x, 1.-cursorParameters.cursor_start_y, &a, &b, &c); +// *xi=a; +// *yi=b; +// plcalc_world(cursorParameters.cursor_end_x, 1.-cursorParameters.cursor_end_y, &a, &b, &c); +// *xf=a; +// *yf=b; +// +// } +// +// void QtPLWidget::captureMouseDeviceCoords(double * xi, double* yi, double * xf, double * yf) +// { +// setMouseTracking(true); +// cursorParameters.isTracking=true; +// cursorParameters.cursor_start_x= +// cursorParameters.cursor_start_y= +// cursorParameters.cursor_end_x= +// cursorParameters.cursor_end_y=-1.; +// cursorParameters.step=1; +// do +// { +// QCoreApplication::processEvents(QEventLoop::AllEvents, 10); +// +// } while(cursorParameters.isTracking); +// +// *xi=cursorParameters.cursor_start_x; +// *yi=cursorParameters.cursor_start_y; +// *xf=cursorParameters.cursor_end_x; +// *yf=cursorParameters.cursor_end_y; +// } -void QtPLWidget::captureMouseDeviceCoords(double * xi, double* yi, double * xf, double * yf) -{ - setMouseTracking(true); - cursorParameters.isTracking=true; - cursorParameters.cursor_start_x= - cursorParameters.cursor_start_y= - cursorParameters.cursor_end_x= - cursorParameters.cursor_end_y=-1.; - cursorParameters.step=1; - do - { - QCoreApplication::processEvents(QEventLoop::AllEvents, 10); - - } while(cursorParameters.isTracking); - - *xi=cursorParameters.cursor_start_x; - *yi=cursorParameters.cursor_start_y; - *xf=cursorParameters.cursor_end_x; - *yf=cursorParameters.cursor_end_y; -} - void QtPLWidget::resizeEvent( QResizeEvent * ) { m_bAwaitingRedraw=true; @@ -1446,125 +1296,126 @@ void QtPLWidget::paintEvent( QPaintEvent * ) { + if(m_painterP->isActive()) m_painterP->end(); double x_fact, y_fact, x_offset(0.), y_offset(0.); //Parameters to scale and center the plot on the widget getPlotParameters(x_fact, y_fact, x_offset, y_offset); - + QPainter * painter=new QPainter; // If actual redraw, not just adding the cursor acquisition traces - if(m_bAwaitingRedraw || m_pixPixmap==NULL || m_listBuffer.size()!=m_iOldSize ) + if(m_bAwaitingRedraw || m_pixPixmap==NULL) { if(m_pixPixmap!=NULL) delete m_pixPixmap; m_pixPixmap=new QPixmap(width(), height()); - QPainter * painter=new QPainter; painter->begin(m_pixPixmap); painter->fillRect(0, 0, width(), height(), QBrush(Qt::white)); painter->fillRect(0, 0, width(), height(), QBrush(Qt::gray, Qt::Dense4Pattern)); painter->fillRect((int)x_offset, (int)y_offset, (int)floor(x_fact*m_dWidth+0.5), (int)floor(y_fact*m_dHeight+0.5), QBrush(Qt::black)); painter->setRenderHint(QPainter::Antialiasing, true); - doPlot(painter, x_fact, y_fact, x_offset, y_offset); + painter->setWorldMatrix(QMatrix(x_fact, 0., 0., y_fact, x_offset, y_offset)); + pic->play(painter); painter->end(); m_bAwaitingRedraw=false; - m_iOldSize=m_listBuffer.size(); } - m_painterP->begin(this); - - // repaint plot - m_painterP->drawPixmap(0, 0, *m_pixPixmap); + painter->begin(this); +// +// // repaint plot + painter->drawPixmap(0, 0, *m_pixPixmap); // now paint the cursor tracking patterns - if(cursorParameters.isTracking) - { - QPen p=m_painterP->pen(); - p.setColor(Qt::white); - if(cursorParameters.step==1) - { - m_painterP->setPen(p); - m_painterP->drawLine((int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), 0, (int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), height()); - m_painterP->drawLine(0, (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset), width(), (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset)); - } - else - { - p.setStyle(Qt::DotLine); - m_painterP->setPen(p); - m_painterP->drawLine((int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), 0, (int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), height()); - m_painterP->drawLine(0, (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset), width(), (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset)); - p.setStyle(Qt::SolidLine); - m_painterP->setPen(p); - m_painterP->drawLine((int)(cursorParameters.cursor_end_x*x_fact*m_dWidth+x_offset), 0, (int)(cursorParameters.cursor_end_x*x_fact*m_dWidth+x_offset), height()); - m_painterP->drawLine(0, (int)(cursorParameters.cursor_end_y*y_fact*m_dHeight+y_offset), width(), (int)(cursorParameters.cursor_end_y*y_fact*m_dHeight+y_offset)); - } - } +// if(cursorParameters.isTracking) +// { +// QPen p=painter->pen(); +// p.setColor(Qt::white); +// if(cursorParameters.step==1) +// { +// painter->setPen(p); +// painter->drawLine((int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), 0, (int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), height()); +// painter->drawLine(0, (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset), width(), (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset)); +// } +// else +// { +// p.setStyle(Qt::DotLine); +// painter->setPen(p); +// painter->drawLine((int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), 0, (int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), height()); +// painter->drawLine(0, (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset), width(), (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset)); +// p.setStyle(Qt::SolidLine); +// painter->setPen(p); +// painter->drawLine((int)(cursorParameters.cursor_end_x*x_fact*m_dWidth+x_offset), 0, (int)(cursorParameters.cursor_end_x*x_fact*m_dWidth+x_offset), height()); +// painter->drawLine(0, (int)(cursorParameters.cursor_end_y*y_fact*m_dHeight+y_offset), width(), (int)(cursorParameters.cursor_end_y*y_fact*m_dHeight+y_offset)); +// } +// } - m_painterP->end(); + painter->end(); + delete painter; } -void QtPLWidget::mousePressEvent(QMouseEvent* event) -{ - if(!cursorParameters.isTracking) return; - - double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget - - getPlotParameters(x_fact, y_fact, x_offset, y_offset); - - PLFLT X=(PLFLT)(event->x()-x_offset)/(m_dWidth*x_fact); - PLFLT Y=(PLFLT)(event->y()-y_offset)/(m_dHeight*y_fact); - - if(cursorParameters.step==1) - { - cursorParameters.cursor_start_x=X; - cursorParameters.cursor_start_y=Y; - cursorParameters.step=2; // First step of selection done, going to the next one - update(); - } -} +// void QtPLWidget::mousePressEvent(QMouseEvent* event) +// { +// if(!cursorParameters.isTracking) return; +// +// double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget +// +// getPlotParameters(x_fact, y_fact, x_offset, y_offset); +// +// PLFLT X=(PLFLT)(event->x()-x_offset)/(m_dWidth*x_fact); +// PLFLT Y=(PLFLT)(event->y()-y_offset)/(m_dHeight*y_fact); +// +// if(cursorParameters.step==1) +// { +// cursorParameters.cursor_start_x=X; +// cursorParameters.cursor_start_y=Y; +// cursorParameters.step=2; // First step of selection done, going to the next one +// update(); +// } +// } +// +// void QtPLWidget::mouseReleaseEvent(QMouseEvent* event) +// { +// double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget +// +// getPlotParameters(x_fact, y_fact, x_offset, y_offset); +// +// PLFLT X=(PLFLT)(event->x()-x_offset)/(m_dWidth*x_fact); +// PLFLT Y=(PLFLT)(event->y()-y_offset)/(m_dHeight*y_fact); +// +// if(cursorParameters.step!=1) +// { +// cursorParameters.cursor_end_x=X; +// cursorParameters.cursor_end_y=Y; +// cursorParameters.isTracking=false; +// setMouseTracking(false); +// update(); +// } +// } +// +// void QtPLWidget::mouseMoveEvent(QMouseEvent* event) +// { +// this->activateWindow(); +// this->raise(); +// +// if(!cursorParameters.isTracking) return; +// +// double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget +// +// getPlotParameters(x_fact, y_fact, x_offset, y_offset); +// +// PLFLT X=(PLFLT)(event->x()-x_offset)/(m_dWidth*x_fact); +// PLFLT Y=(PLFLT)(event->y()-y_offset)/(m_dHeight*y_fact); +// +// if(cursorParameters.step==1) +// { +// cursorParameters.cursor_start_x=X; +// cursorParameters.cursor_start_y=Y; +// } +// else +// { +// cursorParameters.cursor_end_x=X; +// cursorParameters.cursor_end_y=Y; +// } +// +// update(); +// } -void QtPLWidget::mouseReleaseEvent(QMouseEvent* event) -{ - double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget - - getPlotParameters(x_fact, y_fact, x_offset, y_offset); - - PLFLT X=(PLFLT)(event->x()-x_offset)/(m_dWidth*x_fact); - PLFLT Y=(PLFLT)(event->y()-y_offset)/(m_dHeight*y_fact); - - if(cursorParameters.step!=1) - { - cursorParameters.cursor_end_x=X; - cursorParameters.cursor_end_y=Y; - cursorParameters.isTracking=false; - setMouseTracking(false); - update(); - } -} - -void QtPLWidget::mouseMoveEvent(QMouseEvent* event) -{ - this->activateWindow(); - this->raise(); - - if(!cursorParameters.isTracking) return; - - double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget - - getPlotParameters(x_fact, y_fact, x_offset, y_offset); - - PLFLT X=(PLFLT)(event->x()-x_offset)/(m_dWidth*x_fact); - PLFLT Y=(PLFLT)(event->y()-y_offset)/(m_dHeight*y_fact); - - if(cursorParameters.step==1) - { - cursorParameters.cursor_start_x=X; - cursorParameters.cursor_start_y=Y; - } - else - { - cursorParameters.cursor_end_x=X; - cursorParameters.cursor_end_y=Y; - } - - update(); -} - void QtPLWidget::getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset) { double w=(double)width(); @@ -1586,6 +1437,14 @@ } } +QtPLTabWidget::~QtPLTabWidget() +{ + for(QList<QtPLWidget*>::iterator iter=widgets.begin(); iter!=widgets.end(); ++iter) + { + if(*iter!=NULL) delete (*iter); + } +} + void QtPLTabWidget::newTab() { QtPLWidget * plotWidget=new QtPLWidget; @@ -1594,6 +1453,7 @@ plotWidget->m_dHeight=m_dHeight; addTab(plotWidget, QString("page %1").arg(count()+1)); currentWidget=plotWidget; + widgets.push_back(plotWidget); } @@ -1615,16 +1475,10 @@ pdt->pl_esc = (plD_esc_fp) plD_esc_qt; } -// global variables initialised in init(), used in tidy() -QApplication* app; -int argc=1; // argc and argv have to exist when tidy() is used, thus they are made global -char argv[20]; - void plD_init_qtwidget(PLStream * pls) { PLINT w, h; - argv[0]='\0'; - app=new QApplication(argc, (char**)&argv); + initQtApp(); QMainWindow * mw=new QMainWindow; QtPLTabWidget* tabWidget=new QtPLTabWidget; @@ -1649,12 +1503,14 @@ pls->dev_flush=1; pls->dev_clear=1; pls->termin=1; + pls->dev_text = 1; // want to draw text + pls->dev_unicode = 1; // want unicode mw->setCentralWidget(tabWidget); mw->setVisible(true); mw->setWindowTitle("plplot"); mw->resize(plsc->xlength, plsc->ylength); - app->setActiveWindow(mw); + qApp->setActiveWindow(mw); } @@ -1666,7 +1522,11 @@ void plD_tidy_qtwidget(PLStream *pls) { - app->exec(); + qApp->exec(); + delete ((QtPLTabWidget*)pls->dev); + pls->dev=NULL; + + closeQtApp(); } #endif Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-12 08:19:17 UTC (rev 9728) +++ trunk/drivers/qt.h 2009-03-12 15:31:50 UTC (rev 9729) @@ -6,7 +6,6 @@ Imperial College, London Copyright (C) 2009 Imperial College, London - Copyright (C) 2009 Alan W. Irwin This is free software; you can redistribute it and/or modify it under the terms of the GNU General Lesser Public License as published @@ -43,6 +42,7 @@ #include <QMouseEvent> #include <QTabWidget> #include <QMainWindow> +#include <QPicture> #include "plplotP.h" #include "drivers.h" @@ -51,53 +51,6 @@ #define QT_DEFAULT_X 842 #define QT_DEFAULT_Y 598 -// Types of buffer elements for buffered widgets -typedef enum ElementType_ -{ - LINE, - POLYLINE, - POLYGON, - SET_WIDTH, - SET_COLOUR, - SET_DASHED, - SET_SOLID, - SET_SMOOTH -} ElementType; - -// A buffer element in a buffered widget -class BufferElement -{ - public: - - ElementType Element; - - union DataType - { - struct LineStruct_ - { - PLFLT x1; - PLFLT x2; - PLFLT y1; - PLFLT y2; - } LineStruct; - - struct PolylineStruct_ - { - PLINT npts; - PLFLT* x; - PLFLT* y; - } PolylineStruct; - - struct ColourStruct_ - { - PLINT R, G, B, A; - } ColourStruct; - - PLINT intParam; - PLFLT fltParam; - } Data; -}; - // Basic class, offering the common interface to all Qt plplot devices class QtPLDriver { @@ -114,66 +67,41 @@ virtual void drawPolygon(short * x, short * y, PLINT npts); - virtual void setColor(int r, int g, int b, int a); + virtual void drawText(PLStream* pls, EscText* txt); + virtual void setColor(int r, int g, int b, double alpha); + virtual void setWidth(PLINT w); virtual void setDashed(PLINT nms, PLINT* mark, PLINT* space); // Set pen to draw solid strokes (called after drawing dashed strokes) virtual void setSolid(); - + // Conversion factor from internal plplot coordinates to device coordinates double downscale; double m_dWidth, m_dHeight; protected: + + // Returns font with the good size for a QPicture's resolution + QFont getFont(PLUNICODE code); + // Draws text in a QPicture using a sub-QPicture (!), updates the current xOffset + void drawTextInPicture(QPainter*, const QString&); + // Gets the QPicture displaying text, with the base chrht char height + QPicture getTextPicture(PLUNICODE* text, int len, int chrht); - QPainter* m_painterP; -}; - -// This driver is used if the device may have to redraw (Widget), then the accumulated commands are re-issued, possibly corrected to fit a new device size -class QtPLBufferedDriver: public QtPLDriver -{ - public: - QtPLBufferedDriver(PLINT i_iWidth=QT_DEFAULT_X, PLINT i_iHeight=QT_DEFAULT_Y); - - virtual ~QtPLBufferedDriver(); - - // Accumulates a line command in the end of the buffer - virtual void drawLine(short x1, short y1, short x2, short y2); - - virtual void drawPolyline(short * x, short * y, PLINT npts); - - virtual void drawPolygon(short * x, short * y, PLINT npts); - - virtual void setColor(int r, int g, int b, int a); - - virtual void setWidth(PLINT r); - - virtual void setDashed(PLINT nms, PLINT* mark, PLINT* space); - - virtual void setSolid(); + // Text-related variables + bool underlined; + bool overlined; + double currentFontScale; + double currentFontSize; + double yOffset; + double xOffset; - // Actually plots on the device, using the p QPainter. - // if p is null, then the defaut QPainter m_painterP is used. - // x_fact, y_fact, x_offset and y_offset allow to center the plot - // on the device - // These 5 parameters are actually only used for widgets: - // widgets plot on a pixmap via p, and as the aspect ratio of - // what's drawn is set constant yet taking as much space as possible, - // offsets and factors have to be set - virtual void doPlot(QPainter* p=NULL, double x_fact=1., double y_fact=1., double x_offset=0., double y_offset=0.); + double svgBugFactor; // factor to fix the oversized bounding boxes for texts in the SVG driver + double fontScalingFactor;// To have a nice font size on qtwidget - protected: - - // Gets the offsets and factors using the current size of the device - virtual void getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset); - - // Empties the buffer - void clearBuffer(); - - // Here is the buffer - QLinkedList<BufferElement> m_listBuffer; + QPainter* m_painterP; }; #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) @@ -184,7 +112,7 @@ QtRasterDevice(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y); - virtual ~QtRasterDevice(){} + virtual ~QtRasterDevice(); void definePlotName(const char* fileName, const char* format); @@ -235,12 +163,13 @@ #endif #if defined (PLD_qtwidget) + // This widget allows to use plplot as a plotting engine in a Qt Application // The aspect ratio of the plotted data is constant, so gray strips are used // to delimit the page when the widget aspect ratio is not the one of the plotted page -class QtPLWidget: public QWidget, public QtPLBufferedDriver +class QtPLWidget: public QWidget, public QtPLDriver { - Q_OBJECT +// Q_OBJECT public: // Parameters are the actual size of the page, NOT the size of the widget @@ -257,30 +186,31 @@ // plotWidget->setSmooth(false); // plline(...) // will only smooth the axes and their labels. - void setSmooth(bool); +// void setSmooth(bool); // Clears the widget void clearWidget(); - public slots: +// public slots: // This slot can be used to select an x/y range interactively // xi, yi, xf and yf are the initial and final points coordinates // in their respective windows, 0 if outside a window - void captureMousePlotCoords(double* xi, double* yi, double* xf, double* yf); +// void captureMousePlotCoords(double* xi, double* yi, double* xf, double* yf); +// +// // This slot can be used to select an x/y range interactively +// // xi, yi, xf and yf are the initial and final points coordinates +// // in the whole page (normalized between 0 and 1) +// void captureMouseDeviceCoords(double* xi, double* yi, double* xf, double* yf); - // This slot can be used to select an x/y range interactively - // xi, yi, xf and yf are the initial and final points coordinates - // in the whole page (normalized between 0 and 1) - void captureMouseDeviceCoords(double* xi, double* yi, double* xf, double* yf); +// protected slots: + protected: - protected slots: - void resizeEvent(QResizeEvent*); void paintEvent(QPaintEvent*); - void mousePressEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); +// void mousePressEvent(QMouseEvent*); +// void mouseReleaseEvent(QMouseEvent*); +// void mouseMoveEvent(QMouseEvent*); protected: @@ -300,6 +230,7 @@ QPixmap * m_pixPixmap; // to avoid redrawing everything bool m_bAwaitingRedraw; int m_iOldSize; + QPicture* pic; }; @@ -315,6 +246,8 @@ currentWidget=NULL; } + ~QtPLTabWidget(); + virtual void drawLine(short x1, short y1, short x2, short y2) { if(currentWidget==NULL) newTab(); @@ -333,10 +266,10 @@ currentWidget->drawPolygon(x, y, npts); } - virtual void setColor(int r, int g, int b, int a) + virtual void setColor(int r, int g, int b, double alpha) { if(currentWidget==NULL) newTab(); - currentWidget->setColor(r, g, b, a); + currentWidget->setColor(r, g, b, alpha); } virtual void setWidth(PLINT w) @@ -358,18 +291,25 @@ currentWidget->setSolid(); } - void setSmooth(bool b) + virtual void drawText(PLStream* pls, EscText* txt) { if(currentWidget==NULL) newTab(); - currentWidget->setSmooth(b); + currentWidget->drawText(pls, txt); } +// void setSmooth(bool b) +// { +// if(currentWidget==NULL) newTab(); +// currentWidget->setSmooth(b); +// } + virtual void savePlot(char* fileName){} QtPLWidget* currentWidget; protected: void newTab(); + QList<QtPLWidget*> widgets; }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-12 20:12:31
|
Revision: 9730 http://plplot.svn.sourceforge.net/plplot/?rev=9730&view=rev Author: airwin Date: 2009-03-12 20:12:11 +0000 (Thu, 12 Mar 2009) Log Message: ----------- AWI for Alban Rochel. Remove all special treatment of text positions for SVG. Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-12 15:31:50 UTC (rev 9729) +++ trunk/drivers/qt.cpp 2009-03-12 20:12:11 UTC (rev 9730) @@ -197,7 +197,6 @@ m_dWidth=i_iWidth; m_dHeight=i_iHeight; downscale=1.; - svgBugFactor=1.; // fontScalingFactor=1.; } @@ -294,7 +293,7 @@ p->drawPicture(xOffset+bounding.width()/2., -yOffset, tempPic); - xOffset+=bounding.width()/svgBugFactor; + xOffset+=bounding.width(); } QPicture QtPLDriver::getTextPicture(PLUNICODE* text, int len, int chrht) @@ -665,7 +664,6 @@ // Let's fill the background m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); - svgBugFactor=1.; fontScalingFactor=1.; } @@ -917,7 +915,7 @@ { setSize(QSize(m_dWidth, m_dHeight)); m_painterP=NULL; - svgBugFactor=1.37; + fontScalingFactor=1.; } @@ -1042,7 +1040,7 @@ m_dWidth=pageRect().width(); m_dHeight=pageRect().height(); m_painterP=NULL; - svgBugFactor=1.; + fontScalingFactor=1.; } @@ -1213,7 +1211,6 @@ pic=new QPicture; m_painterP->begin(pic); - svgBugFactor=1.; fontScalingFactor=0.6; } Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-12 15:31:50 UTC (rev 9729) +++ trunk/drivers/qt.h 2009-03-12 20:12:11 UTC (rev 9730) @@ -98,7 +98,6 @@ double yOffset; double xOffset; - double svgBugFactor; // factor to fix the oversized bounding boxes for texts in the SVG driver double fontScalingFactor;// To have a nice font size on qtwidget QPainter* m_painterP; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-16 17:16:14
|
Revision: 9748 http://plplot.svn.sourceforge.net/plplot/?rev=9748&view=rev Author: airwin Date: 2009-03-16 17:15:49 +0000 (Mon, 16 Mar 2009) Log Message: ----------- AWI for Alban Rochel. Patch to make glyph sizes consistent between qtwidget and the remaining qt devices. This works on both the AR and AWI platforms, but on the AWI platform (Debian Lenny, 64-bit, cmake-2.6.0, with Qt-4.5.0 as downloaded from Trolltech), the consistent glyph size for all qt devices is still about 20 per cent too small compared to the equivalent pngcairo results and also 20 per cent too small compared to AR screenshots of qt device driver results taken earlier. So this patch seems to be a step in the right direction, but we are not there yet. Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-16 15:29:08 UTC (rev 9747) +++ trunk/drivers/qt.cpp 2009-03-16 17:15:49 UTC (rev 9748) @@ -253,6 +253,7 @@ plP_fci2hex(unicode, &fontWeight, PL_FCI_WEIGHT); QFont f; + f.setPointSizeF(currentFontSize*currentFontScale<4 ? 4 : currentFontSize*currentFontScale); switch(fontFamily) @@ -313,7 +314,7 @@ yOffset=0.; xOffset=0.; - currentFontSize=chrht*p.device()->logicalDpiY()/25.4*fontScalingFactor; + currentFontSize=chrht*72./25.4*1.5; currentFontScale=1.; underlined=false; overlined=false; @@ -424,11 +425,11 @@ QMatrix rotShearMatrix(cos(rotation)*stride, -sin(rotation)*stride, cos(rotation)*sin(shear)+sin(rotation)*cos(shear), -sin(rotation)*sin(shear)+cos(rotation)*cos(shear), 0., 0.); m_painterP->setWorldMatrix(rotShearMatrix, true); + m_painterP->translate(-txt->just*xOffset*m_painterP->device()->logicalDpiY()/picDpi, 0.); m_painterP->drawPicture(0., 0., picText); m_painterP->setWorldMatrix(QMatrix()); - } void QtPLDriver::setColor(int r, int g, int b, double alpha) @@ -657,14 +658,14 @@ b.setStyle(Qt::SolidPattern); m_painterP->setBrush(b); m_painterP->setRenderHint(QPainter::Antialiasing, true); - int res=DPI/25.4*1000.; - setDotsPerMeterX(res); - setDotsPerMeterY(res); +// int res=DPI/25.4/downscale*1000.; +// setDotsPerMeterX(res); +// setDotsPerMeterY(res); // Let's fill the background m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); - fontScalingFactor=1.; +// fontScalingFactor=1.; } QtRasterDevice::~QtRasterDevice() @@ -710,13 +711,6 @@ pls->dev_unicode = 1; // want unicode initQtApp(false); - /*$$ these variables must be 1 so that we can process - unicode text on our own */ - - - /*$$ if you want to use the hershey font only for the - symbols set this to 1 - pls->dev_hrshsym = 1; */ // Shamelessly copied on the Cairo stuff :) if (pls->xlength <= 0 || pls->ylength <= 0) @@ -739,6 +733,8 @@ plP_setpxl(DPI/25.4/((QtRasterDevice*)(pls->dev))->downscale, DPI/25.4/((QtRasterDevice*)(pls->dev))->downscale); + ((QtRasterDevice*)(pls->dev))->setResolution(pls->xpmm); + /* Initialize family file info */ plFamInit(pls); @@ -916,7 +912,7 @@ setSize(QSize(m_dWidth, m_dHeight)); m_painterP=NULL; - fontScalingFactor=1.; +// fontScalingFactor=1.; } QtSVGDevice::~QtSVGDevice() @@ -1041,7 +1037,7 @@ m_dHeight=pageRect().height(); m_painterP=NULL; - fontScalingFactor=1.; +// fontScalingFactor=1.; } QtEPSDevice::~QtEPSDevice() @@ -1211,7 +1207,7 @@ pic=new QPicture; m_painterP->begin(pic); - fontScalingFactor=0.6; +// fontScalingFactor=1.;//0.6; } @@ -1490,7 +1486,10 @@ plP_setphy((PLINT) 0, (PLINT) (plsc->xlength / tabWidget->downscale), (PLINT) 0, (PLINT) (plsc->ylength / tabWidget->downscale)); - plP_setpxl(DPI/25.4/tabWidget->downscale, DPI/25.4/tabWidget->downscale); + QPicture temp; + QPainter tempPainter(&temp); + + plP_setpxl(temp.logicalDpiX()/25.4/tabWidget->downscale, temp.logicalDpiY()/25.4/tabWidget->downscale); pls->color = 1; /* Is a color device */ pls->plbuf_write=0; @@ -1523,7 +1522,7 @@ delete ((QtPLTabWidget*)pls->dev); pls->dev=NULL; - closeQtApp(); +// closeQtApp(); } #endif Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-16 15:29:08 UTC (rev 9747) +++ trunk/drivers/qt.h 2009-03-16 17:15:49 UTC (rev 9748) @@ -98,7 +98,7 @@ double yOffset; double xOffset; - double fontScalingFactor;// To have a nice font size on qtwidget +// double fontScalingFactor;// To have a nice font size on qtwidget QPainter* m_painterP; }; @@ -117,6 +117,12 @@ void savePlot(); + virtual void setResolution(double dotsPerMM) + { + setDotsPerMeterX(dotsPerMM*1000.*downscale); + setDotsPerMeterY(dotsPerMM*1000.*downscale); + } + protected: char format[5]; QString fileName; @@ -309,6 +315,8 @@ 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. |
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. |
From: <ai...@us...> - 2009-03-18 15:46:24
|
Revision: 9751 http://plplot.svn.sourceforge.net/plplot/?rev=9751&view=rev Author: airwin Date: 2009-03-18 15:46:17 +0000 (Wed, 18 Mar 2009) Log Message: ----------- AWI for Alban Rochel. This patch corrects some issues (DPI value set incorrectly, swapping QtEPSDevice versus QtSVGDevice logic, causing errors in both) in the previous patch that was committed. Also, this patch allows a proper bounding box to be used for eps and pdf results for newer versions of libqt. (AWI comment. This adjustment looks much better for svg, eps, and pdf without hurting anything else.) Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-17 23:09:00 UTC (rev 9750) +++ trunk/drivers/qt.cpp 2009-03-18 15:46:17 UTC (rev 9751) @@ -29,6 +29,7 @@ */ + #include "qt.h" // global variables initialised in init(), used in tidy() @@ -908,7 +909,6 @@ QtSVGDevice::QtSVGDevice(int i_iWidth, int i_iHeight): QtPLDriver(i_iWidth, i_iHeight) { - setSize(QSize(m_dWidth, m_dHeight)); m_painterP=NULL; // fontScalingFactor=1.; @@ -923,6 +923,7 @@ { setFileName(QString(fileName)); setResolution(DPI); + setSize(QSize(m_dWidth, m_dHeight)); m_painterP=new QPainter(this); m_painterP->fillRect(0, 0, m_dWidth, m_dHeight, QBrush(Qt::black)); @@ -1026,7 +1027,12 @@ #if defined (PLD_epsqt) || defined(PLD_pdfqt) QtEPSDevice::QtEPSDevice(int i_iWidth, int i_iHeight) { +#if QT_VERSION < 0x040400 setPageSize(QPrinter::A4); +#else + setFullPage(true); + setPaperSize(QSizeF(i_iWidth, i_iHeight), QPrinter::Point); +#endif setResolution(DPI); setColorMode(QPrinter::Color); setOrientation(QPrinter::Landscape); Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-17 23:09:00 UTC (rev 9750) +++ trunk/drivers/qt.h 2009-03-18 15:46:17 UTC (rev 9751) @@ -29,6 +29,16 @@ */ +/* +Interpretation of the -geometry factor for the various devices: +- bmpqt, jpgqt, pngqt, ppmqt, tiffqt: + The geometry parameter defines the size in pixels +- svgqt, epsqt, pdfqt: + The geometry parameter defines the size in points (1/72 of inches). EPS and PDF files will be drawn in A4 pages for Qt versions before 4.4 +- qtwidget: + The geometry factor defines the default size of the widget, as well as its aspect ratio, which is kept when the widget is resized. + */ + #ifndef QT_H #define QT_H @@ -47,7 +57,7 @@ #include "plplotP.h" #include "drivers.h" -#define DPI 120 //72 +#define DPI 72 #define QT_DEFAULT_X 842 #define QT_DEFAULT_Y 598 @@ -136,8 +146,8 @@ class QtSVGDevice: public QtPLDriver, public QSvgGenerator { public: - QtSVGDevice(int i_iWidth=-1, - int i_iHeight=-1); + QtSVGDevice(int i_iWidth=QT_DEFAULT_X, + int i_iHeight=QT_DEFAULT_Y); virtual ~QtSVGDevice(); @@ -154,8 +164,8 @@ class QtEPSDevice: public QtPLDriver, public QPrinter { public: - QtEPSDevice(int i_iWidth=QT_DEFAULT_X, - int i_iHeight=QT_DEFAULT_Y); + QtEPSDevice(int i_iWidth=-1, + int i_iHeight=-1); virtual ~QtEPSDevice(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-21 15:39:12
|
Revision: 9765 http://plplot.svn.sourceforge.net/plplot/?rev=9765&view=rev Author: airwin Date: 2009-03-21 15:39:08 +0000 (Sat, 21 Mar 2009) Log Message: ----------- AWI for Alban Rochel. - Introduce a mutex to make driver thread safe. Andrew noticed that when 2 qtwidgets were running on 2 streams, closing them didn't close the driver properly. This issue should be fixed by this change. Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-21 00:53:53 UTC (rev 9764) +++ trunk/drivers/qt.cpp 2009-03-21 15:39:08 UTC (rev 9765) @@ -71,6 +71,7 @@ void initQtApp(bool isGUI) { + QtPLDriver::mutex.lock(); ++appCounter; if(qApp==NULL && appCounter==1) { @@ -82,10 +83,12 @@ argv[1][0]='\0'; /*app=*/new QApplication(argc, argv, isGUI ); } + QtPLDriver::mutex.unlock(); } void closeQtApp() { + QtPLDriver::mutex.lock(); --appCounter; if(qApp!=NULL && appCounter==0) { @@ -96,6 +99,7 @@ delete[] argv; argv=NULL; } + QtPLDriver::mutex.unlock(); } /*--------------------------------------------------------------------- @@ -1465,6 +1469,21 @@ widgets.push_back(plotWidget); } +void QtPLTabWidget::exec() +{ + mutex.lock(); + if(!alreadyRun) // This tab widget has never been run + { + qApp->exec(); + foreach(QtPLTabWidget* tab, runningDevices) // All the tab widgets created before have been run in the same time. Let's tag them. + { + tab->alreadyRun=true; + } + + } + runningDevices.removeAll(this); // cleaning up + mutex.unlock(); +} void plD_dispatch_init_qtwidget(PLDispatchTable *pdt) { @@ -1547,11 +1566,11 @@ void plD_tidy_qtwidget(PLStream *pls) { - qApp->exec(); + QtPLTabWidget * w=((QtPLTabWidget*)pls->dev); + w->exec(); + // At this point, the widget has been run, we can delete it delete ((QtPLTabWidget*)pls->dev); pls->dev=NULL; - -// closeQtApp(); } #endif Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-21 00:53:53 UTC (rev 9764) +++ trunk/drivers/qt.h 2009-03-21 15:39:08 UTC (rev 9765) @@ -53,6 +53,7 @@ #include <QTabWidget> #include <QMainWindow> #include <QPicture> +#include <QMutex> #include "plplotP.h" #include "drivers.h" @@ -91,6 +92,8 @@ // Conversion factor from internal plplot coordinates to device coordinates double downscale; double m_dWidth, m_dHeight; + + static QMutex mutex; // All-purpose mutex protected: // Returns font with the good size for a QPicture's resolution @@ -113,6 +116,8 @@ QPainter* m_painterP; }; +QMutex QtPLDriver::mutex; + #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) // Driver painting whatever raster format Qt can save class QtRasterDevice: public QtPLDriver, public QImage @@ -263,6 +268,11 @@ m_iWidth=i_iWidth; m_iHeight=i_iHeight; currentWidget=NULL; + + mutex.lock(); // All QtPLTabWidgets are registered + alreadyRun=false; + runningDevices.push_back(this); + mutex.unlock(); } ~QtPLTabWidget(); @@ -324,10 +334,15 @@ virtual void savePlot(char* fileName){} + void exec(); + QtPLWidget* currentWidget; int m_iWidth, m_iHeight; + static QList<QtPLTabWidget*> runningDevices; + bool alreadyRun; + protected: void newTab(); QList<QtPLWidget*> widgets; @@ -337,6 +352,8 @@ }; +QList<QtPLTabWidget*> QtPLTabWidget::runningDevices; + #endif #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-21 16:54:36
|
Revision: 9766 http://plplot.svn.sourceforge.net/plplot/?rev=9766&view=rev Author: airwin Date: 2009-03-21 16:54:17 +0000 (Sat, 21 Mar 2009) Log Message: ----------- Restore default height and width for epsqt and pdfqt devices for Qt-4.5 case. Swap sense of x and y for bounding box in Qt-4.5 case. Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-21 15:39:08 UTC (rev 9765) +++ trunk/drivers/qt.cpp 2009-03-21 16:54:17 UTC (rev 9766) @@ -1035,7 +1035,7 @@ setPageSize(QPrinter::A4); #else setFullPage(true); - setPaperSize(QSizeF(i_iWidth, i_iHeight), QPrinter::Point); + setPaperSize(QSizeF(i_iHeight, i_iWidth), QPrinter::Point); #endif setResolution(DPI); setColorMode(QPrinter::Color); @@ -1510,10 +1510,6 @@ QMainWindow * mw=new QMainWindow; QtPLTabWidget* tabWidget;//=new QtPLTabWidget; -// plsc->dev = (void*)tabWidget; -// plsc->xlength = tabWidget->m_dWidth; -// plsc->ylength = tabWidget->m_dHeight; - if (pls->xlength <= 0 || pls->ylength <= 0) { tabWidget=new QtPLTabWidget; Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-21 15:39:08 UTC (rev 9765) +++ trunk/drivers/qt.h 2009-03-21 16:54:17 UTC (rev 9766) @@ -169,8 +169,11 @@ class QtEPSDevice: public QtPLDriver, public QPrinter { public: - QtEPSDevice(int i_iWidth=-1, - int i_iHeight=-1); +#if QT_VERSION < 0x040400 + QtEPSDevice(int i_iWidth=-1, int i_iHeight=-1); +#else + QtEPSDevice(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y); +#endif virtual ~QtEPSDevice(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-24 22:02:56
|
Revision: 9771 http://plplot.svn.sourceforge.net/plplot/?rev=9771&view=rev Author: airwin Date: 2009-03-24 22:02:46 +0000 (Tue, 24 Mar 2009) Log Message: ----------- Improve self-documentation. Distinguish between setting number of points per inch (always 72) for "points" device drivers (epsqt, pdfqt, and svgqt), and setting pixels per inch (or dots per inch) for raster devices. Raster version of setResolution changed so it has dots per inch argument similar to points per inch argument for the epsqt, pdfqt, and svgqt versions. Comment out downscale=1.; statement in QtPLDriver which must have been ignored in any case, but which confuses the casual reader of the code. Allow user to control dpi via -dpi command-line option or by using plspage. Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-24 08:20:09 UTC (rev 9770) +++ trunk/drivers/qt.cpp 2009-03-24 22:02:46 UTC (rev 9771) @@ -6,6 +6,7 @@ Imperial College, London Copyright (C) 2009 Imperial College, London + Copyright (C) 2009 Alan W. Irwin This is free software; you can redistribute it and/or modify it under the terms of the GNU General Lesser Public License as published @@ -201,7 +202,7 @@ { m_dWidth=i_iWidth; m_dHeight=i_iHeight; - downscale=1.; +// downscale=1.; // fontScalingFactor=1.; } @@ -318,7 +319,11 @@ yOffset=0.; xOffset=0.; - currentFontSize=chrht*72./25.4*1.6; + // Scaling factor of 1.6 determined empirically to make all qt results + // have the same character size as cairo results (taking into account + // the slightly different actual glyph sizes for the different + // default fonts found by cairo and qt). + currentFontSize=chrht*POINTS_PER_INCH/25.4*1.6; currentFontScale=1.; underlined=false; overlined=false; @@ -662,9 +667,6 @@ b.setStyle(Qt::SolidPattern); m_painterP->setBrush(b); m_painterP->setRenderHint(QPainter::Antialiasing, true); -// int res=DPI/25.4/downscale*1000.; -// setDotsPerMeterX(res); -// setDotsPerMeterY(res); // Let's fill the background m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); @@ -701,6 +703,7 @@ void plD_init_rasterqt(PLStream * pls) { + double dpi; /* Stream setup */ pls->color = 1; pls->plbuf_write=0; @@ -716,6 +719,13 @@ initQtApp(false); + if (pls->xdpi <=0.) + dpi = DEFAULT_DPI; + else + dpi = pls->xdpi; + // For raster debug + // std::cout << dpi << std::endl; + // Shamelessly copied on the Cairo stuff :) if (pls->xlength <= 0 || pls->ylength <= 0) { @@ -735,9 +745,9 @@ plP_setphy((PLINT) 0, (PLINT) (pls->xlength / ((QtRasterDevice*)(pls->dev))->downscale), (PLINT) 0, (PLINT) (pls->ylength / ((QtRasterDevice*)(pls->dev))->downscale)); - plP_setpxl(DPI/25.4/((QtRasterDevice*)(pls->dev))->downscale, DPI/25.4/((QtRasterDevice*)(pls->dev))->downscale); + plP_setpxl(dpi/25.4/((QtRasterDevice*)(pls->dev))->downscale, dpi/25.4/((QtRasterDevice*)(pls->dev))->downscale); - ((QtRasterDevice*)(pls->dev))->setResolution(pls->xpmm); + ((QtRasterDevice*)(pls->dev))->setResolution(dpi); /* Initialize family file info */ plFamInit(pls); @@ -926,7 +936,7 @@ void QtSVGDevice::definePlotName(const char* fileName) { setFileName(QString(fileName)); - setResolution(DPI); + setResolution(POINTS_PER_INCH); setSize(QSize(m_dWidth, m_dHeight)); m_painterP=new QPainter(this); @@ -991,7 +1001,7 @@ plP_setphy((PLINT) 0, (PLINT) (pls->xlength / ((QtSVGDevice*)(pls->dev))->downscale), (PLINT) 0, (PLINT) (pls->ylength / ((QtSVGDevice*)(pls->dev))->downscale)); - plP_setpxl(DPI/25.4/((QtSVGDevice*)(pls->dev))->downscale, DPI/25.4/((QtSVGDevice*)(pls->dev))->downscale); + plP_setpxl(POINTS_PER_INCH/25.4/((QtSVGDevice*)(pls->dev))->downscale, POINTS_PER_INCH/25.4/((QtSVGDevice*)(pls->dev))->downscale); /* Initialize family file info */ plFamInit(pls); @@ -1037,7 +1047,7 @@ setFullPage(true); setPaperSize(QSizeF(i_iHeight, i_iWidth), QPrinter::Point); #endif - setResolution(DPI); + setResolution(POINTS_PER_INCH); setColorMode(QPrinter::Color); setOrientation(QPrinter::Landscape); setPrintProgram(QString("lpr")); @@ -1159,7 +1169,7 @@ plP_setphy((PLINT) 0, (PLINT) (pls->xlength / ((QtEPSDevice*)(pls->dev))->downscale), (PLINT) 0, (PLINT) (pls->ylength / ((QtEPSDevice*)(pls->dev))->downscale)); - plP_setpxl(DPI/25.4/((QtEPSDevice*)(pls->dev))->downscale, DPI/25.4/((QtEPSDevice*)(pls->dev))->downscale); + plP_setpxl(POINTS_PER_INCH/25.4/((QtEPSDevice*)(pls->dev))->downscale, POINTS_PER_INCH/25.4/((QtEPSDevice*)(pls->dev))->downscale); /* Initialize family file info */ plFamInit(pls); Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-24 08:20:09 UTC (rev 9770) +++ trunk/drivers/qt.h 2009-03-24 22:02:46 UTC (rev 9771) @@ -6,6 +6,7 @@ Imperial College, London Copyright (C) 2009 Imperial College, London + Copyright (C) 2009 Alan W. Irwin This is free software; you can redistribute it and/or modify it under the terms of the GNU General Lesser Public License as published @@ -30,13 +31,25 @@ */ /* -Interpretation of the -geometry factor for the various devices: -- bmpqt, jpgqt, pngqt, ppmqt, tiffqt: - The geometry parameter defines the size in pixels +Interpretation of the -geometry XSIZExYSIZE option (or the third and fourth + parameters of plspage if those are specified by the user instead) for + the various devices: +- the raster devices (bmpqt, jpgqt, pngqt, ppmqt, tiffqt): + XSIZE and YSIZE define the x and y size in pixels +- qtwidget: + XSIZE and YSIZE define the default x and y size of the widget in + pixels, as well as its aspect ratio, which is kept when the widget is + resized. - svgqt, epsqt, pdfqt: - The geometry parameter defines the size in points (1/72 of inches). EPS and PDF files will be drawn in A4 pages for Qt versions before 4.4 -- qtwidget: - The geometry factor defines the default size of the widget, as well as its aspect ratio, which is kept when the widget is resized. + XSIZE and YSIZE define the x and y size in points (1/72 of inches). + EPS and PDF files will be drawn in A4 pages for Qt versions before 4.4 + +Interpretation of the -dpi DPI option (or the first parameter of + plspage if that is specified by the user instead). + DPI is ignored for all but the raster devices. For those devices + DPI should be set to the DPI value of the monitor being used to view + the results if exact character sizes are desired. Otherwise, DEFAULT_DPI + (set to an average value for modern monitors) is used instead. */ #ifndef QT_H @@ -58,7 +71,20 @@ #include "plplotP.h" #include "drivers.h" -#define DPI 72 +// Used for devices (epsqt, pdfqt, svgqt) with known physical size in points. +#define POINTS_PER_INCH 72 + +// Average value of dots per inch assumed for modern monitors if the user +// does not specify a value appropriate to their monitor with plspage or +// the -dpi option. Used only for devices with size specified in pixels +// but not qtwidget since it has independent access to information (e.g., +// delivered by X) about the DPI of the monitor. So this value is only +// used for the raster devices (bmpqt, jpgqt, pngqt, ppmqt, tiffqt). +#define DEFAULT_DPI 80 + +// These values are in units of pixels (the raster devices and qtwidget) +// or points (epsqt, pdfqt, svgqt). In the points case, this corresponds +// to the A4 paper size. #define QT_DEFAULT_X 842 #define QT_DEFAULT_Y 595 @@ -132,10 +158,10 @@ void savePlot(); - virtual void setResolution(double dotsPerMM) + virtual void setResolution(double dotsPerInch) { - setDotsPerMeterX(dotsPerMM*1000.*downscale); - setDotsPerMeterY(dotsPerMM*1000.*downscale); + setDotsPerMeterX((dotsPerInch/25.4)*1000.); + setDotsPerMeterY((dotsPerInch/25.4)*1000.); } protected: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-31 19:25:11
|
Revision: 9780 http://plplot.svn.sourceforge.net/plplot/?rev=9780&view=rev Author: airwin Date: 2009-03-31 19:25:07 +0000 (Tue, 31 Mar 2009) Log Message: ----------- AWI for Alban Rochel. Implement text clipping. Fix multiple stream issues demonstrated previously by example 14. Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-31 19:02:28 UTC (rev 9779) +++ trunk/drivers/qt.cpp 2009-03-31 19:25:07 UTC (rev 9780) @@ -70,9 +70,12 @@ #endif ; -void initQtApp(bool isGUI) +MasterHandler handler; + +bool initQtApp(bool isGUI) { QtPLDriver::mutex.lock(); + bool res=false; ++appCounter; if(qApp==NULL && appCounter==1) { @@ -82,9 +85,11 @@ argv[1]=new char[1]; snprintf(argv[0], 10, "qt_driver"); argv[1][0]='\0'; - /*app=*/new QApplication(argc, argv, isGUI ); + new QApplication(argc, argv, isGUI); + res=true; } QtPLDriver::mutex.unlock(); + return res; } void closeQtApp() @@ -94,7 +99,6 @@ if(qApp!=NULL && appCounter==0) { delete qApp; -// qApp=NULL; delete[] argv[0]; delete[] argv[1]; delete[] argv; @@ -184,7 +188,6 @@ void plD_dispatch_init_qtwidget(PLDispatchTable *pdt); void plD_init_qtwidget(PLStream *); void plD_eop_qtwidget(PLStream *); -void plD_tidy_qtwidget(PLStream *); #endif // Declaration of the generic interface functions @@ -198,19 +201,21 @@ ///////////// Generic Qt driver class ///////////////// +QMutex QtPLDriver::mutex; + QtPLDriver::QtPLDriver(PLINT i_iWidth, PLINT i_iHeight) { m_dWidth=i_iWidth; m_dHeight=i_iHeight; -// downscale=1.; -// fontScalingFactor=1.; } QtPLDriver::~QtPLDriver() -{} +{ +} void QtPLDriver::drawLine(short x1, short y1, short x2, short y2) { + if(!m_painterP->isActive()) return; QLineF line( (PLFLT)x1*downscale, m_dHeight-(PLFLT)y1*downscale, (PLFLT)x2*downscale, @@ -222,6 +227,7 @@ void QtPLDriver::drawPolyline(short * x, short * y, PLINT npts) { + if(!m_painterP->isActive()) return; QPointF * polyline=new QPointF[npts]; for(int i=0; i<npts; ++i) { @@ -234,6 +240,7 @@ void QtPLDriver::drawPolygon(short * x, short * y, PLINT npts) { + if(!m_painterP->isActive()) return; QPointF * polygon=new QPointF[npts]; for(int i=0; i<npts; ++i) { @@ -244,10 +251,6 @@ delete[] polygon; } -// QRect getNewRect(const QRect& input, double yOffset, double fontSize) -// { -// return QRect(input.right(), -yOffset*fontSize, 2, 2); -// } QFont QtPLDriver::getFont(PLUNICODE unicode) { @@ -279,6 +282,8 @@ void QtPLDriver::drawTextInPicture(QPainter* p, const QString& text) { + if(!m_painterP->isActive()) return; + QPicture tempPic; QPainter tempPainter(&tempPic); tempPainter.setFont(p->font()); @@ -286,18 +291,11 @@ QRectF bounding; 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()); -// tempPainter.drawLine(bounding.right(), bounding.bottom(), bounding.right(), bounding.top()); -// tempPainter.drawLine(0., bounding.bottom()+5., 0., bounding.top()-5.); + bounding.adjust(-0.5, bounding.height(), -0.5, -bounding.height()/5.); // Empiric adjustment of the true bounding box + tempPainter.end(); p->drawPicture(xOffset+bounding.width()/2., -yOffset, tempPic); - xOffset+=bounding.width(); } @@ -329,7 +327,7 @@ overlined=false; p.setFont(getFont(fci)); - + int i=0; while(i < len) { @@ -410,6 +408,8 @@ void QtPLDriver::drawText(PLStream* pls, EscText* txt) { + if(!m_painterP->isActive()) return; + /* Check that we got unicode, warning message and return if not */ if( txt->unicode_array_len == 0 ) { printf( "Non unicode string passed to a Qt driver, ignoring\n" ); @@ -429,6 +429,9 @@ QPicture picText=getTextPicture(txt->unicode_array, txt->unicode_array_len, pls->chrht); picDpi=picText.logicalDpiY(); + m_painterP->setClipping(true); + m_painterP->setClipRect(QRect(pls->clpxmi*downscale, m_dHeight-pls->clpyma*downscale, (pls->clpxma-pls->clpxmi)*downscale, (pls->clpyma-pls->clpymi)*downscale), Qt::ReplaceClip); + rotation -= pls->diorot * M_PI / 2.0; m_painterP->translate(txt->x*downscale, m_dHeight-txt->y*downscale); QMatrix rotShearMatrix(cos(rotation)*stride, -sin(rotation)*stride, cos(rotation)*sin(shear)+sin(rotation)*cos(shear), -sin(rotation)*sin(shear)+cos(rotation)*cos(shear), 0., 0.); @@ -436,13 +439,17 @@ m_painterP->setWorldMatrix(rotShearMatrix, true); m_painterP->translate(-txt->just*xOffset*m_painterP->device()->logicalDpiY()/picDpi, 0.); + m_painterP->drawPicture(0., 0., picText); m_painterP->setWorldMatrix(QMatrix()); + m_painterP->setClipping(false); } void QtPLDriver::setColor(int r, int g, int b, double alpha) { + if(!m_painterP->isActive()) return; + QPen p=m_painterP->pen(); p.setColor(QColor(r, g, b, alpha*255)); m_painterP->setPen(p); @@ -455,6 +462,8 @@ void QtPLDriver::setWidth(PLINT w) { + if(!m_painterP->isActive()) return; + QPen p=m_painterP->pen(); p.setWidth(w); m_painterP->setPen(p); @@ -462,6 +471,8 @@ void QtPLDriver::setDashed(PLINT nms, PLINT* mark, PLINT* space) { + if(!m_painterP->isActive()) return; + QVector<qreal> vect; for(int i=0; i<nms; ++i) { @@ -475,6 +486,8 @@ void QtPLDriver::setSolid() { + if(!m_painterP->isActive()) return; + QPen p=m_painterP->pen(); p.setStyle(Qt::SolidLine); m_painterP->setPen(p); @@ -500,7 +513,7 @@ if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_qtwidget) - if(widget==NULL) widget=dynamic_cast<QtPLTabWidget*>((QWidget *) pls->dev); + if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); #endif if(widget==NULL) return; @@ -525,7 +538,7 @@ if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_qtwidget) - if(widget==NULL) widget=dynamic_cast<QtPLTabWidget*>((QWidget *) pls->dev); + if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); #endif if(widget==NULL) return; @@ -552,7 +565,7 @@ if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_qtwidget) - if(widget==NULL) widget=dynamic_cast<QtPLTabWidget*>((QWidget *) pls->dev); + if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); #endif if(widget==NULL) return; @@ -608,7 +621,7 @@ if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_qtwidget) - if(widget==NULL) widget=dynamic_cast<QtPLTabWidget*>((QWidget *) pls->dev); + if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); #endif if(widget==NULL) return; @@ -643,9 +656,13 @@ #if defined(PLD_epsqt) || defined(PLD_pdfqt) if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); #endif +#if defined(PLD_qtwidget) + if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QtPLWidget *) pls->dev); +#endif if(widget!=NULL) { + handler.DeviceClosed(widget); delete widget; pls->dev=NULL; } @@ -720,7 +737,7 @@ pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode - initQtApp(false); + bool isMaster=initQtApp(/*false*/true); // Is it still a problem? if (pls->xdpi <=0.) dpi = DEFAULT_DPI; @@ -740,7 +757,9 @@ { pls->dev=new QtRasterDevice(pls->xlength, pls->ylength); } - + + if(isMaster) handler.setMasterDevice((QtRasterDevice*)(pls->dev)); + if (pls->xlength > pls->ylength) ((QtRasterDevice*)(pls->dev))->downscale = (PLFLT)pls->xlength/(PLFLT)(PIXELS_X-1); else @@ -762,6 +781,7 @@ { if(qt_family_check(pls)) {return;} ((QtRasterDevice *)pls->dev)->savePlot(); + handler.DeviceChangedPage((QtRasterDevice *)pls->dev); } #endif @@ -990,7 +1010,7 @@ pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode - initQtApp(false); + bool isMaster=initQtApp(/*false*/ true); // Is is still a problem? if (pls->xlength <= 0 || pls->ylength <= 0) { @@ -1002,7 +1022,9 @@ { pls->dev=new QtSVGDevice(pls->xlength, pls->ylength); } - + + if(isMaster) handler.setMasterDevice((QtSVGDevice*)(pls->dev)); + if (pls->xlength > pls->ylength) ((QtSVGDevice*)(pls->dev))->downscale = (PLFLT)pls->xlength/(PLFLT)(PIXELS_X-1); else @@ -1039,10 +1061,14 @@ // to be able to plot another page. downscale=((QtSVGDevice *)pls->dev)->downscale; s=((QtSVGDevice *)pls->dev)->size(); + bool isMaster=(handler.isMasterDevice((QtSVGDevice *)pls->dev)); delete ((QtSVGDevice *)pls->dev); pls->dev=new QtSVGDevice(s.width(), s.height()); ((QtSVGDevice *)pls->dev)->downscale=downscale; + + if(isMaster) handler.setMasterDevice((QtSVGDevice *)pls->dev); + handler.DeviceChangedPage((QtSVGDevice *)pls->dev); } #endif @@ -1161,7 +1187,7 @@ pls->dev_unicode = 1; // want unicode // QPrinter devices won't create if there is no QApplication declared... - initQtApp(false); + bool isMaster=initQtApp(/*false*/true); //Is it still a problem? if (pls->xlength <= 0 || pls->ylength <= 0) { @@ -1173,7 +1199,9 @@ { pls->dev=new QtEPSDevice(pls->xlength, pls->ylength); } - + + if(isMaster) handler.setMasterDevice((QtEPSDevice*)(pls->dev)); + if (pls->xlength > pls->ylength) ((QtEPSDevice*)(pls->dev))->downscale = (PLFLT)pls->xlength/(PLFLT)(PIXELS_X-1); else @@ -1211,11 +1239,14 @@ // Once saved, we have to create a new device with the same properties // to be able to plot another page. downscale=((QtEPSDevice *)pls->dev)->downscale; + bool isMaster=handler.isMasterDevice((QtEPSDevice *)pls->dev); delete ((QtEPSDevice *)pls->dev); - //QApplication * app=new QApplication(argc, (char**)&argv); + pls->dev=new QtEPSDevice; ((QtEPSDevice *)pls->dev)->downscale=downscale; - //delete app; + + if(isMaster) handler.setMasterDevice((QtEPSDevice *)pls->dev); + handler.DeviceChangedPage((QtEPSDevice *)pls->dev); } #if defined(PLD_epsqt) @@ -1240,22 +1271,18 @@ 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); - pic=new QPicture; m_painterP->begin(pic); + m_painterP->setRenderHint(QPainter::Antialiasing, true); + pageNumber=1; -// fontScalingFactor=1.;//0.6; - } QtPLWidget::~QtPLWidget() { -// clearBuffer(); if(m_pixPixmap!=NULL) delete m_pixPixmap; if(m_painterP!=NULL) delete m_painterP; if(pic!=NULL) delete pic; @@ -1263,62 +1290,35 @@ void QtPLWidget::clearWidget() { -// clearBuffer(); - m_painterP->end(); + if(m_painterP->isActive()) m_painterP->end(); delete pic; pic=new QPicture; m_painterP->begin(pic); + m_painterP->setRenderHint(QPainter::Antialiasing, true); m_bAwaitingRedraw=true; update(); } -// void QtPLWidget::captureMousePlotCoords(double * xi, double* yi, double * xf, double * yf) -// { -// setMouseTracking(true); -// cursorParameters.isTracking=true; -// cursorParameters.cursor_start_x= -// cursorParameters.cursor_start_y= -// cursorParameters.cursor_end_x= -// cursorParameters.cursor_end_y=-1.; -// cursorParameters.step=1; -// do -// { -// QCoreApplication::processEvents(QEventLoop::AllEvents, 10); -// -// } while(cursorParameters.isTracking); -// -// PLFLT a,b; -// PLINT c; -// plcalc_world(cursorParameters.cursor_start_x, 1.-cursorParameters.cursor_start_y, &a, &b, &c); -// *xi=a; -// *yi=b; -// plcalc_world(cursorParameters.cursor_end_x, 1.-cursorParameters.cursor_end_y, &a, &b, &c); -// *xf=a; -// *yf=b; -// -// } -// -// void QtPLWidget::captureMouseDeviceCoords(double * xi, double* yi, double * xf, double * yf) -// { -// setMouseTracking(true); -// cursorParameters.isTracking=true; -// cursorParameters.cursor_start_x= -// cursorParameters.cursor_start_y= -// cursorParameters.cursor_end_x= -// cursorParameters.cursor_end_y=-1.; -// cursorParameters.step=1; -// do -// { -// QCoreApplication::processEvents(QEventLoop::AllEvents, 10); -// -// } while(cursorParameters.isTracking); -// -// *xi=cursorParameters.cursor_start_x; -// *yi=cursorParameters.cursor_start_y; -// *xf=cursorParameters.cursor_end_x; -// *yf=cursorParameters.cursor_end_y; -// } +void QtPLWidget::mouseReleaseEvent ( QMouseEvent * event ) +{ + if(event->button()==Qt::RightButton) + { + handler.DeviceChangedPage(this); + } +} +void QtPLWidget::closeEvent(QCloseEvent* event) +{ + handler.DeviceClosed(this); + event->ignore(); +} + +void QtPLWidget::nextPage() +{ + clearWidget(); + pageNumber++; +} + void QtPLWidget::resizeEvent( QResizeEvent * ) { m_bAwaitingRedraw=true; @@ -1335,7 +1335,7 @@ double x_fact, y_fact, x_offset(0.), y_offset(0.); //Parameters to scale and center the plot on the widget getPlotParameters(x_fact, y_fact, x_offset, y_offset); QPainter * painter=new QPainter; - // If actual redraw, not just adding the cursor acquisition traces + if(m_bAwaitingRedraw || m_pixPixmap==NULL) { if(m_pixPixmap!=NULL) delete m_pixPixmap; @@ -1352,105 +1352,13 @@ } painter->begin(this); -// -// // repaint plot + painter->drawPixmap(0, 0, *m_pixPixmap); - // now paint the cursor tracking patterns -// if(cursorParameters.isTracking) -// { -// QPen p=painter->pen(); -// p.setColor(Qt::white); -// if(cursorParameters.step==1) -// { -// painter->setPen(p); -// painter->drawLine((int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), 0, (int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), height()); -// painter->drawLine(0, (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset), width(), (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset)); -// } -// else -// { -// p.setStyle(Qt::DotLine); -// painter->setPen(p); -// painter->drawLine((int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), 0, (int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), height()); -// painter->drawLine(0, (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset), width(), (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset)); -// p.setStyle(Qt::SolidLine); -// painter->setPen(p); -// painter->drawLine((int)(cursorParameters.cursor_end_x*x_fact*m_dWidth+x_offset), 0, (int)(cursorParameters.cursor_end_x*x_fact*m_dWidth+x_offset), height()); -// painter->drawLine(0, (int)(cursorParameters.cursor_end_y*y_fact*m_dHeight+y_offset), width(), (int)(cursorParameters.cursor_end_y*y_fact*m_dHeight+y_offset)); -// } -// } - painter->end(); delete painter; } -// void QtPLWidget::mousePressEvent(QMouseEvent* event) -// { -// if(!cursorParameters.isTracking) return; -// -// double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget -// -// getPlotParameters(x_fact, y_fact, x_offset, y_offset); -// -// PLFLT X=(PLFLT)(event->x()-x_offset)/(m_dWidth*x_fact); -// PLFLT Y=(PLFLT)(event->y()-y_offset)/(m_dHeight*y_fact); -// -// if(cursorParameters.step==1) -// { -// cursorParameters.cursor_start_x=X; -// cursorParameters.cursor_start_y=Y; -// cursorParameters.step=2; // First step of selection done, going to the next one -// update(); -// } -// } -// -// void QtPLWidget::mouseReleaseEvent(QMouseEvent* event) -// { -// double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget -// -// getPlotParameters(x_fact, y_fact, x_offset, y_offset); -// -// PLFLT X=(PLFLT)(event->x()-x_offset)/(m_dWidth*x_fact); -// PLFLT Y=(PLFLT)(event->y()-y_offset)/(m_dHeight*y_fact); -// -// if(cursorParameters.step!=1) -// { -// cursorParameters.cursor_end_x=X; -// cursorParameters.cursor_end_y=Y; -// cursorParameters.isTracking=false; -// setMouseTracking(false); -// update(); -// } -// } -// -// void QtPLWidget::mouseMoveEvent(QMouseEvent* event) -// { -// this->activateWindow(); -// this->raise(); -// -// if(!cursorParameters.isTracking) return; -// -// double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget -// -// getPlotParameters(x_fact, y_fact, x_offset, y_offset); -// -// PLFLT X=(PLFLT)(event->x()-x_offset)/(m_dWidth*x_fact); -// PLFLT Y=(PLFLT)(event->y()-y_offset)/(m_dHeight*y_fact); -// -// if(cursorParameters.step==1) -// { -// cursorParameters.cursor_start_x=X; -// cursorParameters.cursor_start_y=Y; -// } -// else -// { -// cursorParameters.cursor_end_x=X; -// cursorParameters.cursor_end_y=Y; -// } -// -// update(); -// } - void QtPLWidget::getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset) { double w=(double)width(); @@ -1472,41 +1380,6 @@ } } -QtPLTabWidget::~QtPLTabWidget() -{ - for(QList<QtPLWidget*>::iterator iter=widgets.begin(); iter!=widgets.end(); ++iter) - { - if(*iter!=NULL) delete (*iter); - } -} - -void QtPLTabWidget::newTab() -{ - QtPLWidget * plotWidget=new QtPLWidget(m_iWidth, m_iHeight); - plotWidget->downscale=downscale; -// plotWidget->m_dWidth=m_dWidth; -// plotWidget->m_dHeight=m_dHeight; - addTab(plotWidget, QString("page %1").arg(count()+1)); - currentWidget=plotWidget; - widgets.push_back(plotWidget); -} - -void QtPLTabWidget::exec() -{ - mutex.lock(); - if(!alreadyRun) // This tab widget has never been run - { - qApp->exec(); - foreach(QtPLTabWidget* tab, runningDevices) // All the tab widgets created before have been run in the same time. Let's tag them. - { - tab->alreadyRun=true; - } - - } - runningDevices.removeAll(this); // cleaning up - mutex.unlock(); -} - void plD_dispatch_init_qtwidget(PLDispatchTable *pdt) { #ifndef ENABLE_DYNDRIVERS @@ -1520,7 +1393,7 @@ pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; pdt->pl_eop = (plD_eop_fp) plD_eop_qtwidget; pdt->pl_bop = (plD_bop_fp) plD_bop_qt; - pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qtwidget; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; pdt->pl_state = (plD_state_fp) plD_state_qt; pdt->pl_esc = (plD_esc_fp) plD_esc_qt; } @@ -1528,34 +1401,35 @@ void plD_init_qtwidget(PLStream * pls) { PLINT w, h; - initQtApp(true); - QMainWindow * mw=new QMainWindow; - QtPLTabWidget* tabWidget;//=new QtPLTabWidget; + bool isMaster=initQtApp(true); + QtPLWidget* widget; if (pls->xlength <= 0 || pls->ylength <= 0) { - tabWidget=new QtPLTabWidget; - pls->dev=(void*) tabWidget; - pls->xlength = tabWidget->m_iWidth; - pls->ylength = tabWidget->m_iHeight; + widget=new QtPLWidget; + pls->dev=(void*) widget; + pls->xlength = (int)widget->m_dWidth; + pls->ylength = (int)widget->m_dHeight; } else { - tabWidget=new QtPLTabWidget(pls->xlength, pls->ylength); - pls->dev=(void*) tabWidget; + widget=new QtPLWidget(pls->xlength, pls->ylength); + pls->dev=(void*) widget; } - + + if(isMaster) handler.setMasterDevice(widget); + if (plsc->xlength > plsc->ylength) - tabWidget->downscale = (PLFLT)plsc->xlength/(PLFLT)(PIXELS_X-1); + widget->downscale = (PLFLT)plsc->xlength/(PLFLT)(PIXELS_X-1); else - tabWidget->downscale = (PLFLT)plsc->ylength/(PLFLT)PIXELS_Y; + widget->downscale = (PLFLT)plsc->ylength/(PLFLT)PIXELS_Y; - plP_setphy((PLINT) 0, (PLINT) (plsc->xlength / tabWidget->downscale), (PLINT) 0, (PLINT) (plsc->ylength / tabWidget->downscale)); + plP_setphy((PLINT) 0, (PLINT) (plsc->xlength / widget->downscale), (PLINT) 0, (PLINT) (plsc->ylength / widget->downscale)); QPicture temp; QPainter tempPainter(&temp); - plP_setpxl(temp.logicalDpiX()/25.4/tabWidget->downscale, temp.logicalDpiY()/25.4/tabWidget->downscale); + plP_setpxl(temp.logicalDpiX()/25.4/widget->downscale, temp.logicalDpiY()/25.4/widget->downscale); pls->color = 1; /* Is a color device */ pls->plbuf_write=0; @@ -1567,32 +1441,28 @@ pls->dev_dash=0; pls->dev_flush=1; pls->dev_clear=1; - pls->termin=1; +// pls->termin=1; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode - mw->setCentralWidget(tabWidget); - mw->setVisible(true); - mw->setWindowTitle("plplot"); - mw->resize(plsc->xlength, plsc->ylength); - qApp->setActiveWindow(mw); + widget->setVisible(true); + widget->resize(plsc->xlength, plsc->ylength); + + qApp->connect(&handler, SIGNAL(MasterChangedPage()), widget, SLOT(nextPage())); + qApp->connect(&handler, SIGNAL(MasterClosed()), widget, SLOT(close())); } void plD_eop_qtwidget(PLStream *pls) { - QtPLTabWidget* tabWidget=((QtPLTabWidget*)pls->dev); - tabWidget->currentWidget=NULL; + QtPLWidget* widget=((QtPLWidget*)pls->dev); + int currentPage=widget->pageNumber; + while(currentPage==widget->pageNumber && handler.isMasterDevice(widget)) + { + qApp->processEvents(QEventLoop::WaitForMoreEvents); + } } -void plD_tidy_qtwidget(PLStream *pls) -{ - QtPLTabWidget * w=((QtPLTabWidget*)pls->dev); - w->exec(); - // At this point, the widget has been run, we can delete it - delete ((QtPLTabWidget*)pls->dev); - pls->dev=NULL; -} #endif #endif Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-31 19:02:28 UTC (rev 9779) +++ trunk/drivers/qt.h 2009-03-31 19:25:07 UTC (rev 9780) @@ -88,6 +88,57 @@ #define QT_DEFAULT_X 842 #define QT_DEFAULT_Y 595 +class QtPLDriver; + +// Master Device Handler for multiple streams +// Only handles multiple Qt devices +class MasterHandler:public QObject +{ + Q_OBJECT + + public: + MasterHandler():QObject() + { + masterDevice=NULL; + } + + ~MasterHandler(){} + + bool isMasterDevice(QtPLDriver* d) + { + return d==masterDevice; + } + + void setMasterDevice(QtPLDriver* d) + { + masterDevice=d; + } + + void DeviceChangedPage(QtPLDriver* d) + { + if(d==masterDevice) + { + emit MasterChangedPage(); + } + } + + void DeviceClosed(QtPLDriver* d) + { + if(d==masterDevice) + { + emit MasterClosed(); + masterDevice=NULL; + } + } + signals: + void MasterChangedPage(); + + void MasterClosed(); + + protected: + QtPLDriver* masterDevice; +}; + // Basic class, offering the common interface to all Qt plplot devices class QtPLDriver { @@ -95,7 +146,7 @@ // Constructor, taking the device size as arguments QtPLDriver(PLINT i_iWidth=QT_DEFAULT_X, PLINT i_iHeight=QT_DEFAULT_Y); - virtual ~QtPLDriver(); + virtual ~QtPLDriver(); // does not delete emitter! // Draws a line from (x1, y1) to (x2, y2) in internal plplot coordinates virtual void drawLine(short x1, short y1, short x2, short y2); @@ -120,6 +171,7 @@ double m_dWidth, m_dHeight; static QMutex mutex; // All-purpose mutex + protected: // Returns font with the good size for a QPicture's resolution @@ -142,8 +194,6 @@ QPainter* m_painterP; }; -QMutex QtPLDriver::mutex; - #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) // Driver painting whatever raster format Qt can save class QtRasterDevice: public QtPLDriver, public QImage @@ -219,7 +269,7 @@ // to delimit the page when the widget aspect ratio is not the one of the plotted page class QtPLWidget: public QWidget, public QtPLDriver { -// Q_OBJECT + Q_OBJECT public: // Parameters are the actual size of the page, NOT the size of the widget @@ -228,161 +278,30 @@ virtual ~QtPLWidget(); - // This is an addition to plplot drawing routines. - // Calling setSmooth(...) will (de)activate anti-aliasing in plotting - // For example: - // plotWidget->setSmooth(true); - // plbox(...); - // plotWidget->setSmooth(false); - // plline(...) - // will only smooth the axes and their labels. -// void setSmooth(bool); - - // Clears the widget void clearWidget(); - -// public slots: - // This slot can be used to select an x/y range interactively - // xi, yi, xf and yf are the initial and final points coordinates - // in their respective windows, 0 if outside a window -// void captureMousePlotCoords(double* xi, double* yi, double* xf, double* yf); -// -// // This slot can be used to select an x/y range interactively -// // xi, yi, xf and yf are the initial and final points coordinates -// // in the whole page (normalized between 0 and 1) -// void captureMouseDeviceCoords(double* xi, double* yi, double* xf, double* yf); - -// protected slots: + int pageNumber; + protected: void resizeEvent(QResizeEvent*); void paintEvent(QPaintEvent*); -// void mousePressEvent(QMouseEvent*); -// void mouseReleaseEvent(QMouseEvent*); -// void mouseMoveEvent(QMouseEvent*); - - protected: // Used to center the plot on the page void getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset); - // Used for cursor tracking (capture[...] slots) - struct - { - bool isTracking; - int step; //1 for first part, 2 for second part - double cursor_start_x, cursor_start_y; - double cursor_end_x, cursor_end_y; - } cursorParameters; - double m_dAspectRatio; QPixmap * m_pixPixmap; // to avoid redrawing everything bool m_bAwaitingRedraw; int m_iOldSize; QPicture* pic; -}; - -// This widget wraps up various QtPLWidgets as tabs -// The stream plots on currentWidget, which should be changed by eop() -// Actually, setting currentWidget as NULL creates a new page when -// the first plot instructions are issued. So eop() only has to set it as NULL; -class QtPLTabWidget: public QTabWidget, public QtPLDriver -{ - public: - QtPLTabWidget(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y) - { - - m_iWidth=i_iWidth; - m_iHeight=i_iHeight; - currentWidget=NULL; - - mutex.lock(); // All QtPLTabWidgets are registered - alreadyRun=false; - runningDevices.push_back(this); - mutex.unlock(); - } - - ~QtPLTabWidget(); - - virtual void drawLine(short x1, short y1, short x2, short y2) - { - if(currentWidget==NULL) newTab(); - currentWidget->drawLine(x1, y1, x2, y2); - } - - virtual void drawPolyline(short * x, short * y, PLINT npts) - { - if(currentWidget==NULL) newTab(); - currentWidget->drawPolyline(x, y, npts); - } - - virtual void drawPolygon(short * x, short * y, PLINT npts) - { - if(currentWidget==NULL) newTab(); - currentWidget->drawPolygon(x, y, npts); - } - - virtual void setColor(int r, int g, int b, double alpha) - { - if(currentWidget==NULL) newTab(); - currentWidget->setColor(r, g, b, alpha); - } - - virtual void setWidth(PLINT w) - { - if(currentWidget==NULL) newTab(); - currentWidget->setWidth(w); - } - - virtual void setDashed(PLINT nms, PLINT* mark, PLINT* space) - { - if(currentWidget==NULL) newTab(); - currentWidget->setDashed(nms, mark, space); - } - - // Set pen to draw solid strokes (called after drawing dashed strokes) - virtual void setSolid() - { - if(currentWidget==NULL) newTab(); - currentWidget->setSolid(); - } - - virtual void drawText(PLStream* pls, EscText* txt) - { - if(currentWidget==NULL) newTab(); - currentWidget->drawText(pls, txt); - } - -// void setSmooth(bool b) -// { -// if(currentWidget==NULL) newTab(); -// currentWidget->setSmooth(b); -// } - - virtual void savePlot(char* fileName){} - - void exec(); - - QtPLWidget* currentWidget; - - int m_iWidth, m_iHeight; - - static QList<QtPLTabWidget*> runningDevices; - bool alreadyRun; - - protected: - void newTab(); - QList<QtPLWidget*> widgets; - - double resolution; - - + protected slots: + void mouseReleaseEvent ( QMouseEvent * event ); + void closeEvent(QCloseEvent* event); + void nextPage(); }; -QList<QtPLTabWidget*> QtPLTabWidget::runningDevices; - #endif #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-05-06 15:43:58
|
Revision: 9933 http://plplot.svn.sourceforge.net/plplot/?rev=9933&view=rev Author: airwin Date: 2009-05-06 15:43:56 +0000 (Wed, 06 May 2009) Log Message: ----------- Add <return> to the existing right mouse click method of moving to the next page and eventually exiting. Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-05-06 11:18:25 UTC (rev 9932) +++ trunk/drivers/qt.cpp 2009-05-06 15:43:56 UTC (rev 9933) @@ -1335,6 +1335,14 @@ } } +void QtPLWidget::keyPressEvent(QKeyEvent* event) +{ + if(event->key()==Qt::Key_Enter || event->key()==Qt::Key_Return) + { + handler.DeviceChangedPage(this); + } +} + void QtPLWidget::closeEvent(QCloseEvent* event) { handler.DeviceClosed(this); Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-05-06 11:18:25 UTC (rev 9932) +++ trunk/drivers/qt.h 2009-05-06 15:43:56 UTC (rev 9933) @@ -298,6 +298,7 @@ protected slots: void mouseReleaseEvent ( QMouseEvent * event ); + void keyPressEvent(QKeyEvent* event); void closeEvent(QCloseEvent* event); void nextPage(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-05-07 12:44:06
|
Revision: 9935 http://plplot.svn.sourceforge.net/plplot/?rev=9935&view=rev Author: andrewross Date: 2009-05-07 12:43:52 +0000 (Thu, 07 May 2009) Log Message: ----------- Consistently replace calls to exit() with calls to plexit() for drivers. Modified Paths: -------------- trunk/drivers/tkwin.c trunk/drivers/wxwidgets.cpp trunk/drivers/xwin.c Modified: trunk/drivers/tkwin.c =================================================================== --- trunk/drivers/tkwin.c 2009-05-07 08:22:15 UTC (rev 9934) +++ trunk/drivers/tkwin.c 2009-05-07 12:43:52 UTC (rev 9935) @@ -364,8 +364,7 @@ * abort operations now */ if (pls->plPlotterPtr == NULL) { - fprintf(stderr, "No tk plframe widget to connect to\n"); - exit(1); + plexit("No tk plframe widget to connect to"); } /* Old version for MacOS Tk8.0 */ /* @@ -389,8 +388,7 @@ tkwd->display = XOpenDisplay(pls->FileName); #endif if (tkwd->display == NULL) { - fprintf(stderr, "Can't open display\n"); - exit(1); + plexit( "Can't open display"); } tkwd->displayName = pls->FileName; tkwd->screen = DefaultScreen(tkwd->display); Modified: trunk/drivers/wxwidgets.cpp =================================================================== --- trunk/drivers/wxwidgets.cpp 2009-05-07 08:22:15 UTC (rev 9934) +++ trunk/drivers/wxwidgets.cpp 2009-05-07 12:43:52 UTC (rev 9935) @@ -360,8 +360,7 @@ break; } if( dev == NULL) { - fprintf( stderr, "Insufficient memory\n" ); - exit( 0 ); + plexit( "Insufficient memory" ); } pls->dev = (void*)dev; @@ -1215,7 +1214,7 @@ wxTRY { wxPLGetApp().CallOnInit(); } - wxCATCH_ALL( wxPLGetApp().OnUnhandledException(); fprintf(stderr, "Can't init wxWidgets!\n"); exit(0); ) + wxCATCH_ALL( wxPLGetApp().OnUnhandledException(); plexit( "Can't init wxWidgets!"); ) initApp=true; } @@ -1301,7 +1300,7 @@ wxPLGetApp().OnRun(); /* start wxWidgets application */ callOnExit.exit=false; } - wxCATCH_ALL( wxPLGetApp().OnUnhandledException(); fprintf(stderr, "Problem running wxWidgets!\n"); exit(0); ) + wxCATCH_ALL( wxPLGetApp().OnUnhandledException(); plexit("Problem running wxWidgets!"); ) if( dev->exit ) { wxPLGetApp().OnExit(); Modified: trunk/drivers/xwin.c =================================================================== --- trunk/drivers/xwin.c 2009-05-07 08:22:15 UTC (rev 9934) +++ trunk/drivers/xwin.c 2009-05-07 12:43:52 UTC (rev 9935) @@ -925,12 +925,11 @@ #ifdef HAVE_PTHREAD if (usepthreads) if (! XInitThreads()) - plexit("xwin: XInitThreads() not successful.\n"); + plexit("xwin: XInitThreads() not successful."); #endif xwd->display = XOpenDisplay(pls->FileName); if (xwd->display == NULL) { - fprintf(stderr, "Can't open display\n"); - exit(1); + plexit("Can't open display"); } xwd->displayName = pls->FileName; xwd->screen = DefaultScreen(xwd->display); @@ -2453,8 +2452,7 @@ } } if (!found) { - printf( "Unable to get a StaticColor visual.\n" ); - exit(1); + plexit( "Unable to get a StaticColor visual." ); } printf( "Found StaticColor visual, depth=%d\n", xwd->depth ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-05-11 16:18:37
|
Revision: 9964 http://plplot.svn.sourceforge.net/plplot/?rev=9964&view=rev Author: airwin Date: 2009-05-11 16:18:11 +0000 (Mon, 11 May 2009) Log Message: ----------- AWI for Alban Rochel. Apply minor patch to remove some compiler warnings about casting arguments. Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-05-11 14:08:05 UTC (rev 9963) +++ trunk/drivers/qt.cpp 2009-05-11 16:18:11 UTC (rev 9964) @@ -318,12 +318,12 @@ tempPainter.end(); - p->drawPicture(xOffset+bounding.width()/2., -yOffset, tempPic); + p->drawPicture((int)(xOffset+bounding.width()/2.), -yOffset, tempPic); xOffset+=bounding.width(); } -QPicture QtPLDriver::getTextPicture(PLUNICODE* text, int len, int chrht) +QPicture QtPLDriver::getTextPicture(PLUNICODE* text, int len, PLFLT chrht) { char plplotEsc; plgesc( &plplotEsc ); @@ -453,7 +453,7 @@ picDpi=picText.logicalDpiY(); m_painterP->setClipping(true); - m_painterP->setClipRect(QRect(pls->clpxmi*downscale, m_dHeight-pls->clpyma*downscale, (pls->clpxma-pls->clpxmi)*downscale, (pls->clpyma-pls->clpymi)*downscale), Qt::ReplaceClip); + m_painterP->setClipRect(QRect((int)(pls->clpxmi*downscale), (int)(m_dHeight-pls->clpyma*downscale), (int)((pls->clpxma-pls->clpxmi)*downscale), (int)((pls->clpyma-pls->clpymi)*downscale)), Qt::ReplaceClip); rotation -= pls->diorot * M_PI / 2.0; m_painterP->translate(txt->x*downscale, m_dHeight-txt->y*downscale); @@ -463,7 +463,7 @@ m_painterP->translate(-txt->just*xOffset*m_painterP->device()->logicalDpiY()/picDpi, 0.); - m_painterP->drawPicture(0., 0., picText); + m_painterP->drawPicture(0, 0, picText); m_painterP->setWorldMatrix(QMatrix()); m_painterP->setClipping(false); @@ -474,11 +474,11 @@ if(!m_painterP->isActive()) return; QPen p=m_painterP->pen(); - p.setColor(QColor(r, g, b, alpha*255)); + p.setColor(QColor(r, g, b, (int)(alpha*255))); m_painterP->setPen(p); QBrush B=m_painterP->brush(); - B.setColor(QColor(r, g, b, alpha*255)); + B.setColor(QColor(r, g, b, (int)(alpha*255))); B.setStyle(Qt::SolidPattern); m_painterP->setBrush(B); } @@ -773,8 +773,8 @@ if (pls->xlength <= 0 || pls->ylength <= 0) { pls->dev=new QtRasterDevice; - pls->xlength = ((QtRasterDevice*)(pls->dev))->m_dWidth; - pls->ylength = ((QtRasterDevice*)(pls->dev))->m_dHeight; + pls->xlength = (PLINT)(((QtRasterDevice*)(pls->dev))->m_dWidth); + pls->ylength = (PLINT)(((QtRasterDevice*)(pls->dev))->m_dHeight); } else { @@ -983,13 +983,13 @@ { setFileName(QString(fileName)); setResolution(POINTS_PER_INCH); - setSize(QSize(m_dWidth, m_dHeight)); + setSize(QSize((int)m_dWidth, (int)m_dHeight)); #if QT_VERSION >= 0x040500 setViewBox(QRect(0, 0, (int)m_dWidth, (int)m_dHeight)); #endif m_painterP=new QPainter(this); - m_painterP->fillRect(0, 0, m_dWidth, m_dHeight, QBrush(Qt::black)); + m_painterP->fillRect(0, 0, (int)m_dWidth, (int)m_dHeight, QBrush(Qt::black)); } void QtSVGDevice::savePlot() @@ -1038,8 +1038,8 @@ if (pls->xlength <= 0 || pls->ylength <= 0) { pls->dev=new QtSVGDevice; - pls->xlength = ((QtSVGDevice*)(pls->dev))->m_dWidth; - pls->ylength = ((QtSVGDevice*)(pls->dev))->m_dHeight; + pls->xlength = (int)(((QtSVGDevice*)(pls->dev))->m_dWidth); + pls->ylength = (int)(((QtSVGDevice*)(pls->dev))->m_dHeight); } else { @@ -1143,7 +1143,7 @@ } m_painterP=new QPainter(this); - m_painterP->fillRect(0, 0, m_dWidth, m_dHeight, QBrush(Qt::black)); + m_painterP->fillRect(0, 0, (int)m_dWidth, (int)m_dHeight, QBrush(Qt::black)); } void QtEPSDevice::savePlot() @@ -1215,8 +1215,8 @@ 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; + pls->xlength = (int)(((QtEPSDevice*)(pls->dev))->m_dWidth); + pls->ylength = (int)(((QtEPSDevice*)(pls->dev))->m_dHeight); } else { @@ -1616,8 +1616,8 @@ p.setPen(QPen(Qt::white)); - p.drawLine(cursorParameters.cursor_x, 0., cursorParameters.cursor_x, height()); - p.drawLine(0., cursorParameters.cursor_y, width(), cursorParameters.cursor_y); + p.drawLine((int)cursorParameters.cursor_x, 0, (int)cursorParameters.cursor_x, height()); + p.drawLine(0, (int)cursorParameters.cursor_y, width(), (int)cursorParameters.cursor_y); p.end(); } Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-05-11 14:08:05 UTC (rev 9963) +++ trunk/drivers/qt.h 2009-05-11 16:18:11 UTC (rev 9964) @@ -179,7 +179,7 @@ // Draws text in a QPicture using a sub-QPicture (!), updates the current xOffset void drawTextInPicture(QPainter*, const QString&); // Gets the QPicture displaying text, with the base chrht char height - QPicture getTextPicture(PLUNICODE* text, int len, int chrht); + QPicture getTextPicture(PLUNICODE* text, int len, PLFLT chrht); // Text-related variables bool underlined; @@ -210,8 +210,8 @@ virtual void setResolution(double dotsPerInch) { - setDotsPerMeterX((dotsPerInch/25.4)*1000.); - setDotsPerMeterY((dotsPerInch/25.4)*1000.); + setDotsPerMeterX((int)((dotsPerInch/25.4)*1000.)); + setDotsPerMeterY((int)((dotsPerInch/25.4)*1000.)); } protected: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-05-15 17:35:07
|
Revision: 9980 http://plplot.svn.sourceforge.net/plplot/?rev=9980&view=rev Author: andrewross Date: 2009-05-15 17:34:38 +0000 (Fri, 15 May 2009) Log Message: ----------- ANR for Alban Rochel. Patch for qt driver to (hopefully) fix the blank screen issue on Mac and to make the line widths constant independent of the display size. Modified Paths: -------------- trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-05-14 17:39:14 UTC (rev 9979) +++ trunk/drivers/qt.cpp 2009-05-15 17:34:38 UTC (rev 9980) @@ -307,7 +307,7 @@ void QtPLDriver::drawTextInPicture(QPainter* p, const QString& text) { - if(!m_painterP->isActive()) return; +// if(!m_painterP->isActive()) return; QRectF rect(0., 0., 0., 0.); QRectF bounding; @@ -343,12 +343,10 @@ xOffset+=bounding.width(); } -QPicture QtPLDriver::getTextPicture(PLUNICODE* text, int len, PLFLT chrht) +QPicture QtPLDriver::getTextPicture(PLUNICODE fci, PLUNICODE* text, int len, PLFLT chrht) { char plplotEsc; plgesc( &plplotEsc ); - PLUNICODE fci; - plgfci( &fci ); double old_fontScale; @@ -469,7 +467,9 @@ plRotationShear( txt->xform, &rotation, &shear, &stride); double picDpi; - QPicture picText=getTextPicture(txt->unicode_array, txt->unicode_array_len, pls->chrht); + PLUNICODE fci; + plgfci( &fci ); + QPicture picText=getTextPicture(fci, txt->unicode_array, txt->unicode_array_len, pls->chrht); picDpi=picText.logicalDpiY(); m_painterP->setClipping(true); @@ -1325,38 +1325,223 @@ { m_painterP=new QPainter; - m_dAspectRatio=(double)i_iWidth/(double)i_iHeight; + m_dAspectRatio=m_dWidth/m_dHeight; + m_pixPixmap=NULL; m_iOldSize=0; - - pic=new QPicture; - m_painterP->begin(pic); - m_painterP->setRenderHint(QPainter::Antialiasing, true); - pageNumber=1; - + resize(i_iWidth, i_iHeight); } QtPLWidget::~QtPLWidget() { + clearBuffer(); if(m_pixPixmap!=NULL) delete m_pixPixmap; - if(m_painterP!=NULL) delete m_painterP; - if(pic!=NULL) delete pic; - m_pixPixmap=NULL; - m_painterP=NULL; - pic=NULL; } void QtPLWidget::clearWidget() { - if(m_painterP->isActive()) m_painterP->end(); - delete pic; - pic=new QPicture; - m_painterP->begin(pic); - m_painterP->setRenderHint(QPainter::Antialiasing, true); + clearBuffer(); m_bAwaitingRedraw=true; update(); } +void QtPLWidget::clearBuffer() +{ + for(QLinkedList<BufferElement>::iterator i=m_listBuffer.begin(); i!=m_listBuffer.end(); ++i) + { + switch(i->Element) + { + case POLYLINE: + case POLYGON: + delete[] i->Data.PolylineStruct->x; + delete[] i->Data.PolylineStruct->y; + delete i->Data.PolylineStruct; + break; + + case LINE: + delete i->Data.LineStruct; + break; + + case SET_COLOUR: + delete i->Data.ColourStruct; + break; + + case TEXT: + delete[] i->Data.TextStruct->text; + delete i->Data.TextStruct; + break; + default: + break; + } + } + + m_listBuffer.clear(); +} + +void QtPLWidget::drawLine(short x1, short y1, short x2, short y2) +{ + BufferElement el; + el.Element=LINE; + el.Data.LineStruct=new struct LineStruct_; + el.Data.LineStruct->x1=(PLFLT)x1*downscale; + el.Data.LineStruct->y1=m_dHeight-(PLFLT)y1*downscale; + el.Data.LineStruct->x2=(PLFLT)x2*downscale; + el.Data.LineStruct->y2=m_dHeight-(PLFLT)y2*downscale; + + m_listBuffer.append(el); +} + +void QtPLWidget::drawPolyline(short * x, short * y, PLINT npts) +{ + BufferElement el; + el.Element=POLYLINE; + el.Data.PolylineStruct=new struct PolylineStruct_; + el.Data.PolylineStruct->npts=(PLINT)npts; + el.Data.PolylineStruct->x=new PLFLT[npts]; + el.Data.PolylineStruct->y=new PLFLT[npts]; + for(int i=0; i<npts; ++i) + { + el.Data.PolylineStruct->x[i]=(PLFLT)x[i]*downscale; + el.Data.PolylineStruct->y[i]=m_dHeight-(PLFLT)y[i]*downscale; + } + + m_listBuffer.append(el); +} + +void QtPLWidget::drawPolygon(short * x, short * y, PLINT npts) +{ + BufferElement el; + el.Element=POLYGON; + el.Data.PolylineStruct=new struct PolylineStruct_; + el.Data.PolylineStruct->npts=(PLINT)npts; + el.Data.PolylineStruct->x=new PLFLT[npts]; + el.Data.PolylineStruct->y=new PLFLT[npts]; + for(int i=0; i<npts; ++i) + { + el.Data.PolylineStruct->x[i]=(PLFLT)x[i]*downscale; + el.Data.PolylineStruct->y[i]=m_dHeight-(PLFLT)y[i]*downscale; + } + + m_listBuffer.append(el); +} + +void QtPLWidget::setColor(int r, int g, int b, double alpha) +{ + BufferElement el; + el.Element=SET_COLOUR; + el.Data.ColourStruct=new struct ColourStruct_; + el.Data.ColourStruct->R=r; + el.Data.ColourStruct->G=g; + el.Data.ColourStruct->B=b; + el.Data.ColourStruct->A=alpha*255.; + + m_listBuffer.append(el); +} + +void QtPLWidget::setSolid() +{ + BufferElement el; + el.Element=SET_SOLID; + m_listBuffer.append(el); +} + +void QtPLWidget::setWidth(PLINT w) +{ + BufferElement el; + el.Element=SET_WIDTH; + el.Data.intParam=w; + m_listBuffer.append(el); +} + +void QtPLWidget::drawText(PLStream* pls, EscText* txt) +{ + BufferElement el; + el.Element=TEXT; + el.Data.TextStruct=new struct TextStruct_; + el.Data.TextStruct->x=txt->x*downscale; + el.Data.TextStruct->y=m_dHeight-txt->y*downscale; + el.Data.TextStruct->clipxmin=pls->clpxmi*downscale; + el.Data.TextStruct->clipymin=m_dHeight-pls->clpymi*downscale; + el.Data.TextStruct->clipxmax=pls->clpxma*downscale; + el.Data.TextStruct->clipymax=m_dHeight-pls->clpyma*downscale; + PLUNICODE fci; + plgfci(&fci); + el.Data.TextStruct->fci=fci; + PLFLT rotation, shear, stride; + plRotationShear( txt->xform, &rotation, &shear, &stride); + rotation -= pls->diorot * M_PI / 2.0; + el.Data.TextStruct->rotation=rotation; + el.Data.TextStruct->shear=shear; + el.Data.TextStruct->stride=stride; + el.Data.TextStruct->just=txt->just; + el.Data.TextStruct->text=new PLUNICODE[txt->unicode_array_len]; + memcpy(el.Data.TextStruct->text, txt->unicode_array, txt->unicode_array_len*sizeof(PLUNICODE)); + el.Data.TextStruct->len=txt->unicode_array_len; + el.Data.TextStruct->chrht=pls->chrht; + + m_listBuffer.append(el); + +} + +void QtPLWidget::drawTextInPicture(QPainter* p, const QString& text) +{ + QRectF rect(0., 0., 0., 0.); + QRectF bounding; + QPicture tempPic; + QPainter tempPainter(&tempPic); + tempPainter.setFont(p->font()); + + if(vectorize) + { + bounding=tempPainter.boundingRect(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text); + + QPen savePen=tempPainter.pen(); + QPen pen=savePen; + pen.setStyle(Qt::NoPen); + tempPainter.setPen(pen); + + double offset=QFontMetrics(tempPainter.font(), &tempPic).boundingRect(text).top(); // Distance between the baseline and the top of the bounding box + + QPainterPath path; + path.addText(QPointF(bounding.left(), bounding.top()-offset), tempPainter.font(), text); + tempPainter.drawPath(path); + tempPainter.setPen(pen); + } + else + { + tempPainter.drawText(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text, &bounding); + + } + + tempPainter.end(); + + p->drawPicture((int)(xOffset+bounding.width()/2.), -yOffset, tempPic); + xOffset+=bounding.width(); +} + +void QtPLWidget::renderText(QPainter* p, struct TextStruct_* s, double x_fact, double x_offset, double y_fact, double y_offset) +{ + if(s->len<=0 || s->len>=500) return; + QPicture picText=getTextPicture(s->fci, s->text, s->len, s->chrht*y_fact); + + double picDpi=picText.logicalDpiY(); + + p->setClipping(true); + p->setClipRect(QRectF(s->clipxmin*x_fact+x_offset, s->clipymax*y_fact+y_offset, (s->clipxmax-s->clipxmin)*x_fact, (-s->clipymax+s->clipymin)*y_fact), Qt::ReplaceClip); + + p->translate(s->x*x_fact+x_offset, s->y*y_fact+y_offset); + QMatrix rotShearMatrix(cos(s->rotation)*s->stride, -sin(s->rotation)*s->stride, cos(s->rotation)*sin(s->shear)+sin(s->rotation)*cos(s->shear), -sin(s->rotation)*sin(s->shear)+cos(s->rotation)*cos(s->shear), 0.,0.); + p->setWorldMatrix(rotShearMatrix, true); + + p->translate(-s->just*xOffset*p->device()->logicalDpiY()/picDpi, 0.); + + p->drawPicture(0., 0., picText); + + p->setWorldMatrix(QMatrix()); + + p->setClipping(false); +} + void QtPLWidget::mouseReleaseEvent ( QMouseEvent * event ) { if(event->button()==Qt::RightButton) @@ -1397,39 +1582,121 @@ void QtPLWidget::paintEvent( QPaintEvent * ) { - if(m_painterP->isActive()) m_painterP->end(); double x_fact, y_fact, x_offset(0.), y_offset(0.); //Parameters to scale and center the plot on the widget + getPlotParameters(x_fact, y_fact, x_offset, y_offset); - QPainter * painter=new QPainter; - - if(m_bAwaitingRedraw || m_pixPixmap==NULL) + if(m_bAwaitingRedraw || m_pixPixmap==NULL || m_listBuffer.size()!=m_iOldSize) // If must regenerate image, draw it in the pixmap { if(m_pixPixmap!=NULL) delete m_pixPixmap; m_pixPixmap=new QPixmap(width(), height()); + QPainter* painter=new QPainter; painter->begin(m_pixPixmap); + + // Draw the margins and the background painter->fillRect(0, 0, width(), height(), QBrush(Qt::white)); painter->fillRect(0, 0, width(), height(), QBrush(Qt::gray, Qt::Dense4Pattern)); painter->fillRect((int)x_offset, (int)y_offset, (int)floor(x_fact*m_dWidth+0.5), (int)floor(y_fact*m_dHeight+0.5), QBrush(Qt::black)); - painter->setRenderHint(QPainter::Antialiasing, true); - painter->setWorldMatrix(QMatrix(x_fact, 0., 0., y_fact, x_offset, y_offset)); - pic->play(painter); + + // Draw the plot + doPlot(painter, x_fact, y_fact, x_offset, y_offset); painter->end(); + m_bAwaitingRedraw=false; + m_iOldSize=m_listBuffer.size(); + + delete painter; } - painter->begin(this); + // draw the current pixmap + m_painterP->begin(this); + + m_painterP->drawPixmap(0, 0, *m_pixPixmap); + + m_painterP->end(); +} - painter->drawPixmap(0, 0, *m_pixPixmap); +void QtPLWidget::doPlot(QPainter* p, double x_fact, double y_fact, double x_offset, double y_offset) +{ + QLineF line; + QPointF * polyline; + PLINT npts; + QVector<qreal> vect; + QPen pen=p->pen(); + QBrush brush=p->brush(); + brush.setStyle(Qt::SolidPattern); + p->setBrush(brush); + p->setRenderHints(QPainter::Antialiasing, true); + + if(m_listBuffer.empty()) + { + p->fillRect(0, 0, (int)(x_fact+2.*x_offset), (int)(y_fact+2.*y_offset), QBrush()); + return; + } + // unrolls the buffer and draws each element accordingly + for(QLinkedList<BufferElement>::const_iterator i=m_listBuffer.begin(); i!=m_listBuffer.end(); ++i) + { + switch(i->Element) + { + case LINE: + line=QLineF(i->Data.LineStruct->x1*x_fact+x_offset, i->Data.LineStruct->y1*y_fact+y_offset, i->Data.LineStruct->x2*x_fact+x_offset, i->Data.LineStruct->y2*y_fact+y_offset); + p->drawLine(line); + break; + + case POLYLINE: + npts=i->Data.PolylineStruct->npts; + polyline=new QPointF[npts]; + for(int j=0; j<npts; ++j) + { + polyline[j].setX(i->Data.PolylineStruct->x[j]*x_fact+x_offset); + polyline[j].setY(i->Data.PolylineStruct->y[j]*y_fact+y_offset); + } + p->drawPolyline(polyline, npts); + delete[] polyline; + break; + + case POLYGON: + npts=i->Data.PolylineStruct->npts; + polyline=new QPointF[npts]; + for(int j=0; j<npts; ++j) + { + polyline[j].setX(i->Data.PolylineStruct->x[j]*x_fact+x_offset); + polyline[j].setY(i->Data.PolylineStruct->y[j]*y_fact+y_offset); + } + p->drawPolygon(polyline, npts); + delete[] polyline; + break; + + case TEXT: + renderText(p, i->Data.TextStruct, x_fact, x_offset, y_fact, y_offset); + break; + + case SET_WIDTH: + pen.setWidth(i->Data.intParam); + p->setPen(pen); + break; - painter->end(); - delete painter; + case SET_COLOUR: + pen.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); + p->setPen(pen); + brush.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); + p->setBrush(brush); + break; + + case SET_SOLID: + pen.setStyle(Qt::SolidLine); + p->setPen(pen); + break; + + default: + break; + } + } } void QtPLWidget::getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset) { 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; @@ -1445,6 +1712,8 @@ io_dYOffset=(h-io_dYFact*m_dHeight)/2.; } } + + #endif #if defined (PLD_qtwidget) @@ -1549,10 +1818,10 @@ QCoreApplication::processEvents(QEventLoop::AllEvents, 10); if(m_pixPixmap!=NULL) delete m_pixPixmap; if(m_painterP!=NULL) delete m_painterP; - if(pic!=NULL) delete pic; +// if(pic!=NULL) delete pic; m_pixPixmap=NULL; m_painterP=NULL; - pic=NULL; +// pic=NULL; } void QtExtWidget::captureMousePlotCoords(PLFLT* x, PLFLT* y) Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-05-14 17:39:14 UTC (rev 9979) +++ trunk/drivers/qt.h 2009-05-15 17:34:38 UTC (rev 9980) @@ -179,7 +179,7 @@ // Draws text in a QPicture using a sub-QPicture (!), updates the current xOffset void drawTextInPicture(QPainter*, const QString&); // Gets the QPicture displaying text, with the base chrht char height - QPicture getTextPicture(PLUNICODE* text, int len, PLFLT chrht); + QPicture getTextPicture(PLUNICODE fci, PLUNICODE* text, int len, PLFLT chrht); // Text-related variables bool underlined; @@ -264,6 +264,75 @@ #if defined (PLD_qtwidget) || defined (PLD_extqt) +typedef enum ElementType_ +{ + LINE, + POLYLINE, + POLYGON, + SET_WIDTH, + SET_COLOUR, + SET_SOLID, + TEXT +} ElementType; // Identifiers for elements of the buffer + +struct LineStruct_ +{ + PLFLT x1; + PLFLT x2; + PLFLT y1; + PLFLT y2; +}; + +struct PolylineStruct_ +{ + PLINT npts; + PLFLT* x; + PLFLT* y; +}; + +struct ColourStruct_ +{ + PLINT R, G, B, A; +}; + +struct TextStruct_ +{ + PLFLT x; + PLFLT y; + PLFLT clipxmin; + PLFLT clipymin; + PLFLT clipxmax; + PLFLT clipymax; + PLFLT rotation; + PLFLT shear; + PLFLT stride; + PLFLT just; + PLUNICODE* text; + PLUNICODE fci; + PLINT len; + PLFLT chrht; +}; + +class BufferElement +{ + public: + + ElementType Element; + + union DataType + { + struct LineStruct_* LineStruct; + + struct PolylineStruct_* PolylineStruct; + + struct ColourStruct_* ColourStruct; + + struct TextStruct_* TextStruct; + + PLINT intParam; + } Data; +}; + // This widget allows to use plplot as a plotting engine in a Qt Application // The aspect ratio of the plotted data is constant, so gray strips are used // to delimit the page when the widget aspect ratio is not the one of the plotted page @@ -279,28 +348,43 @@ virtual ~QtPLWidget(); void clearWidget(); + void clearBuffer(); int pageNumber; + + void drawLine(short x1, short y1, short x2, short y2); + void drawPolyline(short * x, short * y, PLINT npts); + void drawPolygon(short * x, short * y, PLINT npts); + void setColor(int r, int g, int b, double alpha); + void setWidth(PLINT r); + void setSolid(); + void drawText(PLStream* pls, EscText* txt); protected: void resizeEvent(QResizeEvent*); void paintEvent(QPaintEvent*); - // Used to center the plot on the page - void getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset); + void getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset); // gives the parameters to scale and center the plot on the page + void doPlot(QPainter* p, double x_fact, double y_fact, double x_offset, double y_offset); // Actually draws the plot. Deported in a function for readability + void drawTextInPicture(QPainter* p, const QString& text); + void renderText(QPainter* p, struct TextStruct_* s, double x_fact, double x_offset, double y_fact, double y_offset); - double m_dAspectRatio; - QPixmap * m_pixPixmap; // to avoid redrawing everything + double m_dAspectRatio; // Is kept constant during resizes + QPixmap * m_pixPixmap; // stores the drawn image as long as it does not have to be regenerated + + QLinkedList<BufferElement> m_listBuffer; // Buffer holding the draw instructions bool m_bAwaitingRedraw; - int m_iOldSize; - QPicture* pic; + int m_iOldSize; // Holds the size of the buffer. Modified => image has to be redrawn + protected slots: void mouseReleaseEvent ( QMouseEvent * event ); void keyPressEvent(QKeyEvent* event); void closeEvent(QCloseEvent* event); void nextPage(); + + }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-07-29 17:48:14
|
Revision: 10188 http://plplot.svn.sourceforge.net/plplot/?rev=10188&view=rev Author: airwin Date: 2009-07-29 17:47:44 +0000 (Wed, 29 Jul 2009) Log Message: ----------- Enable alpha channel/transparency for background. Modified Paths: -------------- trunk/drivers/cairo.c trunk/drivers/svg.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-07-28 21:02:56 UTC (rev 10187) +++ trunk/drivers/cairo.c 2009-07-29 17:47:44 UTC (rev 10188) @@ -328,10 +328,11 @@ /* Fill in the window with the background color. */ cairo_rectangle(aStream->cairoContext, 0.0, 0.0, pls->xlength, pls->ylength); - cairo_set_source_rgb(aStream->cairoContext, + cairo_set_source_rgba(aStream->cairoContext, (double)pls->cmap0[0].r/255.0, (double)pls->cmap0[0].g/255.0, - (double)pls->cmap0[0].b/255.0); + (double)pls->cmap0[0].b/255.0, + (double)pls->cmap0[0].a); cairo_fill(aStream->cairoContext); } @@ -1219,10 +1220,11 @@ /* Fill in the window with the background color. */ cairo_rectangle(aStream->cairoContext, 0.0, 0.0, pls->xlength, pls->ylength); - cairo_set_source_rgb(aStream->cairoContext, + cairo_set_source_rgba(aStream->cairoContext, (double)pls->cmap0[0].r/255.0, (double)pls->cmap0[0].g/255.0, - (double)pls->cmap0[0].b/255.0); + (double)pls->cmap0[0].b/255.0, + (double)pls->cmap0[0].a); cairo_fill(aStream->cairoContext); } Modified: trunk/drivers/svg.c =================================================================== --- trunk/drivers/svg.c 2009-07-28 21:02:56 UTC (rev 10187) +++ trunk/drivers/svg.c 2009-07-29 17:47:44 UTC (rev 10188) @@ -931,6 +931,8 @@ write_hex(aStream->svgFile, pls->cmap0[0].g); write_hex(aStream->svgFile, pls->cmap0[0].b); fprintf(aStream->svgFile, "\"\n"); + svg_indent(aStream); + fprintf(aStream->svgFile, "fill-opacity=\"%f\"\n", pls->cmap0[0].a); } /*--------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-08-15 03:35:10
|
Revision: 10255 http://plplot.svn.sourceforge.net/plplot/?rev=10255&view=rev Author: airwin Date: 2009-08-15 03:35:02 +0000 (Sat, 15 Aug 2009) Log Message: ----------- Straighten out commentary for pls->dev_fill1. Modified Paths: -------------- trunk/drivers/gnome.c trunk/drivers/mem.c trunk/drivers/ntk.c trunk/drivers/pbm.c trunk/drivers/plmeta.c trunk/drivers/svg.c trunk/drivers/tk.c Modified: trunk/drivers/gnome.c =================================================================== --- trunk/drivers/gnome.c 2009-08-14 21:40:34 UTC (rev 10254) +++ trunk/drivers/gnome.c 2009-08-15 03:35:02 UTC (rev 10255) @@ -811,7 +811,7 @@ pls->termin = 1; /* Is an interactive terminal */ pls->dev_flush = 1; /* Handle our own flushes */ pls->dev_fill0 = 1; /* Handle solid fills */ - pls->dev_fill1 = 1; /* Handle pattern fills */ + pls->dev_fill1 = 1; /* Driver handles pattern fills */ pls->dev_dash = 1; /* Handle dashed lines */ pls->plbuf_write = 1; /* Use plot buffer to replot to another device */ pls->width = 1; Modified: trunk/drivers/mem.c =================================================================== --- trunk/drivers/mem.c 2009-08-14 21:40:34 UTC (rev 10254) +++ trunk/drivers/mem.c 2009-08-15 03:35:02 UTC (rev 10255) @@ -83,8 +83,8 @@ pls->color = 1; /* Is a color device */ pls->dev_fill0 = 0; /* Handle solid fills */ - pls->dev_fill1 = 0; /* Handle pattern fills */ - pls->nopause = 1; /* Don`t pause between frames */ + pls->dev_fill1 = 0; /* Use PLplot core fallback for pattern fills */ + pls->nopause = 1; /* Don't pause between frames */ } Modified: trunk/drivers/ntk.c =================================================================== --- trunk/drivers/ntk.c 2009-08-14 21:40:34 UTC (rev 10254) +++ trunk/drivers/ntk.c 2009-08-15 03:35:02 UTC (rev 10255) @@ -222,7 +222,7 @@ plD_init_ntk(PLStream *pls) { pls->dev_fill0 = 1; /* Handle solid fills */ - pls->dev_fill1 = 1; /* Dont handle pattern fills */ + pls->dev_fill1 = 1; /* Driver handles pattern fills */ pls->color = 1; /* Is a color device */ pls->dev_dash = 1; /* Handle dashed lines */ pls->plbuf_write = 1; /* Use plot buffer */ Modified: trunk/drivers/pbm.c =================================================================== --- trunk/drivers/pbm.c 2009-08-14 21:40:34 UTC (rev 10254) +++ trunk/drivers/pbm.c 2009-08-15 03:35:02 UTC (rev 10255) @@ -81,8 +81,8 @@ pls->color = 1; /* Is a color device */ pls->dev_fill0 = 0; /* Handle solid fills */ - pls->dev_fill1 = 0; /* Handle pattern fills */ - pls->nopause = 1; /* Don`t pause between frames */ + pls->dev_fill1 = 0; /* Use PLplot core fallback for pattern fills */ + pls->nopause = 1; /* Don't pause between frames */ /* Prompt for a file name if not already set */ Modified: trunk/drivers/plmeta.c =================================================================== --- trunk/drivers/plmeta.c 2009-08-14 21:40:34 UTC (rev 10254) +++ trunk/drivers/plmeta.c 2009-08-15 03:35:02 UTC (rev 10255) @@ -136,7 +136,7 @@ pls->color = 1; /* Is a color device */ pls->dev_fill0 = 1; /* Handle solid fills */ - pls->dev_fill1 = 1; /* Handle pattern fills */ + pls->dev_fill1 = 1; /* Driver handles pattern fills */ /* Initialize family file info */ Modified: trunk/drivers/svg.c =================================================================== --- trunk/drivers/svg.c 2009-08-14 21:40:34 UTC (rev 10254) +++ trunk/drivers/svg.c 2009-08-15 03:35:02 UTC (rev 10255) @@ -160,7 +160,7 @@ pls->dev_unicode = 1; /* wants text as unicode */ pls->page = 0; pls->dev_fill0 = 1; /* driver generates solid fills */ - pls->dev_fill1 = 0; /* PLplot core software generates pattern fills */ + pls->dev_fill1 = 0; /* Use PLplot core fallback for pattern fills */ pls->graphx = GRAPHICS_MODE; Modified: trunk/drivers/tk.c =================================================================== --- trunk/drivers/tk.c 2009-08-14 21:40:34 UTC (rev 10254) +++ trunk/drivers/tk.c 2009-08-15 03:35:02 UTC (rev 10255) @@ -229,7 +229,7 @@ pls->dev_di = 1; /* Handle driver interface commands */ pls->dev_flush = 1; /* Handle our own flushes */ pls->dev_fill0 = 1; /* Handle solid fills */ - pls->dev_fill1 = 1; /* Handle pattern fills */ + pls->dev_fill1 = 1; /* Driver handles pattern fills */ pls->server_nokill = 1; /* don't kill if ^C */ pls->dev_xor = 1; /* device support xor mode */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |