qwt_double_range.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_DOUBLE_RANGE_H
  10. #define QWT_DOUBLE_RANGE_H
  11. #include "qwt_global.h"
  12. /*!
  13. \brief A class which controls a value within an interval
  14. This class is useful as a base class or a member for sliders.
  15. It represents an interval of type double within which a value can
  16. be moved. The value can be either an arbitrary point inside
  17. the interval (see QwtDoubleRange::setValue), or it can be fitted
  18. into a step raster (see QwtDoubleRange::fitValue and
  19. QwtDoubleRange::incValue).
  20. As a special case, a QwtDoubleRange can be periodic, which means that
  21. a value outside the interval will be mapped to a value inside the
  22. interval when QwtDoubleRange::setValue(), QwtDoubleRange::fitValue(),
  23. QwtDoubleRange::incValue() or QwtDoubleRange::incPages() are called.
  24. */
  25. class QWT_EXPORT QwtDoubleRange
  26. {
  27. public:
  28. QwtDoubleRange();
  29. virtual ~QwtDoubleRange();
  30. void setRange( double vmin, double vmax,
  31. double vstep = 0.0, int pagesize = 1 );
  32. void setValid( bool );
  33. bool isValid() const;
  34. virtual void setValue( double );
  35. double value() const;
  36. void setPeriodic( bool tf );
  37. bool periodic() const;
  38. void setStep( double );
  39. double step() const;
  40. double maxValue() const;
  41. double minValue() const;
  42. int pageSize() const;
  43. virtual void incValue( int );
  44. virtual void incPages( int );
  45. virtual void fitValue( double );
  46. protected:
  47. double exactValue() const;
  48. double exactPrevValue() const;
  49. double prevValue() const;
  50. virtual void valueChange();
  51. virtual void stepChange();
  52. virtual void rangeChange();
  53. private:
  54. void setNewValue( double x, bool align = false );
  55. double d_minValue;
  56. double d_maxValue;
  57. double d_step;
  58. int d_pageSize;
  59. bool d_isValid;
  60. double d_value;
  61. double d_exactValue;
  62. double d_exactPrevValue;
  63. double d_prevValue;
  64. bool d_periodic;
  65. };
  66. #endif