Qwt Programmer's Manual

QwtDiMap


NAME

QwtDiMap - Map a double interval into an integer interval

SYNOPSIS

#include <qwt_dimap.h>

DESCRIPTION

The QwtDiMap class maps an interval of type double into an interval of type integer. It consists of two intervals D = [d1, d2] (double) and I = [i1, i2] (int), which are specified with the setDblRange and setIntRange members. The point d1 is mapped to the point i1, and d2 is mapped to i2. Any point inside or outside D can be mapped to a point inside or outside I using transform or limTransform or vice versa using invTransform. D can be scaled linearly or logarithmically, as specified with setDblRange.

INHERITED CLASSES

QwtScaleDraw

PUBLIC MEMBERS

QwtDiMap (1)
Constructor
QwtDiMap (2)
Constructor
~QwtDiMap
Destructor
contains (1)
value contained in double interval?
contains (2)
value contained in int interval?
setIntRange
Specify integer interval
setDblRange
Specify double interval
transform
transform double -> int
invTransform
transform int -> double
xTransform
transform double -> double(int)
limTransform(double x)
transform double -> int
d1
first border of double interval
d2
second border of double interval
i1
first border of integer interval
i2
second border of int interval
logarithmic
double interval scaled logarithmically?

USAGE

      #include <qwt_dimap.h>

      QwtDiMap map;
      int ival;
      double dval;

      map.setDblRange(0.0, 3.1415);   // Assign an interval of type double with
                                      // linear mapping
      map.setIntRange(0,100);         // Assign an integer interval

      ival = map.transform(1.0);      // obtain integer value corresponding to 1.0
      dval = map.invTransform(77);    // obtain double value corresponding to 77

MEMBER FUNCTION DESCRIPTION


QwtDiMap::QwtDiMap (1)

Construct a QwtDiMap instance.

Syntax

QwtDiMap::QwtDiMap()

Description

The double and integer intervals are both set to [0,1].

QwtDiMap::QwtDiMap (2)

Construct a QwtDiMap instance with initial integer and double intervals

Syntax

QwtDiMap::QwtDiMap(int i1, int i2, double d1, double d2, bool logarithmic)

Parameters

int i1
first border of integer interval
int i2
second border of integer interval
double d1
first border of double interval
double d2
second border of double interval
bool logarithmic
logarithmic mapping, TRUE or FALSE. Defaults to FALSE.

QwtDiMap::~QwtDiMap

Destroy a QwtDiMap instance.

Syntax

QwtDiMap::~QwtDiMap()

QwtDiMap::contains (1)

Returns TRUE if a value x lies inside or at the border of the map's double range.

Syntax

bool QwtDiMap::contains(double x)

Parameters

double x
value

QwtDiMap::contains (2)

Returns TRUE if a value x lies inside or at the border of the map's integer range

Syntax

bool QwtDiMap::contains(int x)

Parameters

int x
value

QwtDiMap::setDblRange

Specify the borders of the double interval

Syntax

void QwtDiMap::setDblRange(double d1, double d2, bool lg = FALSE)

Parameters

double d1
first border
double d2
second border
bool lg
logarithmic (TRUE) or linear (FALSE) scaling. Defaults to FALSE.

QwtDiMap::setIntRange

Specify the borders of the integer interval

Syntax

void QwtDiMap::setIntRange(int i1, int i2)

Parameters

int i1
first border
int i2
second border

QwtDiMap::transform

Transform a point in double interval into an point in the integer interval

Syntax

int QwtDiMap::transform(double x)

Parameters

double x

Return Value

linear mapping:
rint(i1 + (i2 - i1) / (d2 - d1) * (x - d1))
logarithmic mapping:
rint(i1 + (i2 - i1) / log(d2 / d1) * log(x / d1))

Note

The specified point is allowed to lie outside the intervals. If you want to limit the returned value, use limTransform.

QwtDiMap::invTransform

Transform an integer value into a double value

Syntax

double QwtDiMap::invTransform(int y)

Parameters

int y
integer value to be transformed

Return Value

linear mapping:
d1 + (d2 - d1) / (i2 - i1) * (y - i1)
logarithmic mapping:
d1 + (d2 - d1) / log(i2 / i1) * log(y / i1)

QwtDiMap::limTransform

Transform and limit

Syntax

int QwtDiMap::limTransform(double x)

Parameters

double x

Return Value

transformed value

Description

The function is similar to transform, but limits the input value to the nearest border of the map's double interval if it lies outside that interval.

QwtDiMap::xTransform

Exact transformation

Syntax

double QwtDiMap::dTransform(double x)

Parameters

double x
value to be transformed

Return Value

linear mapping:
i1 + (i2 - i1) / (d2 - d1) * (x - d1)
logarithmic mapping:
i1 + (i2 - i1) / log(d2 / d1) * log(x / d1)

Description

This function is similar to transform, but makes the integer interval appear to be double.

QwtDiMap::d1

Returns the first border of the double interval

Syntax

double QwtDiMap::d1()

QwtDiMap::d2

Returns the second border of the double interval

Syntax

double QwtDiMap::d2()

QwtDiMap::i1

Returns the first border of the integer interval

Syntax

int QwtDiMap::i1()

QwtDiMap::i2

Returns the second border of the integer interval

Syntax

int QwtDiMap::i2()

QwtDiMap::logarithmic

Returns TRUE if the double interval is scaled logarithmically

Syntax

bool QwtDiMap::logarithmic()
Qwt Widget Library 01/01/98