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