C++ API Reference

Manipulate Linear Data. More...

#include <MDistance.h>

Public Types

enum  Unit { ,
  kInches, kFeet, kYards, kMiles,
  kMillimeters, kCentimeters, kKilometers, kMeters
}
 Available Unit Systems. More...
 

Public Member Functions

 MDistance ()
 The default class constructor. More...
 
 MDistance (double value, Unit unitSystem=kCentimeters)
 Class constructor. More...
 
 MDistance (const MDistance &src)
 Copy constructor. More...
 
 ~MDistance ()
 The class destructor.
 
MDistanceoperator= (const MDistance &src)
 The assignment operator. More...
 
Unit unit () const
 Return the units currently in effect for this instance. More...
 
double value () const
 Return the value of the current instance in the currently set units. More...
 
MStatus setUnit (Unit newUnit)
 Set the units used by this instance. More...
 
MStatus setValue (double newValue)
 Set the value of this instance. More...
 
double as (Unit newUnit, MStatus *ReturnStatus=NULL) const
 Return the current value of this instance in the provided units. More...
 
double asUnits (Unit newUnit, MStatus *ReturnStatus=NULL) const
 Return the current value of this instance in the provided units. More...
 
double asInches () const
 Return the current value of this instance in inches. More...
 
double asFeet () const
 Return the current value of this instance in feet. More...
 
double asYards () const
 Return the current value of this instance in yards. More...
 
double asMiles () const
 Return the current value of this instance in miles. More...
 
double asMillimeters () const
 Return the current value of this instance in millimeters. More...
 
double asCentimeters () const
 Return the current value of this instance in centimeters. More...
 
double asKilometers () const
 Return the current value of this instance in kilometers. More...
 
double asMeters () const
 Return the current value of this instance in meters. More...
 

Static Public Member Functions

static Unit uiUnit ()
 Returns the Working Units (or UI units) chosen in the settings of the prefs window. More...
 
static MStatus setUIUnit (Unit newUnit)
 Set the unit system to be used by the user in the UI. More...
 
static Unit internalUnit ()
 Returns the internal unit system. More...
 
static double internalToUI (double internalValue)
 Converts a value from internal units to UI units. More...
 
static double uiToInternal (double uiValue)
 Converts a value from UI units to internal units. More...
 
static const char * className ()
 Returns the name of this class. More...
 
static MStatus setInternalUnit (Unit internalUnit)
 This method is obsolete. More...
 

Detailed Description

Member Enumeration Documentation

enum Unit

Available Unit Systems.

Enumerator
kInches 

Inches.

kFeet 

Feet.

kYards 

Yards.

kMiles 

Miles.

kMillimeters 

Millimeters.

kCentimeters 

Centimeters.

kKilometers 

Kilometers.

kMeters 

Meters.

Constructor & Destructor Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN MDistance ( )

The default class constructor.

Initialize the MDistance instance to 0 in the current internal units. (See setInternalUnit and internalUnit below).

MDistance ( double  newValue,
MDistance::Unit  newUnit = kCentimeters 
)

Class constructor.

Initialize the MDistance instance to the given value in the given unit system

Parameters
[in]newValuethe initial value of the instance
[in]newUnitthe unit system for the initial value
MDistance ( const MDistance src)

Copy constructor.

Parameters
[in]srcExisting MDistance object from which to initialize the new one.

Member Function Documentation

MDistance & operator= ( const MDistance src)

The assignment operator.

Parameters
[in]srcExisting MDistance object from which to set the value of this one.
Returns
Reference to this MDistance instance.
MDistance::Unit unit ( ) const

Return the units currently in effect for this instance.

Returns
An element of the MDistance::Unit enum
double value ( ) const

Return the value of the current instance in the currently set units.

Returns
The current value of the instance
MStatus setUnit ( MDistance::Unit  newUnit)

Set the units used by this instance.

Parameters
[in]newUnitan element of the MDistance::Unit enum
Returns
MS::kSuccess if a valid unit was provided, MS::kFailure otherwise
MStatus setValue ( double  newValue)

Set the value of this instance.

Parameters
[in]newValuethe new value in the units currently in effect
Returns
Always returns MS::kSuccess
double as ( MDistance::Unit  otherUnit,
MStatus ReturnStatus = NULL 
) const

Return the current value of this instance in the provided units.

Parameters
[in]otherUnitan element of the MDistance::Unit enum specifying the desired units
[out]ReturnStatusreturn status
Returns
The current value in the given units
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
Examples:
cgFx/cgfxAttrDef.cpp.
double asUnits ( MDistance::Unit  otherUnit,
MStatus ReturnStatus = NULL 
) const

Return the current value of this instance in the provided units.

Parameters
[in]otherUnitan element of the MDistance::Unit enum specifying the desired units
[out]ReturnStatusreturn status
Returns
The current value in the given units
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
double asInches ( ) const

Return the current value of this instance in inches.

Returns
The current value in the inches
double asFeet ( ) const

Return the current value of this instance in feet.

Returns
The current value in the feet
double asYards ( ) const

Return the current value of this instance in yards.

Returns
The current value in the yards
double asMiles ( ) const

Return the current value of this instance in miles.

Returns
The current value in the miles
double asMillimeters ( ) const

Return the current value of this instance in millimeters.

Returns
The current value in the millimeters
double asKilometers ( ) const

Return the current value of this instance in kilometers.

Returns
The current value in the kilometers
double asMeters ( ) const

Return the current value of this instance in meters.

Returns
The current value in the meters
MDistance::Unit uiUnit ( )
static

Returns the Working Units (or UI units) chosen in the settings of the prefs window.

Returns
An element of the MDistance::Unit enum
Examples:
animExportUtil/animFileExport.cpp, animImportExport/animFileUtils.cpp, atomImportExport/atomFileUtils.cpp, and objExport/objExport.cpp.
MStatus setUIUnit ( MDistance::Unit  newUnit)
static

Set the unit system to be used by the user in the UI.

Parameters
[in]newUnitand element of the MDistance::Unit enum.
Returns
MS::kSuccess if a valid unit was provided, MS::kFailure otherwise
Examples:
animImportExport/animFileUtils.cpp, atomImportExport/atomFileUtils.cpp, and atomImportExport/atomImportExport.cpp.
MDistance::Unit internalUnit ( )
static

Returns the internal unit system.

Returns
The internal unit for distance
Examples:
animImportExport/animFileUtils.cpp, atomImportExport/atomFileUtils.cpp, and cgFx/cgfxAttrDef.cpp.
double internalToUI ( double  internalValue)
static

Converts a value from internal units to UI units.

Parameters
[in]internalValuea value in internal units
Returns
The value in UI units
Examples:
objExport/objExport.cpp.
double uiToInternal ( double  uiValue)
static

Converts a value from UI units to internal units.

Parameters
[in]uiValuea value in UI units
Returns
The value in internal units.
Examples:
tessellatedQuad/TessellatedQuadNode.cpp.
const char * className ( )
static

Returns the name of this class.

Returns
The name of this class.
MStatus setInternalUnit ( MDistance::Unit  internalUnit)
static

This method is obsolete.

Set the internal unit system.

[as of Maya 2019]

Deprecated:
Changing the internal units is generally not a good idea and using the method may often produce unexpected results. It is recommended to just read the values and convert them to the units desired.
Parameters
[in]internalUnitthe internal unit to be used by distance
Returns
Status code
Status Codes:
  • MS::kSuccess a valid unit was provided
  • MS::kFailure a valid unit was not provided

The documentation for this class was generated from the following files: