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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef USDHOUDINI_GENERATED_HOUDINISELECTABLEAPI_H
25 #define USDHOUDINI_GENERATED_HOUDINISELECTABLEAPI_H
26 
27 /// \file usdHoudini/houdiniSelectableAPI.h
28 
29 #include "pxr/pxr.h"
30 #include "./api.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "./tokens.h"
35 
36 #include "pxr/base/vt/value.h"
37 
38 #include "pxr/base/gf/vec3d.h"
39 #include "pxr/base/gf/vec3f.h"
40 #include "pxr/base/gf/matrix4d.h"
41 
42 #include "pxr/base/tf/token.h"
43 #include "pxr/base/tf/type.h"
44 
46 
47 class SdfAssetPath;
48 
49 // -------------------------------------------------------------------------- //
50 // HOUDINISELECTABLEAPI //
51 // -------------------------------------------------------------------------- //
52 
53 /// \class UsdHoudiniHoudiniSelectableAPI
54 ///
55 /// Houdini API schema for marking primitives as selectable or not.
56 ///
57 class
60 {
61 public:
62  /// Compile time constant representing what kind of schema this class is.
63  ///
64  /// \sa UsdSchemaKind
65  static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
66 
67  /// Construct a UsdHoudiniHoudiniSelectableAPI on UsdPrim \p prim .
68  /// Equivalent to UsdHoudiniHoudiniSelectableAPI::Get(prim.GetStage(), prim.GetPath())
69  /// for a \em valid \p prim, but will not immediately throw an error for
70  /// an invalid \p prim
72  : UsdAPISchemaBase(prim)
73  {
74  }
75 
76  /// Construct a UsdHoudiniHoudiniSelectableAPI on the prim held by \p schemaObj .
77  /// Should be preferred over UsdHoudiniHoudiniSelectableAPI(schemaObj.GetPrim()),
78  /// as it preserves SchemaBase state.
79  explicit UsdHoudiniHoudiniSelectableAPI(const UsdSchemaBase& schemaObj)
80  : UsdAPISchemaBase(schemaObj)
81  {
82  }
83 
84  /// Destructor.
85  virtual ~UsdHoudiniHoudiniSelectableAPI() override;
86 
87  /// Return a vector of names of all pre-declared attributes for this schema
88  /// class and all its ancestor classes. Does not include attributes that
89  /// may be authored by custom/extended methods of the schemas involved.
90  static const TfTokenVector &
91  GetSchemaAttributeNames(bool includeInherited=true);
92 
93  /// Return a UsdHoudiniHoudiniSelectableAPI holding the prim adhering to this
94  /// schema at \p path on \p stage. If no prim exists at \p path on
95  /// \p stage, or if the prim at that path does not adhere to this schema,
96  /// return an invalid schema object. This is shorthand for the following:
97  ///
98  /// \code
99  /// UsdHoudiniHoudiniSelectableAPI(stage->GetPrimAtPath(path));
100  /// \endcode
101  ///
103  Get(const UsdStagePtr &stage, const SdfPath &path);
104 
105 
106  /// Returns true if this <b>single-apply</b> API schema can be applied to
107  /// the given \p prim. If this schema can not be a applied to the prim,
108  /// this returns false and, if provided, populates \p whyNot with the
109  /// reason it can not be applied.
110  ///
111  /// Note that if CanApply returns false, that does not necessarily imply
112  /// that calling Apply will fail. Callers are expected to call CanApply
113  /// before calling Apply if they want to ensure that it is valid to
114  /// apply a schema.
115  ///
116  /// \sa UsdPrim::GetAppliedSchemas()
117  /// \sa UsdPrim::HasAPI()
118  /// \sa UsdPrim::CanApplyAPI()
119  /// \sa UsdPrim::ApplyAPI()
120  /// \sa UsdPrim::RemoveAPI()
121  ///
122  static bool
123  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
124 
125  /// Applies this <b>single-apply</b> API schema to the given \p prim.
126  /// This information is stored by adding "HoudiniSelectableAPI" to the
127  /// token-valued, listOp metadata \em apiSchemas on the prim.
128  ///
129  /// \return A valid UsdHoudiniHoudiniSelectableAPI object is returned upon success.
130  /// An invalid (or empty) UsdHoudiniHoudiniSelectableAPI object is returned upon
131  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
132  /// resulting in failure.
133  ///
134  /// \sa UsdPrim::GetAppliedSchemas()
135  /// \sa UsdPrim::HasAPI()
136  /// \sa UsdPrim::CanApplyAPI()
137  /// \sa UsdPrim::ApplyAPI()
138  /// \sa UsdPrim::RemoveAPI()
139  ///
141  Apply(const UsdPrim &prim);
142 
143 protected:
144  /// Returns the kind of schema this class belongs to.
145  ///
146  /// \sa UsdSchemaKind
147  UsdSchemaKind _GetSchemaKind() const override;
148 
149 private:
150  // needs to invoke _GetStaticTfType.
151  friend class UsdSchemaRegistry;
152  static const TfType &_GetStaticTfType();
153 
154  static bool _IsTypedSchema();
155 
156  // override SchemaBase virtuals.
157  const TfType &_GetTfType() const override;
158 
159 public:
160  // --------------------------------------------------------------------- //
161  // HOUDINISELECTABLE
162  // --------------------------------------------------------------------- //
163  /// If true, then this primitive will be selectable in the Houdini
164  /// viewport. If false, clicking on this primitive in the viewport
165  /// will select nothing. This attribute can be set at any level
166  /// of the scene graph hierarchy, and its effect will apply to all
167  /// descendant primitives. If values are authored at multiple
168  /// levels of the scene graph tree, the value on the primitive or
169  /// ancestor closest to the primitive that was clicked on will
170  /// determine if the primitive can be selected or not.
171  ///
172  /// | ||
173  /// | -- | -- |
174  /// | Declaration | `uniform bool houdini:selectable = 1` |
175  /// | C++ Type | bool |
176  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
177  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
178  UsdAttribute GetHoudiniSelectableAttr() const;
179 
180  /// See GetHoudiniSelectableAttr(), and also
181  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
182  /// If specified, author \p defaultValue as the attribute's default,
183  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
184  /// the default for \p writeSparsely is \c false.
185  UsdAttribute CreateHoudiniSelectableAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
186 
187 public:
188  // ===================================================================== //
189  // Feel free to add custom code below this line, it will be preserved by
190  // the code generator.
191  //
192  // Just remember to:
193  // - Close the class declaration with };
194  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
195  // - Close the include guard with #endif
196  // ===================================================================== //
197  // --(BEGIN CUSTOM CODE)--
198 };
199 
201 
202 #endif
#define USDHOUDINI_API
Definition: api.h:47
Single Apply API schema.
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
UsdHoudiniHoudiniSelectableAPI(const UsdPrim &prim=UsdPrim())
Definition: prim.h:135
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
Definition: path.h:291
UsdSchemaKind
Definition: common.h:127
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
Definition: type.h:64
UsdHoudiniHoudiniSelectableAPI(const UsdSchemaBase &schemaObj)
Definition: value.h:167