A scale engine for date/time values. More...
#include <qwt_date_scale_engine.h>
Classes | |
class | PrivateData |
Public Member Functions | |
virtual void | autoScale (int maxNumSteps, double &x1, double &x2, double &stepSize) const QWT_OVERRIDE |
virtual QwtScaleDiv | divideScale (double x1, double x2, int maxMajorSteps, int maxMinorSteps, double stepSize=0.0) const QWT_OVERRIDE |
Calculate a scale division for a date/time interval. More... | |
virtual QwtDate::IntervalType | intervalType (const QDateTime &, const QDateTime &, int maxSteps) const |
int | maxWeeks () const |
QwtDateScaleEngine (Qt::TimeSpec=Qt::LocalTime) | |
Constructor. More... | |
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. More... | |
Public Member Functions inherited from QwtLinearScaleEngine | |
QwtLinearScaleEngine (uint base=10) | |
virtual | ~QwtLinearScaleEngine () |
Destructor. More... | |
Public Member Functions inherited from QwtScaleEngine | |
Attributes | attributes () const |
uint | base () const |
double | lowerMargin () const |
QwtScaleEngine (uint base=10) | |
double | reference () const |
void | setAttribute (Attribute, bool on=true) |
void | setAttributes (Attributes) |
void | setBase (uint base) |
void | setMargins (double lower, double upper) |
Specify margins at the scale's endpoints. More... | |
void | setReference (double) |
Specify a reference point. More... | |
void | setTransformation (QwtTransform *) |
bool | testAttribute (Attribute) const |
QwtTransform * | transformation () const |
double | upperMargin () const |
virtual | ~QwtScaleEngine () |
Destructor. More... | |
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... | |
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... | |
void | buildTicks (const QwtInterval &, double stepSize, int maxMinorSteps, QList< double > ticks[QwtScaleDiv::NTickTypes]) const |
Calculate ticks for an interval. More... | |
Protected Member Functions inherited from QwtScaleEngine | |
QwtInterval | buildInterval (double value) const |
Build an interval around a value. More... | |
bool | contains (const QwtInterval &, double value) const |
double | divideInterval (double intervalSize, int numSteps) const |
QList< double > | strip (const QList< double > &, const QwtInterval &) const |
Private Member Functions | |
QwtScaleDiv | buildScaleDiv (const QDateTime &, const QDateTime &, int maxMajorSteps, int maxMinorSteps, QwtDate::IntervalType) const |
Private Attributes | |
PrivateData * | m_data |
Additional Inherited Members | |
Public Types inherited from QwtScaleEngine | |
enum | Attribute { NoAttribute = 0x00, IncludeReference = 0x01, Symmetric = 0x02, Floating = 0x04, Inverted = 0x08 } |
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().
Definition at line 42 of file qwt_date_scale_engine.h.
|
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.
timeSpec | Time specification |
Definition at line 751 of file qwt_date_scale_engine.cpp.
|
virtual |
Destructor.
Definition at line 758 of file qwt_date_scale_engine.cpp.
|
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.
dateTime | Date/time value |
stepSize | Step size |
intervalType | Interval type |
up | When true dateTime is ceiled - otherwise it is floored |
Definition at line 1112 of file qwt_date_scale_engine.cpp.
|
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().
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) |
Reimplemented from QwtLinearScaleEngine.
Definition at line 929 of file qwt_date_scale_engine.cpp.
|
private |
Definition at line 1052 of file qwt_date_scale_engine.cpp.
|
virtual |
Calculate a scale division for a date/time interval.
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. |
Reimplemented from QwtLinearScaleEngine.
Definition at line 996 of file qwt_date_scale_engine.cpp.
|
virtual |
Classification of a date/time interval division
minDate | Minimum ( = earlier ) of the interval |
maxDate | Maximum ( = later ) of the interval |
maxSteps | Maximum for the number of steps |
Definition at line 869 of file qwt_date_scale_engine.cpp.
int QwtDateScaleEngine::maxWeeks | ( | ) | const |
Definition at line 855 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.
weeks | Upper limit for the number of weeks |
Definition at line 845 of file qwt_date_scale_engine.cpp.
void QwtDateScaleEngine::setTimeSpec | ( | Qt::TimeSpec | timeSpec | ) |
Set the time specification used by the engine
timeSpec | Time specification |
Definition at line 769 of file qwt_date_scale_engine.cpp.
void QwtDateScaleEngine::setUtcOffset | ( | int | seconds | ) |
Set the offset in seconds from Coordinated Universal Time
seconds | Offset in seconds |
Definition at line 793 of file qwt_date_scale_engine.cpp.
void QwtDateScaleEngine::setWeek0Type | ( | QwtDate::Week0Type | week0Type | ) |
Sets how to identify the first week of a year.
week0Type | Mode how to identify the first week of a year |
Definition at line 819 of file qwt_date_scale_engine.cpp.
Qt::TimeSpec QwtDateScaleEngine::timeSpec | ( | ) | const |
Definition at line 778 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()
Definition at line 1302 of file qwt_date_scale_engine.cpp.
int QwtDateScaleEngine::utcOffset | ( | ) | const |
Definition at line 805 of file qwt_date_scale_engine.cpp.
QwtDate::Week0Type QwtDateScaleEngine::week0Type | ( | ) | const |
Definition at line 828 of file qwt_date_scale_engine.cpp.
|
private |
Definition at line 91 of file qwt_date_scale_engine.h.