24 #include <qpainterpath.h> 28 QRectF clipRect = rect;
29 if ( painter->hasClipping() )
30 clipRect &= painter->clipBoundingRect();
47 int w =
qwtCeil( 1.5 * sz.width() );
51 sz.setWidth( qMax( 8, w ) );
63 i1 = qBound( 0, i1, size - 1 );
64 i2 = qBound( 0, i2, size - 1 );
69 return ( i2 - i1 + 1 );
304 setPen( QPen( color, width, style ) );
383 const QRectF &canvasRect,
int from,
int to )
const 385 const size_t numSamples =
dataSize();
387 if ( !painter || numSamples <= 0 )
412 xMap, yMap, canvasRect, from, to );
431 const QRectF &canvasRect,
int from,
int to )
const 443 drawLines( painter, xMap, yMap, canvasRect, from, to );
446 drawSticks( painter, xMap, yMap, canvasRect, from, to );
449 drawSteps( painter, xMap, yMap, canvasRect, from, to );
452 drawDots( painter, xMap, yMap, canvasRect, from, to );
459 drawLines(painter, xMap, yMap, canvasRect, from, to);
461 QPen prev_pen = painter->pen();
462 QPen new_pen = prev_pen;
463 new_pen.setWidth(prev_pen.width() * 3);
465 painter->setPen(new_pen);
466 drawDots(painter, xMap, yMap, canvasRect, from, to);
467 painter->setPen(prev_pen);
493 const QRectF &canvasRect,
int from,
int to )
const 500 const bool doFill = (
d_data->
brush.style() != Qt::NoBrush )
509 clipRect = clipRect.adjusted(-pw, -pw, pw, pw);
527 QPolygonF polyline = mapper.
toPolygonF( xMap, yMap,
data(), from, to );
540 if ( painter->pen().style() != Qt::NoPen )
545 QPolygonF filled = polyline;
546 fillCurve( painter, xMap, yMap, canvasRect, filled );
556 fillCurve( painter, xMap, yMap, canvasRect, polyline );
570 const QPainterPath curvePath =
573 painter->drawPath( curvePath );
602 const QRectF &canvasRect,
int from,
int to )
const 604 Q_UNUSED( canvasRect )
607 painter->setRenderHint( QPainter::Antialiasing,
false );
623 for (
int i = from; i <= to; i++ )
626 double xi = xMap.
transform( sample.x() );
627 double yi = yMap.
transform( sample.y() );
634 if ( o == Qt::Horizontal )
657 const QRectF &canvasRect,
int from,
int to )
const 659 const QColor color = painter->pen().color();
661 if ( painter->pen().style() == Qt::NoPen || color.alpha() == 0 )
666 const bool doFill = (
d_data->
brush.style() != Qt::NoBrush )
676 if ( ( color.alpha() == 255 )
677 && !( painter->renderHints() & QPainter::Antialiasing ) )
688 xMap, yMap,
data(), from, to );
691 fillCurve( painter, xMap, yMap, canvasRect, points );
695 const QImage image = mapper.
toImage( xMap, yMap,
697 painter->testRenderHint( QPainter::Antialiasing ),
700 painter->drawImage( canvasRect.toAlignedRect(), image );
706 for (
int i = from; i <= to; i++ )
710 double xi = xMap.
transform( sample.x() );
711 double yi = yMap.
transform( sample.y() );
726 const QPolygon points = mapper.
toPoints(
727 xMap, yMap,
data(), from, to );
733 const QPolygonF points = mapper.
toPointsF(
734 xMap, yMap,
data(), from, to );
758 const QRectF &canvasRect,
int from,
int to )
const 762 QPolygonF polygon( 2 * ( to - from ) + 1 );
763 QPointF *points = polygon.data();
767 inverted = !inverted;
772 for ( i = from, ip = 0; i <= to; i++, ip += 2 )
775 double xi = xMap.
transform( sample.x() );
776 double yi = yMap.
transform( sample.y() );
785 const QPointF &p0 = points[ip - 2];
786 QPointF &p = points[ip - 1];
800 points[ip].rx() = xi;
801 points[ip].ry() = yi;
809 clipRect = clipRect.adjusted(-pw, -pw, pw, pw);
812 clipRect, polygon,
false );
822 fillCurve( painter, xMap, yMap, canvasRect, polygon );
906 const QRectF &canvasRect, QPolygonF &polygon )
const 912 if ( polygon.count() <= 2 )
916 if ( !brush.color().isValid() )
927 painter->setPen( Qt::NoPen );
928 painter->setBrush( brush );
946 QPolygonF &polygon )
const 948 if ( polygon.size() < 2 )
960 double refY = yMap.
transform( baseline );
962 refY = qRound( refY );
964 polygon += QPointF( polygon.last().x(), refY );
965 polygon += QPointF( polygon.first().x(), refY );
972 double refX = xMap.
transform( baseline );
974 refX = qRound( refX );
976 polygon += QPointF( refX, polygon.last().y() );
977 polygon += QPointF( refX, polygon.first().y() );
996 const QRectF &canvasRect,
int from,
int to )
const 1007 const int chunkSize = 500;
1009 for (
int i = from; i <= to; i += chunkSize )
1011 const int n = qMin( chunkSize, to - i + 1 );
1013 const QPolygonF points = mapper.
toPointsF( xMap, yMap,
1014 data(), i, i + n - 1 );
1016 if ( points.size() > 0 )
1068 const size_t numSamples =
dataSize();
1070 if (
plot() == NULL || numSamples <= 0 )
1079 double dmin = 1.0e10;
1081 for ( uint i = 0; i < numSamples; i++ )
1085 const double cx = xMap.
transform( sample.x() ) - pos.x();
1086 const double cy = yMap.
transform( sample.y() ) - pos.y();
1096 *dist = std::sqrt( dmin );
1114 if ( size.isEmpty() )
1121 QPainter painter( &graphic );
1122 painter.setRenderHint( QPainter::Antialiasing,
1130 if ( brush.style() == Qt::NoBrush &&
1135 brush = QBrush(
pen().color() );
1144 if ( brush.style() != Qt::NoBrush )
1146 QRectF r( 0, 0, size.width(), size.height() );
1147 painter.fillRect( r, brush );
1153 if (
pen() != Qt::NoPen )
1156 pn.setCapStyle( Qt::FlatCap );
1158 painter.setPen( pn );
1160 const double y = 0.5 * size.height();
1169 QRectF r( 0, 0, size.width(), size.height() );
1219 const double *xData,
const double *yData,
int size )
1239 const float *xData,
const float *yData,
int size )
1299 const double *xData,
const double *yData,
int size )
1316 const float *xData,
const float *yData,
int size )
virtual void legendChanged()
Qt::Orientation orientation() const
virtual QRect boundingRect() 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)
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()
QwtPlotCurve(const QString &title=QString())
static int qwtVerifyRange(int size, int &i1, int &i2)
static void drawPoints(QPainter *, const QPolygon &)
Wrapper for QPainter::drawPoints()
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
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.
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 &)
void setSymbol(QwtSymbol *)
Assign a symbol.
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
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
Round points to integer values.
void setLegendAttributes(LegendAttributes)
A class representing a text.
virtual QwtScaleMap canvasMap(int axisId) const
void setZ(double z)
Set the z value.
Data class containing a pointer to memory of y coordinates.
A paint device for scalable graphics.
int yAxis() const
Return yAxis.
void drawSymbols(QPainter *, const QPolygonF &) const
Draw symbols at the specified points.
void setPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
const QwtTransform * transformation() const
Get the transformation.
QPointF sample(int index) const
virtual void itemChanged()
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
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.
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
static bool roundingAlignment()
virtual ~QwtPlotCurve()
Destructor.
A helper class for translating a series of points.
const QwtText & title() const
No Style. The symbol cannot be drawn.
void setCurveAttribute(CurveAttribute, bool on=true)