Loading...
Searching...
No Matches
attributeSpec.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_USD_SDF_ATTRIBUTE_SPEC_H
8#define PXR_USD_SDF_ATTRIBUTE_SPEC_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/sdf/api.h"
14#include "pxr/usd/sdf/declareSpec.h"
15#include "pxr/usd/sdf/path.h"
17#include "pxr/usd/sdf/types.h"
18#include "pxr/base/tf/enum.h"
19
20PXR_NAMESPACE_OPEN_SCOPE
21
22class TsSpline;
23
42{
43 SDF_DECLARE_SPEC(SdfAttributeSpec, SdfPropertySpec);
44
45public:
46 typedef SdfAttributeSpec This;
47 typedef SdfPropertySpec Parent;
48
52
57 SDF_API
58 static SdfAttributeSpecHandle
59 New(const SdfPrimSpecHandle& owner,
60 const std::string& name, const SdfValueTypeName& typeName,
61 SdfVariability variability = SdfVariabilityVarying,
62 bool custom = false);
63
65
68
73 SDF_API
75
77 SDF_API
78 bool HasConnectionPaths() const;
79
81 SDF_API
83
87
93 SDF_API
94 VtTokenArray GetAllowedTokens() const;
95
97 SDF_API
98 void SetAllowedTokens(const VtTokenArray& allowedTokens);
99
101 SDF_API
102 bool HasAllowedTokens() const;
103
105 SDF_API
107
109 SDF_API
111
115 SDF_API
116 void SetLimits(const VtDictionary& limits);
117
119 SDF_API
120 bool HasLimits() const;
121
123 SDF_API
125
127 SDF_API
129
131 SDF_API
132 void SetDisplayUnit(const TfEnum& displayUnit);
133
135 SDF_API
136 bool HasDisplayUnit() const;
137
139 SDF_API
141
145 SDF_API
147
150 SDF_API
151 void SetColorSpace(const TfToken &colorSpace);
152
154 SDF_API
155 bool HasColorSpace() const;
156
158 SDF_API
160
173 SDF_API
174 int64_t GetArraySizeConstraint() const;
175
179 SDF_API
180 void SetArraySizeConstraint(int64_t constraint);
181
184 SDF_API
186
188 SDF_API
190
194
198 SDF_API
200
202
206 SDF_API
207 bool HasSpline() const;
208
211 SDF_API
213
215 SDF_API
216 void SetSpline(const TsSpline& value);
217
219 SDF_API
221
223
227 SDF_API
228 SdfTimeSampleMap GetTimeSampleMap() const;
229
230 SDF_API
231 std::set<double> ListTimeSamples() const;
232
233 SDF_API
234 size_t GetNumTimeSamples() const;
235
236 SDF_API
237 bool GetBracketingTimeSamples(double time, double* tLower,
238 double* tUpper) const;
239
240 SDF_API
241 bool QueryTimeSample(double time, VtValue *value=NULL) const;
242 SDF_API
243 bool QueryTimeSample(double time, SdfAbstractDataValue *value) const;
244
245 template <class T>
246 bool QueryTimeSample(double time, T* data) const
247 {
248 if (!data) {
249 return QueryTimeSample(time);
250 }
251
252 SdfAbstractDataTypedValue<T> outValue(data);
253 const bool hasValue = QueryTimeSample(
254 time, static_cast<SdfAbstractDataValue *>(&outValue));
255
256 if (std::is_same<T, SdfValueBlock>::value) {
257 return hasValue && outValue.isValueBlock;
258 }
259
260 return hasValue && (!outValue.isValueBlock);
261 }
262
263 SDF_API
264 void SetTimeSample(double time, const VtValue & value);
265 SDF_API
266 void SetTimeSample(double time, const SdfAbstractDataConstValue& value);
267
268 template <class T>
269 void SetTimeSample(double time, const T& value)
270 {
271 const SdfAbstractDataConstTypedValue<T> inValue(&value);
272 const SdfAbstractDataConstValue& untypedInValue = inValue;
273 return SetTimeSample(time, untypedInValue);
274 }
275
276 SDF_API
277 void EraseTimeSample(double time);
278
280};
281
293SDF_API
294SdfAttributeSpecHandle
296 const SdfLayerHandle &layer,
297 const SdfPath &attrPath,
298 const SdfValueTypeName &typeName,
299 SdfVariability variability = SdfVariabilityVarying,
300 bool isCustom = false);
301
315SDF_API
316bool
318 const SdfLayerHandle &layer,
319 const SdfPath &attrPath,
320 const SdfValueTypeName &typeName,
321 SdfVariability variability = SdfVariabilityVarying,
322 bool isCustom = false);
323
324PXR_NAMESPACE_CLOSE_SCOPE
325
326#endif // PXR_USD_SDF_ATTRIBUTE_SPEC_H
SDF_API SdfAttributeSpecHandle SdfCreatePrimAttributeInLayer(const SdfLayerHandle &layer, const SdfPath &attrPath, const SdfValueTypeName &typeName, SdfVariability variability=SdfVariabilityVarying, bool isCustom=false)
Convenience function to create an attributeSpec on a primSpec at the given path, and any necessary pa...
SDF_API bool SdfJustCreatePrimAttributeInLayer(const SdfLayerHandle &layer, const SdfPath &attrPath, const SdfValueTypeName &typeName, SdfVariability variability=SdfVariabilityVarying, bool isCustom=false)
Convenience function to create an attributeSpec on a primSpec at the given path, and any necessary pa...
The fully-typed container for a field value in an SdfAbstractData.
A type-erased container for a const field value in an SdfAbstractData.
The fully-typed container for a field value in an SdfAbstractData.
A type-erased container for a field value in an SdfAbstractData.
A subclass of SdfPropertySpec that holds typed data.
SDF_API void SetAllowedTokens(const VtTokenArray &allowedTokens)
Sets the allowed tokens metadata for this attribute.
SDF_API bool HasDisplayUnit() const
Returns true if a display unit is set for this attribute.
SDF_API void SetDisplayUnit(const TfEnum &displayUnit)
Sets the display unit of the attribute.
SDF_API bool HasArraySizeConstraint() const
Returns true if this attribute has an array size constraint value authored.
SDF_API void ClearLimits()
Clears the limits metadata for this attribute.
SDF_API void ClearConnectionPaths()
Clears the connection paths for this attribute.
SDF_API void SetColorSpace(const TfToken &colorSpace)
Sets the color space in which a color or texture valued attribute is authored.
SDF_API TfToken GetRoleName() const
Returns the roleName for this attribute's typeName.
SDF_API void SetSpline(const TsSpline &value)
Set the provided value as the spline for this attribute spec.
SDF_API TfToken GetColorSpace() const
Returns the color space in which a color or texture valued attribute is authored.
SDF_API void ClearDisplayUnit()
Clears the display unit of the attribute.
SDF_API bool HasConnectionPaths() const
Returns true if any connection paths are set on this attribute.
SDF_API VtTokenArray GetAllowedTokens() const
Returns the allowed tokens metadata for this attribute.
static SDF_API SdfAttributeSpecHandle New(const SdfPrimSpecHandle &owner, const std::string &name, const SdfValueTypeName &typeName, SdfVariability variability=SdfVariabilityVarying, bool custom=false)
Constructs a new prim attribute instance.
SDF_API void SetArraySizeConstraint(int64_t constraint)
Sets the array size constraint value for this attribute.
SDF_API bool HasAllowedTokens() const
Returns true if allowed tokens metadata is set for this attribute.
SDF_API TsSpline GetSpline() const
Returns the TsSpline at this attribute spec if a spec exists, otherwise an empty spline is returned.
SDF_API SdfConnectionsProxy GetConnectionPathList() const
Returns a proxy for editing the attribute's connection paths.
SDF_API int64_t GetArraySizeConstraint() const
Returns the array size constraint value for this attribute.
SDF_API void ClearSpline()
Clear the spline from this attribute spec.
SDF_API void ClearAllowedTokens()
Clears the allowed tokens metadata for this attribute.
SDF_API void ClearArraySizeConstraint()
Clears the array size constraint value for this attribute.
SDF_API VtDictionary GetLimits() const
Returns the limits dictionary for this attribute.
SDF_API bool HasLimits() const
Returns true if limits metadata is set for this attribute.
SDF_API void SetLimits(const VtDictionary &limits)
Sets the limits dictionary for this attribute.
SDF_API TfEnum GetDisplayUnit() const
Returns the display unit of the attribute.
SDF_API void ClearColorSpace()
Clears the colorSpace metadata value set on this attribute.
SDF_API bool HasColorSpace() const
Returns true if this attribute has a colorSpace value authored.
Represents a set of list editing operations.
A path value used to locate objects in layers or scenegraphs.
Definition path.h:281
Base class for SdfAttributeSpec and SdfRelationshipSpec.
Represents a value type name, i.e.
An enum class that records both enum type and enum value.
Definition enum.h:120
Token for efficient comparison, assignment, and hashing of known strings.
Definition token.h:81
A mathematical description of a curved function from time to value.
Definition spline.h:60
A map with string keys and VtValue values.
Definition dictionary.h:52
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition value.h:90
Basic Sdf data types.
SdfVariability
An enum that identifies variability types for attributes.
Definition types.h:161
std::map< double, VtValue > SdfTimeSampleMap
A map from sample times to sample values.
Definition types.h:282