Rhino C++ API  8.14
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
ON_ScaleValue Class Reference

#include <opennurbs_string_value.h>

Public Types

enum  ScaleStringFormat : unsigned char {
  ScaleStringFormat::None = 0, ScaleStringFormat::RatioFormat = 1, ScaleStringFormat::EquationFormat = 2, ScaleStringFormat::FractionFormat = 3,
  ScaleStringFormat::Unset = 0xFF
}
 Specifies preferred formats for automatically created string descriptions of a scale value. More...
 

Public Member Functions

 ON_ScaleValue ()=default
 
 ON_ScaleValue (const ON_ScaleValue &)=default
 
 ~ON_ScaleValue ()=default
 
const ON_SHA1_Hash ContentHash () const
 
bool IsSet () const
 
bool IsUnset () const
 
const class ON_LengthValueLeftLengthValue () const
 
double LeftToRightScale () const
 
ON_ScaleValueoperator= (const ON_ScaleValue &)=default
 
bool Read (class ON_BinaryArchive &archive)
 
const class ON_LengthValueRightLengthValue () const
 
double RightToLeftScale () const
 
const ON_wStringScaleAsString () const
 
const wchar_t * ScaleAsStringPointer () const
 
const ON_ParseSettings ScaleStringParseSettings () const
 
void SwapLeftAndRight ()
 
bool Write (class ON_BinaryArchive &archive) const
 

Static Public Member Functions

static int Compare (const ON_ScaleValue &lhs, const ON_ScaleValue &rhs)
 
static ON_ScaleValue Create (const class ON_LengthValue &left_side_length, const class ON_LengthValue &right_side_length, ON_ScaleValue::ScaleStringFormat string_format_preference)
 
static ON_ScaleValue CreateFromString (ON_ParseSettings parse_settings, const wchar_t *string)
 
static ON_ScaleValue CreateFromSubString (ON_ParseSettings parse_settings, const wchar_t *string, int string_count, const wchar_t **string_end)
 
static ON_ScaleValue::ScaleStringFormat ScaleStringFormatFromUnsigned (unsigned int scale_string_format_as_unsigned)
 

Static Public Attributes

static const ON_ScaleValue OneToOne
 
static const ON_ScaleValue Unset
 

Member Enumeration Documentation

◆ ScaleStringFormat

enum ON_ScaleValue::ScaleStringFormat : unsigned char
strong

Specifies preferred formats for automatically created string descriptions of a scale value.

Enumerator
None 

No preference for automatically created string descriptions of a scale value.

RatioFormat 

Prefer the ratio format using a colon, like "1:4" or "4:1".

EquationFormat 

Prefer the equation format using an equal sign, like "1 = 4" or "4 = 1".

FractionFormat 

Prefer the fraction format using a slash, like "1/4" or "4/1".

Unset 

ON_ScaleValue::ScaleStringFormat::Unset is used to indicate no preference is set. This condition is different from ON_ScaleValue::ScaleStringFormat::None.

Constructor & Destructor Documentation

◆ ON_ScaleValue() [1/2]

ON_ScaleValue::ON_ScaleValue ( )
default

◆ ~ON_ScaleValue()

ON_ScaleValue::~ON_ScaleValue ( )
default

◆ ON_ScaleValue() [2/2]

ON_ScaleValue::ON_ScaleValue ( const ON_ScaleValue )
default

Member Function Documentation

◆ Compare()

static int ON_ScaleValue::Compare ( const ON_ScaleValue lhs,
const ON_ScaleValue rhs 
)
static

◆ ContentHash()

const ON_SHA1_Hash ON_ScaleValue::ContentHash ( ) const

◆ Create()

static ON_ScaleValue ON_ScaleValue::Create ( const class ON_LengthValue left_side_length,
const class ON_LengthValue right_side_length,
ON_ScaleValue::ScaleStringFormat  string_format_preference 
)
static

Parameters: left_length - [in] right_length - [in] Returns: A scale value for converting a distance from source_length to destination_length. Remarks: If you don't like the automatically created string value, then format the string yourself and use ON_ScaleValue::CreateFromString().

