HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XUSD_AttributeUtils.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright 2019 Side Effects Software Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef __XUSD_AttributeUtils_h__
20 #define __XUSD_AttributeUtils_h__
21 
22 #include "HUSD_API.h"
23 #include <SYS/SYS_Deprecated.h>
24 #include <SYS/SYS_Types.h>
25 #include <UT/UT_UniquePtr.h>
26 #include <pxr/pxr.h>
28 
29 class VOP_Node;
30 class VOP_TypeInfo;
32 class PRM_Parm;
33 class HUSD_TimeCode;
34 class HUSD_AutoAnyLock;
35 
37 class UsdObject;
38 class UsdAttribute;
39 class UsdRelationship;
40 class UsdTimeCode;
41 class UsdShadeInput;
42 class UsdShadeOutput;
44 
45 /// Returns the SdfValueTypeName string best corresponding to the UT type.
46 template<typename UT_VALUE_TYPE>
47 HUSD_API const char *
49 
50 /// Sets the given @p attribute to the given @p value.
51 template<typename UT_VALUE_TYPE>
52 HUSD_API bool
54  const UT_VALUE_TYPE &value,
55  const UsdTimeCode &timecode,
56  bool clear_existing = true);
57 
58 /// Sets the given @p attribute to the value of a given @p parm.
59 /// @note HUSD_TimeCode allows evaluating a parameter at a given frame
60 /// while authoring an attribute value at the default time code.
61 HUSD_API bool
63  const PRM_Parm &parm,
64  const HUSD_TimeCode &timecode);
65 
66 /// The lock_to_release is freed before calling setValue on the parm. This
67 /// may be necessary because PRM_Parm::setValue evaluates the PRM_Parm first.
68 /// This may execute expression functions which involve cooking the LOP
69 /// Network in a way this might invalidate the lock. So in this function we
70 /// will free the lock object before calling setValue.
71 HUSD_API bool
73  const UsdAttribute &attribute,
74  const UsdTimeCode &timecode,
75  bool save_for_undo = false,
76  UT_UniquePtr<HUSD_AutoAnyLock> *lock_to_release = nullptr);
77 
78 /// The lock_to_release is freed before calling setValue on the parm. This
79 /// may be necessary because PRM_Parm::setValue evaluates the PRM_Parm first.
80 /// This may execute expression functions which involve cooking the LOP
81 /// Network in a way this might invalidate the lock. So in this function we
82 /// will free the lock object before calling setValue.
83 HUSD_API bool
85  const SdfPathVector &rel_targets,
86  bool save_for_undo = false,
87  UT_UniquePtr<HUSD_AutoAnyLock> *lock_to_release = nullptr);
88 
89 /// Sets the parameter to specify the given source for a connection.
90 HUSD_API bool
92  const UsdShadeConnectionSourceInfo &src_info,
93  bool save_for_undo = false,
94  UT_UniquePtr<HUSD_AutoAnyLock> *lock_to_release = nullptr);
95 
96 /// Gets the @p value of the given @p attribute at specified @p timecode.
97 template<typename UT_VALUE_TYPE>
98 HUSD_API bool
99 HUSDgetAttribute(const UsdAttribute &attribute, UT_VALUE_TYPE &value,
100  const UsdTimeCode &timecode);
101 
102 /// Obtains the source the given destination attribute is connected to.
103 HUSD_API bool
105  UsdShadeConnectionSourceInfo &src_info_value );
106 HUSD_API bool
107 HUSDgetFirstConnectedSrc( const UsdShadeInput &shade_input,
108  UsdShadeConnectionSourceInfo &src_info_value );
109 HUSD_API bool
110 HUSDgetFirstConnectedSrc( const UsdShadeOutput &shade_output,
111  UsdShadeConnectionSourceInfo &src_info_value );
112 
113 
114 template<typename UT_VALUE_TYPE>
115 HUSD_API bool
117  UT_VALUE_TYPE &value);
118 
119 /// Gets obj's metadata given its name (eg, "active" or "customData:foo:bar").
120 template<typename UT_VALUE_TYPE>
121 HUSD_API bool
122 HUSDsetMetadata(const UsdObject &object, const TfToken &name,
123  const UT_VALUE_TYPE &value);
124 
125 /// Gets obj's metadata given its name (eg, "active" or "customData:foo:bar").
126 template<typename UT_VALUE_TYPE>
127 HUSD_API bool
128 HUSDgetMetadata(const UsdObject &object, const TfToken &name,
129  UT_VALUE_TYPE &value);
130 
131 HUSD_API bool
132 HUSDclearMetadata(const UsdObject &object, const TfToken &name);
133 
134 /// Metadata utilities
135 HUSD_API bool HUSDhasMetadata(const UsdObject &object, const TfToken &name);
136 HUSD_API bool HUSDisArrayMetadata(const UsdObject &object, const TfToken &name);
138  const TfToken &name);
139 
140 /// Fetch custom data.
141 template<typename UT_VALUE_TYPE>
142 HUSD_API bool HUSDgetCustomData(const UsdObject &object, const TfToken &name,
143  UT_VALUE_TYPE &value);
144 
145 /// Fetch asset info.
146 template<typename UT_VALUE_TYPE>
147 HUSD_API bool HUSDgetAssetInfo(const UsdObject &object, const TfToken &name,
148  UT_VALUE_TYPE &value);
149 
150 /// Conversion function between VtValue and UT_* value objects.
151 template<typename UT_VALUE_TYPE>
152 HUSD_API bool
153 HUSDgetValue( const VtValue &vt_value, UT_VALUE_TYPE &ut_value );
154 
155 /// Conversion function between from UT_* value objects and a VtValue with
156 /// a matching GfValue inside.
157 template<typename UT_VALUE_TYPE>
159 HUSDgetVtValue( const UT_VALUE_TYPE &ut_value );
160 
161 
162 /// Returns the best suited Usd attribute type given the Houdini parameter.
164  const PI_EditScriptedParm &parm );
165 
166 /// Returns the value of the best suited Usd type given the Houdini parameter.
168 HUSDgetShaderParmValue( const PRM_Parm &parm, const HUSD_TimeCode &timecode);
171 
172 /// Returns the type of a shader input attribute given the VOP node input.
174  const PRM_Parm &parm );
176  const VOP_Node &vop, int input_idx,
177  const PRM_Parm *parm_hint = nullptr );
179  const VOP_Node &vop, int output_idx,
180  const PRM_Parm *parm_hint = nullptr );
182 
183 
185 
186 #endif
HUSD_API bool HUSDsetRelationshipNodeParm(PRM_Parm &parm, const SdfPathVector &rel_targets, bool save_for_undo=false, UT_UniquePtr< HUSD_AutoAnyLock > *lock_to_release=nullptr)
HUSD_API bool HUSDgetValue(const VtValue &vt_value, UT_VALUE_TYPE &ut_value)
Conversion function between VtValue and UT_* value objects.
GLsizei const GLfloat * value
Definition: glcorearb.h:824
int64 exint
Definition: SYS_Types.h:125
#define HUSD_API
Definition: HUSD_API.h:31
HUSD_API bool HUSDgetAssetInfo(const UsdObject &object, const TfToken &name, UT_VALUE_TYPE &value)
Fetch asset info.
HUSD_API bool HUSDsetNodeParm(PRM_Parm &parm, const UsdAttribute &attribute, const UsdTimeCode &timecode, bool save_for_undo=false, UT_UniquePtr< HUSD_AutoAnyLock > *lock_to_release=nullptr)
HUSD_API bool HUSDhasMetadata(const UsdObject &object, const TfToken &name)
Metadata utilities.
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
HUSD_API SdfValueTypeName HUSDgetShaderAttribSdfTypeName(const PRM_Parm &parm)
Returns the type of a shader input attribute given the VOP node input.
HUSD_API VtValue HUSDgetShaderParmValue(const PRM_Parm &parm, const HUSD_TimeCode &timecode)
Returns the value of the best suited Usd type given the Houdini parameter.
HUSD_API VOP_TypeInfo HUSDgetVopTypeInfo(SdfValueTypeName sdf_type_name)
Definition: token.h:70
HUSD_API bool HUSDisArrayMetadata(const UsdObject &object, const TfToken &name)
HUSD_API bool HUSDclearMetadata(const UsdObject &object, const TfToken &name)
std::vector< class SdfPath > SdfPathVector
HUSD_API VtValue HUSDgetVtValue(const UT_VALUE_TYPE &ut_value)
GLuint const GLchar * name
Definition: glcorearb.h:786
HUSD_API exint HUSDgetMetadataLength(const UsdObject &object, const TfToken &name)
HUSD_API bool HUSDsetConnectionNodeParm(PRM_Parm &parm, const UsdShadeConnectionSourceInfo &src_info, bool save_for_undo=false, UT_UniquePtr< HUSD_AutoAnyLock > *lock_to_release=nullptr)
Sets the parameter to specify the given source for a connection.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HUSD_API VtValue HUSDgetShaderParmDefaultValue(const PRM_Parm &parm)
HUSD_API bool HUSDgetAttribute(const UsdAttribute &attribute, UT_VALUE_TYPE &value, const UsdTimeCode &timecode)
Gets the value of the given attribute at specified timecode.
HUSD_API bool HUSDsetMetadata(const UsdObject &object, const TfToken &name, const UT_VALUE_TYPE &value)
Gets obj's metadata given its name (eg, "active" or "customData:foo:bar").
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HUSD_API SdfValueTypeName HUSDgetShaderInputSdfTypeName(const VOP_Node &vop, int input_idx, const PRM_Parm *parm_hint=nullptr)
HUSD_API SdfValueTypeName HUSDgetAttribSdfTypeName(const PI_EditScriptedParm &parm)
Returns the best suited Usd attribute type given the Houdini parameter.
OIIO_API bool attribute(string_view name, TypeDesc type, const void *val)
HUSD_API bool HUSDgetCustomData(const UsdObject &object, const TfToken &name, UT_VALUE_TYPE &value)
Fetch custom data.
HUSD_API bool HUSDgetFirstConnectedSrc(const UsdAttribute &attribute, UsdShadeConnectionSourceInfo &src_info_value)
Obtains the source the given destination attribute is connected to.
HUSD_API bool HUSDgetMetadata(const UsdObject &object, const TfToken &name, UT_VALUE_TYPE &value)
Gets obj's metadata given its name (eg, "active" or "customData:foo:bar").
HUSD_API const char * HUSDgetSdfTypeName()
Returns the SdfValueTypeName string best corresponding to the UT type.
Definition: value.h:146
HUSD_API bool HUSDsetAttribute(const UsdAttribute &attribute, const UT_VALUE_TYPE &value, const UsdTimeCode &timecode, bool clear_existing=true)
Sets the given attribute to the given value.
HUSD_API bool HUSDgetAttributeSpecDefault(const SdfAttributeSpec &spec, UT_VALUE_TYPE &value)
HUSD_API SdfValueTypeName HUSDgetShaderOutputSdfTypeName(const VOP_Node &vop, int output_idx, const PRM_Parm *parm_hint=nullptr)