Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
QwtDateScaleEngine Class Reference

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

#include <qwt_date_scale_engine.h>

Inheritance diagram for QwtDateScaleEngine:
Inheritance graph
[legend]

List of all members.

Classes

class  PrivateData

Public Member Functions

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.
virtual QwtDate::IntervalType intervalType (const QDateTime &, const QDateTime &, int maxSteps) const
int maxWeeks () const
 QwtDateScaleEngine (Qt::TimeSpec=Qt::LocalTime)
 Constructor.
void setMaxWeeks (int)
void setTimeSpec (Qt::TimeSpec)
void setUtcOffset (int seconds)
void setWeek0Type (QwtDate::Week0Type)
Qt::TimeSpec timeSpec () const
QDateTime toDateTime (double) const
int utcOffset () const
QwtDate::Week0Type week0Type () const
virtual ~QwtDateScaleEngine ()
 Destructor.

Protected Member Functions

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

Private Member Functions

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

Private Attributes

PrivateDatad_data

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

Definition at line 41 of file qwt_date_scale_engine.h.


Constructor & Destructor Documentation

QwtDateScaleEngine::QwtDateScaleEngine ( Qt::TimeSpec  timeSpec = Qt::LocalTime) [explicit]

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:
timeSpecTime specification
See also:
setTimeSpec(), setMaxWeeks(), setWeek0Type()

Definition at line 747 of file qwt_date_scale_engine.cpp.

Destructor.

Definition at line 754 of file qwt_date_scale_engine.cpp.


Member Function Documentation

QDateTime QwtDateScaleEngine::alignDate ( const QDateTime &  dateTime,
double  stepSize,
QwtDate::IntervalType  intervalType,
bool  up 
) const [protected, virtual]

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:
dateTimeDate/time value
stepSizeStep size
intervalTypeInterval type
upWhen true dateTime is ceiled - otherwise it is floored
Returns:
Aligned date/time value

Definition at line 1108 of file qwt_date_scale_engine.cpp.

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:
maxNumStepsMax. number of steps
x1First limit of the interval (In/Out)
x2Second limit of the interval (In/Out)
stepSizeStep size (Out)
See also:
QwtScaleEngine::setAttribute()

Reimplemented from QwtLinearScaleEngine.

Definition at line 925 of file qwt_date_scale_engine.cpp.

QwtScaleDiv QwtDateScaleEngine::buildScaleDiv ( const QDateTime &  minDate,
const QDateTime &  maxDate,
int  maxMajorSteps,
int  maxMinorSteps,
QwtDate::IntervalType  intervalType 
) const [private]

Definition at line 1048 of file qwt_date_scale_engine.cpp.

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:
x1First interval limit
x2Second interval limit
maxMajorStepsMaximum for the number of major steps
maxMinorStepsMaximum number of minor steps
stepSizeStep size. If stepSize == 0, the scaleEngine calculates one.
Returns:
Calculated scale division

Reimplemented from QwtLinearScaleEngine.

Definition at line 992 of file qwt_date_scale_engine.cpp.

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

Classification of a date/time interval division

Parameters:
minDateMinimum ( = earlier ) of the interval
maxDateMaximum ( = later ) of the interval
maxStepsMaximum for the number of steps
Returns:
Interval classification

Definition at line 865 of file qwt_date_scale_engine.cpp.

Returns:
Upper limit for the number of weeks, when an interval can be classified as Qt::Week.
See also:
setMaxWeeks(), week0Type()

Definition at line 851 of file qwt_date_scale_engine.cpp.

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:
weeksUpper limit for the number of weeks
Note:
In business charts a year is often devided into weeks [1-52]
See also:
maxWeeks(), setWeek0Type()

Definition at line 841 of file qwt_date_scale_engine.cpp.

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

Set the time specification used by the engine

Parameters:
timeSpecTime specification
See also:
timeSpec(), setUtcOffset(), toDateTime()

Definition at line 765 of file qwt_date_scale_engine.cpp.

void QwtDateScaleEngine::setUtcOffset ( int  seconds)

Set the offset in seconds from Coordinated Universal Time

Parameters:
secondsOffset in seconds
Note:
The offset has no effect beside for the time specification Qt::OffsetFromUTC.
See also:
QDate::utcOffset(), setTimeSpec(), toDateTime()

Definition at line 789 of file qwt_date_scale_engine.cpp.

Sets how to identify the first week of a year.

Parameters:
week0TypeMode 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.

Definition at line 815 of file qwt_date_scale_engine.cpp.

Qt::TimeSpec QwtDateScaleEngine::timeSpec ( ) const
Returns:
Time specification used by the engine
See also:
setTimeSpec(), utcOffset(), toDateTime()

Definition at line 774 of file qwt_date_scale_engine.cpp.

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

Definition at line 1290 of file qwt_date_scale_engine.cpp.

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

Definition at line 801 of file qwt_date_scale_engine.cpp.

Returns:
Setting how to identify the first week of a year.
See also:
setWeek0Type(), maxWeeks()

Definition at line 824 of file qwt_date_scale_engine.cpp.


Member Data Documentation

Reimplemented from QwtScaleEngine.

Definition at line 82 of file qwt_date_scale_engine.h.


The documentation for this class was generated from the following files:


plotjuggler
Author(s): Davide Faconti
autogenerated on Fri Sep 1 2017 02:41:57