Loading...
Searching...
No Matches
qwt_plot_curve.cpp
/******************************************************************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#include "qwt_plot_curve.h"
#include "qwt_point_data.h"
#include "qwt_math.h"
#include "qwt_clipper.h"
#include "qwt_painter.h"
#include "qwt_scale_map.h"
#include "qwt_plot.h"
#include "qwt_spline_curve_fitter.h"
#include "qwt_symbol.h"
#include "qwt_point_mapper.h"
#include "qwt_text.h"
#include "qwt_graphic.h"
#include <qpainter.h>
#include <qpainterpath.h>
#include <qnumeric.h>
#include <climits>
static inline QRectF qwtIntersectedClipRect( const QRectF& rect, QPainter* painter )
{
QRectF clipRect = rect;
if ( painter->hasClipping() )
clipRect &= painter->clipBoundingRect();
return clipRect;
}
static void qwtUpdateLegendIconSize( QwtPlotCurve* curve )
{
if ( curve->symbol() &&
curve->testLegendAttribute( QwtPlotCurve::LegendShowSymbol ) )
{
QSize sz = curve->symbol()->boundingRect().size();
sz += QSize( 2, 2 ); // margin
if ( curve->testLegendAttribute( QwtPlotCurve::LegendShowLine ) )
{
// Avoid, that the line is completely covered by the symbol
int w = qwtCeil( 1.5 * sz.width() );
if ( w % 2 )
w++;
sz.setWidth( qMax( 8, w ) );
}
curve->setLegendIconSize( sz );
}
}
static int qwtVerifyRange( int size, int& i1, int& i2 )
{
if ( size < 1 )
return 0;
i1 = qBound( 0, i1, size - 1 );
i2 = qBound( 0, i2, size - 1 );
if ( i1 > i2 )
qSwap( i1, i2 );
return ( i2 - i1 + 1 );
}
class QwtPlotCurve::PrivateData
{
public:
PrivateData()
: style( QwtPlotCurve::Lines )
, baseline( 0.0 )
, symbol( NULL )
, pen( Qt::black )
, paintAttributes( QwtPlotCurve::ClipPolygons | QwtPlotCurve::FilterPoints )
{
curveFitter = new QwtSplineCurveFitter;
}
~PrivateData()
{
delete symbol;
delete curveFitter;
}
QwtPlotCurve::CurveStyle style;
double baseline;
const QwtSymbol* symbol;
QwtCurveFitter* curveFitter;
QPen pen;
QBrush brush;
QwtPlotCurve::CurveAttributes attributes;
QwtPlotCurve::PaintAttributes paintAttributes;
QwtPlotCurve::LegendAttributes legendAttributes;
};
QwtPlotCurve::QwtPlotCurve( const QwtText& title )
: QwtPlotSeriesItem( title )
{
init();
}
QwtPlotCurve::QwtPlotCurve( const QString& title )
: QwtPlotSeriesItem( QwtText( title ) )
{
init();
}
QwtPlotCurve::~QwtPlotCurve()
{
delete m_data;
}
void QwtPlotCurve::init()
{
setItemAttribute( QwtPlotItem::Legend );
setItemAttribute( QwtPlotItem::AutoScale );
m_data = new PrivateData;
setData( new QwtPointSeriesData() );
setZ( 20.0 );
}
int QwtPlotCurve::rtti() const
{
return QwtPlotItem::Rtti_PlotCurve;
}
void QwtPlotCurve::setPaintAttribute( PaintAttribute attribute, bool on )
{
if ( on )
m_data->paintAttributes |= attribute;
else
m_data->paintAttributes &= ~attribute;
}
bool QwtPlotCurve::testPaintAttribute( PaintAttribute attribute ) const
{
return ( m_data->paintAttributes & attribute );
}
void QwtPlotCurve::setLegendAttribute( LegendAttribute attribute, bool on )
{
if ( on != testLegendAttribute( attribute ) )
{
if ( on )
m_data->legendAttributes |= attribute;
else
m_data->legendAttributes &= ~attribute;
qwtUpdateLegendIconSize( this );
legendChanged();
}
}
bool QwtPlotCurve::testLegendAttribute( LegendAttribute attribute ) const
{
return ( m_data->legendAttributes & attribute );
}
void QwtPlotCurve::setLegendAttributes( LegendAttributes attributes )
{
if ( attributes != m_data->legendAttributes )
{
m_data->legendAttributes = attributes;
qwtUpdateLegendIconSize( this );
legendChanged();
}
}
QwtPlotCurve::LegendAttributes QwtPlotCurve::legendAttributes() const
{
return m_data->legendAttributes;
}
void QwtPlotCurve::setStyle( CurveStyle style )
{
if ( style != m_data->style )
{
m_data->style = style;
legendChanged();
itemChanged();
}
}
QwtPlotCurve::CurveStyle QwtPlotCurve::style() const
{
return m_data->style;
}
void QwtPlotCurve::setSymbol( QwtSymbol* symbol )
{
if ( symbol != m_data->symbol )
{
delete m_data->symbol;
m_data->symbol = symbol;
qwtUpdateLegendIconSize( this );
legendChanged();
itemChanged();
}
}
const QwtSymbol* QwtPlotCurve::symbol() const
{
return m_data->symbol;
}
void QwtPlotCurve::setPen( const QColor& color, qreal width, Qt::PenStyle style )
{
setPen( QPen( color, width, style ) );
}
void QwtPlotCurve::setPen( const QPen& pen )
{
if ( pen != m_data->pen )
{
m_data->pen = pen;
legendChanged();
itemChanged();
}
}
const QPen& QwtPlotCurve::pen() const
{
return m_data->pen;
}
void QwtPlotCurve::setBrush( const QBrush& brush )
{
if ( brush != m_data->brush )
{
m_data->brush = brush;
legendChanged();
itemChanged();
}
}
const QBrush& QwtPlotCurve::brush() const
{
return m_data->brush;
}
void QwtPlotCurve::drawSeries( QPainter* painter,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const
{
const size_t numSamples = dataSize();
if ( !painter || numSamples <= 0 )
return;
if ( to < 0 )
to = numSamples - 1;
if ( qwtVerifyRange( numSamples, from, to ) > 0 )
{
painter->save();
painter->setPen( m_data->pen );
/*
Qt 4.0.0 is slow when drawing lines, but it's even
slower when the painter has a brush. So we don't
set the brush before we really need it.
*/
drawCurve( painter, m_data->style, xMap, yMap, canvasRect, from, to );
painter->restore();
if ( m_data->symbol &&
( m_data->symbol->style() != QwtSymbol::NoSymbol ) )
{
painter->save();
drawSymbols( painter, *m_data->symbol,
xMap, yMap, canvasRect, from, to );
painter->restore();
}
}
}
void QwtPlotCurve::drawCurve( QPainter* painter, int style,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const
{
switch ( style )
{
case Lines:
if ( testCurveAttribute( Fitted ) )
{
// we always need the complete
// curve for fitting
from = 0;
to = dataSize() - 1;
}
drawLines( painter, xMap, yMap, canvasRect, from, to );
break;
case Sticks:
drawSticks( painter, xMap, yMap, canvasRect, from, to );
break;
case Steps:
drawSteps( painter, xMap, yMap, canvasRect, from, to );
break;
case Dots:
drawDots( painter, xMap, yMap, canvasRect, from, to );
break;
case NoCurve:
default:
break;
}
}
void QwtPlotCurve::drawLines( QPainter* painter,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const
{
if ( from > to )
return;
const bool doFit = ( m_data->attributes & Fitted ) && m_data->curveFitter;
const bool doAlign = !doFit && QwtPainter::roundingAlignment( painter );
const bool doFill = ( m_data->brush.style() != Qt::NoBrush )
&& ( m_data->brush.color().alpha() > 0 );
QRectF clipRect;
if ( m_data->paintAttributes & ClipPolygons )
{
clipRect = qwtIntersectedClipRect( canvasRect, painter );
const qreal pw = QwtPainter::effectivePenWidth( painter->pen() );
clipRect = clipRect.adjusted(-pw, -pw, pw, pw);
}
QwtPointMapper mapper;
if ( doAlign )
{
mapper.setFlag( QwtPointMapper::RoundPoints, true );
mapper.setFlag( QwtPointMapper::WeedOutIntermediatePoints,
testPaintAttribute( FilterPointsAggressive ) );
}
mapper.setFlag( QwtPointMapper::WeedOutPoints,
testPaintAttribute( FilterPoints ) ||
testPaintAttribute( FilterPointsAggressive ) );
mapper.setBoundingRect( canvasRect );
QPolygonF polyline = mapper.toPolygonF( xMap, yMap, data(), from, to );
if ( doFill )
{
if ( doFit )
{
// it might be better to extend and draw the curvePath, but for
// the moment we keep an implementation, where we translate the
// path back to a polyline.
polyline = m_data->curveFitter->fitCurve( polyline );
}
if ( painter->pen().style() != Qt::NoPen )
{
// here we are wasting memory for the filled copy,
// do polygon clipping twice etc .. TODO
QPolygonF filled = polyline;
fillCurve( painter, xMap, yMap, canvasRect, filled );
filled.clear();
if ( m_data->paintAttributes & ClipPolygons )
QwtClipper::clipPolygonF( clipRect, polyline, false );
QwtPainter::drawPolyline( painter, polyline );
}
else
{
fillCurve( painter, xMap, yMap, canvasRect, polyline );
}
}
else
{
if ( testPaintAttribute( ClipPolygons ) )
{
QwtClipper::clipPolygonF( clipRect, polyline, false );
}
if ( doFit )
{
if ( m_data->curveFitter->mode() == QwtCurveFitter::Path )
{
const QPainterPath curvePath =
m_data->curveFitter->fitCurvePath( polyline );
painter->drawPath( curvePath );
}
else
{
polyline = m_data->curveFitter->fitCurve( polyline );
QwtPainter::drawPolyline( painter, polyline );
}
}
else
{
QwtPainter::drawPolyline( painter, polyline );
}
}
}
void QwtPlotCurve::drawSticks( QPainter* painter,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const
{
Q_UNUSED( canvasRect )
painter->save();
painter->setRenderHint( QPainter::Antialiasing, false );
const bool doAlign = QwtPainter::roundingAlignment( painter );
double x0 = xMap.transform( m_data->baseline );
double y0 = yMap.transform( m_data->baseline );
if ( doAlign )
{
x0 = qRound( x0 );
y0 = qRound( y0 );
}
const Qt::Orientation o = orientation();
const QwtSeriesData< QPointF >* series = data();
for ( int i = from; i <= to; i++ )
{
const QPointF sample = series->sample( i );
double xi = xMap.transform( sample.x() );
double yi = yMap.transform( sample.y() );
if ( doAlign )
{
xi = qRound( xi );
yi = qRound( yi );
}
if ( o == Qt::Horizontal )
QwtPainter::drawLine( painter, x0, yi, xi, yi );
else
QwtPainter::drawLine( painter, xi, y0, xi, yi );
}
painter->restore();
}
void QwtPlotCurve::drawDots( QPainter* painter,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const
{
const QColor color = painter->pen().color();
if ( painter->pen().style() == Qt::NoPen || color.alpha() == 0 )
{
return;
}
const bool doFill = ( m_data->brush.style() != Qt::NoBrush )
&& ( m_data->brush.color().alpha() > 0 );
const bool doAlign = QwtPainter::roundingAlignment( painter );
QwtPointMapper mapper;
mapper.setBoundingRect( canvasRect );
mapper.setFlag( QwtPointMapper::RoundPoints, doAlign );
if ( m_data->paintAttributes & FilterPoints )
{
if ( ( color.alpha() == 255 )
&& !( painter->renderHints() & QPainter::Antialiasing ) )
{
mapper.setFlag( QwtPointMapper::WeedOutPoints, true );
}
}
if ( doFill )
{
mapper.setFlag( QwtPointMapper::WeedOutPoints, false );
QPolygonF points = mapper.toPolygonF(
xMap, yMap, data(), from, to );
QwtPainter::drawPoints( painter, points );
fillCurve( painter, xMap, yMap, canvasRect, points );
}
else if ( m_data->paintAttributes & ImageBuffer )
{
const QImage image = mapper.toImage( xMap, yMap,
data(), from, to, m_data->pen,
painter->testRenderHint( QPainter::Antialiasing ),
renderThreadCount() );
painter->drawImage( canvasRect.toAlignedRect(), image );
}
else if ( m_data->paintAttributes & MinimizeMemory )
{
const QwtSeriesData< QPointF >* series = data();
for ( int i = from; i <= to; i++ )
{
const QPointF sample = series->sample( i );
double xi = xMap.transform( sample.x() );
double yi = yMap.transform( sample.y() );
if ( doAlign )
{
xi = qRound( xi );
yi = qRound( yi );
}
QwtPainter::drawPoint( painter, QPointF( xi, yi ) );
}
}
else
{
if ( doAlign )
{
const QPolygon points = mapper.toPoints(
xMap, yMap, data(), from, to );
QwtPainter::drawPoints( painter, points );
}
else
{
const QPolygonF points = mapper.toPointsF(
xMap, yMap, data(), from, to );
QwtPainter::drawPoints( painter, points );
}
}
}
void QwtPlotCurve::drawSteps( QPainter* painter,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const
{
const bool doAlign = QwtPainter::roundingAlignment( painter );
QPolygonF polygon( 2 * ( to - from ) + 1 );
QPointF* points = polygon.data();
bool inverted = orientation() == Qt::Vertical;
if ( m_data->attributes & Inverted )
inverted = !inverted;
const QwtSeriesData< QPointF >* series = data();
int i, ip;
for ( i = from, ip = 0; i <= to; i++, ip += 2 )
{
const QPointF sample = series->sample( i );
double xi = xMap.transform( sample.x() );
double yi = yMap.transform( sample.y() );
if ( doAlign )
{
xi = qRound( xi );
yi = qRound( yi );
}
if ( ip > 0 )
{
const QPointF& p0 = points[ip - 2];
QPointF& p = points[ip - 1];
if ( inverted )
{
p.rx() = p0.x();
p.ry() = yi;
}
else
{
p.rx() = xi;
p.ry() = p0.y();
}
}
points[ip].rx() = xi;
points[ip].ry() = yi;
}
if ( m_data->paintAttributes & ClipPolygons )
{
QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter );
const qreal pw = QwtPainter::effectivePenWidth( painter->pen() );
clipRect = clipRect.adjusted(-pw, -pw, pw, pw);
const QPolygonF clipped = QwtClipper::clippedPolygonF(
clipRect, polygon, false );
QwtPainter::drawPolyline( painter, clipped );
}
else
{
QwtPainter::drawPolyline( painter, polygon );
}
if ( m_data->brush.style() != Qt::NoBrush )
fillCurve( painter, xMap, yMap, canvasRect, polygon );
}
void QwtPlotCurve::setCurveAttribute( CurveAttribute attribute, bool on )
{
if ( bool( m_data->attributes & attribute ) == on )
return;
if ( on )
m_data->attributes |= attribute;
else
m_data->attributes &= ~attribute;
itemChanged();
}
bool QwtPlotCurve::testCurveAttribute( CurveAttribute attribute ) const
{
return m_data->attributes & attribute;
}
void QwtPlotCurve::setCurveFitter( QwtCurveFitter* curveFitter )
{
delete m_data->curveFitter;
m_data->curveFitter = curveFitter;
itemChanged();
}
QwtCurveFitter* QwtPlotCurve::curveFitter() const
{
return m_data->curveFitter;
}
void QwtPlotCurve::fillCurve( QPainter* painter,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, QPolygonF& polygon ) const
{
if ( m_data->brush.style() == Qt::NoBrush )
return;
closePolyline( painter, xMap, yMap, polygon );
if ( polygon.count() <= 2 ) // a line can't be filled
return;
QBrush brush = m_data->brush;
if ( !brush.color().isValid() )
brush.setColor( m_data->pen.color() );
if ( m_data->paintAttributes & ClipPolygons )
{
const QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter );
QwtClipper::clipPolygonF( clipRect, polygon, true );
}
painter->save();
painter->setPen( Qt::NoPen );
painter->setBrush( brush );
QwtPainter::drawPolygon( painter, polygon );
painter->restore();
}
void QwtPlotCurve::closePolyline( QPainter* painter,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
QPolygonF& polygon ) const
{
if ( polygon.size() < 2 )
return;
const bool doAlign = QwtPainter::roundingAlignment( painter );
double baseline = m_data->baseline;
if ( orientation() == Qt::Vertical )
{
if ( yMap.transformation() )
baseline = yMap.transformation()->bounded( baseline );
double refY = yMap.transform( baseline );
if ( doAlign && qAbs( refY ) < std::numeric_limits< int >::max() )
refY = qRound( refY );
polygon += QPointF( polygon.last().x(), refY );
polygon += QPointF( polygon.first().x(), refY );
}
else
{
if ( xMap.transformation() )
baseline = xMap.transformation()->bounded( baseline );
double refX = xMap.transform( baseline );
if ( doAlign && qAbs( refX ) < std::numeric_limits< int >::max() )
refX = qRound( refX );
polygon += QPointF( refX, polygon.last().y() );
polygon += QPointF( refX, polygon.first().y() );
}
}
void QwtPlotCurve::drawSymbols( QPainter* painter, const QwtSymbol& symbol,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to ) const
{
QwtPointMapper mapper;
mapper.setFlag( QwtPointMapper::RoundPoints,
QwtPainter::roundingAlignment( painter ) );
mapper.setFlag( QwtPointMapper::WeedOutPoints,
testPaintAttribute( QwtPlotCurve::FilterPoints ) );
const QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter );
mapper.setBoundingRect( clipRect );
const int chunkSize = 500;
for ( int i = from; i <= to; i += chunkSize )
{
const int n = qMin( chunkSize, to - i + 1 );
const QPolygonF points = mapper.toPointsF( xMap, yMap,
data(), i, i + n - 1 );
if ( points.size() > 0 )
symbol.drawSymbols( painter, points );
}
}
void QwtPlotCurve::setBaseline( double value )
{
if ( m_data->baseline != value )
{
m_data->baseline = value;
itemChanged();
}
}
double QwtPlotCurve::baseline() const
{
return m_data->baseline;
}
int QwtPlotCurve::closestPoint( const QPointF& pos, double* dist ) const
{
const QwtPlot* plot = this->plot();
if ( ( plot == NULL ) || !plot->isAxisValid( xAxis() ) || !plot->isAxisValid( yAxis() ) )
return -1;
const size_t numSamples = dataSize();
if ( numSamples <= 0 )
return -1;
const QwtSeriesData< QPointF >* series = data();
const QwtScaleMap xMap = plot->canvasMap( xAxis() );
const QwtScaleMap yMap = plot->canvasMap( yAxis() );
int index = -1;
double dmin = 1.0e10;
for ( uint i = 0; i < numSamples; i++ )
{
const QPointF sample = series->sample( i );
const double cx = xMap.transform( sample.x() ) - pos.x();
const double cy = yMap.transform( sample.y() ) - pos.y();
const double f = qwtSqr( cx ) + qwtSqr( cy );
if ( f < dmin )
{
index = i;
dmin = f;
}
}
if ( dist )
*dist = std::sqrt( dmin );
return index;
}
int QwtPlotCurve::adjacentPoint( Qt::Orientation orientation, qreal value ) const
{
const QwtSeriesData< QPointF >* data = this->data();
if ( data == NULL )
return -1;
if ( orientation == Qt::Horizontal )
{
struct compareX
{
inline bool operator()( const double x, const QPointF& pos ) const
{
return ( x < pos.x() );
}
};
return qwtUpperSampleIndex< QPointF >( *data, value, compareX() );
}
else
{
struct compareY
{
inline bool operator()( const double y, const QPointF& pos ) const
{
return ( y < pos.y() );
}
};
return qwtUpperSampleIndex< QPointF >( *data, value, compareY() );
}
return -1;
}
qreal QwtPlotCurve::interpolatedValueAt( Qt::Orientation orientation, double value ) const
{
const QRectF br = boundingRect();
if ( br.width() <= 0.0 )
return qQNaN();
double v;
if ( orientation == Qt::Horizontal )
{
if ( value < br.left() || value > br.right() )
return qQNaN();
const int index = adjacentPoint( orientation, value );
if ( index == -1 )
{
const QPointF last = sample( dataSize() - 1 );
if ( value != last.x() )
return qQNaN();
v = last.y();
}
else
{
const QLineF line( sample( index - 1 ), sample( index ) );
v = line.pointAt( ( value - line.p1().x() ) / line.dx() ).y();
}
}
else
{
if ( value < br.top() || value > br.bottom() )
return qQNaN();
const int index = adjacentPoint( orientation, value );
if ( index == -1 )
{
const QPointF last = sample( dataSize() - 1 );
if ( value != last.y() )
return qQNaN();
v = last.x();
}
else
{
const QLineF line( sample( index - 1 ), sample( index ) );
v = line.pointAt( ( value - line.p1().y() ) / line.dy() ).x();
}
}
return v;
}
QwtGraphic QwtPlotCurve::legendIcon( int index, const QSizeF& size ) const
{
Q_UNUSED( index );
if ( size.isEmpty() )
return QwtGraphic();
QwtGraphic graphic;
graphic.setDefaultSize( size );
graphic.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
QPainter painter( &graphic );
painter.setRenderHint( QPainter::Antialiasing,
testRenderHint( QwtPlotItem::RenderAntialiased ) );
if ( m_data->legendAttributes == 0 ||
m_data->legendAttributes & QwtPlotCurve::LegendShowBrush )
{
QBrush brush = m_data->brush;
if ( brush.style() == Qt::NoBrush &&
m_data->legendAttributes == 0 )
{
if ( style() != QwtPlotCurve::NoCurve )
{
brush = QBrush( pen().color() );
}
else if ( m_data->symbol &&
( m_data->symbol->style() != QwtSymbol::NoSymbol ) )
{
brush = QBrush( m_data->symbol->pen().color() );
}
}
if ( brush.style() != Qt::NoBrush )
{
QRectF r( 0, 0, size.width(), size.height() );
painter.fillRect( r, brush );
}
}
if ( m_data->legendAttributes & QwtPlotCurve::LegendShowLine )
{
if ( pen() != Qt::NoPen )
{
QPen pn = pen();
pn.setCapStyle( Qt::FlatCap );
painter.setPen( pn );
const double y = 0.5 * size.height();
QwtPainter::drawLine( &painter, 0.0, y, size.width(), y );
}
}
if ( m_data->legendAttributes & QwtPlotCurve::LegendShowSymbol )
{
if ( m_data->symbol )
{
QRectF r( 0, 0, size.width(), size.height() );
m_data->symbol->drawSymbol( &painter, r );
}
}
return graphic;
}
void QwtPlotCurve::setSamples( QwtSeriesData< QPointF >* data )
{
setData( data );
}
void QwtPlotCurve::setSamples( const QVector< QPointF >& samples )
{
setData( new QwtPointSeriesData( samples ) );
}
void QwtPlotCurve::setRawSamples(
const double* xData, const double* yData, int size )
{
setData( new QwtCPointerData< double >( xData, yData, size ) );
}
void QwtPlotCurve::setRawSamples(
const float* xData, const float* yData, int size )
{
setData( new QwtCPointerData< float >( xData, yData, size ) );
}
void QwtPlotCurve::setRawSamples( const double* yData, int size )
{
setData( new QwtCPointerValueData< double >( yData, size ) );
}
void QwtPlotCurve::setRawSamples( const float* yData, int size )
{
setData( new QwtCPointerValueData< float >( yData, size ) );
}
void QwtPlotCurve::setSamples(
const double* xData, const double* yData, int size )
{
setData( new QwtPointArrayData< double >( xData, yData, size ) );
}
void QwtPlotCurve::setSamples(
const float* xData, const float* yData, int size )
{
setData( new QwtPointArrayData< float >( xData, yData, size ) );
}
void QwtPlotCurve::setSamples( const QVector< double >& xData,
const QVector< double >& yData )
{
setData( new QwtPointArrayData< double >( xData, yData ) );
}
void QwtPlotCurve::setSamples( const QVector< float >& xData,
const QVector< float >& yData )
{
setData( new QwtPointArrayData< float >( xData, yData ) );
}
void QwtPlotCurve::setSamples( const double* yData, int size )
{
setData( new QwtValuePointData< double >( yData, size ) );
}
void QwtPlotCurve::setSamples( const float* yData, int size )
{
setData( new QwtValuePointData< float >( yData, size ) );
}
void QwtPlotCurve::setSamples( const QVector< double >& yData )
{
setData( new QwtValuePointData< double >( yData ) );
}
void QwtPlotCurve::setSamples( const QVector< float >& yData )
{
setData( new QwtValuePointData< float >( yData ) );
}
QVector
Definition qwt_clipper.h:23
QwtArraySeriesData
Template class for data, that is organized as QVector.
Definition qwt_series_data.h:153
QwtCPointerData
Data class containing two pointers to memory blocks of T.
Definition qwt_point_data.h:44
QwtCPointerValueData
Data class containing a pointer to memory of y coordinates.
Definition qwt_point_data.h:90
QwtCurveFitter
Abstract base class for a curve fitter.
Definition qwt_curve_fitter.h:22
QwtCurveFitter::fitCurvePath
virtual QPainterPath fitCurvePath(const QPolygonF &polygon) const =0
QwtCurveFitter::Path
@ Path
Definition qwt_curve_fitter.h:48
QwtCurveFitter::mode
Mode mode() const
Definition qwt_curve_fitter.cpp:27
QwtCurveFitter::fitCurve
virtual QPolygonF fitCurve(const QPolygonF &polygon) const =0
QwtGraphic
A paint device for scalable graphics.
Definition qwt_graphic.h:76
QwtGraphic::RenderPensUnscaled
@ RenderPensUnscaled
Definition qwt_graphic.h:96
QwtGraphic::setRenderHint
void setRenderHint(RenderHint, bool on=true)
Definition qwt_graphic.cpp:443
QwtGraphic::setDefaultSize
void setDefaultSize(const QSizeF &)
Set a default size.
Definition qwt_graphic.cpp:553
QwtPainter::drawPoints
static void drawPoints(QPainter *, const QPolygon &)
Wrapper for QPainter::drawPoints()
Definition qwt_painter.h:142
QwtPainter::drawPolygon
static void drawPolygon(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolygon()
Definition qwt_painter.cpp:551
QwtPainter::drawPolyline
static void drawPolyline(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolyline()
Definition qwt_painter.cpp:568
QwtPainter::effectivePenWidth
static qreal effectivePenWidth(const QPen &)
Definition qwt_painter.h:201
QwtPainter::drawPoint
static void drawPoint(QPainter *, const QPoint &)
Wrapper for QPainter::drawPoint()
Definition qwt_painter.cpp:681
QwtPainter::roundingAlignment
static bool roundingAlignment()
Definition qwt_painter.h:183
QwtPainter::drawLine
static void drawLine(QPainter *, qreal x1, qreal y1, qreal x2, qreal y2)
Wrapper for QPainter::drawLine()
Definition qwt_painter.h:154
QwtPlotCurve
A plot item, that represents a series of points.
Definition qwt_plot_curve.h:59
QwtPlotCurve::interpolatedValueAt
qreal interpolatedValueAt(Qt::Orientation, double) const
Definition qwt_plot_curve.cpp:1158
QwtPlotCurve::setLegendAttribute
void setLegendAttribute(LegendAttribute, bool on=true)
Definition qwt_plot_curve.cpp:184
QwtPlotCurve::drawSeries
virtual void drawSeries(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const override
Definition qwt_plot_curve.cpp:384
QwtPlotCurve::setLegendAttributes
void setLegendAttributes(LegendAttributes)
Definition qwt_plot_curve.cpp:213
QwtPlotCurve::CurveStyle
CurveStyle
Definition qwt_plot_curve.h:66
QwtPlotCurve::NoCurve
@ NoCurve
Definition qwt_plot_curve.h:70
QwtPlotCurve::Steps
@ Steps
Definition qwt_plot_curve.h:90
QwtPlotCurve::Sticks
@ Sticks
Definition qwt_plot_curve.h:83
QwtPlotCurve::Lines
@ Lines
Definition qwt_plot_curve.h:77
QwtPlotCurve::Dots
@ Dots
Definition qwt_plot_curve.h:98
QwtPlotCurve::closePolyline
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...
Definition qwt_plot_curve.cpp:932
QwtPlotCurve::legendAttributes
LegendAttributes legendAttributes() const
Definition qwt_plot_curve.cpp:228
QwtPlotCurve::drawCurve
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.
Definition qwt_plot_curve.cpp:432
QwtPlotCurve::LegendAttributes
QFlags< LegendAttribute > LegendAttributes
Definition qwt_plot_curve.h:168
QwtPlotCurve::fillCurve
virtual void fillCurve(QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRectF &canvasRect, QPolygonF &) const
Definition qwt_plot_curve.cpp:892
QwtPlotCurve::setStyle
void setStyle(CurveStyle style)
Definition qwt_plot_curve.cpp:239
QwtPlotCurve::CurveAttribute
CurveAttribute
Definition qwt_plot_curve.h:113
QwtPlotCurve::Fitted
@ Fitted
Definition qwt_plot_curve.h:130
QwtPlotCurve::Inverted
@ Inverted
Definition qwt_plot_curve.h:118
QwtPlotCurve::style
CurveStyle style() const
Definition qwt_plot_curve.cpp:254
QwtPlotCurve::setSymbol
void setSymbol(QwtSymbol *)
Assign a symbol.
Definition qwt_plot_curve.cpp:269
QwtPlotCurve::closestPoint
virtual int closestPoint(const QPointF &pos, double *dist=NULL) const
Definition qwt_plot_curve.cpp:1054
QwtPlotCurve::drawDots
virtual void drawDots(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
Definition qwt_plot_curve.cpp:643
QwtPlotCurve::QwtPlotCurve
QwtPlotCurve(const QString &title=QString())
Definition qwt_plot_curve.cpp:123
QwtPlotCurve::drawSticks
virtual void drawSticks(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
Definition qwt_plot_curve.cpp:588
QwtPlotCurve::drawSymbols
virtual void drawSymbols(QPainter *, const QwtSymbol &, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
Definition qwt_plot_curve.cpp:982
QwtPlotCurve::adjacentPoint
virtual int adjacentPoint(Qt::Orientation orientation, qreal value) const
Definition qwt_plot_curve.cpp:1108
QwtPlotCurve::testLegendAttribute
bool testLegendAttribute(LegendAttribute) const
Definition qwt_plot_curve.cpp:202
QwtPlotCurve::testCurveAttribute
bool testCurveAttribute(CurveAttribute) const
Definition qwt_plot_curve.cpp:839
QwtPlotCurve::setCurveAttribute
void setCurveAttribute(CurveAttribute, bool on=true)
Definition qwt_plot_curve.cpp:822
QwtPlotCurve::LegendAttribute
LegendAttribute
Definition qwt_plot_curve.h:143
QwtPlotCurve::LegendShowBrush
@ LegendShowBrush
Definition qwt_plot_curve.h:165
QwtPlotCurve::LegendShowSymbol
@ LegendShowSymbol
Definition qwt_plot_curve.h:159
QwtPlotCurve::LegendShowLine
@ LegendShowLine
Definition qwt_plot_curve.h:154
QwtPlotCurve::init
void init()
Initialize internal members.
Definition qwt_plot_curve.cpp:136
QwtPlotCurve::setPaintAttribute
void setPaintAttribute(PaintAttribute, bool on=true)
Definition qwt_plot_curve.cpp:160
QwtPlotCurve::PaintAttribute
PaintAttribute
Definition qwt_plot_curve.h:177
QwtPlotCurve::MinimizeMemory
@ MinimizeMemory
Definition qwt_plot_curve.h:198
QwtPlotCurve::ClipPolygons
@ ClipPolygons
Definition qwt_plot_curve.h:183
QwtPlotCurve::FilterPointsAggressive
@ FilterPointsAggressive
Definition qwt_plot_curve.h:231
QwtPlotCurve::ImageBuffer
@ ImageBuffer
Definition qwt_plot_curve.h:207
QwtPlotCurve::FilterPoints
@ FilterPoints
Definition qwt_plot_curve.h:191
QwtPlotCurve::testPaintAttribute
bool testPaintAttribute(PaintAttribute) const
Definition qwt_plot_curve.cpp:172
QwtPlotCurve::legendIcon
virtual QwtGraphic legendIcon(int index, const QSizeF &) const override
Definition qwt_plot_curve.cpp:1223
QwtPlotCurve::drawLines
virtual void drawLines(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
Draw lines.
Definition qwt_plot_curve.cpp:479
QwtPlotCurve::~QwtPlotCurve
virtual ~QwtPlotCurve()
Destructor.
Definition qwt_plot_curve.cpp:130
QwtPlotCurve::setSamples
void setSamples(const double *xData, const double *yData, int size)
Definition qwt_plot_curve.cpp:1410
QwtPlotCurve::pen
const QPen & pen() const
Definition qwt_plot_curve.cpp:331
QwtPlotCurve::setCurveFitter
void setCurveFitter(QwtCurveFitter *)
Definition qwt_plot_curve.cpp:861
QwtPlotCurve::brush
const QBrush & brush() const
Definition qwt_plot_curve.cpp:366
QwtPlotCurve::setBaseline
void setBaseline(double)
Set the value of the baseline.
Definition qwt_plot_curve.cpp:1025
QwtPlotCurve::setBrush
void setBrush(const QBrush &)
Assign a brush.
Definition qwt_plot_curve.cpp:351
QwtPlotCurve::symbol
const QwtSymbol * symbol() const
Definition qwt_plot_curve.cpp:287
QwtPlotCurve::PaintAttributes
QFlags< PaintAttribute > PaintAttributes
Definition qwt_plot_curve.h:234
QwtPlotCurve::setPen
void setPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
Definition qwt_plot_curve.cpp:305
QwtPlotCurve::curveFitter
QwtCurveFitter * curveFitter() const
Definition qwt_plot_curve.cpp:875
QwtPlotCurve::CurveAttributes
QFlags< CurveAttribute > CurveAttributes
Definition qwt_plot_curve.h:133
QwtPlotCurve::baseline
double baseline() const
Definition qwt_plot_curve.cpp:1038
QwtPlotCurve::drawSteps
virtual void drawSteps(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
Definition qwt_plot_curve.cpp:744
QwtPlotCurve::rtti
virtual int rtti() const override
Definition qwt_plot_curve.cpp:148
QwtPlotCurve::setRawSamples
void setRawSamples(const double *xData, const double *yData, int size)
Initialize the data by pointing to memory blocks which are not managed by QwtPlotCurve.
Definition qwt_plot_curve.cpp:1331
QwtPlot
A 2-D plotting widget.
Definition qwt_plot.h:79
QwtPlot::isAxisValid
bool isAxisValid(QwtAxisId) const
Definition qwt_plot_axis.cpp:132
QwtPlot::canvasMap
virtual QwtScaleMap canvasMap(QwtAxisId) const
Definition qwt_plot.cpp:800
QwtPlotItem::yAxis
QwtAxisId yAxis() const
Return yAxis.
Definition qwt_plot_item.cpp:559
QwtPlotItem::setLegendIconSize
void setLegendIconSize(const QSize &)
Definition qwt_plot_item.cpp:373
QwtPlotItem::legendChanged
virtual void legendChanged()
Definition qwt_plot_item.cpp:491
QwtPlotItem::setZ
void setZ(double z)
Set the z value.
Definition qwt_plot_item.cpp:165
QwtPlotItem::setItemAttribute
void setItemAttribute(ItemAttribute, bool on=true)
Definition qwt_plot_item.cpp:228
QwtPlotItem::plot
QwtPlot * plot() const
Return attached plot.
Definition qwt_plot_item.cpp:142
QwtPlotItem::xAxis
QwtAxisId xAxis() const
Return xAxis.
Definition qwt_plot_item.cpp:553
QwtPlotItem::Rtti_PlotCurve
@ Rtti_PlotCurve
For QwtPlotCurve.
Definition qwt_plot_item.h:93
QwtPlotItem::RenderAntialiased
@ RenderAntialiased
Enable antialiasing.
Definition qwt_plot_item.h:206
QwtPlotItem::testRenderHint
bool testRenderHint(RenderHint) const
Definition qwt_plot_item.cpp:332
QwtPlotItem::itemChanged
virtual void itemChanged()
Definition qwt_plot_item.cpp:481
QwtPlotItem::Legend
@ Legend
The item is represented on the legend.
Definition qwt_plot_item.h:150
QwtPlotItem::AutoScale
@ AutoScale
Definition qwt_plot_item.h:157
QwtPlotItem::renderThreadCount
uint renderThreadCount() const
Definition qwt_plot_item.cpp:360
QwtPlotSeriesItem
Base class for plot items representing a series of samples.
Definition qwt_plot_seriesitem.h:26
QwtPlotSeriesItem::orientation
Qt::Orientation orientation() const
Definition qwt_plot_seriesitem.cpp:77
QwtPlotSeriesItem::boundingRect
virtual QRectF boundingRect() const override
Definition qwt_plot_seriesitem.cpp:97
QwtPointArrayData
Interface for iterating over two QVector<T> objects.
Definition qwt_point_data.h:23
QwtPointMapper
A helper class for translating a series of points.
Definition qwt_point_mapper.h:33
QwtPointMapper::setBoundingRect
void setBoundingRect(const QRectF &)
Definition qwt_point_mapper.cpp:612
QwtPointMapper::toPolygonF
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.
Definition qwt_point_mapper.cpp:647
QwtPointMapper::toImage
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.
Definition qwt_point_mapper.cpp:883
QwtPointMapper::toPointsF
QPolygonF toPointsF(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtSeriesData< QPointF > *series, int from, int to) const
Translate a series into a QPolygonF.
Definition qwt_point_mapper.cpp:759
QwtPointMapper::setFlag
void setFlag(TransformationFlag, bool on=true)
Definition qwt_point_mapper.cpp:586
QwtPointMapper::RoundPoints
@ RoundPoints
Round points to integer values.
Definition qwt_point_mapper.h:42
QwtPointMapper::WeedOutPoints
@ WeedOutPoints
Definition qwt_point_mapper.h:48
QwtPointMapper::WeedOutIntermediatePoints
@ WeedOutIntermediatePoints
Definition qwt_point_mapper.h:68
QwtPointMapper::toPoints
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.
Definition qwt_point_mapper.cpp:833
QwtScaleMap
A scale map.
Definition qwt_scale_map.h:27
QwtScaleMap::transform
double transform(double s) const
Definition qwt_scale_map.h:137
QwtScaleMap::transformation
const QwtTransform * transformation() const
Get the transformation.
Definition qwt_scale_map.cpp:88
QwtSeriesData< QPointF >
QwtSeriesData::sample
virtual T sample(size_t i) const =0
QwtSeriesStore< QPointF >::sample
QPointF sample(int index) const
Definition qwt_series_store.h:158
QwtSeriesStore< QPointF >::dataSize
virtual size_t dataSize() const override
Definition qwt_series_store.h:175
QwtSeriesStore< QPointF >::data
QwtSeriesData< QPointF > * data()
Definition qwt_series_store.h:146
QwtSeriesStore< QPointF >::setData
void setData(QwtSeriesData< QPointF > *series)
Definition qwt_series_store.h:164
QwtSplineCurveFitter
A curve fitter using a spline interpolation.
Definition qwt_spline_curve_fitter.h:26
QwtSymbol
A class for drawing symbols.
Definition qwt_symbol.h:32
QwtSymbol::style
Style style() const
Definition qwt_symbol.cpp:1795
QwtSymbol::drawSymbol
void drawSymbol(QPainter *, const QRectF &) const
Draw the symbol into a rectangle.
Definition qwt_symbol.cpp:1434
QwtSymbol::boundingRect
virtual QRect boundingRect() const
Definition qwt_symbol.cpp:1637
QwtSymbol::drawSymbols
void drawSymbols(QPainter *, const QPolygonF &) const
Draw symbols at the specified points.
Definition qwt_symbol.h:251
QwtSymbol::NoSymbol
@ NoSymbol
No Style. The symbol cannot be drawn.
Definition qwt_symbol.h:41
QwtSymbol::pen
const QPen & pen() const
Definition qwt_symbol.cpp:1171
QwtText
A class representing a text.
Definition qwt_text.h:52
QwtTransform::bounded
virtual double bounded(double value) const
Definition qwt_transform.cpp:33
QwtValuePointData
Interface for iterating over a QVector<T>.
Definition qwt_point_data.h:68
QwtClipper::clippedPolygonF
QWT_EXPORT QPolygonF clippedPolygonF(const QRectF &, const QPolygonF &, bool closePolygon=false)
Definition qwt_clipper.cpp:455
QwtClipper::clipPolygonF
QWT_EXPORT void clipPolygonF(const QRectF &, QPolygonF &, bool closePolygon=false)
Definition qwt_clipper.cpp:404