qwt_plot_curve.cpp
Go to the documentation of this file.
1 /******************************************************************************
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 
100  QwtPlotCurve::CurveAttributes attributes;
101  QwtPlotCurve::PaintAttributes paintAttributes;
102 
103  QwtPlotCurve::LegendAttributes legendAttributes;
104 };
105 
111  : QwtPlotSeriesItem( title )
112 {
113  init();
114 }
115 
121  : QwtPlotSeriesItem( QwtText( title ) )
122 {
123  init();
124 }
125 
128 {
129  delete m_data;
130 }
131 
134 {
137 
138  m_data = new PrivateData;
139  setData( new QwtPointSeriesData() );
140 
141  setZ( 20.0 );
142 }
143 
146 {
148 }
149 
158 {
159  if ( on )
160  m_data->paintAttributes |= attribute;
161  else
162  m_data->paintAttributes &= ~attribute;
163 }
164 
170 {
171  return ( m_data->paintAttributes & attribute );
172 }
173 
182 {
183  if ( on != testLegendAttribute( attribute ) )
184  {
185  if ( on )
186  m_data->legendAttributes |= attribute;
187  else
188  m_data->legendAttributes &= ~attribute;
189 
190  qwtUpdateLegendIconSize( this );
191  legendChanged();
192  }
193 }
194 
200 {
201  return ( m_data->legendAttributes & attribute );
202 }
203 
210 void QwtPlotCurve::setLegendAttributes( LegendAttributes attributes )
211 {
212  if ( attributes != m_data->legendAttributes )
213  {
214  m_data->legendAttributes = attributes;
215 
216  qwtUpdateLegendIconSize( this );
217  legendChanged();
218  }
219 }
220 
225 QwtPlotCurve::LegendAttributes QwtPlotCurve::legendAttributes() const
226 {
227  return m_data->legendAttributes;
228 }
229 
237 {
238  if ( style != m_data->style )
239  {
240  m_data->style = style;
241 
242  legendChanged();
243  itemChanged();
244  }
245 }
246 
252 {
253  return m_data->style;
254 }
255 
267 {
268  if ( symbol != m_data->symbol )
269  {
270  delete m_data->symbol;
271  m_data->symbol = symbol;
272 
273  qwtUpdateLegendIconSize( this );
274 
275  legendChanged();
276  itemChanged();
277  }
278 }
279 
285 {
286  return m_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 != m_data->pen )
316  {
317  m_data->pen = pen;
318 
319  legendChanged();
320  itemChanged();
321  }
322 }
323 
328 const QPen& QwtPlotCurve::pen() const
329 {
330  return m_data->pen;
331 }
332 
348 void QwtPlotCurve::setBrush( const QBrush& brush )
349 {
350  if ( brush != m_data->brush )
351  {
352  m_data->brush = brush;
353 
354  legendChanged();
355  itemChanged();
356  }
357 }
358 
363 const QBrush& QwtPlotCurve::brush() const
364 {
365  return m_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( m_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, m_data->style, xMap, yMap, canvasRect, from, to );
405  painter->restore();
406 
407  if ( m_data->symbol &&
409  {
410  painter->save();
411  drawSymbols( painter, *m_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 
470  case NoCurve:
471  default:
472  break;
473  }
474 }
475 
492 void QwtPlotCurve::drawLines( QPainter* painter,
493  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
494  const QRectF& canvasRect, int from, int to ) const
495 {
496  if ( from > to )
497  return;
498 
499  const bool doFit = ( m_data->attributes & Fitted ) && m_data->curveFitter;
500  const bool doAlign = !doFit && QwtPainter::roundingAlignment( painter );
501  const bool doFill = ( m_data->brush.style() != Qt::NoBrush )
502  && ( m_data->brush.color().alpha() > 0 );
503 
504  QRectF clipRect;
506  {
507  clipRect = qwtIntersectedClipRect( canvasRect, painter );
508 
509  const qreal pw = QwtPainter::effectivePenWidth( painter->pen() );
510  clipRect = clipRect.adjusted(-pw, -pw, pw, pw);
511  }
512 
513  QwtPointMapper mapper;
514 
515  if ( doAlign )
516  {
517  mapper.setFlag( QwtPointMapper::RoundPoints, true );
520  }
521 
525 
526  mapper.setBoundingRect( canvasRect );
527 
528  QPolygonF polyline = mapper.toPolygonF( xMap, yMap, data(), from, to );
529 
530  if ( doFill )
531  {
532  if ( doFit )
533  {
534  // it might be better to extend and draw the curvePath, but for
535  // the moment we keep an implementation, where we translate the
536  // path back to a polyline.
537 
538  polyline = m_data->curveFitter->fitCurve( polyline );
539  }
540 
541  if ( painter->pen().style() != Qt::NoPen )
542  {
543  // here we are wasting memory for the filled copy,
544  // do polygon clipping twice etc .. TODO
545 
546  QPolygonF filled = polyline;
547  fillCurve( painter, xMap, yMap, canvasRect, filled );
548  filled.clear();
549 
551  QwtClipper::clipPolygonF( clipRect, polyline, false );
552 
553  QwtPainter::drawPolyline( painter, polyline );
554  }
555  else
556  {
557  fillCurve( painter, xMap, yMap, canvasRect, polyline );
558  }
559  }
560  else
561  {
563  {
564  QwtClipper::clipPolygonF( clipRect, polyline, false );
565  }
566 
567  if ( doFit )
568  {
570  {
571  const QPainterPath curvePath =
572  m_data->curveFitter->fitCurvePath( polyline );
573 
574  painter->drawPath( curvePath );
575  }
576  else
577  {
578  polyline = m_data->curveFitter->fitCurve( polyline );
579  QwtPainter::drawPolyline( painter, polyline );
580  }
581  }
582  else
583  {
584  QwtPainter::drawPolyline( painter, polyline );
585  }
586  }
587 }
588 
601 void QwtPlotCurve::drawSticks( QPainter* painter,
602  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
603  const QRectF& canvasRect, int from, int to ) const
604 {
605  Q_UNUSED( canvasRect )
606 
607  painter->save();
608  painter->setRenderHint( QPainter::Antialiasing, false );
609 
610  const bool doAlign = QwtPainter::roundingAlignment( painter );
611 
612  double x0 = xMap.transform( m_data->baseline );
613  double y0 = yMap.transform( m_data->baseline );
614  if ( doAlign )
615  {
616  x0 = qRound( x0 );
617  y0 = qRound( y0 );
618  }
619 
620  const Qt::Orientation o = orientation();
621 
622  const QwtSeriesData< QPointF >* series = data();
623 
624  for ( int i = from; i <= to; i++ )
625  {
626  const QPointF sample = series->sample( i );
627  double xi = xMap.transform( sample.x() );
628  double yi = yMap.transform( sample.y() );
629  if ( doAlign )
630  {
631  xi = qRound( xi );
632  yi = qRound( yi );
633  }
634 
635  if ( o == Qt::Horizontal )
636  QwtPainter::drawLine( painter, x0, yi, xi, yi );
637  else
638  QwtPainter::drawLine( painter, xi, y0, xi, yi );
639  }
640 
641  painter->restore();
642 }
643 
656 void QwtPlotCurve::drawDots( QPainter* painter,
657  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
658  const QRectF& canvasRect, int from, int to ) const
659 {
660  const QColor color = painter->pen().color();
661 
662  if ( painter->pen().style() == Qt::NoPen || color.alpha() == 0 )
663  {
664  return;
665  }
666 
667  const bool doFill = ( m_data->brush.style() != Qt::NoBrush )
668  && ( m_data->brush.color().alpha() > 0 );
669  const bool doAlign = QwtPainter::roundingAlignment( painter );
670 
671  QwtPointMapper mapper;
672  mapper.setBoundingRect( canvasRect );
673  mapper.setFlag( QwtPointMapper::RoundPoints, doAlign );
674 
676  {
677  if ( ( color.alpha() == 255 )
678  && !( painter->renderHints() & QPainter::Antialiasing ) )
679  {
680  mapper.setFlag( QwtPointMapper::WeedOutPoints, true );
681  }
682  }
683 
684  if ( doFill )
685  {
686  mapper.setFlag( QwtPointMapper::WeedOutPoints, false );
687 
688  QPolygonF points = mapper.toPointsF(
689  xMap, yMap, data(), from, to );
690 
691  QwtPainter::drawPoints( painter, points );
692  fillCurve( painter, xMap, yMap, canvasRect, points );
693  }
694  else if ( m_data->paintAttributes & ImageBuffer )
695  {
696  const QImage image = mapper.toImage( xMap, yMap,
697  data(), from, to, m_data->pen,
698  painter->testRenderHint( QPainter::Antialiasing ),
699  renderThreadCount() );
700 
701  painter->drawImage( canvasRect.toAlignedRect(), image );
702  }
703  else if ( m_data->paintAttributes & MinimizeMemory )
704  {
705  const QwtSeriesData< QPointF >* series = data();
706 
707  for ( int i = from; i <= to; i++ )
708  {
709  const QPointF sample = series->sample( i );
710 
711  double xi = xMap.transform( sample.x() );
712  double yi = yMap.transform( sample.y() );
713 
714  if ( doAlign )
715  {
716  xi = qRound( xi );
717  yi = qRound( yi );
718  }
719 
720  QwtPainter::drawPoint( painter, QPointF( xi, yi ) );
721  }
722  }
723  else
724  {
725  if ( doAlign )
726  {
727  const QPolygon points = mapper.toPoints(
728  xMap, yMap, data(), from, to );
729 
730  QwtPainter::drawPoints( painter, points );
731  }
732  else
733  {
734  const QPolygonF points = mapper.toPointsF(
735  xMap, yMap, data(), from, to );
736 
737  QwtPainter::drawPoints( painter, points );
738  }
739  }
740 }
741 
757 void QwtPlotCurve::drawSteps( QPainter* painter,
758  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
759  const QRectF& canvasRect, int from, int to ) const
760 {
761  const bool doAlign = QwtPainter::roundingAlignment( painter );
762 
763  QPolygonF polygon( 2 * ( to - from ) + 1 );
764  QPointF* points = polygon.data();
765 
766  bool inverted = orientation() == Qt::Vertical;
767  if ( m_data->attributes & Inverted )
768  inverted = !inverted;
769 
770  const QwtSeriesData< QPointF >* series = data();
771 
772  int i, ip;
773  for ( i = from, ip = 0; i <= to; i++, ip += 2 )
774  {
775  const QPointF sample = series->sample( i );
776  double xi = xMap.transform( sample.x() );
777  double yi = yMap.transform( sample.y() );
778  if ( doAlign )
779  {
780  xi = qRound( xi );
781  yi = qRound( yi );
782  }
783 
784  if ( ip > 0 )
785  {
786  const QPointF& p0 = points[ip - 2];
787  QPointF& p = points[ip - 1];
788 
789  if ( inverted )
790  {
791  p.rx() = p0.x();
792  p.ry() = yi;
793  }
794  else
795  {
796  p.rx() = xi;
797  p.ry() = p0.y();
798  }
799  }
800 
801  points[ip].rx() = xi;
802  points[ip].ry() = yi;
803  }
804 
806  {
807  QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter );
808 
809  const qreal pw = QwtPainter::effectivePenWidth( painter->pen() );
810  clipRect = clipRect.adjusted(-pw, -pw, pw, pw);
811 
812  const QPolygonF clipped = QwtClipper::clippedPolygonF(
813  clipRect, polygon, false );
814 
815  QwtPainter::drawPolyline( painter, clipped );
816  }
817  else
818  {
819  QwtPainter::drawPolyline( painter, polygon );
820  }
821 
822  if ( m_data->brush.style() != Qt::NoBrush )
823  fillCurve( painter, xMap, yMap, canvasRect, polygon );
824 }
825 
826 
836 {
837  if ( bool( m_data->attributes & attribute ) == on )
838  return;
839 
840  if ( on )
841  m_data->attributes |= attribute;
842  else
843  m_data->attributes &= ~attribute;
844 
845  itemChanged();
846 }
847 
853 {
854  return m_data->attributes & attribute;
855 }
856 
875 {
876  delete m_data->curveFitter;
878 
879  itemChanged();
880 }
881 
889 {
890  return m_data->curveFitter;
891 }
892 
905 void QwtPlotCurve::fillCurve( QPainter* painter,
906  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
907  const QRectF& canvasRect, QPolygonF& polygon ) const
908 {
909  if ( m_data->brush.style() == Qt::NoBrush )
910  return;
911 
912  closePolyline( painter, xMap, yMap, polygon );
913  if ( polygon.count() <= 2 ) // a line can't be filled
914  return;
915 
916  QBrush brush = m_data->brush;
917  if ( !brush.color().isValid() )
918  brush.setColor( m_data->pen.color() );
919 
921  {
922  const QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter );
923  QwtClipper::clipPolygonF( clipRect, polygon, true );
924  }
925 
926  painter->save();
927 
928  painter->setPen( Qt::NoPen );
929  painter->setBrush( brush );
930 
931  QwtPainter::drawPolygon( painter, polygon );
932 
933  painter->restore();
934 }
935 
945 void QwtPlotCurve::closePolyline( QPainter* painter,
946  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
947  QPolygonF& polygon ) const
948 {
949  if ( polygon.size() < 2 )
950  return;
951 
952  const bool doAlign = QwtPainter::roundingAlignment( painter );
953 
954  double baseline = m_data->baseline;
955 
956  if ( orientation() == Qt::Vertical )
957  {
958  if ( yMap.transformation() )
959  baseline = yMap.transformation()->bounded( baseline );
960 
961  double refY = yMap.transform( baseline );
962  if ( doAlign )
963  refY = qRound( refY );
964 
965  polygon += QPointF( polygon.last().x(), refY );
966  polygon += QPointF( polygon.first().x(), refY );
967  }
968  else
969  {
970  if ( xMap.transformation() )
971  baseline = xMap.transformation()->bounded( baseline );
972 
973  double refX = xMap.transform( baseline );
974  if ( doAlign )
975  refX = qRound( refX );
976 
977  polygon += QPointF( refX, polygon.last().y() );
978  polygon += QPointF( refX, polygon.first().y() );
979  }
980 }
981 
995 void QwtPlotCurve::drawSymbols( QPainter* painter, const QwtSymbol& symbol,
996  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
997  const QRectF& canvasRect, int from, int to ) const
998 {
999  QwtPointMapper mapper;
1001  QwtPainter::roundingAlignment( painter ) );
1004 
1005  const QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter );
1006  mapper.setBoundingRect( clipRect );
1007 
1008  const int chunkSize = 500;
1009 
1010  for ( int i = from; i <= to; i += chunkSize )
1011  {
1012  const int n = qMin( chunkSize, to - i + 1 );
1013 
1014  const QPolygonF points = mapper.toPointsF( xMap, yMap,
1015  data(), i, i + n - 1 );
1016 
1017  if ( points.size() > 0 )
1018  symbol.drawSymbols( painter, points );
1019  }
1020 }
1021 
1039 {
1040  if ( m_data->baseline != value )
1041  {
1042  m_data->baseline = value;
1043  itemChanged();
1044  }
1045 }
1046 
1052 {
1053  return m_data->baseline;
1054 }
1055 
1067 int QwtPlotCurve::closestPoint( const QPoint& pos, double* dist ) const
1068 {
1069  const size_t numSamples = dataSize();
1070 
1071  if ( plot() == NULL || numSamples <= 0 )
1072  return -1;
1073 
1074  const QwtSeriesData< QPointF >* series = data();
1075 
1076  const QwtScaleMap xMap = plot()->canvasMap( xAxis() );
1077  const QwtScaleMap yMap = plot()->canvasMap( yAxis() );
1078 
1079  int index = -1;
1080  double dmin = 1.0e10;
1081 
1082  for ( uint i = 0; i < numSamples; i++ )
1083  {
1084  const QPointF sample = series->sample( i );
1085 
1086  const double cx = xMap.transform( sample.x() ) - pos.x();
1087  const double cy = yMap.transform( sample.y() ) - pos.y();
1088 
1089  const double f = qwtSqr( cx ) + qwtSqr( cy );
1090  if ( f < dmin )
1091  {
1092  index = i;
1093  dmin = f;
1094  }
1095  }
1096  if ( dist )
1097  *dist = std::sqrt( dmin );
1098 
1099  return index;
1100 }
1101 
1111 QwtGraphic QwtPlotCurve::legendIcon( int index, const QSizeF& size ) const
1112 {
1113  Q_UNUSED( index );
1114 
1115  if ( size.isEmpty() )
1116  return QwtGraphic();
1117 
1118  QwtGraphic graphic;
1119  graphic.setDefaultSize( size );
1121 
1122  QPainter painter( &graphic );
1123  painter.setRenderHint( QPainter::Antialiasing,
1125 
1126  if ( m_data->legendAttributes == 0 ||
1128  {
1129  QBrush brush = m_data->brush;
1130 
1131  if ( brush.style() == Qt::NoBrush &&
1132  m_data->legendAttributes == 0 )
1133  {
1134  if ( style() != QwtPlotCurve::NoCurve )
1135  {
1136  brush = QBrush( pen().color() );
1137  }
1138  else if ( m_data->symbol &&
1139  ( m_data->symbol->style() != QwtSymbol::NoSymbol ) )
1140  {
1141  brush = QBrush( m_data->symbol->pen().color() );
1142  }
1143  }
1144 
1145  if ( brush.style() != Qt::NoBrush )
1146  {
1147  QRectF r( 0, 0, size.width(), size.height() );
1148  painter.fillRect( r, brush );
1149  }
1150  }
1151 
1153  {
1154  if ( pen() != Qt::NoPen )
1155  {
1156  QPen pn = pen();
1157  pn.setCapStyle( Qt::FlatCap );
1158 
1159  painter.setPen( pn );
1160 
1161  const double y = 0.5 * size.height();
1162  QwtPainter::drawLine( &painter, 0.0, y, size.width(), y );
1163  }
1164  }
1165 
1167  {
1168  if ( m_data->symbol )
1169  {
1170  QRectF r( 0, 0, size.width(), size.height() );
1171  m_data->symbol->drawSymbol( &painter, r );
1172  }
1173  }
1174 
1175  return graphic;
1176 }
1177 
1189 {
1190  setData( data );
1191 }
1192 
1201 {
1202  setData( new QwtPointSeriesData( samples ) );
1203 }
1204 
1220  const double* xData, const double* yData, int size )
1221 {
1222  setData( new QwtCPointerData< double >( xData, yData, size ) );
1223 }
1224 
1240  const float* xData, const float* yData, int size )
1241 {
1242  setData( new QwtCPointerData< float >( xData, yData, size ) );
1243 }
1244 
1261 void QwtPlotCurve::setRawSamples( const double* yData, int size )
1262 {
1263  setData( new QwtCPointerValueData< double >( yData, size ) );
1264 }
1265 
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 
1344  const QVector< float >& yData )
1345 {
1346  setData( new QwtPointArrayData< float >( xData, yData ) );
1347 }
1348 
1360 void QwtPlotCurve::setSamples( const double* yData, int size )
1361 {
1362  setData( new QwtValuePointData< double >( yData, size ) );
1363 }
1364 
1376 void QwtPlotCurve::setSamples( const float* yData, int size )
1377 {
1378  setData( new QwtValuePointData< float >( yData, size ) );
1379 }
1380 
1392 {
1393  setData( new QwtValuePointData< double >( yData ) );
1394 }
1395 
1407 {
1408  setData( new QwtValuePointData< float >( yData ) );
1409 }
virtual void legendChanged()
const QPen & pen() const
Mode mode() const
QwtPlotCurve::CurveAttributes attributes
void setRawSamples(const double *xData, const double *yData, int size)
Initialize the data by pointing to memory blocks which are not managed by QwtPlotCurve.
CurveStyle style() const
uint renderThreadCount() const
void setStyle(CurveStyle style)
Enable antialiasing.
A plot item, that represents a series of points.
void setBoundingRect(const QRectF &)
const QwtText & title() const
f
static void drawLine(QPainter *, qreal x1, qreal y1, qreal x2, qreal y2)
Wrapper for QPainter::drawLine()
Definition: qwt_painter.h:154
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:142
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...
QwtPlotCurve::PaintAttributes paintAttributes
Interface for iterating over a QVector<T>.
void setData(QwtSeriesData< QPointF > *series)
QPointF sample(int index) const
virtual void drawDots(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
bool testCurveAttribute(CurveAttribute) const
A curve fitter using a spline interpolation.
virtual int rtti() const QWT_OVERRIDE
Qt::Orientation orientation() const
void setPaintAttribute(PaintAttribute, bool on=true)
QwtSeriesData< QPointF > * data()
double transform(double s) const
A class for drawing symbols.
Definition: qwt_symbol.h:31
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.
QwtCurveFitter * curveFitter
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::LegendAttributes legendAttributes
void setSamples(const double *xData, const double *yData, int size)
void setBaseline(double)
Set the value of the baseline.
void setRenderHint(RenderHint, bool on=true)
static qreal effectivePenWidth(const QPen &)
Definition: qwt_painter.h:201
void setSymbol(QwtSymbol *)
Assign a symbol.
void setDefaultSize(const QSizeF &)
Set a default size.
const QwtTransform * transformation() const
Get the transformation.
The item is represented on the legend.
void setFlag(TransformationFlag, bool on=true)
QwtAxisId xAxis() const
Return xAxis.
void init()
Initialize internal members.
const QwtSymbol * symbol
QwtPlot * plot() const
Return attached plot.
const QBrush & brush() const
double baseline() const
PrivateData * m_data
static void drawPolygon(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolygon()
virtual QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE
void setCurveFitter(QwtCurveFitter *)
virtual int closestPoint(const QPoint &pos, double *dist=NULL) const
Data class containing two pointers to memory blocks of T.
virtual void drawSteps(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
LegendAttributes legendAttributes() const
Style style() const
virtual QPainterPath fitCurvePath(const QPolygonF &polygon) const =0
Round points to integer values.
void setLegendAttributes(LegendAttributes)
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.
A class representing a text.
Definition: qwt_text.h:51
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
void drawSymbols(QPainter *, const QPolygonF &) const
Draw symbols at the specified points.
Definition: qwt_symbol.h:251
virtual QRect boundingRect() const
void setPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
A scale map.
Definition: qwt_scale_map.h:26
virtual void itemChanged()
const QwtSymbol * symbol() const
color
Definition: color.h:23
bool testLegendAttribute(LegendAttribute) const
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 drawPolyline(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolyline()
virtual void drawLines(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
Draw lines.
bool testRenderHint(RenderHint) const
QwtPlotCurve::CurveStyle style
virtual QPolygonF fitCurve(const QPolygonF &polygon) const =0
QWT_EXPORT void clipPolygonF(const QRectF &, QPolygonF &, bool closePolygon=false)
void setBrush(const QBrush &)
Assign a brush.
virtual T sample(size_t i) const =0
static void qwtUpdateLegendIconSize(QwtPlotCurve *curve)
virtual QwtScaleMap canvasMap(QwtAxisId) const
Definition: qwt_plot.cpp:800
const QPen & pen() const
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span.hpp:1485
virtual size_t dataSize() const QWT_OVERRIDE
Definition: core.h:1131
Base class for plot items representing a series of samples.
void drawSymbol(QPainter *, const QRectF &) const
Draw the symbol into a rectangle.
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)
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
virtual void drawSticks(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
virtual void drawSymbols(QPainter *, const QwtSymbol &, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
static QRectF qwtIntersectedClipRect(const QRectF &rect, QPainter *painter)
QwtCurveFitter * curveFitter() const
QWT_EXPORT QPolygonF clippedPolygonF(const QRectF &, const QPolygonF &, bool closePolygon=false)
#define ip
QPolygonF toPointsF(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtSeriesData< QPointF > *series, int from, int to) const
Translate a series into a QPolygonF.
QwtAxisId yAxis() const
Return yAxis.
Interface for iterating over two QVector<T> objects.
static void drawPoint(QPainter *, const QPoint &)
Wrapper for QPainter::drawPoint()
Interface for iterating over an array of points.
Abstract base class for a curve fitter.
int qwtCeil(qreal value)
Definition: qwt_math.h:262
bool testPaintAttribute(PaintAttribute) const
static bool roundingAlignment()
Definition: qwt_painter.h:183
Definition: format.h:895
virtual ~QwtPlotCurve()
Destructor.
virtual void fillCurve(QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRectF &canvasRect, QPolygonF &) const
A helper class for translating a series of points.
virtual double bounded(double value) const
For QwtPlotCurve.
Definition: qwt_plot_item.h:93
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 Mon Jun 19 2023 03:01:38