An abstract base class for classes containing a scale. More...
#include <qwt_abstract_scale.h>
Classes | |
class | PrivateData |
Public Member Functions | |
QwtAbstractScale () | |
virtual | ~QwtAbstractScale () |
Destructor. | |
void | setScale (double vmin, double vmax, double step=0.0) |
Specify a scale. | |
void | setScale (const QwtDoubleInterval &, double step=0.0) |
Specify a scale. | |
void | setScale (const QwtScaleDiv &s) |
Specify a scale. | |
void | setAutoScale () |
Advise the widget to control the scale range internally. | |
bool | autoScale () const |
void | setScaleMaxMajor (int ticks) |
Set the maximum number of major tick intervals. | |
int | scaleMaxMinor () const |
void | setScaleMaxMinor (int ticks) |
Set the maximum number of minor tick intervals. | |
int | scaleMaxMajor () const |
void | setScaleEngine (QwtScaleEngine *) |
Set a scale engine. | |
const QwtScaleEngine * | scaleEngine () const |
QwtScaleEngine * | scaleEngine () |
const QwtScaleMap & | scaleMap () const |
Protected Member Functions | |
void | rescale (double vmin, double vmax, double step=0.0) |
void | setAbstractScaleDraw (QwtAbstractScaleDraw *) |
Set a scale draw. | |
const QwtAbstractScaleDraw * | abstractScaleDraw () const |
QwtAbstractScaleDraw * | abstractScaleDraw () |
virtual void | scaleChange () |
Notify changed scale. |
An abstract base class for classes containing a scale.
QwtAbstractScale is used to provide classes with a QwtScaleDraw, and a QwtScaleDiv. The QwtScaleDiv might be set explicitely or calculated by a QwtScaleEngine.
Definition at line 29 of file qwt_abstract_scale.h.
QwtAbstractScale::QwtAbstractScale | ( | ) |
Constructor
Creates a default QwtScaleDraw and a QwtLinearScaleEngine. Autoscaling is enabled, and the stepSize is initialized by 0.0.
Definition at line 53 of file qwt_abstract_scale.cpp.
References rescale().
{ d_data = new PrivateData; rescale(0.0, 100.0); }
QwtAbstractScale::~QwtAbstractScale | ( | ) | [virtual] |
const QwtAbstractScaleDraw * QwtAbstractScale::abstractScaleDraw | ( | ) | const [protected] |
Definition at line 249 of file qwt_abstract_scale.cpp.
References QwtAbstractScale::PrivateData::scaleDraw.
Referenced by QwtThermo::scaleDraw(), QwtSlider::scaleDraw(), and QwtKnob::scaleDraw().
{ return d_data->scaleDraw; }
QwtAbstractScaleDraw * QwtAbstractScale::abstractScaleDraw | ( | ) | [protected] |
Definition at line 240 of file qwt_abstract_scale.cpp.
References QwtAbstractScale::PrivateData::scaleDraw.
{ return d_data->scaleDraw; }
bool QwtAbstractScale::autoScale | ( | ) | const |
true
if autoscaling is enabled Definition at line 159 of file qwt_abstract_scale.cpp.
References QwtAbstractScale::PrivateData::autoScale.
Referenced by QwtSlider::rangeChange(), and QwtThermo::setRange().
{ return d_data->autoScale; }
void QwtAbstractScale::rescale | ( | double | vmin, |
double | vmax, | ||
double | stepSize = 0.0 |
||
) | [protected] |
Recalculate the scale division and update the scale draw.
vmin | Lower limit of the scale interval |
vmax | Upper limit of the scale interval |
stepSize | Major step size |
Definition at line 127 of file qwt_abstract_scale.cpp.
References QwtScaleEngine::divideScale(), QwtAbstractScale::PrivateData::maxMajor, QwtAbstractScale::PrivateData::maxMinor, scaleChange(), QwtAbstractScaleDraw::scaleDiv(), QwtAbstractScale::PrivateData::scaleDraw, QwtAbstractScale::PrivateData::scaleEngine, QwtAbstractScaleDraw::setScaleDiv(), QwtAbstractScaleDraw::setTransformation(), and QwtScaleEngine::transformation().
Referenced by QwtAbstractScale(), QwtSlider::rangeChange(), QwtThermo::setRange(), and setScale().
{ const QwtScaleDiv scaleDiv = d_data->scaleEngine->divideScale( vmin, vmax, d_data->maxMajor, d_data->maxMinor, stepSize); if ( scaleDiv != d_data->scaleDraw->scaleDiv() ) { d_data->scaleDraw->setTransformation( d_data->scaleEngine->transformation()); d_data->scaleDraw->setScaleDiv(scaleDiv); scaleChange(); } }
void QwtAbstractScale::scaleChange | ( | ) | [protected, virtual] |
Notify changed scale.
Dummy empty implementation, intended to be overloaded by derived classes
Reimplemented in QwtSlider, and QwtThermo.
Definition at line 301 of file qwt_abstract_scale.cpp.
Referenced by rescale(), setAutoScale(), and setScale().
{ }
const QwtScaleEngine * QwtAbstractScale::scaleEngine | ( | ) | const |
Definition at line 282 of file qwt_abstract_scale.cpp.
References QwtAbstractScale::PrivateData::scaleEngine.
Referenced by QwtThermo::setRange(), and setScaleEngine().
{ return d_data->scaleEngine; }
QwtScaleEngine * QwtAbstractScale::scaleEngine | ( | ) |
Definition at line 291 of file qwt_abstract_scale.cpp.
References QwtAbstractScale::PrivateData::scaleEngine.
{ return d_data->scaleEngine; }
const QwtScaleMap & QwtAbstractScale::scaleMap | ( | ) | const |
Definition at line 308 of file qwt_abstract_scale.cpp.
References QwtAbstractScale::PrivateData::scaleDraw, and QwtAbstractScaleDraw::scaleMap().
int QwtAbstractScale::scaleMaxMajor | ( | ) | const |
Definition at line 213 of file qwt_abstract_scale.cpp.
References QwtAbstractScale::PrivateData::maxMajor.
{ return d_data->maxMajor; }
int QwtAbstractScale::scaleMaxMinor | ( | ) | const |
Definition at line 204 of file qwt_abstract_scale.cpp.
References QwtAbstractScale::PrivateData::maxMinor.
{ return d_data->maxMinor; }
void QwtAbstractScale::setAbstractScaleDraw | ( | QwtAbstractScaleDraw * | scaleDraw ) | [protected] |
Set a scale draw.
scaleDraw has to be created with new and will be deleted in ~QwtAbstractScale or the next call of setAbstractScaleDraw.
Definition at line 224 of file qwt_abstract_scale.cpp.
References QwtAbstractScaleDraw::scaleDiv(), QwtAbstractScale::PrivateData::scaleDraw, and QwtAbstractScaleDraw::setScaleDiv().
Referenced by QwtThermo::setScaleDraw(), QwtSlider::setScaleDraw(), and QwtKnob::setScaleDraw().
void QwtAbstractScale::setAutoScale | ( | ) |
Advise the widget to control the scale range internally.
Autoscaling is on by default.
Definition at line 147 of file qwt_abstract_scale.cpp.
References QwtAbstractScale::PrivateData::autoScale, and scaleChange().
{ if (!d_data->autoScale) { d_data->autoScale = true; scaleChange(); } }
void QwtAbstractScale::setScale | ( | double | vmin, |
double | vmax, | ||
double | stepSize = 0.0 |
||
) |
Specify a scale.
Disable autoscaling and define a scale by an interval and a step size
vmin | lower limit of the scale interval |
vmax | upper limit of the scale interval |
stepSize | major step size |
Definition at line 75 of file qwt_abstract_scale.cpp.
References QwtAbstractScale::PrivateData::autoScale, rescale(), and QwtAbstractScale::PrivateData::stepSize.
Referenced by setScale().
void QwtAbstractScale::setScale | ( | const QwtScaleDiv & | scaleDiv ) |
Specify a scale.
Disable autoscaling and define a scale by a scale division
scaleDiv | Scale division |
Definition at line 107 of file qwt_abstract_scale.cpp.
References QwtAbstractScale::PrivateData::autoScale, scaleChange(), QwtAbstractScaleDraw::scaleDiv(), QwtAbstractScale::PrivateData::scaleDraw, and QwtAbstractScaleDraw::setScaleDiv().
{ d_data->autoScale = false; if (scaleDiv != d_data->scaleDraw->scaleDiv()) { d_data->scaleDraw->setScaleDiv(scaleDiv); scaleChange(); } }
void QwtAbstractScale::setScale | ( | const QwtDoubleInterval & | interval, |
double | stepSize = 0.0 |
||
) |
Specify a scale.
Disable autoscaling and define a scale by an interval and a step size
interval | Interval |
stepSize | major step size |
Definition at line 92 of file qwt_abstract_scale.cpp.
References QwtDoubleInterval::maxValue(), QwtDoubleInterval::minValue(), and setScale().
void QwtAbstractScale::setScaleEngine | ( | QwtScaleEngine * | scaleEngine ) |
Set a scale engine.
The scale engine is responsible for calculating the scale division, and in case of auto scaling how to align the scale.
scaleEngine has to be created with new and will be deleted in ~QwtAbstractScale or the next call of setScaleEngine.
Definition at line 269 of file qwt_abstract_scale.cpp.
References scaleEngine(), and QwtAbstractScale::PrivateData::scaleEngine.
Referenced by QwtThermo::setRange().
{ if ( scaleEngine != NULL && scaleEngine != d_data->scaleEngine ) { delete d_data->scaleEngine; d_data->scaleEngine = scaleEngine; } }
void QwtAbstractScale::setScaleMaxMajor | ( | int | ticks ) |
Set the maximum number of major tick intervals.
The scale's major ticks are calculated automatically such that the number of major intervals does not exceed ticks. The default value is 5.
ticks | maximal number of major ticks. |
Definition at line 173 of file qwt_abstract_scale.cpp.
References QwtAbstractScale::PrivateData::maxMajor.
void QwtAbstractScale::setScaleMaxMinor | ( | int | ticks ) |
Set the maximum number of minor tick intervals.
The scale's minor ticks are calculated automatically such that the number of minor intervals does not exceed ticks. The default value is 3.
ticks |
Definition at line 191 of file qwt_abstract_scale.cpp.
References QwtAbstractScale::PrivateData::maxMinor.