102 m_painterP->drawPie( rect, (
int) ( angle1 * 16 ), (
int) ( ( angle2 - angle1 ) * 16 ) );
104 m_painterP->drawArc( rect, (
int) ( angle1 * 16 ), (
int) ( ( angle2 - angle1 ) * 16 ) );
129 QPointF * polyline =
new QPointF[npts];
130 for (
int i = 0; i < npts; ++i )
143 QPointF * polygon =
new QPointF[npts];
144 for (
int i = 0; i < npts; ++i )
149 if ( plsc->dev_eofill )
150 m_painterP->drawPolygon( polygon, npts, Qt::OddEvenFill );
152 m_painterP->drawPolygon( polygon, npts, Qt::WindingFill );
160 unsigned char fontFamily, fontStyle, fontWeight;
170 switch ( fontFamily )
173 f.setStyleHint( QFont::Serif );
176 f.setStyleHint( QFont::TypeWriter );
178 case 0:
case 3:
case 4:
default:
179 f.setStyleHint( QFont::SansSerif );
188 f.setFamily(
"bogusxxxxxxxxxxxxxxxxxxxxbogus" );
193 f.setWeight( QFont::Bold );
195 f.setWeight( QFont::Normal );
205 QRectF rect( 0., 0., 0., 0. );
208 QPainter tempPainter( &tempPic );
209 tempPainter.setFont( p->font() );
213 bounding = tempPainter.boundingRect( rect, Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextDontClip,
text );
217 QPen pen = QPen( Qt::NoPen );
218 tempPainter.setPen( pen );
220 double offset = QFontMetrics( tempPainter.font(), &tempPic ).boundingRect(
text ).top();
223 path.addText( QPointF( bounding.left(), bounding.top() - offset ), tempPainter.font(),
text );
224 tempPainter.drawPath( path );
225 tempPainter.restore();
229 tempPainter.drawText( rect, Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextDontClip,
text, &bounding );
234 p->drawPicture( (
int) (
xOffset + bounding.width() / 2. ), (
int) -
yOffset, tempPic );
244# define RISE_FACTOR 0.8
254 QString currentString;
255 PLFLT old_sscale, sscale, old_soffset, soffset;
277 PLFLT empirical_yOffset = 0.;
279 PLFLT empirical_yOffset = 0.;
302 currentString.append( QString( QChar(
text[i] ) ) );
311 currentString.clear();
313 &old_sscale, &sscale, &old_soffset, &soffset );
331 currentString.clear();
333 &old_sscale, &sscale, &old_soffset, &soffset );
351 currentString.clear();
359 currentString.clear();
366 currentString.append( QString( (QChar *) &(
text[i] ), 1 ) );
370 std::cout <<
"unknown escape char " << ( (QChar)
text[i] ).toLatin1() << std::endl;
378 currentString.clear();
399 printf(
"Non unicode string passed to a Qt driver, ignoring\n" );
406 printf(
"Sorry, the Qt drivers only handle strings of length < %d\n", 500 );
410 PLFLT rotation, shear, stride;
417 picDpi = picText.logicalDpiY();
430 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. );
432 m_painterP->setWorldMatrix( rotShearMatrix,
true );
448 p.setColor( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
452 B.setColor( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
453 B.setStyle( Qt::SolidPattern );
458 unsigned char *r,
unsigned char *g,
466 QLinearGradient linear_gradient;
467 QGradientStops stops;
469 linear_gradient = QLinearGradient(
473 for ( i = 0; i < ncol1; i++ )
475 stop_arg = (qreal) i / (qreal) ( ncol1 - 1 );
476 stops << QGradientStop( stop_arg, QColor( r[i], g[i],
477 b[i], (
int) ( alpha[i] * 255 ) ) );
479 linear_gradient.setStops( stops );
514 p.setStyle( Qt::SolidLine );
519#if defined ( PLD_bmpqt ) || defined ( PLD_jpgqt ) || defined ( PLD_pngqt ) || defined ( PLD_ppmqt ) || defined ( PLD_tiffqt ) || defined ( PLD_memqt )
520QtRasterDevice::QtRasterDevice(
int i_iWidth,
int i_iHeight ) :
522 QImage( i_iWidth, i_iHeight, QImage::Format_ARGB32 )
527 fill( Qt::transparent );
530 b.setStyle( Qt::SolidPattern );
532 m_painterP->setRenderHint( QPainter::Antialiasing, (
bool) lines_aa );
535QtRasterDevice::~QtRasterDevice()
540void QtRasterDevice::definePlotName(
const char*
fileName,
const char* format )
543 strncpy( this->format, format, 4 );
544 this->format[4] =
'\0';
546 this->fileName = QString(
fileName );
549void QtRasterDevice::savePlot()
554 m_painterP->begin(
this );
555 m_painterP->setRenderHint( QPainter::Antialiasing, (
bool) lines_aa );
556 QBrush b = m_painterP->brush();
557 b.setStyle( Qt::SolidPattern );
558 m_painterP->setBrush( b );
562 printf(
"WARNING: %s raster format currently not supported by your Qt installation\n", format );
566void QtRasterDevice::setBackgroundColor(
int r,
int g,
int b,
double alpha )
568 if ( !m_painterP->isActive() )
572 QBrush brush( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
573 m_painterP->fillRect( 0, 0, width(), height(), brush );
577#if defined ( PLD_svgqt ) && QT_VERSION >= 0x040300
578QtSVGDevice::QtSVGDevice(
int i_iWidth,
int i_iHeight ) :
584QtSVGDevice::~QtSVGDevice()
589void QtSVGDevice::definePlotName(
const char*
fileName )
593 setSize( QSize( (
int) m_dWidth, (
int) m_dHeight ) );
594#if QT_VERSION >= 0x040500
595 setViewBox( QRect( 0, 0, (
int) m_dWidth, (
int) m_dHeight ) );
598 m_painterP =
new QPainter(
this );
601void QtSVGDevice::savePlot()
606void QtSVGDevice::setBackgroundColor(
int r,
int g,
int b,
double alpha )
608 if ( !m_painterP->isActive() )
611 QBrush brush( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
612 m_painterP->fillRect( 0, 0, width(), height(), brush );
616#if defined ( PLD_epsqt ) || defined ( PLD_pdfqt )
617QtEPSDevice::QtEPSDevice(
int i_iWidth,
int i_iHeight )
619#if QT_VERSION < 0x040400
620 setPageSize( QPrinter::A4 );
623 setPaperSize( QSizeF( i_iHeight, i_iWidth ), QPrinter::Point );
626 setColorMode( QPrinter::Color );
627 setOrientation( QPrinter::Landscape );
628 setPrintProgram( QString(
"lpr" ) );
630 if ( i_iWidth <= 0 || i_iHeight <= 0 )
632 m_dWidth = pageRect().width();
633 m_dHeight = pageRect().height();
638 m_dHeight = i_iHeight;
643QtEPSDevice::~QtEPSDevice()
648void QtEPSDevice::definePlotName(
const char*
fileName,
int ifeps )
650 setOutputFileName( QString(
fileName ) );
653#ifndef PLPLOT_USE_QT5
654 setOutputFormat( QPrinter::PostScriptFormat );
659 setOutputFormat( QPrinter::PdfFormat );
662 m_painterP =
new QPainter(
this );
665void QtEPSDevice::savePlot()
670void QtEPSDevice::setBackgroundColor(
int r,
int g,
int b,
double alpha )
672 if ( !m_painterP->isActive() )
675 QBrush brush( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
676 m_painterP->fillRect( 0, 0, width(), height(), brush );
680#if defined ( PLD_qtwidget ) || defined ( PLD_extqt )
681QtPLWidget::QtPLWidget(
int i_iWidth,
int i_iHeight, QWidget* parent ) :
682 QWidget( parent ),
QtPLDriver( i_iWidth, i_iHeight )
691 resize( i_iWidth, i_iHeight );
700 redrawFromLastFlush =
false;
703 NoPen = QPen( Qt::NoPen );
704 NoPen.setWidthF( 0. );
709QtPLWidget::~QtPLWidget()
715void QtPLWidget::clearWidget()
718 setBackgroundColor( bgColour.r, bgColour.g, bgColour.b, bgColour.alpha );
724void QtPLWidget::flush()
727 QApplication::processEvents();
730void QtPLWidget::clearBuffer()
733 for ( QLinkedList<BufferElement>::iterator i = m_listBuffer.begin(); i != m_listBuffer.end(); ++i )
735 switch ( i->Element )
746 delete i->Data.Polyline;
750 delete[] i->Data.TextStruct->text;
751 delete i->Data.TextStruct;
756 delete i->Data.ColourStruct;
760 delete i->Data.LinearGradient;
764 delete i->Data.ArcStruct->rect;
765 delete i->Data.ArcStruct->dx;
766 delete i->Data.ArcStruct;
773 m_listBuffer.clear();
774 start_iterator = m_listBuffer.constBegin();
779void QtPLWidget::drawArc(
short x,
short y,
short a,
short b,
PLFLT angle1,
PLFLT angle2,
PLFLT rotate,
bool fill )
783 el.Data.ArcStruct =
new struct ArcStruct_;
784 el.Data.ArcStruct->rect =
new QRectF( (
PLFLT) ( x - a ) * downscale,
785 m_dHeight - (
PLFLT) ( y + b ) * downscale,
786 (
PLFLT) a * downscale * 2,
787 (
PLFLT) b * downscale * 2
789 el.Data.ArcStruct->startAngle = (int) ( angle1 * 16 );
790 el.Data.ArcStruct->spanAngle = (int) ( ( angle2 - angle1 ) * 16 );
791 el.Data.ArcStruct->rotate = rotate;
792 el.Data.ArcStruct->dx =
new QPointF( (
PLFLT) x * downscale, m_dHeight - (
PLFLT) y * downscale );
793 el.Data.ArcStruct->fill =
fill;
795 m_listBuffer.append( el );
796 redrawFromLastFlush =
true;
800void QtPLWidget::drawLine(
short x1,
short y1,
short x2,
short y2 )
804 el.Data.Line =
new QLineF( QPointF( (
PLFLT) x1 * downscale, (
PLFLT) ( m_dHeight - y1 * downscale ) ), QPointF( (
PLFLT) x2 * downscale, (
PLFLT) ( m_dHeight - y2 * downscale ) ) );
806 m_listBuffer.append( el );
807 redrawFromLastFlush =
true;
810void QtPLWidget::drawPolyline(
short * x,
short * y,
PLINT npts )
814 el.Data.Polyline =
new QPolygonF;
815 for (
int i = 0; i < npts; ++i )
817 ( *el.Data.Polyline ) << QPointF( (
PLFLT) ( x[i] ) * downscale, (
PLFLT) ( m_dHeight - ( y[i] ) * downscale ) );
820 m_listBuffer.append( el );
821 redrawFromLastFlush =
true;
824void QtPLWidget::drawPolygon(
short * x,
short * y,
PLINT npts )
831 if ( x[0] == x[1] && x[2] == x[3] && y[0] == y[3] && y[1] == y[2] )
835 else if ( x[0] == x[3] && x[1] == x[2] && y[0] == y[1] && y[2] == y[3] )
842 if ( x[0] == x[4] && y[0] == y[4] )
844 if ( x[0] == x[1] && x[2] == x[3] && y[0] == y[3] && y[1] == y[2] )
848 else if ( x[0] == x[3] && x[1] == x[2] && y[0] == y[1] && y[2] == y[3] )
857 el.Element = RECTANGLE;
859 double x1, y1, x2, y2, x0, y0, width, height;
860 x1 = (
PLFLT) ( x[0] ) * downscale;
861 x2 = (
PLFLT) ( x[2] ) * downscale;
862 y1 = (
PLFLT) ( m_dHeight - ( y[0] ) * downscale );
863 y2 = (
PLFLT) ( m_dHeight - ( y[2] ) * downscale );
884 el.Data.Rect =
new QRectF( x0, y0, width, height );
888 el.Element = POLYGON;
889 el.Data.Polyline =
new QPolygonF;
890 for (
int i = 0; i < npts; ++i )
892 ( *el.Data.Polyline ) << QPointF( (
PLFLT) ( x[i] ) * downscale, (
PLFLT) ( m_dHeight - ( y[i] ) * downscale ) );
896 m_listBuffer.append( el );
897 redrawFromLastFlush =
true;
900void QtPLWidget::setColor(
int r,
int g,
int b,
double alpha )
902 if ( lastColour.r != r || lastColour.g != g || lastColour.b != b || lastColour.alpha != alpha )
905 el.Element = SET_COLOUR;
906 el.Data.ColourStruct =
new struct ColourStruct_;
907 el.Data.ColourStruct->R = r;
908 el.Data.ColourStruct->G = g;
909 el.Data.ColourStruct->B = b;
910 el.Data.ColourStruct->A = (
PLINT) ( alpha * 255. );
912 m_listBuffer.append( el );
917 lastColour.alpha = alpha;
923void QtPLWidget::setGradient(
int x1,
int x2,
int y1,
int y2,
924 unsigned char *r,
unsigned char *g,
930 QGradientStops stops;
932 el.Element = SET_GRADIENT;
934 el.Data.LinearGradient =
new QLinearGradient;
935 *el.Data.LinearGradient = QLinearGradient(
936 QPointF( (qreal) ( x1 * downscale ), (qreal) ( m_dHeight - y1 * downscale ) ),
937 QPointF( (qreal) ( x2 * downscale ), (qreal) ( m_dHeight - y2 * downscale ) ) );
938 for ( i = 0; i < ncol1; i++ )
940 stop_arg = (qreal) i / (qreal) ( ncol1 - 1 );
941 stops << QGradientStop( stop_arg, QColor( r[i], g[i],
942 b[i], (
int) ( alpha[i] * 255 ) ) );
944 ( *el.Data.LinearGradient ).setStops( stops );
945 m_listBuffer.append( el );
952void QtPLWidget::setBackgroundColor(
int r,
int g,
int b,
double alpha )
955 el.Element = SET_BG_COLOUR;
956 el.Data.ColourStruct =
new struct ColourStruct_;
957 el.Data.ColourStruct->R = r;
958 el.Data.ColourStruct->G = g;
959 el.Data.ColourStruct->B = b;
960 el.Data.ColourStruct->A = (
PLINT) ( alpha * 255. );
965 bgColour.alpha = alpha;
966 if ( alpha >= 0.999 )
970 m_listBuffer.append( el );
971 redrawFromLastFlush =
true;
974void QtPLWidget::setWidthF(
PLFLT w )
977 el.Element = SET_WIDTH;
978 el.Data.fltParam = w;
979 m_listBuffer.append( el );
983void QtPLWidget::drawText(
EscText* txt )
995 picText = getTextPicture( fci,
1006 picDpi = picText.logicalDpiY();
1015 el.Data.TextStruct =
new struct TextStruct_;
1016 el.Data.TextStruct->x = txt->
x * downscale;
1017 el.Data.TextStruct->y = m_dHeight - txt->
y * downscale;
1018 el.Data.TextStruct->clipxmin =
pls->
clpxmi * downscale;
1019 el.Data.TextStruct->clipymin = m_dHeight -
pls->
clpymi * downscale;
1020 el.Data.TextStruct->clipxmax =
pls->
clpxma * downscale;
1021 el.Data.TextStruct->clipymax = m_dHeight -
pls->
clpyma * downscale;
1024 el.Data.TextStruct->fci = fci;
1025 PLFLT rotation, shear, stride;
1028 el.Data.TextStruct->rotation = rotation;
1029 el.Data.TextStruct->shear = shear;
1030 el.Data.TextStruct->stride = stride;
1031 el.Data.TextStruct->just = txt->
just;
1035 el.Data.TextStruct->chrht =
pls->
chrht;
1037 m_listBuffer.append( el );
1038 redrawFromLastFlush =
true;
1041void QtPLWidget::renderText( QPainter* p,
struct TextStruct_* s,
double x_fact,
double x_offset,
double y_fact,
double y_offset )
1043 if ( s->len <= 0 || s->len >= 500 )
1045 QPicture picText = getTextPicture( s->fci, s->text, s->len, s->chrht * y_fact );
1047 double picDpi = picText.logicalDpiY();
1049 p->setClipping(
true );
1050 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 );
1051 p->translate( s->x * x_fact + x_offset, s->y * y_fact + y_offset );
1052 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. );
1053 p->setWorldMatrix( rotShearMatrix,
true );
1055 p->translate( -s->just * xOffset * p->device()->logicalDpiY() / picDpi, 0. );
1057 p->drawPicture( 0, 0, picText );
1059 p->resetTransform();
1061 p->setClipping(
false );
1064void QtPLWidget::resetPensAndBrushes( QPainter* painter )
1068 painter->setPen( SolidPen );
1069 SolidBrush = QBrush( Qt::SolidPattern );
1072void QtPLWidget::lookupButtonEvent( QMouseEvent * event )
1074 Qt::MouseButtons buttons =
event->buttons();
1075 Qt::KeyboardModifiers modifiers =
event->modifiers();
1076 gin.pX =
event->x();
1077 gin.pY = height() -
event->y();
1078 gin.dX = (
PLFLT) event->x() / width();
1079 gin.dY = (
PLFLT) ( height() -
event->y() ) / height();
1081 switch ( event->button() )
1083 case Qt::LeftButton:
1089 case Qt::RightButton:
1099 if ( buttons & Qt::LeftButton )
1100 gin.state |= 1 << 8;
1101 if ( buttons & Qt::MidButton )
1102 gin.state |= 1 << 9;
1103 if ( buttons & Qt::RightButton )
1104 gin.state |= 1 << 10;
1105 if ( modifiers & Qt::ShiftModifier )
1106 gin.state |= 1 << 0;
1107 if ( modifiers & Qt::ControlModifier )
1108 gin.state |= 1 << 2;
1109 if ( modifiers & Qt::AltModifier )
1110 gin.state |= 1 << 3;
1111 if ( modifiers & Qt::MetaModifier )
1112 gin.state |= 1 << 3;
1117void QtPLWidget::locate()
1121 if ( locate_mode == 2 )
1124 if ( gin.keysym < 0xFF && isprint( gin.keysym ) )
1125 std::cout << gin.wX <<
" " << gin.wY <<
" " << (char) gin.keysym << std::endl;
1127 std::cout << gin.wX <<
" " << gin.wY <<
" " << std::hex << gin.keysym << std::endl;
1135 QApplication::restoreOverrideCursor();
1139void QtPLWidget::mouseEvent( QMouseEvent * event )
1141 lookupButtonEvent( event );
1145 if ( event->button() == Qt::LeftButton )
1152 if ( event->button() == Qt::RightButton )
1154 handler.DeviceChangedPage(
this );
1159void QtPLWidget::mousePressEvent( QMouseEvent * event )
1161 mouseEvent( event );
1164void QtPLWidget::mouseReleaseEvent( QMouseEvent *
PL_UNUSED( event ) )
1169void QtPLWidget::mouseMoveEvent( QMouseEvent *
PL_UNUSED( event ) )
1174void QtPLWidget::keyPressEvent( QKeyEvent* event )
1178 QPoint p = QCursor::pos();
1180 gin.pY = height() - p.y();
1181 gin.dX = (
PLFLT) p.x() / width();
1182 gin.dY = (
PLFLT) ( height() - p.y() ) / height();
1184 switch ( event->key() )
1186 case Qt::Key_Escape:
1188 QApplication::restoreOverrideCursor();
1192 case Qt::Key_Control:
1202 int x1, y1, dx = 0, dy = 0;
1203 int xmin = 0, xmax = width() - 1, ymin = 0, ymax = height() - 1;
1204 switch ( event->key() )
1219 if ( event->modifiers() & Qt::ShiftModifier )
1224 if ( event->modifiers() & Qt::ControlModifier )
1229 if ( event->modifiers() & Qt::AltModifier )
1246 QCursor::setPos( p.x() + dx, p.y() + dy );
1257 if ( event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return )
1259 handler.DeviceChangedPage(
this );
1261 if ( event->text() ==
"Q" )
1267 else if ( event->text() ==
"L" )
1271 QApplication::setOverrideCursor( Qt::CrossCursor );
1276void QtPLWidget::closeEvent( QCloseEvent* event )
1278 handler.DeviceClosed(
this );
1282void QtPLWidget::nextPage()
1288void QtPLWidget::resizeEvent( QResizeEvent * )
1296void QtPLWidget::paintEvent( QPaintEvent * )
1298 double x_fact, y_fact, x_offset( 0. ), y_offset( 0. );
1300 getPlotParameters( x_fact, y_fact, x_offset, y_offset );
1302 if ( redrawAll || m_pixPixmap == NULL )
1304 if ( m_pixPixmap != NULL )
1308 m_pixPixmap =
new QPixmap( width(), height() );
1309 QPainter* painter =
new QPainter;
1310 painter->begin( m_pixPixmap );
1313 painter->fillRect( 0, 0, width(), height(), QColor( bgColour.r, bgColour.g, bgColour.b ) );
1316 resetPensAndBrushes( painter );
1318 start_iterator = m_listBuffer.constBegin();
1321 doPlot( painter, x_fact, y_fact, x_offset, y_offset );
1330 QPainter* painter =
new QPainter;
1331 painter->begin( m_pixPixmap );
1333 painter->setPen( SolidPen );
1335 painter->setPen( NoPen );
1338 doPlot( painter, x_fact, y_fact, x_offset, y_offset );
1343 m_painterP->begin(
this );
1345 m_painterP->drawPixmap( 0, 0, *m_pixPixmap );
1350void QtPLWidget::doPlot( QPainter* p,
double x_fact,
double y_fact,
double x_offset,
double y_offset )
1353 QVector<qreal> vect;
1364 p->setRenderHints( QPainter::Antialiasing, (
bool) lines_aa );
1367 p->setBrush( SolidBrush );
1370 trans = trans.translate( x_offset, y_offset );
1371 trans = trans.scale( x_fact, y_fact );
1373 p->setTransform( trans );
1375 if ( m_listBuffer.empty() )
1377 p->fillRect( 0, 0, 1, 1, QBrush() );
1382 for ( QLinkedList<BufferElement>::const_iterator i = start_iterator; i != m_listBuffer.constEnd(); ++i )
1384 switch ( i->Element )
1387 SolidPen.setColor( QColor( i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A ) );
1390 p->setPen( SolidPen );
1392 SolidBrush.setColor( QColor( i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A ) );
1393 p->setBrush( SolidBrush );
1397 p->setBrush( *( i->Data.LinearGradient ) );
1403 p->setPen( SolidPen );
1406 p->drawLine( *( i->Data.Line ) );
1413 p->setPen( SolidPen );
1416 p->drawPolyline( *( i->Data.Polyline ) );
1420 p->setRenderHints( QPainter::Antialiasing,
false );
1426 p->drawRect( *( i->Data.Rect ) );
1427 p->setRenderHints( QPainter::Antialiasing, (
bool) lines_aa );
1431 p->setRenderHints( QPainter::Antialiasing,
false );
1437 if ( plsc->dev_eofill )
1438 p->drawPolygon( *( i->Data.Polyline ), Qt::OddEvenFill );
1440 p->drawPolygon( *( i->Data.Polyline ), Qt::WindingFill );
1441 p->setRenderHints( QPainter::Antialiasing, (
bool) lines_aa );
1447 p->setPen( SolidPen );
1451 p->resetTransform();
1453 renderText( p, i->Data.TextStruct, x_fact, x_offset, y_fact, y_offset );
1458 SolidPen.setWidthF( i->Data.fltParam );
1461 p->setPen( SolidPen );
1466 SolidBrush.setColor( QColor( i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A ) );
1467 p->fillRect( 0, 0, (
int) m_dWidth, (
int) m_dHeight, SolidBrush );
1473 p->setPen( SolidPen );
1476 if ( i->Data.ArcStruct->rotate != 0.0 )
1479 p->translate( *( i->Data.ArcStruct->dx ) );
1480 p->rotate( -i->Data.ArcStruct->rotate );
1481 p->translate( -*( i->Data.ArcStruct->dx ) );
1484 if ( i->Data.ArcStruct->fill )
1485 p->drawPie( *( i->Data.ArcStruct->rect ), i->Data.ArcStruct->startAngle, i->Data.ArcStruct->spanAngle );
1487 p->drawArc( *( i->Data.ArcStruct->rect ), i->Data.ArcStruct->startAngle, i->Data.ArcStruct->spanAngle );
1489 if ( i->Data.ArcStruct->rotate != 0.0 )
1500 start_iterator = m_listBuffer.constEnd();
1502 redrawFromLastFlush =
false;
1506void QtPLWidget::getPlotParameters(
double & io_dXFact,
double & io_dYFact,
double & io_dXOffset,
double & io_dYOffset )
1508 double w = (double) width();
1509 double h = (double) height();
1510 if ( w / h > m_dAspectRatio )
1512 io_dYFact = h / m_dHeight;
1513 io_dXFact = h * m_dAspectRatio / m_dWidth;
1515 io_dXOffset = ( w - io_dXFact * m_dWidth ) / 2.;
1519 io_dXFact = w / m_dWidth;
1520 io_dYFact = w / m_dAspectRatio / m_dHeight;
1522 io_dYOffset = ( h - io_dYFact * m_dHeight ) / 2.;
1531 QApplication::setOverrideCursor( Qt::CrossCursor );
1533 while ( gin.pX < 0 && locate_mode )
1534 QCoreApplication::processEvents( QEventLoop::AllEvents, 10 );
1536 QApplication::restoreOverrideCursor();
1542#if defined ( PLD_extqt )
1543QtExtWidget::QtExtWidget(
int i_iWidth,
int i_iHeight, QWidget* parent ) :
1544 QtPLWidget( i_iWidth, i_iHeight, parent )
1546 cursorParameters.isTracking =
false;
1547 cursorParameters.cursor_x = -1.0;
1548 cursorParameters.cursor_y = -1.0;
1552QtExtWidget::~QtExtWidget()
1555 QCoreApplication::processEvents( QEventLoop::AllEvents, 10 );
1562void QtExtWidget::captureMousePlotCoords(
PLFLT* x,
PLFLT* y )
1564 setMouseTracking(
true );
1565 cursorParameters.isTracking =
true;
1566 cursorParameters.cursor_x =
1567 cursorParameters.cursor_y = -1.;
1570 QCoreApplication::processEvents( QEventLoop::AllEvents, 10 );
1571 }
while ( cursorParameters.isTracking && !killed );
1573 *x = cursorParameters.cursor_x;
1574 *y = cursorParameters.cursor_y;
1577void QtExtWidget::mouseMoveEvent( QMouseEvent* event )
1579 if ( !cursorParameters.isTracking )
1582 double x_fact, y_fact, x_offset, y_offset;
1584 getPlotParameters( x_fact, y_fact, x_offset, y_offset );
1586 cursorParameters.cursor_x = (
PLFLT) event->x();
1587 cursorParameters.cursor_y = (
PLFLT) event->y();
1591 ratio_x = ( cursorParameters.cursor_x - x_offset ) / ( width() - 2. * x_offset );
1592 ratio_y = ( cursorParameters.cursor_y - y_offset ) / ( height() - 2. * y_offset );
1600 cursorParameters.cursor_x = -1.;
1601 cursorParameters.cursor_y = -1.;
1607void QtExtWidget::mousePressEvent( QMouseEvent* )
1611void QtExtWidget::mouseReleaseEvent( QMouseEvent* event )
1613 if ( !cursorParameters.isTracking )
1616 double x_fact, y_fact, x_offset, y_offset;
1618 getPlotParameters( x_fact, y_fact, x_offset, y_offset );
1620 cursorParameters.cursor_x = (
PLFLT) event->x();
1621 cursorParameters.cursor_y = (
PLFLT) event->y();
1622 cursorParameters.isTracking =
false;
1623 setMouseTracking(
false );
1627 ratio_x = ( cursorParameters.cursor_x - x_offset ) / ( width() - 2. * x_offset );
1628 ratio_y = ( cursorParameters.cursor_y - y_offset ) / ( height() - 2. * y_offset );
1636 cursorParameters.cursor_x = -1.;
1637 cursorParameters.cursor_y = -1.;
1641 cursorParameters.cursor_x = a;
1642 cursorParameters.cursor_y = b;
1648void QtExtWidget::paintEvent( QPaintEvent* event )
1650 QtPLWidget::paintEvent( event );
1652 if ( !cursorParameters.isTracking || cursorParameters.cursor_x < 0 )
1657 p.setPen( QPen( Qt::white ) );
1659 p.drawLine( (
int) cursorParameters.cursor_x, 0, (
int) cursorParameters.cursor_x, height() );
1660 p.drawLine( 0, (
int) cursorParameters.cursor_y, width(), (
int) cursorParameters.cursor_y );
1665void plsetqtdev( QtExtWidget* widget )
1667 plsc->dev = (
void *) widget;
1668 widget->setPLStream( plsc );
1671void plsetqtdev( QtExtWidget* widget,
int argc,
char**
argv )
1674 plsc->dev = (
void *) widget;
1675 widget->setPLStream( plsc );
1680 delete ( (QtExtWidget *) plsc->dev );
QtPLDriver * masterDevice
void DeviceChangedPage(QtPLDriver *d)
bool isMasterDevice(QtPLDriver *d)
void DeviceClosed(QtPLDriver *d)
void setMasterDevice(QtPLDriver *d)
virtual void drawLine(short x1, short y1, short x2, short y2)
virtual void drawPolyline(short *x, short *y, PLINT npts)
virtual void setWidthF(PLFLT w)
virtual void setColor(int r, int g, int b, double alpha)
virtual void drawArc(short x, short y, short width, short height, PLFLT angle1, PLFLT angle2, PLFLT rotate, bool fill)
QPicture getTextPicture(PLUNICODE fci, PLUNICODE *text, int len, PLFLT chrht)
void setPLStream(PLStream *pls)
virtual void drawPolygon(short *x, short *y, PLINT npts)
void drawTextInPicture(QPainter *, const QString &)
virtual void drawText(EscText *txt)
QtPLDriver(PLINT i_iWidth=QT_DEFAULT_X, PLINT i_iHeight=QT_DEFAULT_Y)
virtual void setGradient(int x1, int x2, int y1, int y2, unsigned char *r, unsigned char *g, unsigned char *b, PLFLT *alpha, PLINT ncol1)
QFont getFont(PLUNICODE code)
PLDLLIMPEXP_CXX void fill(PLINT n, const PLFLT *x, const PLFLT *y)
void plP_fci2hex(PLUNICODE fci, unsigned char *phexdigit, unsigned char hexpower)
static PLStream * pls[PL_NSTREAMS]
void plGinInit(PLGraphicsIn *gin)
void plexit(PLCHAR_VECTOR errormsg)
#define PLDLLIMPEXP_QT_DATA(type)
void plRotationShear(PLFLT *xFormMatrix, PLFLT *rotation, PLFLT *shear, PLFLT *stride)
PLINT plTranslateCursor(PLGraphicsIn *plg)
static struct line line[]
void plP_script_scale(PLBOOL ifupper, PLINT *level, PLFLT *old_scale, PLFLT *scale, PLFLT *old_offset, PLFLT *offset)
unsigned short unicode_array_len
PLUNICODE * unicode_array
static const char * fileName