hydraObserver.h
1 //
2 // Copyright 2022 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_IMAGING_USDVIEWQ_HYDRA_OBSERVER_H
25 #define PXR_USD_IMAGING_USDVIEWQ_HYDRA_OBSERVER_H
26 
27 #include "pxr/imaging/hd/sceneIndex.h"
28 #include "pxr/usdImaging/usdviewq/api.h"
29 
30 
31 PXR_NAMESPACE_OPEN_SCOPE
32 
46 {
47 public:
48 
49  USDVIEWQ_API
50  UsdviewqHydraObserver() = default;
51 
52  USDVIEWQ_API
54 
58  USDVIEWQ_API
59  static
60  std::vector<std::string> GetRegisteredSceneIndexNames();
61 
62 
65  USDVIEWQ_API
66  bool TargetToNamedSceneIndex(const std::string &name);
67 
68  using IndexList = std::vector<size_t> ;
69 
76  USDVIEWQ_API
77  bool TargetToInputSceneIndex(const IndexList &inputIndices);
78 
79 
82  USDVIEWQ_API
83  std::string GetDisplayName();
84 
92  USDVIEWQ_API
93  std::vector<std::string> GetInputDisplayNames(
94  const IndexList &inputIndices);
95 
98  USDVIEWQ_API
99  SdfPathVector GetChildPrimPaths(const SdfPath &primPath);
100 
103  USDVIEWQ_API
104  HdSceneIndexPrim GetPrim(const SdfPath &primPath);
105 
108  struct NoticeEntry
109  {
111  : added(entries)
112  {}
113 
115  : removed(entries)
116  {}
117 
119  : dirtied(entries)
120  {}
121 
122  NoticeEntry(const NoticeEntry &other) = default;
123 
127  };
128 
129  using NoticeEntryVector = std::vector<NoticeEntry>;
130 
133  USDVIEWQ_API
134  bool HasPendingNotices();
135 
138  USDVIEWQ_API
139  NoticeEntryVector GetPendingNotices();
140 
142  USDVIEWQ_API
143  void ClearPendingNotices();
144 
145 private:
146 
147  bool _Target(const HdSceneIndexBaseRefPtr &sceneIndex);
148 
149  class _Observer : public HdSceneIndexObserver
150  {
151  public:
152  USDVIEWQ_API
153  void PrimsAdded(
154  const HdSceneIndexBase &sender,
155  const AddedPrimEntries &entries) override;
156 
157  USDVIEWQ_API
158  void PrimsRemoved(
159  const HdSceneIndexBase &sender,
160  const RemovedPrimEntries &entries) override;
161 
162  USDVIEWQ_API
163  void PrimsDirtied(
164  const HdSceneIndexBase &sender,
165  const DirtiedPrimEntries &entries) override;
166 
167  NoticeEntryVector notices;
168  };
169 
170  HdSceneIndexBaseRefPtr _sceneIndex;
171  _Observer _observer;
172 };
173 
174 PXR_NAMESPACE_CLOSE_SCOPE
175 
176 #endif
USDVIEWQ_API NoticeEntryVector GetPendingNotices()
Returns (and clears) any accumulated scene change notices.
USDVIEWQ_API bool TargetToNamedSceneIndex(const std::string &name)
Target this observer to a scene index with the given name previously registered via HdSceneIndexNameR...
USDVIEWQ_API HdSceneIndexPrim GetPrim(const SdfPath &primPath)
Returns the prim type and data source for the specified primPath for the actively observer scene inde...
Aggregate of HdSceneIndexObserver entry types for easier binding to python.
USDVIEWQ_API std::string GetDisplayName()
Returns the display name of the actively targeted scene index.
USDVIEWQ_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath)
Returns the paths of the immediate children of the specified primPath for the actively observer scene...
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:49
Observer of scene data.
Abstract interface to scene data.
Definition: sceneIndex.h:62
USDVIEWQ_API std::vector< std::string > GetInputDisplayNames(const IndexList &inputIndices)
Starting from the currently targeted HdSceneIndex, each value in the inputIndices is treated as an in...
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
USDVIEWQ_API bool TargetToInputSceneIndex(const IndexList &inputIndices)
Starting from the currently targeted HdSceneIndex, each value in the inputIndices is treated as an in...
USDVIEWQ_API bool HasPendingNotices()
Returns true if there are pending scene change notices.
Abstracts pieces necessary for implementing a Hydra Scene Browser in a manner convenient for exposing...
Definition: hydraObserver.h:45
USDVIEWQ_API void ClearPendingNotices()
Clears any accumulated scene change notices.
static USDVIEWQ_API std::vector< std::string > GetRegisteredSceneIndexNames()
Returns the names of scene indices previously registered with HdSceneIndexNameRegistry.