units.h File Reference

#include "maxheap.h"
#include "strclass.h"
#include "maxtypes.h"

Classes

struct  DispInfo
 This is the display information structure. More...
 

Macros

#define UNITS_INCHES   0
 
#define UNITS_FEET   1
 
#define UNITS_MILES   2
 
#define UNITS_MILLIMETERS   3
 
#define UNITS_CENTIMETERS   4
 
#define UNITS_METERS   5
 
#define UNITS_KILOMETERS   6
 
#define MAX_UNIT_TYPES   7
 
#define UNITDISP_GENERIC   0
 
#define UNITDISP_METRIC   1
 
#define UNITDISP_US   2
 
#define UNITDISP_CUSTOM   3
 
#define MAX_UNITDISP_TYPES   4
 
#define UNIT_METRIC_DISP_MM   0
 
#define UNIT_METRIC_DISP_CM   1
 
#define UNIT_METRIC_DISP_M   2
 
#define UNIT_METRIC_DISP_KM   3
 
#define MAX_METRIC_DISP_TYPES   4
 
#define UNIT_US_DISP_FRAC_IN   0
 
#define UNIT_US_DISP_DEC_IN   1
 
#define UNIT_US_DISP_FRAC_FT   2
 
#define UNIT_US_DISP_DEC_FT   3
 
#define UNIT_US_DISP_FT_FRAC_IN   4
 
#define UNIT_US_DISP_FT_DEC_IN   5
 
#define MAX_US_DISP_TYPES   6
 
#define UNIT_FRAC_1_1   0
 
#define UNIT_FRAC_1_2   1
 
#define UNIT_FRAC_1_4   2
 
#define UNIT_FRAC_1_8   3
 
#define UNIT_FRAC_1_10   4
 
#define UNIT_FRAC_1_16   5
 
#define UNIT_FRAC_1_32   6
 
#define UNIT_FRAC_1_64   7
 
#define UNIT_FRAC_1_100   8
 
#define MAX_FRAC_TYPES   9
 
#define UNIT_DESIG_MM   0
 
#define UNIT_DESIG_CM   1
 
#define UNIT_DESIG_M   2
 
#define UNIT_DESIG_KM   3
 
#define UNIT_DESIG_IN   4
 
#define UNIT_DESIG_FT   5
 
#define UNIT_DESIG_CUSTOM   6
 
#define UNIT_DESIG_TYPES   7
 
#define US_UNIT_DEFAULT_FEET   0
 
#define US_UNIT_DEFAULT_INCHES   1
 

Enumerations

enum  TimeDisp { DISPTIME_FRAMES, DISPTIME_SMPTE, DISPTIME_FRAMETICKS, DISPTIME_TIMETICKS }
 

Functions

CoreExport double GetMasterScale (int type)
 Retrieves the master scale in terms of the specified unit type. More...
 
CoreExport double GetRelativeScale (int fromType, float fromScale, int toType, float toScale)
 Computes a scaling factor for going from given System Units to others. More...
 
CoreExport void GetMasterUnitInfo (int *type, float *scale)
 Retrieves the master unit settings in effect. More...
 
CoreExport int SetMasterUnitInfo (int type, float scale)
 Sets the master unit settings. More...
 
CoreExport void GetUnitDisplayInfo (DispInfo *info)
 Retrieves the current unit display information. More...
 
CoreExport int SetUnitDisplayInfo (DispInfo *info)
 Sets the unit display information used by 3ds Max. More...
 
CoreExport int GetUnitDisplayType ()
 Returns the current unit display type to one of the following values: More...
 
CoreExport int SetUnitDisplayType (int type)
 Sets the current unit display type to one of the following values: More...
 
CoreExport BOOL IsValidUnitCharacter (int ch)
 
CoreExport void SetUSDefaultUnit (int type)
 
CoreExport int GetUSDefaultUnit ()
 
CoreExport const MCHARGetFirstUnitName ()
 
CoreExport const MCHARGetNextUnitName ()
 
CoreExport const MCHARGetFirstMetricDisp ()
 
CoreExport const MCHARGetNextMetricDisp ()
 
CoreExport const MCHARGetFirstUSDisp ()
 
CoreExport const MCHARGetNextUSDisp ()
 
CoreExport const MCHARGetFirstFraction ()
 
CoreExport const MCHARGetNextFraction ()
 
CoreExport const MCHARFormatUniverseValue (float value)
 Converts the specified value to an ASCII representation according to the current unit scale. More...
 
