Rhino C++ API  7.24
Public Types | Public Member Functions | Static Public Member Functions | List of all members
CRhRdkVariant Class Referencefinal

#include <RhRdkVariant.h>

Public Types

enum  VariantType {
  vtNull = 0, vtBool = 1, vtInteger = 2, vtFloat = 3,
  vtDouble = 4, vtColor = 5, vtVector2d = 6, vtVector3d = 7,
  vtString = 8, vtPointer = 9, vtUuid = 10, vtMatrix = 11,
  vtTime = 12, vtBuffer = 13, vtPoint4d = 14, vtForce32bit = 0xFFFFFFFF
}
 

Public Member Functions

 CRhRdkVariant ()
 
 CRhRdkVariant (bool b)
 
 CRhRdkVariant (const char *sz)
 
 CRhRdkVariant (const CRhRdkColor &c)
 
 CRhRdkVariant (const CRhRdkVariant &v)
 
 CRhRdkVariant (const ON_2dVector &v)
 
 CRhRdkVariant (const ON_3dVector &v)
 
 CRhRdkVariant (const ON_4dPoint &p)
 
 CRhRdkVariant (const ON_4fColor &c)
 
 CRhRdkVariant (const ON_Color &c)
 
 CRhRdkVariant (const ON_Xform &xform)
 
 CRhRdkVariant (const time_t &time)
 
 CRhRdkVariant (const UUID &uuid)
 
 CRhRdkVariant (const void *pData, size_t size)
 
 CRhRdkVariant (const wchar_t *wsz)
 
 CRhRdkVariant (double d)
 
 CRhRdkVariant (float f)
 
 CRhRdkVariant (int i)
 
 CRhRdkVariant (void *p)
 
 ~CRhRdkVariant ()
 
bool AsBool (void) const
 
const void * AsBuffer (size_t &sizeOut) const
 
double AsDouble (void) const
 
float AsFloat (void) const
 
int AsInteger (void) const
 
ON_Xform AsMatrix (void) const
 
double AsModelDouble (const CRhinoDoc *pDoc) const
 
float AsModelFloat (const CRhinoDoc *pDo) const
 
ON_Color AsOn4fColor (void) const
 
ON_Color AsOnColor (void) const
 
ON_4dPoint AsPoint4d (void) const
 
void * AsPointer (void) const
 
CRhRdkColor AsRdkColor (void) const
 
bool AsSmartBool (bool bNullResult=false, bool bVariesResult=true) const
 
double AsSmartDouble (double dNullResult=0.0, double dVariesResult=0.0) const
 
const wchar_t * AsSmartString (const wchar_t *wszNullResult=L"", const wchar_t *wszVariesResult=L"") const
 
const wchar_t * AsString (void) const
 
time_t AsTime (void) const
 
UUID AsUuid (void) const
 
ON_2dVector AsVector2d (void) const
 
ON_3dVector AsVector3d (void) const
 
DWORD CalculateCRC (void) const
 
void ChangeType (VariantType)
 
void * EF (const wchar_t *wszFunc, void *pvData)
 
void Format (ON_wString &sOut) const
 
bool IsNull (void) const
 
 operator bool (void) const
 
 operator const wchar_t * (void) const
 
 operator CRhRdkColor (void) const
 
 operator double (void) const
 
 operator float (void) const
 
 operator int (void) const
 
 operator ON_2dVector (void) const
 
 operator ON_3dVector (void) const
 
 operator ON_4dPoint (void) const
 
 operator ON_4fColor (void) const
 
 operator ON_Color (void) const
 
 operator ON_Xform (void) const
 
 operator time_t (void) const
 
 operator UUID (void) const
 
 operator void * (void) const
 
bool operator!= (const CRhRdkVariant &v) const
 
bool operator< (const CRhRdkVariant &v) const
 
const CRhRdkVariantoperator= (bool b)
 
const CRhRdkVariantoperator= (const char *sz)
 
const CRhRdkVariantoperator= (const CRhRdkVariant &v)
 
const CRhRdkVariantoperator= (const ON_2dVector &v)
 
const CRhRdkVariantoperator= (const ON_3dVector &v)
 
const CRhRdkVariantoperator= (const ON_4dPoint &p)
 
const CRhRdkVariantoperator= (const ON_4fColor &c)
 
const CRhRdkVariantoperator= (const ON_Color &c)
 
const CRhRdkVariantoperator= (const ON_Xform &xform)
 
