HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sceneGraphPrimAPI.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_SCENEGRAPHPRIMAPI_H
8 #define USDUI_GENERATED_SCENEGRAPHPRIMAPI_H
9 
10 /// \file usdUI/sceneGraphPrimAPI.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 // SCENEGRAPHPRIMAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdUISceneGraphPrimAPI
37 ///
38 ///
39 /// Utility schema for display properties of a prim
40 ///
41 ///
42 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
43 /// that are text/tokens, the actual token is published and defined in \ref UsdUITokens.
44 /// So to set an attribute to the value "rightHanded", use UsdUITokens->rightHanded
45 /// as the value.
46 ///
48 {
49 public:
50  /// Compile time constant representing what kind of schema this class is.
51  ///
52  /// \sa UsdSchemaKind
54 
55  /// Construct a UsdUISceneGraphPrimAPI on UsdPrim \p prim .
56  /// Equivalent to UsdUISceneGraphPrimAPI::Get(prim.GetStage(), prim.GetPath())
57  /// for a \em valid \p prim, but will not immediately throw an error for
58  /// an invalid \p prim
59  explicit UsdUISceneGraphPrimAPI(const UsdPrim& prim=UsdPrim())
60  : UsdAPISchemaBase(prim)
61  {
62  }
63 
64  /// Construct a UsdUISceneGraphPrimAPI on the prim held by \p schemaObj .
65  /// Should be preferred over UsdUISceneGraphPrimAPI(schemaObj.GetPrim()),
66  /// as it preserves SchemaBase state.
67  explicit UsdUISceneGraphPrimAPI(const UsdSchemaBase& schemaObj)
68  : UsdAPISchemaBase(schemaObj)
69  {
70  }
71 
72  /// Destructor.
73  USDUI_API
74  virtual ~UsdUISceneGraphPrimAPI();
75 
76  /// Return a vector of names of all pre-declared attributes for this schema
77  /// class and all its ancestor classes. Does not include attributes that
78  /// may be authored by custom/extended methods of the schemas involved.
79  USDUI_API
80  static const TfTokenVector &
81  GetSchemaAttributeNames(bool includeInherited=true);
82 
83  /// Return a UsdUISceneGraphPrimAPI holding the prim adhering to this
84  /// schema at \p path on \p stage. If no prim exists at \p path on
85  /// \p stage, or if the prim at that path does not adhere to this schema,
86  /// return an invalid schema object. This is shorthand for the following:
87  ///
88  /// \code
89  /// UsdUISceneGraphPrimAPI(stage->GetPrimAtPath(path));
90  /// \endcode
91  ///
92  USDUI_API
94  Get(const UsdStagePtr &stage, const SdfPath &path);
95 
96 
97  /// Returns true if this <b>single-apply</b> API schema can be applied to
98  /// the given \p prim. If this schema can not be a applied to the prim,
99  /// this returns false and, if provided, populates \p whyNot with the
100  /// reason it can not be applied.
101  ///
102  /// Note that if CanApply returns false, that does not necessarily imply
103  /// that calling Apply will fail. Callers are expected to call CanApply
104  /// before calling Apply if they want to ensure that it is valid to
105  /// apply a schema.
106  ///
107  /// \sa UsdPrim::GetAppliedSchemas()
108  /// \sa UsdPrim::HasAPI()
109  /// \sa UsdPrim::CanApplyAPI()
110  /// \sa UsdPrim::ApplyAPI()
111  /// \sa UsdPrim::RemoveAPI()
112  ///
113  USDUI_API
114  static bool
115  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
116 
117  /// Applies this <b>single-apply</b> API schema to the given \p prim.
118  /// This information is stored by adding "SceneGraphPrimAPI" to the
119  /// token-valued, listOp metadata \em apiSchemas on the prim.
120  ///
121  /// \return A valid UsdUISceneGraphPrimAPI object is returned upon success.
122  /// An invalid (or empty) UsdUISceneGraphPrimAPI object is returned upon
123  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
124  /// resulting in failure.
125  ///
126  /// \sa UsdPrim::GetAppliedSchemas()
127  /// \sa UsdPrim::HasAPI()
128  /// \sa UsdPrim::CanApplyAPI()
129  /// \sa UsdPrim::ApplyAPI()
130  /// \sa UsdPrim::RemoveAPI()
131  ///
132  USDUI_API
133  static UsdUISceneGraphPrimAPI
134  Apply(const UsdPrim &prim);
135 
136 protected:
137  /// Returns the kind of schema this class belongs to.
138  ///
139  /// \sa UsdSchemaKind
140  USDUI_API
141  UsdSchemaKind _GetSchemaKind() const override;
142 
143 private:
144  // needs to invoke _GetStaticTfType.
145  friend class UsdSchemaRegistry;
146  USDUI_API
147  static const TfType &_GetStaticTfType();
148 
149  static bool _IsTypedSchema();
150 
151  // override SchemaBase virtuals.
152  USDUI_API
153  const TfType &_GetTfType() const override;
154 
155 public:
156  // --------------------------------------------------------------------- //
157  // DISPLAYNAME
158  // --------------------------------------------------------------------- //
159  /// When publishing a nodegraph or a material, it can be useful to
160  /// provide an optional display name, for readability.
161  ///
162  ///
163  /// | ||
164  /// | -- | -- |
165  /// | Declaration | `uniform token ui:displayName` |
166  /// | C++ Type | TfToken |
167  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
168  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
169  USDUI_API
171 
172  /// See GetDisplayNameAttr(), and also
173  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
174  /// If specified, author \p defaultValue as the attribute's default,
175  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
176  /// the default for \p writeSparsely is \c false.
177  USDUI_API
178  UsdAttribute CreateDisplayNameAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
179 
180 public:
181  // --------------------------------------------------------------------- //
182  // DISPLAYGROUP
183  // --------------------------------------------------------------------- //
184  /// When publishing a nodegraph or a material, it can be useful to
185  /// provide an optional display group, for organizational purposes and
186  /// readability. This is because often the usd shading hierarchy is rather
187  /// flat while we want to display it in organized groups.
188  ///
189  ///
190  /// | ||
191  /// | -- | -- |
192  /// | Declaration | `uniform token ui:displayGroup` |
193  /// | C++ Type | TfToken |
194  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
195  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
196  USDUI_API
198 
199  /// See GetDisplayGroupAttr(), and also
200  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
201  /// If specified, author \p defaultValue as the attribute's default,
202  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
203  /// the default for \p writeSparsely is \c false.
204  USDUI_API
205  UsdAttribute CreateDisplayGroupAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
206 
207 public:
208  // ===================================================================== //
209  // Feel free to add custom code below this line, it will be preserved by
210  // the code generator.
211  //
212  // Just remember to:
213  // - Close the class declaration with };
214  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
215  // - Close the include guard with #endif
216  // ===================================================================== //
217  // --(BEGIN CUSTOM CODE)--
218 };
219 
221 
222 #endif
USDUI_API UsdAttribute CreateDisplayNameAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDUI_API UsdUISceneGraphPrimAPI Apply(const UsdPrim &prim)
virtual USDUI_API ~UsdUISceneGraphPrimAPI()
Destructor.
USDUI_API UsdSchemaKind _GetSchemaKind() const override
USDUI_API UsdAttribute CreateDisplayGroupAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Single Apply API schema.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDUI_API UsdAttribute GetDisplayNameAttr() const
static USDUI_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
UsdUISceneGraphPrimAPI(const UsdSchemaBase &schemaObj)
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
static const UsdSchemaKind schemaKind
UsdSchemaKind
Definition: common.h:112
#define USDUI_API
Definition: api.h:23
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
static USDUI_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
UsdUISceneGraphPrimAPI(const UsdPrim &prim=UsdPrim())
Definition: value.h:146
static USDUI_API UsdUISceneGraphPrimAPI Get(const UsdStagePtr &stage, const SdfPath &path)
USDUI_API UsdAttribute GetDisplayGroupAttr() const