All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
connectableAPI.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 USDSHADE_GENERATED_CONNECTABLEAPI_H
25 #define USDSHADE_GENERATED_CONNECTABLEAPI_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdShade/api.h"
31 #include "pxr/usd/usd/apiSchemaBase.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 
35 #include "pxr/usd/usdShade/shader.h"
36 #include "pxr/usd/usdShade/nodeGraph.h"
37 
38 
39 #include "pxr/base/vt/value.h"
40 
41 #include "pxr/base/gf/vec3d.h"
42 #include "pxr/base/gf/vec3f.h"
43 #include "pxr/base/gf/matrix4d.h"
44 
45 #include "pxr/base/tf/token.h"
46 #include "pxr/base/tf/type.h"
47 
48 PXR_NAMESPACE_OPEN_SCOPE
49 
50 class SdfAssetPath;
51 
52 // -------------------------------------------------------------------------- //
53 // CONNECTABLEAPI //
54 // -------------------------------------------------------------------------- //
55 
80 {
81 public:
86 
91  explicit UsdShadeConnectableAPI(const UsdPrim& prim=UsdPrim())
92  : UsdAPISchemaBase(prim)
93  {
94  }
95 
99  explicit UsdShadeConnectableAPI(const UsdSchemaBase& schemaObj)
100  : UsdAPISchemaBase(schemaObj)
101  {
102  }
103 
105  USDSHADE_API
106  virtual ~UsdShadeConnectableAPI();
107 
111  USDSHADE_API
112  static const TfTokenVector &
113  GetSchemaAttributeNames(bool includeInherited=true);
114 
124  USDSHADE_API
126  Get(const UsdStagePtr &stage, const SdfPath &path);
127 
128 
129 protected:
133  USDSHADE_API
134  UsdSchemaType _GetSchemaType() const override;
135 
136 private:
137  // needs to invoke _GetStaticTfType.
138  friend class UsdSchemaRegistry;
139  USDSHADE_API
140  static const TfType &_GetStaticTfType();
141 
142  static bool _IsTypedSchema();
143 
144  // override SchemaBase virtuals.
145  USDSHADE_API
146  const TfType &_GetTfType() const override;
147 
148 public:
149  // ===================================================================== //
150  // Feel free to add custom code below this line, it will be preserved by
151  // the code generator.
152  //
153  // Just remember to:
154  // - Close the class declaration with };
155  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
156  // - Close the include guard with #endif
157  // ===================================================================== //
158  // --(BEGIN CUSTOM CODE)--
159 
160 protected:
163  USDSHADE_API
164  bool _IsCompatible() const override;
165 
166 public:
167 
174  { }
175 
181  UsdShadeConnectableAPI(nodeGraph.GetPrim())
182  { }
183 
185  USDSHADE_API
186  bool IsShader() const;
187 
189  USDSHADE_API
190  bool IsNodeGraph() const;
191 
199 
208  USDSHADE_API
209  static bool CanConnect(const UsdShadeInput &input,
210  const UsdAttribute &source);
211 
213  USDSHADE_API
214  static bool CanConnect(const UsdShadeInput &input,
215  const UsdShadeInput &sourceInput) {
216  return CanConnect(input, sourceInput.GetAttr());
217  }
218 
220  USDSHADE_API
221  static bool CanConnect(const UsdShadeInput &input,
222  const UsdShadeOutput &sourceOutput) {
223  return CanConnect(input, sourceOutput.GetAttr());
224  }
225 
236  USDSHADE_API
237  static bool CanConnect(const UsdShadeOutput &output,
238  const UsdAttribute &source=UsdAttribute());
239 
241  USDSHADE_API
242  static bool CanConnect(const UsdShadeOutput &output,
243  const UsdShadeInput &sourceInput) {
244  return CanConnect(output, sourceInput.GetAttr());
245  }
246 
248  USDSHADE_API
249  static bool CanConnect(const UsdShadeOutput &output,
250  const UsdShadeOutput &sourceOutput) {
251  return CanConnect(output, sourceOutput.GetAttr());
252  }
253 
280  USDSHADE_API
281  static bool ConnectToSource(
282  UsdAttribute const &shadingAttr,
283  UsdShadeConnectableAPI const &source,
284  TfToken const &sourceName,
285  UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output,
287 
289  USDSHADE_API
290  static bool ConnectToSource(
291  UsdShadeInput const &input,
292  UsdShadeConnectableAPI const &source,
293  TfToken const &sourceName,
294  UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output,
296  {
297  return ConnectToSource(input.GetAttr(), source, sourceName, sourceType,
298  typeName);
299  }
300 
302  USDSHADE_API
303  static bool ConnectToSource(
304  UsdShadeOutput const &output,
305  UsdShadeConnectableAPI const &source,
306  TfToken const &sourceName,
307  UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output,
309  {
310  return ConnectToSource(output.GetAttr(), source, sourceName, sourceType,
311  typeName);
312  }
313 
323  USDSHADE_API
324  static bool ConnectToSource(UsdAttribute const &shadingAttr,
325  SdfPath const &sourcePath);
326 
328  USDSHADE_API
329  static bool ConnectToSource(UsdShadeInput const &input,
330  SdfPath const &sourcePath) {
331  return ConnectToSource(input.GetAttr(), sourcePath);
332  }
333 
335  USDSHADE_API
336  static bool ConnectToSource(UsdShadeOutput const &output,
337  SdfPath const &sourcePath) {
338  return ConnectToSource(output.GetAttr(), sourcePath);
339  }
340 
345  USDSHADE_API
346  static bool ConnectToSource(UsdAttribute const &shadingAttr,
347  UsdShadeInput const &sourceInput);
348 
350  USDSHADE_API
351  static bool ConnectToSource(UsdShadeInput const &input,
352  UsdShadeInput const &sourceInput) {
353  return ConnectToSource(input.GetAttr(), sourceInput);
354  }
355 
357  USDSHADE_API
358  static bool ConnectToSource(UsdShadeOutput const &output,
359  UsdShadeInput const &sourceInput) {
360  return ConnectToSource(output.GetAttr(), sourceInput);
361  }
362 
367  USDSHADE_API
368  static bool ConnectToSource(UsdAttribute const &shadingAttr,
369  UsdShadeOutput const &sourceOutput);
370 
372  USDSHADE_API
373  static bool ConnectToSource(UsdShadeInput const &input,
374  UsdShadeOutput const &sourceOutput) {
375  return ConnectToSource(input.GetAttr(), sourceOutput);
376  }
377 
379  USDSHADE_API
380  static bool ConnectToSource(UsdShadeOutput const &output,
381  UsdShadeOutput const &sourceOutput) {
382  return ConnectToSource(output.GetAttr(), sourceOutput);
383  }
384 
385 
407  USDSHADE_API
408  static bool GetConnectedSource(UsdAttribute const &shadingAttr,
409  UsdShadeConnectableAPI *source,
410  TfToken *sourceName,
411  UsdShadeAttributeType *sourceType);
412 
414  USDSHADE_API
415  static bool GetConnectedSource(UsdShadeInput const &input,
416  UsdShadeConnectableAPI *source,
417  TfToken *sourceName,
418  UsdShadeAttributeType *sourceType) {
419  return GetConnectedSource(input.GetAttr(), source, sourceName,
420  sourceType);
421  }
422 
424  USDSHADE_API
425  static bool GetConnectedSource(UsdShadeOutput const &output,
426  UsdShadeConnectableAPI *source,
427  TfToken *sourceName,
428  UsdShadeAttributeType *sourceType) {
429  return GetConnectedSource(output.GetAttr(), source, sourceName,
430  sourceType);
431  }
432 
436  USDSHADE_API
437  static bool GetRawConnectedSourcePaths(UsdAttribute const &shadingAttr,
438  SdfPathVector *sourcePaths);
439 
441  USDSHADE_API
442  static bool GetRawConnectedSourcePaths(UsdShadeInput const &input,
443  SdfPathVector *sourcePaths) {
444  return GetRawConnectedSourcePaths(input.GetAttr(), sourcePaths);
445  }
446 
448  USDSHADE_API
449  static bool GetRawConnectedSourcePaths(UsdShadeOutput const &output,
450  SdfPathVector *sourcePaths) {
451  return GetRawConnectedSourcePaths(output.GetAttr(), sourcePaths);
452  }
453 
467  USDSHADE_API
468  static bool HasConnectedSource(const UsdAttribute &shadingAttr);
469 
471  USDSHADE_API
472  static bool HasConnectedSource(const UsdShadeInput &input) {
473  return HasConnectedSource(input.GetAttr());
474  }
475 
477  USDSHADE_API
478  static bool HasConnectedSource(const UsdShadeOutput &output) {
479  return HasConnectedSource(output.GetAttr());
480  }
481 
486  USDSHADE_API
488  const UsdAttribute &shadingAttr);
489 
491  USDSHADE_API
494  }
495 
497  USDSHADE_API
499  {
501  }
502 
513  USDSHADE_API
514  static bool DisconnectSource(UsdAttribute const &shadingAttr);
515 
517  USDSHADE_API
518  static bool DisconnectSource(UsdShadeInput const &input) {
519  return DisconnectSource(input.GetAttr());
520  }
521 
523  USDSHADE_API
524  static bool DisconnectSource(UsdShadeOutput const &output) {
525  return DisconnectSource(output.GetAttr());
526  }
527 
534  USDSHADE_API
535  static bool ClearSource(UsdAttribute const &shadingAttr);
536 
538  USDSHADE_API
539  static bool ClearSource(UsdShadeInput const &input) {
540  return ClearSource(input.GetAttr());
541  }
542 
544  USDSHADE_API
545  static bool ClearSource(UsdShadeOutput const &output) {
546  return ClearSource(output.GetAttr());
547  }
548 
550 
551 
554 
561  USDSHADE_API
562  UsdShadeOutput CreateOutput(const TfToken& name,
563  const SdfValueTypeName& typeName) const;
564 
569  USDSHADE_API
570  UsdShadeOutput GetOutput(const TfToken &name) const;
571 
575  USDSHADE_API
576  std::vector<UsdShadeOutput> GetOutputs() const;
577 
579 
582 
587  USDSHADE_API
588  UsdShadeInput CreateInput(const TfToken& name,
589  const SdfValueTypeName& typeName) const;
590 
595  USDSHADE_API
596  UsdShadeInput GetInput(const TfToken &name) const;
597 
601  USDSHADE_API
602  std::vector<UsdShadeInput> GetInputs() const;
603 
605 
606 };
607 
608 PXR_NAMESPACE_CLOSE_SCOPE
609 
610 #endif
static USDSHADE_API bool ConnectToSource(UsdShadeOutput const &output, UsdShadeConnectableAPI const &source, TfToken const &sourceName, UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output, SdfValueTypeName typeName=SdfValueTypeName())
USDSHADE_API UsdShadeOutput GetOutput(const TfToken &name) const
Return the requested output if it exists.
static USDSHADE_API bool GetRawConnectedSourcePaths(UsdShadeOutput const &output, SdfPathVector *sourcePaths)
static USDSHADE_API bool GetRawConnectedSourcePaths(UsdAttribute const &shadingAttr, SdfPathVector *sourcePaths)
Returns the &quot;raw&quot; (authored) connected source paths for the given shading attribute.
UsdShadeConnectableAPI(const UsdSchemaBase &schemaObj)
Construct a UsdShadeConnectableAPI on the prim held by schemaObj .
USDSHADE_API UsdSchemaType _GetSchemaType() const override
Returns the type of schema this class belongs to.
static USDSHADE_API bool ConnectToSource(UsdShadeInput const &input, UsdShadeInput const &sourceInput)
static USDSHADE_API bool ConnectToSource(UsdShadeInput const &input, UsdShadeOutput const &sourceOutput)
static USDSHADE_API bool ClearSource(UsdShadeOutput const &output)
static USDSHADE_API bool CanConnect(const UsdShadeInput &input, const UsdShadeInput &sourceInput)
UsdAttribute GetAttr() const
Explicit UsdAttribute extractor.
Definition: output.h:211
static USDSHADE_API bool ConnectToSource(UsdAttribute const &shadingAttr, UsdShadeConnectableAPI const &source, TfToken const &sourceName, UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output, SdfValueTypeName typeName=SdfValueTypeName())
Authors a connection for a given shading attribute shadingAttr.
Represents a value type name, i.e.
Definition: valueTypeName.h:83
USDSHADE_API std::vector< UsdShadeInput > GetInputs() const
Returns all inputs on the connectable prim (i.e.
The base class for all API schemas.
static USDSHADE_API bool ConnectToSource(UsdShadeOutput const &output, UsdShadeInput const &sourceInput)
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
USDSHADE_API UsdShadeOutput CreateOutput(const TfToken &name, const SdfValueTypeName &typeName) const
Create an output, which represents and externally computed, typed value.
A node-graph is a container for shading nodes, as well as other node-graphs.
Definition: nodeGraph.h:79
This class encapsulates a shader or node-graph input, which is a connectable attribute representing a...
Definition: input.h:46
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
static USDSHADE_API bool CanConnect(const UsdShadeInput &input, const UsdShadeOutput &sourceOutput)
static USDSHADE_API bool GetConnectedSource(UsdShadeOutput const &output, UsdShadeConnectableAPI *source, TfToken *sourceName, UsdShadeAttributeType *sourceType)
static USDSHADE_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Return a vector of names of all pre-declared attributes for this schema class and all its ancestor cl...
static USDSHADE_API bool ConnectToSource(UsdShadeInput const &input, SdfPath const &sourcePath)
static USDSHADE_API bool ConnectToSource(UsdShadeOutput const &output, SdfPath const &sourcePath)
static USDSHADE_API bool ConnectToSource(UsdShadeInput const &input, UsdShadeConnectableAPI const &source, TfToken const &sourceName, UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output, SdfValueTypeName typeName=SdfValueTypeName())
Non-applied API schema.
USDSHADE_API bool IsShader() const
Returns true if the prim is a shader.
USDSHADE_API UsdShadeInput CreateInput(const TfToken &name, const SdfValueTypeName &typeName) const
Create an input which can both have a value and be connected.
UsdShadeConnectableAPI is an API schema that provides a common interface for creating outputs and mak...
UsdSchemaType
An enum representing which type of schema a given schema class belongs to.
Definition: common.h:127
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:132
virtual USDSHADE_API ~UsdShadeConnectableAPI()
Destructor.
static const UsdSchemaType schemaType
Compile time constant representing what kind of schema this class is.
const UsdAttribute & GetAttr() const
Explicit UsdAttribute extractor.
Definition: input.h:227
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:431
static USDSHADE_API bool IsSourceConnectionFromBaseMaterial(const UsdAttribute &shadingAttr)
Returns true if the connection to the given shading attribute&#39;s source, as returned by UsdShadeConnec...
USDSHADE_API bool _IsCompatible() const override
Returns true if the given prim is compatible with this API schema, i.e.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
UsdShadeConnectableAPI(const UsdShadeShader &shader)
Constructor that takes a UsdShadeShader.
static USDSHADE_API bool HasConnectedSource(const UsdShadeInput &input)
static USDSHADE_API bool ConnectToSource(UsdShadeOutput const &output, UsdShadeOutput const &sourceOutput)
static USDSHADE_API bool DisconnectSource(UsdAttribute const &shadingAttr)
Disconnect source for this shading attribute.
static USDSHADE_API bool ClearSource(UsdAttribute const &shadingAttr)
Clears source for this shading attribute in the current UsdEditTarget.
static USDSHADE_API bool GetConnectedSource(UsdAttribute const &shadingAttr, UsdShadeConnectableAPI *source, TfToken *sourceName, UsdShadeAttributeType *sourceType)
Finds the source of a connection for the given shading attribute.
static USDSHADE_API bool GetConnectedSource(UsdShadeInput const &input, UsdShadeConnectableAPI *source, TfToken *sourceName, UsdShadeAttributeType *sourceType)
static USDSHADE_API bool HasConnectedSource(const UsdAttribute &shadingAttr)
Returns true if and only if the shading attribute is currently connected to a valid (defined) source...
Contains an asset path and an optional resolved path.
Definition: assetPath.h:43
UsdShadeConnectableAPI(const UsdShadeNodeGraph &nodeGraph)
Constructor that takes a UsdShadeNodeGraph.
static USDSHADE_API bool CanConnect(const UsdShadeOutput &output, const UsdShadeOutput &sourceOutput)
UsdShadeConnectableAPI(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeConnectableAPI on UsdPrim prim .
static USDSHADE_API bool HasConnectedSource(const UsdShadeOutput &output)
static USDSHADE_API bool IsSourceConnectionFromBaseMaterial(const UsdShadeOutput &output)
Base class for all USD shaders.
Definition: shader.h:89
TfType represents a dynamic runtime type.
Definition: type.h:64
Singleton registry that provides access to schema type information and the prim definitions for regis...
USDSHADE_API std::vector< UsdShadeOutput > GetOutputs() const
Returns all outputs on the connectable prim (i.e.
static USDSHADE_API bool CanConnect(const UsdShadeOutput &output, const UsdShadeInput &sourceInput)
This class encapsulates a shader or node-graph output, which is a connectable attribute representing ...
Definition: output.h:45
The base class for all schema types in Usd.
Definition: schemaBase.h:56
USDSHADE_API UsdShadeInput GetInput(const TfToken &name) const
Return the requested input if it exists.
static USDSHADE_API bool CanConnect(const UsdShadeInput &input, const UsdAttribute &source)
Determines whether the given input can be connected to the given source attribute, which can be an input or an output.
static USDSHADE_API UsdShadeConnectableAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdShadeConnectableAPI holding the prim adhering to this schema at path on stage...
static USDSHADE_API bool DisconnectSource(UsdShadeInput const &input)
static USDSHADE_API bool DisconnectSource(UsdShadeOutput const &output)
static USDSHADE_API bool IsSourceConnectionFromBaseMaterial(const UsdShadeInput &input)
static USDSHADE_API bool GetRawConnectedSourcePaths(UsdShadeInput const &input, SdfPathVector *sourcePaths)
USDSHADE_API bool IsNodeGraph() const
Returns true if the prim is a node-graph.
UsdPrim GetPrim() const
Return this schema object&#39;s held prim.
Definition: schemaBase.h:119
static USDSHADE_API bool ClearSource(UsdShadeInput const &input)