Qwt User's Guide svn
qwt_plot_histogram.h
00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * Qwt Widget Library
00003  * Copyright (C) 1997   Josef Wilgen
00004  * Copyright (C) 2002   Uwe Rathmann
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the Qwt License, Version 1.0
00008  *****************************************************************************/
00009 
00010 #ifndef QWT_PLOT_HISTOGRAM_H
00011 #define QWT_PLOT_HISTOGRAM_H
00012 
00013 #include "qwt_global.h"
00014 #include "qwt_plot_seriesitem.h"
00015 #include "qwt_column_symbol.h"
00016 #include <qcolor.h>
00017 #include <qvector.h>
00018 
00019 class QwtIntervalData;
00020 class QString;
00021 class QPolygonF;
00022 
00037 class QWT_EXPORT QwtPlotHistogram: public QwtPlotSeriesItem<QwtIntervalSample>
00038 {
00039 public:
00046     enum HistogramStyle
00047     {
00054         Outline,
00055 
00061         Columns,
00062 
00066         Lines,
00067 
00073         UserStyle = 100
00074     };
00075 
00076     explicit QwtPlotHistogram( const QString &title = QString::null );
00077     explicit QwtPlotHistogram( const QwtText &title );
00078     virtual ~QwtPlotHistogram();
00079 
00080     virtual int rtti() const;
00081 
00082     void setPen( const QPen & );
00083     const QPen &pen() const;
00084 
00085     void setBrush( const QBrush & );
00086     const QBrush &brush() const;
00087 
00088     void setSamples( const QVector<QwtIntervalSample> & );
00089 
00090     void setBaseline( double reference );
00091     double baseline() const;
00092 
00093     void setStyle( HistogramStyle style );
00094     HistogramStyle style() const;
00095 
00096     void setSymbol( const QwtColumnSymbol * );
00097     const QwtColumnSymbol *symbol() const;
00098 
00099     virtual void drawSeries( QPainter *p,
00100         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00101         const QRectF &canvasRect, int from, int to ) const;
00102 
00103     virtual QRectF boundingRect() const;
00104 
00105     virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const;
00106 
00107 protected:
00108     virtual QwtColumnRect columnRect( const QwtIntervalSample &,
00109         const QwtScaleMap &, const QwtScaleMap & ) const;
00110 
00111     virtual void drawColumn( QPainter *, const QwtColumnRect &,
00112         const QwtIntervalSample & ) const;
00113 
00114     void drawColumns( QPainter *,
00115         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00116         int from, int to ) const;
00117 
00118     void drawOutline( QPainter *,
00119         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00120         int from, int to ) const;
00121 
00122     void drawLines( QPainter *,
00123          const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00124          int from, int to ) const;
00125 
00126 private:
00127     void init();
00128     void flushPolygon( QPainter *, double baseLine, QPolygonF & ) const;
00129 
00130     class PrivateData;
00131     PrivateData *d_data;
00132 };
00133 
00134 #endif
qmi style