A class representing a scale division. More...
#include <qwt_scale_div.h>
Public Types | |
enum | TickType { NoTick = -1, MinorTick, MediumTick, MajorTick, NTickTypes } |
Scale tick types. More... | |
Public Member Functions | |
QwtScaleDiv () | |
Construct an invalid QwtScaleDiv instance. | |
QwtScaleDiv (const QwtDoubleInterval &, QwtValueList[NTickTypes]) | |
QwtScaleDiv (double lowerBound, double upperBound, QwtValueList[NTickTypes]) | |
int | operator== (const QwtScaleDiv &s) const |
Equality operator. | |
int | operator!= (const QwtScaleDiv &s) const |
Inequality. | |
void | setInterval (double lowerBound, double upperBound) |
void | setInterval (const QwtDoubleInterval &) |
QwtDoubleInterval | interval () const |
double | lowerBound () const |
double | upperBound () const |
double | range () const |
bool | contains (double v) const |
void | setTicks (int type, const QwtValueList &) |
const QwtValueList & | ticks (int type) const |
void | invalidate () |
Invalidate the scale division. | |
bool | isValid () const |
Check if the scale division is valid. | |
void | invert () |
Invert the scale divison. |
A class representing a scale division.
A scale division consists of its limits and 3 list of tick values qualified as major, medium and minor ticks.
In most cases scale divisions are calculated by a QwtScaleEngine.
Definition at line 30 of file qwt_scale_div.h.
Scale tick types.
Definition at line 34 of file qwt_scale_div.h.
{ NoTick = -1, MinorTick, MediumTick, MajorTick, NTickTypes };
QwtScaleDiv::QwtScaleDiv | ( | ) | [explicit] |
Construct an invalid QwtScaleDiv instance.
Definition at line 15 of file qwt_scale_div.cpp.
:
d_lowerBound(0.0),
d_upperBound(0.0),
d_isValid(false)
{
}
QwtScaleDiv::QwtScaleDiv | ( | const QwtDoubleInterval & | interval, |
QwtValueList | ticks[NTickTypes] | ||
) | [explicit] |
Construct QwtScaleDiv instance.
interval | Interval |
ticks | List of major, medium and minor ticks |
Definition at line 28 of file qwt_scale_div.cpp.
References NTickTypes, and ticks().
: d_lowerBound(interval.minValue()), d_upperBound(interval.maxValue()), d_isValid(true) { for ( int i = 0; i < NTickTypes; i++ ) d_ticks[i] = ticks[i]; }
QwtScaleDiv::QwtScaleDiv | ( | double | lowerBound, |
double | upperBound, | ||
QwtValueList | ticks[NTickTypes] | ||
) | [explicit] |
Construct QwtScaleDiv instance.
lowerBound | First interval limit |
upperBound | Second interval limit |
ticks | List of major, medium and minor ticks |
Definition at line 46 of file qwt_scale_div.cpp.
References NTickTypes, and ticks().
: d_lowerBound(lowerBound), d_upperBound(upperBound), d_isValid(true) { for ( int i = 0; i < NTickTypes; i++ ) d_ticks[i] = ticks[i]; }
bool QwtScaleDiv::contains | ( | double | value ) | const |
Return if a value is between lowerBound() and upperBound()
value | Value |
Definition at line 121 of file qwt_scale_div.cpp.
References QuadProgPP::max(), min, qwtMax, and qwtMin.
Referenced by QwtRoundScaleDraw::extent(), QwtScaleDraw::maxLabelHeight(), and QwtScaleDraw::maxLabelWidth().
QwtDoubleInterval QwtScaleDiv::interval | ( | ) | const [inline] |
Definition at line 94 of file qwt_scale_div.h.
{ return QwtDoubleInterval(d_lowerBound, d_upperBound); }
void QwtScaleDiv::invalidate | ( | ) |
Invalidate the scale division.
Definition at line 98 of file qwt_scale_div.cpp.
References NTickTypes.
Referenced by QwtPlot::setAxisMaxMajor(), QwtPlot::setAxisMaxMinor(), QwtPlot::setAxisScale(), QwtPlot::setAxisScaleEngine(), and QwtPlot::updateAxes().
{ d_isValid = false; // detach arrays for ( int i = 0; i < NTickTypes; i++ ) d_ticks[i].clear(); d_lowerBound = d_upperBound = 0; }
void QwtScaleDiv::invert | ( | ) |
Invert the scale divison.
Definition at line 133 of file qwt_scale_div.cpp.
References NTickTypes, and ticks().
Referenced by QwtLog10ScaleEngine::divideScale(), and QwtLinearScaleEngine::divideScale().
{ qSwap(d_lowerBound, d_upperBound); for ( int i = 0; i < NTickTypes; i++ ) { QwtValueList& ticks = d_ticks[i]; const int size = ticks.count(); const int size2 = size / 2; for (int i=0; i < size2; i++) qSwap(ticks[i], ticks[size - 1 - i]); } }
bool QwtScaleDiv::isValid | ( | ) | const |
Check if the scale division is valid.
Definition at line 110 of file qwt_scale_div.cpp.
Referenced by QwtPlotMagnifier::rescale(), and QwtPlot::updateAxes().
{
return d_isValid;
}
double QwtScaleDiv::lowerBound | ( | ) | const [inline] |
Definition at line 103 of file qwt_scale_div.h.
Referenced by QwtPlot::canvasMap(), QwtPlotRescaler::interval(), QwtPlotPanner::moveCanvas(), QwtPlot::print(), QwtPlotZoomer::rescale(), QwtPlotMagnifier::rescale(), QwtPlotPicker::scaleRect(), setInterval(), QwtAbstractScaleDraw::setScaleDiv(), and QwtPlotRescaler::updateScales().
{
return d_lowerBound;
}
int QwtScaleDiv::operator!= | ( | const QwtScaleDiv & | s ) | const |
Inequality.
Definition at line 92 of file qwt_scale_div.cpp.
{ return (!(*this == s)); }
int QwtScaleDiv::operator== | ( | const QwtScaleDiv & | other ) | const |
Equality operator.
Definition at line 70 of file qwt_scale_div.cpp.
References NTickTypes.
{ if ( d_lowerBound != other.d_lowerBound || d_upperBound != other.d_upperBound || d_isValid != other.d_isValid ) { return false; } for ( int i = 0; i < NTickTypes; i++ ) { if ( d_ticks[i] != other.d_ticks[i] ) return false; } return true; }
double QwtScaleDiv::range | ( | ) | const [inline] |
Definition at line 120 of file qwt_scale_div.h.
Referenced by QwtPlotMagnifier::rescale(), and QwtPlotPicker::scaleRect().
{
return d_upperBound - d_lowerBound;
}
void QwtScaleDiv::setInterval | ( | const QwtDoubleInterval & | interval ) |
Change the interval
interval | Interval |
Definition at line 61 of file qwt_scale_div.cpp.
References QwtDoubleInterval::maxValue(), QwtDoubleInterval::minValue(), and setInterval().
{ setInterval(interval.minValue(), interval.maxValue()); }
void QwtScaleDiv::setInterval | ( | double | lowerBound, |
double | upperBound | ||
) | [inline] |
Change the interval
lowerBound | lower bound |
upperBound | upper bound |
Definition at line 85 of file qwt_scale_div.h.
References lowerBound(), and upperBound().
Referenced by setInterval().
{ d_lowerBound = lowerBound; d_upperBound = upperBound; }
void QwtScaleDiv::setTicks | ( | int | type, |
const QwtValueList & | ticks | ||
) |
Assign ticks
type | MinorTick, MediumTick or MajorTick |
ticks | Values of the tick positions |
Definition at line 155 of file qwt_scale_div.cpp.
References NTickTypes, and ticks().
{ if ( type >= 0 || type < NTickTypes ) d_ticks[type] = ticks; }
const QwtValueList & QwtScaleDiv::ticks | ( | int | type ) | const |
Return a list of ticks
type | MinorTick, MediumTick or MajorTick |
Definition at line 166 of file qwt_scale_div.cpp.
References NTickTypes.
Referenced by QwtPlotGrid::draw(), QwtRoundScaleDraw::extent(), QwtScaleDraw::getBorderDistHint(), invert(), QwtScaleDraw::maxLabelHeight(), QwtScaleDraw::maxLabelWidth(), QwtScaleDraw::minLabelDist(), QwtScaleDraw::minLength(), QwtScaleDiv(), setTicks(), QwtPlot::sizeHint(), and QwtPlotRescaler::updateScales().
{ if ( type >= 0 || type < NTickTypes ) return d_ticks[type]; static QwtValueList noTicks; return noTicks; }
double QwtScaleDiv::upperBound | ( | ) | const [inline] |
Definition at line 112 of file qwt_scale_div.h.
Referenced by QwtPlot::canvasMap(), QwtPlotRescaler::interval(), QwtPlotPanner::moveCanvas(), QwtPlot::print(), QwtPlotZoomer::rescale(), setInterval(), QwtAbstractScaleDraw::setScaleDiv(), and QwtPlotRescaler::updateScales().
{
return d_upperBound;
}