[8127] | 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_BAR_CHART_H
|
---|
| 11 | #define QWT_PLOT_BAR_CHART_H
|
---|
| 12 |
|
---|
| 13 | #include "qwt_global.h"
|
---|
| 14 | #include "qwt_plot_abstract_barchart.h"
|
---|
| 15 | #include "qwt_series_data.h"
|
---|
| 16 |
|
---|
| 17 | class QwtColumnRect;
|
---|
| 18 | class QwtColumnSymbol;
|
---|
| 19 |
|
---|
| 20 | /*!
|
---|
| 21 | \brief QwtPlotBarChart displays a series of a values as bars.
|
---|
| 22 |
|
---|
| 23 | Each bar might be customized individually by implementing
|
---|
| 24 | a specialSymbol(). Otherwise it is rendered using a default symbol.
|
---|
| 25 |
|
---|
[9383] | 26 | Depending on its orientation() the bars are displayed horizontally
|
---|
| 27 | or vertically. The bars cover the interval between the baseline()
|
---|
[8127] | 28 | and the value.
|
---|
| 29 |
|
---|
| 30 | By activating the LegendBarTitles mode each sample will have
|
---|
| 31 | its own entry on the legend.
|
---|
| 32 |
|
---|
| 33 | The most common use case of a bar chart is to display a
|
---|
| 34 | list of y coordinates, where the x coordinate is simply the index
|
---|
| 35 | in the list. But for other situations ( f.e. when values are related
|
---|
| 36 | to dates ) it is also possible to set x coordinates explicitly.
|
---|
| 37 |
|
---|
| 38 | \sa QwtPlotMultiBarChart, QwtPlotHistogram, QwtPlotCurve::Sticks,
|
---|
| 39 | QwtPlotSeriesItem::orientation(), QwtPlotAbstractBarChart::baseline()
|
---|
| 40 | */
|
---|
| 41 | class QWT_EXPORT QwtPlotBarChart:
|
---|
| 42 | public QwtPlotAbstractBarChart, public QwtSeriesStore<QPointF>
|
---|
| 43 | {
|
---|
| 44 | public:
|
---|
| 45 | /*!
|
---|
| 46 | \brief Legend modes.
|
---|
| 47 |
|
---|
| 48 | The default setting is QwtPlotBarChart::LegendChartTitle.
|
---|
| 49 | \sa setLegendMode(), legendMode()
|
---|
| 50 | */
|
---|
| 51 | enum LegendMode
|
---|
| 52 | {
|
---|
[9383] | 53 | /*!
|
---|
[8127] | 54 | One entry on the legend showing the default symbol
|
---|
| 55 | and the title() of the chart
|
---|
| 56 |
|
---|
| 57 | \sa QwtPlotItem::title()
|
---|
| 58 | */
|
---|
| 59 | LegendChartTitle,
|
---|
| 60 |
|
---|
| 61 | /*!
|
---|
| 62 | One entry for each value showing the individual symbol
|
---|
| 63 | of the corresponding bar and the bar title.
|
---|
| 64 |
|
---|
| 65 | \sa specialSymbol(), barTitle()
|
---|
| 66 | */
|
---|
| 67 | LegendBarTitles
|
---|
| 68 | };
|
---|
| 69 |
|
---|
[9383] | 70 | explicit QwtPlotBarChart( const QString &title = QString() );
|
---|
[8127] | 71 | explicit QwtPlotBarChart( const QwtText &title );
|
---|
| 72 |
|
---|
| 73 | virtual ~QwtPlotBarChart();
|
---|
| 74 |
|
---|
| 75 | virtual int rtti() const;
|
---|
| 76 |
|
---|
| 77 | void setSamples( const QVector<QPointF> & );
|
---|
| 78 | void setSamples( const QVector<double> & );
|
---|
[9383] | 79 | void setSamples( QwtSeriesData<QPointF> * );
|
---|
[8127] | 80 |
|
---|
| 81 | void setSymbol( QwtColumnSymbol * );
|
---|
| 82 | const QwtColumnSymbol *symbol() const;
|
---|
| 83 |
|
---|
| 84 | void setLegendMode( LegendMode );
|
---|
| 85 | LegendMode legendMode() const;
|
---|
| 86 |
|
---|
| 87 | virtual void drawSeries( QPainter *painter,
|
---|
| 88 | const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
---|
| 89 | const QRectF &canvasRect, int from, int to ) const;
|
---|
| 90 |
|
---|
| 91 | virtual QRectF boundingRect() const;
|
---|
| 92 |
|
---|
[9383] | 93 | virtual QwtColumnSymbol *specialSymbol(
|
---|
[8127] | 94 | int sampleIndex, const QPointF& ) const;
|
---|
| 95 |
|
---|
| 96 | virtual QwtText barTitle( int sampleIndex ) const;
|
---|
| 97 |
|
---|
| 98 | protected:
|
---|
| 99 | virtual void drawSample( QPainter *painter,
|
---|
| 100 | const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
---|
| 101 | const QRectF &canvasRect, const QwtInterval &boundingInterval,
|
---|
| 102 | int index, const QPointF& sample ) const;
|
---|
| 103 |
|
---|
| 104 | virtual void drawBar( QPainter *,
|
---|
[9383] | 105 | int sampleIndex, const QPointF& sample,
|
---|
[8127] | 106 | const QwtColumnRect & ) const;
|
---|
| 107 |
|
---|
| 108 | QList<QwtLegendData> legendData() const;
|
---|
| 109 | QwtGraphic legendIcon( int index, const QSizeF & ) const;
|
---|
| 110 |
|
---|
| 111 | private:
|
---|
| 112 | void init();
|
---|
| 113 |
|
---|
| 114 | class PrivateData;
|
---|
| 115 | PrivateData *d_data;
|
---|
| 116 | };
|
---|
| 117 |
|
---|
| 118 | #endif
|
---|