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