HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
accessibilityAPI.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 USDUI_GENERATED_ACCESSIBILITYAPI_H
8 #define USDUI_GENERATED_ACCESSIBILITYAPI_H
9 
10 /// \file usdUI/accessibilityAPI.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdUI/api.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
17 #include "pxr/usd/usdUI/tokens.h"
18 
19 #include "pxr/base/vt/value.h"
20 
21 #include "pxr/base/gf/vec3d.h"
22 #include "pxr/base/gf/vec3f.h"
23 #include "pxr/base/gf/matrix4d.h"
24 
25 #include "pxr/base/tf/token.h"
26 #include "pxr/base/tf/type.h"
27 
29 
30 class SdfAssetPath;
31 
32 // -------------------------------------------------------------------------- //
33 // ACCESSIBILITYAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdUIAccessibilityAPI
37 ///
38 ///
39 /// This API describes \em Accessibility information on a Prim that may be
40 /// surfaced to a given runtime's accessibility frameworks.
41 /// This information may be used by assistive tooling such as voice controls
42 /// or screen readers.
43 /// Accessibility information is provided as a standard triplet of label,
44 /// description and priority.
45 ///
46 /// OpenUSD does not provide a accessibility runtime itself, but endeavours
47 /// to provide the information needed for compatible runtimes to extract and
48 /// present this information.
49 ///
50 /// This is a multiple apply schema, and so may have multiple namespaced
51 /// accessibility triplets, where a instance name may reflect a given purpose
52 /// for that triplet. For example, you may desire to express different
53 /// information for different aspects of the prim, such as size or color.
54 ///
55 /// \note The API will use \em "default" as an instance name if no
56 /// namespace is specified.
57 ///
58 /// There are several best practices for using this schema.:
59 ///
60 /// \li Most accessibility runtimes support a single accessibility description.
61 /// Therefore we recommend placing any critical information in the default
62 /// instance.
63 ///
64 /// \li A default value should be authored if using time sampled accessibility
65 /// information. This helps accessibility runtimes that do not currently
66 /// support time sampled information.
67 ///
68 /// \li Provide accessibility information of your scene on the default prim
69 /// of the layer, and any top level prims. This allows accessibility systems to
70 /// provide concise scene descriptions to a user, but also allows supporting
71 /// accessibility systems that either do not support hierarchy information or
72 /// when a user has turned off that level of granularity. Accessibility
73 /// information may still be provided on other prims in the hierarchy.
74 ///
75 /// \note The use of the default prim and top level prims for scene
76 /// accessibility descriptions is a recommended convention. Outside of that,
77 /// accessibility information is not implicitly inherited through a prim
78 /// hierarchy. The inheritance should be left to the accessibility runtime to
79 /// decide how best to surface information to users.
80 ///
81 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
82 /// that are text/tokens, the actual token is published and defined in \ref UsdUITokens.
83 /// So to set an attribute to the value "rightHanded", use UsdUITokens->rightHanded
84 /// as the value.
85 ///
87 {
88 public:
89  /// Compile time constant representing what kind of schema this class is.
90  ///
91  /// \sa UsdSchemaKind
93 
94  /// Construct a UsdUIAccessibilityAPI on UsdPrim \p prim with
95  /// name \p name . Equivalent to
96  /// UsdUIAccessibilityAPI::Get(
97  /// prim.GetStage(),
98  /// prim.GetPath().AppendProperty(
99  /// "accessibility:name"));
100  ///
101  /// for a \em valid \p prim, but will not immediately throw an error for
102  /// an invalid \p prim
104  const UsdPrim& prim=UsdPrim(), const TfToken &name=TfToken())
105  : UsdAPISchemaBase(prim, /*instanceName*/ name)
106  { }
107 
108  /// Construct a UsdUIAccessibilityAPI on the prim held by \p schemaObj with
109  /// name \p name. Should be preferred over
110  /// UsdUIAccessibilityAPI(schemaObj.GetPrim(), name), as it preserves
111  /// SchemaBase state.
113  const UsdSchemaBase& schemaObj, const TfToken &name)
114  : UsdAPISchemaBase(schemaObj, /*instanceName*/ name)
115  { }
116 
117  /// Destructor.
118  USDUI_API
119  virtual ~UsdUIAccessibilityAPI();
120 
121  /// Return a vector of names of all pre-declared attributes for this schema
122  /// class and all its ancestor classes. Does not include attributes that
123  /// may be authored by custom/extended methods of the schemas involved.
124  USDUI_API
125  static const TfTokenVector &
126  GetSchemaAttributeNames(bool includeInherited=true);
127 
128  /// Return a vector of names of all pre-declared attributes for this schema
129  /// class and all its ancestor classes for a given instance name. Does not
130  /// include attributes that may be authored by custom/extended methods of
131  /// the schemas involved. The names returned will have the proper namespace
132  /// prefix.
133  USDUI_API
134  static TfTokenVector
135  GetSchemaAttributeNames(bool includeInherited, const TfToken &instanceName);
136 
137  /// Returns the name of this multiple-apply schema instance
138  TfToken GetName() const {
139  return _GetInstanceName();
140  }
141 
142  /// Return a UsdUIAccessibilityAPI holding the prim adhering to this
143  /// schema at \p path on \p stage. If no prim exists at \p path on
144  /// \p stage, or if the prim at that path does not adhere to this schema,
145  /// return an invalid schema object. \p path must be of the format
146  /// <path>.accessibility:name .
147  ///
148  /// This is shorthand for the following:
149  ///
150  /// \code
151  /// TfToken name = SdfPath::StripNamespace(path.GetToken());
152  /// UsdUIAccessibilityAPI(
153  /// stage->GetPrimAtPath(path.GetPrimPath()), name);
154  /// \endcode
155  ///
156  USDUI_API
157  static UsdUIAccessibilityAPI
158  Get(const UsdStagePtr &stage, const SdfPath &path);
159 
160  /// Return a UsdUIAccessibilityAPI with name \p name holding the
161  /// prim \p prim. Shorthand for UsdUIAccessibilityAPI(prim, name);
162  USDUI_API
163  static UsdUIAccessibilityAPI
164  Get(const UsdPrim &prim, const TfToken &name);
165 
166  /// Return a vector of all named instances of UsdUIAccessibilityAPI on the
167  /// given \p prim.
168  USDUI_API
169  static std::vector<UsdUIAccessibilityAPI>
170  GetAll(const UsdPrim &prim);
171 
172  /// Checks if the given name \p baseName is the base name of a property
173  /// of AccessibilityAPI.
174  USDUI_API
175  static bool
176  IsSchemaPropertyBaseName(const TfToken &baseName);
177 
178  /// Checks if the given path \p path is of an API schema of type
179  /// AccessibilityAPI. If so, it stores the instance name of
180  /// the schema in \p name and returns true. Otherwise, it returns false.
181  USDUI_API
182  static bool
184 
185  /// Returns true if this <b>multiple-apply</b> API schema can be applied,
186  /// with the given instance name, \p name, to the given \p prim. If this
187  /// schema can not be a applied the prim, this returns false and, if
188  /// provided, populates \p whyNot with the reason it can not be applied.
189  ///
190  /// Note that if CanApply returns false, that does not necessarily imply
191  /// that calling Apply will fail. Callers are expected to call CanApply
192  /// before calling Apply if they want to ensure that it is valid to
193  /// apply a schema.
194  ///
195  /// \sa UsdPrim::GetAppliedSchemas()
196  /// \sa UsdPrim::HasAPI()
197  /// \sa UsdPrim::CanApplyAPI()
198  /// \sa UsdPrim::ApplyAPI()
199  /// \sa UsdPrim::RemoveAPI()
200  ///
201  USDUI_API
202  static bool
203  CanApply(const UsdPrim &prim, const TfToken &name,
204  std::string *whyNot=nullptr);
205 
206  /// Applies this <b>multiple-apply</b> API schema to the given \p prim
207  /// along with the given instance name, \p name.
208  ///
209  /// This information is stored by adding "AccessibilityAPI:<i>name</i>"
210  /// to the token-valued, listOp metadata \em apiSchemas on the prim.
211  /// For example, if \p name is 'instance1', the token
212  /// 'AccessibilityAPI:instance1' is added to 'apiSchemas'.
213  ///
214  /// \return A valid UsdUIAccessibilityAPI object is returned upon success.
215  /// An invalid (or empty) UsdUIAccessibilityAPI object is returned upon
216  /// failure. See \ref UsdPrim::ApplyAPI() for
217  /// conditions resulting in failure.
218  ///
219  /// \sa UsdPrim::GetAppliedSchemas()
220  /// \sa UsdPrim::HasAPI()
221  /// \sa UsdPrim::CanApplyAPI()
222  /// \sa UsdPrim::ApplyAPI()
223  /// \sa UsdPrim::RemoveAPI()
224  ///
225  USDUI_API
226  static UsdUIAccessibilityAPI
227  Apply(const UsdPrim &prim, const TfToken &name);
228 
229 protected:
230  /// Returns the kind of schema this class belongs to.
231  ///
232  /// \sa UsdSchemaKind
233  USDUI_API
234  UsdSchemaKind _GetSchemaKind() const override;
235 
236 private:
237  // needs to invoke _GetStaticTfType.
238  friend class UsdSchemaRegistry;
239  USDUI_API
240  static const TfType &_GetStaticTfType();
241 
242  static bool _IsTypedSchema();
243 
244  // override SchemaBase virtuals.
245  USDUI_API
246  const TfType &_GetTfType() const override;
247 
248 public:
249  // --------------------------------------------------------------------- //
250  // LABEL
251  // --------------------------------------------------------------------- //
252  /// A short label to concisely describe the prim.
253  /// It is not recommended to time vary the label unless the concise
254  /// description changes substantially.
255  ///
256  /// There is no specific suggested length for the label, but it is
257  /// recommended to keep it succinct.
258  ///
259  /// | ||
260  /// | -- | -- |
261  /// | Declaration | `string label` |
262  /// | C++ Type | std::string |
263  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->String |
264  USDUI_API
265  UsdAttribute GetLabelAttr() const;
266 
267  /// See GetLabelAttr(), and also
268  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
269  /// If specified, author \p defaultValue as the attribute's default,
270  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
271  /// the default for \p writeSparsely is \c false.
272  USDUI_API
273  UsdAttribute CreateLabelAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
274 
275 public:
276  // --------------------------------------------------------------------- //
277  // DESCRIPTION
278  // --------------------------------------------------------------------- //
279  /// An extended description of the prim to provide more details.
280  /// If a label attribute is not authored in a given instance name,
281  /// the description attribute should not be used in it its place. A
282  /// description is an optional attribute, and some accessibility systems
283  /// may only use the label.
284  ///
285  /// Descriptions may be time varying for runtimes that support it. For
286  /// example, you may describe what a character is doing at a given time.
287  ///
288  ///
289  /// | ||
290  /// | -- | -- |
291  /// | Declaration | `string description` |
292  /// | C++ Type | std::string |
293  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->String |
294  USDUI_API
296 
297  /// See GetDescriptionAttr(), and also
298  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
299  /// If specified, author \p defaultValue as the attribute's default,
300  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
301  /// the default for \p writeSparsely is \c false.
302  USDUI_API
303  UsdAttribute CreateDescriptionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
304 
305 public:
306  // --------------------------------------------------------------------- //
307  // PRIORITY
308  // --------------------------------------------------------------------- //
309  /// A hint to the accessibility runtime of how to prioritize this
310  /// instance's label and description, relative to others.
311  ///
312  /// This attribute is optional and is considered a hint that runtimes may
313  /// ignore, if they feel there are other necessities that take precedence
314  /// over the prioritization values.
315  ///
316  /// Priority may not be time varying.
317  ///
318  ///
319  /// | ||
320  /// | -- | -- |
321  /// | Declaration | `uniform token priority = "standard"` |
322  /// | C++ Type | TfToken |
323  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
324  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
325  /// | \ref UsdUITokens "Allowed Values" | low, standard, high |
326  USDUI_API
328 
329  /// See GetPriorityAttr(), and also
330  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
331  /// If specified, author \p defaultValue as the attribute's default,
332  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
333  /// the default for \p writeSparsely is \c false.
334  USDUI_API
335  UsdAttribute CreatePriorityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
336 
337 public:
338  // ===================================================================== //
339  // Feel free to add custom code below this line, it will be preserved by
340  // the code generator.
341  //
342  // Just remember to:
343  // - Close the class declaration with };
344  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
345  // - Close the include guard with #endif
346  // ===================================================================== //
347  // --(BEGIN CUSTOM CODE)--
348 
349  /// Creates an instance of the API with the default instance name.
350  /// /sa UsdUIAccessibilityAPI
351  USDUI_API
352  static UsdUIAccessibilityAPI CreateDefaultAPI(const UsdPrim& prim);
353 
354  /// Creates an instance of the API with a schema object using the default instance name.
355  /// /sa UsdUIAccessibilityAPI
356  USDUI_API
357  static UsdUIAccessibilityAPI CreateDefaultAPI(const UsdSchemaBase& schemaObj);
358 
359  /// Applies an instance of the API with the default instance name.
360  /// /sa Apply
361  USDUI_API
362  static UsdUIAccessibilityAPI ApplyDefaultAPI(const UsdPrim& prim);
363 };
364 
366 
367 #endif
USDUI_API UsdAttribute GetLabelAttr() const
UsdUIAccessibilityAPI(const UsdPrim &prim=UsdPrim(), const TfToken &name=TfToken())
static const UsdSchemaKind schemaKind
USDUI_API UsdAttribute GetDescriptionAttr() const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
static USDUI_API UsdUIAccessibilityAPI Get(const UsdStagePtr &stage, const SdfPath &path)
USDUI_API UsdAttribute CreatePriorityAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDUI_API UsdAttribute GetPriorityAttr() const
const TfToken & _GetInstanceName() const
Definition: token.h:70
USDUI_API UsdAttribute CreateLabelAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: prim.h:116
virtual USDUI_API ~UsdUIAccessibilityAPI()
Destructor.
static USDUI_API UsdUIAccessibilityAPI ApplyDefaultAPI(const UsdPrim &prim)
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
TfToken GetName() const
Returns the name of this multiple-apply schema instance.
UsdUIAccessibilityAPI(const UsdSchemaBase &schemaObj, const TfToken &name)
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:273
static USDUI_API bool IsAccessibilityAPIPath(const SdfPath &path, TfToken *name)
static USDUI_API UsdUIAccessibilityAPI Apply(const UsdPrim &prim, const TfToken &name)
UsdSchemaKind
Definition: common.h:112
#define USDUI_API
Definition: api.h:23
USDUI_API UsdAttribute CreateDescriptionAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDUI_API UsdUIAccessibilityAPI CreateDefaultAPI(const UsdPrim &prim)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
static USDUI_API bool CanApply(const UsdPrim &prim, const TfToken &name, std::string *whyNot=nullptr)
Definition: type.h:47
static USDUI_API std::vector< UsdUIAccessibilityAPI > GetAll(const UsdPrim &prim)
static USDUI_API bool IsSchemaPropertyBaseName(const TfToken &baseName)
Definition: value.h:146
Multiple Apply API Schema.
USDUI_API UsdSchemaKind _GetSchemaKind() const override
static USDUI_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)