Qwt User's Guide  6.1.0
 All Classes Functions Variables Typedefs Enumerations Enumerator Pages
qwt_plot_histogram.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #ifndef QWT_PLOT_HISTOGRAM_H
11 #define QWT_PLOT_HISTOGRAM_H
12 
13 #include "qwt_global.h"
14 #include "qwt_plot_seriesitem.h"
15 #include "qwt_column_symbol.h"
16 #include <qcolor.h>
17 #include <qvector.h>
18 
19 class QwtIntervalData;
20 class QString;
21 class QPolygonF;
22 
39 class QWT_EXPORT QwtPlotHistogram:
40  public QwtPlotSeriesItem, public QwtSeriesStore<QwtIntervalSample>
41 {
42 public:
50  {
58 
65 
70 
76  UserStyle = 100
77  };
78 
79  explicit QwtPlotHistogram( const QString &title = QString::null );
80  explicit QwtPlotHistogram( const QwtText &title );
81  virtual ~QwtPlotHistogram();
82 
83  virtual int rtti() const;
84 
85  void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
86  void setPen( const QPen & );
87  const QPen &pen() const;
88 
89  void setBrush( const QBrush & );
90  const QBrush &brush() const;
91 
92  void setSamples( const QVector<QwtIntervalSample> & );
93  void setSamples( QwtSeriesData<QwtIntervalSample> * );
94 
95  void setBaseline( double reference );
96  double baseline() const;
97 
98  void setStyle( HistogramStyle style );
99  HistogramStyle style() const;
100 
101  void setSymbol( const QwtColumnSymbol * );
102  const QwtColumnSymbol *symbol() const;
103 
104  virtual void drawSeries( QPainter *p,
105  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
106  const QRectF &canvasRect, int from, int to ) const;
107 
108  virtual QRectF boundingRect() const;
109 
110  virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
111 
112 protected:
113  virtual QwtColumnRect columnRect( const QwtIntervalSample &,
114  const QwtScaleMap &, const QwtScaleMap & ) const;
115 
116  virtual void drawColumn( QPainter *, const QwtColumnRect &,
117  const QwtIntervalSample & ) const;
118 
119  void drawColumns( QPainter *,
120  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
121  int from, int to ) const;
122 
123  void drawOutline( QPainter *,
124  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
125  int from, int to ) const;
126 
127  void drawLines( QPainter *,
128  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
129  int from, int to ) const;
130 
131 private:
132  void init();
133  void flushPolygon( QPainter *, double baseLine, QPolygonF & ) const;
134 
135  class PrivateData;
136  PrivateData *d_data;
137 };
138 
139 #endif