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() );
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 *, int style,
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;
virtual void drawLines( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawSticks( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawDots( QPainter *,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to ) const;
virtual void drawSteps( QPainter *,
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::minYValue
double minYValue() const
boundingRect().top()
Definition: qwt_plot_curve.h:322
QwtPlotSeriesItem::boundingRect
virtual QRectF boundingRect() const
Definition: qwt_plot_seriesitem.cpp:95
QwtCurveFitter
Abstract base class for a curve fitter.
Definition: qwt_curve_fitter.h:23
QwtPlotSeriesItem
Base class for plot items representing a series of samples.
Definition: qwt_plot_seriesitem.h:24
QwtPlotCurve::Lines
@ Lines
Definition: qwt_plot_curve.h:75
QwtSeriesStore
Class storing a QwtSeriesData object.
Definition: qwt_series_store.h:66
QwtPlotCurve::LegendAttributes
QFlags< LegendAttribute > LegendAttributes
Legend attributes.
Definition: qwt_plot_curve.h:168
QwtPlotCurve::Dots
@ Dots
Definition: qwt_plot_curve.h:96
QwtPlotCurve::LegendAttribute
LegendAttribute
Definition: qwt_plot_curve.h:142
QwtPlotCurve::maxYValue
double maxYValue() const
boundingRect().bottom()
Definition: qwt_plot_curve.h:328
QwtPlotItem::rtti
virtual int rtti() const
Definition: qwt_plot_item.cpp:120
QwtSeriesData< QPointF >
QwtText
A class representing a text.
Definition: qwt_text.h:52
QwtPlotSeriesItem::drawSeries
virtual void drawSeries(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const =0
QwtPlotCurve::Steps
@ Steps
Definition: qwt_plot_curve.h:88
QwtPlotCurve::PaintAttributes
QFlags< PaintAttribute > PaintAttributes
Paint attributes.
Definition: qwt_plot_curve.h:211
QwtPlotCurve::maxXValue
double maxXValue() const
boundingRect().right()
Definition: qwt_plot_curve.h:316
QwtGraphic
A paint device for scalable graphics.
Definition: qwt_graphic.h:75
QwtPlotCurve::minXValue
double minXValue() const
boundingRect().left()
Definition: qwt_plot_curve.h:310
QwtPlotCurve::PaintAttribute
PaintAttribute
Definition: qwt_plot_curve.h:177
QwtPlotCurve::CurveStyle
CurveStyle
Definition: qwt_plot_curve.h:64
QwtPlotCurve::CurveAttribute
CurveAttribute
Definition: qwt_plot_curve.h:111
QwtScaleMap
A scale map.
Definition: qwt_scale_map.h:31
QwtSymbol
A class for drawing symbols.
Definition: qwt_symbol.h:31
QwtPlotCurve
A plot item, that represents a series of points.
Definition: qwt_plot_curve.h:57
QwtPlotCurve::Sticks
@ Sticks
Definition: qwt_plot_curve.h:81
QwtPlotItem::legendIcon
virtual QwtGraphic legendIcon(int index, const QSizeF &) const
Definition: qwt_plot_item.cpp:371
QwtPlotCurve::CurveAttributes
QFlags< CurveAttribute > CurveAttributes
Curve attributes.
Definition: qwt_plot_curve.h:132