CoreExport float DecodeUniverseValue (const MCHAR *string, BOOL *valid=NULL)
 Parses the specified string using the current unit settings and converts it to a floating point value. More...
 
CoreExport void TimeToString (TimeValue t, MSTR &string)
 
CoreExport BOOL StringToTime (MSTR string, TimeValue &t)
 
CoreExport int GetFrameRate ()
 
CoreExport void SetFrameRate (int rate)
 
CoreExport int GetTicksPerFrame ()
 
CoreExport void SetTicksPerFrame (int ticks)
 
CoreExport TimeDisp GetTimeDisplayMode ()
 
CoreExport void SetTimeDisplayMode (TimeDisp m)
 
CoreExport int LegalFrameRate (int r)
 
CoreExport void RegisterDistanceDefault (const MCHAR *section, const MCHAR *key, float inchesDefault, float metersDefault)
 Registers a default value for a distance value. More...
 
CoreExport void RestoreDistanceDefault (const MCHAR *section, const MCHAR *key, float inchesDefault, float metersDefault)
 Restores the original default value for a distance value. More...
 
CoreExport float GetDistanceDefault (const MCHAR *section, const MCHAR *key)
 Gets the default for the given section and key in the defaults file. More...
 
CoreExport void SetDistanceDefault (const MCHAR *section, const MCHAR *key, float value)
 Sets the defaults for the given section and key in the defaults file. More...
 

Macro Definition Documentation

#define UNITS_INCHES   0
#define UNITS_FEET   1
#define UNITS_MILES   2
#define UNITS_MILLIMETERS   3
#define UNITS_CENTIMETERS   4
#define UNITS_METERS   5
#define UNITS_KILOMETERS   6
#define MAX_UNIT_TYPES   7
#define UNITDISP_GENERIC   0
#define UNITDISP_METRIC   1
#define UNITDISP_US   2
#define UNITDISP_CUSTOM   3
#define MAX_UNITDISP_TYPES   4
#define UNIT_METRIC_DISP_MM   0
#define UNIT_METRIC_DISP_CM   1
#define UNIT_METRIC_DISP_M   2
#define UNIT_METRIC_DISP_KM   3
#define MAX_METRIC_DISP_TYPES   4
#define UNIT_US_DISP_FRAC_IN   0
#define UNIT_US_DISP_DEC_IN   1
#define UNIT_US_DISP_FRAC_FT   2
#define UNIT_US_DISP_DEC_FT   3
#define UNIT_US_DISP_FT_FRAC_IN   4
#define UNIT_US_DISP_FT_DEC_IN   5
#define MAX_US_DISP_TYPES   6
#define UNIT_FRAC_1_1   0
#define UNIT_FRAC_1_2   1
#define UNIT_FRAC_1_4   2
#define UNIT_FRAC_1_8   3
#define UNIT_FRAC_1_10   4
#define UNIT_FRAC_1_16   5
#define UNIT_FRAC_1_32   6
#define UNIT_FRAC_1_64   7
#define UNIT_FRAC_1_100   8
#define MAX_FRAC_TYPES   9
#define UNIT_DESIG_MM   0
#define UNIT_DESIG_CM   1
#define UNIT_DESIG_M   2
#define UNIT_DESIG_KM   3
#define UNIT_DESIG_IN   4
#define UNIT_DESIG_FT   5
#define UNIT_DESIG_CUSTOM   6
#define UNIT_DESIG_TYPES   7
#define US_UNIT_DEFAULT_FEET   0
#define US_UNIT_DEFAULT_INCHES   1

Enumeration Type Documentation

enum TimeDisp
Enumerator
DISPTIME_FRAMES 
DISPTIME_SMPTE 
DISPTIME_FRAMETICKS 
DISPTIME_TIMETICKS 
203  {
208  };
Definition: units.h:206
Definition: units.h:205
Definition: units.h:204
Definition: units.h:207

Function Documentation

CoreExport double GetMasterScale ( int  type)

Retrieves the master scale in terms of the specified unit type.

For example, GetMasterScale(UNITS_INCHES) returns the number of inches per unit. Returns -1.0 if an invalid unit type is supplied.

CoreExport double GetRelativeScale ( int  fromType,
float  fromScale,
int  toType,
float  toScale 
)

Computes a scaling factor for going from given System Units to others.

