CODMeasure Class

class CODMeasure

Encapsulates a real number and a unit of measure. Objects of this type are aware of their unit of measurement and can easily be converted from one unit of measurement to another. A conversion matrix is used to store conversion ratios between all units of measure, so conversions consist of one access to an NxN array and one floating point multiply.

Conversions can be performed by calling the  Convert method. A float cast operator is provided so that the value of the measurement can be substituted in places where a float is expected.

The comparison operators perform automatic conversion on one of the arguments to ensure that comparisons are performed on values that are in a common unit of measure. For example, if you compare a CODMeasure that contains yards to one that contains millimeters, the CODMeasure object is smart enough to convert yards to millimeters so that the result of the comparison is valid.

Defined in: OdMeasure.h

Class Members

 CODMeasure(const OD_UNIT_OF_MEASURE units = OD_INCHES, const float fValue = 0.0f)

Constructor.

 CODMeasure(const OD_UNIT_OF_MEASURE units, const CODMeasure& src)

Constructor.

 CODMeasure(const CODMeasure& src)

Copy constructor.

 operator float() const

Return measurement as a float.

CODMeasure&  operator=(const CODMeasure& src)

Perform assignment of a CODMeasure object.

CODMeasure&  operator=(const float fValue)

Perform assignment of a float value.

BOOL  operator==(const CODMeasure& m) const

Compare two measurements for equality.

BOOL  operator!=(const CODMeasure& m) const

Compare two measurements for inequality.

BOOL operator<(const CODMeasure& m) const

Is this measurement less than.

BOOL  operator>(const CODMeasure& m) const

Is this measurement greater than.

BOOL operator<=(const CODMeasure& m) const

Is this measurement less than or equal.

BOOL  operator>=(const CODMeasure& m) const

Is this measurement greater than or equal.

virtual CODMeasure&  Convert(const CODMeasure& src)

Convert the given value into units supported by this object.

virtual CODMeasure&  Convert(const OD_UNIT_OF_MEASURE units, const float fValue)

Convert the given value into units supported by this object.

void  SetUnits(const OD_UNIT_OF_MEASURE units)

Set the unit of measure.

OD_UNIT_OF_MEASURE  GetUnits() const

Get the unit of measure.

static UINT  GetResId(const OD_UNIT_OF_MEASURE units)

Get resource ID for a given unit of measure.

static void  MeasureLogicalUnit(const int nMapMode, const CSize& szWndExt, const CSize& szVpExt, CODMeasure& logXUnit, CODMeasure& logYUnit)

Measures the size of one logical unit on the screen.

static BOOL  IsMetric(const OD_UNIT_OF_MEASURE units)

Determines if the given unit of measure is metric or not

float m_fValue

Value of measurement

OD_UNIT_OF_MEASURE m_units

Unit of measurement