Qwt Programmer's manual
QwtScaleDiv
QwtScaleDiv - A class for building scale divisions
#include <qwt_scldiv.h>
- QwtScaleDiv
- constructor
- ~QwtScaleDiv
- destructor
- QwtScaleDiv
- copy constructor
- lbound
- lower boundary
- hBound
- upper boundary
- minCnt
- number of minor marks
- majCnt
- number of major marks
- logScale
- logarithmic or linear
- majMark
- major mark with index i
- minMark
- minor mark with index i
- majStep
- major step width
- rebuild
- build a new scale division
- reset
- reset the scale
- operator=
- assignment operator
- operator==
- equality
- operator!=
- inequality
The QwtScaleDiv class can build
linear and logarithmic scale divisions for specified
intervals. It uses an adjustable algorithm to
generate the major and minor step widths automatically.
A scale division has a minimum value, a maximum value,
a vector of major marks, and a vector of minor marks.
QwtScaleDiv uses implicit sharing for the mark vectors.
Build a logarithmic scale division from 0.01 to 1000
and print out the major and minor marks.
#include <qwt_scldiv.h>
#include <iostream.h>
main()
{
int i,k;
QwtScaleDiv sd;
sd.rebuild(0.01, 100, 10, 10, TRUE, 0.0);
k=0;
for (i=0;i<sd.majCnt();i++)
{
while(k < sd.minCnt())
{
if(sd.minMark(k) < sd.majMark(i))
{
cout << " - " << sd.minMark(i) << "\n";
k++;
}
else
break;
}
cout << "-- " << sd.majMark(i) << "\n";
}
while(k < sd.minCnt())
{
cout << " - " << sd.minMark(i) << "\n";
k++;
}
}
Construct a QwtScaleDiv instance.
QwtScaleDiv::QwtScaleDiv()
Destroy a QwtScaleDiv instance.
QwtScaleDiv::~QwtScaleDiv()
Copy Constructor
QwtScaleDiv::QwtScaleDiv(const QwtScaleDiv &s)
- const QwtScaleDiv &s
- scale division to be copied
Assignment operator
QwtScaleDiv & QwtScaleDiv::operator=(const QwtScaleDiv &s)
- const QwtScaleDiv &s
- scale divison to be assigned
Build a scale width major and minor divisions
- double x1
- first boundary value
- double x2
- second boundary value
- int maxMajSteps
- max. number of major step intervals
- int maxMinSteps
- max. number of minor step intervals
- bool log
- logarithmic division (TRUE/FALSE)
- double step
- fixed major step width. Defaults to 0.0.
- bool ascend
- if TRUE, sort in ascending order from min(x1, x2)
to max(x1, x2). If FALSE, sort in the direction
from x1 to x2. Defaults to TRUE.
True if the arrays have been allocated successfully.
If no fixed step width is specified or if it is set to 0, the
major step width will be calculated automatically according to the
the value of maxMajSteps. The maxMajSteps parameter has no effect
if a fixed step size is specified. The minor step width is always
calculated automatically.
If the step width is to be calculated automatically, the algorithm
tries to find reasonable values fitting into the scheme {1,2,5}*10^n
with an integer number n for linear scales.
For logarithmic scales, there are three different cases:
- If the major step width is one decade, the minor marks
will fit into one of the schemes {1,2,...9}, {2,4,6,8}, {2,5} or {5},
depending on the maxMinSteps parameter.
- If the major step size spans
more than one decade, the minor step size will be {1,2,5}*10^n decades
with a natural number n.
- If the whole range is less than one decade, a linear scale
division will be built
For logarithmic scales, the step width is measured in decades.
Equality operator
int QwtScaleDiv::operator==(const QwtScaleDiv &s)
- const QwtScaleDiv &s
-
TRUE if this instance is equal to s
Inequality
int QwtScaleDiv::operator!=(const QwtScaleDiv &s)
- const QwtScaleDiv &s
-
TRUE if this instance is not equal to s
Detach the shared data and set everything to zero.
void QwtScaleDiv::reset()
Qwt Widget Library 02/04/98