Qwt User's Guide 6.1.3

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | List of all members
QwtDateScaleEngine Class Reference

A scale engine for date/time values. More...

`#include <qwt_date_scale_engine.h>`

Inheritance diagram for QwtDateScaleEngine:
[legend]

## Public Member Functions
| QwtDateScaleEngine (Qt::TimeSpec=Qt::LocalTime)
| Constructor. More...
virtual | ~QwtDateScaleEngine ()
| Destructor.
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
| Calculate a scale division for a date/time interval. More...
virtual QwtDate::IntervalType | intervalType (const QDateTime &, const QDateTime &, int maxSteps) const
QDateTime | toDateTime (double) const
Public Member Functions inherited from QwtLinearScaleEngine
| QwtLinearScaleEngine (uint base=10)
virtual | ~QwtLinearScaleEngine ()
| Destructor.
Public Member Functions inherited from QwtScaleEngine
| QwtScaleEngine (uint base=10)
virtual | ~QwtScaleEngine ()
| Destructor.
void | setBase (uint base)
uint | base () const
void | setAttribute (Attribute, bool on=true)
bool | testAttribute (Attribute) const
void | setAttributes (Attributes)
Attributes | attributes () const
void | setReference (double reference)
| Specify a reference point. More...
double | reference () const
void | setMargins (double lower, double upper)
| Specify margins at the scale's endpoints. More...
double | lowerMargin () const
double | upperMargin () const
void | setTransformation (QwtTransform *)
QwtTransform * | transformation () const

## Protected Member Functions
virtual QDateTime | alignDate (const QDateTime &, double stepSize, QwtDate::IntervalType, bool up) const
Protected Member Functions inherited from QwtLinearScaleEngine
QwtInterval | align (const QwtInterval &, double stepSize) const
| Align an interval to a step size. More...
void | buildTicks (const QwtInterval &, double stepSize, int maxMinSteps, QList< double > ticks[QwtScaleDiv::NTickTypes]) const
| Calculate ticks for an interval. More...
QList< double > | buildMajorTicks (const QwtInterval &interval, double stepSize) const
| Calculate major ticks for an interval. More...
void | buildMinorTicks (const QList< double > &majorTicks, int maxMinorSteps, double stepSize, QList< double > &minorTicks, QList< double > &mediumTicks) const
| Calculate minor/medium ticks for major ticks. More...
Protected Member Functions inherited from QwtScaleEngine
bool | contains (const QwtInterval &, double val) const
QList< double > | strip (const QList< double > &, const QwtInterval &) const
double | divideInterval (double interval, int numSteps) const
QwtInterval | buildInterval (double v) const
| Build an interval around a value. More...

## Additional Inherited Members
Public Types inherited from QwtScaleEngine
enum | Attribute { NoAttribute = 0x00, IncludeReference = 0x01, Symmetric = 0x02, Floating = 0x04, Inverted = 0x08 }
typedef QFlags< Attribute > | Attributes
| Layout attributes.

## Detailed Description

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().

See also
  QwtDate, QwtPlot::setAxisScaleEngine(), QwtAbstractScale::setScaleEngine()

## Constructor & Destructor Documentation

QwtDateScaleEngine::QwtDateScaleEngine | ( | Qt::TimeSpec | timeSpec = `Qt::LocalTime` | ) |

Constructor.

The engine is initialized to build scales for the given time specification. It classifies intervals > 4 weeks as >= Qt::Month. The first week of a year is defined like for QwtDate::FirstThursday.

Parameters

  timeSpec | Time specification

See also
  setTimeSpec(), setMaxWeeks(), setWeek0Type()

## Member Function Documentation

QDateTime QwtDateScaleEngine::alignDate | ( | const QDateTime & | dateTime,
|  | double | stepSize,
|  | QwtDate::IntervalType | intervalType,
|  | bool | up
| ) |  | const
| protectedvirtual

Align a date/time value for a step size

For Qt::Day alignments there is no "natural day 0" - instead the first day of the year is used to avoid jumping major ticks positions when panning a scale. For other alignments ( f.e according to the first day of the month ) alignDate() has to be overloaded.

Parameters

  dateTime | Date/time value
  stepSize | Step size
  intervalType | Interval type
  up | When true dateTime is ceiled - otherwise it is floored

Returns
  Aligned date/time value

