qwt_plot_curve.h
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* 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
*****************************************************************************/
#ifndef QWT_PLOT_CURVE_H
#define QWT_PLOT_CURVE_H
#include "qwt_global.h"
#include "qwt_plot_seriesitem.h"
#include "qwt_series_data.h"
#include "qwt_text.h"
#include <qpen.h>
#include <qstring.h>
class QPainter;
class QPolygonF;
class QwtScaleMap;
class QwtSymbol;
class QwtCurveFitter;
class QWT_EXPORT QwtPlotCurve:
public QwtPlotSeriesItem, public QwtSeriesStore<QPointF>
{
public:
enum CurveStyle
{
NoCurve = -1,
Lines,
Sticks,
Steps,
Dots,
UserCurve = 100
};
enum CurveAttribute
{
Inverted = 0x01,
Fitted = 0x02
};
typedef QFlags<CurveAttribute> CurveAttributes;
enum LegendAttribute
{
LegendNoAttribute = 0x00,
LegendShowLine = 0x01,
LegendShowSymbol = 0x02,
LegendShowBrush = 0x04
};
typedef QFlags<LegendAttribute> LegendAttributes;
enum PaintAttribute
{
ClipPolygons = 0x01,
FilterPoints = 0x02,
MinimizeMemory = 0x04,
ImageBuffer = 0x08
};
typedef QFlags<PaintAttribute> PaintAttributes;
explicit QwtPlotCurve( const QString &title = QString::null );
explicit QwtPlotCurve( const QwtText &title );
virtual ~QwtPlotCurve();
virtual int rtti() const;
void setPaintAttribute( PaintAttribute, bool on = true );
bool testPaintAttribute( PaintAttribute ) const;
void setLegendAttribute( LegendAttribute, bool on = true );
bool testLegendAttribute( LegendAttribute ) const;
#ifndef QWT_NO_COMPAT
void setRawSamples( const double *xData, const double *yData, int size );
void setSamples( const double *xData, const double *yData, int size );
void setSamples( const QVector<double> &xData, const QVector<double> &yData );
#endif
void setSamples( const QVector<QPointF> & );
void setSamples( QwtSeriesData<QPointF> * );
int closestPoint( const QPoint &pos, double *dist = NULL ) const;
double minXValue() const;
double maxXValue() const;
double minYValue() const;
double maxYValue() const;
void setCurveAttribute( CurveAttribute, bool on = true );
bool testCurveAttribute( CurveAttribute ) const;
void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
void setPen( const QPen & );
const QPen &pen() const;
void setBrush( const QBrush & );
const QBrush &brush() const;
void setBaseline( double );
double baseline() const;
void setStyle( CurveStyle style );
CurveStyle style() const;
void setSymbol( QwtSymbol * );
const QwtSymbol *symbol() const;
void setCurveFitter( QwtCurveFitter * );
QwtCurveFitter *curveFitter() const;
virtual void drawSeries( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
protected:
void init();
virtual void drawCurve( QPainter *p, int style,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawSymbols( QPainter *p, const QwtSymbol &,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawLines( QPainter *p,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawSticks( QPainter *p,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawDots( QPainter *p,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawSteps( QPainter *p,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void fillCurve( QPainter *,
const QwtScaleMap &, const QwtScaleMap &,
const QRectF &canvasRect, QPolygonF & ) const;
void closePolyline( QPainter *,
const QwtScaleMap &, const QwtScaleMap &, QPolygonF & ) const;
private:
class PrivateData;
PrivateData *d_data;
};
inline double QwtPlotCurve::minXValue() const
{
return boundingRect().left();
}
inline double QwtPlotCurve::maxXValue() const
{
return boundingRect().right();
}
inline double QwtPlotCurve::minYValue() const
{
return boundingRect().top();
}
inline double QwtPlotCurve::maxYValue() const
{
return boundingRect().bottom();
}
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::PaintAttributes )
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::LegendAttributes )
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::CurveAttributes )
#endif
QwtPlotCurve::maxXValue
double maxXValue() const
boundingRect().right()
Definition: qwt_plot_curve.h:316
QwtPlotCurve::CurveAttributes
QFlags< CurveAttribute > CurveAttributes
Curve attributes.
Definition: qwt_plot_curve.h:132
QwtPlotCurve::CurveAttribute
CurveAttribute
Definition: qwt_plot_curve.h:110
QwtPlotCurve::LegendAttribute
LegendAttribute
Definition: qwt_plot_curve.h:141
QwtPlotSeriesItem::boundingRect
virtual QRectF boundingRect() const
Definition: qwt_plot_seriesitem.cpp:94
QwtPlotCurve::minXValue
double minXValue() const
boundingRect().left()
Definition: qwt_plot_curve.h:310
QwtPlotCurve
A plot item, that represents a series of points.
Definition: qwt_plot_curve.h:55
QwtPlotCurve::PaintAttribute
PaintAttribute
Definition: qwt_plot_curve.h:176
QwtText
A class representing a text.
Definition: qwt_text.h:51
QwtCurveFitter
Abstract base class for a curve fitter.
Definition: qwt_curve_fitter.h:22
QwtScaleMap
A scale map.
Definition: qwt_scale_map.h:30
QwtPlotItem::legendIcon
virtual QwtGraphic legendIcon(int index, const QSizeF &) const
Definition: qwt_plot_item.cpp:371
QwtPlotCurve::minYValue
double minYValue() const
boundingRect().top()
Definition: qwt_plot_curve.h:322
QwtPlotCurve::CurveStyle
CurveStyle
Definition: qwt_plot_curve.h:63
QwtPlotItem::rtti
virtual int rtti() const
Definition: qwt_plot_item.cpp:120
QwtSymbol
A class for drawing symbols.
Definition: qwt_symbol.h:30
QwtPlotCurve::LegendAttributes
QFlags< LegendAttribute > LegendAttributes
Legend attributes.
Definition: qwt_plot_curve.h:168
QwtPlotSeriesItem::drawSeries
virtual void drawSeries(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const =0
QwtSeriesData< QPointF >
QwtSeriesStore
Class storing a QwtSeriesData object.
Definition: qwt_series_store.h:57
QwtPlotSeriesItem
Base class for plot items representing a series of samples.
Definition: qwt_plot_seriesitem.h:22
QwtPlotCurve::Lines
Definition: qwt_plot_curve.h:75
QwtPlotCurve::Dots
Definition: qwt_plot_curve.h:96
QwtPlotCurve::Steps
Definition: qwt_plot_curve.h:88
QwtGraphic
A paint device for scalable graphics.
Definition: qwt_graphic.h:74
QwtPlotCurve::maxYValue
double maxYValue() const
boundingRect().bottom()
Definition: qwt_plot_curve.h:328
QwtPlotCurve::PaintAttributes
QFlags< PaintAttribute > PaintAttributes
Paint attributes.
Definition: qwt_plot_curve.h:211
QwtPlotCurve::Sticks
Definition: qwt_plot_curve.h:81