qwt_plot_multi_barchart.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. #ifndef QWT_PLOT_MULTI_BAR_CHART_H
  10. #define QWT_PLOT_MULTI_BAR_CHART_H
  11. #include "qwt_global.h"
  12. #include "qwt_plot_abstract_barchart.h"
  13. #include "qwt_series_data.h"
  14. class QwtColumnRect;
  15. class QwtColumnSymbol;
  16. /*!
  17. \brief QwtPlotMultiBarChart displays a series of a samples that consist
  18. each of a set of values.
  19. Each value is displayed as a bar, the bars of each set can be organized
  20. side by side or accumulated.
  21. Each bar of a set is rendered by a QwtColumnSymbol, that is set by setSymbol().
  22. The bars of different sets use the same symbols. Exceptions are possible
  23. by overloading specialSymbol() or overloading drawBar().
  24. Depending on its orientation() the bars are displayed horizontally
  25. or vertically. The bars cover the interval between the baseline()
  26. and the value.
  27. In opposite to most other plot items, QwtPlotMultiBarChart returns more
  28. than one entry for the legend - one for each symbol.
  29. \sa QwtPlotBarChart, QwtPlotHistogram
  30. QwtPlotSeriesItem::orientation(), QwtPlotAbstractBarChart::baseline()
  31. */
  32. class QWT_EXPORT QwtPlotMultiBarChart:
  33. public QwtPlotAbstractBarChart, public QwtSeriesStore<QwtSetSample>
  34. {
  35. public:
  36. /*!
  37. \brief Chart styles.
  38. The default setting is QwtPlotMultiBarChart::Grouped.
  39. \sa setStyle(), style()
  40. */
  41. enum ChartStyle
  42. {
  43. //! The bars of a set are displayed side by side
  44. Grouped,
  45. /*!
  46. The bars are displayed on top of each other accumulating
  47. to a single bar. All values of a set need to have the same
  48. sign.
  49. */
  50. Stacked
  51. };
  52. explicit QwtPlotMultiBarChart( const QString &title = QString() );
  53. explicit QwtPlotMultiBarChart( const QwtText &title );
  54. virtual ~QwtPlotMultiBarChart();
  55. virtual int rtti() const;
  56. void setBarTitles( const QList<QwtText> & );
  57. QList<QwtText> barTitles() const;
  58. void setSamples( const QVector<QwtSetSample> & );
  59. void setSamples( const QVector< QVector<double> > & );
  60. void setSamples( QwtSeriesData<QwtSetSample> * );
  61. void setStyle( ChartStyle style );
  62. ChartStyle style() const;
  63. void setSymbol( int valueIndex, QwtColumnSymbol * );
  64. const QwtColumnSymbol *symbol( int valueIndex ) const;
  65. void resetSymbolMap();
  66. virtual void drawSeries( QPainter *painter,
  67. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  68. const QRectF &canvasRect, int from, int to ) const;
  69. virtual QRectF boundingRect() const;
  70. virtual QList<QwtLegendData> legendData() const;
  71. virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
  72. protected:
  73. QwtColumnSymbol *symbol( int valueIndex );
  74. virtual QwtColumnSymbol *specialSymbol(
  75. int sampleIndex, int valueIndex ) const;
  76. virtual void drawSample( QPainter *painter,
  77. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  78. const QRectF &canvasRect, const QwtInterval &boundingInterval,
  79. int index, const QwtSetSample& sample ) const;
  80. virtual void drawBar( QPainter *, int sampleIndex,
  81. int valueIndex, const QwtColumnRect & ) const;
  82. void drawStackedBars( QPainter *painter,
  83. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  84. const QRectF &canvasRect, int index,
  85. double sampleWidth, const QwtSetSample& sample ) const;
  86. void drawGroupedBars( QPainter *painter,
  87. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  88. const QRectF &canvasRect, int index,
  89. double sampleWidth, const QwtSetSample& sample ) const;
  90. private:
  91. void init();
  92. class PrivateData;
  93. PrivateData *d_data;
  94. };
  95. #endif