const CRhRdkVariantoperator= (const time_t &time)
 
const CRhRdkVariantoperator= (const UUID &uuid)
 
const CRhRdkVariantoperator= (const wchar_t *wsz)
 
const CRhRdkVariantoperator= (double d)
 
const CRhRdkVariantoperator= (float f)
 
const CRhRdkVariantoperator= (int i)
 
const CRhRdkVariantoperator= (void *p)
 
bool operator== (const CRhRdkVariant &v) const
 
bool operator> (const CRhRdkVariant &v) const
 
void SetAsModelDouble (double d, const CRhinoDoc *pDoc)
 
void SetAsModelFloat (float f, const CRhinoDoc *pDoc)
 
void SetNull (void)
 
void SetUnits (ON::LengthUnitSystem units)
 
void SetValue (bool b)
 
void SetValue (const char *sz)
 
void SetValue (const CRhRdkColor &c)
 
void SetValue (const ON_2dVector &v)
 
void SetValue (const ON_3dVector &v)
 
void SetValue (const ON_4dPoint &p)
 
void SetValue (const ON_4fColor &c)
 
void SetValue (const ON_Color &c)
 
void SetValue (const ON_Xform &xform)
 
void SetValue (const time_t &time)
 
void SetValue (const UUID &uuid)
 
void SetValue (const void *pBuffer, size_t size)
 
void SetValue (const wchar_t *wsz)
 
void SetValue (double v)
 
void SetValue (float v)
 
void SetValue (int v)
 
void SetValue (void *p)
 
void SetVaries (void)
 
VariantType Type (void) const
 
ON::LengthUnitSystem Units (void) const
 
bool Varies (void) const
 

Static Public Member Functions

static const CRhRdkVariantNull (void)
 

Detailed Description

The RDK variant is an object that can hold data of different types. It is primarily used by the automatic user interface system to provide a unified way of passing parameters to and from the user interface.

A null variant has a type of vtNull and no value.

Use the 'varying' feature to represent multiple different values of the same type. This is useful for property pages etc. If you use this feature, you must check Varies() before retrieving the value. If you never call SetVaries() then you never have to call Varies().

When reading the value, conversion will be performed if necessary.

Note
It is not possible to retrieve the value if the variant is null or varying. An assert will occur if this is attempted.

This class has no virtual functions and should not be subclassed.

Member Enumeration Documentation

◆ VariantType

Variant type.

Enumerator
vtNull 
vtBool 
vtInteger 
vtFloat 
vtDouble 
vtColor 
vtVector2d 
vtVector3d 
vtString 
vtPointer 
vtUuid 
vtMatrix 
vtTime 
vtBuffer 
vtPoint4d 
vtForce32bit 

Constructor & Destructor Documentation

◆ ~CRhRdkVariant()

CRhRdkVariant::~CRhRdkVariant ( )

◆ CRhRdkVariant() [1/19]

CRhRdkVariant::CRhRdkVariant ( )

Construct as null.

◆ CRhRdkVariant() [2/19]

CRhRdkVariant::CRhRdkVariant ( int  i)

Construct from an integer.

◆ CRhRdkVariant() [3/19]

CRhRdkVariant::CRhRdkVariant ( bool  b)

Construct from a boolean.

◆ CRhRdkVariant() [4/19]

CRhRdkVariant::CRhRdkVariant ( float  f)

Construct from a float.

◆ CRhRdkVariant() [5/19]

CRhRdkVariant::CRhRdkVariant ( double  d)

Construct from a double.

◆ CRhRdkVariant() [6/19]

CRhRdkVariant::CRhRdkVariant ( const char *  sz)

Construct from a string.

◆ CRhRdkVariant() [7/19]

CRhRdkVariant::CRhRdkVariant ( const wchar_t *  wsz)

Construct from a wide string.

◆ CRhRdkVariant() [8/19]

CRhRdkVariant::CRhRdkVariant ( const ON_Color c)

Construct from a color.

◆ CRhRdkVariant() [9/19]

CRhRdkVariant::CRhRdkVariant ( const CRhRdkColor c)

Construct from an RDK color.

◆ CRhRdkVariant() [10/19]

CRhRdkVariant::CRhRdkVariant ( const ON_4fColor c)

Construct from a float color.

◆ CRhRdkVariant() [11/19]

CRhRdkVariant::CRhRdkVariant ( const ON_2dVector v)

Construct from a 2 dimensional vector.

