qwt_date_scale_engine.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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_DATE_SCALE_ENGINE_H_
  10. #define _QWT_DATE_SCALE_ENGINE_H_ 1
  11. #include "qwt_date.h"
  12. #include "qwt_scale_engine.h"
  13. /*!
  14. \brief A scale engine for date/time values
  15. QwtDateScaleEngine builds scales from a time intervals.
  16. Together with QwtDateScaleDraw it can be used for
  17. axes according to date/time values.
  18. Years, months, weeks, days, hours and minutes are organized
  19. in steps with non constant intervals. QwtDateScaleEngine
  20. classifies intervals and aligns the boundaries and tick positions
  21. according to this classification.
  22. QwtDateScaleEngine supports representations depending
  23. on Qt::TimeSpec specifications. The valid range for scales
  24. is limited by the range of QDateTime, that differs
  25. between Qt4 and Qt5.
  26. Datetime values are expected as the number of milliseconds since
  27. 1970-01-01T00:00:00 Universal Coordinated Time - also known
  28. as "The Epoch", that can be converted to QDateTime using
  29. QwtDate::toDateTime().
  30. \sa QwtDate, QwtPlot::setAxisScaleEngine(),
  31. QwtAbstractScale::setScaleEngine()
  32. */
  33. class QWT_EXPORT QwtDateScaleEngine: public QwtLinearScaleEngine
  34. {
  35. public:
  36. QwtDateScaleEngine( Qt::TimeSpec = Qt::LocalTime );
  37. virtual ~QwtDateScaleEngine();
  38. void setTimeSpec( Qt::TimeSpec );
  39. Qt::TimeSpec timeSpec() const;
  40. void setUtcOffset( int seconds );
  41. int utcOffset() const;
  42. void setWeek0Type( QwtDate::Week0Type );
  43. QwtDate::Week0Type week0Type() const;
  44. void setMaxWeeks( int );
  45. int maxWeeks() const;
  46. virtual void autoScale( int maxNumSteps,
  47. double &x1, double &x2, double &stepSize ) const;
  48. virtual QwtScaleDiv divideScale(
  49. double x1, double x2,
  50. int maxMajorSteps, int maxMinorSteps,
  51. double stepSize = 0.0 ) const;
  52. virtual QwtDate::IntervalType intervalType(
  53. const QDateTime &, const QDateTime &, int maxSteps ) const;
  54. QDateTime toDateTime( double ) const;
  55. protected:
  56. virtual QDateTime alignDate( const QDateTime &, double stepSize,
  57. QwtDate::IntervalType, bool up ) const;
  58. private:
  59. QwtScaleDiv buildScaleDiv( const QDateTime &, const QDateTime &,
  60. int maxMajorSteps, int maxMinorSteps,
  61. QwtDate::IntervalType ) const;
  62. private:
  63. class PrivateData;
  64. PrivateData *d_data;
  65. };
  66. #endif