source: ntrip/trunk/BNC/qwt/qwt_plot_histogram.h@ 7905

Last change on this file since 7905 was 4271, checked in by mervart, 12 years ago
File size: 4.0 KB
Line 
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
19class QwtIntervalData;
20class QString;
21class QPolygonF;
22
23/*!
24 \brief QwtPlotHistogram represents a series of samples, where an interval
25 is associated with a value ( \f$y = f([x1,x2])\f$ ).
26
27 The representation depends on the style() and an optional symbol()
28 that is displayed for each interval.
29
30 \note The term "histogram" is used in a different way in the areas of
31 digital image processing and statistics. Wikipedia introduces the
32 terms "image histogram" and "color histogram" to avoid confusions.
33 While "image histograms" can be displayed by a QwtPlotCurve there
34 is no applicable plot item for a "color histogram" yet.
35*/
36
37class QWT_EXPORT QwtPlotHistogram: public QwtPlotSeriesItem<QwtIntervalSample>
38{
39public:
40 /*!
41 Histogram styles.
42 The default style is QwtPlotHistogram::Columns.
43
44 \sa setStyle(), style(), setSymbol(), symbol(), setBaseline()
45 */
46 enum HistogramStyle
47 {
48 /*!
49 Draw an outline around the area, that is build by all intervals
50 using the pen() and fill it with the brush(). The outline style
51 requires, that the intervals are in increasing order and
52 not overlapping.
53 */
54 Outline,
55
56 /*!
57 Draw a column for each interval. When a symbol() has been set
58 the symbol is used otherwise the column is displayed as
59 plain rectangle using pen() and brush().
60 */
61 Columns,
62
63 /*!
64 Draw a simple line using the pen() for each interval.
65 */
66 Lines,
67
68 /*!
69 Styles >= UserStyle are reserved for derived
70 classes that overload drawSeries() with
71 additional application specific ways to display a histogram.
72 */
73 UserStyle = 100
74 };
75
76 explicit QwtPlotHistogram( const QString &title = QString::null );
77 explicit QwtPlotHistogram( const QwtText &title );
78 virtual ~QwtPlotHistogram();
79
80 virtual int rtti() const;
81
82 void setPen( const QPen & );
83 const QPen &pen() const;
84
85 void setBrush( const QBrush & );
86 const QBrush &brush() const;
87
88 void setSamples( const QVector<QwtIntervalSample> & );
89
90 void setBaseline( double reference );
91 double baseline() const;
92
93 void setStyle( HistogramStyle style );
94 HistogramStyle style() const;
95
96 void setSymbol( const QwtColumnSymbol * );
97 const QwtColumnSymbol *symbol() const;
98
99 virtual void drawSeries( QPainter *p,
100 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
101 const QRectF &canvasRect, int from, int to ) const;
102
103 virtual QRectF boundingRect() const;
104
105 virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const;
106
107protected:
108 virtual QwtColumnRect columnRect( const QwtIntervalSample &,
109 const QwtScaleMap &, const QwtScaleMap & ) const;
110
111 virtual void drawColumn( QPainter *, const QwtColumnRect &,
112 const QwtIntervalSample & ) const;
113
114 void drawColumns( QPainter *,
115 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
116 int from, int to ) const;
117
118 void drawOutline( QPainter *,
119 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
120 int from, int to ) const;
121
122 void drawLines( QPainter *,
123 const QwtScaleMap &xMap, const QwtScaleMap &yMap,
124 int from, int to ) const;
125
126private:
127 void init();
128 void flushPolygon( QPainter *, double baseLine, QPolygonF & ) const;
129
130 class PrivateData;
131 PrivateData *d_data;
132};
133
134#endif
Note: See TracBrowser for help on using the repository browser.