◆ CRhRdkVariant() [12/19]

CRhRdkVariant::CRhRdkVariant ( const ON_3dVector v)

Construct from a 3 dimensional vector.

◆ CRhRdkVariant() [13/19]

CRhRdkVariant::CRhRdkVariant ( const ON_4dPoint p)

Construct from a 4 dimensional point.

◆ CRhRdkVariant() [14/19]

CRhRdkVariant::CRhRdkVariant ( void *  p)

Construct from a pointer. The variant treats the pointer as an opaque 32-bit value.

◆ CRhRdkVariant() [15/19]

CRhRdkVariant::CRhRdkVariant ( const UUID &  uuid)

Construct from a UUID.

◆ CRhRdkVariant() [16/19]

CRhRdkVariant::CRhRdkVariant ( const ON_Xform xform)

Construct from a matrix.

◆ CRhRdkVariant() [17/19]

CRhRdkVariant::CRhRdkVariant ( const time_t &  time)

Construct from a time.

◆ CRhRdkVariant() [18/19]

CRhRdkVariant::CRhRdkVariant ( const void *  pData,
size_t  size 
)

Construct from a buffer.

◆ CRhRdkVariant() [19/19]

CRhRdkVariant::CRhRdkVariant ( const CRhRdkVariant v)

Construct from another variant.

Member Function Documentation

◆ AsBool()

bool CRhRdkVariant::AsBool ( void  ) const

Retrieve the value as a boolean. Null or varying returns false.

◆ AsBuffer()

const void* CRhRdkVariant::AsBuffer ( size_t &  sizeOut) const

Retrieve the value as a buffer. Null or varying returns NULL pointer and zero length.

◆ AsDouble()

double CRhRdkVariant::AsDouble ( void  ) const

Retrieve the value as a double. Null or varying returns 0.0.

◆ AsFloat()

float CRhRdkVariant::AsFloat ( void  ) const

Retrieve the value as a float. Null or varying returns 0.0f.

◆ AsInteger()

int CRhRdkVariant::AsInteger ( void  ) const

Retrieve the value as an integer. Null or varying returns 0.

◆ AsMatrix()

ON_Xform CRhRdkVariant::AsMatrix ( void  ) const

Retrieve the value as a matrix. Null or varying returns zero matrix.

◆ AsModelDouble()

double CRhRdkVariant::AsModelDouble ( const CRhinoDoc pDoc) const

Retrieve the value as a double in model units. Null or varying returns 0.0. The value will be converted from the variant's units to model units if necessary.

See also
Units().
SetUnits().

◆ AsModelFloat()

float CRhRdkVariant::AsModelFloat ( const CRhinoDoc pDo) const

Retrieve the value as a float in model units. Null or varying returns 0.0. The value will be converted from the variant's units to model units if necessary.

See also
Units().
SetUnits().

◆ AsOn4fColor()

ON_Color CRhRdkVariant::AsOn4fColor ( void  ) const

Retrieve the value as an ON_4fColor. Null or varying returns black.

◆ AsOnColor()

ON_Color CRhRdkVariant::AsOnColor ( void  ) const

Retrieve the value as an ON_Color. Null or varying returns black.

◆ AsPoint4d()

ON_4dPoint CRhRdkVariant::AsPoint4d ( void  ) const

Retrieve the value as a 4 dimensional point. Null or varying returns (0, 0, 0, 0).

◆ AsPointer()

void* CRhRdkVariant::AsPointer ( void  ) const

Retrieve the value as a pointer. Null or varying returns NULL.

◆ AsRdkColor()

CRhRdkColor CRhRdkVariant::AsRdkColor ( void  ) const

Retrieve the value as a CRhRdkColor. Null or varying returns black.

◆ AsSmartBool()

bool CRhRdkVariant::AsSmartBool ( bool  bNullResult = false,
bool  bVariesResult = true 
) const

It is often necessary to get a variant as a boolean, especially in dialogs with lots of check boxes. This helper retrieves the value as a boolean ensuring that null and varying are handled correctly. Null returns bNullResult, varying returns bVariesResult.

◆ AsSmartDouble()

double CRhRdkVariant::AsSmartDouble ( double  dNullResult = 0.0,
double  dVariesResult = 0.0 
) const

It is often necessary to get a variant as a double, especially in dialogs with lots of numeric edit boxes. This helper retrieves the value as a double ensuring that null and varying are handled correctly. Null returns dNullResult, varying returns dVariesResult.

