Main Page | Class Hierarchy | Alphabetical List | Class List | Class Members | Related Pages

PlotMM::ScaleDiv Class Reference

List of all members.

Detailed Description

A class for building scale divisions.

The ScaleDiv 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.

ScaleDiv uses implicit sharing for the mark vectors.
To build a logarithmic scale division from 0.01 to 1000 and print out the major and minor marks.
#include <plotmm/scalediv.h> #include <iostream.h> main() { int i,k; PlotMM::ScaleDiv sd; sd.rebuild(0.01, 1000, 10, 10, TRUE, 0.0); k=0; for (i=0;i<sd.maj_count();i++) { while(k < sd.min_count()) { if (sd.min_mark(k) < sd.maj_mark(i)) { cout << " - " << sd.min_mark(i) << "\n"; k++; } else break; } cout << "-- " << sd.maj_mark(i) << "\n"; } while(k < sd.min_count()) { cout << " - " << sd.min_mark(i) << "\n"; k++; } }

Public Member Functions

 ScaleDiv ()
int operator== (const ScaleDiv &s) const
int operator!= (const ScaleDiv &s) const
double low_bound () const
double high_bound () const
uint min_count () const
uint maj_count () const
bool log_scale () const
double maj_mark (int i) const
double min_mark (int i) const
double maj_step () const
void reset ()
bool rebuild (double lBound, double hBound, int maxMaj, int maxMin, bool log, double step=0.0, bool ascend=true)

Constructor & Destructor Documentation

ScaleDiv::ScaleDiv  ) 

Construct a ScaleDiv instance.

Member Function Documentation

double PlotMM::ScaleDiv::high_bound  )  const

right bound
See also:

bool PlotMM::ScaleDiv::log_scale  )  const

TRUE id ths scale div is logarithmic
See also:

double PlotMM::ScaleDiv::low_bound  )  const

left bound
See also:

uint PlotMM::ScaleDiv::maj_count  )  const

major mark count
See also:

double PlotMM::ScaleDiv::maj_mark int  i  )  const

Return major mark at position i.

double PlotMM::ScaleDiv::maj_step  )  const

major step size
See also:

uint PlotMM::ScaleDiv::min_count  )  const

minor mark count
See also:

double PlotMM::ScaleDiv::min_mark int  i  )  const

Return minor mark at position i.

int ScaleDiv::operator!= const ScaleDiv s  )  const


true if this instance is not equal to s

int ScaleDiv::operator== const ScaleDiv s  )  const

Equality operator.

true if this instance is equal to s

bool ScaleDiv::rebuild double  x1,
double  x2,
int  maxMajSteps,
int  maxMinSteps,
bool  log,
double  step = 0.0,
bool  ascend = true

Build a scale width major and minor divisions 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

  1. 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.
  2. 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.
  3. If the whole range is less than one decade, a linear scale division will be built.

x1 first boundary value
x2 second boundary value
maxMajSteps max. number of major step intervals
maxMinSteps max. number of minor step intervals
log logarithmic division (true/false)
step fixed major step width. Defaults to 0.0.
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.
For logarithmic scales, the step width is measured in decades.

void ScaleDiv::reset  ) 

Detach the shared data and set everything to zero.

Generated on Thu Jul 8 14:56:46 2004 for PlotMM by doxygen 1.3.6