void QwtDateScaleEngine::autoScale | ( | int | maxNumSteps,
|  | double & | x1,
|  | double & | x2,
|  | double & | stepSize
| ) |  | const
| virtual

Align and divide an interval

The algorithm aligns and divides the interval into steps.

Datetime interval divisions are usually not equidistant and the calculated stepSize can only be used as an approximation for the steps calculated by divideScale().

Parameters

  maxNumSteps | Max. number of steps
  x1 | First limit of the interval (In/Out)
  x2 | Second limit of the interval (In/Out)
  stepSize | Step size (Out)

See also
  QwtScaleEngine::setAttribute()

Reimplemented from QwtLinearScaleEngine.

QwtScaleDiv QwtDateScaleEngine::divideScale | ( | double | x1,
|  | double | x2,
|  | int | maxMajorSteps,
|  | int | maxMinorSteps,
|  | double | stepSize = `0.0`
| ) |  | const
| virtual

Calculate a scale division for a date/time interval.

Parameters

  x1 | First interval limit
  x2 | Second interval limit
  maxMajorSteps | Maximum for the number of major steps
  maxMinorSteps | Maximum number of minor steps
  stepSize | Step size. If stepSize == 0, the scaleEngine calculates one.

Returns
  Calculated scale division

Reimplemented from QwtLinearScaleEngine.

QwtDate::IntervalType QwtDateScaleEngine::intervalType | ( | const QDateTime & | minDate,
|  | const QDateTime & | maxDate,
|  | int | maxSteps
| ) |  | const
| virtual

Classification of a date/time interval division

Parameters

  minDate | Minimum ( = earlier ) of the interval
  maxDate | Maximum ( = later ) of the interval
  maxSteps | Maximum for the number of steps

Returns
  Interval classification

int QwtDateScaleEngine::maxWeeks | ( |  | ) | const

Returns
  Upper limit for the number of weeks, when an interval can be classified as Qt::Week.

See also
  setMaxWeeks(), week0Type()

void QwtDateScaleEngine::setMaxWeeks | ( | int | weeks | ) |

Set a upper limit for the number of weeks, when an interval can be classified as Qt::Week.

The default setting is 4 weeks.

Parameters

  weeks | Upper limit for the number of weeks

Note
  In business charts a year is often devided into weeks [1-52]

See also
  maxWeeks(), setWeek0Type()

void QwtDateScaleEngine::setTimeSpec | ( | Qt::TimeSpec | timeSpec | ) |

Set the time specification used by the engine

Parameters

  timeSpec | Time specification

See also
  timeSpec(), setUtcOffset(), toDateTime()

void QwtDateScaleEngine::setUtcOffset | ( | int | seconds | ) |

Set the offset in seconds from Coordinated Universal Time

Parameters

  seconds | Offset in seconds

Note
  The offset has no effect beside for the time specification Qt::OffsetFromUTC.

See also
  QDate::utcOffset(), setTimeSpec(), toDateTime()

void QwtDateScaleEngine::setWeek0Type | ( | QwtDate::Week0Type | week0Type | ) |

Sets how to identify the first week of a year.

Parameters

  week0Type | Mode how to identify the first week of a year

See also
  week0Type(), setMaxWeeks()

Note
  week0Type has no effect beside for intervals classified as QwtDate::Week.

Qt::TimeSpec QwtDateScaleEngine::timeSpec | ( |  | ) | const

Returns
  Time specification used by the engine

See also
  setTimeSpec(), utcOffset(), toDateTime()

QDateTime QwtDateScaleEngine::toDateTime | ( | double | value | ) | const

Translate a double value into a QDateTime object.

For QDateTime result is bounded by QwtDate::minDate() and QwtDate::maxDate()

Returns
  QDateTime object initialized with timeSpec() and utcOffset().

See also
  timeSpec(), utcOffset(), QwtDate::toDateTime()

int QwtDateScaleEngine::utcOffset | ( |  | ) | const

Returns
  Offset in seconds from Coordinated Universal Time

Note
  The offset has no effect beside for the time specification Qt::OffsetFromUTC.

See also
  QDate::setUtcOffset(), setTimeSpec(), toDateTime()

QwtDate::Week0Type QwtDateScaleEngine::week0Type | ( |  | ) | const

Returns
  Setting how to identify the first week of a year.

See also
  setWeek0Type(), maxWeeks()