Qwt Programmer's manual

QwtScaleDiv


NAME

QwtScaleDiv - A class for building scale divisions

SYNOPSIS

#include <qwt_scldiv.h>

PUBLIC MEMBERS

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

DESCRIPTION

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.

NOTE

QwtScaleDiv uses implicit sharing for the mark vectors.

EXAMPLE

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++;
          }
      }


MEMBER FUNCTION DESCRIPTION


QwtScaleDiv::QwtScaleDiv

Construct a QwtScaleDiv instance.

Syntax

QwtScaleDiv::QwtScaleDiv()

QwtScaleDiv::~QwtScaleDiv

Destroy a QwtScaleDiv instance.

Syntax

QwtScaleDiv::~QwtScaleDiv()

QwtScaleDiv::QwtScaleDiv

Copy Constructor

Syntax

QwtScaleDiv::QwtScaleDiv(const QwtScaleDiv &s)

Parameters

const QwtScaleDiv &s
scale division to be copied

QwtScaleDiv::operator=

Assignment operator

Syntax

QwtScaleDiv & QwtScaleDiv::operator=(const QwtScaleDiv &s)

Parameters

const QwtScaleDiv &s
scale divison to be assigned

QwtScaleDiv::rebuild

Build a scale width major and minor divisions

Parameters

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.

Return Value

True if the arrays have been allocated successfully.

Description

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:

Note

For logarithmic scales, the step width is measured in decades.

QwtScaleDiv::operator==

Equality operator

Syntax

int QwtScaleDiv::operator==(const QwtScaleDiv &s)

Parameters

const QwtScaleDiv &s

Return Value

TRUE if this instance is equal to s

QwtScaleDiv::operator!=

Inequality

Syntax

int QwtScaleDiv::operator!=(const QwtScaleDiv &s)

Parameters

const QwtScaleDiv &s

Return Value

TRUE if this instance is not equal to s

QwtScaleDiv::reset

Detach the shared data and set everything to zero.

Syntax

void QwtScaleDiv::reset()
Qwt Widget Library 02/04/98