HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UsdAttributeLimits Class Reference

#include <attributeLimits.h>

Classes

class  ValidationResult
 

Public Member Functions

 UsdAttributeLimits ()=default
 
USD_API UsdAttributeLimits (const UsdAttribute &attr, const TfToken &subDictKey)
 
 operator bool () const
 
bool operator== (const UsdAttributeLimits &rhs) const
 Equality operator. More...
 
bool operator!= (const UsdAttributeLimits &rhs) const
 Inequality operator. More...
 
Object Information

Information about the limits object itself.

USD_API bool IsValid () const
 
USD_API UsdAttribute GetAttribute () const
 Return the limits object's attribute. More...
 
USD_API TfToken GetSubDictKey () const
 Return the sub-dictionary key the limits object is using. More...
 
Opinions API

API for determining whether authored opinions exist, and clearing them.

USD_API bool HasAuthored () const
 
USD_API bool Clear ()
 
USD_API bool HasAuthored (const TfToken &key) const
 
USD_API bool Clear (const TfToken &key)
 
USD_API bool HasAuthoredMinimum () const
 
USD_API bool ClearMinimum ()
 
USD_API bool HasAuthoredMaximum () const
 
USD_API bool ClearMaximum ()
 
Sub-dictionary Operations

Operations related to the entire limits sub-dictionary.

USD_API bool Validate (const VtDictionary &subDict, ValidationResult *result=nullptr) const
 
USD_API bool Set (const VtDictionary &subDict)
 
Typed Value API

Templated API for retrieving and authoring individual limits values.

template<typename T >
std::optional< TGet (const TfToken &key) const
 
template<typename T >
T GetOr (const TfToken &key, const T &defaultValue) const
 
template<typename T >
bool Set (const TfToken &key, const T &value)
 
template<typename T >
std::optional< TGetMinimum () const
 
template<typename T >
T GetMinimumOr (const T &defaultValue) const
 
template<typename T >
bool SetMinimum (const T &value)
 
template<typename T >
std::optional< TGetMaximum () const
 
template<typename T >
T GetMaximumOr (const T &defaultValue) const
 
template<typename T >
bool SetMaximum (const T &value)
 
Type-erased Value API

VtValue-based overloads, mainly for use by the Python wrapping.

USD_API VtValue Get (const TfToken &key) const
 
USD_API bool Set (const TfToken &key, const VtValue &value)
 
USD_API VtValue GetMinimum () const
 
USD_API bool SetMinimum (const VtValue &value)
 
USD_API VtValue GetMaximum () const
 
USD_API bool SetMaximum (const VtValue &value)
 

Detailed Description

Provides API for retrieving and authoring values within a particular sub-dictionary of the limits dictionary metadata field on a UsdAttribute instance. Within a given sub-dictionary, minimum and maximum values are encoded under the UsdLimitsKeys->Minimum and UsdLimitsKeys->Maximum keys, respectively.

For example, to express that an attribute's typical useful value range is between 5 and 10 (the "soft limits"), but that it must be between 0 and 15 (the "hard limits"), a typical limits dictionary might look like the following:

def "MyPrim"
{
int attr = 7 (
limits = {
dictionary soft = {
int minimum = 5
int maximum = 10
}
dictionary hard = {
int minimum = 0
int maximum = 15
}
}
)
}

To work with these values, use the UsdAttributeLimits objects returned by UsdAttribute::GetSoftLimits() and UsdAttribute::GetHardLimits(), which edit and interpret the "soft" and "hard" sub-dictionaries, respectively.

UsdAttributeLimits softLimits = attr.GetSoftLimits();
if (x >= softLimits.GetMinimumOr(0) && x <= softLimits.GetMaximumOr(100)) {
// x is within the soft limits, 5 and 10. The passed-in defaults
// (0 and 100) are ignored since both min and max values are authored
}

You can also create custom sub-dictionaries:

UsdAttributeLimits customLimits = attr.GetLimits(TfToken("myCustomSubDict"));
customLimits.SetMinimum(50);
customLimits.SetMaximum(100);
customLimits.Set(TfToken("customKey"), 42.5));

Combined with the starting limits dictionary above, this would produce:

def "MyPrim"
{
int attr = 7 (
limits = {
dictionary soft = {
int minimum = 5
int maximum = 10
}
dictionary hard = {
int minimum = 0
int maximum = 15
}
dictionary myCustomSubDict = {
int minimum = 50,
int maximum = 100,
double customKey = 42.5
}
}
)
}

Definition at line 107 of file attributeLimits.h.

Constructor & Destructor Documentation

UsdAttributeLimits::UsdAttributeLimits ( )
default

Construct an invalid limits object.

Calling "set" operations on an invalid limits object will post errors. "Get" operations will return empty.

USD_API UsdAttributeLimits::UsdAttributeLimits ( const UsdAttribute attr,
const TfToken subDictKey 
)

Construct a limits object for the sub-dictionary given by subDictKey in attr's limits dictionary.

Member Function Documentation

USD_API bool UsdAttributeLimits::Clear ( )

Clear all authored opinions for the limits sub-dictionary at the current edit target. Return true if successful.

USD_API bool UsdAttributeLimits::Clear ( const TfToken key)

Clear the authored opinion for key in the limits sub-dictionary. Return true if successful.

