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;
274 currentString.append( QString( QChar( text[i] ) ) );
283 currentString.clear();
285 &old_sscale, &sscale, &old_soffset, &soffset );
303 currentString.clear();
305 &old_sscale, &sscale, &old_soffset, &soffset );
323 currentString.clear();
331 currentString.clear();
338 currentString.append( QString( (QChar *) &( text[i] ), 1 ) );
342 std::cout <<
"unknown escape char " << ( (QChar) text[i] ).toLatin1() << std::endl;
350 currentString.clear();
371 printf(
"Non unicode string passed to a Qt driver, ignoring\n" );
378 printf(
"Sorry, the Qt drivers only handle strings of length < %d\n", 500 );
382 PLFLT rotation, shear, stride;
389 picDpi = picText.logicalDpiY();
402 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. );
404 m_painterP->setWorldMatrix( rotShearMatrix,
true );
420 p.setColor( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
424 B.setColor( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
425 B.setStyle( Qt::SolidPattern );
430 unsigned char *r,
unsigned char *g,
438 QLinearGradient linear_gradient;
439 QGradientStops stops;
441 linear_gradient = QLinearGradient(
443 QPointF( (qreal) ( x2 * downscale ), (qreal) (
m_dHeight - y2 * downscale ) ) );
445 for ( i = 0; i < ncol1; i++ )
447 stop_arg = (qreal) i / (qreal) ( ncol1 - 1 );
448 stops << QGradientStop( stop_arg, QColor( r[i], g[i],
449 b[i], (
int) ( alpha[i] * 255 ) ) );
451 linear_gradient.setStops( stops );
486 p.setStyle( Qt::SolidLine );
491 #if defined ( PLD_bmpqt ) || defined ( PLD_jpgqt ) || defined ( PLD_pngqt ) || defined ( PLD_ppmqt ) || defined ( PLD_tiffqt )
492 QtRasterDevice::QtRasterDevice(
int i_iWidth,
int i_iHeight ) :
494 QImage( i_iWidth, i_iHeight, QImage::Format_RGB32 )
500 b.setStyle( Qt::SolidPattern );
502 m_painterP->setRenderHint( QPainter::Antialiasing, (
bool) lines_aa );
505 QtRasterDevice::~QtRasterDevice()
510 void QtRasterDevice::definePlotName(
const char*
fileName,
const char* format )
513 strncpy( this->format, format, 4 );
514 this->format[4] =
'\0';
516 this->fileName = QString( fileName );
519 void QtRasterDevice::savePlot()
524 m_painterP->begin(
this );
525 m_painterP->setRenderHint( QPainter::Antialiasing, (
bool) lines_aa );
526 QBrush b = m_painterP->brush();
527 b.setStyle( Qt::SolidPattern );
528 m_painterP->setBrush( b );
531 void QtRasterDevice::setBackgroundColor(
int r,
int g,
int b,
double alpha )
533 if ( !m_painterP->isActive() )
536 QBrush brush( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
537 m_painterP->fillRect( 0, 0, width(), height(), brush );
541 #if defined ( PLD_svgqt ) && QT_VERSION >= 0x040300
542 QtSVGDevice::QtSVGDevice(
int i_iWidth,
int i_iHeight ) :
548 QtSVGDevice::~QtSVGDevice()
553 void QtSVGDevice::definePlotName(
const char*
fileName )
555 setFileName( QString( fileName ) );
557 setSize( QSize( (
int) m_dWidth, (
int) m_dHeight ) );
558 #if QT_VERSION >= 0x040500
559 setViewBox( QRect( 0, 0, (
int) m_dWidth, (
int) m_dHeight ) );
562 m_painterP =
new QPainter(
this );
565 void QtSVGDevice::savePlot()
570 void QtSVGDevice::setBackgroundColor(
int r,
int g,
int b,
double alpha )
572 if ( !m_painterP->isActive() )
575 QBrush brush( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
576 m_painterP->fillRect( 0, 0, width(), height(), brush );
580 #if defined ( PLD_epsqt ) || defined ( PLD_pdfqt )
581 QtEPSDevice::QtEPSDevice(
int i_iWidth,
int i_iHeight )
583 #if QT_VERSION < 0x040400
584 setPageSize( QPrinter::A4 );
587 setPaperSize( QSizeF( i_iHeight, i_iWidth ), QPrinter::Point );
590 setColorMode( QPrinter::Color );
591 setOrientation( QPrinter::Landscape );
592 setPrintProgram( QString(
"lpr" ) );
594 if ( i_iWidth <= 0 || i_iHeight <= 0 )
596 m_dWidth = pageRect().width();
597 m_dHeight = pageRect().height();
602 m_dHeight = i_iHeight;
607 QtEPSDevice::~QtEPSDevice()
612 void QtEPSDevice::definePlotName(
const char* fileName,
int ifeps )
614 setOutputFileName( QString( fileName ) );
617 setOutputFormat( QPrinter::PostScriptFormat );
621 setOutputFormat( QPrinter::PdfFormat );
624 m_painterP =
new QPainter(
this );
627 void QtEPSDevice::savePlot()
632 void QtEPSDevice::setBackgroundColor(
int r,
int g,
int b,
double alpha )
634 if ( !m_painterP->isActive() )
637 QBrush brush( QColor( r, g, b, (
int) ( alpha * 255 ) ) );
638 m_painterP->fillRect( 0, 0, width(), height(), brush );
642 #if defined ( PLD_qtwidget ) || defined ( PLD_extqt )
643 QtPLWidget::QtPLWidget(
int i_iWidth,
int i_iHeight, QWidget* parent ) :
644 QWidget( parent ),
QtPLDriver( i_iWidth, i_iHeight )
653 resize( i_iWidth, i_iHeight );
656 QApplication::processEvents();
657 redrawFromLastFlush =
false;
660 NoPen = QPen( Qt::NoPen );
661 NoPen.setWidthF( 0. );
666 QtPLWidget::~QtPLWidget()
672 void QtPLWidget::clearWidget()
675 setBackgroundColor( bgColour.r, bgColour.g, bgColour.b, bgColour.alpha );
681 void QtPLWidget::flush()
684 QApplication::processEvents();
687 void QtPLWidget::clearBuffer()
690 for ( QLinkedList<BufferElement>::iterator i = m_listBuffer.begin(); i != m_listBuffer.end(); ++i )
692 switch ( i->Element )
703 delete i->Data.Polyline;
707 delete[] i->Data.TextStruct->text;
708 delete i->Data.TextStruct;
713 delete i->Data.ColourStruct;
717 delete i->Data.LinearGradient;
721 delete i->Data.ArcStruct->rect;
722 delete i->Data.ArcStruct->dx;
723 delete i->Data.ArcStruct;
730 m_listBuffer.clear();
731 start_iterator = m_listBuffer.constBegin();
736 void QtPLWidget::drawArc(
short x,
short y,
short a,
short b,
PLFLT angle1,
PLFLT angle2,
PLFLT rotate,
bool fill )
740 el.Data.ArcStruct =
new struct ArcStruct_;
741 el.Data.ArcStruct->rect =
new QRectF( (
PLFLT) ( x - a ) * downscale,
742 m_dHeight - (
PLFLT) ( y + b ) * downscale,
743 (
PLFLT) a * downscale * 2,
744 (
PLFLT) b * downscale * 2
746 el.Data.ArcStruct->startAngle = (int) ( angle1 * 16 );
747 el.Data.ArcStruct->spanAngle = (int) ( ( angle2 - angle1 ) * 16 );
748 el.Data.ArcStruct->rotate = rotate;
749 el.Data.ArcStruct->dx =
new QPointF( (
PLFLT) x * downscale, m_dHeight - (
PLFLT) y * downscale );
750 el.Data.ArcStruct->fill = fill;
752 m_listBuffer.append( el );
753 redrawFromLastFlush =
true;
757 void QtPLWidget::drawLine(
short x1,
short y1,
short x2,
short y2 )
761 el.Data.Line =
new QLineF( QPointF( (
PLFLT) x1 * downscale, (
PLFLT) ( m_dHeight - y1 * downscale ) ), QPointF( (
PLFLT) x2 * downscale, (
PLFLT) ( m_dHeight - y2 * downscale ) ) );
763 m_listBuffer.append( el );
764 redrawFromLastFlush =
true;
767 void QtPLWidget::drawPolyline(
short * x,
short * y,
PLINT npts )
771 el.Data.Polyline =
new QPolygonF;
772 for (
int i = 0; i < npts; ++i )
774 ( *el.Data.Polyline ) << QPointF( (
PLFLT) ( x[i] ) * downscale, (
PLFLT) ( m_dHeight - ( y[i] ) * downscale ) );
777 m_listBuffer.append( el );
778 redrawFromLastFlush =
true;
781 void QtPLWidget::drawPolygon(
short * x,
short * y,
PLINT npts )
788 if ( x[0] == x[1] && x[2] == x[3] && y[0] == y[3] && y[1] == y[2] )
792 else if ( x[0] == x[3] && x[1] == x[2] && y[0] == y[1] && y[2] == y[3] )
799 if ( x[0] == x[4] && y[0] == y[4] )
801 if ( x[0] == x[1] && x[2] == x[3] && y[0] == y[3] && y[1] == y[2] )
805 else if ( x[0] == x[3] && x[1] == x[2] && y[0] == y[1] && y[2] == y[3] )
814 el.Element = RECTANGLE;
816 double x1, y1, x2, y2, x0, y0, width, height;
817 x1 = (
PLFLT) ( x[0] ) * downscale;
818 x2 = (
PLFLT) ( x[2] ) * downscale;
819 y1 = (
PLFLT) ( m_dHeight - ( y[0] ) * downscale );
820 y2 = (
PLFLT) ( m_dHeight - ( y[2] ) * downscale );
841 el.Data.Rect =
new QRectF( x0, y0, width, height );
845 el.Element = POLYGON;
846 el.Data.Polyline =
new QPolygonF;
847 for (
int i = 0; i < npts; ++i )
849 ( *el.Data.Polyline ) << QPointF( (
PLFLT) ( x[i] ) * downscale, (
PLFLT) ( m_dHeight - ( y[i] ) * downscale ) );
853 m_listBuffer.append( el );
854 redrawFromLastFlush =
true;
857 void QtPLWidget::setColor(
int r,
int g,
int b,
double alpha )
859 if ( lastColour.r != r || lastColour.g != g || lastColour.b != b || lastColour.alpha != alpha )
862 el.Element = SET_COLOUR;
863 el.Data.ColourStruct =
new struct ColourStruct_;
864 el.Data.ColourStruct->R = r;
865 el.Data.ColourStruct->G = g;
866 el.Data.ColourStruct->B = b;
867 el.Data.ColourStruct->A = (
PLINT) ( alpha * 255. );
869 m_listBuffer.append( el );
874 lastColour.alpha = alpha;
880 void QtPLWidget::setGradient(
int x1,
int x2,
int y1,
int y2,
881 unsigned char *r,
unsigned char *g,
887 QGradientStops stops;
889 el.Element = SET_GRADIENT;
891 el.Data.LinearGradient =
new QLinearGradient;
892 *el.Data.LinearGradient = QLinearGradient(
893 QPointF( (qreal) ( x1 * downscale ), (qreal) ( m_dHeight - y1 * downscale ) ),
894 QPointF( (qreal) ( x2 * downscale ), (qreal) ( m_dHeight - y2 * downscale ) ) );
895 for ( i = 0; i < ncol1; i++ )
897 stop_arg = (qreal) i / (qreal) ( ncol1 - 1 );
898 stops << QGradientStop( stop_arg, QColor( r[i], g[i],
899 b[i], (
int) ( alpha[i] * 255 ) ) );
901 ( *el.Data.LinearGradient ).setStops( stops );
902 m_listBuffer.append( el );
909 void QtPLWidget::setBackgroundColor(
int r,
int g,
int b,
double alpha )
912 el.Element = SET_BG_COLOUR;
913 el.Data.ColourStruct =
new struct ColourStruct_;
914 el.Data.ColourStruct->R = r;
915 el.Data.ColourStruct->G = g;
916 el.Data.ColourStruct->B = b;
917 el.Data.ColourStruct->A = (
PLINT) ( alpha * 255. );
922 bgColour.alpha = alpha;
923 if ( alpha >= 0.999 )
927 m_listBuffer.append( el );
928 redrawFromLastFlush =
true;
931 void QtPLWidget::setWidthF(
PLFLT w )
934 el.Element = SET_WIDTH;
935 el.Data.fltParam = w;
936 m_listBuffer.append( el );
940 void QtPLWidget::drawText(
EscText* txt )
952 picText = getTextPicture( fci,
963 picDpi = picText.logicalDpiY();
972 el.Data.TextStruct =
new struct TextStruct_;
973 el.Data.TextStruct->x = txt->
x * downscale;
974 el.Data.TextStruct->y = m_dHeight - txt->
y * downscale;
975 el.Data.TextStruct->clipxmin =
pls->
clpxmi * downscale;
976 el.Data.TextStruct->clipymin = m_dHeight -
pls->
clpymi * downscale;
977 el.Data.TextStruct->clipxmax =
pls->
clpxma * downscale;
978 el.Data.TextStruct->clipymax = m_dHeight -
pls->
clpyma * downscale;
981 el.Data.TextStruct->fci = fci;
982 PLFLT rotation, shear, stride;
985 el.Data.TextStruct->rotation = rotation;
986 el.Data.TextStruct->shear = shear;
987 el.Data.TextStruct->stride = stride;
988 el.Data.TextStruct->just = txt->
just;
992 el.Data.TextStruct->chrht =
pls->
chrht;
994 m_listBuffer.append( el );
995 redrawFromLastFlush =
true;
998 void QtPLWidget::renderText( QPainter* p,
struct TextStruct_* s,
double x_fact,
double x_offset,
double y_fact,
double y_offset )
1000 if ( s->len <= 0 || s->len >= 500 )
1002 QPicture picText = getTextPicture( s->fci, s->text, s->len, s->chrht * y_fact );
1004 double picDpi = picText.logicalDpiY();
1006 p->setClipping(
true );
1007 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 );
1008 p->translate( s->x * x_fact + x_offset, s->y * y_fact + y_offset );
1009 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. );
1010 p->setWorldMatrix( rotShearMatrix,
true );
1012 p->translate( -s->just * xOffset * p->device()->logicalDpiY() / picDpi, 0. );
1014 p->drawPicture( 0, 0, picText );
1016 p->resetTransform();
1018 p->setClipping(
false );
1021 void QtPLWidget::resetPensAndBrushes( QPainter* painter )
1025 painter->setPen( SolidPen );
1026 SolidBrush = QBrush( Qt::SolidPattern );
1029 void QtPLWidget::lookupButtonEvent( QMouseEvent * event )
1031 Qt::MouseButtons buttons =
event->buttons();
1032 Qt::KeyboardModifiers modifiers =
event->modifiers();
1033 gin.pX =
event->x();
1034 gin.pY = height() -
event->y();
1035 gin.dX = (
PLFLT) event->x() / width();
1036 gin.dY = (
PLFLT) ( height() -
event->y() ) / height();
1038 switch ( event->button() )
1040 case Qt::LeftButton:
1046 case Qt::RightButton:
1056 if ( buttons & Qt::LeftButton )
1057 gin.state |= 1 << 8;
1058 if ( buttons & Qt::MidButton )
1059 gin.state |= 1 << 9;
1060 if ( buttons & Qt::RightButton )
1061 gin.state |= 1 << 10;
1062 if ( modifiers & Qt::ShiftModifier )
1063 gin.state |= 1 << 0;
1064 if ( modifiers & Qt::ControlModifier )
1065 gin.state |= 1 << 2;
1066 if ( modifiers & Qt::AltModifier )
1067 gin.state |= 1 << 3;
1068 if ( modifiers & Qt::MetaModifier )
1069 gin.state |= 1 << 3;
1074 void QtPLWidget::locate()
1078 if ( locate_mode == 2 )
1081 if ( gin.keysym < 0xFF && isprint( gin.keysym ) )
1082 std::cout << gin.wX <<
" " << gin.wY <<
" " << (char) gin.keysym << std::endl;
1084 std::cout << gin.wX <<
" " << gin.wY <<
" " << std::hex << gin.keysym << std::endl;
1092 QApplication::restoreOverrideCursor();
1096 void QtPLWidget::mouseEvent( QMouseEvent * event )
1098 lookupButtonEvent( event );
1102 if ( event->button() == Qt::LeftButton )
1109 if ( event->button() == Qt::RightButton )
1111 handler.DeviceChangedPage(
this );
1116 void QtPLWidget::mousePressEvent( QMouseEvent * event )
1118 mouseEvent( event );
1121 void QtPLWidget::mouseReleaseEvent( QMouseEvent * event )
1126 void QtPLWidget::mouseMoveEvent( QMouseEvent * event )
1131 void QtPLWidget::keyPressEvent( QKeyEvent* event )
1135 QPoint p = QCursor::pos();
1137 gin.pY = height() - p.y();
1138 gin.dX = (
PLFLT) p.x() / width();
1139 gin.dY = (
PLFLT) ( height() - p.y() ) / height();
1141 switch ( event->key() )
1143 case Qt::Key_Escape:
1145 QApplication::restoreOverrideCursor();
1149 case Qt::Key_Control:
1159 int x1, y1,
dx = 0,
dy = 0;
1161 switch ( event->key() )
1176 if ( event->modifiers() & Qt::ShiftModifier )
1181 if ( event->modifiers() & Qt::ControlModifier )
1186 if ( event->modifiers() & Qt::AltModifier )
1203 QCursor::setPos( p.x() +
dx, p.y() +
dy );
1214 if ( event->key() == Qt::Key_Enter ||
event->key() == Qt::Key_Return )
1216 handler.DeviceChangedPage(
this );
1218 if ( event->text() ==
"Q" )
1224 else if ( event->text() ==
"L" )
1228 QApplication::setOverrideCursor( Qt::CrossCursor );
1233 void QtPLWidget::closeEvent( QCloseEvent* event )
1235 handler.DeviceClosed(
this );
1239 void QtPLWidget::nextPage()
1245 void QtPLWidget::resizeEvent( QResizeEvent * )
1253 void QtPLWidget::paintEvent( QPaintEvent * )
1255 double x_fact, y_fact, x_offset( 0. ), y_offset( 0. );
1257 getPlotParameters( x_fact, y_fact, x_offset, y_offset );
1259 if ( redrawAll || m_pixPixmap == NULL )
1261 if ( m_pixPixmap != NULL )
1265 m_pixPixmap =
new QPixmap( width(), height() );
1266 QPainter* painter =
new QPainter;
1267 painter->begin( m_pixPixmap );
1270 painter->fillRect( 0, 0, width(), height(), QColor( bgColour.r, bgColour.g, bgColour.b ) );
1273 resetPensAndBrushes( painter );
1275 start_iterator = m_listBuffer.constBegin();
1278 doPlot( painter, x_fact, y_fact, x_offset, y_offset );
1287 QPainter* painter =
new QPainter;
1288 painter->begin( m_pixPixmap );
1290 painter->setPen( SolidPen );
1292 painter->setPen( NoPen );
1295 doPlot( painter, x_fact, y_fact, x_offset, y_offset );
1300 m_painterP->begin(
this );
1302 m_painterP->drawPixmap( 0, 0, *m_pixPixmap );
1307 void QtPLWidget::doPlot( QPainter* p,
double x_fact,
double y_fact,
double x_offset,
double y_offset )
1310 QVector<qreal> vect;
1321 p->setRenderHints( QPainter::Antialiasing, (
bool) lines_aa );
1324 p->setBrush( SolidBrush );
1327 trans = trans.translate( x_offset, y_offset );
1328 trans = trans.scale( x_fact, y_fact );
1330 p->setTransform( trans );
1332 if ( m_listBuffer.empty() )
1334 p->fillRect( 0, 0, 1, 1, QBrush() );
1339 for ( QLinkedList<BufferElement>::const_iterator i = start_iterator; i != m_listBuffer.constEnd(); ++i )
1341 switch ( i->Element )
1344 SolidPen.setColor( QColor( i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A ) );
1347 p->setPen( SolidPen );
1349 SolidBrush.setColor( QColor( i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A ) );
1350 p->setBrush( SolidBrush );
1354 p->setBrush( *( i->Data.LinearGradient ) );
1360 p->setPen( SolidPen );
1363 p->drawLine( *( i->Data.Line ) );
1370 p->setPen( SolidPen );
1373 p->drawPolyline( *( i->Data.Polyline ) );
1377 p->setRenderHints( QPainter::Antialiasing,
false );
1383 p->drawRect( *( i->Data.Rect ) );
1384 p->setRenderHints( QPainter::Antialiasing, (
bool) lines_aa );
1388 p->setRenderHints( QPainter::Antialiasing,
false );
1394 if ( plsc->dev_eofill )
1395 p->drawPolygon( *( i->Data.Polyline ), Qt::OddEvenFill );
1397 p->drawPolygon( *( i->Data.Polyline ), Qt::WindingFill );
1398 p->setRenderHints( QPainter::Antialiasing, (
bool) lines_aa );
1404 p->setPen( SolidPen );
1408 p->resetTransform();
1410 renderText( p, i->Data.TextStruct, x_fact, x_offset, y_fact, y_offset );
1415 SolidPen.setWidthF( i->Data.fltParam );
1418 p->setPen( SolidPen );
1423 SolidBrush.setColor( QColor( i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A ) );
1424 p->fillRect( 0, 0, (
int) m_dWidth, (
int) m_dHeight, SolidBrush );
1430 p->setPen( SolidPen );
1433 if ( i->Data.ArcStruct->rotate != 0.0 )
1436 p->translate( *( i->Data.ArcStruct->dx ) );
1437 p->rotate( -i->Data.ArcStruct->rotate );
1438 p->translate( -*( i->Data.ArcStruct->dx ) );
1441 if ( i->Data.ArcStruct->fill )
1442 p->drawPie( *( i->Data.ArcStruct->rect ), i->Data.ArcStruct->startAngle, i->Data.ArcStruct->spanAngle );
1444 p->drawArc( *( i->Data.ArcStruct->rect ), i->Data.ArcStruct->startAngle, i->Data.ArcStruct->spanAngle );
1446 if ( i->Data.ArcStruct->rotate != 0.0 )
1457 start_iterator = m_listBuffer.constEnd();
1459 redrawFromLastFlush =
false;
1463 void QtPLWidget::getPlotParameters(
double & io_dXFact,
double & io_dYFact,
double & io_dXOffset,
double & io_dYOffset )
1465 double w = (double) width();
1466 double h = (double) height();
1467 if ( w / h > m_dAspectRatio )
1469 io_dYFact = h / m_dHeight;
1470 io_dXFact = h * m_dAspectRatio / m_dWidth;
1472 io_dXOffset = ( w - io_dXFact * m_dWidth ) / 2.;
1476 io_dXFact = w / m_dWidth;
1477 io_dYFact = w / m_dAspectRatio / m_dHeight;
1479 io_dYOffset = ( h - io_dYFact * m_dHeight ) / 2.;
1488 QApplication::setOverrideCursor( Qt::CrossCursor );
1490 while ( gin.pX < 0 && locate_mode )
1491 QCoreApplication::processEvents( QEventLoop::AllEvents, 10 );
1493 QApplication::restoreOverrideCursor();
1499 #if defined ( PLD_extqt )
1500 QtExtWidget::QtExtWidget(
int i_iWidth,
int i_iHeight, QWidget* parent ) :
1501 QtPLWidget( i_iWidth, i_iHeight, parent )
1503 cursorParameters.isTracking =
false;
1504 cursorParameters.cursor_x = -1.0;
1505 cursorParameters.cursor_y = -1.0;
1509 QtExtWidget::~QtExtWidget()
1512 QCoreApplication::processEvents( QEventLoop::AllEvents, 10 );
1519 void QtExtWidget::captureMousePlotCoords(
PLFLT* x,
PLFLT* y )
1521 setMouseTracking(
true );
1522 cursorParameters.isTracking =
true;
1523 cursorParameters.cursor_x =
1524 cursorParameters.cursor_y = -1.;
1527 QCoreApplication::processEvents( QEventLoop::AllEvents, 10 );
1528 }
while ( cursorParameters.isTracking && !killed );
1530 *x = cursorParameters.cursor_x;
1531 *y = cursorParameters.cursor_y;
1534 void QtExtWidget::mouseMoveEvent( QMouseEvent* event )
1536 if ( !cursorParameters.isTracking )
1539 double x_fact, y_fact, x_offset, y_offset;
1541 getPlotParameters( x_fact, y_fact, x_offset, y_offset );
1543 cursorParameters.cursor_x = (
PLFLT) event->x();
1544 cursorParameters.cursor_y = (
PLFLT) event->y();
1548 ratio_x = ( cursorParameters.cursor_x - x_offset ) / ( width() - 2. * x_offset );
1549 ratio_y = ( cursorParameters.cursor_y - y_offset ) / ( height() - 2. * y_offset );
1557 cursorParameters.cursor_x = -1.;
1558 cursorParameters.cursor_y = -1.;
1564 void QtExtWidget::mousePressEvent( QMouseEvent* )
1568 void QtExtWidget::mouseReleaseEvent( QMouseEvent* event )
1570 if ( !cursorParameters.isTracking )
1573 double x_fact, y_fact, x_offset, y_offset;
1575 getPlotParameters( x_fact, y_fact, x_offset, y_offset );
1577 cursorParameters.cursor_x = (
PLFLT) event->x();
1578 cursorParameters.cursor_y = (
PLFLT) event->y();
1579 cursorParameters.isTracking =
false;
1580 setMouseTracking(
false );
1584 ratio_x = ( cursorParameters.cursor_x - x_offset ) / ( width() - 2. * x_offset );
1585 ratio_y = ( cursorParameters.cursor_y - y_offset ) / ( height() - 2. * y_offset );
1593 cursorParameters.cursor_x = -1.;
1594 cursorParameters.cursor_y = -1.;
1598 cursorParameters.cursor_x =
a;
1599 cursorParameters.cursor_y = b;
1605 void QtExtWidget::paintEvent( QPaintEvent* event )
1607 QtPLWidget::paintEvent( event );
1609 if ( !cursorParameters.isTracking || cursorParameters.cursor_x < 0 )
1614 p.setPen( QPen( Qt::white ) );
1616 p.drawLine( (
int) cursorParameters.cursor_x, 0, (
int) cursorParameters.cursor_x, height() );
1617 p.drawLine( 0, (
int) cursorParameters.cursor_y, width(), (
int) cursorParameters.cursor_y );
1622 void plsetqtdev( QtExtWidget* widget )
1624 plsc->dev = (
void *) widget;
1625 widget->setPLStream( plsc );
1628 void plsetqtdev( QtExtWidget* widget,
int argc,
char**
argv )
1631 plsc->dev = (
void *) widget;
1632 widget->setPLStream( plsc );
1637 delete ( (QtExtWidget *) plsc->dev );