qwt_plot_seriesitem.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. #include "qwt_plot_seriesitem.h"
  10. class QwtPlotAbstractSeriesItem::PrivateData
  11. {
  12. public:
  13. PrivateData():
  14. orientation( Qt::Vertical )
  15. {
  16. }
  17. Qt::Orientation orientation;
  18. };
  19. /*!
  20. Constructor
  21. \param title Title of the curve
  22. */
  23. QwtPlotAbstractSeriesItem::QwtPlotAbstractSeriesItem( const QwtText &title ):
  24. QwtPlotItem( title )
  25. {
  26. d_data = new PrivateData();
  27. }
  28. /*!
  29. Constructor
  30. \param title Title of the curve
  31. */
  32. QwtPlotAbstractSeriesItem::QwtPlotAbstractSeriesItem( const QString &title ):
  33. QwtPlotItem( QwtText( title ) )
  34. {
  35. d_data = new PrivateData();
  36. }
  37. //! Destructor
  38. QwtPlotAbstractSeriesItem::~QwtPlotAbstractSeriesItem()
  39. {
  40. delete d_data;
  41. }
  42. /*!
  43. Set the orientation of the item.
  44. The orientation() might be used in specific way by a plot item.
  45. F.e. a QwtPlotCurve uses it to identify how to display the curve
  46. int QwtPlotCurve::Steps or QwtPlotCurve::Sticks style.
  47. \sa orientation()
  48. */
  49. void QwtPlotAbstractSeriesItem::setOrientation( Qt::Orientation orientation )
  50. {
  51. if ( d_data->orientation != orientation )
  52. {
  53. d_data->orientation = orientation;
  54. itemChanged();
  55. }
  56. }
  57. /*!
  58. \return Orientation of the plot item
  59. \sa setOrientation()
  60. */
  61. Qt::Orientation QwtPlotAbstractSeriesItem::orientation() const
  62. {
  63. return d_data->orientation;
  64. }
  65. /*!
  66. \brief Draw the complete series
  67. \param painter Painter
  68. \param xMap Maps x-values into pixel coordinates.
  69. \param yMap Maps y-values into pixel coordinates.
  70. \param canvasRect Contents rect of the canvas
  71. */
  72. void QwtPlotAbstractSeriesItem::draw( QPainter *painter,
  73. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  74. const QRectF &canvasRect ) const
  75. {
  76. drawSeries( painter, xMap, yMap, canvasRect, 0, -1 );
  77. }