USD_API bool UsdAttributeLimits::ClearMaximum ( )

Clear the authored maximum value opinion in the limits sub-dictionary. Return true if successful.

USD_API bool UsdAttributeLimits::ClearMinimum ( )

Clear the authored minimum value opinion in the limits sub-dictionary. Return true if successful.

template<typename T >
std::optional< T > UsdAttributeLimits::Get ( const TfToken key) const
inline

Return the value encoded under key in the limits sub-dictionary. Return an empty std::optional if no authored or fallback value is present, or if the template type T does not match the type of the stored value.

Definition at line 430 of file attributeLimits.h.

USD_API VtValue UsdAttributeLimits::Get ( const TfToken key) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

USD_API UsdAttribute UsdAttributeLimits::GetAttribute ( ) const

Return the limits object's attribute.

template<typename T >
std::optional< T > UsdAttributeLimits::GetMaximum ( ) const
inline

Return the maximum value from the limits sub-dictionary. Return an empty std::optional if no authored or fallback value is present, or if the template type T does not match the type of the stored value.

Definition at line 498 of file attributeLimits.h.

USD_API VtValue UsdAttributeLimits::GetMaximum ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T >
T UsdAttributeLimits::GetMaximumOr ( const T defaultValue) const
inline

Return the maximum value from the limits sub-dictionary. Return defaultValue if no authored or fallback value is present, or if the template type T does not match the type of the stored value.

Definition at line 505 of file attributeLimits.h.

template<typename T >
std::optional< T > UsdAttributeLimits::GetMinimum ( ) const
inline

Return the minimum value from the limits sub-dictionary. Return an empty std::optional if no authored or fallback value is present, or if the template type T does not match the type of the stored value.

Definition at line 477 of file attributeLimits.h.

USD_API VtValue UsdAttributeLimits::GetMinimum ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T >
T UsdAttributeLimits::GetMinimumOr ( const T defaultValue) const
inline

Return the minimum value from the limits sub-dictionary. Return defaultValue if no authored or fallback value is present, or if the template type T does not match the type of the stored value.

Definition at line 484 of file attributeLimits.h.

template<typename T >
T UsdAttributeLimits::GetOr ( const TfToken key,
const T defaultValue 
) const
inline

Return the value encoded under key in the limits sub-dictionary. Return defaultValue if no authored or fallback value is present, or if the template type T does not match the type of the stored value.

Definition at line 448 of file attributeLimits.h.

USD_API TfToken UsdAttributeLimits::GetSubDictKey ( ) const

Return the sub-dictionary key the limits object is using.

USD_API bool UsdAttributeLimits::HasAuthored ( ) const

Return whether any authored opinions exist for the limits sub-dictionary.

USD_API bool UsdAttributeLimits::HasAuthored ( const TfToken key) const

Return whether an authored opinion for key exists in the limits sub-dictionary.

USD_API bool UsdAttributeLimits::HasAuthoredMaximum ( ) const

Return whether an authored maximum value opinion exists in the limits sub-dictionary.

USD_API bool UsdAttributeLimits::HasAuthoredMinimum ( ) const

Return whether an authored minimum value opinion exists in the limits sub-dictionary.

USD_API bool UsdAttributeLimits::IsValid ( ) const

Return whether the limits object is valid.

Calling "set" operations on an invalid limits object will post errors. "Get" operations will return empty.

UsdAttributeLimits::operator bool ( ) const
inlineexplicit

Return true if this limits object is valid.

See Also
IsValid()

Definition at line 405 of file attributeLimits.h.

bool UsdAttributeLimits::operator!= ( const UsdAttributeLimits rhs) const
inline

Inequality operator.

Definition at line 415 of file attributeLimits.h.

bool UsdAttributeLimits::operator== ( const UsdAttributeLimits rhs) const
inline

Equality operator.

Definition at line 410 of file attributeLimits.h.

USD_API bool UsdAttributeLimits::Set ( const VtDictionary subDict)

Set the entire limits sub-dictionary to subDict. Return true if successful.

The types of encoded minimum and maximum values must match the value type of the attribute.

template<typename T >
bool UsdAttributeLimits::Set ( const TfToken key,
const T value 
)
inline

Set the value encoded under key in the limits sub-dictionary to value. Return true if successful.

Definition at line 468 of file attributeLimits.h.

USD_API bool UsdAttributeLimits::Set ( const TfToken key,
const VtValue value 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T >
bool UsdAttributeLimits::SetMaximum ( const T value)
inline

Set the maximum value in the limits sub-dictionary. Return true if successful.

The type of value must match the attribute's value type.

Definition at line 512 of file attributeLimits.h.

USD_API bool UsdAttributeLimits::SetMaximum ( const VtValue value)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T >
bool UsdAttributeLimits::SetMinimum ( const T value)
inline

Set the minimum value in the limits sub-dictionary. Return true if successful.

The type of value must match the attribute's value type.

Definition at line 491 of file attributeLimits.h.

USD_API bool UsdAttributeLimits::SetMinimum ( const VtValue value)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

USD_API bool UsdAttributeLimits::Validate ( const VtDictionary subDict,
ValidationResult result = nullptr 
) const

Return whether subDict is a valid limits sub-dictionary. If result is provided, fill it in. To be valid, the types of encoded minimum and maximum values must match the value type of the attribute.

See Also
ValidationResult

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