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
270 PLFLT empirical_yOffset = 0.;
293 currentString.append( QString( QChar( text[i] ) ) );
302 currentString.clear();
304 &old_sscale, &sscale, &old_soffset, &soffset );
322 currentString.clear();
324 &old_sscale, &sscale, &old_soffset, &soffset );
342 currentString.clear();
350 currentString.clear();
357 currentString.append( QString( (QChar *) &( text[i] ), 1 ) );
361 std::cout <<
"unknown escape char " << ( (QChar) text[i] ).toLatin1() << std::endl;
369 currentString.clear();
390 printf(
"Non unicode string passed to a Qt driver, ignoring\n" );
397 printf(
"Sorry, the Qt drivers only handle strings of length < %d\n", 500 );
401 PLFLT rotation, shear, stride;
408 picDpi = picText.logicalDpiY();
421 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. );
423 m_painterP->setWorldMatrix( rotShearMatrix,
true );
439 p.setColor( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
443 B.setColor( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
444 B.setStyle( Qt::SolidPattern );
449 unsigned char *r,
unsigned char *g,
457 QLinearGradient linear_gradient;
458 QGradientStops stops;
460 linear_gradient = QLinearGradient(
462 QPointF( (qreal) ( x2 * downscale ), (qreal) (
m_dHeight - y2 * downscale ) ) );
464 for ( i = 0; i < ncol1; i++ )
466 stop_arg = (qreal) i / (qreal) ( ncol1 - 1 );
467 stops << QGradientStop( stop_arg, QColor( r[i], g[i],
468 b[i], (
int) ( alpha[i] * 255 ) ) );
470 linear_gradient.setStops( stops );
505 p.setStyle( Qt::SolidLine );
510 #if defined ( PLD_bmpqt ) || defined ( PLD_jpgqt ) || defined ( PLD_pngqt ) || defined ( PLD_ppmqt ) || defined ( PLD_tiffqt )
511 QtRasterDevice::QtRasterDevice(
int i_iWidth,
int i_iHeight ) :
513 QImage( i_iWidth, i_iHeight, QImage::Format_RGB32 )
519 b.setStyle( Qt::SolidPattern );
521 m_painterP->setRenderHint( QPainter::Antialiasing, (
bool) lines_aa );
524 QtRasterDevice::~QtRasterDevice()
529 void QtRasterDevice::definePlotName(
const char*
fileName,
const char* format )
532 strncpy( this->format, format, 4 );
533 this->format[4] =
'\0';
535 this->fileName = QString( fileName );
538 void QtRasterDevice::savePlot()
543 m_painterP->begin(
this );
544 m_painterP->setRenderHint( QPainter::Antialiasing, (
bool) lines_aa );
545 QBrush b = m_painterP->brush();
546 b.setStyle( Qt::SolidPattern );
547 m_painterP->setBrush( b );
550 void QtRasterDevice::setBackgroundColor(
int r,
int g,
int b,
double alpha )
552 if ( !m_painterP->isActive() )
555 QBrush brush( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
556 m_painterP->fillRect( 0, 0, width(), height(), brush );
560 #if defined ( PLD_svgqt ) && QT_VERSION >= 0x040300
561 QtSVGDevice::QtSVGDevice(
int i_iWidth,
int i_iHeight ) :
567 QtSVGDevice::~QtSVGDevice()
572 void QtSVGDevice::definePlotName(
const char*
fileName )
574 setFileName( QString( fileName ) );
576 setSize( QSize( (
int) m_dWidth, (
int) m_dHeight ) );
577 #if QT_VERSION >= 0x040500
578 setViewBox( QRect( 0, 0, (
int) m_dWidth, (
int) m_dHeight ) );
581 m_painterP =
new QPainter(
this );
584 void QtSVGDevice::savePlot()
589 void QtSVGDevice::setBackgroundColor(
int r,
int g,
int b,
double alpha )
591 if ( !m_painterP->isActive() )
594 QBrush brush( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
595 m_painterP->fillRect( 0, 0, width(), height(), brush );
599 #if defined ( PLD_epsqt ) || defined ( PLD_pdfqt )
600 QtEPSDevice::QtEPSDevice(
int i_iWidth,
int i_iHeight )
602 #if QT_VERSION < 0x040400
603 setPageSize( QPrinter::A4 );
606 setPaperSize( QSizeF( i_iHeight, i_iWidth ), QPrinter::Point );
609 setColorMode( QPrinter::Color );
610 setOrientation( QPrinter::Landscape );
611 setPrintProgram( QString(
"lpr" ) );
613 if ( i_iWidth <= 0 || i_iHeight <= 0 )
615 m_dWidth = pageRect().width();
616 m_dHeight = pageRect().height();
621 m_dHeight = i_iHeight;
626 QtEPSDevice::~QtEPSDevice()
631 void QtEPSDevice::definePlotName(
const char* fileName,
int ifeps )
633 setOutputFileName( QString( fileName ) );
636 #ifndef PLPLOT_USE_QT5
637 setOutputFormat( QPrinter::PostScriptFormat );
642 setOutputFormat( QPrinter::PdfFormat );
645 m_painterP =
new QPainter(
this );
648 void QtEPSDevice::savePlot()
653 void QtEPSDevice::setBackgroundColor(
int r,
int g,
int b,
double alpha )
655 if ( !m_painterP->isActive() )
658 QBrush brush( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
659 m_painterP->fillRect( 0, 0, width(), height(), brush );
663 #if defined ( PLD_qtwidget ) || defined ( PLD_extqt )
664 QtPLWidget::QtPLWidget(
int i_iWidth,
int i_iHeight, QWidget* parent ) :
665 QWidget( parent ),
QtPLDriver( i_iWidth, i_iHeight )
674 resize( i_iWidth, i_iHeight );
683 redrawFromLastFlush =
false;
686 NoPen = QPen( Qt::NoPen );
687 NoPen.setWidthF( 0. );
692 QtPLWidget::~QtPLWidget()
698 void QtPLWidget::clearWidget()
701 setBackgroundColor( bgColour.r, bgColour.g, bgColour.b, bgColour.alpha );
707 void QtPLWidget::flush()
710 QApplication::processEvents();
713 void QtPLWidget::clearBuffer()
716 for ( QLinkedList<BufferElement>::iterator i = m_listBuffer.begin(); i != m_listBuffer.end(); ++i )
718 switch ( i->Element )
729 delete i->Data.Polyline;
733 delete[] i->Data.TextStruct->text;
734 delete i->Data.TextStruct;
739 delete i->Data.ColourStruct;
743 delete i->Data.LinearGradient;
747 delete i->Data.ArcStruct->rect;
748 delete i->Data.ArcStruct->dx;
749 delete i->Data.ArcStruct;
756 m_listBuffer.clear();
757 start_iterator = m_listBuffer.constBegin();
762 void QtPLWidget::drawArc(
short x,
short y,
short a,
short b,
PLFLT angle1,
PLFLT angle2,
PLFLT rotate,
bool fill )
766 el.Data.ArcStruct =
new struct ArcStruct_;
767 el.Data.ArcStruct->rect =
new QRectF( (
PLFLT) ( x - a ) * downscale,
768 m_dHeight - (
PLFLT) ( y + b ) * downscale,
769 (
PLFLT) a * downscale * 2,
770 (
PLFLT) b * downscale * 2
772 el.Data.ArcStruct->startAngle = (int) ( angle1 * 16 );
773 el.Data.ArcStruct->spanAngle = (int) ( ( angle2 - angle1 ) * 16 );
774 el.Data.ArcStruct->rotate = rotate;
775 el.Data.ArcStruct->dx =
new QPointF( (
PLFLT) x * downscale, m_dHeight - (
PLFLT) y * downscale );
776 el.Data.ArcStruct->fill =
fill;
778 m_listBuffer.append( el );
779 redrawFromLastFlush =
true;
783 void QtPLWidget::drawLine(
short x1,
short y1,
short x2,
short y2 )
787 el.Data.Line =
new QLineF( QPointF( (
PLFLT) x1 * downscale, (
PLFLT) ( m_dHeight - y1 * downscale ) ), QPointF( (
PLFLT) x2 * downscale, (
PLFLT) ( m_dHeight - y2 * downscale ) ) );
789 m_listBuffer.append( el );
790 redrawFromLastFlush =
true;
793 void QtPLWidget::drawPolyline(
short * x,
short * y,
PLINT npts )
797 el.Data.Polyline =
new QPolygonF;
798 for (
int i = 0; i < npts; ++i )
800 ( *el.Data.Polyline ) << QPointF( (
PLFLT) ( x[i] ) * downscale, (
PLFLT) ( m_dHeight - ( y[i] ) * downscale ) );
803 m_listBuffer.append( el );
804 redrawFromLastFlush =
true;
807 void QtPLWidget::drawPolygon(
short * x,
short * y,
PLINT npts )
814 if ( x[0] == x[1] && x[2] == x[3] && y[0] == y[3] && y[1] == y[2] )
818 else if ( x[0] == x[3] && x[1] == x[2] && y[0] == y[1] && y[2] == y[3] )
825 if ( x[0] == x[4] && y[0] == y[4] )
827 if ( x[0] == x[1] && x[2] == x[3] && y[0] == y[3] && y[1] == y[2] )
831 else if ( x[0] == x[3] && x[1] == x[2] && y[0] == y[1] && y[2] == y[3] )
840 el.Element = RECTANGLE;
842 double x1, y1, x2, y2, x0, y0, width, height;
843 x1 = (
PLFLT) ( x[0] ) * downscale;
844 x2 = (
PLFLT) ( x[2] ) * downscale;
845 y1 = (
PLFLT) ( m_dHeight - ( y[0] ) * downscale );
846 y2 = (
PLFLT) ( m_dHeight - ( y[2] ) * downscale );
867 el.Data.Rect =
new QRectF( x0, y0, width, height );
871 el.Element = POLYGON;
872 el.Data.Polyline =
new QPolygonF;
873 for (
int i = 0; i < npts; ++i )
875 ( *el.Data.Polyline ) << QPointF( (
PLFLT) ( x[i] ) * downscale, (
PLFLT) ( m_dHeight - ( y[i] ) * downscale ) );
879 m_listBuffer.append( el );
880 redrawFromLastFlush =
true;
883 void QtPLWidget::setColor(
int r,
int g,
int b,
double alpha )
885 if ( lastColour.r != r || lastColour.g != g || lastColour.b != b || lastColour.alpha != alpha )
888 el.Element = SET_COLOUR;
889 el.Data.ColourStruct =
new struct ColourStruct_;
890 el.Data.ColourStruct->R = r;
891 el.Data.ColourStruct->G = g;
892 el.Data.ColourStruct->B = b;
893 el.Data.ColourStruct->A = (
PLINT) ( alpha * 255. );
895 m_listBuffer.append( el );
900 lastColour.alpha = alpha;
906 void QtPLWidget::setGradient(
int x1,
int x2,
int y1,
int y2,
907 unsigned char *r,
unsigned char *g,
913 QGradientStops stops;
915 el.Element = SET_GRADIENT;
917 el.Data.LinearGradient =
new QLinearGradient;
918 *el.Data.LinearGradient = QLinearGradient(
919 QPointF( (qreal) ( x1 * downscale ), (qreal) ( m_dHeight - y1 * downscale ) ),
920 QPointF( (qreal) ( x2 * downscale ), (qreal) ( m_dHeight - y2 * downscale ) ) );
921 for ( i = 0; i < ncol1; i++ )
923 stop_arg = (qreal) i / (qreal) ( ncol1 - 1 );
924 stops << QGradientStop( stop_arg, QColor( r[i], g[i],
925 b[i], (
int) ( alpha[i] * 255 ) ) );
927 ( *el.Data.LinearGradient ).setStops( stops );
928 m_listBuffer.append( el );
935 void QtPLWidget::setBackgroundColor(
int r,
int g,
int b,
double alpha )
938 el.Element = SET_BG_COLOUR;
939 el.Data.ColourStruct =
new struct ColourStruct_;
940 el.Data.ColourStruct->R = r;
941 el.Data.ColourStruct->G = g;
942 el.Data.ColourStruct->B = b;
943 el.Data.ColourStruct->A = (
PLINT) ( alpha * 255. );
948 bgColour.alpha = alpha;
949 if ( alpha >= 0.999 )
953 m_listBuffer.append( el );
954 redrawFromLastFlush =
true;
957 void QtPLWidget::setWidthF(
PLFLT w )
960 el.Element = SET_WIDTH;
961 el.Data.fltParam = w;
962 m_listBuffer.append( el );
966 void QtPLWidget::drawText(
EscText* txt )
978 picText = getTextPicture( fci,
989 picDpi = picText.logicalDpiY();
998 el.Data.TextStruct =
new struct TextStruct_;
999 el.Data.TextStruct->x = txt->
x * downscale;
1000 el.Data.TextStruct->y = m_dHeight - txt->
y * downscale;
1001 el.Data.TextStruct->clipxmin =
pls->
clpxmi * downscale;
1002 el.Data.TextStruct->clipymin = m_dHeight -
pls->
clpymi * downscale;
1003 el.Data.TextStruct->clipxmax =
pls->
clpxma * downscale;
1004 el.Data.TextStruct->clipymax = m_dHeight -
pls->
clpyma * downscale;
1007 el.Data.TextStruct->fci = fci;
1008 PLFLT rotation, shear, stride;
1011 el.Data.TextStruct->rotation = rotation;
1012 el.Data.TextStruct->shear = shear;
1013 el.Data.TextStruct->stride = stride;
1014 el.Data.TextStruct->just = txt->
just;
1018 el.Data.TextStruct->chrht =
pls->
chrht;
1020 m_listBuffer.append( el );
1021 redrawFromLastFlush =
true;
1024 void QtPLWidget::renderText( QPainter* p,
struct TextStruct_* s,
double x_fact,
double x_offset,
double y_fact,
double y_offset )
1026 if ( s->len <= 0 || s->len >= 500 )
1028 QPicture picText = getTextPicture( s->fci, s->text, s->len, s->chrht * y_fact );
1030 double picDpi = picText.logicalDpiY();
1032 p->setClipping(
true );
1033 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 );
1034 p->translate( s->x * x_fact + x_offset, s->y * y_fact + y_offset );
1035 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. );
1036 p->setWorldMatrix( rotShearMatrix,
true );
1038 p->translate( -s->just * xOffset * p->device()->logicalDpiY() / picDpi, 0. );
1040 p->drawPicture( 0, 0, picText );
1042 p->resetTransform();
1044 p->setClipping(
false );
1047 void QtPLWidget::resetPensAndBrushes( QPainter* painter )
1051 painter->setPen( SolidPen );
1052 SolidBrush = QBrush( Qt::SolidPattern );
1055 void QtPLWidget::lookupButtonEvent( QMouseEvent * event )
1057 Qt::MouseButtons buttons =
event->buttons();
1058 Qt::KeyboardModifiers modifiers =
event->modifiers();
1059 gin.pX =
event->x();
1060 gin.pY = height() -
event->y();
1061 gin.dX = (
PLFLT) event->x() / width();
1062 gin.dY = (
PLFLT) ( height() -
event->y() ) / height();
1064 switch ( event->button() )
1066 case Qt::LeftButton:
1072 case Qt::RightButton:
1082 if ( buttons & Qt::LeftButton )
1083 gin.state |= 1 << 8;
1084 if ( buttons & Qt::MidButton )
1085 gin.state |= 1 << 9;
1086 if ( buttons & Qt::RightButton )
1087 gin.state |= 1 << 10;
1088 if ( modifiers & Qt::ShiftModifier )
1089 gin.state |= 1 << 0;
1090 if ( modifiers & Qt::ControlModifier )
1091 gin.state |= 1 << 2;
1092 if ( modifiers & Qt::AltModifier )
1093 gin.state |= 1 << 3;
1094 if ( modifiers & Qt::MetaModifier )
1095 gin.state |= 1 << 3;
1100 void QtPLWidget::locate()
1104 if ( locate_mode == 2 )
1107 if ( gin.keysym < 0xFF && isprint( gin.keysym ) )
1108 std::cout << gin.wX <<
" " << gin.wY <<
" " << (char) gin.keysym << std::endl;
1110 std::cout << gin.wX <<
" " << gin.wY <<
" " << std::hex << gin.keysym << std::endl;
1118 QApplication::restoreOverrideCursor();
1122 void QtPLWidget::mouseEvent( QMouseEvent * event )
1124 lookupButtonEvent( event );
1128 if ( event->button() == Qt::LeftButton )
1135 if ( event->button() == Qt::RightButton )
1137 handler.DeviceChangedPage(
this );
1142 void QtPLWidget::mousePressEvent( QMouseEvent * event )
1144 mouseEvent( event );
1147 void QtPLWidget::mouseReleaseEvent( QMouseEvent *
PL_UNUSED( event ) )
1152 void QtPLWidget::mouseMoveEvent( QMouseEvent *
PL_UNUSED( event ) )
1157 void QtPLWidget::keyPressEvent( QKeyEvent* event )
1161 QPoint p = QCursor::pos();
1163 gin.pY = height() - p.y();
1164 gin.dX = (
PLFLT) p.x() / width();
1165 gin.dY = (
PLFLT) ( height() - p.y() ) / height();
1167 switch ( event->key() )
1169 case Qt::Key_Escape:
1171 QApplication::restoreOverrideCursor();
1175 case Qt::Key_Control:
1185 int x1, y1,
dx = 0,
dy = 0;
1187 switch ( event->key() )
1202 if ( event->modifiers() & Qt::ShiftModifier )
1207 if ( event->modifiers() & Qt::ControlModifier )
1212 if ( event->modifiers() & Qt::AltModifier )
1229 QCursor::setPos( p.x() +
dx, p.y() +
dy );
1240 if ( event->key() == Qt::Key_Enter ||
event->key() == Qt::Key_Return )
1242 handler.DeviceChangedPage(
this );
1244 if ( event->text() ==
"Q" )
1250 else if ( event->text() ==
"L" )
1254 QApplication::setOverrideCursor( Qt::CrossCursor );
1259 void QtPLWidget::closeEvent( QCloseEvent* event )
1261 handler.DeviceClosed(
this );
1265 void QtPLWidget::nextPage()
1271 void QtPLWidget::resizeEvent( QResizeEvent * )
1279 void QtPLWidget::paintEvent( QPaintEvent * )
1281 double x_fact, y_fact, x_offset( 0. ), y_offset( 0. );
1283 getPlotParameters( x_fact, y_fact, x_offset, y_offset );
1285 if ( redrawAll || m_pixPixmap == NULL )
1287 if ( m_pixPixmap != NULL )
1291 m_pixPixmap =
new QPixmap( width(), height() );
1292 QPainter* painter =
new QPainter;
1293 painter->begin( m_pixPixmap );
1296 painter->fillRect( 0, 0, width(), height(), QColor( bgColour.r, bgColour.g, bgColour.b ) );
1299 resetPensAndBrushes( painter );
1301 start_iterator = m_listBuffer.constBegin();
1304 doPlot( painter, x_fact, y_fact, x_offset, y_offset );
1313 QPainter* painter =
new QPainter;
1314 painter->begin( m_pixPixmap );
1316 painter->setPen( SolidPen );
1318 painter->setPen( NoPen );
1321 doPlot( painter, x_fact, y_fact, x_offset, y_offset );
1326 m_painterP->begin(
this );
1328 m_painterP->drawPixmap( 0, 0, *m_pixPixmap );
1333 void QtPLWidget::doPlot( QPainter* p,
double x_fact,
double y_fact,
double x_offset,
double y_offset )
1336 QVector<qreal> vect;
1347 p->setRenderHints( QPainter::Antialiasing, (
bool) lines_aa );
1350 p->setBrush( SolidBrush );
1353 trans = trans.translate( x_offset, y_offset );
1354 trans = trans.scale( x_fact, y_fact );
1356 p->setTransform( trans );
1358 if ( m_listBuffer.empty() )
1360 p->fillRect( 0, 0, 1, 1, QBrush() );
1365 for ( QLinkedList<BufferElement>::const_iterator i = start_iterator; i != m_listBuffer.constEnd(); ++i )
1367 switch ( i->Element )
1370 SolidPen.setColor( QColor( i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A ) );
1373 p->setPen( SolidPen );
1375 SolidBrush.setColor( QColor( i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A ) );
1376 p->setBrush( SolidBrush );
1380 p->setBrush( *( i->Data.LinearGradient ) );
1386 p->setPen( SolidPen );
1389 p->drawLine( *( i->Data.Line ) );
1396 p->setPen( SolidPen );
1399 p->drawPolyline( *( i->Data.Polyline ) );
1403 p->setRenderHints( QPainter::Antialiasing,
false );
1409 p->drawRect( *( i->Data.Rect ) );
1410 p->setRenderHints( QPainter::Antialiasing, (
bool) lines_aa );
1414 p->setRenderHints( QPainter::Antialiasing,
false );
1420 if ( plsc->dev_eofill )
1421 p->drawPolygon( *( i->Data.Polyline ), Qt::OddEvenFill );
1423 p->drawPolygon( *( i->Data.Polyline ), Qt::WindingFill );
1424 p->setRenderHints( QPainter::Antialiasing, (
bool) lines_aa );
1430 p->setPen( SolidPen );
1434 p->resetTransform();
1436 renderText( p, i->Data.TextStruct, x_fact, x_offset, y_fact, y_offset );
1441 SolidPen.setWidthF( i->Data.fltParam );
1444 p->setPen( SolidPen );
1449 SolidBrush.setColor( QColor( i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A ) );
1450 p->fillRect( 0, 0, (
int) m_dWidth, (
int) m_dHeight, SolidBrush );
1456 p->setPen( SolidPen );
1459 if ( i->Data.ArcStruct->rotate != 0.0 )
1462 p->translate( *( i->Data.ArcStruct->dx ) );
1463 p->rotate( -i->Data.ArcStruct->rotate );
1464 p->translate( -*( i->Data.ArcStruct->dx ) );
1467 if ( i->Data.ArcStruct->fill )
1468 p->drawPie( *( i->Data.ArcStruct->rect ), i->Data.ArcStruct->startAngle, i->Data.ArcStruct->spanAngle );
1470 p->drawArc( *( i->Data.ArcStruct->rect ), i->Data.ArcStruct->startAngle, i->Data.ArcStruct->spanAngle );
1472 if ( i->Data.ArcStruct->rotate != 0.0 )
1483 start_iterator = m_listBuffer.constEnd();
1485 redrawFromLastFlush =
false;
1489 void QtPLWidget::getPlotParameters(
double & io_dXFact,
double & io_dYFact,
double & io_dXOffset,
double & io_dYOffset )
1491 double w = (double) width();
1492 double h = (double) height();
1493 if ( w / h > m_dAspectRatio )
1495 io_dYFact = h / m_dHeight;
1496 io_dXFact = h * m_dAspectRatio / m_dWidth;
1498 io_dXOffset = ( w - io_dXFact * m_dWidth ) / 2.;
1502 io_dXFact = w / m_dWidth;
1503 io_dYFact = w / m_dAspectRatio / m_dHeight;
1505 io_dYOffset = ( h - io_dYFact * m_dHeight ) / 2.;
1514 QApplication::setOverrideCursor( Qt::CrossCursor );
1516 while ( gin.pX < 0 && locate_mode )
1517 QCoreApplication::processEvents( QEventLoop::AllEvents, 10 );
1519 QApplication::restoreOverrideCursor();
1525 #if defined ( PLD_extqt )
1526 QtExtWidget::QtExtWidget(
int i_iWidth,
int i_iHeight, QWidget* parent ) :
1527 QtPLWidget( i_iWidth, i_iHeight, parent )
1529 cursorParameters.isTracking =
false;
1530 cursorParameters.cursor_x = -1.0;
1531 cursorParameters.cursor_y = -1.0;
1535 QtExtWidget::~QtExtWidget()
1538 QCoreApplication::processEvents( QEventLoop::AllEvents, 10 );
1545 void QtExtWidget::captureMousePlotCoords(
PLFLT* x,
PLFLT* y )
1547 setMouseTracking(
true );
1548 cursorParameters.isTracking =
true;
1549 cursorParameters.cursor_x =
1550 cursorParameters.cursor_y = -1.;
1553 QCoreApplication::processEvents( QEventLoop::AllEvents, 10 );
1554 }
while ( cursorParameters.isTracking && !killed );
1556 *x = cursorParameters.cursor_x;
1557 *y = cursorParameters.cursor_y;
1560 void QtExtWidget::mouseMoveEvent( QMouseEvent* event )
1562 if ( !cursorParameters.isTracking )
1565 double x_fact, y_fact, x_offset, y_offset;
1567 getPlotParameters( x_fact, y_fact, x_offset, y_offset );
1569 cursorParameters.cursor_x = (
PLFLT) event->x();
1570 cursorParameters.cursor_y = (
PLFLT) event->y();
1574 ratio_x = ( cursorParameters.cursor_x - x_offset ) / ( width() - 2. * x_offset );
1575 ratio_y = ( cursorParameters.cursor_y - y_offset ) / ( height() - 2. * y_offset );
1583 cursorParameters.cursor_x = -1.;
1584 cursorParameters.cursor_y = -1.;
1590 void QtExtWidget::mousePressEvent( QMouseEvent* )
1594 void QtExtWidget::mouseReleaseEvent( QMouseEvent* event )
1596 if ( !cursorParameters.isTracking )
1599 double x_fact, y_fact, x_offset, y_offset;
1601 getPlotParameters( x_fact, y_fact, x_offset, y_offset );
1603 cursorParameters.cursor_x = (
PLFLT) event->x();
1604 cursorParameters.cursor_y = (
PLFLT) event->y();
1605 cursorParameters.isTracking =
false;
1606 setMouseTracking(
false );
1610 ratio_x = ( cursorParameters.cursor_x - x_offset ) / ( width() - 2. * x_offset );
1611 ratio_y = ( cursorParameters.cursor_y - y_offset ) / ( height() - 2. * y_offset );
1619 cursorParameters.cursor_x = -1.;
1620 cursorParameters.cursor_y = -1.;
1624 cursorParameters.cursor_x = a;
1625 cursorParameters.cursor_y = b;
1631 void QtExtWidget::paintEvent( QPaintEvent* event )
1633 QtPLWidget::paintEvent( event );
1635 if ( !cursorParameters.isTracking || cursorParameters.cursor_x < 0 )
1640 p.setPen( QPen( Qt::white ) );
1642 p.drawLine( (
int) cursorParameters.cursor_x, 0, (
int) cursorParameters.cursor_x, height() );
1643 p.drawLine( 0, (
int) cursorParameters.cursor_y, width(), (
int) cursorParameters.cursor_y );
1648 void plsetqtdev( QtExtWidget* widget )
1650 plsc->dev = (
void *) widget;
1651 widget->setPLStream( plsc );
1654 void plsetqtdev( QtExtWidget* widget,
int argc,
char**
argv )
1657 plsc->dev = (
void *) widget;
1658 widget->setPLStream( plsc );
1663 delete ( (QtExtWidget *) plsc->dev );