qwt_scale_div.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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_SCALE_DIV_H
  10. #define QWT_SCALE_DIV_H
  11. #include "qwt_global.h"
  12. #include "qwt_interval.h"
  13. #include <qlist.h>
  14. class QwtInterval;
  15. /*!
  16. \brief A class representing a scale division
  17. A scale division consists of its limits and 3 list
  18. of tick values qualified as major, medium and minor ticks.
  19. In most cases scale divisions are calculated by a QwtScaleEngine.
  20. \sa subDivideInto(), subDivide()
  21. */
  22. class QWT_EXPORT QwtScaleDiv
  23. {
  24. public:
  25. //! Scale tick types
  26. enum TickType
  27. {
  28. NoTick = -1,
  29. MinorTick,
  30. MediumTick,
  31. MajorTick,
  32. NTickTypes
  33. };
  34. explicit QwtScaleDiv();
  35. explicit QwtScaleDiv( const QwtInterval &, QList<double>[NTickTypes] );
  36. explicit QwtScaleDiv(
  37. double lowerBound, double upperBound, QList<double>[NTickTypes] );
  38. bool operator==( const QwtScaleDiv &s ) const;
  39. bool operator!=( const QwtScaleDiv &s ) const;
  40. void setInterval( double lowerBound, double upperBound );
  41. void setInterval( const QwtInterval & );
  42. QwtInterval interval() const;
  43. double lowerBound() const;
  44. double upperBound() const;
  45. double range() const;
  46. bool contains( double v ) const;
  47. void setTicks( int type, const QList<double> & );
  48. const QList<double> &ticks( int type ) const;
  49. void invalidate();
  50. bool isValid() const;
  51. void invert();
  52. private:
  53. double d_lowerBound;
  54. double d_upperBound;
  55. QList<double> d_ticks[NTickTypes];
  56. bool d_isValid;
  57. };
  58. /*!
  59. Change the interval
  60. \param lowerBound lower bound
  61. \param upperBound upper bound
  62. */
  63. inline void QwtScaleDiv::setInterval( double lowerBound, double upperBound )
  64. {
  65. d_lowerBound = lowerBound;
  66. d_upperBound = upperBound;
  67. }
  68. /*!
  69. \return lowerBound -> upperBound
  70. */
  71. inline QwtInterval QwtScaleDiv::interval() const
  72. {
  73. return QwtInterval( d_lowerBound, d_upperBound );
  74. }
  75. /*!
  76. \return lower bound
  77. \sa upperBound()
  78. */
  79. inline double QwtScaleDiv::lowerBound() const
  80. {
  81. return d_lowerBound;
  82. }
  83. /*!
  84. \return upper bound
  85. \sa lowerBound()
  86. */
  87. inline double QwtScaleDiv::upperBound() const
  88. {
  89. return d_upperBound;
  90. }
  91. /*!
  92. \return upperBound() - lowerBound()
  93. */
  94. inline double QwtScaleDiv::range() const
  95. {
  96. return d_upperBound - d_lowerBound;
  97. }
  98. #endif