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

QwtDiMap Class Reference

Map a double interval into an integer interval. More...

#include <qwt_dimap.h>

Inheritance diagram for QwtDiMap:

QwtScaleDraw QwtDialScaleDraw List of all members.

Public Member Functions

 QwtDiMap ()
 QwtDiMap (int i1, int i2, double d1, double d2, bool lg=FALSE)
 ~QwtDiMap ()
bool contains (double x) const
bool contains (int x) const
void setIntRange (int i1, int i2)
void setDblRange (double d1, double d2, bool lg=FALSE)
int transform (double x) const
double invTransform (int i) const
int limTransform (double x) const
double xTransform (double x) const
double d1 () const
double d2 () const
int i1 () const
int i2 () const
bool logarithmic () const

Public Attributes

QT_STATIC_CONST double LogMin = 1.0e-150
QT_STATIC_CONST double LogMax = 1.0e150

Private Member Functions

void newFactor ()

Private Attributes

double d_x1
double d_x2
int d_y1
int d_y2
double d_cnv
bool d_log

Detailed Description

Map a double interval into an integer interval.

The QwtDiMap class maps an interval of type double into an interval of type int. It consists of two intervals D = [d1, d2] (double) and I = [i1, i2] (int), which are specified with the QwtDiMap::setDblRange and QwtDiMap::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 QwtDiMap::transform or QwtDiMap::limTransform or vice versa using QwtPlot::invTransform. D can be scaled linearly or logarithmically, as specified with QwtDiMap::setDblRange.

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

Definition at line 45 of file qwt_dimap.h.


Constructor & Destructor Documentation

QwtDiMap::QwtDiMap  ) 
 

Constructor.

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

Definition at line 22 of file qwt_dimap.cpp.

References d_cnv, d_x1, d_x2, d_y1, and d_y2.

QwtDiMap::QwtDiMap int  i1,
int  i2,
double  d1,
double  d2,
bool  logarithmic = FALSE
 

Constructor.

Constructs a QwtDiMap instance with initial integer and double intervals

Parameters:
i1 first border of integer interval
i2 second border of integer interval
d1 first border of double interval
d2 second border of double interval
logarithmic logarithmic mapping, TRUE or FALSE.

Definition at line 44 of file qwt_dimap.cpp.

References d_log, setDblRange(), and setIntRange().

QwtDiMap::~QwtDiMap  ) 
 

Destructor.

Definition at line 54 of file qwt_dimap.cpp.


Member Function Documentation

bool QwtDiMap::contains int  x  )  const
 

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

Definition at line 73 of file qwt_dimap.cpp.

References d_y1, d_y2, qwtMax, and qwtMin.

bool QwtDiMap::contains double  x  )  const
 

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

Definition at line 63 of file qwt_dimap.cpp.

References d_x1, d_x2, qwtMax, and qwtMin.

double QwtDiMap::d1  )  const [inline]
 

Returns:
the first border of the double interval

Definition at line 85 of file qwt_dimap.h.

References d_x1.

Referenced by QwtSlider::getValue(), and QwtSlider::xyPosition().

double QwtDiMap::d2  )  const [inline]
 

Returns:
the second border of the double interval

Definition at line 93 of file qwt_dimap.h.

References d_x2.

Referenced by QwtSlider::getValue(), and QwtSlider::xyPosition().

int QwtDiMap::i1  )  const [inline]
 

Returns:
the second border of the integer interval

Definition at line 101 of file qwt_dimap.h.

References d_y1.

Referenced by QwtScaleDraw::drawBackbone(), QwtSlider::getScrollMode(), QwtSlider::getValue(), and QwtSlider::xyPosition().

int QwtDiMap::i2  )  const [inline]
 

Returns:
the second border of the integer interval

Definition at line 109 of file qwt_dimap.h.

References d_y2.

Referenced by QwtScaleDraw::drawBackbone(), QwtSlider::getScrollMode(), QwtSlider::getValue(), and QwtSlider::xyPosition().

double QwtDiMap::invTransform int  y  )  const
 

Transform an integer value into a double value.

Parameters:
y integer value to be transformed
Returns:
linear mapping:
d1 + (d2 - d1) / (i2 - i1) * (y - i1)
logarithmic mapping:
d1 + (d2 - d1) / log(i2 / i1) * log(y / i1)

Definition at line 155 of file qwt_dimap.cpp.

References d_cnv, d_log, d_x1, and d_y1.

Referenced by QwtSlider::getValue(), and QwtPlot::invTransform().

int QwtDiMap::limTransform double  x  )  const
 

Transform and limit.

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

Parameters:
x value to be transformed
Returns:
transformed value

Definition at line 179 of file qwt_dimap.cpp.

References d_x1, d_x2, qwtMax, qwtMin, and transform().

