Qwt User's Guide
|
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 00039 class QWT_EXPORT QwtPlotHistogram: 00040 public QwtPlotSeriesItem, public QwtSeriesStore<QwtIntervalSample> 00041 { 00042 public: 00049 enum HistogramStyle 00050 { 00057 Outline, 00058 00064 Columns, 00065 00069 Lines, 00070 00076 UserStyle = 100 00077 }; 00078 00079 explicit QwtPlotHistogram( const QString &title = QString::null ); 00080 explicit QwtPlotHistogram( const QwtText &title ); 00081 virtual ~QwtPlotHistogram(); 00082 00083 virtual int rtti() const; 00084 00085 void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine ); 00086 void setPen( const QPen & ); 00087 const QPen &pen() const; 00088 00089 void setBrush( const QBrush & ); 00090 const QBrush &brush() const; 00091 00092 void setSamples( const QVector<QwtIntervalSample> & ); 00093 void setSamples( QwtSeriesData<QwtIntervalSample> * ); 00094 00095 void setBaseline( double reference ); 00096 double baseline() const; 00097 00098 void setStyle( HistogramStyle style ); 00099 HistogramStyle style() const; 00100 00101 void setSymbol( const QwtColumnSymbol * ); 00102 const QwtColumnSymbol *symbol() const; 00103 00104 virtual void drawSeries( QPainter *p, 00105 const QwtScaleMap &xMap, const QwtScaleMap &yMap, 00106 const QRectF &canvasRect, int from, int to ) const; 00107 00108 virtual QRectF boundingRect() const; 00109 00110 virtual QwtGraphic legendIcon( int index, const QSizeF & ) const; 00111 00112 protected: 00113 virtual QwtColumnRect columnRect( const QwtIntervalSample &, 00114 const QwtScaleMap &, const QwtScaleMap & ) const; 00115 00116 virtual void drawColumn( QPainter *, const QwtColumnRect &, 00117 const QwtIntervalSample & ) const; 00118 00119 void drawColumns( QPainter *, 00120 const QwtScaleMap &xMap, const QwtScaleMap &yMap, 00121 int from, int to ) const; 00122 00123 void drawOutline( QPainter *, 00124 const QwtScaleMap &xMap, const QwtScaleMap &yMap, 00125 int from, int to ) const; 00126 00127 void drawLines( QPainter *, 00128 const QwtScaleMap &xMap, const QwtScaleMap &yMap, 00129 int from, int to ) const; 00130 00131 private: 00132 void init(); 00133 void flushPolygon( QPainter *, double baseLine, QPolygonF & ) const; 00134 00135 class PrivateData; 00136 PrivateData *d_data; 00137 }; 00138 00139 #endif