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
113 SDF_API
114 void SetLimits(const VtDictionary& limits);
115
117 SDF_API
118 bool HasLimits() const;
119
121 SDF_API
123
125 SDF_API
127
129 SDF_API
130 void SetDisplayUnit(const TfEnum& displayUnit);
131
133 SDF_API
134 bool HasDisplayUnit() const;
135
137 SDF_API
139
143 SDF_API
145
148 SDF_API
149 void SetColorSpace(const TfToken &colorSpace);
150
152 SDF_API
153 bool HasColorSpace() const;
154
156 SDF_API
158
171 SDF_API
172 int64_t GetArraySizeConstraint() const;
173
177 SDF_API
178 void SetArraySizeConstraint(int64_t constraint);
179
182 SDF_API
184
186 SDF_API
188
192
196 SDF_API
198
200
204 SDF_API
205 bool HasSpline() const;
206
209 SDF_API
211
213 SDF_API
214 void SetSpline(const TsSpline& value);
215
217 SDF_API
219
221
225 SDF_API
226 SdfTimeSampleMap GetTimeSampleMap() const;
227
228 SDF_API
229 std::set<double> ListTimeSamples() const;
230
231 SDF_API
232 size_t GetNumTimeSamples() const;
233
234 SDF_API
235 bool GetBracketingTimeSamples(double time, double* tLower,
236 double* tUpper) const;
237
238 SDF_API
239 bool QueryTimeSample(double time, VtValue *value=NULL) const;
240 SDF_API
241 bool QueryTimeSample(double time, SdfAbstractDataValue *value) const;
242
243 template <class T>
244 bool QueryTimeSample(double time, T* data) const
245 {
246 if (!data) {
247 return QueryTimeSample(time);
248 }
249
250 SdfAbstractDataTypedValue<T> outValue(data);
251 const bool hasValue = QueryTimeSample(
252 time, static_cast<SdfAbstractDataValue *>(&outValue));
253
254 if (std::is_same<T, SdfValueBlock>::value) {
255 return hasValue && outValue.isValueBlock;
256 }
257
258 return hasValue && (!outValue.isValueBlock);
259 }
260
261 SDF_API
262 void SetTimeSample(double time, const VtValue & value);
263 SDF_API
264 void SetTimeSample(double time, const SdfAbstractDataConstValue& value);
265
266 template <class T>
267 void SetTimeSample(double time, const T& value)
268 {
269 const SdfAbstractDataConstTypedValue<T> inValue(&value);
270 const SdfAbstractDataConstValue& untypedInValue = inValue;
271 return SetTimeSample(time, untypedInValue);
272 }
273
274 SDF_API
275 void EraseTimeSample(double time);
276
278};
279
291SDF_API
292SdfAttributeSpecHandle
294 const SdfLayerHandle &layer,
295 const SdfPath &attrPath,
296 const SdfValueTypeName &typeName,
297 SdfVariability variability = SdfVariabilityVarying,
298 bool isCustom = false);
299
313SDF_API
314bool
316 const SdfLayerHandle &layer,
317 const SdfPath &attrPath,
318 const SdfValueTypeName &typeName,
319 SdfVariability variability = SdfVariabilityVarying,
320 bool isCustom = false);
321
322PXR_NAMESPACE_CLOSE_SCOPE
323
324#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.
Definition: abstractData.h:592
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:544
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:482
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:417
A subclass of SdfPropertySpec that holds typed data.
Definition: attributeSpec.h:42
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:274
Base class for SdfAttributeSpec and SdfRelationshipSpec.
Definition: propertySpec.h:47
Represents a value type name, i.e.
Definition: valueTypeName.h:72
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:71
A mathematical description of a curved function from time to value.
Definition: spline.h:59
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:156
std::map< double, VtValue > SdfTimeSampleMap
A map from sample times to sample values.
Definition: types.h:277