HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
inherits.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 PXR_USD_USD_INHERITS_H
8 #define PXR_USD_USD_INHERITS_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/usd/usd/api.h"
12 #include "pxr/usd/usd/common.h"
13 #include "pxr/usd/usd/prim.h"
14 
16 #include "pxr/usd/sdf/path.h"
17 
19 
21 
22 /// \class UsdInherits
23 ///
24 /// A proxy class for applying listOp edits to the inherit paths list for a
25 /// prim.
26 ///
27 /// All paths passed to the UsdInherits API are expected to be in the
28 /// namespace of the owning prim's stage. Subroot prim inherit paths
29 /// will be translated from this namespace to the namespace of the current
30 /// edit target, if necessary. If a path cannot be translated, a coding error
31 /// will be issued and no changes will be made. Root prim inherit paths will
32 /// not be translated.
33 ///
34 class UsdInherits {
35  friend class UsdPrim;
36 
37  explicit UsdInherits(const UsdPrim& prim) : _prim(prim) {}
38 
39 public:
40  /// Adds a path to the inheritPaths listOp at the current EditTarget,
41  /// in the position specified by \p position.
42  USD_API
43  bool AddInherit(const SdfPath &primPath,
45 
46  /// Removes the specified path from the inheritPaths listOp at the
47  /// current EditTarget.
48  USD_API
49  bool RemoveInherit(const SdfPath &primPath);
50 
51  /// Removes the authored inheritPaths listOp edits at the current edit
52  /// target.
53  USD_API
54  bool ClearInherits();
55 
56  /// Explicitly set the inherited paths, potentially blocking weaker opinions
57  /// that add or remove items, returning true on success, false if the edit
58  /// could not be performed.
59  USD_API
60  bool SetInherits(const SdfPathVector& items);
61 
62  /// Return all the paths in this prim's stage's local layer stack that would
63  /// compose into this prim via direct inherits (excluding prim specs that
64  /// would be composed into this prim due to inherits authored on ancestral
65  /// prims) in strong-to-weak order.
66  ///
67  /// Note that there currently may not be any scene description at these
68  /// paths on the stage. This returns all the potential places that such
69  /// opinions could appear.
70  USD_API
72 
73  /// Return the prim this object is bound to.
74  const UsdPrim &GetPrim() const { return _prim; }
75  UsdPrim GetPrim() { return _prim; }
76 
77  explicit operator bool() { return bool(_prim); }
78 
79  // ---------------------------------------------------------------------- //
80  // Private Methods and Members
81  // ---------------------------------------------------------------------- //
82 private:
83 
84  UsdPrim _prim;
85 };
86 
88 
89 #endif // PXR_USD_USD_INHERITS_H
#define USD_API
Definition: api.h:23
USD_API bool ClearInherits()
UsdPrim GetPrim()
Definition: inherits.h:75
USD_API bool RemoveInherit(const SdfPath &primPath)
OutGridT const XformOp bool bool
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfPrimSpec)
USD_API bool AddInherit(const SdfPath &primPath, UsdListPosition position=UsdListPositionBackOfPrependList)
std::vector< class SdfPath > SdfPathVector
USD_API SdfPathVector GetAllDirectInherits() const
Definition: prim.h:116
Definition: path.h:273
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
SIM_API const UT_StringHolder position
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
UsdListPosition
Definition: common.h:71
USD_API bool SetInherits(const SdfPathVector &items)
const UsdPrim & GetPrim() const
Return the prim this object is bound to.
Definition: inherits.h:74