◆ AsSmartString()

const wchar_t* CRhRdkVariant::AsSmartString ( const wchar_t *  wszNullResult = L"",
const wchar_t *  wszVariesResult = L"" 
) const

It is often necessary to get a variant as a string, especially in dialogs with lots of combo boxes. This helper retrieves the value as a string ensuring that null and varying are handled correctly. Null returns wszNullResult, varying returns wszVariesResult.

◆ AsString()

const wchar_t* CRhRdkVariant::AsString ( void  ) const

Retrieve the value as a wide string. Null returns "NULL", varying returns "VARIES".

◆ AsTime()

time_t CRhRdkVariant::AsTime ( void  ) const

Retrieve the value as a time. Null or varying returns zero time.

◆ AsUuid()

UUID CRhRdkVariant::AsUuid ( void  ) const

Retrieve the value as a UUID. Null or varying returns ON_nil_uuid.

◆ AsVector2d()

ON_2dVector CRhRdkVariant::AsVector2d ( void  ) const

Retrieve the value as a 2 dimensional vector. Null or varying returns (0, 0).

◆ AsVector3d()

ON_3dVector CRhRdkVariant::AsVector3d ( void  ) const

Retrieve the value as a 3 dimensional vector. Null or varying returns (0, 0, 0).

◆ CalculateCRC()

DWORD CRhRdkVariant::CalculateCRC ( void  ) const

Calculates a CRC for the variant's state. If the variant is null or 'varies' this will be zero.

Returns
CRC value which is never zero for a valid variant.

◆ ChangeType()

void CRhRdkVariant::ChangeType ( VariantType  )

Change the type of the variant while retaining the data as close as possible.

◆ EF()

void* CRhRdkVariant::EF ( const wchar_t *  wszFunc,
void *  pvData 
)

Emergency function for future expansion.

◆ Format()

void CRhRdkVariant::Format ( ON_wString sOut) const

Format string as type and value. Useful for debugging.

◆ IsNull()

bool CRhRdkVariant::IsNull ( void  ) const

Check if the variant is null.

◆ Null()

static const CRhRdkVariant& CRhRdkVariant::Null ( void  )
static

General purpose null variant for use in return values where a null variant means "nothing".

◆ operator bool()

CRhRdkVariant::operator bool ( void  ) const

◆ operator const wchar_t *()

CRhRdkVariant::operator const wchar_t * ( void  ) const

◆ operator CRhRdkColor()

CRhRdkVariant::operator CRhRdkColor ( void  ) const

◆ operator double()

CRhRdkVariant::operator double ( void  ) const

◆ operator float()

CRhRdkVariant::operator float ( void  ) const

◆ operator int()

CRhRdkVariant::operator int ( void  ) const

◆ operator ON_2dVector()

CRhRdkVariant::operator ON_2dVector ( void  ) const

◆ operator ON_3dVector()

CRhRdkVariant::operator ON_3dVector ( void  ) const

◆ operator ON_4dPoint()

CRhRdkVariant::operator ON_4dPoint ( void  ) const

◆ operator ON_4fColor()

CRhRdkVariant::operator ON_4fColor ( void  ) const

◆ operator ON_Color()

CRhRdkVariant::operator ON_Color ( void  ) const

◆ operator ON_Xform()

CRhRdkVariant::operator ON_Xform ( void  ) const

◆ operator time_t()

CRhRdkVariant::operator time_t ( void  ) const

◆ operator UUID()

CRhRdkVariant::operator UUID ( void  ) const

◆ operator void *()

CRhRdkVariant::operator void * ( void  ) const

◆ operator!=()

bool CRhRdkVariant::operator!= ( const CRhRdkVariant v) const

Inequality check.

◆ operator<()

bool CRhRdkVariant::operator< ( const CRhRdkVariant v) const

Less-than check.