◆ CreateFromString()

static ON_ScaleValue ON_ScaleValue::CreateFromString ( ON_ParseSettings  parse_settings,
const wchar_t *  string 
)
static

Description: Create an ON_ScaleValue by parsing a string. Parameters: parse_settings - [in] Pass ON_ParseSettings(context_length_unit_system,context_angle_unit_system,context_locale_id) string - [in] null terminated string to parse. Returns: If the string is valid, the exact scale value is returned. If the string is not valid or parsing ends before the string's null terminator, the ON_ScaleValue::Unset is returned. Remarks: If the entire string is not parsed, that is an error condition. Use CreateFromSubString() to permit parsing a portion of the string. Examples: "1:4", "1=4", "1/4", "0.25" will set LeftToRightScale() = 4, RightToLeftScale() = 0.25

"4:1", "4=1", "4/1", "4" will set LeftToRightScale() = 0.25, RightToLeftScale() = 4

"100:1", "100=1", "1 meter = 1 centimeter" will set LeftToRightScale() = 0.01, RightToLeftScale() = 100

"1:100", "1=100", "1 centimeter = 1 meter" will set LeftToRightScale() = 100, RightToLeftScale() = 0.01

"12:1", "12=1", "12/1", "12", "1 foot = 1 inch" will set LeftToRightScale() = 0.08333..., RightToLeftScale() = 12

"1:12", "1=12", "1/12", "1 inch = 1 foot" will set LeftToRightScale() = 12, RightToLeftScale() = 0.08333...

"1:48", "1 = 48", "1/4 inch = 1 foot" will set LeftToRightScale() = 48, RightToLeftScale() = 0.0208333...

◆ CreateFromSubString()

static ON_ScaleValue ON_ScaleValue::CreateFromSubString ( ON_ParseSettings  parse_settings,
const wchar_t *  string,
int  string_count,
const wchar_t **  string_end 
)
static

Description: Create an ON_ScaleValue by parsing a string. Parameters: parse_settings - [in] Pass ON_ParseSettings(context_length_unit_system,context_angle_unit_system,context_locale_id) string - [in] null terminated string to parse. string_count - [in] string[] and string_count specify the string to parse. If string_count >= 0, it specifies the maximum number of elements in string[] that may be parsed. If string_count = -1, then the string must contain a character that terminates scale parsing. string_end - [out] If string_end is not nullptr, then *string_end points to the first element in the string that was not parsed. Returns: If the string is valid, the exact scale value is returned. If the string is not valid or parsing ends before the string's null terminator, the ON_ScaleValue::Unset is returned. Remarks: If the entire string is not parsed, that is an error condition. Use CreateFromSubString() to permit parsing a portion of the string.

Examples: "1:4", "1=4", "1/4", "0.25" will set LeftToRightScale() = 4, RightToLeftScale() = 0.25

"4:1", "4=1", "4/1", "4" will set LeftToRightScale() = 0.25, RightToLeftScale() = 4

"100:1", "100=1", "1 meter = 1 centimeter" will set LeftToRightScale() = 0.01, RightToLeftScale() = 100

"1:100", "1=100", "1 centimeter = 1 meter" will set LeftToRightScale() = 100, RightToLeftScale() = 0.01

"12:1", "12=1", "12/1", "12", "1 foot = 1 inch" will set LeftToRightScale() = 0.08333..., RightToLeftScale() = 12

"1:12", "1=12", "1/12", "1 inch = 1 foot" will set LeftToRightScale() = 12, RightToLeftScale() = 0.08333...

"1:48", "1 = 48", "1/4 inch = 1 foot" will set LeftToRightScale() = 48, RightToLeftScale() = 0.0208333...

◆ IsSet()

bool ON_ScaleValue::IsSet ( ) const

◆ IsUnset()

bool ON_ScaleValue::IsUnset ( ) const

◆ LeftLengthValue()

const class ON_LengthValue& ON_ScaleValue::LeftLengthValue ( ) const

◆ LeftToRightScale()

