qwt_plot_abstract_barchart.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_ABSTRACT_BAR_CHART_H
  10. #define QWT_PLOT_ABSTRACT_BAR_CHART_H
  11. #include "qwt_global.h"
  12. #include "qwt_plot_seriesitem.h"
  13. #include "qwt_series_data.h"
  14. /*!
  15. \brief Abstract base class for bar chart items
  16. In opposite to almost all other plot items bar charts can't be
  17. displayed inside of their bounding rectangle and need a special
  18. API how to calculate the width of the bars and how they affect
  19. the layout of the attached plot.
  20. */
  21. class QWT_EXPORT QwtPlotAbstractBarChart: public QwtPlotSeriesItem
  22. {
  23. public:
  24. /*!
  25. \brief Mode how to calculate the bar width
  26. setLayoutPolicy(), setLayoutHint(), barWidthHint()
  27. */
  28. enum LayoutPolicy
  29. {
  30. /*!
  31. The sample width is calculated by dividing the bounding rectangle
  32. by the number of samples. The layoutHint() is used as a minimum width
  33. in paint device coordinates.
  34. \sa boundingRectangle()
  35. */
  36. AutoAdjustSamples,
  37. /*!
  38. layoutHint() defines an interval in axis coordinates
  39. */
  40. ScaleSamplesToAxes,
  41. /*!
  42. The bar width is calculated by multiplying layoutHint()
  43. with the height or width of the canvas.
  44. \sa boundingRectangle()
  45. */
  46. ScaleSampleToCanvas,
  47. /*!
  48. layoutHint() defines a fixed width in paint device coordinates.
  49. */
  50. FixedSampleSize
  51. };
  52. explicit QwtPlotAbstractBarChart( const QwtText &title );
  53. virtual ~QwtPlotAbstractBarChart();
  54. void setLayoutPolicy( LayoutPolicy );
  55. LayoutPolicy layoutPolicy() const;
  56. void setLayoutHint( double );
  57. double layoutHint() const;
  58. void setSpacing( int );
  59. int spacing() const;
  60. void setMargin( int );
  61. int margin() const;
  62. void setBaseline( double );
  63. double baseline() const;
  64. virtual void getCanvasMarginHint(
  65. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  66. const QRectF &canvasRect,
  67. double &left, double &top, double &right, double &bottom) const;
  68. protected:
  69. double sampleWidth( const QwtScaleMap &map,
  70. double canvasSize, double boundingSize,
  71. double value ) const;
  72. private:
  73. class PrivateData;
  74. PrivateData *d_data;
  75. };
  76. #endif