◆ operator=() [1/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( bool  b)

Assign from a boolean.

◆ operator=() [2/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( const char *  sz)

Assign from a string.

◆ operator=() [3/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( const CRhRdkVariant v)

Assign from another variant. Null and varying can be copied.

◆ operator=() [4/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( const ON_2dVector v)

Assign from a 2 dimensional vector.

◆ operator=() [5/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( const ON_3dVector v)

Assign from a 3 dimensional vector.

◆ operator=() [6/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( const ON_4dPoint p)

Assign from a 4 dimensional point.

◆ operator=() [7/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( const ON_4fColor c)

Assign from a float color.

◆ operator=() [8/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( const ON_Color c)

Assign from a color.

◆ operator=() [9/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( const ON_Xform xform)

Assign from a matrix.

◆ operator=() [10/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( const time_t &  time)

Assign from a time.

◆ operator=() [11/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( const UUID &  uuid)

Assign from a UUID.

◆ operator=() [12/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( const wchar_t *  wsz)

Assign from a wide string.

◆ operator=() [13/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( double  d)

Assign from a double.

◆ operator=() [14/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( float  f)

Assign from a float.

◆ operator=() [15/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( int  i)

Assign from an integer.

◆ operator=() [16/16]

const CRhRdkVariant& CRhRdkVariant::operator= ( void *  p)

Assign from a pointer. The variant treats the pointer as an opaque 32-bit value.

◆ operator==()

bool CRhRdkVariant::operator== ( const CRhRdkVariant v) const

Equality check.

◆ operator>()

bool CRhRdkVariant::operator> ( const CRhRdkVariant v) const

Greater-than check.

◆ SetAsModelDouble()

void CRhRdkVariant::SetAsModelDouble ( double  d,
const CRhinoDoc pDoc 
)

Set the value to a double in model units. The value will be converted from model units to the variant's units if necessary.

See also
Units().
SetUnits().

◆ SetAsModelFloat()

void CRhRdkVariant::SetAsModelFloat ( float  f,
const CRhinoDoc pDoc 
)

Set the value to a float in model units. The value will be converted from model units to the variant's units if necessary.

See also
Units().
SetUnits().

◆ SetNull()

void CRhRdkVariant::SetNull ( void  )

Set the variant to be null. Can be called at any time.

◆ SetUnits()

void CRhRdkVariant::SetUnits ( ON::LengthUnitSystem  units)

Set the units associated with numeric values.

See also
AsModelFloat().
AsModelDouble().
SetAsModelFloat().
SetAsModelDouble().

◆ SetValue() [1/17]

void CRhRdkVariant::SetValue ( bool  b)

◆ SetValue() [2/17]

void CRhRdkVariant::SetValue ( const char *  sz)

◆ SetValue() [3/17]

void CRhRdkVariant::SetValue ( const CRhRdkColor c)

Set the value to an RDK color.

◆ SetValue() [4/17]

void CRhRdkVariant::SetValue ( const ON_2dVector v)

◆ SetValue() [5/17]

void CRhRdkVariant::SetValue ( const ON_3dVector v)

◆ SetValue() [6/17]

void CRhRdkVariant::SetValue ( const ON_4dPoint p)

◆ SetValue() [7/17]

void CRhRdkVariant::SetValue ( const ON_4fColor c)

◆ SetValue() [8/17]

void CRhRdkVariant::SetValue ( const ON_Color c)

◆ SetValue() [9/17]

void CRhRdkVariant::SetValue ( const ON_Xform xform)

Set the value to a matrix.

◆ SetValue() [10/17]

void CRhRdkVariant::SetValue ( const time_t &  time)

Set the value to a time.

◆ SetValue() [11/17]

void CRhRdkVariant::SetValue ( const UUID &  uuid)

Set the value to a UUID.

◆ SetValue() [12/17]

void CRhRdkVariant::SetValue ( const void *  pBuffer,
size_t  size 
)

Set the value to a buffer.

◆ SetValue() [13/17]

void CRhRdkVariant::SetValue ( const wchar_t *  wsz)

◆ SetValue() [14/17]

void CRhRdkVariant::SetValue ( double  v)

◆ SetValue() [15/17]

void CRhRdkVariant::SetValue ( float  v)

◆ SetValue() [16/17]

void CRhRdkVariant::SetValue ( int  v)

◆ SetValue() [17/17]

void CRhRdkVariant::SetValue ( void *  p)

Set the value to a pointer. The variant treats the pointer as an opaque 64-bit value.

◆ SetVaries()

void CRhRdkVariant::SetVaries ( void  )

Set the value to varying. The type is retained. Calling this method on a null variant is not supported.

◆ Type()

VariantType CRhRdkVariant::Type ( void  ) const

◆ Units()

ON::LengthUnitSystem CRhRdkVariant::Units ( void  ) const

Retrieve the units associated with numeric values.

◆ Varies()

bool CRhRdkVariant::Varies ( void  ) const

Check if the value is varying.