qwt_plot_curve.cpp
Go to the documentation of this file.
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #include "qwt_plot_curve.h"
11 #include "qwt_point_data.h"
12 #include "qwt_math.h"
13 #include "qwt_clipper.h"
14 #include "qwt_painter.h"
15 #include "qwt_scale_map.h"
16 #include "qwt_plot.h"
18 #include "qwt_symbol.h"
19 #include "qwt_point_mapper.h"
20 #include "qwt_text.h"
21 #include "qwt_graphic.h"
22 
23 #include <qpainter.h>
24 #include <qpainterpath.h>
25 
26 static inline QRectF qwtIntersectedClipRect( const QRectF &rect, QPainter *painter )
27 {
28  QRectF clipRect = rect;
29  if ( painter->hasClipping() )
30  clipRect &= painter->clipBoundingRect();
31 
32  return clipRect;
33 }
34 
36 {
37  if ( curve->symbol() &&
39  {
40  QSize sz = curve->symbol()->boundingRect().size();
41  sz += QSize( 2, 2 ); // margin
42 
44  {
45  // Avoid, that the line is completely covered by the symbol
46 
47  int w = qwtCeil( 1.5 * sz.width() );
48  if ( w % 2 )
49  w++;
50 
51  sz.setWidth( qMax( 8, w ) );
52  }
53 
54  curve->setLegendIconSize( sz );
55  }
56 }
57 
58 static int qwtVerifyRange( int size, int &i1, int &i2 )
59 {
60  if ( size < 1 )
61  return 0;
62 
63  i1 = qBound( 0, i1, size - 1 );
64  i2 = qBound( 0, i2, size - 1 );
65 
66  if ( i1 > i2 )
67  qSwap( i1, i2 );
68 
69  return ( i2 - i1 + 1 );
70 }
71 
73 {
74 public:
77  baseline( 0.0 ),
78  symbol( NULL ),
79  pen( Qt::black ),
81  {
83  }
84 
86  {
87  delete symbol;
88  delete curveFitter;
89  }
90 
92  double baseline;
93 
94  const QwtSymbol *symbol;
96 
97  QPen pen;
98  QBrush brush;
99 
102 
104 };
105 
111  QwtPlotSeriesItem( title )
112 {
113  init();
114 }
115 
121  QwtPlotSeriesItem( QwtText( title ) )
122 {
123  init();
124 }
125 
128 {
129  delete d_data;
130 }
131 
134 {
137 
138  d_data = new PrivateData;
139  setData( new QwtPointSeriesData() );
140 
141  setZ( 20.0 );
142 }
143 
146 {
148 }
149 
158 {
159  if ( on )
160  d_data->paintAttributes |= attribute;
161  else
162  d_data->paintAttributes &= ~attribute;
163 }
164 
170 {
171  return ( d_data->paintAttributes & attribute );
172 }
173 
182 {
183  if ( on != testLegendAttribute( attribute ) )
184  {
185  if ( on )
186  d_data->legendAttributes |= attribute;
187  else
188  d_data->legendAttributes &= ~attribute;
189 
190  qwtUpdateLegendIconSize( this );
191  legendChanged();
192  }
193 }
194 
200 {
201  return ( d_data->legendAttributes & attribute );
202 }
203 
211 {
212  if ( attributes != d_data->legendAttributes )
213  {
214  d_data->legendAttributes = attributes;
215 
216  qwtUpdateLegendIconSize( this );
217  legendChanged();
218  }
219 }
220 
226 {
227  return d_data->legendAttributes;
228 }
229 
237 {
238  if ( style != d_data->style )
239  {
240  d_data->style = style;
241 
242  legendChanged();
243  itemChanged();
244  }
245 }
246 
252 {
253  return d_data->style;
254 }
255 
267 {
268  if ( symbol != d_data->symbol )
269  {
270  delete d_data->symbol;
271  d_data->symbol = symbol;
272 
273  qwtUpdateLegendIconSize( this );
274 
275  legendChanged();
276  itemChanged();
277  }
278 }
279 
285 {
286  return d_data->symbol;
287 }
288 
302 void QwtPlotCurve::setPen( const QColor &color, qreal width, Qt::PenStyle style )
303 {
304  setPen( QPen( color, width, style ) );
305 }
306 
313 void QwtPlotCurve::setPen( const QPen &pen )
314 {
315  if ( pen != d_data->pen )
316  {
317  d_data->pen = pen;
318 
319  legendChanged();
320  itemChanged();
321  }
322 }
323 
328 const QPen& QwtPlotCurve::pen() const
329 {
330  return d_data->pen;
331 }
332 
348 void QwtPlotCurve::setBrush( const QBrush &brush )
349 {
350  if ( brush != d_data->brush )
351  {
352  d_data->brush = brush;
353 
354  legendChanged();
355  itemChanged();
356  }
357 }
358 
363 const QBrush& QwtPlotCurve::brush() const
364 {
365  return d_data->brush;
366 }
367 
381 void QwtPlotCurve::drawSeries( QPainter *painter,
382  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
383  const QRectF &canvasRect, int from, int to ) const
384 {
385  const size_t numSamples = dataSize();
386 
387  if ( !painter || numSamples <= 0 )
388  return;
389 
390  if ( to < 0 )
391  to = numSamples - 1;
392 
393  if ( qwtVerifyRange( numSamples, from, to ) > 0 )
394  {
395  painter->save();
396  painter->setPen( d_data->pen );
397 
398  /*
399  Qt 4.0.0 is slow when drawing lines, but it's even
400  slower when the painter has a brush. So we don't
401  set the brush before we really need it.
402  */
403 
404  drawCurve( painter, d_data->style, xMap, yMap, canvasRect, from, to );
405  painter->restore();
406 
407  if ( d_data->symbol &&
409  {
410  painter->save();
411  drawSymbols( painter, *d_data->symbol,
412  xMap, yMap, canvasRect, from, to );
413  painter->restore();
414  }
415  }
416 }
417 
429 void QwtPlotCurve::drawCurve( QPainter *painter, int style,
430  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
431  const QRectF &canvasRect, int from, int to ) const
432 {
433  switch ( style )
434  {
435  case Lines:
436  if ( testCurveAttribute( Fitted ) )
437  {
438  // we always need the complete
439  // curve for fitting
440  from = 0;
441  to = dataSize() - 1;
442  }
443  drawLines( painter, xMap, yMap, canvasRect, from, to );
444  break;
445  case Sticks:
446  drawSticks( painter, xMap, yMap, canvasRect, from, to );
447  break;
448  case Steps:
449  drawSteps( painter, xMap, yMap, canvasRect, from, to );
450  break;
451  case Dots:
452  drawDots( painter, xMap, yMap, canvasRect, from, to );
453  break;
454  case LinesAndDots: {
455  if (testCurveAttribute(Fitted)) {
456  from = 0;
457  to = dataSize() - 1;
458  }
459  drawLines(painter, xMap, yMap, canvasRect, from, to);
460 
461  QPen prev_pen = painter->pen();
462  QPen new_pen = prev_pen;
463  new_pen.setWidth(prev_pen.width() * 3);
464 
465  painter->setPen(new_pen);
466  drawDots(painter, xMap, yMap, canvasRect, from, to);
467  painter->setPen(prev_pen);
468  } break;
469  case NoCurve:
470  default:
471  break;
472  }
473 }
474 
491 void QwtPlotCurve::drawLines( QPainter *painter,
492  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
493  const QRectF &canvasRect, int from, int to ) const
494 {
495  if ( from > to )
496  return;
497 
498  const bool doFit = ( d_data->attributes & Fitted ) && d_data->curveFitter;
499  const bool doAlign = !doFit && QwtPainter::roundingAlignment( painter );
500  const bool doFill = ( d_data->brush.style() != Qt::NoBrush )
501  && ( d_data->brush.color().alpha() > 0 );
502 
503  QRectF clipRect;
505  {
506  clipRect = qwtIntersectedClipRect( canvasRect, painter );
507 
508  const qreal pw = QwtPainter::effectivePenWidth( painter->pen() );
509  clipRect = clipRect.adjusted(-pw, -pw, pw, pw);
510  }
511 
512  QwtPointMapper mapper;
513 
514  if ( doAlign )
515  {
516  mapper.setFlag( QwtPointMapper::RoundPoints, true );
519  }
520 
524 
525  mapper.setBoundingRect( canvasRect );
526 
527  QPolygonF polyline = mapper.toPolygonF( xMap, yMap, data(), from, to );
528 
529  if ( doFill )
530  {
531  if ( doFit )
532  {
533  // it might be better to extend and draw the curvePath, but for
534  // the moment we keep an implementation, where we translate the
535  // path back to a polyline.
536 
537  polyline = d_data->curveFitter->fitCurve( polyline );
538  }
539 
540  if ( painter->pen().style() != Qt::NoPen )
541  {
542  // here we are wasting memory for the filled copy,
543  // do polygon clipping twice etc .. TODO
544 
545  QPolygonF filled = polyline;
546  fillCurve( painter, xMap, yMap, canvasRect, filled );
547  filled.clear();
548 
550  QwtClipper::clipPolygonF( clipRect, polyline, false );
551 
552  QwtPainter::drawPolyline( painter, polyline );
553  }
554  else
555  {
556  fillCurve( painter, xMap, yMap, canvasRect, polyline );
557  }
558  }
559  else
560  {
562  {
563  QwtClipper::clipPolygonF( clipRect, polyline, false );
564  }
565 
566  if ( doFit )
567  {
569  {
570  const QPainterPath curvePath =
571  d_data->curveFitter->fitCurvePath( polyline );
572 
573  painter->drawPath( curvePath );
574  }
575  else
576  {
577  polyline = d_data->curveFitter->fitCurve( polyline );
578  QwtPainter::drawPolyline( painter, polyline );
579  }
580  }
581  else
582  {
583  QwtPainter::drawPolyline( painter, polyline );
584  }
585  }
586 }
587 
600 void QwtPlotCurve::drawSticks( QPainter *painter,
601  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
602  const QRectF &canvasRect, int from, int to ) const
603 {
604  Q_UNUSED( canvasRect )
605 
606  painter->save();
607  painter->setRenderHint( QPainter::Antialiasing, false );
608 
609  const bool doAlign = QwtPainter::roundingAlignment( painter );
610 
611  double x0 = xMap.transform( d_data->baseline );
612  double y0 = yMap.transform( d_data->baseline );
613  if ( doAlign )
614  {
615  x0 = qRound( x0 );
616  y0 = qRound( y0 );
617  }
618 
619  const Qt::Orientation o = orientation();
620 
621  const QwtSeriesData<QPointF> *series = data();
622 
623  for ( int i = from; i <= to; i++ )
624  {
625  const QPointF sample = series->sample( i );
626  double xi = xMap.transform( sample.x() );
627  double yi = yMap.transform( sample.y() );
628  if ( doAlign )
629  {
630  xi = qRound( xi );
631  yi = qRound( yi );
632  }
633 
634  if ( o == Qt::Horizontal )
635  QwtPainter::drawLine( painter, x0, yi, xi, yi );
636  else
637  QwtPainter::drawLine( painter, xi, y0, xi, yi );
638  }
639 
640  painter->restore();
641 }
642 
655 void QwtPlotCurve::drawDots( QPainter *painter,
656  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
657  const QRectF &canvasRect, int from, int to ) const
658 {
659  const QColor color = painter->pen().color();
660 
661  if ( painter->pen().style() == Qt::NoPen || color.alpha() == 0 )
662  {
663  return;
664  }
665 
666  const bool doFill = ( d_data->brush.style() != Qt::NoBrush )
667  && ( d_data->brush.color().alpha() > 0 );
668  const bool doAlign = QwtPainter::roundingAlignment( painter );
669 
670  QwtPointMapper mapper;
671  mapper.setBoundingRect( canvasRect );
672  mapper.setFlag( QwtPointMapper::RoundPoints, doAlign );
673 
675  {
676  if ( ( color.alpha() == 255 )
677  && !( painter->renderHints() & QPainter::Antialiasing ) )
678  {
679  mapper.setFlag( QwtPointMapper::WeedOutPoints, true );
680  }
681  }
682 
683  if ( doFill )
684  {
685  mapper.setFlag( QwtPointMapper::WeedOutPoints, false );
686 
687  QPolygonF points = mapper.toPointsF(
688  xMap, yMap, data(), from, to );
689 
690  QwtPainter::drawPoints( painter, points );
691  fillCurve( painter, xMap, yMap, canvasRect, points );
692  }
693  else if ( d_data->paintAttributes & ImageBuffer )
694  {
695  const QImage image = mapper.toImage( xMap, yMap,
696  data(), from, to, d_data->pen,
697  painter->testRenderHint( QPainter::Antialiasing ),
698  renderThreadCount() );
699 
700  painter->drawImage( canvasRect.toAlignedRect(), image );
701  }
702  else if ( d_data->paintAttributes & MinimizeMemory )
703  {
704  const QwtSeriesData<QPointF> *series = data();
705 
706  for ( int i = from; i <= to; i++ )
707  {
708  const QPointF sample = series->sample( i );
709 
710  double xi = xMap.transform( sample.x() );
711  double yi = yMap.transform( sample.y() );
712 
713  if ( doAlign )
714  {
715  xi = qRound( xi );
716  yi = qRound( yi );
717  }
718 
719  QwtPainter::drawPoint( painter, QPointF( xi, yi ) );
720  }
721  }
722  else
723  {
724  if ( doAlign )
725  {
726  const QPolygon points = mapper.toPoints(
727  xMap, yMap, data(), from, to );
728 
729  QwtPainter::drawPoints( painter, points );
730  }
731  else
732  {
733  const QPolygonF points = mapper.toPointsF(
734  xMap, yMap, data(), from, to );
735 
736  QwtPainter::drawPoints( painter, points );
737  }
738  }
739 }
740 
756 void QwtPlotCurve::drawSteps( QPainter *painter,
757  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
758  const QRectF &canvasRect, int from, int to ) const
759 {
760  const bool doAlign = QwtPainter::roundingAlignment( painter );
761 
762  QPolygonF polygon( 2 * ( to - from ) + 1 );
763  QPointF *points = polygon.data();
764 
765  bool inverted = orientation() == Qt::Vertical;
766  if ( d_data->attributes & Inverted )
767  inverted = !inverted;
768 
769  const QwtSeriesData<QPointF> *series = data();
770 
771  int i, ip;
772  for ( i = from, ip = 0; i <= to; i++, ip += 2 )
773  {
774  const QPointF sample = series->sample( i );
775  double xi = xMap.transform( sample.x() );
776  double yi = yMap.transform( sample.y() );
777  if ( doAlign )
778  {
779  xi = qRound( xi );
780  yi = qRound( yi );
781  }
782 
783  if ( ip > 0 )
784  {
785  const QPointF &p0 = points[ip - 2];
786  QPointF &p = points[ip - 1];
787 
788  if ( inverted )
789  {
790  p.rx() = p0.x();
791  p.ry() = yi;
792  }
793  else
794  {
795  p.rx() = xi;
796  p.ry() = p0.y();
797  }
798  }
799 
800  points[ip].rx() = xi;
801  points[ip].ry() = yi;
802  }
803 
805  {
806  QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter );
807 
808  const qreal pw = QwtPainter::effectivePenWidth( painter->pen() );
809  clipRect = clipRect.adjusted(-pw, -pw, pw, pw);
810 
811  const QPolygonF clipped = QwtClipper::clippedPolygonF(
812  clipRect, polygon, false );
813 
814  QwtPainter::drawPolyline( painter, clipped );
815  }
816  else
817  {
818  QwtPainter::drawPolyline( painter, polygon );
819  }
820 
821  if ( d_data->brush.style() != Qt::NoBrush )
822  fillCurve( painter, xMap, yMap, canvasRect, polygon );
823 }
824 
825 
835 {
836  if ( bool( d_data->attributes & attribute ) == on )
837  return;
838 
839  if ( on )
840  d_data->attributes |= attribute;
841  else
842  d_data->attributes &= ~attribute;
843 
844  itemChanged();
845 }
846 
852 {
853  return d_data->attributes & attribute;
854 }
855 
874 {
875  delete d_data->curveFitter;
877 
878  itemChanged();
879 }
880 
888 {
889  return d_data->curveFitter;
890 }
891 
904 void QwtPlotCurve::fillCurve( QPainter *painter,
905  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
906  const QRectF &canvasRect, QPolygonF &polygon ) const
907 {
908  if ( d_data->brush.style() == Qt::NoBrush )
909  return;
910 
911  closePolyline( painter, xMap, yMap, polygon );
912  if ( polygon.count() <= 2 ) // a line can't be filled
913  return;
914 
915  QBrush brush = d_data->brush;
916  if ( !brush.color().isValid() )
917  brush.setColor( d_data->pen.color() );
918 
920  {
921  const QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter );
922  QwtClipper::clipPolygonF( clipRect, polygon, true );
923  }
924 
925  painter->save();
926 
927  painter->setPen( Qt::NoPen );
928  painter->setBrush( brush );
929 
930  QwtPainter::drawPolygon( painter, polygon );
931 
932  painter->restore();
933 }
934 
944 void QwtPlotCurve::closePolyline( QPainter *painter,
945  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
946  QPolygonF &polygon ) const
947 {
948  if ( polygon.size() < 2 )
949  return;
950 
951  const bool doAlign = QwtPainter::roundingAlignment( painter );
952 
953  double baseline = d_data->baseline;
954 
955  if ( orientation() == Qt::Vertical )
956  {
957  if ( yMap.transformation() )
958  baseline = yMap.transformation()->bounded( baseline );
959 
960  double refY = yMap.transform( baseline );
961  if ( doAlign )
962  refY = qRound( refY );
963 
964  polygon += QPointF( polygon.last().x(), refY );
965  polygon += QPointF( polygon.first().x(), refY );
966  }
967  else
968  {
969  if ( xMap.transformation() )
970  baseline = xMap.transformation()->bounded( baseline );
971 
972  double refX = xMap.transform( baseline );
973  if ( doAlign )
974  refX = qRound( refX );
975 
976  polygon += QPointF( refX, polygon.last().y() );
977  polygon += QPointF( refX, polygon.first().y() );
978  }
979 }
980 
994 void QwtPlotCurve::drawSymbols( QPainter *painter, const QwtSymbol &symbol,
995  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
996  const QRectF &canvasRect, int from, int to ) const
997 {
998  QwtPointMapper mapper;
1000  QwtPainter::roundingAlignment( painter ) );
1003 
1004  const QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter );
1005  mapper.setBoundingRect( clipRect );
1006 
1007  const int chunkSize = 500;
1008 
1009  for ( int i = from; i <= to; i += chunkSize )
1010  {
1011  const int n = qMin( chunkSize, to - i + 1 );
1012 
1013  const QPolygonF points = mapper.toPointsF( xMap, yMap,
1014  data(), i, i + n - 1 );
1015 
1016  if ( points.size() > 0 )
1017  symbol.drawSymbols( painter, points );
1018  }
1019 }
1020 
1038 {
1039  if ( d_data->baseline != value )
1040  {
1041  d_data->baseline = value;
1042  itemChanged();
1043  }
1044 }
1045 
1051 {
1052  return d_data->baseline;
1053 }
1054 
1066 int QwtPlotCurve::closestPoint( const QPoint &pos, double *dist ) const
1067 {
1068  const size_t numSamples = dataSize();
1069 
1070  if ( plot() == NULL || numSamples <= 0 )
1071  return -1;
1072 
1073  const QwtSeriesData<QPointF> *series = data();
1074 
1075  const QwtScaleMap xMap = plot()->canvasMap( xAxis() );
1076  const QwtScaleMap yMap = plot()->canvasMap( yAxis() );
1077 
1078  int index = -1;
1079  double dmin = 1.0e10;
1080 
1081  for ( uint i = 0; i < numSamples; i++ )
1082  {
1083  const QPointF sample = series->sample( i );
1084 
1085  const double cx = xMap.transform( sample.x() ) - pos.x();
1086  const double cy = yMap.transform( sample.y() ) - pos.y();
1087 
1088  const double f = qwtSqr( cx ) + qwtSqr( cy );
1089  if ( f < dmin )
1090  {
1091  index = i;
1092  dmin = f;
1093  }
1094  }
1095  if ( dist )
1096  *dist = std::sqrt( dmin );
1097 
1098  return index;
1099 }
1100 
1110 QwtGraphic QwtPlotCurve::legendIcon( int index, const QSizeF &size ) const
1111 {
1112  Q_UNUSED( index );
1113 
1114  if ( size.isEmpty() )
1115  return QwtGraphic();
1116 
1117  QwtGraphic graphic;
1118  graphic.setDefaultSize( size );
1120 
1121  QPainter painter( &graphic );
1122  painter.setRenderHint( QPainter::Antialiasing,
1124 
1125  if ( d_data->legendAttributes == 0 ||
1127  {
1128  QBrush brush = d_data->brush;
1129 
1130  if ( brush.style() == Qt::NoBrush &&
1131  d_data->legendAttributes == 0 )
1132  {
1133  if ( style() != QwtPlotCurve::NoCurve )
1134  {
1135  brush = QBrush( pen().color() );
1136  }
1137  else if ( d_data->symbol &&
1138  ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
1139  {
1140  brush = QBrush( d_data->symbol->pen().color() );
1141  }
1142  }
1143 
1144  if ( brush.style() != Qt::NoBrush )
1145  {
1146  QRectF r( 0, 0, size.width(), size.height() );
1147  painter.fillRect( r, brush );
1148  }
1149  }
1150 
1152  {
1153  if ( pen() != Qt::NoPen )
1154  {
1155  QPen pn = pen();
1156  pn.setCapStyle( Qt::FlatCap );
1157 
1158  painter.setPen( pn );
1159 
1160  const double y = 0.5 * size.height();
1161  QwtPainter::drawLine( &painter, 0.0, y, size.width(), y );
1162  }
1163  }
1164 
1166  {
1167  if ( d_data->symbol )
1168  {
1169  QRectF r( 0, 0, size.width(), size.height() );
1170  d_data->symbol->drawSymbol( &painter, r );
1171  }
1172  }
1173 
1174  return graphic;
1175 }
1176 
1188 {
1189  setData( data );
1190 }
1191 
1200 {
1201  setData( new QwtPointSeriesData( samples ) );
1202 }
1203 
1219  const double *xData, const double *yData, int size )
1220 {
1221  setData( new QwtCPointerData<double>( xData, yData, size ) );
1222 }
1223 
1239  const float *xData, const float *yData, int size )
1240 {
1241  setData( new QwtCPointerData<float>( xData, yData, size ) );
1242 }
1243 
1260 void QwtPlotCurve::setRawSamples( const double *yData, int size )
1261 {
1262  setData( new QwtCPointerValueData<double>( yData, size ) );
1263 }
1264 
1282 void QwtPlotCurve::setRawSamples( const float *yData, int size )
1283 {
1284  setData( new QwtCPointerValueData<float>( yData, size ) );
1285 }
1286 
1299  const double *xData, const double *yData, int size )
1300 {
1301  setData( new QwtPointArrayData<double>( xData, yData, size ) );
1302 }
1303 
1316  const float *xData, const float *yData, int size )
1317 {
1318  setData( new QwtPointArrayData<float>( xData, yData, size ) );
1319 }
1320 
1330  const QVector<double> &yData )
1331 {
1332  setData( new QwtPointArrayData<double>( xData, yData ) );
1333 }
1334 
1345 void QwtPlotCurve::setSamples( const double *yData, int size )
1346 {
1347  setData( new QwtValuePointData<double>( yData, size ) );
1348 }
1349 
1360 void QwtPlotCurve::setSamples( const float *yData, int size )
1361 {
1362  setData( new QwtValuePointData<float>( yData, size ) );
1363 }
1364 
1376 {
1377  setData( new QwtValuePointData<double>( yData ) );
1378 }
1379 
1391 {
1392  setData( new QwtValuePointData<float>( yData ) );
1393 }
virtual void legendChanged()
Qt::Orientation orientation() const
virtual QRect boundingRect() const
Style style() const
QwtPlotCurve::CurveAttributes attributes
enum MQTTPropertyCodes value
void setRawSamples(const double *xData, const double *yData, int size)
Initialize the data by pointing to memory blocks which are not managed by QwtPlotCurve.
void setStyle(CurveStyle style)
Enable antialiasing.
QPolygonF toPointsF(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtSeriesData< QPointF > *series, int from, int to) const
Translate a series into a QPolygonF.
A plot item, that represents a series of points.
void setBoundingRect(const QRectF &)
static void drawLine(QPainter *, qreal x1, qreal y1, qreal x2, qreal y2)
Wrapper for QPainter::drawLine()
Definition: qwt_painter.h:152
QwtPlotCurve(const QString &title=QString())
static int qwtVerifyRange(int size, int &i1, int &i2)
static void drawPoints(QPainter *, const QPolygon &)
Wrapper for QPainter::drawPoints()
Definition: qwt_painter.h:140
PrivateData * d_data
virtual void drawLines(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
Draw lines.
const QBrush & brush() const
int xAxis() const
Return xAxis.
QwtPlotCurve::PaintAttributes paintAttributes
Interface for iterating over a QVector<T>.
void setData(QwtSeriesData< QPointF > *series)
LegendAttributes legendAttributes() const
double baseline() const
virtual void fillCurve(QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRectF &canvasRect, QPolygonF &) const
QFlags< CurveAttribute > CurveAttributes
Curve attributes.
A curve fitter using a spline interpolation.
virtual int rtti() const QWT_OVERRIDE
void setPaintAttribute(PaintAttribute, bool on=true)
QwtSeriesData< QPointF > * data()
A class for drawing symbols.
Definition: qwt_symbol.h:31
QwtPlot * plot() const
Return attached plot.
virtual void drawDots(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
QwtCurveFitter * curveFitter
static QPolygonF clippedPolygonF(const QRectF &, const QPolygonF &, bool closePolygon=false)
QwtPlotCurve::LegendAttributes legendAttributes
void setSamples(const double *xData, const double *yData, int size)
void setBaseline(double)
Set the value of the baseline.
void closePolyline(QPainter *, const QwtScaleMap &, const QwtScaleMap &, QPolygonF &) const
Complete a polygon to be a closed polygon including the area between the original polygon and the bas...
void setRenderHint(RenderHint, bool on=true)
static qreal effectivePenWidth(const QPen &)
Definition: qwt_painter.h:199
void setSymbol(QwtSymbol *)
Assign a symbol.
virtual double bounded(double value) const
void setDefaultSize(const QSizeF &)
Set a default size.
The item is represented on the legend.
void setFlag(TransformationFlag, bool on=true)
void init()
Initialize internal members.
virtual int closestPoint(const QPoint &pos, double *dist=NULL) const
const QwtSymbol * symbol
QPolygon toPoints(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtSeriesData< QPointF > *series, int from, int to) const
Translate a series of points into a QPolygon.
const QwtSymbol * symbol() const
static void drawPolygon(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolygon()
virtual QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE
virtual void drawSymbols(QPainter *, const QwtSymbol &, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
void setCurveFitter(QwtCurveFitter *)
bool testRenderHint(RenderHint) const
Data class containing two pointers to memory blocks of T.
static void clipPolygonF(const QRectF &, QPolygonF &, bool closePolygon=false)
virtual QPainterPath fitCurvePath(const QPolygonF &polygon) const =0
const QPen & pen() const
Round points to integer values.
void setLegendAttributes(LegendAttributes)
A class representing a text.
Definition: qwt_text.h:51
virtual QwtScaleMap canvasMap(int axisId) const
Definition: qwt_plot.cpp:786
void setZ(double z)
Set the z value.
Data class containing a pointer to memory of y coordinates.
A paint device for scalable graphics.
Definition: qwt_graphic.h:75
int yAxis() const
Return yAxis.
void drawSymbols(QPainter *, const QPolygonF &) const
Draw symbols at the specified points.
Definition: qwt_symbol.h:251
void setPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
const QwtTransform * transformation() const
Get the transformation.
A scale map.
Definition: qwt_scale_map.h:26
QPointF sample(int index) const
virtual void itemChanged()
CurveStyle style() const
uint renderThreadCount() const
virtual void drawSticks(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
static void drawPolyline(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolyline()
QPolygonF toPolygonF(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtSeriesData< QPointF > *series, int from, int to) const
Translate a series of points into a QPolygonF.
QwtPlotCurve::CurveStyle style
QFlags< LegendAttribute > LegendAttributes
Legend attributes.
QFlags< PaintAttribute > PaintAttributes
Paint attributes.
bool testLegendAttribute(LegendAttribute) const
virtual QPolygonF fitCurve(const QPolygonF &polygon) const =0
Mode mode() const
bool testCurveAttribute(CurveAttribute) const
void setBrush(const QBrush &)
Assign a brush.
virtual T sample(size_t i) const =0
virtual void drawCurve(QPainter *, int style, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
Draw the line part (without symbols) of a curve interval.
static void qwtUpdateLegendIconSize(QwtPlotCurve *curve)
virtual size_t dataSize() const QWT_OVERRIDE
Base class for plot items representing a series of samples.
virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const QWT_OVERRIDE
void setLegendAttribute(LegendAttribute, bool on=true)
QImage toImage(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtSeriesData< QPointF > *series, int from, int to, const QPen &, bool antialiased, uint numThreads) const
Translate a series into a QImage.
void setItemAttribute(ItemAttribute, bool on=true)
void setLegendIconSize(const QSize &)
double qwtSqr(double x)
Return the square of a number.
Definition: qwt_math.h:191
double transform(double s) const
static QRectF qwtIntersectedClipRect(const QRectF &rect, QPainter *painter)
QwtCurveFitter * curveFitter() const
Interface for iterating over two QVector<T> objects.
void drawSymbol(QPainter *, const QRectF &) const
Draw the symbol into a rectangle.
static void drawPoint(QPainter *, const QPoint &)
Wrapper for QPainter::drawPoint()
Interface for iterating over an array of points.
virtual void drawSteps(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
Abstract base class for a curve fitter.
bool testPaintAttribute(PaintAttribute) const
int qwtCeil(qreal value)
Definition: qwt_math.h:262
const QPen & pen() const
static bool roundingAlignment()
Definition: qwt_painter.h:181
virtual ~QwtPlotCurve()
Destructor.
A helper class for translating a series of points.
const QwtText & title() const
For QwtPlotCurve.
Definition: qwt_plot_item.h:92
No Style. The symbol cannot be drawn.
Definition: qwt_symbol.h:41
void setCurveAttribute(CurveAttribute, bool on=true)


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:10