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

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

Constructor.

VIEWS_API CODMeasure(const OD_UNIT_OF_MEASURE units, const CODMeasure& src)

Constructor.

VIEWS_API CODMeasure(const CODMeasure& src)

Copy constructor.

VIEWS_API operator float() const

Return measurement as a float.

VIEWS_API CODMeasure& operator=(const CODMeasure& src)

Perform assignment of a CODMeasure object.

VIEWS_API CODMeasure& operator=(const float fValue)

Perform assignment of a float value.

VIEWS_API BOOL operator==(const CODMeasure& m) const

Compare two measurements for equality.

VIEWS_API BOOL operator!=(const CODMeasure& m) const

Compare two measurements for inequality.

VIEWS_API BOOL operator<(const CODMeasure& m) const

Is this measurement less than.

VIEWS_API BOOL operator>(const CODMeasure& m) const

Is this measurement greater than.

VIEWS_API BOOL operator<=(const CODMeasure& m) const

Is this measurement less than or equal.

VIEWS_API BOOL operator>=(const CODMeasure& m) const

Is this measurement greater than or equal.

VIEWS_API virtual CODMeasure& Convert(const CODMeasure& src)

Convert the given value into units supported by this object.

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

Convert the given value into units supported by this object.

VIEWS_API void SetUnits(const OD_UNIT_OF_MEASURE units)

Set the unit of measure.

VIEWS_API OD_UNIT_OF_MEASURE GetUnits() const

Get the unit of measure.

VIEWS_API static UINT GetResId(const OD_UNIT_OF_MEASURE units)

Get resource ID for a given unit of measure.

VIEWS_API 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.

VIEWS_API 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