HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
houdiniSelectableAPI.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 USDHOUDINI_GENERATED_HOUDINISELECTABLEAPI_H
8 #define USDHOUDINI_GENERATED_HOUDINISELECTABLEAPI_H
9 
10 /// \file usdHoudini/houdiniSelectableAPI.h
11 
12 #include "pxr/pxr.h"
13 #include "./api.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
17 #include "./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 // HOUDINISELECTABLEAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdHoudiniHoudiniSelectableAPI
37 ///
38 /// Houdini API schema for marking primitives as selectable or not.
39 ///
40 class
43 {
44 public:
45  /// Compile time constant representing what kind of schema this class is.
46  ///
47  /// \sa UsdSchemaKind
48  static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
49 
50  /// Construct a UsdHoudiniHoudiniSelectableAPI on UsdPrim \p prim .
51  /// Equivalent to UsdHoudiniHoudiniSelectableAPI::Get(prim.GetStage(), prim.GetPath())
52  /// for a \em valid \p prim, but will not immediately throw an error for
53  /// an invalid \p prim
55  : UsdAPISchemaBase(prim)
56  {
57  }
58 
59  /// Construct a UsdHoudiniHoudiniSelectableAPI on the prim held by \p schemaObj .
60  /// Should be preferred over UsdHoudiniHoudiniSelectableAPI(schemaObj.GetPrim()),
61  /// as it preserves SchemaBase state.
62  explicit UsdHoudiniHoudiniSelectableAPI(const UsdSchemaBase& schemaObj)
63  : UsdAPISchemaBase(schemaObj)
64  {
65  }
66 
67  /// Destructor.
68  virtual ~UsdHoudiniHoudiniSelectableAPI() override;
69 
70  /// Return a vector of names of all pre-declared attributes for this schema
71  /// class and all its ancestor classes. Does not include attributes that
72  /// may be authored by custom/extended methods of the schemas involved.
73  static const TfTokenVector &
74  GetSchemaAttributeNames(bool includeInherited=true);
75 
76  /// Return a UsdHoudiniHoudiniSelectableAPI holding the prim adhering to this
77  /// schema at \p path on \p stage. If no prim exists at \p path on
78  /// \p stage, or if the prim at that path does not adhere to this schema,
79  /// return an invalid schema object. This is shorthand for the following:
80  ///
81  /// \code
82  /// UsdHoudiniHoudiniSelectableAPI(stage->GetPrimAtPath(path));
83  /// \endcode
84  ///
86  Get(const UsdStagePtr &stage, const SdfPath &path);
87 
88 
89  /// Returns true if this <b>single-apply</b> API schema can be applied to
90  /// the given \p prim. If this schema can not be a applied to the prim,
91  /// this returns false and, if provided, populates \p whyNot with the
92  /// reason it can not be applied.
93  ///
94  /// Note that if CanApply returns false, that does not necessarily imply
95  /// that calling Apply will fail. Callers are expected to call CanApply
96  /// before calling Apply if they want to ensure that it is valid to
97  /// apply a schema.
98  ///
99  /// \sa UsdPrim::GetAppliedSchemas()
100  /// \sa UsdPrim::HasAPI()
101  /// \sa UsdPrim::CanApplyAPI()
102  /// \sa UsdPrim::ApplyAPI()
103  /// \sa UsdPrim::RemoveAPI()
104  ///
105  static bool
106  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
107 
108  /// Applies this <b>single-apply</b> API schema to the given \p prim.
109  /// This information is stored by adding "HoudiniSelectableAPI" to the
110  /// token-valued, listOp metadata \em apiSchemas on the prim.
111  ///
112  /// \return A valid UsdHoudiniHoudiniSelectableAPI object is returned upon success.
113  /// An invalid (or empty) UsdHoudiniHoudiniSelectableAPI object is returned upon
114  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
115  /// resulting in failure.
116  ///
117  /// \sa UsdPrim::GetAppliedSchemas()
118  /// \sa UsdPrim::HasAPI()
119  /// \sa UsdPrim::CanApplyAPI()
120  /// \sa UsdPrim::ApplyAPI()
121  /// \sa UsdPrim::RemoveAPI()
122  ///
124  Apply(const UsdPrim &prim);
125 
126 protected:
127  /// Returns the kind of schema this class belongs to.
128  ///
129  /// \sa UsdSchemaKind
130  UsdSchemaKind _GetSchemaKind() const override;
131 
132 private:
133  // needs to invoke _GetStaticTfType.
134  friend class UsdSchemaRegistry;
135  static const TfType &_GetStaticTfType();
136 
137  static bool _IsTypedSchema();
138 
139  // override SchemaBase virtuals.
140  const TfType &_GetTfType() const override;
141 
142 public:
143  // --------------------------------------------------------------------- //
144  // HOUDINISELECTABLE
145  // --------------------------------------------------------------------- //
146  /// If true, then this primitive will be selectable in the Houdini
147  /// viewport. If false, clicking on this primitive in the viewport
148  /// will select nothing. This attribute can be set at any level
149  /// of the scene graph hierarchy, and its effect will apply to all
150  /// descendant primitives. If values are authored at multiple
151  /// levels of the scene graph tree, the value on the primitive or
152  /// ancestor closest to the primitive that was clicked on will
153  /// determine if the primitive can be selected or not.
154  ///
155  /// | ||
156  /// | -- | -- |
157  /// | Declaration | `uniform bool houdini:selectable = 1` |
158  /// | C++ Type | bool |
159  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
160  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
161  UsdAttribute GetHoudiniSelectableAttr() const;
162 
163  /// See GetHoudiniSelectableAttr(), and also
164  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
165  /// If specified, author \p defaultValue as the attribute's default,
166  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
167  /// the default for \p writeSparsely is \c false.
168  UsdAttribute CreateHoudiniSelectableAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
169 
170 public:
171  // ===================================================================== //
172  // Feel free to add custom code below this line, it will be preserved by
173  // the code generator.
174  //
175  // Just remember to:
176  // - Close the class declaration with };
177  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
178  // - Close the include guard with #endif
179  // ===================================================================== //
180  // --(BEGIN CUSTOM CODE)--
181 };
182 
184 
185 #endif
#define USDHOUDINI_API
Definition: api.h:23
Single Apply API schema.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
UsdHoudiniHoudiniSelectableAPI(const UsdPrim &prim=UsdPrim())
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
UsdSchemaKind
Definition: common.h:112
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
UsdHoudiniHoudiniSelectableAPI(const UsdSchemaBase &schemaObj)
Definition: value.h:146