41 #include <QMutexLocker>
56 #if defined ( PLD_bmpqt )
57 "bmpqt:Qt Windows bitmap driver:0:qt:66:bmpqt\n"
59 #if defined ( PLD_jpgqt )
60 "jpgqt:Qt jpg driver:0:qt:67:jpgqt\n"
62 #if defined ( PLD_pngqt )
63 "pngqt:Qt png driver:0:qt:68:pngqt\n"
65 #if defined ( PLD_ppmqt )
66 "ppmqt:Qt ppm driver:0:qt:69:ppmqt\n"
68 #if defined ( PLD_tiffqt )
69 "tiffqt:Qt tiff driver:0:qt:70:tiffqt\n"
71 #if defined ( PLD_svgqt ) && QT_VERSION >= 0x040300
72 "svgqt:Qt SVG driver:0:qt:71:svgqt\n"
74 #if defined ( PLD_qtwidget )
75 "qtwidget:Qt Widget:1:qt:72:qtwidget\n"
77 #if defined ( PLD_epsqt )
78 "epsqt:Qt EPS driver:0:qt:73:epsqt\n"
80 #if defined ( PLD_pdfqt )
81 "pdfqt:Qt PDF driver:0:qt:74:pdfqt\n"
83 #if defined ( PLD_extqt )
84 "extqt:External Qt driver:0:qt:75:extqt\n"
86 #if defined ( PLD_memqt )
87 "memqt:Memory Qt driver:0:qt:76:memqt\n"
93 {
"lines_antialiasing",
DRV_INT, &lines_aa,
"Toggles antialiasing on lines (0|1)" },
94 { NULL,
DRV_INT, NULL, NULL } };
109 argv[0] =
new char[10];
110 argv[1] =
new char[1];
115 if ( getenv(
"DISPLAY" ) == NULL )
118 new QApplication(
argc,
argv, isGUI );
168 plwarn(
"All pages after the first skipped because family file output not specified.\n" );
175 #if defined ( PLD_bmpqt ) || defined ( PLD_jpgqt ) || defined ( PLD_pngqt ) || defined ( PLD_ppmqt ) || defined ( PLD_tiffqt ) || defined ( PLD_memqt )
176 void plD_init_rasterqt(
PLStream * );
177 void plD_eop_rasterqt(
PLStream * );
178 void plD_line_rasterqt(
PLStream *,
short,
short,
short,
short );
179 void plD_polyline_rasterqt(
PLStream *,
short*,
short*,
PLINT );
180 void plD_tidy_rasterqt(
PLStream * );
185 #if defined ( PLD_bmpqt )
190 #if defined ( PLD_jpgqt )
195 #if defined ( PLD_pngqt )
200 #if defined ( PLD_ppmqt )
205 #if defined ( PLD_tiffqt )
210 #if defined ( PLD_svgqt ) && QT_VERSION >= 0x040300
215 void plD_line_svgqt(
PLStream *,
short,
short,
short,
short );
216 void plD_polyline_svgqt(
PLStream *,
short*,
short*,
PLINT );
222 #if defined ( PLD_epsqt ) || defined ( PLD_pdfqt )
223 void plD_init_epspdfqt(
PLStream * );
224 void plD_bop_epspdfqt_helper(
PLStream *,
int ifeps );
225 void plD_eop_epspdfqt(
PLStream * );
226 void plD_line_epspdfqt(
PLStream *,
short,
short,
short,
short );
227 void plD_polyline_epspdfqt(
PLStream *,
short*,
short*,
PLINT );
228 void plD_tidy_epspdfqt(
PLStream * );
232 #if defined ( PLD_epsqt )
236 #if defined ( PLD_pdfqt )
241 #if defined ( PLD_qtwidget )
243 void plD_init_qtwidget(
PLStream * );
244 void plD_eop_qtwidget(
PLStream * );
245 void plD_wait_qtwidget(
PLStream * );
246 void plD_line_qtwidget(
PLStream *,
short,
short,
short,
short );
247 void plD_polyline_qtwidget(
PLStream *,
short*,
short*,
PLINT );
248 void plD_tidy_qtwidget(
PLStream * );
251 void plD_bop_qtwidget(
PLStream * );
254 #if defined ( PLD_extqt )
258 void plD_line_extqt(
PLStream *,
short,
short,
short,
short );
259 void plD_polyline_extqt(
PLStream *,
short*,
short*,
PLINT );
266 #if defined ( PLD_memqt )
274 #if defined ( PLD_bmpqt ) || defined ( PLD_jpgqt ) || defined ( PLD_pngqt ) || defined ( PLD_ppmqt ) || defined ( PLD_tiffqt ) || defined ( PLD_memqt )
314 pls->
dev =
new QtRasterDevice;
322 ( (QtRasterDevice *)
pls->
dev )->setPLStream(
pls );
325 handler.setMasterDevice( (QtRasterDevice *) (
pls->
dev ) );
334 plP_setpxl( dpi / 25.4 / ( (QtRasterDevice *) (
pls->
dev ) )->downscale, dpi / 25.4 / ( (QtRasterDevice *) (
pls->
dev ) )->downscale );
336 ( (QtRasterDevice *) (
pls->
dev ) )->setResolution( dpi );
350 ( (QtRasterDevice *)
pls->
dev )->savePlot();
351 handler.DeviceChangedPage( (QtRasterDevice *)
pls->
dev );
354 void plD_line_rasterqt(
PLStream *
pls,
short x1a,
short y1a,
short x2a,
short y2a )
356 QtRasterDevice* widget = (QtRasterDevice *)
pls->
dev;
362 if ( widget == NULL )
366 widget->drawLine( x1a, y1a, x2a, y2a );
369 void plD_polyline_rasterqt(
PLStream *
pls,
short *xa,
short *ya,
PLINT npts )
371 QtRasterDevice * widget = (QtRasterDevice *)
pls->
dev;
377 if ( widget == NULL )
381 widget->drawPolyline( xa, ya, npts );
387 unsigned char *r, *g, *b;
390 QtRasterDevice * widget = (QtRasterDevice *)
pls->
dev;
395 if ( widget == NULL )
459 widget->drawText( (
EscText *) ptr );
468 QtRasterDevice * widget = (QtRasterDevice *)
pls->
dev;
473 if ( widget == NULL )
497 QtRasterDevice * widget = (QtRasterDevice *)
pls->
dev;
499 if ( widget != NULL )
501 handler.DeviceClosed( widget );
511 #if defined ( PLD_bmpqt )
514 #ifndef ENABLE_DYNDRIVERS
546 #if defined ( PLD_jpgqt )
549 #ifndef ENABLE_DYNDRIVERS
581 #if defined ( PLD_pngqt )
584 #ifndef ENABLE_DYNDRIVERS
616 #if defined ( PLD_ppmqt )
619 #ifndef ENABLE_DYNDRIVERS
651 #if defined ( PLD_tiffqt )
654 #ifndef ENABLE_DYNDRIVERS
686 #if defined ( PLD_svgqt ) && QT_VERSION >= 0x040300
689 #ifndef ENABLE_DYNDRIVERS
736 pls->
dev =
new QtSVGDevice;
744 ( (QtSVGDevice *)
pls->
dev )->setPLStream(
pls );
747 handler.setMasterDevice( (QtSVGDevice *) (
pls->
dev ) );
788 ( (QtSVGDevice *)
pls->
dev )->savePlot();
791 downscale = ( (QtSVGDevice *)
pls->
dev )->downscale;
792 s = ( (QtSVGDevice *)
pls->
dev )->size();
793 bool isMaster = ( handler.isMasterDevice( (QtSVGDevice *)
pls->
dev ) );
794 delete ( (QtSVGDevice *)
pls->
dev );
796 pls->
dev =
new QtSVGDevice( s.width(), s.height() );
797 ( (QtSVGDevice *)
pls->
dev )->downscale = downscale;
798 ( (QtSVGDevice *)
pls->
dev )->setPLStream(
pls );
801 handler.setMasterDevice( (QtSVGDevice *)
pls->
dev );
802 handler.DeviceChangedPage( (QtSVGDevice *)
pls->
dev );
805 void plD_line_svgqt(
PLStream *
pls,
short x1a,
short y1a,
short x2a,
short y2a )
807 QtSVGDevice* widget = (QtSVGDevice *)
pls->
dev;
812 if ( widget == NULL )
816 widget->drawLine( x1a, y1a, x2a, y2a );
821 QtSVGDevice * widget = (QtSVGDevice *)
pls->
dev;
826 if ( widget == NULL )
830 widget->drawPolyline( xa, ya, npts );
836 unsigned char *r, *g, *b;
839 QtSVGDevice * widget = (QtSVGDevice *)
pls->
dev;
844 if ( widget == NULL )
901 widget->drawText( (
EscText *) ptr );
911 QtSVGDevice * widget = (QtSVGDevice *)
pls->
dev;
916 if ( widget == NULL )
939 QtSVGDevice * widget = (QtSVGDevice *)
pls->
dev;
941 if ( widget != NULL )
943 handler.DeviceClosed( widget );
953 #if defined ( PLD_epsqt )
956 #ifndef ENABLE_DYNDRIVERS
973 #if defined ( PLD_pdfqt )
976 #ifndef ENABLE_DYNDRIVERS
993 #if defined ( PLD_epsqt ) || defined ( PLD_pdfqt )
1027 pls->
dev =
new QtEPSDevice;
1035 ( (QtEPSDevice *)
pls->
dev )->setPLStream(
pls );
1038 handler.setMasterDevice( (QtEPSDevice *) (
pls->
dev ) );
1055 void plD_bop_epspdfqt_helper(
PLStream *
pls,
int ifeps )
1078 ( (QtEPSDevice *)
pls->
dev )->savePlot();
1081 downscale = ( (QtEPSDevice *)
pls->
dev )->downscale;
1082 bool isMaster = handler.isMasterDevice( (QtEPSDevice *)
pls->
dev );
1083 delete ( (QtEPSDevice *)
pls->
dev );
1085 pls->
dev =
new QtEPSDevice;
1086 ( (QtEPSDevice *)
pls->
dev )->downscale = downscale;
1089 handler.setMasterDevice( (QtEPSDevice *)
pls->
dev );
1090 handler.DeviceChangedPage( (QtEPSDevice *)
pls->
dev );
1093 void plD_line_epspdfqt(
PLStream *
pls,
short x1a,
short y1a,
short x2a,
short y2a )
1095 QtEPSDevice* widget = (QtEPSDevice *)
pls->
dev;
1100 if ( widget == NULL )
1104 widget->drawLine( x1a, y1a, x2a, y2a );
1107 void plD_polyline_epspdfqt(
PLStream *
pls,
short *xa,
short *ya,
PLINT npts )
1109 QtEPSDevice * widget = (QtEPSDevice *)
pls->
dev;
1114 if ( widget == NULL )
1118 widget->drawPolyline( xa, ya, npts );
1124 unsigned char *r, *g, *b;
1127 QtEPSDevice * widget = (QtEPSDevice *)
pls->
dev;
1134 if ( widget == NULL )
1191 widget->drawText( (
EscText *) ptr );
1195 widget->drawArc( arc_info->x, arc_info->y, arc_info->a, arc_info->b, arc_info->angle1, arc_info->angle2, arc_info->rotate, arc_info->fill );
1204 QtEPSDevice * widget = (QtEPSDevice *)
pls->
dev;
1209 if ( widget == NULL )
1233 QtEPSDevice * widget = (QtEPSDevice *)
pls->
dev;
1235 if ( widget != NULL )
1237 handler.DeviceClosed( widget );
1247 #if defined ( PLD_epsqt )
1250 plD_bop_epspdfqt_helper(
pls, 1 );
1254 #if defined ( PLD_pdfqt )
1257 plD_bop_epspdfqt_helper(
pls, 0 );
1261 #if defined ( PLD_qtwidget )
1264 #ifndef ENABLE_DYNDRIVERS
1292 widget =
new QtPLWidget;
1293 pls->
dev = (
void *) widget;
1300 pls->
dev = (
void *) widget;
1302 widget->setPLStream(
pls );
1305 handler.setMasterDevice( widget );
1307 if ( plsc->xlength > plsc->ylength )
1315 QPainter tempPainter( &temp );
1317 plP_setpxl( temp.logicalDpiX() / 25.4 / widget->downscale, temp.logicalDpiY() / 25.4 / widget->downscale );
1338 widget->setVisible(
true );
1339 widget->resize( plsc->xlength, plsc->ylength );
1340 widget->move( plsc->xoffset, plsc->yoffset );
1344 qApp->connect( &handler, SIGNAL( MasterChangedPage() ), widget, SLOT( nextPage() ) );
1345 qApp->connect( &handler, SIGNAL( MasterClosed() ), widget, SLOT( close() ) );
1350 QtPLWidget* widget = ( (QtPLWidget *)
pls->
dev );
1358 QtPLWidget* widget = ( (QtPLWidget *)
pls->
dev );
1359 int currentPage = widget->pageNumber;
1362 while ( currentPage == widget->pageNumber && handler.isMasterDevice( widget ) )
1364 qApp->processEvents( QEventLoop::WaitForMoreEvents );
1370 QtPLWidget* widget = ( (QtPLWidget *)
pls->
dev );
1374 void plD_line_qtwidget(
PLStream *
pls,
short x1a,
short y1a,
short x2a,
short y2a )
1376 QtPLWidget* widget = (QtPLWidget *)
pls->
dev;
1377 if ( widget == NULL )
1381 widget->drawLine( x1a, y1a, x2a, y2a );
1384 void plD_polyline_qtwidget(
PLStream *
pls,
short *xa,
short *ya,
PLINT npts )
1386 QtPLWidget * widget = (QtPLWidget *)
pls->
dev;
1387 if ( widget == NULL )
1391 widget->drawPolyline( xa, ya, npts );
1398 unsigned char *r, *g, *b;
1400 QtPLWidget * widget = (QtPLWidget *)
pls->
dev;
1402 if ( widget == NULL )
1458 widget->drawText( (
EscText *) ptr );
1462 widget->drawArc( arc_info->x, arc_info->y, arc_info->a, arc_info->b, arc_info->angle1, arc_info->angle2, arc_info->rotate, arc_info->fill );
1477 QtPLWidget * widget = (QtPLWidget *)
pls->
dev;
1478 if ( widget == NULL )
1502 QtPLWidget * widget = (QtPLWidget *)
pls->
dev;
1504 if ( widget != NULL )
1506 handler.DeviceClosed( widget );
1515 #if defined ( PLD_extqt )
1518 #ifndef ENABLE_DYNDRIVERS
1543 printf(
"Error: use plsetqtdev to set up the Qt device before calling plinit()\n" );
1547 QtExtWidget* widget = (QtExtWidget *) (
pls->
dev );
1549 if ( widget->m_dWidth > widget->m_dHeight )
1557 QPainter tempPainter( &temp );
1559 plP_setpxl( temp.logicalDpiX() / 25.4 / widget->downscale, temp.logicalDpiY() / 25.4 / widget->downscale );
1587 void plD_line_extqt(
PLStream *
pls,
short x1a,
short y1a,
short x2a,
short y2a )
1589 QtExtWidget * widget = NULL;
1591 widget = (QtExtWidget *)
pls->
dev;
1593 widget->drawLine( x1a, y1a, x2a, y2a );
1598 QtExtWidget * widget = NULL;
1600 widget = (QtExtWidget *)
pls->
dev;
1602 widget->drawPolyline( xa, ya, npts );
1609 unsigned char *r, *g, *b;
1611 QtExtWidget * widget = NULL;
1614 widget = (QtExtWidget *)
pls->
dev;
1669 widget->drawText( (
EscText *) ptr );
1673 widget->drawArc( arc_info->
x, arc_info->
y, arc_info->
a, arc_info->
b, arc_info->
angle1, arc_info->
angle2, arc_info->
rotate, arc_info->
fill );
1682 QtExtWidget * widget = NULL;
1684 widget = (QtExtWidget *)
pls->
dev;
1706 QtExtWidget * widget = NULL;
1708 widget = (QtExtWidget *)
pls->
dev;
1709 if ( widget != NULL )
1711 handler.DeviceClosed( widget );
1726 QtExtWidget * widget = NULL;
1727 widget = (QtExtWidget *)
pls->
dev;
1732 #if defined ( PLD_memqt )
1735 #ifndef ENABLE_DYNDRIVERS
1755 unsigned char *qt_mem;
1756 unsigned char *input_mem;
1797 input_mem = (
unsigned char *)
pls->
dev;
1801 ( (QtRasterDevice *)
pls->
dev )->setPLStream(
pls );
1802 ( (QtRasterDevice *)
pls->
dev )->memory = input_mem;
1805 handler.setMasterDevice( (QtRasterDevice *) (
pls->
dev ) );
1814 plP_setpxl( dpi / 25.4 / ( (QtRasterDevice *) (
pls->
dev ) )->downscale, dpi / 25.4 / ( (QtRasterDevice *) (
pls->
dev ) )->downscale );
1820 qt_mem = ( (QtRasterDevice *)
pls->
dev )->scanLine( 0 );
1824 qt_mem[2] = input_mem[0];
1825 qt_mem[1] = input_mem[1];
1826 qt_mem[0] = input_mem[2];
1829 qt_mem[3] = input_mem[3];
1839 ( (QtRasterDevice *) (
pls->
dev ) )->setResolution( dpi );
1853 unsigned char *memory;
1854 unsigned char *qt_mem;
1856 memory = ( (QtRasterDevice *)
pls->
dev )->memory;
1857 qt_mem = ( (QtRasterDevice *)
pls->
dev )->scanLine( 0 );
1861 memory[0] = qt_mem[2];
1862 memory[1] = qt_mem[1];
1863 memory[2] = qt_mem[0];
1866 memory[3] = qt_mem[3];