90 (
PLFLT) a * downscale * 2,
91 (
PLFLT) b * downscale * 2
102 m_painterP->drawPie( rect, (
int) ( angle1 * 16 ), (
int) ( ( angle2 - angle1 ) * 16 ) );
104 m_painterP->drawArc( rect, (
int) ( angle1 * 16 ), (
int) ( ( angle2 - angle1 ) * 16 ) );
118 (
PLFLT) x2 * downscale,
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 );
187 f.setWeight( QFont::Bold );
189 f.setWeight( QFont::Normal );
199 QRectF rect( 0., 0., 0., 0. );
202 QPainter tempPainter( &tempPic );
203 tempPainter.setFont( p->font() );
207 bounding = tempPainter.boundingRect( rect, Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextDontClip, text );
211 QPen pen = QPen( Qt::NoPen );
212 tempPainter.setPen( pen );
214 double offset = QFontMetrics( tempPainter.font(), &tempPic ).boundingRect( text ).top();
217 path.addText( QPointF( bounding.left(), bounding.top() - offset ), tempPainter.font(), text );
218 tempPainter.drawPath( path );
219 tempPainter.restore();
223 tempPainter.drawText( rect, Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextDontClip, text, &bounding );
228 p->drawPicture( (
int) (
xOffset + bounding.width() / 2. ), (
int) -
yOffset, tempPic );
238 # define RISE_FACTOR 0.8
248 QString currentString;
249 PLFLT old_sscale, sscale, old_soffset, soffset;
252 #ifdef PLPLOT_USE_QT5
271 PLFLT empirical_yOffset = 0.;
273 PLFLT empirical_yOffset = 0.;
296 currentString.append( QString( QChar( text[i] ) ) );
305 currentString.clear();
307 &old_sscale, &sscale, &old_soffset, &soffset );
325 currentString.clear();
327 &old_sscale, &sscale, &old_soffset, &soffset );
345 currentString.clear();
353 currentString.clear();
360 currentString.append( QString( (QChar *) &( text[i] ), 1 ) );
364 std::cout <<
"unknown escape char " << ( (QChar) text[i] ).toLatin1() << std::endl;
372 currentString.clear();
393 printf(
"Non unicode string passed to a Qt driver, ignoring\n" );
400 printf(
"Sorry, the Qt drivers only handle strings of length < %d\n", 500 );
404 PLFLT rotation, shear, stride;
411 picDpi = picText.logicalDpiY();
424 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. );
426 m_painterP->setWorldMatrix( rotShearMatrix,
true );
442 p.setColor( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
446 B.setColor( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
447 B.setStyle( Qt::SolidPattern );
452 unsigned char *r,
unsigned char *g,
460 QLinearGradient linear_gradient;
461 QGradientStops stops;
463 linear_gradient = QLinearGradient(
465 QPointF( (qreal) ( x2 * downscale ), (qreal) (
m_dHeight - y2 * downscale ) ) );
467 for ( i = 0; i < ncol1; i++ )
469 stop_arg = (qreal) i / (qreal) ( ncol1 - 1 );
470 stops << QGradientStop( stop_arg, QColor( r[i], g[i],
471 b[i], (
int) ( alpha[i] * 255 ) ) );
473 linear_gradient.setStops( stops );
508 p.setStyle( Qt::SolidLine );
513 #if defined ( PLD_bmpqt ) || defined ( PLD_jpgqt ) || defined ( PLD_pngqt ) || defined ( PLD_ppmqt ) || defined ( PLD_tiffqt ) || defined ( PLD_memqt )
514 QtRasterDevice::QtRasterDevice(
int i_iWidth,
int i_iHeight ) :
516 QImage( i_iWidth, i_iHeight, QImage::Format_RGB32 )
522 b.setStyle( Qt::SolidPattern );
524 m_painterP->setRenderHint( QPainter::Antialiasing, (
bool) lines_aa );
527 QtRasterDevice::~QtRasterDevice()
532 void QtRasterDevice::definePlotName(
const char*
fileName,
const char* format )
535 strncpy( this->format, format, 4 );
536 this->format[4] =
'\0';
538 this->fileName = QString( fileName );
541 void QtRasterDevice::savePlot()
546 m_painterP->begin(
this );
547 m_painterP->setRenderHint( QPainter::Antialiasing, (
bool) lines_aa );
548 QBrush b = m_painterP->brush();
549 b.setStyle( Qt::SolidPattern );
550 m_painterP->setBrush( b );
553 void QtRasterDevice::setBackgroundColor(
int r,
int g,
int b,
double alpha )
555 if ( !m_painterP->isActive() )
558 QBrush brush( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
559 m_painterP->fillRect( 0, 0, width(), height(), brush );
563 #if defined ( PLD_svgqt ) && QT_VERSION >= 0x040300
564 QtSVGDevice::QtSVGDevice(
int i_iWidth,
int i_iHeight ) :
570 QtSVGDevice::~QtSVGDevice()
575 void QtSVGDevice::definePlotName(
const char*
fileName )
577 setFileName( QString( fileName ) );
579 setSize( QSize( (
int) m_dWidth, (
int) m_dHeight ) );
580 #if QT_VERSION >= 0x040500
581 setViewBox( QRect( 0, 0, (
int) m_dWidth, (
int) m_dHeight ) );
584 m_painterP =
new QPainter(
this );
587 void QtSVGDevice::savePlot()
592 void QtSVGDevice::setBackgroundColor(
int r,
int g,
int b,
double alpha )
594 if ( !m_painterP->isActive() )
597 QBrush brush( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
598 m_painterP->fillRect( 0, 0, width(), height(), brush );
602 #if defined ( PLD_epsqt ) || defined ( PLD_pdfqt )
603 QtEPSDevice::QtEPSDevice(
int i_iWidth,
int i_iHeight )
605 #if QT_VERSION < 0x040400
606 setPageSize( QPrinter::A4 );
609 setPaperSize( QSizeF( i_iHeight, i_iWidth ), QPrinter::Point );
612 setColorMode( QPrinter::Color );
613 setOrientation( QPrinter::Landscape );
614 setPrintProgram( QString(
"lpr" ) );
616 if ( i_iWidth <= 0 || i_iHeight <= 0 )
618 m_dWidth = pageRect().width();
619 m_dHeight = pageRect().height();
624 m_dHeight = i_iHeight;
629 QtEPSDevice::~QtEPSDevice()
634 void QtEPSDevice::definePlotName(
const char* fileName,
int ifeps )
636 setOutputFileName( QString( fileName ) );
639 #ifndef PLPLOT_USE_QT5
640 setOutputFormat( QPrinter::PostScriptFormat );
645 setOutputFormat( QPrinter::PdfFormat );
648 m_painterP =
new QPainter(
this );
651 void QtEPSDevice::savePlot()
656 void QtEPSDevice::setBackgroundColor(
int r,
int g,
int b,
double alpha )
658 if ( !m_painterP->isActive() )
661 QBrush brush( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
662 m_painterP->fillRect( 0, 0, width(), height(), brush );
666 #if defined ( PLD_qtwidget ) || defined ( PLD_extqt )
667 QtPLWidget::QtPLWidget(
int i_iWidth,
int i_iHeight, QWidget* parent ) :
668 QWidget( parent ),
QtPLDriver( i_iWidth, i_iHeight )
677 resize( i_iWidth, i_iHeight );
686 redrawFromLastFlush =
false;
689 NoPen = QPen( Qt::NoPen );
690 NoPen.setWidthF( 0. );
695 QtPLWidget::~QtPLWidget()
701 void QtPLWidget::clearWidget()
704 setBackgroundColor( bgColour.r, bgColour.g, bgColour.b, bgColour.alpha );
710 void QtPLWidget::flush()
713 QApplication::processEvents();
716 void QtPLWidget::clearBuffer()
719 for ( QLinkedList<BufferElement>::iterator i = m_listBuffer.begin(); i != m_listBuffer.end(); ++i )
721 switch ( i->Element )
732 delete i->Data.Polyline;
736 delete[] i->Data.TextStruct->text;
737 delete i->Data.TextStruct;
742 delete i->Data.ColourStruct;
746 delete i->Data.LinearGradient;
750 delete i->Data.ArcStruct->rect;
751 delete i->Data.ArcStruct->dx;
752 delete i->Data.ArcStruct;
759 m_listBuffer.clear();
760 start_iterator = m_listBuffer.constBegin();
765 void QtPLWidget::drawArc(
short x,
short y,
short a,
short b,
PLFLT angle1,
PLFLT angle2,
PLFLT rotate,
bool fill )
769 el.Data.ArcStruct =
new struct ArcStruct_;
770 el.Data.ArcStruct->rect =
new QRectF( (
PLFLT) ( x - a ) * downscale,
771 m_dHeight - (
PLFLT) ( y + b ) * downscale,
772 (
PLFLT) a * downscale * 2,
773 (
PLFLT) b * downscale * 2
775 el.Data.ArcStruct->startAngle = (int) ( angle1 * 16 );
776 el.Data.ArcStruct->spanAngle = (int) ( ( angle2 - angle1 ) * 16 );
777 el.Data.ArcStruct->rotate = rotate;
778 el.Data.ArcStruct->dx =
new QPointF( (
PLFLT) x * downscale, m_dHeight - (
PLFLT) y * downscale );
779 el.Data.ArcStruct->fill =
fill;
781 m_listBuffer.append( el );
782 redrawFromLastFlush =
true;
786 void QtPLWidget::drawLine(
short x1,
short y1,
short x2,
short y2 )
790 el.Data.Line =
new QLineF( QPointF( (
PLFLT) x1 * downscale, (
PLFLT) ( m_dHeight - y1 * downscale ) ), QPointF( (
PLFLT) x2 * downscale, (
PLFLT) ( m_dHeight - y2 * downscale ) ) );
792 m_listBuffer.append( el );
793 redrawFromLastFlush =
true;
796 void QtPLWidget::drawPolyline(
short * x,
short * y,
PLINT npts )
800 el.Data.Polyline =
new QPolygonF;
801 for (
int i = 0; i < npts; ++i )
803 ( *el.Data.Polyline ) << QPointF( (
PLFLT) ( x[i] ) * downscale, (
PLFLT) ( m_dHeight - ( y[i] ) * downscale ) );
806 m_listBuffer.append( el );
807 redrawFromLastFlush =
true;
810 void QtPLWidget::drawPolygon(
short * x,
short * y,
PLINT npts )
817 if ( x[0] == x[1] && x[2] == x[3] && y[0] == y[3] && y[1] == y[2] )
821 else if ( x[0] == x[3] && x[1] == x[2] && y[0] == y[1] && y[2] == y[3] )
828 if ( x[0] == x[4] && y[0] == y[4] )
830 if ( x[0] == x[1] && x[2] == x[3] && y[0] == y[3] && y[1] == y[2] )
834 else if ( x[0] == x[3] && x[1] == x[2] && y[0] == y[1] && y[2] == y[3] )
843 el.Element = RECTANGLE;
845 double x1, y1, x2, y2, x0, y0, width, height;
846 x1 = (
PLFLT) ( x[0] ) * downscale;
847 x2 = (
PLFLT) ( x[2] ) * downscale;
848 y1 = (
PLFLT) ( m_dHeight - ( y[0] ) * downscale );
849 y2 = (
PLFLT) ( m_dHeight - ( y[2] ) * downscale );
870 el.Data.Rect =
new QRectF( x0, y0, width, height );
874 el.Element = POLYGON;
875 el.Data.Polyline =
new QPolygonF;
876 for (
int i = 0; i < npts; ++i )
878 ( *el.Data.Polyline ) << QPointF( (
PLFLT) ( x[i] ) * downscale, (
PLFLT) ( m_dHeight - ( y[i] ) * downscale ) );
882 m_listBuffer.append( el );
883 redrawFromLastFlush =
true;
886 void QtPLWidget::setColor(
int r,
int g,
int b,
double alpha )
888 if ( lastColour.r != r || lastColour.g != g || lastColour.b != b || lastColour.alpha != alpha )
891 el.Element = SET_COLOUR;
892 el.Data.ColourStruct =
new struct ColourStruct_;
893 el.Data.ColourStruct->R = r;
894 el.Data.ColourStruct->G = g;
895 el.Data.ColourStruct->B = b;
896 el.Data.ColourStruct->A = (
PLINT) ( alpha * 255. );
898 m_listBuffer.append( el );
903 lastColour.alpha = alpha;
909 void QtPLWidget::setGradient(
int x1,
int x2,
int y1,
int y2,
910 unsigned char *r,
unsigned char *g,
916 QGradientStops stops;
918 el.Element = SET_GRADIENT;
920 el.Data.LinearGradient =
new QLinearGradient;
921 *el.Data.LinearGradient = QLinearGradient(
922 QPointF( (qreal) ( x1 * downscale ), (qreal) ( m_dHeight - y1 * downscale ) ),
923 QPointF( (qreal) ( x2 * downscale ), (qreal) ( m_dHeight - y2 * downscale ) ) );
924 for ( i = 0; i < ncol1; i++ )
926 stop_arg = (qreal) i / (qreal) ( ncol1 - 1 );
927 stops << QGradientStop( stop_arg, QColor( r[i], g[i],
928 b[i], (
int) ( alpha[i] * 255 ) ) );
930 ( *el.Data.LinearGradient ).setStops( stops );
931 m_listBuffer.append( el );
938 void QtPLWidget::setBackgroundColor(
int r,
int g,
int b,
double alpha )
941 el.Element = SET_BG_COLOUR;
942 el.Data.ColourStruct =
new struct ColourStruct_;
943 el.Data.ColourStruct->R = r;
944 el.Data.ColourStruct->G = g;
945 el.Data.ColourStruct->B = b;
946 el.Data.ColourStruct->A = (
PLINT) ( alpha * 255. );
951 bgColour.alpha = alpha;
952 if ( alpha >= 0.999 )
956 m_listBuffer.append( el );
957 redrawFromLastFlush =
true;
960 void QtPLWidget::setWidthF(
PLFLT w )
963 el.Element = SET_WIDTH;
964 el.Data.fltParam = w;
965 m_listBuffer.append( el );
969 void QtPLWidget::drawText(
EscText* txt )
981 picText = getTextPicture( fci,
992 picDpi = picText.logicalDpiY();
1001 el.Data.TextStruct =
new struct TextStruct_;
1002 el.Data.TextStruct->x = txt->
x * downscale;
1003 el.Data.TextStruct->y = m_dHeight - txt->
y * downscale;
1004 el.Data.TextStruct->clipxmin =
pls->
clpxmi * downscale;
1005 el.Data.TextStruct->clipymin = m_dHeight -
pls->
clpymi * downscale;
1006 el.Data.TextStruct->clipxmax =
pls->
clpxma * downscale;
1007 el.Data.TextStruct->clipymax = m_dHeight -
pls->
clpyma * downscale;
1010 el.Data.TextStruct->fci = fci;
1011 PLFLT rotation, shear, stride;
1014 el.Data.TextStruct->rotation = rotation;
1015 el.Data.TextStruct->shear = shear;
1016 el.Data.TextStruct->stride = stride;
1017 el.Data.TextStruct->just = txt->
just;
1021 el.Data.TextStruct->chrht =
pls->
chrht;
1023 m_listBuffer.append( el );
1024 redrawFromLastFlush =
true;
1027 void QtPLWidget::renderText( QPainter* p,
struct TextStruct_* s,
double x_fact,
double x_offset,
double y_fact,
double y_offset )
1029 if ( s->len <= 0 || s->len >= 500 )
1031 QPicture picText = getTextPicture( s->fci, s->text, s->len, s->chrht * y_fact );
1033 double picDpi = picText.logicalDpiY();
1035 p->setClipping(
true );
1036 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 );
1037 p->translate( s->x * x_fact + x_offset, s->y * y_fact + y_offset );
1038 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. );
1039 p->setWorldMatrix( rotShearMatrix,
true );
1041 p->translate( -s->just * xOffset * p->device()->logicalDpiY() / picDpi, 0. );
1043 p->drawPicture( 0, 0, picText );
1045 p->resetTransform();
1047 p->setClipping(
false );
1050 void QtPLWidget::resetPensAndBrushes( QPainter* painter )
1054 painter->setPen( SolidPen );
1055 SolidBrush = QBrush( Qt::SolidPattern );
1058 void QtPLWidget::lookupButtonEvent( QMouseEvent * event )
1060 Qt::MouseButtons buttons =
event->buttons();
1061 Qt::KeyboardModifiers modifiers =
event->modifiers();
1062 gin.pX =
event->x();
1063 gin.pY = height() -
event->y();
1064 gin.dX = (
PLFLT) event->x() / width();
1065 gin.dY = (
PLFLT) ( height() -
event->y() ) / height();
1067 switch ( event->button() )
1069 case Qt::LeftButton:
1075 case Qt::RightButton:
1085 if ( buttons & Qt::LeftButton )
1086 gin.state |= 1 << 8;
1087 if ( buttons & Qt::MidButton )
1088 gin.state |= 1 << 9;
1089 if ( buttons & Qt::RightButton )
1090 gin.state |= 1 << 10;
1091 if ( modifiers & Qt::ShiftModifier )
1092 gin.state |= 1 << 0;
1093 if ( modifiers & Qt::ControlModifier )
1094 gin.state |= 1 << 2;
1095 if ( modifiers & Qt::AltModifier )
1096 gin.state |= 1 << 3;
1097 if ( modifiers & Qt::MetaModifier )
1098 gin.state |= 1 << 3;
1103 void QtPLWidget::locate()
1107 if ( locate_mode == 2 )
1110 if ( gin.keysym < 0xFF && isprint( gin.keysym ) )
1111 std::cout << gin.wX <<
" " << gin.wY <<
" " << (char) gin.keysym << std::endl;
1113 std::cout << gin.wX <<
" " << gin.wY <<
" " << std::hex << gin.keysym << std::endl;
1121 QApplication::restoreOverrideCursor();
1125 void QtPLWidget::mouseEvent( QMouseEvent * event )
1127 lookupButtonEvent( event );
1131 if ( event->button() == Qt::LeftButton )
1138 if ( event->button() == Qt::RightButton )
1140 handler.DeviceChangedPage(
this );
1145 void QtPLWidget::mousePressEvent( QMouseEvent * event )
1147 mouseEvent( event );
1150 void QtPLWidget::mouseReleaseEvent( QMouseEvent *
PL_UNUSED( event ) )
1155 void QtPLWidget::mouseMoveEvent( QMouseEvent *
PL_UNUSED( event ) )
1160 void QtPLWidget::keyPressEvent( QKeyEvent* event )
1164 QPoint p = QCursor::pos();
1166 gin.pY = height() - p.y();
1167 gin.dX = (
PLFLT) p.x() / width();
1168 gin.dY = (
PLFLT) ( height() - p.y() ) / height();
1170 switch ( event->key() )
1172 case Qt::Key_Escape:
1174 QApplication::restoreOverrideCursor();
1178 case Qt::Key_Control:
1188 int x1, y1, dx = 0, dy = 0;
1189 int xmin = 0, xmax = width() - 1, ymin = 0, ymax = height() - 1;
1190 switch ( event->key() )
1205 if ( event->modifiers() & Qt::ShiftModifier )
1210 if ( event->modifiers() & Qt::ControlModifier )
1215 if ( event->modifiers() & Qt::AltModifier )
1232 QCursor::setPos( p.x() + dx, p.y() + dy );
1243 if ( event->key() == Qt::Key_Enter ||
event->key() == Qt::Key_Return )
1245 handler.DeviceChangedPage(
this );
1247 if ( event->text() ==
"Q" )
1253 else if ( event->text() ==
"L" )
1257 QApplication::setOverrideCursor( Qt::CrossCursor );
1262 void QtPLWidget::closeEvent( QCloseEvent* event )
1264 handler.DeviceClosed(
this );
1268 void QtPLWidget::nextPage()
1274 void QtPLWidget::resizeEvent( QResizeEvent * )
1282 void QtPLWidget::paintEvent( QPaintEvent * )
1284 double x_fact, y_fact, x_offset( 0. ), y_offset( 0. );
1286 getPlotParameters( x_fact, y_fact, x_offset, y_offset );
1288 if ( redrawAll || m_pixPixmap == NULL )
1290 if ( m_pixPixmap != NULL )
1294 m_pixPixmap =
new QPixmap( width(), height() );
1295 QPainter* painter =
new QPainter;
1296 painter->begin( m_pixPixmap );
1299 painter->fillRect( 0, 0, width(), height(), QColor( bgColour.r, bgColour.g, bgColour.b ) );
1302 resetPensAndBrushes( painter );
1304 start_iterator = m_listBuffer.constBegin();
1307 doPlot( painter, x_fact, y_fact, x_offset, y_offset );
1316 QPainter* painter =
new QPainter;
1317 painter->begin( m_pixPixmap );
1319 painter->setPen( SolidPen );
1321 painter->setPen( NoPen );
1324 doPlot( painter, x_fact, y_fact, x_offset, y_offset );
1329 m_painterP->begin(
this );
1331 m_painterP->drawPixmap( 0, 0, *m_pixPixmap );
1336 void QtPLWidget::doPlot( QPainter* p,
double x_fact,
double y_fact,
double x_offset,
double y_offset )
1339 QVector<qreal> vect;
1350 p->setRenderHints( QPainter::Antialiasing, (
bool) lines_aa );
1353 p->setBrush( SolidBrush );
1356 trans = trans.translate( x_offset, y_offset );
1357 trans = trans.scale( x_fact, y_fact );
1359 p->setTransform( trans );
1361 if ( m_listBuffer.empty() )
1363 p->fillRect( 0, 0, 1, 1, QBrush() );
1368 for ( QLinkedList<BufferElement>::const_iterator i = start_iterator; i != m_listBuffer.constEnd(); ++i )
1370 switch ( i->Element )
1373 SolidPen.setColor( QColor( i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A ) );
1376 p->setPen( SolidPen );
1378 SolidBrush.setColor( QColor( i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A ) );
1379 p->setBrush( SolidBrush );
1383 p->setBrush( *( i->Data.LinearGradient ) );
1389 p->setPen( SolidPen );
1392 p->drawLine( *( i->Data.Line ) );
1399 p->setPen( SolidPen );
1402 p->drawPolyline( *( i->Data.Polyline ) );
1406 p->setRenderHints( QPainter::Antialiasing,
false );
1412 p->drawRect( *( i->Data.Rect ) );
1413 p->setRenderHints( QPainter::Antialiasing, (
bool) lines_aa );
1417 p->setRenderHints( QPainter::Antialiasing,
false );
1423 if ( plsc->dev_eofill )
1424 p->drawPolygon( *( i->Data.Polyline ), Qt::OddEvenFill );
1426 p->drawPolygon( *( i->Data.Polyline ), Qt::WindingFill );
1427 p->setRenderHints( QPainter::Antialiasing, (
bool) lines_aa );
1433 p->setPen( SolidPen );
1437 p->resetTransform();
1439 renderText( p, i->Data.TextStruct, x_fact, x_offset, y_fact, y_offset );
1444 SolidPen.setWidthF( i->Data.fltParam );
1447 p->setPen( SolidPen );
1452 SolidBrush.setColor( QColor( i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A ) );
1453 p->fillRect( 0, 0, (
int) m_dWidth, (
int) m_dHeight, SolidBrush );
1459 p->setPen( SolidPen );
1462 if ( i->Data.ArcStruct->rotate != 0.0 )
1465 p->translate( *( i->Data.ArcStruct->dx ) );
1466 p->rotate( -i->Data.ArcStruct->rotate );
1467 p->translate( -*( i->Data.ArcStruct->dx ) );
1470 if ( i->Data.ArcStruct->fill )
1471 p->drawPie( *( i->Data.ArcStruct->rect ), i->Data.ArcStruct->startAngle, i->Data.ArcStruct->spanAngle );
1473 p->drawArc( *( i->Data.ArcStruct->rect ), i->Data.ArcStruct->startAngle, i->Data.ArcStruct->spanAngle );
1475 if ( i->Data.ArcStruct->rotate != 0.0 )
1486 start_iterator = m_listBuffer.constEnd();
1488 redrawFromLastFlush =
false;
1492 void QtPLWidget::getPlotParameters(
double & io_dXFact,
double & io_dYFact,
double & io_dXOffset,
double & io_dYOffset )
1494 double w = (double) width();
1495 double h = (double) height();
1496 if ( w / h > m_dAspectRatio )
1498 io_dYFact = h / m_dHeight;
1499 io_dXFact = h * m_dAspectRatio / m_dWidth;
1501 io_dXOffset = ( w - io_dXFact * m_dWidth ) / 2.;
1505 io_dXFact = w / m_dWidth;
1506 io_dYFact = w / m_dAspectRatio / m_dHeight;
1508 io_dYOffset = ( h - io_dYFact * m_dHeight ) / 2.;
1517 QApplication::setOverrideCursor( Qt::CrossCursor );
1519 while ( gin.pX < 0 && locate_mode )
1520 QCoreApplication::processEvents( QEventLoop::AllEvents, 10 );
1522 QApplication::restoreOverrideCursor();
1528 #if defined ( PLD_extqt )
1529 QtExtWidget::QtExtWidget(
int i_iWidth,
int i_iHeight, QWidget* parent ) :
1530 QtPLWidget( i_iWidth, i_iHeight, parent )
1532 cursorParameters.isTracking =
false;
1533 cursorParameters.cursor_x = -1.0;
1534 cursorParameters.cursor_y = -1.0;
1538 QtExtWidget::~QtExtWidget()
1541 QCoreApplication::processEvents( QEventLoop::AllEvents, 10 );
1548 void QtExtWidget::captureMousePlotCoords(
PLFLT* x,
PLFLT* y )
1550 setMouseTracking(
true );
1551 cursorParameters.isTracking =
true;
1552 cursorParameters.cursor_x =
1553 cursorParameters.cursor_y = -1.;
1556 QCoreApplication::processEvents( QEventLoop::AllEvents, 10 );
1557 }
while ( cursorParameters.isTracking && !killed );
1559 *x = cursorParameters.cursor_x;
1560 *y = cursorParameters.cursor_y;
1563 void QtExtWidget::mouseMoveEvent( QMouseEvent* event )
1565 if ( !cursorParameters.isTracking )
1568 double x_fact, y_fact, x_offset, y_offset;
1570 getPlotParameters( x_fact, y_fact, x_offset, y_offset );
1572 cursorParameters.cursor_x = (
PLFLT) event->x();
1573 cursorParameters.cursor_y = (
PLFLT) event->y();
1577 ratio_x = ( cursorParameters.cursor_x - x_offset ) / ( width() - 2. * x_offset );
1578 ratio_y = ( cursorParameters.cursor_y - y_offset ) / ( height() - 2. * y_offset );
1586 cursorParameters.cursor_x = -1.;
1587 cursorParameters.cursor_y = -1.;
1593 void QtExtWidget::mousePressEvent( QMouseEvent* )
1597 void QtExtWidget::mouseReleaseEvent( QMouseEvent* event )
1599 if ( !cursorParameters.isTracking )
1602 double x_fact, y_fact, x_offset, y_offset;
1604 getPlotParameters( x_fact, y_fact, x_offset, y_offset );
1606 cursorParameters.cursor_x = (
PLFLT) event->x();
1607 cursorParameters.cursor_y = (
PLFLT) event->y();
1608 cursorParameters.isTracking =
false;
1609 setMouseTracking(
false );
1613 ratio_x = ( cursorParameters.cursor_x - x_offset ) / ( width() - 2. * x_offset );
1614 ratio_y = ( cursorParameters.cursor_y - y_offset ) / ( height() - 2. * y_offset );
1622 cursorParameters.cursor_x = -1.;
1623 cursorParameters.cursor_y = -1.;
1627 cursorParameters.cursor_x = a;
1628 cursorParameters.cursor_y = b;
1634 void QtExtWidget::paintEvent( QPaintEvent* event )
1636 QtPLWidget::paintEvent( event );
1638 if ( !cursorParameters.isTracking || cursorParameters.cursor_x < 0 )
1643 p.setPen( QPen( Qt::white ) );
1645 p.drawLine( (
int) cursorParameters.cursor_x, 0, (
int) cursorParameters.cursor_x, height() );
1646 p.drawLine( 0, (
int) cursorParameters.cursor_y, width(), (
int) cursorParameters.cursor_y );
1651 void plsetqtdev( QtExtWidget* widget )
1653 plsc->dev = (
void *) widget;
1654 widget->setPLStream( plsc );
1657 void plsetqtdev( QtExtWidget* widget,
int argc,
char**
argv )
1660 plsc->dev = (
void *) widget;
1661 widget->setPLStream( plsc );
1666 delete ( (QtExtWidget *) plsc->dev );
virtual void drawPolygon(short *x, short *y, PLINT npts)
void plP_script_scale(PLBOOL ifupper, PLINT *level, PLFLT *old_scale, PLFLT *scale, PLFLT *old_offset, PLFLT *offset)
void plexit(PLCHAR_VECTOR errormsg)
void plP_fci2hex(PLUNICODE fci, unsigned char *phexdigit, unsigned char hexpower)
virtual void setColor(int r, int g, int b, double alpha)
QPicture getTextPicture(PLUNICODE fci, PLUNICODE *text, int len, PLFLT chrht)
void plGinInit(PLGraphicsIn *gin)
PLINT plTranslateCursor(PLGraphicsIn *plg)
virtual void drawPolyline(short *x, short *y, PLINT npts)
virtual void drawArc(short x, short y, short width, short height, PLFLT angle1, PLFLT angle2, PLFLT rotate, bool fill)
void DeviceClosed(QtPLDriver *d)
QtPLDriver * masterDevice
static const char * fileName
static struct line line[]
virtual void drawText(EscText *txt)
void DeviceChangedPage(QtPLDriver *d)
void setMasterDevice(QtPLDriver *d)
static PLStream * pls[PL_NSTREAMS]
QtPLDriver(PLINT i_iWidth=QT_DEFAULT_X, PLINT i_iHeight=QT_DEFAULT_Y)
void plRotationShear(PLFLT *xFormMatrix, PLFLT *rotation, PLFLT *shear, PLFLT *stride)
virtual void setWidthF(PLFLT w)
unsigned short unicode_array_len
virtual void setGradient(int x1, int x2, int y1, int y2, unsigned char *r, unsigned char *g, unsigned char *b, PLFLT *alpha, PLINT ncol1)
virtual void drawLine(short x1, short y1, short x2, short y2)
void drawTextInPicture(QPainter *, const QString &)
PLDLLIMPEXP_QT_DATA(int) vectorize=0
QFont getFont(PLUNICODE code)
PLUNICODE * unicode_array
void setPLStream(PLStream *pls)
PLDLLIMPEXP_CXX void fill(PLINT n, const PLFLT *x, const PLFLT *y)
bool isMasterDevice(QtPLDriver *d)