#include <qwt_autoscl.h>
Public Types | |
enum | { None = 0, IncludeRef = 1, Symmetric = 2, Floating = 4, Logarithmic = 8, Inverted = 16 } |
Public Methods | |
QwtAutoScale () | |
~QwtAutoScale () | |
void | adjust ( double *arr, int n, int reset = 0) |
void | adjust ( double x1, double x2, int reset = 0) |
void | build () |
void | changeOptions (int opt, bool tf) |
void | reset () |
void | setAutoRebuild (bool tf) |
void | setAutoScale () |
void | setMargins (double m1, double m2) |
void | setMaxMajor ( int n ) |
void | setMaxMinor (int n) |
void | setOptions (int opt) |
void | setReference (double r) |
void | setScale (double xmin, double xmax, double step = 0.0) |
bool | autoScale () const |
double | loMargin () const |
double | hiMargin () const |
int | maxMajor () const |
int | maxMinor () const |
bool | option (int opt) const |
int | options () const |
double | reference () const |
const QwtScaleDiv& | scaleDiv () const |
Protected Methods | |
void | buildLinScale () |
void | buildLogScale () |
void | setRange (double x1, double x2) |
Protected Attributes | |
QwtScaleDiv | d_scldiv |
double | d_minValue |
double | d_maxValue |
double | d_scaleMin |
double | d_scaleMax |
double | d_step |
int | d_maxMajor |
int | d_maxMinor |
int | d_scaleOpt |
bool | d_autoScale |
double | d_loMargin |
double | d_hiMargin |
int | d_reset |
double | d_ref |
double | d_lref |
bool | d_autoRebuild |
This class can be used to generate a scale which may span multiple ranges of values. A scale consists of a lower boundary, an upper boundary, a vector of major scale ticks and a vector of minor scale ticks which divide it into subintervals. A quick look at the example below will give you an idea of how the auto-scaler works.
The auto-scaler produces "reasonable" major and minor step sizes. For linear scales, the major step size will fit into the pattern
, where n is an integer. In logarithmic mode (setOptions()) the step size is measured in *decades* and the major step size will be adjusted to fit the pattern
, where n is a natural number including zero.
The step size can be manipulated indirectly using setMaxMajor(). The layout of the scale can be varied with setOptions().
The auto-scaling algorithm can be partly or completely disabled (even temporarily) if a user-defined scale is desired. This can be done with the setScale() function. It can be switched off again with setAutoScale().
The two adjust() members are used to extend the scale if necessary in order to include another range or array of values. The resulting scale division can be obtained with scaleDiv(). reset() resets the scale to zero.
QwtAutoScale as;
// ... determine x1 and x1, range_min and range_max here ...
as.reset(); // clear it as.adjust(range_min, range_max); // include a range as.adjust(x1,100); // include an array as.adjust(x2,200); // include another array
for (i=0;i
|
Ctor.
|
|
Dtor.
|
|
Adjust the scale to include a specified interval.
This member function extends the boundaries of the scale and re-calculates the step size if necessary in order to include a specified interval. If the reset parameter has nonzero value, the previous state will be cleared.
|
|
Adjust the scale to include a given array of input values.
This member function extends the boundaries of the scale and re-calculates the step size if necessary in order to include all values in the array. If the reset parameter has nonzero value, the previous state will be cleared.
|
|
|
|
Re-build the scale.
|
|
Build a linear scale.
|
|
build a logarithmic scale.
|
|
Set or reset specified scale options.
|
|
|
|
|
|
|
|
|
|
Returns TRUE if the specified option is set.
|
|
|
|
|
|
Set the interval boundaries to zero and clear the scale division.
This member function resets an AutoScale object to its initial state. It is needed to clean up the scale before or after subsequent adjust() calls. The boundaries of the scale are set to zero and the scale division is cleared.
|
|
The scale division consists of two boundary values, an array of major tickmarks and an array of minor tickmarks.
|
|
|
|
Enable auto-scaling.
This function is used to switch back to auto-scaling mode if the scale has been frozen temporarily (see setScale()). When auto-scaling is reactivated, the scale will be rebuild, which means that
|
|
Specify margins at the scale's endpoints.
|
|
Specify the maximum number of major intervals.
|
|
Specify the maximum number of minor subdivisions within major scale intervals.
|
|
Reset scale options and set specified options.
#include "../include/qwt_autoscl.h> void main() { QwtAutoScale as; // build linear scale with default settings as.adjust(17.45, 87344.0); //... // change to logarithmic scale with floating ends as.setOptions(QwtAutoScale::Floating | QwtAutoscale::Logarithmic); //... // change to linear, zero-symmetric scale as.setOptions(QwtAutoScale::ZeroSymmetric); //... }
|
|
|
|
Specify a reference point.
|
|
Specify a user-defined scale and switch off auto-scaling.
The fixed-scale mode can switched off using setAutoScale(), which restores the previous values.
|