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 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 USDUI_GENERATED_NODEGRAPHNODEAPI_H
25 #define USDUI_GENERATED_NODEGRAPHNODEAPI_H
26 
27 /// \file usdUI/nodeGraphNodeAPI.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdUI/api.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usdUI/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 // NODEGRAPHNODEAPI //
51 // -------------------------------------------------------------------------- //
52 
53 /// \class UsdUINodeGraphNodeAPI
54 ///
55 ///
56 /// This api helps storing information about nodes in node graphs.
57 ///
58 ///
59 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
60 /// that are text/tokens, the actual token is published and defined in \ref UsdUITokens.
61 /// So to set an attribute to the value "rightHanded", use UsdUITokens->rightHanded
62 /// as the value.
63 ///
65 {
66 public:
67  /// Compile time constant representing what kind of schema this class is.
68  ///
69  /// \sa UsdSchemaKind
71 
72  /// Construct a UsdUINodeGraphNodeAPI on UsdPrim \p prim .
73  /// Equivalent to UsdUINodeGraphNodeAPI::Get(prim.GetStage(), prim.GetPath())
74  /// for a \em valid \p prim, but will not immediately throw an error for
75  /// an invalid \p prim
76  explicit UsdUINodeGraphNodeAPI(const UsdPrim& prim=UsdPrim())
77  : UsdAPISchemaBase(prim)
78  {
79  }
80 
81  /// Construct a UsdUINodeGraphNodeAPI on the prim held by \p schemaObj .
82  /// Should be preferred over UsdUINodeGraphNodeAPI(schemaObj.GetPrim()),
83  /// as it preserves SchemaBase state.
84  explicit UsdUINodeGraphNodeAPI(const UsdSchemaBase& schemaObj)
85  : UsdAPISchemaBase(schemaObj)
86  {
87  }
88 
89  /// Destructor.
90  USDUI_API
91  virtual ~UsdUINodeGraphNodeAPI();
92 
93  /// Return a vector of names of all pre-declared attributes for this schema
94  /// class and all its ancestor classes. Does not include attributes that
95  /// may be authored by custom/extended methods of the schemas involved.
96  USDUI_API
97  static const TfTokenVector &
98  GetSchemaAttributeNames(bool includeInherited=true);
99 
100  /// Return a UsdUINodeGraphNodeAPI holding the prim adhering to this
101  /// schema at \p path on \p stage. If no prim exists at \p path on
102  /// \p stage, or if the prim at that path does not adhere to this schema,
103  /// return an invalid schema object. This is shorthand for the following:
104  ///
105  /// \code
106  /// UsdUINodeGraphNodeAPI(stage->GetPrimAtPath(path));
107  /// \endcode
108  ///
109  USDUI_API
110  static UsdUINodeGraphNodeAPI
111  Get(const UsdStagePtr &stage, const SdfPath &path);
112 
113 
114  /// Returns true if this <b>single-apply</b> API schema can be applied to
115  /// the given \p prim. If this schema can not be a applied to the prim,
116  /// this returns false and, if provided, populates \p whyNot with the
117  /// reason it can not be applied.
118  ///
119  /// Note that if CanApply returns false, that does not necessarily imply
120  /// that calling Apply will fail. Callers are expected to call CanApply
121  /// before calling Apply if they want to ensure that it is valid to
122  /// apply a schema.
123  ///
124  /// \sa UsdPrim::GetAppliedSchemas()
125  /// \sa UsdPrim::HasAPI()
126  /// \sa UsdPrim::CanApplyAPI()
127  /// \sa UsdPrim::ApplyAPI()
128  /// \sa UsdPrim::RemoveAPI()
129  ///
130  USDUI_API
131  static bool
132  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
133 
134  /// Applies this <b>single-apply</b> API schema to the given \p prim.
135  /// This information is stored by adding "NodeGraphNodeAPI" to the
136  /// token-valued, listOp metadata \em apiSchemas on the prim.
137  ///
138  /// \return A valid UsdUINodeGraphNodeAPI object is returned upon success.
139  /// An invalid (or empty) UsdUINodeGraphNodeAPI object is returned upon
140  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
141  /// resulting in failure.
142  ///
143  /// \sa UsdPrim::GetAppliedSchemas()
144  /// \sa UsdPrim::HasAPI()
145  /// \sa UsdPrim::CanApplyAPI()
146  /// \sa UsdPrim::ApplyAPI()
147  /// \sa UsdPrim::RemoveAPI()
148  ///
149  USDUI_API
150  static UsdUINodeGraphNodeAPI
151  Apply(const UsdPrim &prim);
152 
153 protected:
154  /// Returns the kind of schema this class belongs to.
155  ///
156  /// \sa UsdSchemaKind
157  USDUI_API
158  UsdSchemaKind _GetSchemaKind() const override;
159 
160 private:
161  // needs to invoke _GetStaticTfType.
162  friend class UsdSchemaRegistry;
163  USDUI_API
164  static const TfType &_GetStaticTfType();
165 
166  static bool _IsTypedSchema();
167 
168  // override SchemaBase virtuals.
169  USDUI_API
170  const TfType &_GetTfType() const override;
171 
172 public:
173  // --------------------------------------------------------------------- //
174  // POS
175  // --------------------------------------------------------------------- //
176  ///
177  /// Declared relative position to the parent in a node graph.
178  /// X is the horizontal position.
179  /// Y is the vertical position. Higher numbers correspond to lower positions
180  /// (coordinates are Qt style, not cartesian).
181  ///
182  /// These positions are not explicitly meant in pixel space, but rather
183  /// assume that the size of a node is approximately 1.0x1.0. Where size-x is
184  /// the node width and size-y height of the node. Depending on
185  /// graph UI implementation, the size of a node may vary in each direction.
186  ///
187  /// Example: If a node's width is 300 and it is position is at 1000, we
188  /// store for x-position: 1000 * (1.0/300)
189  ///
190  ///
191  /// | ||
192  /// | -- | -- |
193  /// | Declaration | `uniform float2 ui:nodegraph:node:pos` |
194  /// | C++ Type | GfVec2f |
195  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float2 |
196  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
197  USDUI_API
198  UsdAttribute GetPosAttr() const;
199 
200  /// See GetPosAttr(), and also
201  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
202  /// If specified, author \p defaultValue as the attribute's default,
203  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
204  /// the default for \p writeSparsely is \c false.
205  USDUI_API
206  UsdAttribute CreatePosAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
207 
208 public:
209  // --------------------------------------------------------------------- //
210  // STACKINGORDER
211  // --------------------------------------------------------------------- //
212  ///
213  /// This optional value is a useful hint when an application cares about
214  /// the visibility of a node and whether each node overlaps another.
215  ///
216  /// Nodes with lower stacking order values are meant to be drawn below
217  /// higher ones. Negative values are meant as background. Positive values
218  /// are meant as foreground.
219  /// Undefined values should be treated as 0.
220  ///
221  /// There are no set limits in these values.
222  ///
223  ///
224  /// | ||
225  /// | -- | -- |
226  /// | Declaration | `uniform int ui:nodegraph:node:stackingOrder` |
227  /// | C++ Type | int |
228  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
229  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
230  USDUI_API
232 
233  /// See GetStackingOrderAttr(), and also
234  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
235  /// If specified, author \p defaultValue as the attribute's default,
236  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
237  /// the default for \p writeSparsely is \c false.
238  USDUI_API
239  UsdAttribute CreateStackingOrderAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
240 
241 public:
242  // --------------------------------------------------------------------- //
243  // DISPLAYCOLOR
244  // --------------------------------------------------------------------- //
245  ///
246  /// This hint defines what tint the node should have in the node graph.
247  ///
248  ///
249  /// | ||
250  /// | -- | -- |
251  /// | Declaration | `uniform color3f ui:nodegraph:node:displayColor` |
252  /// | C++ Type | GfVec3f |
253  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Color3f |
254  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
255  USDUI_API
257 
258  /// See GetDisplayColorAttr(), and also
259  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
260  /// If specified, author \p defaultValue as the attribute's default,
261  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
262  /// the default for \p writeSparsely is \c false.
263  USDUI_API
264  UsdAttribute CreateDisplayColorAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
265 
266 public:
267  // --------------------------------------------------------------------- //
268  // ICON
269  // --------------------------------------------------------------------- //
270  ///
271  /// This points to an image that should be displayed on the node. It is
272  /// intended to be useful for summary visual classification of nodes, rather
273  /// than a thumbnail preview of the computed result of the node in some
274  /// computational system.
275  ///
276  ///
277  /// | ||
278  /// | -- | -- |
279  /// | Declaration | `uniform asset ui:nodegraph:node:icon` |
280  /// | C++ Type | SdfAssetPath |
281  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Asset |
282  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
283  USDUI_API
284  UsdAttribute GetIconAttr() const;
285 
286  /// See GetIconAttr(), and also
287  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
288  /// If specified, author \p defaultValue as the attribute's default,
289  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
290  /// the default for \p writeSparsely is \c false.
291  USDUI_API
292  UsdAttribute CreateIconAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
293 
294 public:
295  // --------------------------------------------------------------------- //
296  // EXPANSIONSTATE
297  // --------------------------------------------------------------------- //
298  ///
299  /// The current expansionState of the node in the ui.
300  /// 'open' = fully expanded
301  /// 'closed' = fully collapsed
302  /// 'minimized' = should take the least space possible
303  ///
304  ///
305  /// | ||
306  /// | -- | -- |
307  /// | Declaration | `uniform token ui:nodegraph:node:expansionState` |
308  /// | C++ Type | TfToken |
309  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
310  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
311  /// | \ref UsdUITokens "Allowed Values" | open, closed, minimized |
312  USDUI_API
314 
315  /// See GetExpansionStateAttr(), and also
316  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
317  /// If specified, author \p defaultValue as the attribute's default,
318  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
319  /// the default for \p writeSparsely is \c false.
320  USDUI_API
321  UsdAttribute CreateExpansionStateAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
322 
323 public:
324  // --------------------------------------------------------------------- //
325  // SIZE
326  // --------------------------------------------------------------------- //
327  ///
328  /// Optional size hint for a node in a node graph.
329  /// X is the width.
330  /// Y is the height.
331  ///
332  /// This value is optional, because node size is often determined
333  /// based on the number of in- and outputs of a node.
334  ///
335  ///
336  /// | ||
337  /// | -- | -- |
338  /// | Declaration | `uniform float2 ui:nodegraph:node:size` |
339  /// | C++ Type | GfVec2f |
340  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float2 |
341  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
342  USDUI_API
343  UsdAttribute GetSizeAttr() const;
344 
345  /// See GetSizeAttr(), and also
346  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
347  /// If specified, author \p defaultValue as the attribute's default,
348  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
349  /// the default for \p writeSparsely is \c false.
350  USDUI_API
351  UsdAttribute CreateSizeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
352 
353 public:
354  // ===================================================================== //
355  // Feel free to add custom code below this line, it will be preserved by
356  // the code generator.
357  //
358  // Just remember to:
359  // - Close the class declaration with };
360  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
361  // - Close the include guard with #endif
362  // ===================================================================== //
363  // --(BEGIN CUSTOM CODE)--
364 };
365 
367 
368 #endif
static USDUI_API UsdUINodeGraphNodeAPI Apply(const UsdPrim &prim)
Single Apply API schema.
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDUI_API UsdAttribute GetSizeAttr() 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:133
USDUI_API UsdAttribute GetDisplayColorAttr() const
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457
USDUI_API UsdAttribute GetExpansionStateAttr() const
Definition: path.h:290
UsdSchemaKind
Definition: common.h:129
static const UsdSchemaKind schemaKind
USDUI_API UsdSchemaKind _GetSchemaKind() const override
#define USDUI_API
Definition: api.h:40
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:1432
USDUI_API UsdAttribute GetStackingOrderAttr() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
static USDUI_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Definition: type.h:64
USDUI_API UsdAttribute CreateDisplayColorAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: value.h:164