qwt_date_scale_engine.h 2.23 KB
Newer Older
Bryant's avatar
Bryant committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#ifndef _QWT_DATE_SCALE_ENGINE_H_
#define _QWT_DATE_SCALE_ENGINE_H_ 1

#include "qwt_date.h"
#include "qwt_scale_engine.h"

/*!
  \brief A scale engine for date/time values

  QwtDateScaleEngine builds scales from a time intervals.
  Together with QwtDateScaleDraw it can be used for
  axes according to date/time values.

  Years, months, weeks, days, hours and minutes are organized
  in steps with non constant intervals. QwtDateScaleEngine
  classifies intervals and aligns the boundaries and tick positions
  according to this classification.

  QwtDateScaleEngine supports representations depending
  on Qt::TimeSpec specifications. The valid range for scales
  is limited by the range of QDateTime, that differs 
  between Qt4 and Qt5.
  
  Datetime values are expected as the number of milliseconds since
  1970-01-01T00:00:00 Universal Coordinated Time - also known
  as "The Epoch", that can be converted to QDateTime using 
  QwtDate::toDateTime().

  \sa QwtDate, QwtPlot::setAxisScaleEngine(),
      QwtAbstractScale::setScaleEngine()
*/
class QWT_EXPORT QwtDateScaleEngine: public QwtLinearScaleEngine
{
public:
    QwtDateScaleEngine( Qt::TimeSpec = Qt::LocalTime );
    virtual ~QwtDateScaleEngine();

    void setTimeSpec( Qt::TimeSpec );
    Qt::TimeSpec timeSpec() const;

    void setUtcOffset( int seconds );
    int utcOffset() const;

    void setWeek0Type( QwtDate::Week0Type );
    QwtDate::Week0Type week0Type() const;
    
    void setMaxWeeks( int );
    int maxWeeks() const;

    virtual void autoScale( int maxNumSteps,
        double &x1, double &x2, double &stepSize ) const;

    virtual QwtScaleDiv divideScale( 
        double x1, double x2,
        int maxMajorSteps, int maxMinorSteps,
        double stepSize = 0.0 ) const;

    virtual QwtDate::IntervalType intervalType( 
        const QDateTime &, const QDateTime &, int maxSteps ) const;

    QDateTime toDateTime( double ) const;

protected:
    virtual QDateTime alignDate( const QDateTime &, double stepSize,
        QwtDate::IntervalType, bool up ) const;

private:
    QwtScaleDiv buildScaleDiv( const QDateTime &, const QDateTime &,
        int maxMajorSteps, int maxMinorSteps, 
        QwtDate::IntervalType ) const;

private:
    class PrivateData;
    PrivateData *d_data;
};

#endif