All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
primCompositionQuery.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 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 PXR_USD_USD_PRIM_COMPOSITION_QUERY_H
25 #define PXR_USD_USD_PRIM_COMPOSITION_QUERY_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usd/api.h"
31 #include "pxr/usd/usd/prim.h"
32 
33 #include "pxr/usd/pcp/node.h"
34 #include "pxr/usd/pcp/primIndex.h"
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
52 {
53 public:
54  ~UsdPrimCompositionQueryArc() = default;
55 
66 
68  USD_API
69  PcpNodeRef GetTargetNode() const;
70 
76  USD_API
78 
80 
87 
94  USD_API
95  SdfLayerHandle GetIntroducingLayer() const;
96 
104  USD_API
106 
116  USD_API
118  SdfReference *ref) const;
119 
129  USD_API
131  SdfPayload *payload) const;
132 
142  USD_API
144  SdfPath *path) const;
145 
155  USD_API
157  std::string *name) const;
158 
160 
165 
167  USD_API
168  PcpArcType GetArcType() const;
169 
174  USD_API
175  bool IsImplicit() const;
176 
179  USD_API
180  bool IsAncestral() const;
181 
184  USD_API
185  bool HasSpecs() const;
186 
191  USD_API
192  bool IsIntroducedInRootLayerStack() const;
193 
197  USD_API
198  bool IsIntroducedInRootLayerPrimSpec() const;
199 
201 
202 private:
203  // These will only be created by a UsdPrimCompositionQuery itself.
204  friend class UsdPrimCompositionQuery;
206 
207  PcpNodeRef _node;
208  PcpNodeRef _originalIntroducedNode;
209  PcpNodeRef _introducingNode;
210 };
211 
225 {
226 public:
228  enum class ArcTypeFilter
229  {
230  All = 0,
231 
232  // Single arc types
233  Reference,
234  Payload,
235  Inherit,
236  Specialize,
237  Variant,
238 
239  // Related arc types
240  ReferenceOrPayload,
241  InheritOrSpecialize,
242 
243  // Inverse of related arc types
244  NotReferenceOrPayload,
245  NotInheritOrSpecialize,
246  NotVariant
247  };
248 
253  {
254  All = 0,
255 
256  Direct,
257  Ancestral
258  };
259 
263  {
264  All = 0,
265 
266  // Indicates that we only want arcs that are authored somewhere in the
267  // root layer stack.
268  IntroducedInRootLayerStack,
269 
270  // Indicates that we only want arcs that are authored directly in the
271  // in the prim's prim spec in the root layer stack.
272  IntroducedInRootLayerPrimSpec
273  };
274 
277  enum class HasSpecsFilter
278  {
279  All = 0,
280 
281  HasSpecs,
282  HasNoSpecs
283  };
284 
287  struct Filter
288  {
290  ArcTypeFilter arcTypeFilter {ArcTypeFilter::All};
291 
293  DependencyTypeFilter dependencyTypeFilter {DependencyTypeFilter::All};
294 
296  ArcIntroducedFilter arcIntroducedFilter {ArcIntroducedFilter::All};
297 
299  HasSpecsFilter hasSpecsFilter {HasSpecsFilter::All};
300 
301  Filter() {};
302 
303  bool operator==(const Filter &rhs) {
304  return arcIntroducedFilter == rhs.arcIntroducedFilter &&
305  arcTypeFilter == rhs.arcTypeFilter &&
306  dependencyTypeFilter == rhs.dependencyTypeFilter &&
307  hasSpecsFilter == rhs.hasSpecsFilter;
308  };
309 
310  bool operator!=(const Filter &rhs) {
311  return !(*this == rhs);
312  };
313  };
314 
317  USD_API
319 
322  USD_API
324 
328  USD_API
330 
333  USD_API
334  UsdPrimCompositionQuery(const UsdPrim & prim,
335  const Filter &filter = Filter());
336 
337  ~UsdPrimCompositionQuery() = default;
338 
340  USD_API
341  void SetFilter(const Filter &filter);
342 
344  USD_API
345  Filter GetFilter() const;
346 
350  USD_API
351  std::vector<UsdPrimCompositionQueryArc> GetCompositionArcs();
352 
353 private:
354  UsdPrim _prim;
355  Filter _filter;
356  PcpPrimIndex _expandedPrimIndex;
357  std::vector<UsdPrimCompositionQueryArc> _unfilteredArcs;
358 };
359 
360 
361 PXR_NAMESPACE_CLOSE_SCOPE
362 
363 #endif // PXR_USD_USD_PRIM_COMPOSITION_QUERY_H
364 
This represents a composition arc that is returned by a UsdPrimCompositionQuery.
USD_API bool GetIntroducingListEditor(SdfReferenceEditorProxy *editor, SdfReference *ref) const
Gets the list editor and authored SdfReference value that introduces this arc to the composition grap...
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:75
Represents a set of list editing operations.
PcpNode represents a node in an expression tree for compositing scene description.
Definition: node.h:67
USD_API PcpArcType GetArcType() const
Returns the arc type.
HasSpecsFilter
Choices for filtering composition arcs on whether the node contributes specs to the prim...
DependencyTypeFilter dependencyTypeFilter
Filters by dependency type, direct or ancestral.
USD_API void SetFilter(const Filter &filter)
Change the filter for this query.
USD_API PcpNodeRef GetIntroducingNode() const
Returns the node that introduces this arc into composition graph.
static USD_API UsdPrimCompositionQuery GetDirectReferences(const UsdPrim &prim)
Returns a prim composition query for the given prim with a preset filter that only returns reference ...
ArcTypeFilter
Choices for filtering composition arcs based on arc type.
static USD_API UsdPrimCompositionQuery GetDirectInherits(const UsdPrim &prim)
Returns a prim composition query for the given prim with a preset filter that only returns inherit ar...
USD_API bool IsAncestral() const
Returns whether this arc is ancestral, i.e.
USD_API std::vector< UsdPrimCompositionQueryArc > GetCompositionArcs()
Return a list of composition arcs for this query&#39;s prim using the current query filter.
USD_API bool IsImplicit() const
Returns whether this arc was implicitly added to this prim meaning it exists because of the introduct...
Represents a payload and all its meta data.
Definition: payload.h:60
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:132
ArcIntroducedFilter
Choices for filtering composition arcs based on where the arc is introduced.
ArcTypeFilter arcTypeFilter
Filters by arc type.
USD_API SdfPath GetIntroducingPrimPath() const
Returns the path of the prim that introduces this arc to the composition graph within the layer in wh...
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
DependencyTypeFilter
Choices for filtering composition arcs on dependency type.
USD_API bool IsIntroducedInRootLayerPrimSpec() const
Returns whether the composition opinion that introduces this arc is authored directly on the prim&#39;s p...
Object for making optionally filtered composition queries about a prim.
Represents a reference and all its meta data.
Definition: reference.h:76
Aggregate filter for filtering composition arcs by the previously defined criteria.
USD_API bool HasSpecs() const
Returns whether the target node of this arc contributes any local spec opinions that are composed for...
static USD_API UsdPrimCompositionQuery GetDirectRootLayerArcs(const UsdPrim &prim)
Returns a prim composition query for the given prim with a preset filter that only returns direct arc...
HasSpecsFilter hasSpecsFilter
Filters by whether the arc provides specs for the prim.
USD_API bool IsIntroducedInRootLayerStack() const
Returns whether the composition opinion that introduces this arc is authored in the root layer stack...
ArcIntroducedFilter arcIntroducedFilter
Filters by where the arc is introduced.
USD_API SdfLayerHandle GetIntroducingLayer() const
Returns the specific layer in the layer stack that adds this arc to the composition graph...
USD_API Filter GetFilter() const
Return a copy of the current filter parameters.
USD_API UsdPrimCompositionQuery(const UsdPrim &prim, const Filter &filter=Filter())
Create a prim composition query for the with the given option filter.
USD_API PcpNodeRef GetTargetNode() const
Returns the targeted node of this composition arc.
PcpArcType
Describes the type of arc connecting two nodes in the prim index.
Definition: types.h:46