GO2cam Javascript API
GO2SUnitUtil Class Reference

Format and parse values with the units of the GO2cam options. More...

Inherits QObject.

Static Public Member Functions

static String Format (Number value, Number type)
 
static String FormatAngle (Number value)
 
static String FormatLength (Number value)
 
static String GetAngleSuffix ()
 
static String GetLengthSuffix ()
 
static String GetSuffix (Number type)
 
static Boolean IsImperial ()
 
static Number Parse (String text, Number type)
 
static Number ParseAngle (String text)
 
static Number ParseLength (String text)
 

Detailed Description

Format and parse values with the units of the GO2cam options.

Values are always in GO2cam internal unit, as returned by the other API functions:

  • length: mm
  • angle: degree
  • time and duration: second
  • cutting speed: m/min, feedrate: mm/min, feed per tooth: mm/tooth, feed per revolution: mm/rev
  • rotation speed: rpm, angular speed: degree/s, power: kW, moment: N.m
  • weight: g, volumic mass: kg/m3, flow: cm/min, strength: N/mm2

The unit types of the other functions are given by the GO2SUnitType enum: GeometryLength, GeometryAngle, Weight, Currency, MachiningTime, CuttingSpeed, FeedRate, RotationSpeed, Power, FeedPerTooth, FeedPerRevolution, Moment, Flow, VolumicMass, Strength, AngularSpeed, Duration

GO2SDialogUtil.SetText("m_lblFeed", GO2SUnitUtil.Format(1200, GO2SUnitType.FeedRate))
Helper containing utility methods for dialog.
Definition GO2SDialogUtil.hpp:14
Format and parse values with the units of the GO2cam options.
Definition GO2SUnitUtil.hpp:29
static String FormatLength(Number value)
static String Format(Number value, Number type)
static void SetText(String name, String value)
Version
2027

Member Function Documentation

◆ Format()

static String GO2SUnitUtil::Format ( Number value,
Number type )
static

Format a value with the unit of the options

var text = GO2SUnitUtil.Format(1200, GO2SUnitType.FeedRate) // "1200 mm/min" or "47.24 in/min"
Returns
the formatted text with its suffix, for display only. The raw value if the type is invalid
Version
2027
Parameters
[in]valuevalue in GO2cam internal unit
[in]typeunit type, see GO2SUnitType

◆ FormatAngle()

static String GO2SUnitUtil::FormatAngle ( Number value)
static

Format an angle with the unit of the options

var text = GO2SUnitUtil.FormatAngle(45) // "45¶ø" or "0.7854 rad"
static String FormatAngle(Number value)
Returns
the formatted text with its suffix, for display only
Version
2027
Parameters
[in]valueangle in degree

◆ FormatLength()

static String GO2SUnitUtil::FormatLength ( Number value)
static

Format a length with the unit of the options

var text = GO2SUnitUtil.FormatLength(12.5) // "12.5 mm" or "0.4921 in"
Returns
the formatted text with its suffix, for display only
Version
2027
Parameters
[in]valuelength in mm

◆ GetAngleSuffix()

static String GO2SUnitUtil::GetAngleSuffix ( )
static

Get the suffix of the angle unit of the options

Returns
the suffix ("¶ø", "rad"...)
Version
2027

◆ GetLengthSuffix()

static String GO2SUnitUtil::GetLengthSuffix ( )
static

Get the suffix of the length unit of the options

var header = "Diameter (" + GO2SUnitUtil.GetLengthSuffix() + ")"
static String GetLengthSuffix()
Returns
the suffix ("mm", "in"...)
Version
2027

◆ GetSuffix()

static String GO2SUnitUtil::GetSuffix ( Number type)
static

Get the suffix of a unit of the options

var suffix = GO2SUnitUtil.GetSuffix(GO2SUnitType.CuttingSpeed)
static String GetSuffix(Number type)
Returns
the suffix, empty if the type is invalid
Version
2027
Parameters
[in]typeunit type, see GO2SUnitType

◆ IsImperial()

static Boolean GO2SUnitUtil::IsImperial ( )
static

Check if the length unit of the options is imperial

Returns
true for inch, feet, yard, mile
Version
2027

◆ Parse()

static Number GO2SUnitUtil::Parse ( String text,
Number type )
static

Read a value typed by the user

Warning
a value without unit is in the unit of the options
var feed = GO2SUnitUtil.Parse("50 in/min", GO2SUnitType.FeedRate)
static Number Parse(String text, Number type)
Returns
the value in GO2cam internal unit, NaN if the text or the type is not valid
Version
2027
Parameters
[in]textvalue with optional unit, or expression
[in]typeunit type, see GO2SUnitType

◆ ParseAngle()

static Number GO2SUnitUtil::ParseAngle ( String text)
static

Read an angle typed by the user

Warning
a value without unit is in the unit of the options. DMS text is not read
var angle = GO2SUnitUtil.ParseAngle("0.5 rad")
static Number ParseAngle(String text)
Returns
the angle in degree, NaN if the text is not valid
Version
2027
Parameters
[in]textvalue with optional unit, or expression ("90/4")

◆ ParseLength()

static Number GO2SUnitUtil::ParseLength ( String text)
static

Read a length typed by the user

Warning
a value without unit is in the unit of the options: add the unit to read a value from a file
var length = GO2SUnitUtil.ParseLength("1/2 in") // 12.7
var fromFile = GO2SUnitUtil.ParseLength(csvValue + " mm")
static Number ParseLength(String text)
Returns
the length in mm, NaN if the text is not valid
Version
2027
Parameters
[in]textvalue with optional unit, or expression ("10+2")