Referenced by QwtThermo::drawThermo().

bool QwtDiMap::logarithmic  )  const [inline]
 

Returns:
TRUE if the double interval is scaled logarithmically

Definition at line 117 of file qwt_dimap.h.

References d_log.

void QwtDiMap::newFactor  )  [private]
 

Re-calculate the conversion factor.

Definition at line 216 of file qwt_dimap.cpp.

References d_cnv, d_x1, d_x2, d_y1, and d_y2.

Referenced by setDblRange(), and setIntRange().

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

Specify the borders of the double interval.

Parameters:
d1 first border
d2 second border
lg logarithmic (TRUE) or linear (FALSE) scaling

Definition at line 84 of file qwt_dimap.cpp.

References d_log, d_x1, d_x2, LogMax, LogMin, and newFactor().

Referenced by QwtThermo::init(), QwtPlot::print(), QwtDiMap(), QwtThermo::setRange(), and QwtScaleDraw::setScale().

void QwtDiMap::setIntRange int  i1,
int  i2
 

Specify the borders of the integer interval.

Parameters:
i1 first border
i2 second border

Definition at line 116 of file qwt_dimap.cpp.

References d_y1, d_y2, and newFactor().

Referenced by QwtPlot::canvasMap(), QwtSlider::layoutSlider(), QwtThermo::layoutThermo(), QwtPlot::print(), QwtDiMap(), QwtScaleDraw::setAngleRange(), and QwtScaleDraw::setGeometry().

int QwtDiMap::transform double  x  )  const
 

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

Parameters:
x value
Returns:
linear mapping:
rint(i1 + (i2 - i1) / (d2 - d1) * (x - d1))
logarithmic mapping:
rint(i1 + (i2 - i1) / log(d2 / d1) * log(x / d1))
Warning:
The specified point is allowed to lie outside the intervals. If you want to limit the returned value, use QwtDiMap::limTransform.

Definition at line 138 of file qwt_dimap.cpp.

References d_cnv, d_log, d_x1, and d_y1.

Referenced by QwtCurve::closePolyline(), QwtGrid::draw(), QwtCurve::drawDots(), QwtCurve::drawLines(), QwtCurve::drawSteps(), QwtCurve::drawSticks(), QwtCurve::drawSymbols(), QwtScaleDraw::drawTick(), QwtScaleDraw::labelPlacement(), limTransform(), QwtPlot::transform(), and QwtSlider::xyPosition().

double QwtDiMap::xTransform double  x  )  const
 

Exact transformation.

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

Parameters:
x value to be transformed
Returns:
linear mapping:
i1 + (i2 - i1) / (d2 - d1) * (x - d1)
logarithmic mapping:
i1 + (i2 - i1) / log(d2 / d1) * log(x / d1)

Definition at line 200 of file qwt_dimap.cpp.

References d_cnv, d_log, d_x1, and d_y1.

Referenced by QwtCurve::drawSpline().


Member Data Documentation

double QwtDiMap::d_cnv [private]
 

Definition at line 78 of file qwt_dimap.h.

Referenced by invTransform(), newFactor(), QwtDiMap(), transform(), and xTransform().

bool QwtDiMap::d_log [private]
 

Definition at line 79 of file qwt_dimap.h.

Referenced by invTransform(), logarithmic(), QwtDiMap(), setDblRange(), transform(), and xTransform().

double QwtDiMap::d_x1 [private]
 

Definition at line 76 of file qwt_dimap.h.

Referenced by contains(), d1(), invTransform(), limTransform(), newFactor(), QwtDiMap(), setDblRange(), transform(), and xTransform().

double QwtDiMap::d_x2 [private]
 

Definition at line 76 of file qwt_dimap.h.

Referenced by contains(), d2(), limTransform(), newFactor(), QwtDiMap(), and setDblRange().

int QwtDiMap::d_y1 [private]
 

Definition at line 77 of file qwt_dimap.h.

Referenced by contains(), i1(), invTransform(), newFactor(), QwtDiMap(), setIntRange(), transform(), and xTransform().

int QwtDiMap::d_y2 [private]
 

Definition at line 77 of file qwt_dimap.h.

Referenced by contains(), i2(), newFactor(), QwtDiMap(), and setIntRange().

QT_STATIC_CONST_IMPL double QwtDiMap::LogMax = 1.0e150
 

Definition at line 14 of file qwt_dimap.cpp.

Referenced by setDblRange().

QT_STATIC_CONST_IMPL double QwtDiMap::LogMin = 1.0e-150
 

Definition at line 13 of file qwt_dimap.cpp.

Referenced by setDblRange().


The documentation for this class was generated from the following files:
Generated on Fri Nov 7 14:11:48 2003 for Qwt Developer's Guide by doxygen 1.3.2