00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_PLOT_HISTOGRAM_H
00011 #define QWT_PLOT_HISTOGRAM_H
00012
00013 #include <qglobal.h>
00014 #include <qcolor.h>
00015
00016 #include "qwt_polygon.h"
00017 #include "qwt_plot_seriesitem.h"
00018 #include "qwt_column_symbol.h"
00019
00020 class QwtIntervalData;
00021 class QString;
00022
00023 class QWT_EXPORT QwtPlotHistogram: public QwtPlotSeriesItem<QwtIntervalSample>
00024 {
00025 public:
00026 enum CurveStyle
00027 {
00028 NoCurve,
00029
00030 Outline,
00031
00032 Columns,
00033 Lines,
00034
00035 UserCurve = 100
00036 };
00037
00038 explicit QwtPlotHistogram(const QString &title = QString::null);
00039 explicit QwtPlotHistogram(const QwtText &title);
00040 virtual ~QwtPlotHistogram();
00041
00042 virtual int rtti() const;
00043
00044 void setPen(const QPen &);
00045 const QPen &pen() const;
00046
00047 void setBrush(const QBrush &);
00048 const QBrush &brush() const;
00049
00050 void setData(const QwtArray<QwtIntervalSample> &data);
00051 void setData(const QwtSeriesData<QwtIntervalSample> &data);
00052
00053 void setBaseline(double reference);
00054 double baseline() const;
00055
00056 void setStyle(CurveStyle style);
00057 CurveStyle style() const;
00058
00059 void setSymbol(const QwtColumnSymbol &);
00060 const QwtColumnSymbol &symbol() const;
00061
00062 virtual void drawSeries(QPainter *p,
00063 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00064 const QRect &canvasRect, int from, int to) const;
00065
00066 virtual QwtDoubleRect boundingRect() const;
00067 virtual void updateLegend(QwtLegend *) const;
00068
00069 protected:
00070 virtual QRect columnRect(const QwtIntervalSample &,
00071 const QwtScaleMap &, const QwtScaleMap &,
00072 QwtColumnSymbol::Direction &) const;
00073
00074 virtual void drawColumn(QPainter *, const QRect &,
00075 QwtColumnSymbol::Direction, const QwtIntervalSample &) const;
00076
00077 void drawColumns(QPainter *,
00078 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00079 int from, int to) const;
00080
00081 void drawOutline(QPainter *,
00082 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00083 int from, int to) const;
00084
00085 void drawLines(QPainter *,
00086 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00087 int from, int to) const;
00088
00089 private:
00090 void init();
00091 #if QT_VERSION < 0x040000
00092 void flushPolygon(QPainter *, int baseLine, QValueList<QPoint> &) const;
00093 void drawPolygon(QPainter *, const QValueList<QPoint>&) const;
00094 #else
00095 void flushPolygon(QPainter *, int baseLine, QwtPolygon &) const;
00096 #endif
00097
00098 class PrivateData;
00099 PrivateData *d_data;
00100 };
00101
00102 #endif