Go to the documentation of this file.
24 #include <qpainterpath.h>
30 QRectF clipRect = rect;
31 if ( painter->hasClipping() )
32 clipRect &= painter->clipBoundingRect();
49 int w =
qwtCeil( 1.5 * sz.width() );
53 sz.setWidth( qMax( 8, w ) );
65 i1 = qBound( 0, i1,
size - 1 );
66 i2 = qBound( 0, i2,
size - 1 );
71 return ( i2 - i1 + 1 );
385 const QRectF& canvasRect,
int from,
int to )
const
387 const size_t numSamples =
dataSize();
389 if ( !painter || numSamples <= 0 )
414 xMap, yMap, canvasRect, from, to );
433 const QRectF& canvasRect,
int from,
int to )
const
445 drawLines( painter, xMap, yMap, canvasRect, from, to );
448 drawSticks( painter, xMap, yMap, canvasRect, from, to );
451 drawSteps( painter, xMap, yMap, canvasRect, from, to );
454 drawDots( painter, xMap, yMap, canvasRect, from, to );
461 drawLines(painter, xMap, yMap, canvasRect, from, to);
463 QPen prev_pen = painter->pen();
464 QPen new_pen = prev_pen;
465 new_pen.setWidth(prev_pen.width() * 3);
467 painter->setPen(new_pen);
468 drawDots(painter, xMap, yMap, canvasRect, from, to);
469 painter->setPen(prev_pen);
496 const QRectF& canvasRect,
int from,
int to )
const
503 const bool doFill = (
m_data->
brush.style() != Qt::NoBrush )
512 clipRect = clipRect.adjusted(-pw, -pw, pw, pw);
530 QPolygonF polyline = mapper.
toPolygonF( xMap, yMap,
data(), from, to );
543 if ( painter->pen().style() != Qt::NoPen )
548 QPolygonF filled = polyline;
549 fillCurve( painter, xMap, yMap, canvasRect, filled );
559 fillCurve( painter, xMap, yMap, canvasRect, polyline );
573 const QPainterPath curvePath =
576 painter->drawPath( curvePath );
605 const QRectF& canvasRect,
int from,
int to )
const
607 Q_UNUSED( canvasRect )
610 painter->setRenderHint( QPainter::Antialiasing,
false );
626 for (
int i = from; i <= to; i++ )
637 if ( o == Qt::Horizontal )
660 const QRectF& canvasRect,
int from,
int to )
const
662 const QColor
color = painter->pen().color();
664 if ( painter->pen().style() == Qt::NoPen ||
color.alpha() == 0 )
669 const bool doFill = (
m_data->
brush.style() != Qt::NoBrush )
679 if ( (
color.alpha() == 255 )
680 && !( painter->renderHints() & QPainter::Antialiasing ) )
691 xMap, yMap,
data(), from, to );
694 fillCurve( painter, xMap, yMap, canvasRect, points );
698 const QImage image = mapper.
toImage( xMap, yMap,
700 painter->testRenderHint( QPainter::Antialiasing ),
703 painter->drawImage( canvasRect.toAlignedRect(), image );
709 for (
int i = from; i <= to; i++ )
729 const QPolygon points = mapper.
toPoints(
730 xMap, yMap,
data(), from, to );
736 const QPolygonF points = mapper.
toPointsF(
737 xMap, yMap,
data(), from, to );
761 const QRectF& canvasRect,
int from,
int to )
const
765 QPolygonF polygon( 2 * ( to - from ) + 1 );
766 QPointF* points = polygon.data();
770 inverted = !inverted;
775 for ( i = from,
ip = 0; i <= to; i++,
ip += 2 )
788 const QPointF& p0 = points[
ip - 2];
789 QPointF& p = points[
ip - 1];
803 points[
ip].rx() = xi;
804 points[
ip].ry() = yi;
812 clipRect = clipRect.adjusted(-pw, -pw, pw, pw);
815 clipRect, polygon,
false );
825 fillCurve( painter, xMap, yMap, canvasRect, polygon );
909 const QRectF& canvasRect, QPolygonF& polygon )
const
915 if ( polygon.count() <= 2 )
919 if ( !
brush.color().isValid() )
930 painter->setPen( Qt::NoPen );
931 painter->setBrush(
brush );
949 QPolygonF& polygon )
const
951 if ( polygon.size() < 2 )
964 if ( doAlign && qAbs( refY ) < std::numeric_limits< int >::max() )
965 refY = qRound( refY );
967 polygon += QPointF( polygon.last().x(), refY );
968 polygon += QPointF( polygon.first().x(), refY );
976 if ( doAlign && qAbs( refX ) < std::numeric_limits< int >::max() )
977 refX = qRound( refX );
979 polygon += QPointF( refX, polygon.last().y() );
980 polygon += QPointF( refX, polygon.first().y() );
999 const QRectF& canvasRect,
int from,
int to )
const
1010 const int chunkSize = 500;
1012 for (
int i = from; i <= to; i += chunkSize )
1014 const int n = qMin( chunkSize, to - i + 1 );
1016 const QPolygonF points = mapper.
toPointsF( xMap, yMap,
1017 data(), i, i + n - 1 );
1019 if ( points.size() > 0 )
1076 const size_t numSamples =
dataSize();
1077 if ( numSamples <= 0 )
1086 double dmin = 1.0e10;
1088 for ( uint i = 0; i < numSamples; i++ )
1103 *dist = std::sqrt( dmin );
1126 if ( data ==
nullptr )
1133 inline bool operator()(
const double x,
const QPointF& pos )
const
1135 return (
x < pos.x() );
1139 return qwtUpperSampleIndex< QPointF >( *
data, value,
compareX() );
1145 inline bool operator()(
const double y,
const QPointF& pos )
const
1147 return (
y < pos.y() );
1151 return qwtUpperSampleIndex< QPointF >( *
data, value, compareY() );
1176 if ( br.width() <= 0.0 )
1183 if ( value < br.left() || value > br.right() )
1192 if ( value != last.x() )
1199 const QLineF line(
sample( index - 1 ),
sample( index ) );
1200 v = line.pointAt( ( value - line.p1().x() ) / line.dx() ).y();
1205 if ( value < br.top() || value > br.bottom() )
1214 if ( value != last.y() )
1221 const QLineF line(
sample( index - 1 ),
sample( index ) );
1222 v = line.pointAt( ( value - line.p1().y() ) / line.dy() ).x();
1242 if (
size.isEmpty() )
1249 QPainter painter( &graphic );
1250 painter.setRenderHint( QPainter::Antialiasing,
1258 if (
brush.style() == Qt::NoBrush &&
1272 if (
brush.style() != Qt::NoBrush )
1274 QRectF r( 0, 0,
size.width(),
size.height() );
1275 painter.fillRect( r,
brush );
1281 if (
pen() != Qt::NoPen )
1284 pn.setCapStyle( Qt::FlatCap );
1286 painter.setPen( pn );
1288 const double y = 0.5 *
size.height();
1297 QRectF r( 0, 0,
size.width(),
size.height() );
1347 const double* xData,
const double* yData,
int size )
1367 const float* xData,
const float* yData,
int size )
1426 const double* xData,
const double* yData,
int size )
1443 const float* xData,
const float* yData,
int size )
Interface for iterating over two QVector<T> objects.
double qwtSqr(double x)
Return the square of a number.
LegendAttributes legendAttributes() const
QPointF sample(int index) const
Data class containing a pointer to memory of y coordinates.
void drawSymbols(QPainter *, const QPolygonF &) const
Draw symbols at the specified points.
virtual void legendChanged()
Base class for plot items representing a series of samples.
virtual int closestPoint(const QPointF &pos, double *dist=NULL) const
A paint device for scalable graphics.
static void drawPolyline(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolyline()
Qt::Orientation orientation() const
virtual void drawLines(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
Draw lines.
void setPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
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.
void setRenderHint(RenderHint, bool on=true)
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 setBrush(const QBrush &)
Assign a brush.
void setCurveFitter(QwtCurveFitter *)
void setData(QwtSeriesData< QPointF > *series)
virtual QRect boundingRect() const
virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const QWT_OVERRIDE
static void qwtUpdateLegendIconSize(QwtPlotCurve *curve)
virtual void drawSymbols(QPainter *, const QwtSymbol &, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
@ Legend
The item is represented on the legend.
static bool roundingAlignment()
QwtPlotCurve::CurveStyle style
QwtAxisId xAxis() const
Return xAxis.
virtual void drawSticks(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
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.
static int qwtVerifyRange(int size, int &i1, int &i2)
@ NoSymbol
No Style. The symbol cannot be drawn.
QwtPlot * plot() const
Return attached plot.
void setLegendAttributes(LegendAttributes)
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...
bool testPaintAttribute(PaintAttribute) const
static void drawPoint(QPainter *, const QPoint &)
Wrapper for QPainter::drawPoint()
QwtPlotCurve::CurveAttributes attributes
virtual void fillCurve(QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRectF &canvasRect, QPolygonF &) const
span_constexpr std::size_t size(span< T, Extent > const &spn)
bool testCurveAttribute(CurveAttribute) const
A helper class for translating a series of points.
Data class containing two pointers to memory blocks of T.
QPolygonF toPointsF(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtSeriesData< QPointF > *series, int from, int to) const
Translate a series into a QPolygonF.
const QwtSymbol * symbol() const
QwtCurveFitter * curveFitter
A class representing a text.
virtual QPolygonF fitCurve(const QPolygonF &polygon) const =0
A class for drawing symbols.
virtual int rtti() const QWT_OVERRIDE
QwtPlotCurve::PaintAttributes paintAttributes
Abstract base class for a curve fitter.
void drawSymbol(QPainter *, const QRectF &) const
Draw the symbol into a rectangle.
void setZ(double z)
Set the z value.
static void drawLine(QPainter *, qreal x1, qreal y1, qreal x2, qreal y2)
Wrapper for QPainter::drawLine()
void setPaintAttribute(PaintAttribute, bool on=true)
void setBaseline(double)
Set the value of the baseline.
void setCurveAttribute(CurveAttribute, bool on=true)
void setSymbol(QwtSymbol *)
Assign a symbol.
void setBoundingRect(const QRectF &)
virtual ~QwtPlotCurve()
Destructor.
void setStyle(CurveStyle style)
QWT_EXPORT void clipPolygonF(const QRectF &, QPolygonF &, bool closePolygon=false)
virtual T sample(size_t i) const =0
qreal interpolatedValueAt(Qt::Orientation, double) const
QwtSeriesData< QPointF > * data()
double transform(double s) const
static QRectF qwtIntersectedClipRect(const QRectF &rect, QPainter *painter)
void init()
Initialize internal members.
virtual void itemChanged()
virtual QPainterPath fitCurvePath(const QPolygonF &polygon) const =0
virtual size_t dataSize() const QWT_OVERRIDE
@ WeedOutIntermediatePoints
void setLegendAttribute(LegendAttribute, bool on=true)
@ RoundPoints
Round points to integer values.
QwtPlotCurve(const QString &title=QString())
void setFlag(TransformationFlag, bool on=true)
Interface for iterating over a QVector<T>.
void setItemAttribute(ItemAttribute, bool on=true)
A curve fitter using a spline interpolation.
QwtCurveFitter * curveFitter() const
virtual void drawDots(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
static qreal effectivePenWidth(const QPen &)
QWT_EXPORT QPolygonF clippedPolygonF(const QRectF &, const QPolygonF &, bool closePolygon=false)
void setSamples(const double *xData, const double *yData, int size)
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.
static void drawPoints(QPainter *, const QPolygon &)
Wrapper for QPainter::drawPoints()
static void drawPolygon(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolygon()
virtual QRectF boundingRect() const QWT_OVERRIDE
bool testRenderHint(RenderHint) const
bool isAxisValid(QwtAxisId) const
const QwtTransform * transformation() const
Get the transformation.
bool testLegendAttribute(LegendAttribute) const
QwtArraySeriesData< QPointF > QwtPointSeriesData
Interface for iterating over an array of points.
void setLegendIconSize(const QSize &)
virtual QwtScaleMap canvasMap(QwtAxisId) const
@ RenderAntialiased
Enable antialiasing.
void setDefaultSize(const QSizeF &)
Set a default size.
@ Rtti_PlotCurve
For QwtPlotCurve.
QwtAxisId yAxis() const
Return yAxis.
virtual int adjacentPoint(Qt::Orientation orientation, qreal value) const
A plot item, that represents a series of points.
virtual QwtGraphic legendIcon(int index, const QSizeF &) const QWT_OVERRIDE
virtual void drawSteps(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) 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 QBrush & brush() const
QwtPlotCurve::LegendAttributes legendAttributes
uint renderThreadCount() const
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:45