qwt_scale_div.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #ifndef QT_NO_DEBUG_STREAM
  15. #include <qdebug.h>
  16. #endif
  17. /*!
  18. \brief A class representing a scale division
  19. A Qwt scale is defined by its boundaries and 3 list
  20. for the positions of the major, medium and minor ticks.
  21. The upperBound() might be smaller than the lowerBound()
  22. to indicate inverted scales.
  23. Scale divisions can be calculated from a QwtScaleEngine.
  24. \sa QwtScaleEngine::divideScale(), QwtPlot::setAxisScaleDiv(),
  25. QwtAbstractSlider::setScaleDiv()
  26. */
  27. class QWT_EXPORT QwtScaleDiv
  28. {
  29. public:
  30. //! Scale tick types
  31. enum TickType
  32. {
  33. //! No ticks
  34. NoTick = -1,
  35. //! Minor ticks
  36. MinorTick,
  37. //! Medium ticks
  38. MediumTick,
  39. //! Major ticks
  40. MajorTick,
  41. //! Number of valid tick types
  42. NTickTypes
  43. };
  44. explicit QwtScaleDiv( double lowerBound = 0.0,
  45. double upperBound = 0.0 );
  46. explicit QwtScaleDiv( const QwtInterval &, QList<double>[NTickTypes] );
  47. explicit QwtScaleDiv( double lowerBound, double upperBound,
  48. QList<double>[NTickTypes] );
  49. explicit QwtScaleDiv( double lowerBound, double upperBound,
  50. const QList<double> &minorTicks, const QList<double> &mediumTicks,
  51. const QList<double> &majorTicks );
  52. bool operator==( const QwtScaleDiv & ) const;
  53. bool operator!=( const QwtScaleDiv & ) const;
  54. void setInterval( double lowerBound, double upperBound );
  55. void setInterval( const QwtInterval & );
  56. QwtInterval interval() const;
  57. void setLowerBound( double );
  58. double lowerBound() const;
  59. void setUpperBound( double );
  60. double upperBound() const;
  61. double range() const;
  62. bool contains( double value ) const;
  63. void setTicks( int tickType, const QList<double> & );
  64. QList<double> ticks( int tickType ) const;
  65. bool isEmpty() const;
  66. bool isIncreasing() const;
  67. void invert();
  68. QwtScaleDiv inverted() const;
  69. QwtScaleDiv bounded( double lowerBound, double upperBound ) const;
  70. private:
  71. double d_lowerBound;
  72. double d_upperBound;
  73. QList<double> d_ticks[NTickTypes];
  74. };
  75. Q_DECLARE_TYPEINFO( QwtScaleDiv, Q_MOVABLE_TYPE );
  76. #ifndef QT_NO_DEBUG_STREAM
  77. QWT_EXPORT QDebug operator<<( QDebug, const QwtScaleDiv & );
  78. #endif
  79. #endif