HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nodeGraphNodeAPI.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_NODEGRAPHNODEAPI_H
8 #define USDUI_GENERATED_NODEGRAPHNODEAPI_H
9 
10 /// \file usdUI/nodeGraphNodeAPI.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 // NODEGRAPHNODEAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdUINodeGraphNodeAPI
37 ///
38 ///
39 /// This api helps storing information about nodes in node graphs.
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 UsdUINodeGraphNodeAPI on UsdPrim \p prim .
56  /// Equivalent to UsdUINodeGraphNodeAPI::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 UsdUINodeGraphNodeAPI(const UsdPrim& prim=UsdPrim())
60  : UsdAPISchemaBase(prim)
61  {
62  }
63 
64  /// Construct a UsdUINodeGraphNodeAPI on the prim held by \p schemaObj .
65  /// Should be preferred over UsdUINodeGraphNodeAPI(schemaObj.GetPrim()),
66  /// as it preserves SchemaBase state.
67  explicit UsdUINodeGraphNodeAPI(const UsdSchemaBase& schemaObj)
68  : UsdAPISchemaBase(schemaObj)
69  {
70  }
71 
72  /// Destructor.
73  USDUI_API
74  virtual ~UsdUINodeGraphNodeAPI();
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 UsdUINodeGraphNodeAPI 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  /// UsdUINodeGraphNodeAPI(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 "NodeGraphNodeAPI" to the
119  /// token-valued, listOp metadata \em apiSchemas on the prim.
120  ///
121  /// \return A valid UsdUINodeGraphNodeAPI object is returned upon success.
122  /// An invalid (or empty) UsdUINodeGraphNodeAPI 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 UsdUINodeGraphNodeAPI
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  // POS
158  // --------------------------------------------------------------------- //
159  ///
160  /// Declared relative position to the parent in a node graph.
161  /// X is the horizontal position.
162  /// Y is the vertical position. Higher numbers correspond to lower positions
163  /// (coordinates are Qt style, not cartesian).
164  ///
165  /// These positions are not explicitly meant in pixel space, but rather
166  /// assume that the size of a node is approximately 1.0x1.0. Where size-x is
167  /// the node width and size-y height of the node. Depending on
168  /// graph UI implementation, the size of a node may vary in each direction.
169  ///
170  /// Example: If a node's width is 300 and it is position is at 1000, we
171  /// store for x-position: 1000 * (1.0/300)
172  ///
173  ///
174  /// | ||
175  /// | -- | -- |
176  /// | Declaration | `uniform float2 ui:nodegraph:node:pos` |
177  /// | C++ Type | GfVec2f |
178  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float2 |
179  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
180  USDUI_API
181  UsdAttribute GetPosAttr() const;
182 
183  /// See GetPosAttr(), and also
184  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
185  /// If specified, author \p defaultValue as the attribute's default,
186  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
187  /// the default for \p writeSparsely is \c false.
188  USDUI_API
189  UsdAttribute CreatePosAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
190 
191 public:
192  // --------------------------------------------------------------------- //
193  // STACKINGORDER
194  // --------------------------------------------------------------------- //
195  ///
196  /// This optional value is a useful hint when an application cares about
197  /// the visibility of a node and whether each node overlaps another.
198  ///
199  /// Nodes with lower stacking order values are meant to be drawn below
200  /// higher ones. Negative values are meant as background. Positive values
201  /// are meant as foreground.
202  /// Undefined values should be treated as 0.
203  ///
204  /// There are no set limits in these values.
205  ///
206  ///
207  /// | ||
208  /// | -- | -- |
209  /// | Declaration | `uniform int ui:nodegraph:node:stackingOrder` |
210  /// | C++ Type | int |
211  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
212  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
213  USDUI_API
215 
216  /// See GetStackingOrderAttr(), and also
217  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
218  /// If specified, author \p defaultValue as the attribute's default,
219  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
220  /// the default for \p writeSparsely is \c false.
221  USDUI_API
222  UsdAttribute CreateStackingOrderAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
223 
224 public:
225  // --------------------------------------------------------------------- //
226  // DISPLAYCOLOR
227  // --------------------------------------------------------------------- //
228  ///
229  /// This hint defines what tint the node should have in the node graph.
230  ///
231  ///
232  /// | ||
233  /// | -- | -- |
234  /// | Declaration | `uniform color3f ui:nodegraph:node:displayColor` |
235  /// | C++ Type | GfVec3f |
236  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Color3f |
237  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
238  USDUI_API
240 
241  /// See GetDisplayColorAttr(), and also
242  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
243  /// If specified, author \p defaultValue as the attribute's default,
244  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
245  /// the default for \p writeSparsely is \c false.
246  USDUI_API
247  UsdAttribute CreateDisplayColorAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
248 
249 public:
250  // --------------------------------------------------------------------- //
251  // ICON
252  // --------------------------------------------------------------------- //
253  ///
254  /// This points to an image that should be displayed on the node. It is
255  /// intended to be useful for summary visual classification of nodes, rather
256  /// than a thumbnail preview of the computed result of the node in some
257  /// computational system.
258  ///
259  ///
260  /// | ||
261  /// | -- | -- |
262  /// | Declaration | `uniform asset ui:nodegraph:node:icon` |
263  /// | C++ Type | SdfAssetPath |
264  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Asset |
265  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
266  USDUI_API
267  UsdAttribute GetIconAttr() const;
268 
269  /// See GetIconAttr(), and also
270  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
271  /// If specified, author \p defaultValue as the attribute's default,
272  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
273  /// the default for \p writeSparsely is \c false.
274  USDUI_API
275  UsdAttribute CreateIconAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
276 
277 public:
278  // --------------------------------------------------------------------- //
279  // EXPANSIONSTATE
280  // --------------------------------------------------------------------- //
281  ///
282  /// The current expansionState of the node in the ui.
283  /// 'open' = fully expanded
284  /// 'closed' = fully collapsed
285  /// 'minimized' = should take the least space possible
286  ///
287  ///
288  /// | ||
289  /// | -- | -- |
290  /// | Declaration | `uniform token ui:nodegraph:node:expansionState` |
291  /// | C++ Type | TfToken |
292  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
293  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
294  /// | \ref UsdUITokens "Allowed Values" | open, closed, minimized |
295  USDUI_API
297 
298  /// See GetExpansionStateAttr(), and also
299  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
300  /// If specified, author \p defaultValue as the attribute's default,
301  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
302  /// the default for \p writeSparsely is \c false.
303  USDUI_API
304  UsdAttribute CreateExpansionStateAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
305 
306 public:
307  // --------------------------------------------------------------------- //
308  // SIZE
309  // --------------------------------------------------------------------- //
310  ///
311  /// Optional size hint for a node in a node graph.
312  /// X is the width.
313  /// Y is the height.
314  ///
315  /// This value is optional, because node size is often determined
316  /// based on the number of in- and outputs of a node.
317  ///
318  ///
319  /// | ||
320  /// | -- | -- |
321  /// | Declaration | `uniform float2 ui:nodegraph:node:size` |
322  /// | C++ Type | GfVec2f |
323  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float2 |
324  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
325  USDUI_API
326  UsdAttribute GetSizeAttr() const;
327 
328  /// See GetSizeAttr(), and also
329  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
330  /// If specified, author \p defaultValue as the attribute's default,
331  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
332  /// the default for \p writeSparsely is \c false.
333  USDUI_API
334  UsdAttribute CreateSizeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
335 
336 public:
337  // --------------------------------------------------------------------- //
338  // DOCURI
339  // --------------------------------------------------------------------- //
340  ///
341  /// A URI pointing to additional detailed documentation for this
342  /// node or node type.
343  ///
344  ///
345  /// | ||
346  /// | -- | -- |
347  /// | Declaration | `uniform string ui:nodegraph:node:docURI` |
348  /// | C++ Type | std::string |
349  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->String |
350  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
351  USDUI_API
352  UsdAttribute GetDocURIAttr() const;
353 
354  /// See GetDocURIAttr(), and also
355  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
356  /// If specified, author \p defaultValue as the attribute's default,
357  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
358  /// the default for \p writeSparsely is \c false.
359  USDUI_API
360  UsdAttribute CreateDocURIAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
361 
362 public:
363  // ===================================================================== //
364  // Feel free to add custom code below this line, it will be preserved by
365  // the code generator.
366  //
367  // Just remember to:
368  // - Close the class declaration with };
369  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
370  // - Close the include guard with #endif
371  // ===================================================================== //
372  // --(BEGIN CUSTOM CODE)--
373 };
374 
376 
377 #endif
static USDUI_API UsdUINodeGraphNodeAPI Apply(const UsdPrim &prim)
Single Apply API schema.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDUI_API UsdAttribute GetSizeAttr() const
USDUI_API UsdAttribute GetDocURIAttr() const
UsdUINodeGraphNodeAPI(const UsdPrim &prim=UsdPrim())
virtual USDUI_API ~UsdUINodeGraphNodeAPI()
Destructor.
USDUI_API UsdAttribute CreateStackingOrderAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDUI_API UsdAttribute CreateIconAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDUI_API UsdAttribute CreatePosAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDUI_API UsdAttribute GetIconAttr() const
static USDUI_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
static USDUI_API UsdUINodeGraphNodeAPI Get(const UsdStagePtr &stage, const SdfPath &path)
USDUI_API UsdAttribute CreateSizeAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: prim.h:116
USDUI_API UsdAttribute GetDisplayColorAttr() const
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
USDUI_API UsdAttribute GetExpansionStateAttr() const
Definition: path.h:273
USDUI_API UsdAttribute CreateDocURIAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdSchemaKind
Definition: common.h:112
static const UsdSchemaKind schemaKind
USDUI_API UsdSchemaKind _GetSchemaKind() const override
#define USDUI_API
Definition: api.h:23
USDUI_API UsdAttribute CreateExpansionStateAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDUI_API UsdAttribute GetPosAttr() const
UsdUINodeGraphNodeAPI(const UsdSchemaBase &schemaObj)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDUI_API UsdAttribute GetStackingOrderAttr() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
static USDUI_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Definition: type.h:47
USDUI_API UsdAttribute CreateDisplayColorAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: value.h:146