double ON_ScaleValue::LeftToRightScale ( ) const

Returns: A dimensionless scale factor. The word "dimensionless" is critical. Differences in left and right side unit systems are accounted for in the returned value. Remarks: LeftToRightScale() = 1.0/RightToLeftScale() Examples: "1:4", "1=4", "1/4", "0.25" will set LeftToRightScale() = 4, RightToLeftScale() = 0.25

"4:1", "4=1", "4/1", "4" will set LeftToRightScale() = 0.25, RightToLeftScale() = 4

"100:1", "100=1", "1 meter = 1 centimeter" will set LeftToRightScale() = 0.01, RightToLeftScale() = 100

"1:100", "1=100", "1 centimeter = 1 meter" will set LeftToRightScale() = 100, RightToLeftScale() = 0.01

"12:1", "12=1", "12/1", "12", "1 foot = 1 inch" will set LeftToRightScale() = 0.08333..., RightToLeftScale() = 12

"1:12", "1=12", "1/12", "1 inch = 1 foot" will set LeftToRightScale() = 12, RightToLeftScale() = 0.08333...

"1:48", "1 = 48", "1/4 inch = 1 foot" will set LeftToRightScale() = 48, RightToLeftScale() = 0.0208333...

◆ operator=()

ON_ScaleValue& ON_ScaleValue::operator= ( const ON_ScaleValue )
default

◆ Read()

bool ON_ScaleValue::Read ( class ON_BinaryArchive archive)

◆ RightLengthValue()

const class ON_LengthValue& ON_ScaleValue::RightLengthValue ( ) const

◆ RightToLeftScale()

double ON_ScaleValue::RightToLeftScale ( ) const

Returns: A dimensionless scale factor. The word "dimensionless" is critical. Differences in left and right side unit systems are accounted for in the returned value. Remarks: RightToLeftScale() = 1.0/LeftToRightScale() Examples: "1:4", "1=4", "1/4", "0.25" will set LeftToRightScale() = 4, RightToLeftScale() = 0.25

"4:1", "4=1", "4/1", "4" will set LeftToRightScale() = 0.25, RightToLeftScale() = 4

"100:1", "100=1", "1 meter = 1 centimeter" will set LeftToRightScale() = 0.01, RightToLeftScale() = 100

"1:100", "1=100", "1 centimeter = 1 meter" will set LeftToRightScale() = 100, RightToLeftScale() = 0.01

"12:1", "12=1", "12/1", "12", "1 foot = 1 inch" will set LeftToRightScale() = 0.08333..., RightToLeftScale() = 12

"1:12", "1=12", "1/12", "1 inch = 1 foot" will set LeftToRightScale() = 12, RightToLeftScale() = 0.08333...

"1:48", "1 = 48", "1/4 inch = 1 foot" will set LeftToRightScale() = 48, RightToLeftScale() = 0.0208333...

◆ ScaleAsString()

const ON_wString& ON_ScaleValue::ScaleAsString ( ) const

Returns: The scale as a string. Remarks: If ON_ScaleValue::CreateFromString() or ON_ScaleValue::CreateFromSubString() were used to create this ON_ScaleValue, a copy of that string is returned.

◆ ScaleAsStringPointer()

const wchar_t* ON_ScaleValue::ScaleAsStringPointer ( ) const

◆ ScaleStringFormatFromUnsigned()

static ON_ScaleValue::ScaleStringFormat ON_ScaleValue::ScaleStringFormatFromUnsigned ( unsigned int  scale_string_format_as_unsigned)
static

◆ ScaleStringParseSettings()

const ON_ParseSettings ON_ScaleValue::ScaleStringParseSettings ( ) const

◆ SwapLeftAndRight()

void ON_ScaleValue::SwapLeftAndRight ( )

Description Exchange the left and right lengths.

◆ Write()

bool ON_ScaleValue::Write ( class ON_BinaryArchive archive) const

Member Data Documentation

◆ OneToOne

const ON_ScaleValue ON_ScaleValue::OneToOne
static

◆ Unset

const ON_ScaleValue ON_ScaleValue::Unset
static