Parameters
[in]fromType- type of System Units from which we start (a value going from UNITS_INCHES to UNITS_KILOMETERS).
[in]fromScale- scale of System Units from which we start.
[in]toType- type of System Units into which we want to rescale (a value going from UNITS_INCHES to UNITS_KILOMETERS).
[in]toScale- scale of System Units into which we want to rescale.
Returns
- The scale factor that is needed to scale from given System Units to others.
CoreExport void GetMasterUnitInfo ( int type,
float *  scale 
)

Retrieves the master unit settings in effect.

These are the unit type (Inches, Feet, Meters, and so on) and the master scale setting. This is the value that users enter in the "1 Unit = XXX field" of the General Page in the Preference Settings dialog box.

CoreExport int SetMasterUnitInfo ( int  type,
float  scale 
)

Sets the master unit settings.

These are the unit type (Inches, Feet, Meters, and so on) and the master scale setting.

CoreExport void GetUnitDisplayInfo ( DispInfo info)

Retrieves the current unit display information.

CoreExport int SetUnitDisplayInfo ( DispInfo info)

Sets the unit display information used by 3ds Max.

CoreExport int GetUnitDisplayType ( )

Returns the current unit display type to one of the following values:

  • UNITDISP_GENERIC
  • UNITDISP_METRIC
  • UNITDISP_US
  • UNITDISP_CUSTOM
CoreExport int SetUnitDisplayType ( int  type)

Sets the current unit display type to one of the following values:

  • UNITDISP_GENERIC
  • UNITDISP_METRIC
  • UNITDISP_US
  • UNITDISP_CUSTOM
CoreExport BOOL IsValidUnitCharacter ( int  ch)
CoreExport void SetUSDefaultUnit ( int  type)
CoreExport int GetUSDefaultUnit ( )
CoreExport const MCHAR* GetFirstUnitName ( )
CoreExport const MCHAR* GetNextUnitName ( )
CoreExport const MCHAR* GetFirstMetricDisp ( )
CoreExport const MCHAR* GetNextMetricDisp ( )
CoreExport const MCHAR* GetFirstUSDisp ( )
CoreExport const MCHAR* GetNextUSDisp ( )
CoreExport const MCHAR* GetFirstFraction ( )
CoreExport const MCHAR* GetNextFraction ( )
CoreExport const MCHAR* FormatUniverseValue ( float  value)

Converts the specified value to an ASCII representation according to the current unit scale.

Note that this can cause a string overflow, especially when the units are set to miles or kilometers. If an overflow occurs the function returns a null string (_T("")). So, developers can check for this condition using something like if (buf[0] == '\0') to see if an overflow occurred.

CoreExport float DecodeUniverseValue ( const MCHAR string,
BOOL *  valid = NULL 
)

Parses the specified string using the current unit settings and converts it to a floating point value.

If an error occurs in the parsing then valid is set to FALSE.

CoreExport void TimeToString ( TimeValue  t,
MSTR string 
)
CoreExport BOOL StringToTime ( MSTR  string,
TimeValue t 
)
CoreExport int GetFrameRate ( )
CoreExport void SetFrameRate ( int  rate)
CoreExport int GetTicksPerFrame ( )
CoreExport void SetTicksPerFrame ( int  ticks)
CoreExport TimeDisp GetTimeDisplayMode ( )
CoreExport void SetTimeDisplayMode ( TimeDisp  m)
CoreExport int LegalFrameRate ( int  r)
CoreExport void RegisterDistanceDefault ( const MCHAR section,
const MCHAR key,
float  inchesDefault,
float  metersDefault 
)

Registers a default value for a distance value.

The default has separate values for both Imperial and Metric systems. The Imperial default is given in inches and the Metric default is given in Meters.

CoreExport void RestoreDistanceDefault ( const MCHAR section,
const MCHAR key,
float  inchesDefault,
float  metersDefault 
)

Restores the original default value for a distance value.

CoreExport float GetDistanceDefault ( const MCHAR section,
const MCHAR key 
)

Gets the default for the given section and key in the defaults file.

The system returns the default relative to the current system units. If the units are Imperial (inches, feet, and so on) it returns the Imperial version of the default, otherwise it returns the Metric version. In either case the default value is returned in the current system units.

CoreExport void SetDistanceDefault ( const MCHAR section,
const MCHAR key,
float  value 
)

Sets the defaults for the given section and key in the defaults file.

The system sets the default relative to the current system units. If the units are Imperial (inches, feet, and so on) it sets the Imperial version of the default, otherwise it sets the Metric version.